简体   繁体   English

eslint 规则要求导入的对象与文件同名?

[英]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?知道是否可以为此使用规则吗?

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.

相关问题 检测到一个变量和一个 function 在 Javascript 中具有相同名称的 ESlint 规则? - ESlint rule that detects that a variable and a function has the same name in Javascript? 数组和对象中的eslint的自定义缩进规则 - Custom indentation rule for eslint in arrays and objects ESLint规则,通过创建同名的const来防止重写功能(尤其是在赋值期间) - ESLint rule to prevent overriding function by creating a const of the same name (especially during assignment) 'eslint'无法使用文件名 - 'eslint' is not working with the file name 是否包括相同ESLint规则的错误和警告? - Including both errors and warnings for same ESLint rule? ESLint 规则:文件的最大嵌套路径 - ESLint rule: maximum nesting path for file 在 Eslint 配置文件中禁用报价规则 - Disable quote rule in Eslint config file 对象中的 ES6 风格简写函数是否有 ESLint 规则? - Is there an ESLint rule for ES6 style shorthanded functions in objects? 确保最小变量名长度的 Eslint 规则,但不在 JSON 上? - Eslint rule to ensure minimum variable name length, but not on JSON? ESLInt插件和ESLInt规则有什么区别? 要创建自定义规则,我们是否必须首先创建自己的插件? - What's the difference between an ESLInt plugin and an ESLInt rule? To create a customized rule, do we have to create our own plugin first?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM