Can't deactivate "import/no-extraneous-dependencies" (for devDependencies) for .ts files
See original GitHub issueI continue to get errors for “import/no-extraneous-dependencies” despite doing my best to deactivate it in my .eslintrc.js. I’ve tried all variations of deactivating it I could think of for well over an hour now, and all of them are ignored. I can’t even set it to “warn” instead of “error”.
Things that work:
- Turning it off seems to work fine in .js files. When I rename my file from main.ts to main.js, my “import/no-extraneous-dependencies” configuration behaves exactly as expected.
- All other changes I make in the .eslintrc.js file work fine.
- Deactivating the error with
// eslint-disable-next-line import/no-extraneous-dependenciesworks fine. /* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */works fine too, but putting the same into .eslintrc.js produces no effect. It’s like something adds the rule after my .eslintrc.js rules.
Here is an example of the error I get:
'pixi.js' should be listed in the project's dependencies, not devDependencies.eslint(import/no-extraneous-dependencies)
Here is my .eslintrc.js:
module.exports = {
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"eslint-comments",
"jest",
"promise",
"unicorn",
],
extends: [
"airbnb-typescript",
"plugin:@typescript-eslint/recommended",
"plugin:eslint-comments/recommended",
"plugin:jest/recommended",
"plugin:promise/recommended",
"plugin:unicorn/recommended",
"prettier",
"prettier/react",
"prettier/@typescript-eslint",
],
env: {
node: true,
browser: true,
jest: true,
},
rules: {
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
"no-prototype-builtins": "off",
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
"import/prefer-default-export": "off",
"import/no-default-export": "error",
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
"react/destructuring-assignment": "off",
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
"react/jsx-filename-extension": "off",
// Use function hoisting to improve code readability
"no-use-before-define": [
"error",
{ functions: false, classes: true, variables: true },
],
// Makes no sense to allow type inferrence for expression parameters, but require typing the response
"@typescript-eslint/explicit-function-return-type": [
"error",
{ allowExpressions: true, allowTypedFunctionExpressions: true },
],
"@typescript-eslint/no-use-before-define": [
"error",
{ functions: false, classes: true, variables: true, typedefs: true },
],
// Common abbreviations are known and readable
"unicorn/prevent-abbreviations": "off",
// I put everything into dev-dependencies because it will all be transpiled by webpack
"import/no-extraneous-dependencies": [
"warn",
{
"devDependencies": true,
"optionalDependencies": true,
"peerDependencies": true,
}
],
// I don't see the point of this
"unicorn/prefer-node-append": "off"
},
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Can't deactivate "import/no-extraneous-dependencies" (for ...
js files. When I rename my file from main.ts to main.js, my "import/no-extraneous-dependencies" configuration behaves exactly as expected.
Read more >Why (and How Can I FIx) ESLint import/no-extraneous ...
I solved it simply by setting devDependencies to true. By default it is false. "import/no-extraneous-dependencies": [ "error", ...
Read more >eslint/eslint - Gitter
'import/no-extraneous-dependencies':0 now to disable it. but I would have preferred not to disable only on aliases defined in webpack. Kevin Partington.
Read more >eslint-plugin-import - npm
Ensure imports point to a file/module that can be resolved. ... Forbid the use of extraneous packages ( no-extraneous-dependencies ) ...
Read more >eslint-config-rasenplanscher - NPM Package Overview
This could indicate that a single version should not be used, ... to your project's dev dependencies and include in your estlintrc's extends ......
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 Free
Top 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
Re “I put everything into dev-dependencies because it will all be transpiled by webpack” - anything that is conceptually a runtime dependency belongs in production deps. Use of webpack is an implementation detail, and doesn’t make those things dev deps.
That said, it should certainly be set to
warnas a result of this config. Try adding"root": true, because you might have a~/.eslintrcor something?Turns out I was using an extremely outdated eslint-config-airbnb-typescript (among other things). Upgrading my package.json to current versions (via
ncu -u) helped.Thanks a lot for your quick answers, and sorry I wasted your time there!