Disable 'eslint' in all (nested) 'node_modules'.
See original GitHub issueenvironment
OS - macOS: HighSierra - 10.13.3 (17D102)
Node - v8.7.0
Npm - v5.6.0
create-react-app - v1.4.1
react-scripts - v.1.1.2
Steps to reproduce:
create-react-app test_app
cd test_app/src
mkdir x && cd "$_"
npm init -y
npm install moment
echo "import moment from 'moment'" > y.js
- import y.js file from src/App.js. Like this
import React, { Component } from 'react';
import logo from './logo.svg';
import './x/y';
npm start
You should see βeslintβ errors like this
./src/x/node_modules/moment/moment.js
Line 5: 'define' is not defined no-undef
Line 5: 'define' is not defined no-undef
Search for the keywords to learn more about each error.
When You add this line
/* eslint-disable */
to the top of β./src/x/node_modules/moment/moment.jsβ file, the issue will be solved.
Thank you.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Eslint not ignoring node_modules folder - Stack Overflow
In my case, ESLint (v7.8.1) was ignoring node_modules directories properly, but not my dist directory. I added this to .eslintignore :
Read more >Ignoring Code - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Π΄ΡΠ½ on Twitter: "OK this one actually makes sense. I forgot I ...
I forgot I have nested node_modules in inner packages. ... React compiled bundle in my node_module has an eslint-disable comment with an internal...
Read more >eslint-plugin-disable - npm
To disable plugins for file paths use new ESLint 6+ Overrides feature in config (.eslintrc). It has many different configurations for glob pathΒ ......
Read more >How to disable ESLint for some lines, files or folders
How to disable ESLint for some lines, files or folders ; /* eslint-disable */ Β· 'JavaScript debug log'); console.log('eslint is disabled now');.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Iβll try to explain more detailed and in another way.
When you create an app with CRA, you get a structure like this.
So, letβs imagine that during development I have a structure like this one.
In this case, I will get many errors, because your
eslint
will start checking sources undercore/node_modules
. (We can reproduce this, by trying steps mentioned in the first message of this discussion).My question is still the same. Is it okay, that
eslint
checks sources under**/node_modules
?In my subjective opinion the way by which this
node_modules
appears under/src
has secondary importance. It can be git submodule or something else. And I canβt find a situation, when disabling ofeslint
in allnode_modules
can be a bad thing.Canβt we ever have some folder in which exists
package.json
andnode_modules
undersrc
in the app created by CRA?This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.