eslint why does my plugin show Definition for rule was not found?
Solution 1
I think the key missing piece is no "plugins" section in config.
Why are you extending from "bluelovers"? Do you have a shared config published? It seems like you're working on a plugin, not a config.
You're then using a rule "@bluelovers/no-irregular-whitespace", with a leading @.
If your plugin is published as "@bluelovers/eslint-plugin", you should try something like this:
{
"plugins": ["@bluelovers"],
"extends": ["@bluelovers"], // Assuming you have @bluelovers/eslint-config published, otherwise this might look different or could be skipped
"rules": {
"@bluelovers/no-irregular-whitespace": ["error"]
}
}
Solution 2
It means eslint cannot find rules in your index.js
. Try having a look at your index.js
-exports. They should look something like this:
module.exports = {
rules: {
[myRuleName]: myRule
}
};
And not like this:
exports.default = {
rules: {
[myRuleName]: myRule
}
};
If you're using TypeScript, change your export in index.ts
from export default {...}
to export = {...}
.
bluelovers
Updated on December 23, 2021Comments
-
bluelovers over 2 years
my plugin
@bluelovers/eslint-plugin https://github.com/bluelovers/ws-node-bluelovers/tree/master/packages/eslint-plugin
my base config https://github.com/bluelovers/ws-node-bluelovers/blob/master/packages/eslintrc/.eslintrc.json
runtime user config
{ "extends": [ "bluelovers" ] }
i can type in user repo
eslint --print-config .
this can show config and didn't error, i also see my plugin config inside the list
"@bluelovers/no-irregular-whitespace": [ "error", { "skipComments": true, "skipStrings": false, "skipTemplates": false, "skipRegExps": false, "ignores": [ " " ] } ],
but when i type
eslint index.ts
, it show error1:1 error Definition for rule '@bluelovers/no-irregular-whitespace' was not found @bluelovers/no-irregular-whitespace
index.ts
export const r = /[ \t\uFEFF\xA0 ]+$/; const IRREGULAR_WHITESPACE = /[\f\v ]+/mgu;
how can i fix this??
-
bluelovers almost 5 yearsi have both, plugin and config, and plugin field is set on config
-
bluelovers almost 5 yearseslint-config-bluelovers , @bluelovers/eslint-plugin
-
O. R. Mapper almost 3 yearsIs this answer already outdated? The documentation provides an example for a rule, but the keyword
rules
appears nowhere in that article. -
brooklynDadCore almost 3 yearsThat link does not mention
rules
which is confusing, this one specifically about working with plugins talks aboutrules
-
Suncat2000 about 2 yearsWhat if your project doesn't have an index.js?