eslint-plugin-import-x
eslint-plugin-import-x copied to clipboard
``import-x/no-extraneous-dependencies`` settings not applying to custom files
Steps to reproduce
- Set the rule with the following configuration:
'import-x/no-extraneous-dependencies': [
'error',
{
devDependencies: ['*.config.ts', 'scripts/**/*.ts'],
optionalDependencies: false,
peerDependencies: false,
bundledDependencies: false
}
],
- In
test.config.tsfile, import a dependency defined indevDependenciesin 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.
Having the same issue. The rule stopped working for some reason, since I remember it did work.
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.
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
@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.