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?
ESLint requires ESLint configuration files ( .eslintrc.* files) under your projects Although the ESLint analysis fails by any reasons, you can see the analysis results of DeepScan without an interruption. By default, ESLint analysis is disabled. To enable it, do the following: DeepScan supports ESLint version 5, 6, and 7.
ESLint requires ESLint configuration files ( .eslintrc.* files) under your projects Although the ESLint analysis fails by any reasons, you can see the analysis results of DeepScan without an interruption. By default, ESLint analysis is disabled.
you could set the option devDependencies: true in an .eslintrc in your test folder: rules: import/no-extraneous-dependencies: [error, { devDependencies: true }] Then you’ll get reports of any packages referenced that are not included dependencies or devDependencies.
This rule supports the following options: devDependencies: If set to false, then the rule will show an error when devDependencies are imported. Defaults to true. optionalDependencies: If set to false, then the rule will show an error when optionalDependencies are imported.
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"]}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With