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

πŸ› Suppression comments of assist rules reported as useless #5503

Open
1 task done
Conaclos opened this issue Mar 29, 2025 · 2 comments
Open
1 task done

πŸ› Suppression comments of assist rules reported as useless #5503

Conaclos opened this issue Mar 29, 2025 · 2 comments
Assignees
Labels
A-Analyzer Area: analyzer S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@Conaclos
Copy link
Member

Environment information

Main

What happened?

Here a reproduction:

❯ cat biome.json 
{
  "assist": {
    "actions": {
      "source": {
        "useSortedKeys": "on"
      }
    }
  }
}

❯ cat file.js 
// biome-ignore assist/source/useSortedKeys: tst
var foo = {
	lorem: "lorem", // the text range starts at this line, which is missed by the suppression comment
	ipsum: "ipsum",
};

❯ biome check file.js 
/file.js:1:1 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ⚠ Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule.
  
  > 1 β”‚ // biome-ignore assist/source/useSortedKeys: tst
      β”‚ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 β”‚ var foo = {
    3 β”‚ 	lorem: "lorem", // the text range starts at this line, which is missed by the suppression comment

Expected result

The suppression comment should not be considered as useless.
The issue also affect other assist actions.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added S-Needs triage Status: this issue needs to be triaged S-Bug-confirmed Status: report has been confirmed as a valid bug A-Analyzer Area: analyzer and removed S-Needs triage Status: this issue needs to be triaged labels Mar 29, 2025
@ematipico
Copy link
Member

Fixed by #5482

@ematipico
Copy link
Member

ematipico commented Apr 3, 2025

Investigating this, and it seems that the issue comes down to the fact that in that particular code, there are two signals coming from the same line:

  • source/useSortedKeys
  • suspicious/noVar

The suppression system isn't aware (yet) of the distinction between lint rules and assist actions. When running the check command (or even lint), we hit a false positive where suspicious/noVar is suppressed by another suppression comment.

In fact, if you run check --linter-enabled=false won't yield any errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analyzer Area: analyzer S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

2 participants