selaux / eslint-plugin-filenames

Eslint plugin to check filenames.
318 stars 35 forks source link

match-exported & index clash #26

Closed saiichihashimoto closed 1 year ago

saiichihashimoto commented 6 years ago

Currently, with this setting:

"filenames/match-exported": [ 2, null, "\\.web$" ]

This code:

export default function variableName;

Is allowed if it's named:

variableName.js
variableName.web.js
variableName/index.js

But not:

variableName/index.web.js

Usually I have a variableName.js. Then I realize I need a variableName.web.js. Then I want to extract common code into some utils.js that are only related to them, so I make a variableName folder and move them all in, renaming to variableName/index.js and variableName/index.web.js along the way. This is when filenames/match-exported gets upset.

I think whatever is detecting the "index" file is looking for "index.js", specifically.

selaux commented 6 years ago

Yes. We are looking specifically for the index.js file. Rationale behind this is that only if the file is actually called index.js, we can require the directory, thus the export in the file should be named like the directory. I understand your usecase: different index files for node/browser. But I'm not sure how to handle this case...

saiichihashimoto commented 6 years ago

Can you not use the same regex in match-exported in your index.js check? I can't imagine there'd be a case where there would be the index<regex>.js and that wouldn't be the intention.