76

Somehow after updatingBabel from6 to7 myeslint started giving such a warning innode_modules:

enter image description here

So, from my understandingnode_modules folder is not ignored and that is why the issue popped up. So, reading througheslint docs:

https://eslint.org/docs/user-guide/configuring

I tried adding"ignorePatterns": ["node_modules/"], to the.eslintrc file but got an error:

Module build failed: Error: ESLint configuration in /Users/vlasenkona/Desktop/gris-seqr2/ui/.eslintrc is invalid: - Unexpected top-level property "ignorePatterns".

So, I tried creating.eslintignore file and added there justnode_modules/ but the warning stayed the same. How could I ignore thenode_modules folder? The versions of the packages I am using:

"eslint": "^5.16.0","babel-eslint": "^9.0.0","eslint-config-airbnb": "^16.1.0","eslint-import-resolver-babel-module": "^5.1.2","eslint-loader": "1.9.0","eslint-plugin-flowtype": "2.39.1","eslint-plugin-import": "^2.20.1","eslint-plugin-jsx-a11y": "^6.1.0","eslint-plugin-react": "^7.10.0","eslint-plugin-react-perf": "^2.0.8",

The.eslintrc looks like that:

{  "extends": [    "airbnb",    "plugin:react-perf/recommended"  ],    "parser": "babel-eslint",  "parserOptions": {    "ecmaFeatures": {      "experimentalObjectRestSpread": true    }     },    "env": {    "mocha": true,    "es6": true,    "browser": true,    "node": true,    "jest": true  },    "settings": {    "import/resolver": {      "babel-module": {}    }     },    "rules": {    "semi": [2, "never"],    "no-shadow": ["error", { "allow": ["error"] }],     "arrow-body-style": 0,    "func-names": 0,    "function-paren-newline": 0,    "max-len": 0, //["warn", 80, 2],     "no-console": 0,    "no-multi-str": 0,    "no-param-reassign": 0,    "no-plusplus": 0,    "brace-style": 0,    "object-curly-newline": 0,    "padded-blocks": 0,    "react/jsx-first-prop-new-line": 0,    "react/jsx-wrap-multilines": 0,    "react/prefer-stateless-function": 0,    "react/sort-comp": 0,  // more freedom in arranging class functions    "import/prefer-default-export": 0,    "react/forbid-prop-types": 0,    "no-class-assign": 0,    "react/jsx-filename-extension": [ 1, { "extensions": [".js", ".jsx"]} ],    "react/require-default-props": 0,    "react/require-optimization": 2,    "react/jsx-max-props-per-line": 0,    "react/jsx-no-target-blank": 0,    "spaced-comment": 0,    "jsx-a11y/iframe-has-title": 0,    "jsx-a11y/tabindex-no-positive": 0,    "jsx-a11y/click-events-have-key-events": 0,    "jsx-a11y/anchor-is-valid": 0  }}

Update

I tried adding the following to newly created.eslintignore:

node_modules/*./node_modules/****/node_modules/**

But neither works. Interestingly enough, if I open./node_modules/draftjs-md-converter/dist/index.js and put at the very beginning and end of the file/*eslint-disable */ the warning still remains, so maybe it is not aneslint problem: just totally misleading warning?..

askedFeb 12, 2020 at 15:46
Nikita Vlasenko's user avatar
12
  • Ignore all node_modules folder withnode_modules/* in.eslintignoreCommentedFeb 12, 2020 at 15:50
  • 1
    I tried this too and the error stays the sameCommentedFeb 12, 2020 at 16:28
  • Tried also downgradingeslint to version4.19.1 but no luckCommentedFeb 12, 2020 at 16:37
  • I'm having a similar issue... @NikitaVlasenko did you manage to fix it?CommentedFeb 27, 2020 at 10:50
  • 1
    @NikitaVlasenko any workaround for this in 2021?CommentedMar 3, 2021 at 5:36

5 Answers5

17

In my case, ESLint (v7.8.1) was ignoringnode_modules directories properly, but not mydist directory. I added this to.eslintignore:

client/dist/

and that resolved the issue.

answeredSep 12, 2020 at 0:24
Josh Hansen's user avatar
Sign up to request clarification or add additional context in comments.

Comments

6

Edit: I shouldn't have had a second node_modules folder in the first place, it works with using only the main folder now


Ignoringnode_modules/ in the .eslintignore file in the root folder worked for me.

node_modules/* did not, it caused "An unhandled exception occurred: Failed to load config "airbnb" to extend from." or similar errors when linting the sub-project.

Our project structure looks like this:

root-project

  • node_modules
  • projects
    • sub-project
      • node_modules
      • package.json
      • .eslintrc.json
      • ...
  • src
  • .eslintignore
  • .eslintrc.json
  • ...
answeredAug 17, 2021 at 9:06
Marlene's user avatar

Comments

5

For me,it was my node version. I was running 14 andeslint server was running on 16. This causedeslint to lint all of my node modules.

If you're usingnvm, switch to a newer node:

nvm use 18

You can see the ESLint node server version in your IDE using theESLint: Show Output Channel command.


answeredJun 8, 2023 at 15:41
joematune's user avatar

Comments

5

I had the following script in mypackage.json:

  "scripts": {    "lint": "eslint **/*.ts",  }

It turns out that my shell was expanding the glob, so it passed all.ts files as arguments toeslint (including the ones innode_modules), causing the ignore rules ofeslint to not be applied.

I fixed it by changing the script to pass the glob to eslint rather than expanding it:

  "scripts": {    "lint": "eslint '**/*.ts'",  }
answeredDec 30, 2023 at 0:48
cdauth's user avatar

Comments

1

I've got the same problem.Solution: Make sure your file ".eslintrc" is in the root directory of your project. Where is package.json, node_modules and other things. Good luck.

answeredFeb 28, 2020 at 22:19
Oleg Oshurkov's user avatar

1 Comment

For me,.eslintrc is already in the folder where these other files are located. Moving it to the root of the large project that I have would be wrong logically.

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.