-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
refactor: use /
separator when adjusting ignorePatterns
on Windows
#18613
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
@@ -421,7 +421,7 @@ async function calculateConfigArray(eslint, { | |||
relativeIgnorePatterns = ignorePatterns; | |||
} else { | |||
|
|||
const relativeIgnorePath = path.relative(basePath, cwd); | |||
const relativeIgnorePath = path.relative(basePath, cwd).replaceAll(path.sep, "/"); |
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 add a comment here that summarizes why we are doing this?
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.
Added in 69a6fdb
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.
LGTM. I'll leave it open for others to review.
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.
LGTM.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:
When converting
ignorePatterns
(--ignore-pattern
), which are relative tocwd
, to patterns relative tobasePath
, we were prependingpath.relative(basePath, cwd)
.On Windows, this was producing a mix of
\
and/
as path separators in the result. For example, if the config file is in the root, and you runeslint --ignore-pattern a.js
in a subfoldersrc\app
, the ignore pattern passed to the config array would besrc\app/a.js
.What changes did you make? (Give an overview)
Added
.replaceAll(path.sep, "/")
to the relative path to replace\
with/
on Windows and thus consistently produce ignore patterns with/
separators.Is there anything you'd like reviewers to focus on?
I marked this as a refactor because the previous code currently doesn't cause any bugs, but it would cause bugs after we update config-array to always treat
\
as an escape character (eslint/rewrite#61).