I don't want to publish an eslint plugin as an own npm artifact to share it with other projects.
Instead I already have a npm package published which other projects use. So is it possible I put the Eslint plugin there, and the other projects can extend it ? Instead of having 2 npm artifacts published and having to maintain , I still have only the original one.
Thanks for your help!
I don't want to publish an eslint plugin as an own npm artifact to share it with other projects.
Instead I already have a npm package published which other projects use. So is it possible I put the Eslint plugin there, and the other projects can extend it ? Instead of having 2 npm artifacts published and having to maintain , I still have only the original one.
Thanks for your help!
Share Improve this question asked Nov 19, 2024 at 7:17 Steve CleverSteve Clever 1171 gold badge1 silver badge7 bronze badges1 Answer
Reset to default 0Yes, this is possible. ESLint's new "flat" config (https://eslint./docs/latest/use/configure/configuration-files) allows importing plugins as plain old JavaScript. See https://eslint./docs/latest/use/configure/plugins.
For example, if your plugin is located in ./packages/eslint-plugin-example
, your config might look something like:
// eslint.config.js
import example from "./path/to/eslint-plugin-example";
export default [
{
plugins: {
example
},
rules: {
"example/rule1": "warn"
}
}
];
If you're using using workspaces such as through npm (https://docs.npmjs/cli/v8/using-npm/workspaces) or another package manager, that import path might just be "eslint-plugin-example"
instead. It depends on how you've structured your repository.