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
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
}
}
I have installed eslint-plugin-import & eslint-import-resolver-typescript. And I cannot figure out why, I got that error.
Add the following code to rules
:
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
]
}
airbnb
ESLint config leads the problem.