Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d9ca6a2

Browse files
committedOct 21, 2022
Add multiple parsers for test cases
1 parent f9e3f43 commit d9ca6a2

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed
 

‎tests/src/rules/no-duplicates.js

+24-21
Original file line numberDiff line numberDiff line change
@@ -129,29 +129,32 @@ ruleTester.run('no-duplicates', rule, {
129129
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
130130
}),
131131

132-
// #2347: duplicate identifiers should be removed
133-
test({
134-
code: "import {a} from './foo'; import { a } from './foo'",
135-
output: "import {a} from './foo'; ",
136-
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
137-
parser: parsers.BABEL_OLD, // Needed to avoid "A fatal parsing error occurred: Parsing error: Identifier 'a' has already been declared"
138-
}),
132+
// These test cases use duplicate import identifiers, which causes a fatal parsing error using ESPREE (default) and TS_OLD.
133+
...[parsers.BABEL_OLD, parsers.TS_NEW].flatMap((parser => [
134+
// #2347: duplicate identifiers should be removed
135+
test({
136+
code: "import {a} from './foo'; import { a } from './foo'",
137+
output: "import {a} from './foo'; ",
138+
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
139+
parser,
140+
}),
139141

140-
// #2347: duplicate identifiers should be removed
141-
test({
142-
code: "import {a,b} from './foo'; import { b, c } from './foo'; import {b,c,d} from './foo'",
143-
output: "import {a,b, c ,d} from './foo'; ",
144-
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
145-
parser: parsers.BABEL_OLD, // Needed to avoid "A fatal parsing error occurred: Parsing error: Identifier 'b' has already been declared"
146-
}),
142+
// #2347: duplicate identifiers should be removed
143+
test({
144+
code: "import {a,b} from './foo'; import { b, c } from './foo'; import {b,c,d} from './foo'",
145+
output: "import {a,b, c ,d} from './foo'; ",
146+
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
147+
parser,
148+
}),
147149

148-
// #2347: duplicate identifiers should be removed, but not if they are adjacent to comments
149-
test({
150-
code: "import {a} from './foo'; import { a/*,b*/ } from './foo'",
151-
output: "import {a, a/*,b*/ } from './foo'; ",
152-
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
153-
parser: parsers.BABEL_OLD, // Needed to avoid "A fatal parsing error occurred: Parsing error: Identifier 'a' has already been declared"
154-
}),
150+
// #2347: duplicate identifiers should be removed, but not if they are adjacent to comments
151+
test({
152+
code: "import {a} from './foo'; import { a/*,b*/ } from './foo'",
153+
output: "import {a, a/*,b*/ } from './foo'; ",
154+
errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'],
155+
parser,
156+
}),
157+
])),
155158

156159
test({
157160
code: "import {x} from './foo'; import {} from './foo'; import {/*c*/} from './foo'; import {y} from './foo'",

0 commit comments

Comments
 (0)
Please sign in to comment.