Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint why does my plugin show Definition for rule was not found?

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

like image 270
bluelovers Avatar asked Jun 01 '19 05:06

bluelovers


People also ask

Where do you define ESLint rules?

To limit ESLint to a specific project, place "root": true inside the . eslintrc. * file or eslintConfig field of the package. json file or in the .

What does 2 mean in ESLint rules?

I defines the severity of a rule. Severity should be one of the following: 0 = off, 1 = warning, 2 = error (you passed "3"). Documentation: https://eslint.org/docs/user-guide/configuring/rules.

Where is the ESLint config file?

The ESLint configuration is in the ./node_modules/@spm/eslint-config/index. js file. To check the code for ESLint violations, run the following command in the application root directory. Errors are listed in the console.


1 Answers

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"]
    }
}
like image 59
Platinum Azure Avatar answered Oct 01 '22 17:10

Platinum Azure