简体   繁体   中英

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.

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?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM