Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint scans all dotfiles, even in ignored folders #9470

Closed
Techn1x opened this issue Mar 3, 2021 · 6 comments
Closed

eslint scans all dotfiles, even in ignored folders #9470

Techn1x opened this issue Mar 3, 2021 · 6 comments

Comments

@Techn1x
Copy link

Techn1x commented Mar 3, 2021

I think there's a slight misconfiguration in the default .eslintignore file

Here's an example of it
https://github.com/ember-cli/ember-new-output/blob/7faae3f8d1c029efb0e47664d5ef232a9ef912ac/.eslintignore#L1-L21

# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try

Focusing on the !.* introduced by #8070

This causes it to scan all dot-files and dot-directories, even in the ignored directories listed above it (dist, tmp, vendor, node_modules, ...). It unignores them, I don't think this was the intent when it was added.

One solution is moving that line to the top of the file, but then it will still unignore dotfiles in default eslint ignored directories (like **/node_modules/* or whatever else they might decide to add in the future)

I think a better solution would be better targeting for the !.* - assuming the intent was just to target dotfiles in the top directory, maybe something like this is enough ->./!.*

@Techn1x
Copy link
Author

Techn1x commented Mar 3, 2021

I stumbled on this problem in eslint/eslint#14158
The 7.21.0 eslint release unignores symbolic link files, so I noticed that eslint was scanning my node_modules/.bin/ directory (full of yarn symbolic links, some to JS files) and ended up with eslint errors for that JS file. Turns out it was because of the !.*

@rwjblue
Copy link
Member

rwjblue commented Mar 3, 2021

I think @chancancode / @wagenet just recently fixed this. Mind taking a look?

@rwjblue
Copy link
Member

rwjblue commented Mar 3, 2021

#9456

@Techn1x
Copy link
Author

Techn1x commented Mar 3, 2021

Oh nice! The re-ignoring of dot-directories in #9456 does solve most of the issue (and indeed, the problem I was having)

I don't think it would fix the problem of dotfiles inside ignored folders being scanned. Say if a file like /tmp/abc/.my-file existed, eslint would scan it

Happy for this to be closed though if you think that's an edge-case

@rwjblue
Copy link
Member

rwjblue commented Mar 3, 2021

Can you confirm that is still an issue (dotfiles with or without extension within an ignored directory still get detected and linted)?

It seems odd that ignored directories would be traversed at all in.

@Techn1x
Copy link
Author

Techn1x commented Mar 3, 2021

Looks like you're right. To test this I made my .eslintignore config match the one in the PR, added a file touch ./tmp/.test.js and some code that definitely fails linting. It didn't seem to get picked up.

I think the work in the PR above is sufficient 👍 thanks!

@Techn1x Techn1x closed this as completed Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants