[英]eslint rule to required imported objects to have the same name as file?
I seem to remember there was a rule for this but I can't find it.我似乎记得有一个规则,但我找不到它。 Basically something to require that imported objects have the same name as the package.
基本上要求导入的对象与 package 具有相同的名称。
For example, this would be considered incorrect:例如,这将被认为是不正确的:
import MyButton from './ui/Button.js'; // NOT OK
because the package is called "Button", not "MyButton".因为 package 被称为“按钮”,而不是“我的按钮”。
This would be fine:这会很好:
import Button from './ui/Button.js'; // OK
Maybe even this:甚至可能是这样:
import UserList from './ui/user-list.js'; // OK
Any idea if a rule can be used for this?知道是否可以为此使用规则吗?
The rule your looking for is filenames/match-exported
.您要查找的规则是
filenames/match-exported
。
https://github.com/selaux/eslint-plugin-filenames#matching-exported-values-match-exported https://github.com/selaux/eslint-plugin-filenames#matching-exported-values-match-exported
There are a few proposals out there for this rule idea:有一些关于这个规则想法的建议:
But none of them have made it into an eslint
release yet.但是他们都还没有进入
eslint
版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.