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

Provide a specific error for a rule specification missing a plugin prefix #14027

Closed
JoshuaKGoldberg opened this issue Jan 23, 2021 · 3 comments · Fixed by #15074
Closed

Provide a specific error for a rule specification missing a plugin prefix #14027

JoshuaKGoldberg opened this issue Jan 23, 2021 · 3 comments · Fixed by #15074
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 core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Jan 23, 2021

The version of ESLint you are using.

7.18.0

The problem you want to solve.

In trying to enable a rule from a new custom plugin in my .eslintrc.js, I made the mistake of forgetting to include the plugin prefix in the specifier:

{
    "extends": [
      "plugin:jest-react/recommended"
    ],
    "plugins": [
      "jest-react"
    ],
    "rules": {
        // This should have been:
        // "jest-react/no-mocking-react": "error"
        "no-mocking-react": "error"
    }
  }

Your take on the correct solution to problem.

It would be nice if a "did you mean?" could be printed at the end of all outputs for each rule that could be matched but for a plugin prefix. Roughly proposing:

/path/to/file1.js
  1:1  error  Definition for rule 'no-mocking-react' was not found (though a jest/  no-mocking-react

Definition for 'no-mocking-react' was not found, but 'jest-react/no-mocking-react' was.

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

It would be my honor and privilege. ❤️

I dug a little bit and saw that rules are stored in slots.lastConfigArray.pluginRules within Linter. If a rule is not found, we could check if (semi-pseudocoding here)...

Array.from(slots.lastConfigArray.pluginRules.entries()).some(ruleEntryKey => ruleEntryKey === `/${id}`)
@JoshuaKGoldberg JoshuaKGoldberg 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 Jan 23, 2021
@anikethsaha
Copy link
Member

anikethsaha commented Jan 23, 2021

Thanks for the issue,

This is an interesting suggestion and definitely a helpful one.
My only concern is that it might take some more time to look up and search all plugins when there are too many plugins.
Though this will not be a big concern still it would be good to handle if possible.

+1 for this

@anikethsaha anikethsaha added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jan 23, 2021
@nzakas
Copy link
Member

nzakas commented Feb 9, 2021

At the moment, we aren't making any further changes to how config works or is used while we are building out the new config system.

I wouldn't mind looking at this again once the new config system is up and running, as I think this is a nice addition to help users out.

@nzakas nzakas added this to Evaluating in Triage Feb 9, 2021
@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Sep 16, 2021
@nzakas nzakas moved this from Evaluating to Pull Request Opened in Triage Sep 16, 2021
@nzakas nzakas linked a pull request Sep 16, 2021 that will close this issue
1 task
@nzakas
Copy link
Member

nzakas commented Sep 16, 2021

Created a PR for this in flat config :)

Triage automation moved this from Pull Request Opened to Complete Sep 24, 2021
mdjermanovic pushed a commit that referenced this issue Sep 24, 2021
* Update: Suggest missing rule in flat config (fixes #14027)

* Switch to older syntax

* Fix error messages
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Mar 24, 2022
@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 Mar 24, 2022
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 core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
Triage
Complete
Development

Successfully merging a pull request may close this issue.

3 participants