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.

Add CLI Option to Ignore Passed File Paths in case they are Ignored by eslintignore

See original GitHub issue

The version of ESLint you are using.

6.3.0

The problem you want to solve.

I use lint-staged for running eslint and prettier on each commit. The problem is that I have a few files in my repo that should be ignored by eslint. I have put them into eslintignore, but when I commit, lint-staged will call eslint with all committed files explicitly, i.e. eslint —fix —ext *.{js,ts,tsx} path/to/myfile.tsx path/to/ignored/file.js. eslint ignores eslintignore for files explicitly passed to the eslint CLI.

Your take on the correct solution to problem.

I would suggest to add a new CLI option to ignore passed files in case they are ignored by eslintignore. Also make sure that even when all passed files are ignored, eslint should still exit with code 0.

I would not solve this on lint-staged‘s side because it is tool agnostic and does not know about how eslint works or how it ignores files.

Are you willing to submit a pull request to implement this change?

Currently not.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
fabbcommented, Oct 29, 2019

@robbie-c eslint will exit with a 0 exit code when there are just warnings and no errors, so it works fine with lint-staged. But when one uses eslint --max-warnings 0 which might be desirable, then it would exit with a non-zero exit code, so yes, in this case it would make sense to have no warning in the case of provided ignored file paths. Since it does not fit the my original issue, could you create a new issue for that?

2reactions
fabbcommented, Sep 22, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring Code - ESLint - Pluggable JavaScript Linter
You can ignore files in the following ways: Add ignorePatterns to a configuration file. Create a dedicated file that contains the ignore patterns...
Read more >
how to silence warnings about ignored files in eslint
One workaround I know at the moment is --quiet option, which suppresses all warnings. Of course that doesn't make sense if you have...
Read more >
Configuring ESLint - ESLint中文文档
Ignoring Files and Directories ... When ESLint is run, it looks in the current working directory to find an .eslintignore file before determining...
Read more >
lint-staged - npm
Ultimately you only want to lint files that will be committed. ... will always pass a list of all staged files to the...
Read more >
Command Line Interface - ESLint - Pluggable ... - GitHub Pages
Ignoring files. --ignore-path. This option allows you to specify the file to use as your .eslintignore . By default, ...
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