.eslintrc.json
│ ├── app1
│ └── app2
│ ├── .eslintrc.json
在app2子包下运行此命令。
./node_modules/eslint/bin/eslint.js ./src/ --config .eslintrc.json
并显示此错误。。。
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 )...
为什么ESlint仍在尝试访问../../。eslintrc.json在根文件夹中?
来自文档(强调矿(:
使用配置文件的第一种方式是通过
.eslintrc.*
和package.json
文件。ESLint将自动在要linted的文件的目录中以及连续的父目录中查找它们,直到文件系统的根目录(除非指定了root: true
(。
所以ESLint访问一个";。eslintrc.json";位于父文件夹中的文件只是因为这是默认行为。如果没有另外指定;。eslintr.*";文件将从其他"继承它们的设置;。eslintr.*";其祖先文件夹中的文件。
为了防止这种行为,在"中设置"root": true
;。eslintrc.json";文件内部";app2";,并且ESLint将不再试图访问"../../"。eslintrc.json";或目录结构中的任何其他配置文件。