]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-duplicate-imports.js
2 * @fileoverview Tests for no-duplicate-imports.
3 * @author Simen Bekkhus
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/no-duplicate-imports"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester({ parserOptions
: { ecmaVersion
: 6, sourceType
: "module" } });
21 ruleTester
.run("no-duplicate-imports", rule
, {
23 "import os from \"os\";\nimport fs from \"fs\";",
24 "import { merge } from \"lodash-es\";",
25 "import _, { merge } from \"lodash-es\";",
26 "import * as Foobar from \"async\";",
28 "import os from \"os\";\nexport { something } from \"os\";",
30 code
: "import os from \"os\";\nexport { hello } from \"hello\";",
31 options
: [{ includeExports
: true }]
34 code
: "import os from \"os\";\nexport * from \"hello\";",
35 options
: [{ includeExports
: true }]
38 code
: "import os from \"os\";\nexport { hello as hi } from \"hello\";",
39 options
: [{ includeExports
: true }]
42 code
: "import os from \"os\";\nexport default function(){};",
43 options
: [{ includeExports
: true }]
46 code
: "import { merge } from \"lodash-es\";\nexport { merge as lodashMerge }",
47 options
: [{ includeExports
: true }]
52 code
: "import \"fs\";\nimport \"fs\"",
53 errors
: [{ messageId
: "import", data
: { module
: "fs" }, type
: "ImportDeclaration" }]
56 code
: "import { merge } from \"lodash-es\";import { find } from \"lodash-es\";",
57 errors
: [{ messageId
: "import", data
: { module
: "lodash-es" }, type
: "ImportDeclaration" }]
60 code
: "import { merge } from \"lodash-es\";import _ from \"lodash-es\";",
61 errors
: [{ messageId
: "import", data
: { module
: "lodash-es" }, type
: "ImportDeclaration" }]
64 code
: "export { os } from \"os\";\nexport { something } from \"os\";",
65 options
: [{ includeExports
: true }],
66 errors
: [{ messageId
: "export", data
: { module
: "os" }, type
: "ExportNamedDeclaration" }]
69 code
: "import os from \"os\"; export { os as foobar } from \"os\";\nexport { something } from \"os\";",
70 options
: [{ includeExports
: true }],
72 { messageId
: "exportAs", data
: { module
: "os" }, type
: "ExportNamedDeclaration" },
73 { messageId
: "export", data
: { module
: "os" }, type
: "ExportNamedDeclaration" },
74 { messageId
: "exportAs", data
: { module
: "os" }, type
: "ExportNamedDeclaration" }
78 code
: "import os from \"os\";\nexport { something } from \"os\";",
79 options
: [{ includeExports
: true }],
80 errors
: [{ messageId
: "exportAs", data
: { module
: "os" }, type
: "ExportNamedDeclaration" }]
83 code
: "import os from \"os\";\nexport * from \"os\";",
84 options
: [{ includeExports
: true }],
85 errors
: [{ messageId
: "exportAs", data
: { module
: "os" }, type
: "ExportAllDeclaration" }]