Skip to content

Commit

Permalink
[New] no-named-as-default: support arbitrary module namespace names
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Jan 22, 2022
1 parent 0108aff commit 6bd3c70
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/src/rules/no-named-as-default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, SYNTAX_CASES } from '../utils';
import { test, testVersion, SYNTAX_CASES } from '../utils';
import { RuleTester } from 'eslint';

const ruleTester = new RuleTester();
Expand All @@ -21,6 +21,12 @@ ruleTester.run('no-named-as-default', rule, {
test({ code: 'export default from "./bar";',
parser: require.resolve('babel-eslint') }),

// es2022: Arbitrary module namespae identifier names
testVersion('>= 8.7', () => ({
code: 'import bar, { foo } from "./export-default-string-and-named"',
parserOptions: { ecmaVersion: 2022 },
})),

...SYNTAX_CASES,
],

Expand Down Expand Up @@ -57,5 +63,23 @@ ruleTester.run('no-named-as-default', rule, {
type: 'Literal',
}],
}),

// es2022: Arbitrary module namespae identifier names
testVersion('>= 8.7', () => ({
code: 'import foo from "./export-default-string-and-named"',
errors: [{
message: 'Using exported name \'foo\' as identifier for default export.',
type: 'ImportDefaultSpecifier',
}],
parserOptions: { ecmaVersion: 2022 },
})),
testVersion('>= 8.7', () => ({
code: 'import foo, { foo as bar } from "./export-default-string-and-named"',
errors: [{
message: 'Using exported name \'foo\' as identifier for default export.',
type: 'ImportDefaultSpecifier',
}],
parserOptions: { ecmaVersion: 2022 },
})),
],
});

0 comments on commit 6bd3c70

Please sign in to comment.