Search code examples
eslintvisual-studio-codeeslintrc

How can I add ESLInt custom rules directory to VSCode


I am running VSCode with the ESLint plugin. My project contains some custom rules, which live in a particular directory.

If I run ESLint from the command line and pass in --rulesdir=./custom-eslint-rules everything works as expected.

However, I am specifically referring to the linting that happens per file in the editor itself. There, it lints using the normal rules, but shows errors that the definitions for my custom rules are missing.

How can I configure VSCode so that the per-file linting sees my custom rule definitions that live in a particular directory?


Solution

  • In your setting.json:

    "eslint.options": {
      "rulePaths": "<path>"
    }
    

    Reference: https://eslint.org/docs/developer-guide/nodejs-api#cliengine