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: improve flat config errors for invalid rule options and severities #17140

Conversation

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented May 1, 2023

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Adds a couple of new error messages for flat config schema parsing.

Fixes #17056

Is there anything you'd like reviewers to focus on?

  • Unit tests don't seem to cover the full error messages - is this something you'd want added in?
  • Please bikeshed my error messages 😄 I'm not confident in them, and mostly based them off the legacy config system's.
    • Additionally, this removes the Key: ... portion of the error message, in favor of the traditional Configuration for rule .... I see this change as more readable, perhaps?

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label May 1, 2023
@netlify
Copy link

netlify bot commented May 1, 2023

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit da0ddd9
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64539ab86d54be0009eab13a

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the flat-config-invalid-options-or-severity-error branch from 8541c16 to e724d97 Compare May 1, 2023 21:04
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review May 1, 2023 21:20
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner May 1, 2023 21:20
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Thanks for taking a stab at this. In general, I think this is a good change. I'd just prefer to keep the original error message on the error objects themselves so we have consistency with how errors are reported in the code. Users won't end up seeing those errors messages anyway.

And yes, we don't test verbose error messages because those just bubble up to the CLI. We want to make sure that the thrown error matches the expectation and then we let the CLI do its thing to make those errors pretty.

lib/config/flat-config-schema.js Outdated Show resolved Hide resolved
messages/invalid-rule-options.js Outdated Show resolved Hide resolved
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft May 1, 2023 21:45
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review May 1, 2023 23:11
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM! Just want @mdjermanovic to give this a review before merging.

@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label May 4, 2023
messages/shared.js Outdated Show resolved Hide resolved
lib/config/flat-config-schema.js Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 5db7808 into eslint:main May 4, 2023
22 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the flat-config-invalid-options-or-severity-error branch May 4, 2023 18:44
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Nov 1, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion feature This change adds a new feature to ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Request: Add more context to incorrect rule severity configurations
3 participants