newBike
newBike

Reputation: 15012

Can Eslint specify configuration under child package with monorepo


.eslintrc.json
│   ├── app1
│   └── app2
│       ├── .eslintrc.json

Running this command under app2 child package.

./node_modules/eslint/bin/eslint.js ./src/ --config .eslintrc.json

And showing this error...

Oops! Something went wrong! :(

ESLint: 8.4.1

ESLint couldn't determine the plugin "@typescript-eslint" uniquely.

- @typescript-eslint/eslint-plugin/dist/index.js (loaded in "../../.eslintrc.json )...

why ESlint still trying to access ../../.eslintrc.json in the root folder?

Upvotes: 3

Views: 2413

Answers (1)

GOTO 0
GOTO 0

Reputation: 47801

From the documentation (emphasis mine):

The first way to use configuration files is via .eslintrc.* and package.json files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless root: true is specified).

So the reason why ESLint is accessing an ".eslintrc.json" file located in a parent folder is simply because that is the default behaviour. If not otherwise specified, ".eslintrc.*" files will inherit their settings from other ".eslintrc.*" files in their ancestor folders.

To prevent this behavior, set "root": true in the ".eslintrc.json" file inside "app2", and ESLint will no longer try to access "../../.eslintrc.json" or any other configuration files up in the directory structure.

Upvotes: 5

Related Questions