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: provide unique fix and fix.range objects in lint messages #17332

Merged
merged 2 commits into from Jul 4, 2023

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 #16716

What changes did you make? (Give an overview)

Updated report-translator to always create new fix objects and fix.range arrays. This ensures that lint messages do not share same instances, which could be problematic for processors that mutate these objects.

Added unit tests for report-translator, and one higher-level linter test that specifically targets the case described in #16716.

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 Jul 2, 2023
@mdjermanovic mdjermanovic requested a review from a team as a code owner July 2, 2023 15:32
@netlify
Copy link

netlify bot commented Jul 2, 2023

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit d82e6f0
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64a44c7fb930a0000736a25e

@fasttime
Copy link
Member

fasttime commented Jul 3, 2023

Thanks for this PR. I think that a processor postprocess() function can still return objects with non-unique references, so if problems are passed from a processor to the next one, there is still a chance that some of them will have identical fix and fix.range?

@mdjermanovic
Copy link
Member Author

I think that a processor postprocess() function can still return objects with non-unique references, so if problems are passed from a processor to the next one, there is still a chance that some of them will have identical fix and fix.range?

That looks like something that should rather be fixed in the processor? I think it's unlikely that "normal" processing of messages with unique references produces an output with shared references.

@fasttime
Copy link
Member

fasttime commented Jul 4, 2023

LGTM!

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. Just left one suggestion to clarify JSDoc, but otherwise, ready to merge.

lib/linter/report-translator.js Outdated Show resolved Hide resolved
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
@mdjermanovic mdjermanovic merged commit c667055 into main Jul 4, 2023
22 checks passed
@mdjermanovic mdjermanovic deleted the issue16716 branch July 4, 2023 17:38
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 1, 2024
@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 Jan 1, 2024
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: suggestions are broken on processored code if suggest array contain more that 2 items
3 participants