-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I often see things such as:
import parseDate from './types/date';
import float from './types/parseFloat';The disparity between the default import name (parseDate) and file name (date) often indicates that one or the other is named inappropriately. In the first case, thats the file name. In the second case, thats the local variable name.
Valid code:
import parseFloat from './types/parseFloat';
import parseDate from './types/parseDate';Invalid code:
import parseDate from './types/date';
import float from './types/parseFloat';There is no way to enforce a right name, e.g. user could just as well end up with:
import date from './types/date';
import float from './types/float';However, I would argue that these issues are easy to notice in the code. Having this rule would prevent lazy developers from using a better variable name in a local file and ignore the need to rename the file and other references.
Furthermore, this enables easier code inspection (because it is easy to recognise what a variable represents when it is being used consistently between many files).