React+TS Eslint不生效相关问题

2,282 阅读1分钟

控制台有eslint报错,文件中却没有任何提示
vscode上安装的eslint插件已启用 eslint-plugin -g 实际上应该是项目中的eslint没有启用,状态是“!”

1.保证vscode上安装了eslint和vscode插件
2.配置vscode的setting.json
(有时项目中也有.vscode,但我的情况应该是项目中的.vscode下的setting.json并没有被用。随便它吧,不管了
image.png

{
    "git.enableSmartCommit": true,
    "git.autofetch": true,
    "editor.acceptSuggestionOnEnter": "smart",
    "editor.tabSize": 4,
    "editor.codeActionsOnSave": {
      "source.fixAll": true,
      "source.fixAll.eslint": true
    },
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "eslint.validate": [
      "javascript",
      "javascriptreact",
      "html",
      "vue",
      "typescript",
      "typescriptreact",
      "react"
    ],
    "beautify.config": {
      "brace_style": "collapse,preserve-inline"
    }
}

0AA90132-3411-42ef-8C64-E2CF657FC910.png 因为这张报错,又进行eslint-plugin、eslint-plugin-prettier的全局(-g)和本地(项目下的node_modules中)的安装(感觉这两个依赖包应该还是装在全局起作用,现在也不想特意去验证了)
4.又出现下面两个报错
error1: image.png error2: image.png 分别对应.eslintrc.json两处修改: image.png

【而且还没有解决的问题: pretiter不生效。现在的代码格式丑的要命。】