import/no-named-default Style
它的作用
报告将默认导出作为本地命名导入的用法。
为什么这不好?
理由:这种语法就是为了以表达性的方式导入默认导出,让我们用起来吧。
示例
以下是此规则的错误代码示例:
js
// message: 将导出的名称 'bar' 作为默认导出的标识符。
import { default as foo } from "./foo.js";
import { default as foo, bar } from "./foo.js";以下是此规则的正确代码示例:
js
import foo from "./foo.js";
import foo, { bar } from "./foo.js";如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["import"],
"rules": {
"import/no-named-default": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["import"],
rules: {
"import/no-named-default": "error",
},
});bash
oxlint --deny import/no-named-default --import-plugin版本
此规则在 v0.15.3 中添加。
