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.

Updating to lint-staged v9 issue -- using .eslintignore throws warnings!

See original GitHub issue

Recently we’ve updated to use the latest version of eslint from v6. It appears that lint-staged no longer allows an advanced config. Instead of configuring lint-staged directly, you recommend using .prettierignore (or in our case .eslintignore) to ignore files.

Unfortunately this doesn’t work very well because with .eslintignore we get a warning in the console. Here’s what it looks like in my terminal:

git commit -am "test"
husky > pre-commit (node v10.16.3)
🔍  Finding changed files since git revision 200ebaddb.
🎯  Found 0 changed files.
✅  Everything is awesome!
  ↓ Stashing changes... [skipped]
    → No partially staged files found...
  ❯ Running tasks...
    ❯ Running tasks for client/**/*.js|server/src/**/*.js|e2e-tests/cypress/**/*.js
      ✖ eslint --rule 'react/jsx-curly-brace-presence: 1' --fix --max-warnings=0
        node addCopyright.js
        git add



✖ eslint --rule 'react/jsx-curly-brace-presence: 1' --fix --max-warnings=0 found some errors. Please fix them and try committing again.

/Users/tnrich/Sites/hde/server/src/data-lib/entities/aaSequence/countAASequence.js
0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override

✖ 1 problem (0 errors, 1 warning)

The crucial part is that warning File ignored because of a matching ignore pattern.. Lint staged now passes all the files eslint which is causing the ignore warning.

Not quite sure what to do here. Any suggestions @okonet ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

19reactions
okonetcommented, Nov 13, 2019

I don’t see the problem here. It works as expected so I’m not sure what’s this is about. We don’t change the behavior at any time.

0reactions
tnrichcommented, Nov 14, 2019

Thanks for the help @okonet not your fault. I think that eslint needs to add an option to not throw a warning if a file is ignored by .eslintignore but is specifically passed to eslint like eslint myIgnoreFile.js.

In the meantime I find that this is a decent workaround:

//lint-staged.config.js
const fs = require("fs");
const micromatch = require("micromatch");

const ignore = fs.readFileSync(".eslintignore", "utf8");
const lines = ignore.match(/[^\r\n]+/g);
const jsRunners = files => {
    const match = micromatch.not(files, lines);
    return match.map(
      file =>
        `eslint ${file} --rule 'react/jsx-curly-brace-presence: 1' --fix --max-warnings=0`
    );
  };

module.exports = {
  "client/**/*.js": jsRunners,
  "server/src/**/*.js": jsRunners,
  "e2e-tests/cypress/**/*.js": jsRunners,
  "tg-iso-lims/src/**/*.js|cypress/**/*.js": jsRunners,
  "*.css": ["node addCopyright.js", "git add"]
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

lint-staged - npm
lint -staged GitHub Actions npm version Codecov. Run linters against staged git files and don't let slip into your code base!
Read more >
lint-staged - NPM Package Overview - Socket.dev
Linter commands work on a subset of all staged files, defined by a glob pattern. lint-staged uses micromatch for matching files with the ......
Read more >
Husky/lint-staged is it possible to exclude/ignore file?
While configuring lint-staged in package.json or If you're using any other IDE, in order to ignore/exclude files by lint-Staged and husky ...
Read more >
How to Automate Code Linting in Next.js with ESLint & Husky ...
Linting is the practice of checking code through automated static analysis for syntax errors and optionally code style issues.
Read more >
Error: Failed to load config "@vue/prettier" to extend - You.com
After installing react-native with npx it throws an error on me with eslint settings in webstorm.
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