admin管理员组

文章数量:1181449

my plugin

@bluelovers/eslint-plugin

my base config /.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 error

   1: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??

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 error

   1: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??

Share Improve this question edited Jun 1, 2019 at 9:08 R.J. Dunnill 2,0793 gold badges11 silver badges23 bronze badges asked Jun 1, 2019 at 5:31 blueloversbluelovers 1,2552 gold badges12 silver badges24 bronze badges 2
  • 12 At least in my case this was not a configuration issue and could be resolved by simply restarting VS Code. So before you start digging in the documentation of a dozen eslint plugins, you might want to give that a try. I'll just leave this here as a hint. – tillsanders Commented Jan 6, 2021 at 16:15
  • 1 @bluelovers did you get an answer to this? I see that you have removed the eslintrc from your project. Im stuck on the same issue. – Ashwin Commented Sep 1, 2023 at 10:09
Add a comment  | 

2 Answers 2

Reset to default 13

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"]
    }
}

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 = {...}.

本文标签: javascripteslint why does my plugin show Definition for rule was not foundStack Overflow