I'm trying to implement eslint
in a Next.js
project.The file structure look like below
.eslintignore
.eslintrc.js
.next
.prettierrc
.stylelintrc.js
ponents
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
I'm trying to implement eslint
in a Next.js
project.The file structure look like below
.eslintignore
.eslintrc.js
.next
.prettierrc
.stylelintrc.js
ponents
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
**/node_modules/*
?
– Manuel Spigolon
Commented
May 20, 2021 at 6:37
./node_modules
– enoch
Commented
May 20, 2021 at 6:44
node_modules
and .next
folder then reinstall with them with npm install
.
– enoch
Commented
May 20, 2021 at 6:49
The issue might e from your mand 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' ]
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.
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.