![](/img/trans.png)
[英]ESlint rule that detects that a variable and a function has the same name in Javascript?
[英]eslint rule to required imported objects to have the same name as file?
我似乎記得有一個規則,但我找不到它。 基本上要求導入的對象與 package 具有相同的名稱。
例如,這將被認為是不正確的:
import MyButton from './ui/Button.js'; // NOT OK
因為 package 被稱為“按鈕”,而不是“我的按鈕”。
這會很好:
import Button from './ui/Button.js'; // OK
甚至可能是這樣:
import UserList from './ui/user-list.js'; // OK
知道是否可以為此使用規則嗎?
您要查找的規則是filenames/match-exported
。
https://github.com/selaux/eslint-plugin-filenames#matching-exported-values-match-exported
有一些關於這個規則想法的建議:
但是他們都還沒有進入eslint
版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.