【发布时间】:2020-06-09 15:14:54
【问题描述】:
我在 Visual Studio Code 中使用 ESLint plugin by Dirk Baeumer。
我的项目又大又复杂,分为几个主目录。每个目录都有自己的 package.json 文件、自己的 node_modules 目录和自己的 eslint 版本。这在升级到 ESLint 6 后造成了严重破坏,因为我的 ESLint plugins won't resolve。
如何配置 ESLint 插件以尊重每个目录中使用的 eslint 版本?我觉得跟eslint.workingDirectories的设置有关系,但是不明白怎么正确使用。
更多信息:
我的项目工作区有两个根目录,“folder1”和“folder2”。目录结构如下所示:
folder1
.eslintrc.json -- rules for the entire "folder1" project to follow
build
platform
core
Makefile
core-v1
.eslintrc.json
Makefile
package.json -- eslint v4
node_modules
core-v2
.eslintrc.json
Makefile
package.json -- eslint v6
node_modules
folder2
我的工作区配置文件包括:
"eslint.workingDirectories": [
"./folder1/core/core-v1",
"./folder1/core/core-v2"
]
这似乎会产生以下错误,并且没有检测到或突出显示任何 linting 错误:
Uncaught exception received.
Error: spawn /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper (Renderer).app/Contents/MacOS/Code - Insiders Helper (Renderer) ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
如何配置 ESLint 插件以使用 eslint v4 处理“folder1/core/core-v1”中的文件,使用 v6 处理“folder1/core/core-v2”中的文件?我的构建过程为这些目录运行单独的脚本,但我的编辑器(VS Code)正在尝试使用 v4 或 v6 对项目中的所有文件进行 lint。
【问题讨论】: