Muhammad Umer
Muhammad Umer

Reputation: 18097

vscode eslint not ignoring directory?

Despite clearly indicating in esignore that I want to ignore everything inside lib directory, vscode is saying 9 problems found in that minimized file.

If I run eslint inside foldera in command line everything is fine

using this extension

My directory structure:

foldera/
    .eslintrc
    .eslintignore
    src/
        file.js
    lib/
        wantoignore.min.js
folderb/
    morefiles.js
    .eslintrc
    .eslintignore

.eslintrc file

{
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 2017,
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true
        },
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "no-console": "off"
    }
}

.eslintignore

lib/*

workspace settings:

  "eslint.workingDirectories": [
      "./client", "./server"
   ]

Upvotes: 8

Views: 8350

Answers (3)

Quang Dong
Quang Dong

Reputation: 497

My solutions is:

Source map

root/.vscode/settings.json

Script

    {  
      "eslint.workingDirectories": [{ "mode": "auto" }],
    }

Upvotes: 2

Alonad
Alonad

Reputation: 2236

I had a similar problem, figured out need to set workingDirectory to nested folder:

module
  lib
    src
      index.ts
    .eslintrc.js
    .eslintignore

VSCode setting should be:

  "eslint.workingDirectories": [ "./module/lib" ]

And not

  "eslint.workingDirectories": [ "./module" ]

Upvotes: 0

JowieXiang
JowieXiang

Reputation: 91

I solved this problem following the official doc here.

Basically you need to add the following content to the vscode workspace settings (usually located in your project's root/.vscode/settings.json), so that vscode knows which configs to honor when you're working on a specific script file:

{
    "eslint.workingDirectories": [ "./reactApp" ],
}

Upvotes: 9

Related Questions