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 3 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
18 changes: 13 additions & 5 deletions designs/2024-baseline-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,32 @@ This can be counterintuitive for enabling new rules as `error`, since the develo

To keep track of the all the errors that we would like to ignore, we are introducing the concept of the baseline file; A JSON file containing the number of errors that must be ignored for each rule in each file. By design, the baseline is disabled by default and it doesn't affect existing or new projects, unless the baseline file is generated.
softius marked this conversation as resolved.
Show resolved Hide resolved

Here is what the baseline file looks like. This indicates that the file `"src/app/components/foobar/foobar.component.ts"` has one error for the rule `@typescript-eslint/no-explicit-any` that is acceptable to be ignored.
Here is what the baseline file looks like. This indicates that the file `"/home/user/project/src/app/components/foobar/foobar.component.ts"` has one error for the rule `@typescript-eslint/no-explicit-any` that is acceptable to be ignored.
softius marked this conversation as resolved.
Show resolved Hide resolved

```
{
"src/app/components/foobar/foobar.component.ts": {
"/home/user/project/src/app/components/foobar/foobar.component.ts": {
"@typescript-eslint/no-explicit-any": 1
softius marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

### Generating the baseline

A new option `--generate-baseline` can be added to ESLint CLI. When provided, the baseline is generated and saved in `.eslint-baseline.json`. If the file already exists, it gets over-written. Note that this is a boolean flag option (no values are accepted). For example:
A new option `--baseline` can be added to ESLint CLI. When provided, the baseline is generated and saved in `.eslint-baseline.json`. If the file already exists, it gets over-written. Note that this is a boolean flag option (no values are accepted). For example:

``` bash
eslint --generate-baseline ./src
eslint --baseline ./src
```

The above will go through each result item and messages, and count the number of errors (`severity == 2`). If one or more such messages are found, the necessary details must be stored in the baseline file. The process should take place right after the fixes are applied to avoid counting errors that are about to be fixed.

By default, the baseline file is saved at `.eslint-baseline.json` . To control where the baseline is saved, another option can be introduced `--baseline-location`. That is a string argument specifying the file or a directory. If a directory is specified, a baseline file is created inside the specified folder.

``` bash
eslint --baseline --baseline-location /home/user/project/mycache
```

### Matching against the baseline

The suggested solution always compares against the baseline, given that the baseline file `.eslint-baseline.json` exists. This makes it easier for existing and new projects to adopt the baseline without the need to adjust scripts in `package.json` and CI/CD workflows.
Expand Down Expand Up @@ -187,7 +193,9 @@ I expect to implement this change.
in this section.
-->

No questions so far.
### Does this count warnings?

No, we are only counting errors when generating the baseline. Also only errors are considered when checking against the baseline.

## Related Discussions

Expand Down