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: always resolve default ignore patterns from CWD (fixes #9227) #10638

Merged
merged 2 commits into from
Jul 26, 2018

Conversation

not-an-aardvark
Copy link
Member

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

[x] Bug fix (#9227)

What changes did you make? (Give an overview)

This fixes an issue where the default ignore patterns, such as /node_modules, would always be resolved from the location of an .eslintignore file. As a result of the bug, the node_modules folder in the project root directory would not be ignored if an .eslintignore file in a subdirectory was being used.

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

Nothing in particular

This fixes an issue where the default ignore patterns, such as `/node_modules`, would always be resolved from the location of an `.eslintignore` file. As a result of the bug, the `node_modules` folder in the project root directory would not be ignored if an `.eslintignore` file in a subdirectory was being used.
@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion labels Jul 21, 2018
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

Left one comment, otherwise this looks good to me. Thanks!


addPatternRelativeToIgnoreFile(ig, pattern) {
ig.addPattern(
this.getBaseDir() === this.options.cwd
Copy link
Member

Choose a reason for hiding this comment

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

Should this say something like this.getBaseDir() === this.ignoreFileDir and invert the consequent and alternate below, similar to the method just above this one? Or do we know for sure that this.getBaseDir() will always be the ignore directory or CWD, nothing else?

Edit: I see later down, that condition should indeed hold. But I still think this change would make sense in case we change something in the implementation and this.getBaseDir() could expand to a few different paths.

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@not-an-aardvark not-an-aardvark merged commit 8b83d2b into master Jul 26, 2018
@not-an-aardvark not-an-aardvark deleted the fix-relative-ignores branch July 26, 2018 06:56
ig.addPattern(
this.getBaseDir() === this.options.cwd
? pattern
: relativize(pattern, path.relative(this.ignoreFileDir, this.options.cwd))
Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry for I didn't review on this PR.

After this PR merged, some tests are failing on my environment (#10687). I'm not sure what is there difference between Appvoyer and my environment.

I have not found the cause yet, but the path separator is \ on Windows, isn't it a problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it seems likely that this PR introduced the bug. I had assumed that it was fine because it was working on Appveyor, but it does seem like differences in path separator might cause problems.

If we can figure out what the issue is, we can use something like path.posix.relative rather than path.relative as necessary for consistent behavior.

Copy link
Member

Choose a reason for hiding this comment

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

I guess this.options.cwd can be Windows path, so we cannot use path.posix.relative. Anyway, I added .replace(/\\/g, "/") after the two path.relative(...), but it didn't solve the issue. I'm investigating...

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 23, 2019
@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 Jan 23, 2019
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.

None yet

3 participants