Typescript eslint-缺少文件扩展名“ ts”导入/扩展 [英] Typescript eslint - Missing file extension "ts" import/extensions
本文介绍了Typescript eslint-缺少文件扩展名“ ts”导入/扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用Typescript制作的简单Node / Express应用程序。
并把错误提示给我
I have a simple Node/Express app made with Typescript. And eslint give me the error
Missing file extension "ts" for "./lib/env" import/extensions
这是我的.eslintrc文件
Here is my .eslintrc file
{
"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-impor& eslint-import-resolver-typescript。
而且我不知道为什么,我得到了那个错误。
I have installed eslint-plugin-impor & eslint-import-resolver-typescript. And I cannot figure out why, I got that error.
推荐答案
将以下代码添加到规则
:
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
]
}
airbnb
ESLint 配置会导致此问题。
airbnb
ESLint config leads the problem.
这篇关于Typescript eslint-缺少文件扩展名“ ts”导入/扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文