eslint-plugin-import-x icon indicating copy to clipboard operation
eslint-plugin-import-x copied to clipboard

``import-x/no-extraneous-dependencies`` settings not applying to custom files

Open ferferga opened this issue 1 year ago • 4 comments

Steps to reproduce

  1. Set the rule with the following configuration:
      'import-x/no-extraneous-dependencies': [
        'error',
        {
          devDependencies: ['*.config.ts', 'scripts/**/*.ts'],
          optionalDependencies: false,
          peerDependencies: false,
          bundledDependencies: false
        }
      ],
  1. In test.config.ts file, import a dependency defined in devDependencies in package.json

What's expected? No error is logged, since the file is allowed to import dependencies from devDependencies

What happens? The rule reports an error

Additional context Upstream doesn't have this issue, so switching back to the original plugin will demonstrate the expected behaviour of this rule.

ferferga avatar Jun 13 '24 22:06 ferferga

Having the same issue. The rule stopped working for some reason, since I remember it did work.

RobinTail avatar Jun 24 '24 16:06 RobinTail

I managed to debug it to the return statement due to missing resolution. The issue can be fixed by installing eslint-import-resolver-typescript and adding

    settings: {
      "import-x/resolver": {
        typescript: true,
        node: true,
      },
    },

to the ESLint configuration, exactly as recommended in the Readme.

However, the required package throws the following warning in yarn:

warning " > [email protected]" has unmet peer dependency "eslint-plugin-import@*".

So, it's not declared as a compatible one with the -x plugin. Somehow it should be sorted out.

RobinTail avatar Jun 24 '24 22:06 RobinTail

Related issue regarding that warning message: https://github.com/import-js/eslint-import-resolver-typescript/issues/293

Workaround: https://github.com/import-js/eslint-import-resolver-typescript/issues/293#issuecomment-2189723600

RobinTail avatar Jun 24 '24 22:06 RobinTail

@ferferga If you still have such issue, please provide a minimal but runnable reproduction to describe what's the issue exactly, and helps us to debug.

JounQin avatar Mar 19 '25 07:03 JounQin