@@ -129,29 +129,32 @@ ruleTester.run('no-duplicates', rule, {
129
129
errors : [ '\'./foo\' imported multiple times.' , '\'./foo\' imported multiple times.' ] ,
130
130
} ) ,
131
131
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
+ } ) ,
139
141
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
+ } ) ,
147
149
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
+ ] ) ) ,
155
158
156
159
test ( {
157
160
code : "import {x} from './foo'; import {} from './foo'; import {/*c*/} from './foo'; import {y} from './foo'" ,
0 commit comments