默认导出
按照设计,"restrictedNamedExports"
选项不会禁止 export default
声明。如果将 "default"
配置为受限名称,则该限制将仅适用于命名的导出声明。
By design, the "restrictedNamedExports"
option doesn't disallow export default
declarations. If you configure "default"
as a restricted name, that restriction will apply only to named export declarations.
"restrictedNamedExports": ["default"]
选项的其他错误代码示例:
Examples of additional incorrect code for the "restrictedNamedExports": ["default"]
option:
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default"] }]*/
function foo() {}
export { foo as default };
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default"] }]*/
export { default } from "some_module";
"restrictedNamedExports": ["default"]
选项的附加正确代码示例:
Examples of additional correct code for the "restrictedNamedExports": ["default"]
option:
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default", "foo"] }]*/
export default function foo() {}