[英]Resolve Error: typescript with invalid interface loaded as resolver ESLint
I'm having ESLint in my project and getting an error Resolve Error: typescript with invalid interface loaded as resolver : import-no-restricted-paths
when I add the rule import/no-restricted-paths
我的项目中有 ESLint 并收到错误
Resolve Error: typescript with invalid interface loaded as resolver : import-no-restricted-paths
当我添加规则import/no-restricted-paths
tsconfig.json配置文件
{
"include": [
"./src/**/*",
"./generated/**/*"
],
"compilerOptions": {
"resolveJsonModule": true,
"target": "es5",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"dom",
"es6"
],
"downlevelIteration": true,
"jsx": "react",
"declaration": false,
"sourceMap": true,
"baseUrl": "src",
"outDir": "./dist/js",
"paths": {
"@generated/*": ["../generated/*"],
"api": ["lib/api"],
"api/*": ["lib/api/*"],
"asset/*": ["lib/asset/*"],
"base/*": ["lib/base/*"]
},
// Rules
"noImplicitAny": false,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"isolatedModules": true
}
}
.eslint.json .eslint.json
module.exports = {
env: {
browser: true
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
paths: "./tsconfig.json",
alwaysTryTypes: true
}
},
},
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: ".",
sourceType: "module",
project: "./tsconfig.json"
},
extends: [
"plugin:import/recommended",
"plugin:import/typescript"
],
plugins: [
"@typescript-eslint",
"import"
],
overrides: [
{
files: [
"src/_migration/**"
],
rules: {
"import/no-restricted-paths": [
"error",
{
basePath: "./src",
zones: [
{ target: "./_migration", from: "./", except: ['./_migration'] }
],
},
]
}
},
],
rules: {
"import/no-unresolved": "off",
"@typescript-eslint/typedef": [
"error",
{
parameter: true
}
]
}
};
This seemed to do the trick for me.这似乎对我有用。
npm install -D eslint-import-resolver-typescript
I don't want to delete package-lock.json
because I know from experience that doing so causes problems for my current project.我不想删除
package-lock.json
因为我从经验中知道这样做package-lock.json
我当前的项目带来问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.