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

Allow "reportUnusedDisableDirectives" option to "error" #12703

Closed
obweger opened this issue Dec 22, 2019 · 7 comments
Closed

Allow "reportUnusedDisableDirectives" option to "error" #12703

obweger opened this issue Dec 22, 2019 · 7 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@obweger
Copy link

obweger commented Dec 22, 2019

The version of ESLint you are using.

6.8.0

The problem you want to solve.

I'd like to prevent (i.e., error on) unused directives via my configuration (rather than the CLI).

Your take on the correct solution to problem.

I can error on unused directives via --report-unused-disable-directives. However, for errors to be shown in the IDE, it would be easier to allow the reportUnusedDisableDirectives configuration option to be set to error. Currently, it can only be set to true, which translates to warn.

Are you willing to submit a pull request to implement this change?

Yes.

@obweger obweger added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Dec 22, 2019
@kaicataldo kaicataldo added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion works as intended The behavior described in this issue is working correctly and removed triage An ESLint team member will look at this issue soon labels Dec 23, 2019
@kaicataldo
Copy link
Member

I understand why this would be useful. The current design is intentional, however. If we allowed for errors to be reported with reportUnusedDisableDirectives, we would limit what kind of changes we could publish in a semver-patch release (since fixing a bug that would result in fewer errors could create additional unused disable directives). You can find more information in the original RFC here.

@kaicataldo kaicataldo removed core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Dec 23, 2019
@obweger
Copy link
Author

obweger commented Dec 24, 2019

Right, thanks for the context. I wonder if we can make this a consumer choice (we would obviously have to be very explicit about this in the docs); in our case, it would be perfectly fine to fix all unused directives whenever we upgrade eslint or a plugin, especially if the unused directives would be fixable (see #11815).

@platinumazure
Copy link
Member

Hi @obweger. Just as a note, if you haven't configured any rules to warn, you could use --max-warnings 0 to ensure that ESLint terminates with a failure status code if unused disable directive warnings are generated in your lint run.

@kaicataldo
Copy link
Member

There is precedence for a feature that comes with an explicit “use at your own risk because this feature can’t follow semver and may break your build” warning label in the eslint:all built in config.

@kaicataldo kaicataldo added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed works as intended The behavior described in this issue is working correctly labels Dec 24, 2019
@obweger
Copy link
Author

obweger commented Jan 2, 2020

@platinumazure 👍thanks for that! I think we can work around it with the --report-unused-disable-directives option, I got this to work also in the IDE. I'm happy for this issue to be closed, however in general I think it would be good to have this available through the regular config!

@NickHeiner
Copy link
Contributor

NickHeiner commented Jan 20, 2020

I would also like the option to have reportUnusedDisableDirectives be an error-level option when passed as config. My context:

  1. I'm perfectly happy to fix errors caused by non-semver-major changes if it means that my disable directives were erroneous.
  2. I can't enable --max-warnings 0 because my project currently has hundreds of warnings across 11k+ files.
  3. I can't use the CLI option --report-unused-disable-directives because of the various programmatic means (including the Jest runner) by which ESLint is run.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Feb 20, 2020
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 20, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

4 participants