1. 程式人生 > >通過eslint統一前端IDE的編碼風格,避免git衝突

通過eslint統一前端IDE的編碼風格,避免git衝突

問題描述

前端專案組的開發人員IDE沒法統一,VSCode,Webstrom,Vim都有。結果就是git老是因為格式衝突
這裡寫圖片描述

解決方案

  1. 專案根目錄下新增檔案: .eslintrc.js

    module.exports = {
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true
    },
    "extends": "react-app",
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true
    , "jsx": true }, "sourceType": "module" }, "plugins": [ "react" ], "rules": { "array-bracket-spacing": [ "error", "always" ], "object-curly-spacing": [ "error", "always" ], "indent": [ "error", 4 ], "linebreak-style"
    : [ "error", "unix" ], "quotes": [ "error", "double" ], "semi": [ "error", "never" ] } };