Bug: can't escape `]` in `.eslintignore`
See original GitHub issueEnvironment
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:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let’s keep it open until we update
eslintrc
ineslint
itself. - https://github.com/eslint/eslint/pull/15666I tried upgrading
ignore
in https://github.com/eslint/eslintrc/pull/72 and it doesn’t affect any existing tests.