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.
For example, this would be considered incorrect:
import MyButton from './ui/Button.js'; // NOT OK
because the package is called "Button", not "MyButton".
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
.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.