Reputation: 185
I'm trying to implement eslint
in a Next.js
project.The file structure look like below
.eslintignore
.eslintrc.js
.next
.prettierrc
.stylelintrc.js
components
forms
modals
modules
node_modules
And I have node_modules/*
in my .eslintignore
file. When I try to lint these by eslint --fix /sources/**/*.js
I am getting below error
You are linting "/sources/node_modules/ally.js", but all of the files matching the glob pattern "/sources/node_modules/ally.js" are ignored.
Anyone can help me to solve this? Thanks
Upvotes: 3
Views: 7630
Reputation: 878
Linters don't work the same with different node versions.
In this case updating node from v14.x
to v16.x
worked for me.
If .eslintignore
config doesn't work for you, consider checking your node version.
Upvotes: 0
Reputation: 2245
The issue might come from your command line.
If you forget the single quotes, your terminal is going to evaluate the glob (**/*
), not eslint
. So this will skip all eslint ignore settings.
If you enable eslint
's debug logs with --debug
, you will see it in action:
$ eslint **/*.ts --debug 2>&1 | grep "CLI args"
eslint:cli CLI args: [ 'a.ts', 'b.ts', 'node_modules/package/a.ts', 'node_modules/package/b.ts', '--debug' ]
$ eslint '**/*.ts' --debug 2>&1 | grep "CLI args"
eslint:cli CLI args: [ '**/*.ts', '--debug' ]
Upvotes: 2
Reputation: 6613
If .eslintignore
located in the same directory as node_modules
you can specify it as node_modules
.
# .eslintignore
node_modules
**/.next/**
**/_next/**
**/dist/**
.eslintignore
follows .gitignore
syntax.
See .gitignore specs for more details.
Upvotes: 1