需要使用以下包:
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- eslint-plugin-react
- eslint-plugin-react-hooks
ESLINT 配置:
"env": {
"browser": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended"
],
"plugins": [
"react",
"@typescript-eslint",
"react-hooks"
],
"rules": {
"jsx-a11y/alt-text": 0,
...
}
项目的 .vscode/settings.json
"eslint.enable": true,
"eslint.options": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"eslint.validate": [
"javascript",
"javascriptreact",
"html",
"typescript",
"typescriptreact"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
网友评论