Skip to content

[no-extraneous-import] Error message reports the "@types/blah" package instead of the "blah" package #3208

Description

@cakoose

Here's a minimal repro: https://github.com/cakoose/no-extraneous-dependencies-reporting-types-package-bug

Summary of repo contents

index.ts

import qs from 'qs';
...

package.json (I forget to add a dependency on "qs", but it gets included indirectly via "express")

    "dependencies": {
        "express": "^4.21.2"
    },
    "devDependencies": {
        "@types/qs": "^6.9.7",
        ...
    }

eslint.config.mjs:

    rules: {
        'import/no-extraneous-dependencies': ['error', {
            devDependencies: false,
            peerDependencies: false,
        }],
    },

To reproduce

npm install
npm run lint
 .../index.ts
   1:1  error  '@types/qs' should be listed in the project's dependencies, not devDependencies
 import/no-extraneous-dependencies

Problem: It's reporting "@types/qs" instead of "qs".

This slight reporting issue really threw me off. I was trying all kinds of weird things to figure out why it was reporting the "@types/qs" package, only to realize that I didn't include "qs" in my dependencies list.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions