refactor: use / separator when adjusting ignorePatterns on Windows#18613
Merged
refactor: use / separator when adjusting ignorePatterns on Windows#18613
/ separator when adjusting ignorePatterns on Windows#18613Conversation
✅ Deploy Preview for docs-eslint canceled.
|
nzakas
reviewed
Jun 20, 2024
| } else { | ||
|
|
||
| const relativeIgnorePath = path.relative(basePath, cwd); | ||
| const relativeIgnorePath = path.relative(basePath, cwd).replaceAll(path.sep, "/"); |
Member
There was a problem hiding this comment.
Can we add a comment here that summarizes why we are doing this?
snitin315
approved these changes
Jun 21, 2024
Contributor
snitin315
left a comment
There was a problem hiding this comment.
LGTM. I'll leave it open for others to review.
1 task
This was referenced Jul 19, 2024
This was referenced Aug 19, 2024
This was referenced Sep 3, 2024
This was referenced Sep 14, 2024
This was referenced Sep 23, 2024
This was referenced Sep 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsin 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).