Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Oct 23, 2021
1 parent 65e18bd commit ebfff94
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/src/rules/extensions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RuleTester } from 'eslint';
import rule from 'rules/extensions';
import { test, testFilePath } from '../utils';
import { getTSParsers, test, testFilePath } from '../utils';

const ruleTester = new RuleTester();

Expand Down Expand Up @@ -597,3 +597,34 @@ ruleTester.run('extensions', rule, {
}),
],
});

describe('TypeScript', () => {
getTSParsers()
// Type-only imports were added in TypeScript ESTree 2.23.0
.filter((parser) => parser !== require.resolve('typescript-eslint-parser'))
.forEach((parser) => {
ruleTester.run(`${parser}: extensions ignore type-only`, rule, {
valid: [
test({
code: 'import type { T } from "./typescript-declare";',
options: [
'always',
{ ts: 'never', tsx: 'never', js: 'never', jsx: 'never' },
],
parser,
}),
],
invalid: [
test({
code: 'import { T } from "./typescript-declare";',
errors: ['Missing file extension for "./typescript-declare"'],
options: [
'always',
{ ts: 'never', tsx: 'never', js: 'never', jsx: 'never' },
],
parser,
}),
],
});
});
});

0 comments on commit ebfff94

Please sign in to comment.