Reputation: 587
I have few questions about cascading eslint config file:
tsconfig.json
(in typescript) where I have a root .eslintrc.yml
and I can extend/cascade that to each .eslintrc.yml
for each folder (project)? I'm not sure if this is what the documentation says here.extends
option where sometimes the order is important like on the case of eslint-config-prettier
as mentioned on their docs. There it says:Make sure to put it last, so it gets the chance to override other configs.
plugins
option the order is not important but on extends
sometimes the order is important like what I mentioned on question #2. extends
option, how can I make sure that it follows the order when I have an extension like eslint-plugin-prettier
where it should be the last when I'm not using cascading. For example: If I'm not using cascading it should be like this as what is mentioned here:
extends:
- "some-other-config-you-use"
- "prettier"
- "prettier/@typescript-eslint"
- "prettier/react"
If I'm using cascading my setup will be like this:
# root
root: true
parser: "@typescript-eslint/parser"
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/recommended"
- "prettier"
- "prettier/@typescript-eslint"
# sub-folder
env:
browser: true
extends:
- "plugins:react/recommended"
- "plugins:jsx-a11y/recommended"
- "prettier/react"
Upvotes: 3
Views: 1295
Reputation: 2191
Related to this, I was running into an error after creating the .eslintrc.js
file in a subdirectory:
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config
The solution was to specify ignorePatterns: ['.eslintrc.js'],
in the root config, as discussed here.
Upvotes: 0
Reputation: 13077
root: true
parser: "@typescript-eslint/parser"
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/recommended"
- “./path/your_other_config”
- "prettier"
- "prettier/@typescript-eslint"
Upvotes: 1