Reputation: 1197
In my test files I get eslint error on some imports like
'import/no-extraneous-dependencies': ["error", { devDependencies: true, }],
this happens only in my second tests directory in some subfolder
in my root tests directory I don't get this errors
I didn't find any settings in package.json or .eslintrc which could cause differentiation.
Currently I have to use
/* eslint-disable import/no-extraneous-dependencies*/
in my test files which we don't like
If I add
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
to .eslintrc th rule is off everywhere not just in tests
How can I switch this rule of except of placing .eslintrc to the tests folder? which folders use devDependencies?
Upvotes: 12
Views: 10436
Reputation: 900
You can use an array of globs as follows, which will allow extraneous dependencies to be access from test files where file name matches **/*.test.js
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js"]}]
Upvotes: 25
Reputation: 3614
You can create a .eslintignore
file in the project root to disable ESLint for specific files or directories.
And put the following line into it:
test/*
Reference: http://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories
Edit:
If you want to ignore a specific rule for a particular directory, you can put another .eslintrc
file in that directory.
Reference: http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
Upvotes: -3