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
Change default rule schema to schema: []
and drop support for function-style rules
#14709
Comments
Interesting idea. I think we kept this as-is for maximum compatibility with older rules that were implemented before rules could specify schemas. The big question we need to answer is how many existing plugins would break. Are you thinking this would apply just to object-based rules and function-based rules would still be schemaless? I think it’s an idea worth exploring, though as a breaking change, it would need to wait until v9.0.0, as we have frozen the feature set for v8.0.0. Let’s see what others think. |
Targeting v9 should give us ample time (I assume a year) to communicate about this upcoming breaking change and help rules prepare for it. Other ways we could help rules prepare:
Regarding the question of whether this requirement should apply to both object-based rules and function-based rules, I'm not sure yet. Ideally, it would apply to all rules, but I'm open to excluding function-based rules if there's a strong case made for that. Will function-based rules be supported forever, or can we remove support for that deprecated style at some point? |
We are slowly making creating function rules harder, for instance, in v8.0.0 they can no longer be fixable (#13349) and can’t provide suggestions. So it’s not outside the realm of possibility that we could remove support completely. |
I'm also intrigued by this. I'd feel better if we had some data about how many rules currently don't provide schemas because by doing this, we'd also be compelling them to make a breaking change. |
With some effort, we/I could write a script to download the ~3,500 eslint plugins (titled eslint-plugin-* or keyword:eslint-plugin,eslintplugin) from NPM or github (hopefully without hitting rate-limiting), then check files in Does that sound reasonable, or are there any better/easier ideas for collecting the data? And is there any specific finding you would want to see to feel comfortable moving forward? Regardless of what any analysis finds, I do believe that over the next year, we could help plugins prepare for this change with the ideas I outlined in my previous comment. And we could use this same approach in order to move forward with removing support for other deprecations like function-based rules (the lint rule eslint-plugin/prefer-object-rule would help). |
@bmish that sounds like a great approach. If you have the time to do that, we would appreciate it. |
@bmish having that data available would be amazing as we make the sorts of decisions you mentioned! Please share the code if you’re able because I could see us running it periodically to answer new questions that come up. |
I put together a repository called eslint-ecosystem-analyzer with scripts to perform an analysis of the ESLint plugin ecosystem. It retrieves the top ESLint plugin repositories by searching GitHub and then clones them so that metrics can be computed. The analysis output is included below. To summarize the findings:
These findings seem very favorable toward:
In order to move forward with both of these breaking changes:
Let me know what you think of this analysis and plan. If it sounds good, I could start on RFCs.
|
Wow, that is some fantastic analysis, thank you. I agree, I think the data supports being able to make this change. I’d suggest putting everything into a single RFC as it will be easier to look at the situation holistically. |
That is amazing 👏 I'm also supportive and feel much better knowing that the vast majority of the ecosystem is already prepared. |
Thanks for the feedback! I'll work on a single RFC in the near future. |
Oops! It looks like we lost track of this issue. @eslint/eslint-tsc what do we want to do here? This issue will auto-close in 7 days without an update. |
I still plan to work on this hopefully in the near future so we can target ESLint v9. |
Awesome, adding you as the assignee to make the bot happy. |
I have opened up an RFC for this: |
schema: []
schema: []
and drop support for function-style rules
I updated the title with dropping support for function-style rules, which is included in this change per eslint/rfcs#85. |
@bmish we are starting v9 development, so this is ready to be implemented now. |
Ping @bmish |
I'm working on this. |
The problem you want to solve.
Today, rule schemas (meta.schema) are optional. This has the following effects:
schema: []
, otherwise it's possible that developers could accidentally provide useless rule options to their rule without knowing it.There is an existing, third-party lint rule eslint-plugin/require-meta-schema to enforce that rules have schemas, but this rule is optional and thus not widely used.
Your take on the correct solution to problem.
Change the default rule schema to
schema: []
to enforce that no rule options are passed to rules that do not specify a schema.This has the desirable consequence of requiring rules with options to begin specifying their schema if they did not already.
This would be a breaking change suitable for the next major release.
Making ESLint's default behavior more strict like this goes along with many recent changes to tighten validation (i.e. more RuleTester class validation in ESLint 7, increased rule configuration validation in ESLint 6, etc) to improve rule usability and reduce the chance of mistakes.
And in addition to the obvious benefits of increased rule schema usage such as reduced chance of silent mistakes/bugs, being able to rely on having rule schemas available could enable:
Are you willing to submit a pull request to implement this change?
Yes. I am open to writing the RFC and implementation.
The text was updated successfully, but these errors were encountered: