Javascript 在某些文件上导入默认导出模块时,强制eslint使用默认导出模块的原始名称
在编写代码时,我们的团队始终使用适当的编码标准来遵守规则和规定。我们用过。它很好地解决了我们的一些问题,但不是全部 以下面这个例子为例: Foo.jsJavascript 在某些文件上导入默认导出模块时,强制eslint使用默认导出模块的原始名称,javascript,eslint,Javascript,Eslint,在编写代码时,我们的团队始终使用适当的编码标准来遵守规则和规定。我们用过。它很好地解决了我们的一些问题,但不是全部 以下面这个例子为例: Foo.js const Foo = "Foo" export default Foo Foo.jsx import Bar from './foo'; // This still works. // It can cause confusion. // I want to use the original exported default name
const Foo = "Foo"
export default Foo
Foo.jsx
import Bar from './foo';
// This still works.
// It can cause confusion.
// I want to use the original exported default name Foo instead of Bar
// otherwise show some error in the Code Editor
我希望使用模块或文件的默认导出的原始名称。否则,在代码编辑器中抛出一些错误
如果有人能帮忙,我将不胜感激。
提前感谢。坏消息是,目前没有选择
好消息是,有一个积极的公关正是这个功能,它只需要得到批准,该功能已准备就绪。您可以跟踪PR。我认为您要做的是使用ESLint中的以下规则: 您可以在
.eslintrc
文件中激活此选项:
{"plugins": [ "import" ], "rules": { import/no-named-as-default }}
有关更多信息,您可以转到导入