The Wayback Machine - https://web.archive.org/web/20230116215718/https://github.com/eslint/rfcs/pull/104
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: skip warnings cli flag #104

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

feat: skip warnings cli flag #104

wants to merge 1 commit into from

Conversation

me4502
Copy link

@me4502 me4502 commented Jan 16, 2023

Summary

Currently, ESLint will run all rules that are not marked as off in the configuration.
This RFC proposes adding a way to configure which rules are actually run, to reduce linting
time and better match the reporting outcome. Currently, when a rule is marked as warn,
ESLint will still run the rule but not report the results when run under --quiet. The
intended outcome of this RFC is to allow users to not run these rules when unnecessary.

Related Issues

eslint/eslint#16450

@eslint-github-bot
Copy link

Hi @me4502!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

To Fix: You can fix this problem by running git commit --amend, editing your commit message, and then running git push -f to update this pull request.

Read more about contributing to ESLint here

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 16, 2023

CLA Not Signed

@ljharb
Copy link
Sponsor

ljharb commented Jan 16, 2023

Is there a reason we couldn’t make “quiet” have this behavior?

@me4502
Copy link
Author

me4502 commented Jan 16, 2023

Is there a reason we couldn’t make “quiet” have this behavior?

This is one of the alternatives considered in the RFC. IMO it would make more sense to the user, but would also introduce a few confusion points around the existing flags that make use of warnings, such as --max-warnings which currently work fine alongside --quiet. It'd also be a breaking change


## Alternatives

### Implement this into `--quiet` instead of a new flag
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I prefer this alternative. It seems much more intuitive to me for the --quiet option to avoid running rules that won't influence the results anyway. I also generally believe we should use breaking changes to fix existing behavior that is unintuitive, instead of simply tacking on additional options as workarounds.

Copy link
Sponsor

Choose a reason for hiding this comment

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

Why exactly would it be a breaking change to stop running rules that won't influence the results?

Copy link
Sponsor Member

@bmish bmish Jan 16, 2023

Choose a reason for hiding this comment

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

I suppose that rules could be modifying shared state or have other side effects while running? I'm not sure if that's supposed to be allowed or not or if we need to worry about it here.

Regardless of that, it sounds like there's another potential breaking change related to the interaction with --max-warnings flag.

Copy link
Sponsor

Choose a reason for hiding this comment

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

what if it only skipped the rules when max-warnings wasn't provided? Then it would automatically do what made the most sense.

Copy link
Member

Choose a reason for hiding this comment

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

I suppose that rules could be modifying shared state or have other side effects while running? I'm not sure if that's supposed to be allowed or not or if we need to worry about it here.

We have one case where rule API actually encourages side effects: context.markVariableAsUsed(). For example, react/jsx-uses-vars calls this so that no-unused-vars doesn't report variables that are referenced in jsx elements. If someone has "react/jsx-uses-vars": "warn" in their config, and we don't run this rule, then they'll start getting no-unused-vars errors.

I'm also in favor of not introducing another flag, but not running rules set to "warn" indeed looks like a breaking change even without --max-warnings.

Another potential drawback around this specific implementation is that the existence of
both `--quiet` and `--skip-warnings` might be confusing to some users, however this can be
partially alleviated by updating the `--quiet` docs to mention that warnings will still be
run, and to use `--skip-warnings` instead to not run them.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

It's quite hard for me to guess the difference between --quiet and a hypothetical --skip-warnings option just from their names. While the docs could explain this, I think it's a sign that the design and naming may not be intuitive to users.

Another downside of this alternative is that it would introduce confusion around the
`--max-warnings` flag and other checks that require warnings to run. Currently the quiet
flag works fine alongside these. If we were to implement this into the quiet flag, we would
have to either break that functionality, or have the quiet flag only sometimes stop actual
running depending on what other flags are in use, which is confusing and unclear.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Since this alternative is a breaking change, I think we could reconsider interactions between flags as needed, and even throw an exception when multiple flags are provided that don't make sense to be specified together.

It would help to create a table explaining the current behavior with each combination of flags and also how the behavior would change for each combination (and whether it would still be allowed).

This change adds a new command line flag, as well as a new API method. This adds further
maintenance burden. However, the implementation is relatively simple, and the benefits
are significant.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Since this new flag would have interactions with several existing related flags, the potential implementation/maintenance/documentation burden is multiplied (making sure every possible combination of flags behaves correctly and that users understand the expected behavior of each combination).

@@ -0,0 +1,129 @@
- Repo: eslint/eslint
- Start Date: 2023-01-16
- RFC PR: (leave this empty, to be filled in later)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
- RFC PR: (leave this empty, to be filled in later)
- RFC PR: <https://github.com/eslint/rfcs/pull/104>
@mdjermanovic mdjermanovic added Initial Commenting This RFC is in the initial feedback stage and removed triage labels Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Initial Commenting This RFC is in the initial feedback stage
4 participants