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

Fix: Ignore hidden folders when resolving globs (fixes #8259) #8270

Merged
merged 1 commit into from
Mar 17, 2017

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Mar 17, 2017

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This is a performance improvement, but should not be a change to linting functionality. This is similar to avoiding glob resolution within node_modules. With this change, node-glob will not attempt to find all files within .dotfolder folders. Similar to node_modules, this can be overridden in a user’s ignore file or in an ignore-pattern, and is also prevented if the dotfiles option is true.

Is there anything you'd like reviewers to focus on?

It would be good to double-check our tests around hidden files and folders, as well as perhaps manually trying a few situations. From everything I tested, this works exactly like before, except faster. 🐎

@eslintbot
Copy link

LGTM

@mention-bot
Copy link

@IanVS, thanks for your PR! By analyzing the history of the files in this pull request, we identified @not-an-aardvark, @gyandeeps and @mysticatea to be potential reviewers.

This is a performance improvement, but should not be a change to linting
functionality.  This is similar to avoiding glob resolution within
`node_modules`.  With this change, `node-glob` will not attempt to 
find all files within `.dotfolder` folders.  Similar to `node_modules`,
this can be overridden in a user’s ignore file or in an ignore-pattern.
@eslintbot
Copy link

LGTM

if (this.options.dotfiles !== true) {

// Ignore hidden folders. (This cannot be ".*", or else it's not possible to unignore hidden files)
ig.add([".*/*", "!../"]);
Copy link
Member

@alberto alberto Mar 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be .*/. It's just that you would have to unignore the folder you want to lint e.g !.foo/. Unless the issue is with glob syntax, which I am not so familiar with.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, it's not possible to unignore an ignored folder, which is why I needed it this way.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not good to ig.add('!../'), because .gitignore only cares about the current directory and subtle directories.

Even if it works to do this, it is the side effect of node-ignore however.

Copy link

@kaelzhang kaelzhang Mar 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a better workaround to make sure ../ is excluded in the glob result (May be it already is which I haven't confirmed yet).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I added that pattern a while ago because the patterns in .eslintignore currently are applied against the CWD, not the file's directory (until #7678 is merged). I think we could consider removing that pattern in that PR, since you're right, from then on, the patterns will be relative to the ignore file's location, and the ignore file must be at the project root (unless we make changes for #8090).

It might be interesting to do a search for .eslintignore files on github which contain ../. Seems like that should be possible, but I'm not exactly sure how.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, thanks for reviewing, @kaelzhang!

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion core Relates to ESLint's core APIs and features rule Relates to ESLint's core rules bug ESLint is working incorrectly and removed rule Relates to ESLint's core rules labels Mar 17, 2017
@IanVS
Copy link
Member Author

IanVS commented Mar 17, 2017

It might be good for @kaelzhang to double-check this as well.

if (this.options.dotfiles !== true) {

// Ignore hidden folders. (This cannot be ".*", or else it's not possible to unignore hidden files)
ig.add([".*/*", "!../"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a separate issue (probably for a different PR) maybe we should name this variable to something other than ig. I was having trouble understanding what this code was doing because it's hard to tell what ig.add means conceptually.

@ilyavolodin ilyavolodin merged commit a61c359 into master Mar 17, 2017
@vitorbal vitorbal deleted the issue8259 branch April 12, 2017 11:16
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants