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: normalize cwd passed to ESLint/FlatESLint constructor #17277

Merged
merged 1 commit into from Jun 14, 2023
Merged

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

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

[ ] Documentation update
[x] 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
[ ] Other, please explain:

Fixes #17042

What changes did you make? (Give an overview)

Updated ESLint and FlatESLint constructors to path.normalize() given cwd right away when processing options.

This fixes bug #17042 for the ESLint class (the same bug did not exist for the FLatESLint class) and also ensures that rules and formatters always get normalized cwd.

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

@mdjermanovic mdjermanovic 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 Jun 13, 2023
@mdjermanovic mdjermanovic requested a review from a team as a code owner June 13, 2023 10:49
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Would like someone else to review before merging.

@fasttime
Copy link
Member

After this change, a custom formatter will be passed a normalized cwd instead of what was originally specified. A naively designed unit test could start failing because of the new behavior. Is this acceptable for a non-breaking fix?

@mdjermanovic
Copy link
Member Author

After this change, a custom formatter will be passed a normalized cwd instead of what was originally specified. A naively designed unit test could start failing because of the new behavior. Is this acceptable for a non-breaking fix?

I think it's acceptable for a non-breaking fix. We don't guarantee that the data passed to formatters will remain exactly the same, and that looks more like an integration test than a unit test.

@nzakas
Copy link
Member

nzakas commented Jun 14, 2023

I think it's acceptable for a non-breaking fix. We don't guarantee that the data passed to formatters will remain exactly the same, and that looks more like an integration test than a unit test.

Agreed.

Copy link
Member

@fasttime fasttime 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!

@fasttime fasttime merged commit 5338b56 into main Jun 14, 2023
17 checks passed
@fasttime fasttime deleted the issue17042 branch June 14, 2023 17:17
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Dec 12, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 12, 2023
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.

Bug: (eslintignore breaks when cwd is using forward slash on windows)
3 participants