-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(no-duplicates): remove extra space when merging import specifiers #3246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6951ed7
25ecae4
89772b1
fd031c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,20 +53,20 @@ ruleTester.run('no-duplicates', rule, { | |
| invalid: [ | ||
| test({ | ||
| code: "import { x } from './foo'; import { y } from './foo'", | ||
| output: "import { x , y } from './foo'; ", | ||
| output: "import { x ,y} from './foo'; ", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems wrong to me - either both x and y should have spaces between them and the closest curly brace, or neither should. |
||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| }), | ||
|
|
||
| test({ | ||
| code: "import {x} from './foo'; import {y} from './foo'; import { z } from './foo'", | ||
| output: "import {x,y, z } from './foo'; ", | ||
| output: "import {x,y,z} from './foo'; ", | ||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| }), | ||
|
|
||
| // ensure resolved path results in warnings | ||
| test({ | ||
| code: "import { x } from './bar'; import { y } from 'bar';", | ||
| output: "import { x , y } from './bar'; ", | ||
| output: "import { x ,y} from './bar'; ", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here |
||
| settings: { | ||
| 'import/resolve': { | ||
| paths: [path.join(process.cwd(), 'tests', 'files')], | ||
|
|
@@ -107,7 +107,7 @@ ruleTester.run('no-duplicates', rule, { | |
|
|
||
| test({ | ||
| code: "import type { x } from './foo'; import type { y } from './foo'", | ||
| output: "import type { x , y } from './foo'; ", | ||
| output: "import type { x ,y} from './foo'; ", | ||
| parser: parsers.BABEL_OLD, | ||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| }), | ||
|
|
@@ -145,15 +145,15 @@ ruleTester.run('no-duplicates', rule, { | |
| // #2347: duplicate identifiers should be removed | ||
| test({ | ||
| code: "import {a,b} from './foo'; import { b, c } from './foo'; import {b,c,d} from './foo'", | ||
| output: "import {a,b, c ,d} from './foo'; ", | ||
| output: "import {a,b,c,d} from './foo'; ", | ||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| parser, | ||
| }), | ||
|
|
||
| // #2347: duplicate identifiers should be removed, but not if they are adjacent to comments | ||
| test({ | ||
| code: "import {a} from './foo'; import { a/*,b*/ } from './foo'", | ||
| output: "import {a, a/*,b*/ } from './foo'; ", | ||
| output: "import {a,a/*,b*/} from './foo'; ", | ||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| parser, | ||
| }), | ||
|
|
@@ -186,7 +186,8 @@ ruleTester.run('no-duplicates', rule, { | |
|
|
||
| test({ | ||
| code: "import './foo'; import { /*x*/} from './foo'; import {//y\n} from './foo'; import {z} from './foo'", | ||
| output: "import { /*x*///y\nz} from './foo'; ", | ||
| output: "import {/*x*///y\nz} from './foo'; ", | ||
|
|
||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| }), | ||
|
|
||
|
|
@@ -373,7 +374,7 @@ import {x,y} from './foo' | |
| // #2027 long import list generate empty lines | ||
| test({ | ||
| code: "import { Foo } from './foo';\nimport { Bar } from './foo';\nexport const value = {}", | ||
| output: "import { Foo , Bar } from './foo';\nexport const value = {}", | ||
| output: "import { Foo ,Bar} from './foo';\nexport const value = {}", | ||
| errors: ['\'./foo\' imported multiple times.', '\'./foo\' imported multiple times.'], | ||
| }), | ||
|
|
||
|
|
@@ -402,22 +403,7 @@ import {x,y} from './foo' | |
| ${''} | ||
| export default TestComponent; | ||
| `, | ||
| output: ` | ||
| import { | ||
| DEFAULT_FILTER_KEYS, | ||
| BULK_DISABLED, | ||
| ${''} | ||
| BULK_ACTIONS_ENABLED | ||
| } from '../constants'; | ||
| import React from 'react'; | ||
| ${''} | ||
| const TestComponent = () => { | ||
| return <div> | ||
| </div>; | ||
| } | ||
| ${''} | ||
| export default TestComponent; | ||
| `, | ||
| output: `\n import {\n DEFAULT_FILTER_KEYS,\n BULK_DISABLED,\n BULK_ACTIONS_ENABLED} from '../constants';\n import React from 'react';\n ${''}\n const TestComponent = () => {\n return <div>\n </div>;\n }\n ${''}\n export default TestComponent;\n `, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm confused, this now has a newline after the |
||
| errors: ["'../constants' imported multiple times.", "'../constants' imported multiple times."], | ||
| ...jsxConfig, | ||
| }), | ||
|
|
@@ -439,16 +425,7 @@ import {x,y} from './foo' | |
| } from 'bar'; | ||
|
|
||
| `, | ||
| output: ` | ||
| import {A1,B1,C1} from 'foo'; | ||
| ${''} | ||
| import { | ||
| A2, | ||
| ${''} | ||
| B2, | ||
| C2} from 'bar'; | ||
| ${''} | ||
| `, | ||
| output: `\n import {A1,B1,C1} from 'foo';\n ${''}\n import {\n A2,\n B2,C2} from 'bar';\n ${''}\n `, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here |
||
| errors: [ | ||
| { | ||
| message: "'foo' imported multiple times.", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the newlines? that's not behavior the rule has had before.