Open jhoffmcd opened 3 years ago
Also filed an issue over at the alias plugin because I am not sure where the change would be needed:
https://github.com/johvin/eslint-import-resolver-alias/issues/20
Turn off rules duplicate with eslint-plugin-import
, use eslint-plugin-import
directly might be a better solution.
@Airkro what do you mean exactly? Like
"node/no-missing-require": "off",
?
@lamuertepeluda
Yep. install eslint-plugin-import
+ 'import/no-extraneous-dependencies': 'error',
- 'node/no-extraneous-require': 'error',
- 'node/no-extraneous-import': 'error',
+ 'node/no-extraneous-require': 'off',
+ 'node/no-extraneous-import': 'off',
+ 'import/no-unresolved': 'error'
- 'node/no-missing-require': 'error',
- 'node/no-missing-import': 'error',
+ 'node/no-missing-require': 'off',
+ 'node/no-missing-import': 'off',
now you can use eslint-import-resolver-x
@Airkro thank you!! You pointed me in the right direction! 😃 I have a node-express only project.
I did it like this in my root .eslintrc.json
file and it's working
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:node/recommended",
],
"plugins": ["import", "node"],
"root": true,
"env": {
"es6": true,
"browser": false,
"node": true,
"commonjs": true
},
"settings": {
"import/resolver": {
"alias": {
"map": [
["@src", "./src"],
["@api", "./src/api"],
["@migrations", "./src/migrations"],
["@utils", "./src/utils"],
// customize as you need
],
"extensions": [".js", ".json", ".node"] // customize as you need
}
}
},
"rules": {
// place other rules here
// This one handles require() resolution respecting aliases IF you set commonjs: true
"import/no-unresolved": ["error", { "commonjs": true }],
"import/no-extraneous-dependencies": "error",
// Turned off because conflicts with the ones above and does not support aliases
"node/no-missing-require": "off",
"node/no-extraneous-import":"off",
// place other rules here
}
}
and I am using module-alias and eslint-import-resolver-alias in addition to this.
we get this:
Oops! Something went wrong! :(
ESLint: 8.57.0
EslintPluginImportResolveError: unable to load resolver "alias".
Occurred while linting /Users/nikos/WebstormProjects/agcra-app/app/components/AdminNavTabs.tsx:1
Rule: "import/namespace"
at requireResolver (/Users/nikos/WebstormProjects/agcra-app/node_modules/.pnpm/eslint-module-utils@2.8.1_@typescript-eslint+parser@6.21.0_eslint-import-resolver-node@0.3.9__kttqjlkde72ifr4qchnoh6ko5e/node_modules/eslint-module-utils/resolve.js:199:17)
We have a supported version of this plugin over at https://github.com/eslint-community/eslint-plugin-n
We do support aliases from both typescript and the package.json.
If you need anymore settings we'd be happy to help!
Request to support module aliases as provided by the config in eslint-import-resolver-alias. It seems like the rule node/no-missing-import is not aware of aliases configured by the eslint-import-resolver-alias settings.
Example configuration:
Still produces an error with this statement: