Skip to content

no-extraneous-dependencies causes errors for not imported @types/* #2168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alan-albuquerque opened this issue Jul 28, 2021 · 7 comments
Closed

Comments

@alan-albuquerque
Copy link

alan-albuquerque commented Jul 28, 2021

Hello I'am facing a similar issue reported here and there @ljharb asked to open another issue if it is still happening on version 2.23.4.

My scenario is:
node: v12.22.1

import { difference } from 'ramda';
import { v4 as uuid } from 'uuid';

causes:

  error  '@types/uuid' should be listed in the project's dependencies, not devDependencies  import/no-extraneous-dependencies
  error  '@types/ramda' should be listed in the project's dependencies, not devDependencies  import/no-extraneous-dependencies

package.json

"eslint": "^7.31.0",
"eslint-plugin-import": "2.23.4",

config:

"import/no-extraneous-dependencies": [
            "error",
            {
                "devDependencies": ["**/*.d.ts", "**/*.test.*", "**/*.spec.*", "test-utils/**/*"]
            }
        ]

Am I doing something wrong?

@JounQin
Copy link
Collaborator

JounQin commented Jul 19, 2022

Can you provide a reproduction?

@DonIsaac
Copy link

I'm seeing this problem as well. My config is simlar, and my versions are below:

  • eslint-plugin-import: 2.27.5
  • eslint-plugin-import-resolver-typescript : 2.23.5
  • typescript: 5.0.4
  • typescript-eslint/parser: 5.48.0

@AndyOGo
Copy link
Contributor

AndyOGo commented Aug 21, 2023

I had the same problem with packages from @types/*, e.g. @types/react.
For my case I just needed to allow peerDependecies for react.

import { useEffect, useState } from "react";

'@types/react' should be listed in the project's dependencies, not devDependencies.eslintimport/no-extraneous-dependencies

@ahuth
Copy link

ahuth commented Jan 12, 2024

I think import-js/eslint-import-resolver-typescript#265 may be the cause of this

@JounQin
Copy link
Collaborator

JounQin commented Jan 12, 2024

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
@JounQin
Copy link
Collaborator

JounQin commented Jan 17, 2024

Please follow the README more carefully:

https://github.com/import-js/eslint-plugin-import#typescript

See also

'import/external-module-folders': ['node_modules', 'node_modules/@types'],

@ljharb
Copy link
Member

ljharb commented Jan 17, 2024

More generally, please use the config/typescript config from this plugin, which sets that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants