我有一个使用Typescript制作的简单Node/Express应用程序。但是eslint给了我错误提示。
Missing file extension "ts" for "./lib/env" import/extensions
这是我的.eslintrc文件
{
"extends": [
"airbnb",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/react",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier", "import"],
"settings": {
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"directory": "./tsconfig.json"
},
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"rules": {
"@typescript-eslint/indent": [2, 2],
"no-console": "off",
"import/no-unresolved": [2, { "commonjs": true, "amd": true }],
"import/named": 2,
"import/namespace": 2,
"import/default": 2,
"import/export": 2
}
}
我已经安装了 eslint-plugin-import 和 eslint-import-resolver-typescript。但我无法弄清为什么会出现这个错误。
"import/extensions": [ "error", "ignorePackages", { "": "never" } ]
。 - VimNing