如何配置代碼自動校驗功能

這裏你需要下載安裝 VScode編輯器:

  1. 下載安裝VScode編輯器
    在這裏插入圖片描述
  2. 安裝eslint 和 preitter插件
    在這裏插入圖片描述
    在這裏插入圖片描述

安裝完可以看到底部配置項內容:
在這裏插入圖片描述

  1. 修改eslint配置項

在這裏插入圖片描述

修改內容爲:
在這裏插入圖片描述

右邊的內容爲:

{
    "window.zoomLevel": 0,
    // Controls the font size in pixels.
    "editor.fontSize": 14,
    // The number of spaces a tab is equal to. This setting is overridden based on the file contents when `editor.detectIndentation` is on.
    "editor.tabSize": 2,

    // Always show the ESlint status bar item.
    "eslint.alwaysShowStatus": true,
    // An array of language ids which should be validated by ESLint
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        {
            "language": "vue",
            "autoFix": true
        },
        "html",
        "vue"
    ],
    // Turns auto fix on save on or off.
    "eslint.autoFixOnSave": true
}

因爲這個項目我使用了vue, r如果是react或者其他語言配置相似,適當修改內容。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章