question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable 'eslint' in all (nested) 'node_modules'.

See original GitHub issue

environment

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
  1. 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
suren-atoyancommented, Apr 4, 2018

I’ll try to explain more detailed and in another way.

When you create an app with CRA, you get a structure like this.

β”œβ”€β”€ appName
β”‚   β”œβ”€β”€  node_modules
β”‚   β”‚   β”œβ”€β”€  ...
β”‚   β”œβ”€β”€  public
β”‚   β”‚   β”œβ”€β”€  index.html
β”‚   |   β”œβ”€β”€  ...
β”‚   β”œβ”€β”€  src
β”‚   β”‚   β”œβ”€β”€  App.js
β”‚   |   β”œβ”€β”€  ...
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ ...

So, let’s imagine that during development I have a structure like this one.

β”œβ”€β”€ appName
β”‚   β”œβ”€β”€  node_modules
β”‚   β”‚   β”œβ”€β”€  ...
β”‚   β”œβ”€β”€  public
β”‚   β”‚   β”œβ”€β”€  index.html
β”‚   |   β”œβ”€β”€  ...
β”‚   β”œβ”€β”€  src
β”‚   β”‚   β”œβ”€β”€   core
β”‚   β”‚   |   β”œβ”€β”€  atoms
β”‚   β”‚   |   β”œβ”€β”€  molecules
β”‚   β”‚   |   β”œβ”€β”€  organisms
β”‚   β”‚   |   β”œβ”€β”€  ...
β”‚   β”‚   |   β”œβ”€β”€  package.json
β”‚   β”‚   |   β”œβ”€β”€  node_modules
β”‚   β”‚   β”œβ”€β”€  App.js
β”‚   |   β”œβ”€β”€  ...
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ ...

In this case, I will get many errors, because your eslint will start checking sources under core/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 of eslint in all node_modules can be a bad thing.

Can’t we ever have some folder in which exists package.json and node_modules under src in the app created by CRA?

0reactions
stale[bot]commented, Nov 2, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found