selaux/eslint-plugin-filenames

Feature request: filenames/match-imported

steve-taylor opened this issue · 2 comments

It would be nice to have a new rule, filenames/match-imported, that is similar to filenames/match-exported but works on imports. When used together, this would prevent renaming across the module boundary.

For example:

// src/components/foo-bar.js
const FooBar = ({foo, bar}) => (
    <ul>
        <li>{foo}</li>
        <li>{bar}</li>
    </ul>
);

export default FooBar;
// src/widgets/foo-bar-widget.js (good)
import FooBar from '../components/foo-bar';
// src/widgets/foo-bar-widget.js (bad)
import FooBarComponent from '../components/foo-bar';

This would add a lot of value in combination with filenames/match-exported.
When refactoring, it's easy to forget to rename the variable of the import statement, which can result in a wrong meaning if the meaning of the refactored file has changed. This is especially true when IDEs help to rename import paths automatically without a need to have a look at those files.