Har*_*ris 10 typescript eslint
我正在尝试eslint为我的REACT-TypeScript项目进行配置。它以前使用过tslint,很快就会被弃用。我浏览了网络,终于能够创建我的.eslintrc.json:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"project": "./tsconfig.json",
"ecmaVersion": 2018,
"sourceType": "module"
},
"env": {
"browser": true,
"jest/globals": true
},
"extends": [
"airbnb",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint", "react-hooks", "jest", "prettier"],
"ignorePatterns": ["src/serviceWorker.ts", "src/enums.ts", "node_modules/"],
"rules": { },
"settings": {
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"prettier/prettier": [
"error",
{
"singleQuote": true,
"semi": "error"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我运行该lint命令时,它会引发有关TypeScript语法的错误。这里有几个:
谷歌上的所有链接现在都是紫色的,但我似乎无法弄清楚出了什么问题。请帮我看看这个。
对我来说你的配置看起来不错。如果是 Typescript 错误,则 ESLint 无能为力。只需升级 Typescript 即可。
以防万一检查这个ESLint Prettier Typescript配置,它是我的参考https://levelup.gitconnected.com/setting-up-eslint-with-prettier-typescript-and-visual-studio-code-d113bbec9857?它离你很近
| 归档时间: |
|
| 查看次数: |
6715 次 |
| 最近记录: |