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

feat: Introduce a way to suppress violations #119

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a99c456
Add RFC for baseline support
softius Apr 22, 2024
f9b3976
Fix typos
softius Apr 22, 2024
c9a718c
Add question about warnings
softius May 6, 2024
4d73750
Convert relative to full paths
softius May 6, 2024
9e035f1
Replace --generate-baseline with --baseline/-location
softius May 6, 2024
ed01be1
Add more implementation details, add relative paths to CWD
softius May 8, 2024
d5411af
Update designs/2024-baseline-support/README.md
softius May 30, 2024
98779dc
Remove references to the deprecated engine
softius Jul 27, 2024
b343ddb
Rename default baseline file to eslint-baseline.json
softius Jul 27, 2024
ad5343d
Include more implementation details
softius Jul 27, 2024
485f684
Add link for no-explicit-any
softius Aug 1, 2024
70a7c56
Always update the baseline to update addressed violations
softius Aug 1, 2024
4462ce6
Update designs/2024-baseline-support/README.md
softius Aug 1, 2024
1a1cbba
Add more details for matching against the baseline, and keeping the b…
softius Aug 1, 2024
71ee661
Fix lists formatting
softius Aug 1, 2024
2d4dc84
Minor adjs
softius Aug 1, 2024
dc2d940
First iteration to replace the concept of baseline with suppressions.
softius Aug 2, 2024
b8a1cf7
Fix header and other minor adjustments
softius Aug 2, 2024
0c3d9a4
Simplify language
softius Aug 3, 2024
4fea00e
Revise return types
softius Aug 3, 2024
42d8b95
Minor cleanup
softius Aug 3, 2024
bff622d
Allow to pass multiple rules
softius Aug 6, 2024
48e9d0a
Fix typo
softius Aug 6, 2024
46cf6ae
Update designs/2024-baseline-support/README.md
softius Aug 9, 2024
a94a50d
Fix typo
softius Aug 16, 2024
861f1a4
Use block comments
softius Aug 16, 2024
566e3b9
More details about prune-suggestions and how the filtering works.
softius Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions designs/2024-baseline-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ eslint --suppress-all ./src

### Suppressing violations of a specific rule

A new option `--suppress-rule [RULE1]` will be introduced to ESLint CLI. When provided, the existing suppressions file will be updated to include any existing violation of the provided rule. The suppressions file will be created if not already exists. Note that this is a string flag option (value is required).
A new option `--suppress-rule [RULE1]` will be introduced to ESLint CLI. When provided, the existing suppressions file will be updated to include any existing violation of the provided rule. The suppressions file will be created if not already exists. Note that this is option can accept an array of string values.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
A new option `--suppress-rule [RULE1]` will be introduced to ESLint CLI. When provided, the existing suppressions file will be updated to include any existing violation of the provided rule. The suppressions file will be created if not already exists. Note that this is option can accept an array of string values.
A new option `--suppress-rule [RULE1]` will be introduced to ESLint CLI. When provided, the existing suppressions file will be updated to include any existing violation of the provided rule. The suppressions file will be created if not already exists. Note that this option can accept an array of string values.


``` bash
eslint --suppress-rule '@typescript-eslint/no-explicit-any' ./src
eslint --suppress-rule '@typescript-eslint/no-explicit-any' --suppress-rul '@typescript-eslint/member-ordering' ./src
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
eslint --suppress-rule '@typescript-eslint/no-explicit-any' --suppress-rul '@typescript-eslint/member-ordering' ./src
eslint --suppress-rule '@typescript-eslint/no-explicit-any' --suppress-rule '@typescript-eslint/member-ordering' ./src

```

### Changing the location of the suppressions file
Expand All @@ -84,7 +84,7 @@ Consider the following scenario:
* After fixing a violation, the suppressions file still contains the now-resolved violation.
* Running `eslint ./src` again reports no violations but exits with a non-zero status code, indicating the suppressions file needs updating.
Copy link
Member

@mdjermanovic mdjermanovic Aug 29, 2024

Choose a reason for hiding this comment

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

In this case, will there be an error message, and what would it look like? Technically, will it be a lint message passed to the formatter along with other lint messages for the file, or a separate output?


To address this, a new option `--prune-suggestions` will be introduced to ESLint. This boolean flag removes resolved violations from the suppressions file without adding new ones, unlike `--suppress-all`.
To address this, a new option `--prune-suppressions` will be introduced to ESLint. This boolean flag removes resolved violations from the suppressions file without adding new ones, unlike `--suppress-all`.

``` bash
eslint --prune-suppressions ./src
Expand Down Expand Up @@ -158,10 +158,10 @@ class SuppressedViolationsManager {
* Updates the suppressions file based on the current violations and the provided rule.
*
* @param {LintResult[]} results The lint results.
* @param {string} rule The rule to suppress.
* @param {string[]} rules The rules to suppress.
* @returns {void}
*/
suppressByRule(results, rule)
suppressByRule(results, rules)
softius marked this conversation as resolved.
Show resolved Hide resolved

/**
* Removes old suppressions that do not occur anymore.
Expand Down