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.

Bug: can't escape `]` in `.eslintignore`

See original GitHub issue

Environment

Node version: v14.17.0 npm version: v8.3.0 Local ESLint version: v8.9.0 (Currently used) Global ESLint version: Not found Operating System: darwin 21.2.0

What parser are you using?

Default (Espree)

What did you do?

Configuration
module.exports = {
  rules: {
    "no-console": "error",
  },
};

I’ve set up minimal example repository to reproduce the issue but I’ll describe the issue here as well.

I have a few files and some of them contain special characters like [.

➜  eslint-eslintignore-glob-pattern-issue git:(main) ✗ find src
src
src/index].js
src/[index].js
src/index.js
src/[index.js

I’d like to ignore all of them so I have them listed in an .eslintignore using \ to escape the special characters.

➜  eslint-eslintignore-glob-pattern-issue git:(main) ✗ cat .eslintignore 
src/index.js
src/\[index.js
src/index\].js
src/\[index\].js

What did you expect to happen?

All files listed in .eslintignore to be ignored, zero errors.

What actually happened?

Two of the files won’t be ignored when I lint them using ESLint.

➜  eslint-eslintignore-glob-pattern-issue git:(main) ✗ npm run lint

> eslint-eslintignore-glob-pattern-issue@1.0.0 lint
> eslint '**/*.js' --ignore-path .eslintignore


[removed]/eslint-eslintignore-glob-pattern-issue/src/[index].js
  1:1  error  Unexpected console statement  no-console

[removed]/eslint-eslintignore-glob-pattern-issue/src/index].js
  1:1  error  Unexpected console statement  no-console

✖ 2 problems (2 errors, 0 warnings)

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

The same glob patterns work in .gitignore.

➜  eslint-eslintignore-glob-pattern-issue git:(main) cat .gitignore
node_modules/
src/\[app\].js
src/app\].js
➜  eslint-eslintignore-glob-pattern-issue git:(main) git status --ignored
On branch main
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        node_modules/
        src/[app].js
        src/app].js

nothing to commit, working tree clean

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
snitin315commented, Mar 4, 2022

Let’s keep it open until we update eslintrc in eslint itself. - https://github.com/eslint/eslint/pull/15666

1reaction
snitin315commented, Mar 1, 2022

I tried upgrading ignore in https://github.com/eslint/eslintrc/pull/72 and it doesn’t affect any existing tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable eslint rules for folder - Stack Overflow
To ignore some folder from eslint rules we could create the file .eslintignore in root directory and add there the path to the...
Read more >
ESLint linter doesn't honor .eslintignore file · Issue #6 - GitHub
I am making the assumption here that this is not a bug and rather its my miss-understanding of the implementation...
Read more >
Rules - ESLint - Pluggable JavaScript Linter
Rules are the core building block of ESLint. A rule validates if your code meets a certain expectation, and what to do if...
Read more >
Ignoring ESLint - next.config.js
Ignoring ESLint. When ESLint is detected in your project, Next.js fails your production build ( next build ) when errors are present.
Read more >
eslint does not lint file Code Example - Code Grepper
eslint ignore next line · javascript detect escape key ... ng : File C:\Users\nEW u\AppData\Roaming\npm\ng.ps1 cannot be loaded.
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