Which packages would you like to change?
What problem do you want to solve?
Right now, there's no standard factory function for writing ESLint plugins. https://eslint.org/docs/latest/extend/plugins provides suggested starting objects but:
- It's easy to mistype, forget fields, etc. in plain objects
- Having a factory function makes it easier to give types-directed suggestions in editors and type checking
- The function could abstract away the -IMO confusing- computed
get()er and/or Object.assign folks have to do to get circular references working in the objects
- It could also apply common patterns and/or optimizations for users so they don't have to:
What do you think is the correct solution?
How about an @eslint/plugin-utils package with a definePlugin export?
import { definePlugin } from "@eslint/plugin-utils";
export default definePlugin({
meta: {
name: "eslint-plugin-example",
version: "1.2.3",
},
rules: {
"dollar-sign": {
meta: {
docs: {
recommended: true,
}
},
create(context) {
// rule implementation ...
},
},
},
});
That meta.docs.recommended could be used to generate a configs.recommended in the standard format(s) preferred by flat config.
Participation
Additional comments
@eslint/plugin-kit exists but it's really more of a "languages" kit. I separately tried searching plugin-kit, plugin-utils, and similar terms on ESLint's issue trackers. The closest mention I could find was eslint/eslint#4301 (comment). I have a vague memory of this being discussed somewhere previously, but can't remember where...?
I'd be happy to write up an RFC if it's a direction the project would be interested in.
Which packages would you like to change?
@eslint/compat@eslint/config-array@eslint/config-helpers@eslint/core@eslint/migrate-config@eslint/object-schema@eslint/plugin-kitWhat problem do you want to solve?
Right now, there's no standard factory function for writing ESLint plugins. https://eslint.org/docs/latest/extend/plugins provides suggested starting objects but:
get()er and/orObject.assignfolks have to do to get circular references working in the objectsmeta.docs.recommendedor other propertiesWhat do you think is the correct solution?
How about an
@eslint/plugin-utilspackage with adefinePluginexport?That
meta.docs.recommendedcould be used to generate aconfigs.recommendedin the standard format(s) preferred by flat config.Participation
Additional comments
@eslint/plugin-kitexists but it's really more of a "languages" kit. I separately tried searchingplugin-kit,plugin-utils, and similar terms on ESLint's issue trackers. The closest mention I could find was eslint/eslint#4301 (comment). I have a vague memory of this being discussed somewhere previously, but can't remember where...?I'd be happy to write up an RFC if it's a direction the project would be interested in.