admin管理员组文章数量:1022956
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.
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.
本文标签: typescriptCreate Eslint plugin as part of libraryStack Overflow
版权声明:本文标题:typescript - Create Eslint plugin as part of library? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745578503a2157166.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论