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-pattern
in flat config mode should be relative to cwd
#16425
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -362,17 +362,6 @@ async function calculateConfigArray(eslint, { | |
const negated = pattern.startsWith("!"); | ||
const basePattern = negated ? pattern.slice(1) : pattern; | ||
|
||
/* | ||
* Ignore patterns are considered relative to a directory | ||
* when the pattern contains a slash in a position other | ||
* than the last character. If that's the case, we need to | ||
* add the relative ignore path to the current pattern to | ||
* get the correct behavior. Otherwise, no change is needed. | ||
*/ | ||
if (!basePattern.includes("/") || basePattern.endsWith("/")) { | ||
return pattern; | ||
} | ||
|
||
Comment on lines
-365
to
-375
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second test case was failing because of this conditional. I'm not sure why we had this special case. It could be a leftover from the version where patterns had .gitignore semantics (e.g, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, I’m pretty sure that’s left over from gitignore compatibility. |
||
return (negated ? "!" : "") + | ||
path.posix.join(relativeIgnorePath, basePattern); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
root: true | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rearrange the conditionals in these blocks? It’s a bit hard to follow an else after a not equals. Maybe structure as “if configType is flat, then add ignorePatterns, else do the other stuff”?
Also, I don’t think you need to check for ignorePattern before adding ignorePatterns to options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the suggestion!