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(linter/no-cond-assign): false positive when assignment is in body statement #6665

Conversation

camchenry
Copy link
Contributor

@camchenry camchenry commented Oct 18, 2024

rather than reporting any assignment inside of if, while, etc. when the always option is enabled, we only check if the assignment resides in specific areas that assignment should not be. for example, inside the test of an if, or the test of a for loop.

incidentally, this also fixes an issue (seen in snapshot file) where the same assignment was reported twice.

Copy link

graphite-app bot commented Oct 18, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added the A-linter Area - Linter label Oct 18, 2024
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @camchenry and the rest of your teammates on Graphite Graphite

@github-actions github-actions bot added the C-bug Category - Bug label Oct 18, 2024
@camchenry camchenry force-pushed the 10-18-fix_linter_no-cond-assign_false_positive_when_assignment_is_in_body_statement branch from b7bc6a2 to 0caf04e Compare October 18, 2024 19:44
@camchenry camchenry requested review from camc314 and DonIsaac October 18, 2024 19:46
@camchenry camchenry marked this pull request as ready for review October 18, 2024 19:47
Copy link

codspeed-hq bot commented Oct 18, 2024

CodSpeed Performance Report

Merging #6665 will not alter performance

Comparing 10-18-fix_linter_no-cond-assign_false_positive_when_assignment_is_in_body_statement (b0b6ac7) with main (70c6f24)

Summary

✅ 30 untouched benchmarks

@DonIsaac DonIsaac added the 0-merge Merge with Graphite Merge Queue label Oct 19, 2024
Copy link
Contributor

DonIsaac commented Oct 19, 2024

Merge activity

  • Oct 18, 11:16 PM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 18, 11:16 PM EDT: A user added this pull request to the Graphite merge queue.
  • Oct 18, 11:21 PM EDT: A user merged this pull request with the Graphite merge queue.

… statement (#6665)

- fixes #6656

rather than reporting any assignment inside of `if`, `while`, etc. when the `always` option is enabled, we only check if the assignment resides in specific areas that assignment should not be. for example, inside the test of an `if`, or the test of a `for` loop.

incidentally, this also fixes an issue (seen in snapshot file) where the same assignment was reported twice.
@DonIsaac DonIsaac force-pushed the 10-18-fix_linter_no-cond-assign_false_positive_when_assignment_is_in_body_statement branch from 0caf04e to b0b6ac7 Compare October 19, 2024 03:17
@graphite-app graphite-app bot merged commit b0b6ac7 into main Oct 19, 2024
26 checks passed
@graphite-app graphite-app bot deleted the 10-18-fix_linter_no-cond-assign_false_positive_when_assignment_is_in_body_statement branch October 19, 2024 03:21
Boshen added a commit that referenced this pull request Oct 21, 2024
## [0.10.1] - 2024-10-21

### Features

- af25752 linter: Add `unicorn/prefer-math-min-max` (#6621) (Brian Liu)
- 5095f02 linter: Added fixer for duplicate prefix in valid title jest
rule (#6699) (Tapan Prakash)
- e9976d4 linter: Add title whitespace fixer for jest valid title rule
(#6669) (Tapan Prakash)
- 45f02d5 linter: Add `unicorn/consistent-empty-array-spread` (#6695)
(Brian Liu)
- 01a35bb linter/eslint: Show ignore patterns in `eslint/no-unused-vars`
diagnostic messages (#6696) (DonIsaac)

### Bug Fixes

- 1bcd707 editor: Update config sent to language server (#6724)
(Nicholas Rayburn)
- ce25c45 linter: Panic in `disable-directives` (#6677) (dalaoshu)
- a5de230 linter/import: `import/no-duplicates` handles namespace
imports correctly (#6694) (DonIsaac)
- b0b6ac7 linter/no-cond-assign: False positive when assignment is in
body statement (#6665) (camchenry)

### Performance

- 6a76ea8 linter/no-unused-vars: Use default IgnorePattern when /^_/ is
provided as a pattern (#6697) (DonIsaac)

### Refactor

- d6609e9 linter: Use `run_on_jest_node` for existing lint rules (#6722)
(camchenry)
- 97195ec linter: Add `run_on_jest_node` to run rules on only jest nodes
(#6721) (camchenry)
- 155fe7e linter: Allow `Semantic` to be passed for collecting Jest
nodes (#6720) (camchenry)
- ad8f281 linter: Use iter for collecting jest nodes (#6719) (camchenry)
- dc19a8f linter: Use iterator for collecting jest imports (#6718)
(camchenry)
- 29c1447 linter: `jest/valid-title` fixer to use `Span::shrink` method
(#6703) (Tapan Prakash)
- 2eb984a linter: Add missing `should_run` implementations (#6666)
(camchenry)
- 23f88b3 linter/import: Better diagnostic messages for
`import/no-duplicates` (#6693) (DonIsaac)

---------

Co-authored-by: Boshen <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-linter Area - Linter C-bug Category - Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter: no-cond-assign: false positive
2 participants