noExportedImports
诊断类别:lint/nursery/noExportedImports
¥Diagnostic Category: lint/nursery/noExportedImports
自从:v1.9.0
¥Since: v1.9.0
禁止导出导入的变量。
¥Disallow exporting an imported variable.
在 JavaScript 中,你可以使用 export from
重新导出变量,也可以先导入变量,然后使用常规 export
导出变量。
¥In JavaScript, you can re-export a variable either by using export from
or
by first importing the variable and then exporting it with a regular export
.
你可能更喜欢使用第一种方法,因为它清楚地传达了重新导出导入的意图,并且可以使静态分析更容易。
¥You may prefer to use the first approach, as it clearly communicates the intention to re-export an import, and can make static analysis easier.
¥Examples
¥Invalid
code-block.js:1:10 lint/nursery/noExportedImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ An import should not be exported. Use export from instead.
> 1 │ import { A } from “mod”;
│ ^
2 │ export { A };
3 │
ℹ export from makes it clearer that the intention is to re-export a variable.
code-block.js:1:8 lint/nursery/noExportedImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ An import should not be exported. Use export from instead.
> 1 │ import * as ns from “mod”;
│ ^^^^^^^
2 │ export { ns };
3 │
ℹ export from makes it clearer that the intention is to re-export a variable.
code-block.js:1:8 lint/nursery/noExportedImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ An import should not be exported. Use export from instead.
> 1 │ import D from “mod”;
│ ^
2 │ export { D };
3 │
ℹ export from makes it clearer that the intention is to re-export a variable.
¥Valid
¥Related links