ITADN

Import aliases can't be resolved without an empty config block

#475OpenRareScrap 创建于 2025-12-29
R
RareScrapcommented
The problem is eslint-import-resolver-typescript doesn't support import aliases provided in tsconfig.json without this empty {} non-informative object <details><summary><code>.eslintrc.json</code></summary> ```json { "env": { "browser": true, "es6": true, "node": true }, "extends": [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:import/recommended", "plugin:import/typescript" ], "parser": "@typescript-eslint/parser", "settings": { "import/resolver": { // The problem is eslint-import-resolver-typescript doesn't support import aliases provided in tsconfig.json without this empty {} non-informative object "typescript": {} } } } ``` </details> Output without `"typescript": {}`: ``` $ npm run lint > example@1.0.0 lint > set ESLINT_USE_FLAT_CONFIG=false&& eslint --ext .ts,.tsx . (node:25004) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details. An eslintrc configuration file is used because you have the ESLINT_USE_FLAT_CONFIG environment variable set to false. If you want to use an eslint.config.js file, remove the environment variable. If you want to find the location of the eslintrc configuration file, use the --debug flag. (Use `node --trace-warnings ...` to show where the warning was created) ``` Output with `"typescript": {}`: ``` $ npm run lint > example@1.0.0 lint > set ESLINT_USE_FLAT_CONFIG=false&& eslint --ext .ts,.tsx . C:\Users\user\example\src\index.ts 1:27 error Unable to resolve path to module '@somedir/SomeClass' import/no-unresolved ✖ 1 problem (1 error, 0 warnings) (node:14660) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details. An eslintrc configuration file is used because you have the ESLINT_USE_FLAT_CONFIG environment variable set to false. If you want to use an eslint.config.js file, remove the environment variable. If you want to find the location of the eslintrc configuration file, use the --debug flag. (Use `node --trace-warnings ...` to show where the warning was created) ``` See the [full bug reproduce gist](https://gist.github.com/RareScrap/4c080beaa895e68bd14f5b18304e5b71)
1 条评论