Skip to content

Commit

Permalink
Fix: ignore unmergable imports when checking no-duplicate-imports (fixes
Browse files Browse the repository at this point in the history
 eslint#13180) & Fix: Ignore re-export all in no-duplicate-imports (fixes eslint#12760)
  • Loading branch information
boutahlilsoufiane committed May 27, 2021
1 parent 9d3fd4d commit f97848b
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions tests/lib/rules/no-duplicate-imports.js
Expand Up @@ -26,8 +26,6 @@ ruleTester.run("no-duplicate-imports", rule, {
"import * as Foobar from \"async\";",
"import \"foo\"",
"import os from \"os\";\nexport { something } from \"os\";",
"import * as bar from \"os\";\nimport { baz } from \"os\";",
"import foo, * as bar from \"os\";\nimport { baz } from \"os\";",
{
code: "import os from \"os\";\nexport { hello } from \"hello\";",
options: [{ includeExports: true }]
Expand All @@ -47,14 +45,6 @@ ruleTester.run("no-duplicate-imports", rule, {
{
code: "import { merge } from \"lodash-es\";\nexport { merge as lodashMerge }",
options: [{ includeExports: true }]
},
{
code: "import os from \"os\";\nexport * from \"os\";",
options: [{ includeExports: true }]
},
{
code: "export { something } from \"os\";\nexport * from \"os\";",
options: [{ includeExports: true }]
}
],
invalid: [
Expand All @@ -63,22 +53,11 @@ ruleTester.run("no-duplicate-imports", rule, {
errors: [{ messageId: "import", data: { module: "fs" }, type: "ImportDeclaration" }]
},
{
code: "import { merge } from \"lodash-es\";\nimport { find } from \"lodash-es\";",
errors: [{ messageId: "import", data: { module: "lodash-es" }, type: "ImportDeclaration" }]
},
{
code: "import { merge } from \"lodash-es\";\nimport _ from \"lodash-es\";",
code: "import { merge } from \"lodash-es\";import { find } from \"lodash-es\";",
errors: [{ messageId: "import", data: { module: "lodash-es" }, type: "ImportDeclaration" }]
},
{
code: "import os from \"os\";\nimport { something } from \"os\";\nimport * as foobar from \"os\";",
errors: [
{ messageId: "import", data: { module: "os" }, type: "ImportDeclaration" },
{ messageId: "import", data: { module: "os" }, type: "ImportDeclaration" }
]
},
{
code: "import * as modns from \"lodash-es\";\nimport { merge } from \"lodash-es\";\nimport { baz } from \"lodash-es\";",
code: "import { merge } from \"lodash-es\";import _ from \"lodash-es\";",
errors: [{ messageId: "import", data: { module: "lodash-es" }, type: "ImportDeclaration" }]
},
{
Expand All @@ -87,7 +66,7 @@ ruleTester.run("no-duplicate-imports", rule, {
errors: [{ messageId: "export", data: { module: "os" }, type: "ExportNamedDeclaration" }]
},
{
code: "import os from \"os\";\nexport { os as foobar } from \"os\";\nexport { something } from \"os\";",
code: "import os from \"os\"; export { os as foobar } from \"os\";\nexport { something } from \"os\";",
options: [{ includeExports: true }],
errors: [
{ messageId: "exportAs", data: { module: "os" }, type: "ExportNamedDeclaration" },
Expand All @@ -101,12 +80,7 @@ ruleTester.run("no-duplicate-imports", rule, {
errors: [{ messageId: "exportAs", data: { module: "os" }, type: "ExportNamedDeclaration" }]
},
{
code: "export * from \"os\";\nexport * from \"os\";",
options: [{ includeExports: true }],
errors: [{ messageId: "export", data: { module: "os" }, type: "ExportAllDeclaration" }]
},
{
code: "import \"os\";\nexport * from \"os\";",
code: "import os from \"os\";\nexport * from \"os\";",
options: [{ includeExports: true }],
errors: [{ messageId: "exportAs", data: { module: "os" }, type: "ExportAllDeclaration" }]
}
Expand Down

0 comments on commit f97848b

Please sign in to comment.