Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions e2e/__snapshots__/snapshot.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

exports[`TSGoLint E2E Snapshot Tests > should correctly evaluate project references 1`] = `[]`;

exports[`TSGoLint E2E Snapshot Tests > should correctly lint files not inside a project 1`] = `
[
{
"file_path": "fixtures/with-unmatched-files/src/index.ts",
"fixes": [],
"message": {
"description": "Unsafe argument of type any assigned to a parameter of type string.",
"id": "unsafeArgument",
},
"range": {
"end": 45,
"pos": 36,
},
"rule": "no-unsafe-argument",
"suggestions": [],
},
{
"file_path": "fixtures/with-unmatched-files/test.ts",
"fixes": [],
"message": {
"description": "Unsafe argument of type any assigned to a parameter of type string.",
"id": "unsafeArgument",
},
"range": {
"end": 45,
"pos": 36,
},
"rule": "no-unsafe-argument",
"suggestions": [],
},
]
`;

exports[`TSGoLint E2E Snapshot Tests > should generate consistent diagnostics snapshot 1`] = `
[
{
Expand Down
3 changes: 3 additions & 0 deletions e2e/fixtures/with-unmatched-files/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function foo(_arg0: string) {}

foo('' as any);
3 changes: 3 additions & 0 deletions e2e/fixtures/with-unmatched-files/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function foo(_arg0: string) {}

foo('' as any);
4 changes: 4 additions & 0 deletions e2e/fixtures/with-unmatched-files/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"compilerOptions": {},
"include": ["src/**/*"]
}
19 changes: 19 additions & 0 deletions e2e/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,23 @@ describe('TSGoLint E2E Snapshot Tests', () => {

expect(diagnostics).toMatchSnapshot();
});

it('should correctly lint files not inside a project', async () => {
const testFiles = await getTestFiles('with-unmatched-files');
expect(testFiles.length).toBeGreaterThan(0);

const config = generateConfig(testFiles, ['no-unsafe-argument']);

const env = { ...process.env, GOMAXPROCS: '1' };

const output = execFileSync(TSGOLINT_BIN, ['headless'], {
input: config,
env,
});

let diagnostics = parseHeadlessOutput(output);
diagnostics = sortDiagnostics(diagnostics);

expect(diagnostics).toMatchSnapshot();
});
});
Loading