2
votes

I am using the ESLint plugin by Dirk Baeumer in Visual Studio Code.

My project is large and complex and divided into several primary directories. Each directory has its own package.json file, its own node_modules directory and its own version of eslint. This is causing havoc after upgrading to ESLint 6 because my ESLint plugins won't resolve.

How do I configure the ESLint plugin to respect the eslint version used in each directory? I think it has something to do with the eslint.workingDirectories setting, but I don't understand how to use it properly.

Further information:

My project workspace has two root directories, "folder1" and "folder2". The directory structure looks something like this:

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

My workspace configuration file includes:

        "eslint.workingDirectories": [
            "./folder1/core/core-v1",
            "./folder1/core/core-v2"
        ]

This seems to produce the following error, and no linting errors are detected or highlighted:

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)

How do I configure the ESLint plugin to use eslint v4 for files in "folder1/core/core-v1" and v6 for files in "folder1/core/core-v2"? My build process runs separate scripts for these directories, but my editor (VS Code) is trying to use a either v4 or v6 to lint all of the files in my project.

1

1 Answers

2
votes

First off, the working directories cannot include root folder names:

        "eslint.workingDirectories": [
            "./core/core-v1",
            "./core/core-v2"
        ]

This seems to correctly identify the working directories and allows version 6 of ESLint to correctly resolve plugins, etc. It also applies v6 rules to core-v2 but still seems to be using the v4 rules for core-v1, so I think this is correct.

One issue that is still not resolve completely is how this works with multi-root workspaces. This works fine for folder1. folder2 just seems to be working, though I can't explain why since it's not identified as a working directory. Thankfully there are no conflicting paths, but what would I do if there were? That may be worth a separate question, but I seem to be up and running now.