ESlint在VS Code中不起作用的原因是什么?

huangapple go评论71阅读模式
英文:

What is the reason ESlint doesn't work in VS Code

问题

ESlint不会在保存代码时进行钩子操作,也不会在保存时显示错误,但如果运行npm run lint命令,那么错误将会显示出来。我将附上带有设置的屏幕截图。

ESlint在VS Code中不起作用的原因是什么?

ESlint在VS Code中不起作用的原因是什么?

ESlint在VS Code中不起作用的原因是什么?

    "@typescript-eslint/eslint-plugin": "^5.12.1",
    "@typescript-eslint/parser": "^5.12.1",
    "eslint": "^8.10.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.29.2",
    "eslint-plugin-react-hooks": "^4.3.0",
英文:

ESlint does not hook the code and does not give errors when saving, but if you run the npm run lint command, then the errors are shown, I will attach screenshots with the settings

ESlint在VS Code中不起作用的原因是什么?

ESlint在VS Code中不起作用的原因是什么?

ESlint在VS Code中不起作用的原因是什么?

    "@typescript-eslint/eslint-plugin": "^5.12.1",
    "@typescript-eslint/parser": "^5.12.1",
    "eslint": "^8.10.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.29.2",
    "eslint-plugin-react-hooks": "^4.3.0",

答案1

得分: 2

你可以检查以下步骤:

  1. 在 vscode 上安装 eslint 扩展
  2. 在 vscode 设置中的格式设置部分,取消选中“保存时格式化”
  3. 将设置添加到 .vscode 文件夹中

根据你使用的功能/预设,可以将相关选项添加到 .vscode/settings.json

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": [
    "source.fixAll.eslint"
  ],
  "eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"]
}
  1. 关闭并重新打开 vscode
英文:

You can check this steps:

  1. Install eslint extention on vscode
  2. From vscode settings, formatting section, uncheck Format on save
  3. Add settings to .vscode folder

> Depending on which features/presets you are using, you can add the related options to .vscode/settings.json

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": [
    "source.fixAll.eslint"
  ],
  "eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"]
}
  1. Close and re-open vscode

huangapple
  • 本文由 发表于 2023年2月8日 12:53:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75381505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定