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: Reporting unused inline configs #121

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JoshuaKGoldberg
Copy link
Contributor

Summary

Proposes adding a CLI option to report /* eslint... */ comments that don't change any settings.

Related Issues

@fasttime fasttime added the Initial Commenting This RFC is in the initial feedback stage label Jul 8, 2024
Comment on lines +192 to +193
One way to reduce costs could be to wait until ESLint completely removes support for legacy configs.
That way, only the new ("flat") config system would need to be tested with this change.
Copy link
Member

@fasttime fasttime Jul 9, 2024

Choose a reason for hiding this comment

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

I think it makes sense to enable this change only for the new config system. Probably we don't want to add a new option to eslintrc, even if it's only for internal usage by the CLI. But we should still make sure that no new problems are reported when the Linter runs in eslintrc mode and the default value for reportUnusedInlineConfigs changes to "error" or "warn".

Additional logic can be added to the existing code points in `Linter` that validate inline config options:

- [`_verifyWithFlatConfigArrayAndWithoutProcessors`](https://github.com/eslint/eslint/blob/7c78ad9d9f896354d557f24e2d37710cf79a27bf/lib/linter/linter.js#L1650): called in the current ("flat") config system
- [`getDirectiveComments`](https://github.com/eslint/eslint/blob/7c78ad9d9f896354d557f24e2d37710cf79a27bf/lib/linter/linter.js#L387): called when `ESLINT_USE_FLAT_CONFIG=true`
Copy link
Member

Choose a reason for hiding this comment

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

I think that getDirectiveComments is also called when ESLINT_USE_FLAT_CONFIG is not set?

The existing `--report-unused-disable-directives` (enabling) and `--report-unused-disable-directives-severity` (severity) options were kept separate for backwards compatibility.

Adding a sole `--report-unused-inline-configs` CLI option presents a discrepency between the two sets of options.
An alternative could be to instead add `--report-unused-inline-configs` an `--report-unused-inline-configs-severity` options for consistency's sake.
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
An alternative could be to instead add `--report-unused-inline-configs` an `--report-unused-inline-configs-severity` options for consistency's sake.
An alternative could be to instead add `--report-unused-inline-configs` and `--report-unused-inline-configs-severity` options for consistency's sake.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft July 9, 2024 18:48
@JoshuaKGoldberg
Copy link
Contributor Author

Per eslint/eslint#15476 (comment), converting to a draft so I can rework this to encompass eslint/eslint#15476.

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
Projects
None yet
2 participants