[英]eslint: Unable to resolve path to module 'src/interfaces'
I'm having a very similar problem here and have tried every answer with no luck: Using eslint with typescript - Unable to resolve path to module我在这里遇到了一个非常相似的问题并且尝试了所有答案但没有运气: Using eslint with typescript - Unable to resolve path to module
Here is a screenshot of the linting error:这是 linting 错误的屏幕截图:
tsconfig.json tsconfig.json文件
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["esnext", "DOM"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"useUnknownInCatchVariables": true
},
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"],
"include": ["src"]
}
eslintrc.json eslintrc.json文件
{
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"paths": ["src"]
}
},
"react": "React",
"version": "detect"
},
"env": {
"browser": true,
"es6": true,
"jest": true,
"node": true
},
"extends": [
"eslint:recommended",
"airbnb",
"prettier",
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"allowImportExportEverywhere": true,
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["react", "@typescript-eslint", "prettier", "jest"],
"rules": {
"array-element-newline": ["error", "never"],
"camelcase": "off",
"comma-dangle": ["error", "only-multiline"],
"complexity": ["off"],
"consistent-return": ["off"],
"import/unresolved": ["off"],
"import/extensions": ["off"],
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"jsdoc/require-jsdoc": ["off"],
"linebreak-style": ["off"],
"max-len": ["error", {"code": 350, "tabWidth": 2}],
"max-nested-callbacks": ["off"],
"new-cap": ["off"],
"no-console": ["warn"],
"no-dupe-keys": ["error"],
"no-nested-ternary": ["off"],
"no-use-before-define": ["off"],
"no-useless-catch": ["off"],
"no-var": ["error"],
"quotes": ["error", "single"],
"react/display-name": ["off", {"ignoreTranspilerName": true}],
"react/jsx-filename-extension": [1, {"extensions": [".js", ".jsx", ".tsx"]}],
"semi": ["error", "always"],
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-unused-vars": ["off"],
"@typescript-eslint/explicit-module-boundary-types": ["off"],
"@typescript-eslint/no-explicit-any": ["off"]
}
}
prettierrc.json prettierrc.json
{
"bracketSpacing": false,
"jsxBracketSameLine": true,
"singleQuote": true,
"eslintIntegration": true,
"trailingComma": "es5",
"endOfLine": "auto",
"printWdith": 120
}
I'm not sure why but removing the airbnb
from the extends
solved the issue.我不确定为什么,但是从
extends
中删除airbnb
解决了这个问题。
change eslintrc.json from:将 eslintrc.json 更改为:
"extends": [
"eslint:recommended",
"airbnb",
"prettier",
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
to到
"extends": [
"eslint:recommended",
"prettier",
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
I hope one day there is a global linting file that will allow us to just use 1 so conflicts aren't creating these headaches.我希望有一天会有一个全局 linting 文件,它允许我们只使用 1,这样冲突就不会造成这些麻烦。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.