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.

.eslintignore: can't exclude files from node_modules once ignored

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.4.1
  • Node Version: 8.2.1
  • npm Version: 5.3.0

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration

module.exports = {
  extends: 'airbnb',
  parser: 'babel-eslint',
  plugins: [
    'react',
    'import',
  ],
  rules: {
    'max-len': 'off',
    'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx'] }],
    'import/first': ['error', { 'absolute-first': false }],
    'import/no-extraneous-dependencies': ['error', { devDependencies: true, optionalDependencies: false, peerDependencies: true }],
    curly: ['error', 'all'],
  },
  env: {
    browser: true,
    jest: true,
  },
  settings: {
    'import/cache:': {
      lifetime: 2,
    },
    'import/resolver': {
      webpack: {
        config: path.join(__dirname, 'webpack.config.dev.js'),
      },
    },
  },
};
!.*
node_modules/
coverage/
junit/
dist/
mobiles/
!node_modules/some-package/

What did you do? Please include the actual source code causing the issue.

Introduce linting error in node_modules/some-package/test.js

const test = 1 // missing semi (also unused const)

What did you expect to happen?

A linting error. When I comment node_modules in .eslintignore it works, but also lints node_modules.

What actually happened? Please include the actual, raw output from ESLint.

eslint .
can't resolve reference #/definitions/basicConfig from id #
can't resolve reference #/definitions/basicConfigOrBoolean from id #
can't resolve reference #/definitions/basicConfigOrBoolean from id #
Done in 47.24s.

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kaelzhangcommented, Aug 14, 2017

@not-an-aardvark

According to the .gitignore rules

It is not possible to re-include a file if a parent directory of that file is excluded.

node_modules/* only ignores the things inside the directory.

While node_modules/ ignores the directory and everything inside it, then node_modules/some-packages could not be re-included because its parent dir node_modules/ is ignored.

0reactions
adrienharnaycommented, Aug 14, 2017

Ok figured it out. It was a mix of @kaelzhang 's solution, and the fact that I have nested node_modules in my project.

!.*
coverage/
junit/
dist/
mobiles/
**/node_modules/*
!**/node_modules/some-package/

did the trick. Thanks to all!

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
Create a dedicated file that contains the ignore patterns ( .eslintignore by default) ... You cannot write ignorePatterns property under overrides property.
Read more >
eslintignore file doesn't seem to be working
Paths are being resolved correctly, but of course you're not going to describe files to ignore in one project from another project's eslintignore....
Read more >
Ignoring ESLint - next.config.js
Next.js reports ESLint errors and warnings during builds by default. Learn how to opt-out of this behavior here.
Read more >
prettier-eslint-cli - npm
--eslint-ignore Only format matching files even if they are not ignored by .eslintignore. (can use --no-eslint-ignore to disable this) ...
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