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

refactor(linter): improve eslint/no-constant-condition #8845

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shulaoda
Copy link
Contributor

@shulaoda shulaoda commented Feb 3, 2025

I've re-ported all the test cases for eslint/no-constant-condition and ensured they pass successfully. Additionally, I have aligned its options configuration with eslint.

Copy link

graphite-app bot commented Feb 3, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Feb 3, 2025
Copy link

codspeed-hq bot commented Feb 3, 2025

CodSpeed Performance Report

Merging #8845 will not alter performance

Comparing shulaoda:refactor/no-constant-condition (32d78c0) with main (9c84c6d)

Summary

✅ 33 untouched benchmarks

@Boshen Boshen requested a review from Sysix February 3, 2025 04:10
fn run_once(&self, ctx: &LintContext) {
let mut current_scope = Span::default();
let mut scopes = Vec::<(Span, FxHashSet<Span>)>::new();
for node in ctx.semantic().nodes() {
Copy link
Member

Choose a reason for hiding this comment

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

For correctness rules, we must not loop over the ast nodes again due to performance reasons. You can use a ref cell in the rule config if you really need to store state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We seem to have tried this before, but because the rule is shared across multiple threads, it seems impossible to store it in the rule config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait for #8854

@shulaoda shulaoda marked this pull request as draft February 3, 2025 04:15
@shulaoda shulaoda marked this pull request as ready for review February 3, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants