react项目环境

293 阅读1分钟

npm包

npm install -g eslint-plugin-html eslint babel-eslint standard

vscode扩展

  1. language-stylus
  2. JavaScript Standard Style
  3. Document this
  4. React-Native/React/Redux snippets for es6/es7
  5. JavaScript Standard Style(用standard.js做代码规范)

vscode设置

{
    "editor.tabSize": 2,
    "editor.fontSize": 17,
    "files.autoSave": "off",
    "javascript.validate.enable": false,
    "emmet.triggerExpansionOnTab": true,
    "standard.autoFixOnSave": true,
    "standard.validate": [{
            "language": "javascript",
            "autoFix": true
        },
        {
            "language": "javascriptreact",
            "autoFix": true
        },
        {
            "language": "vue",
            "autoFix": true
        },
        "html"
    ],
    // "standard.options": {
    //     "plugins": [
    //         "html"
    //     ]
    // },
    "workbench.statusBar.visible": false,
    "files.associations": {
        "*.vue": "vue"
    },
    "window.zoomLevel": 0,
    "java.errors.incompleteClasspath.severity": "ignore",
    "extensions.ignoreRecommendations": false,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "workbench.activityBar.visible": true,
    "workbench.sideBar.location": "right",
    "editor.fontFamily": "Monaco, 'Courier New', monospace",
    "editor.fontWeight": "300",
    "git.enableSmartCommit": true,
    "explorer.confirmDelete": false,
    "workbench.colorTheme": "Atom One Dark",
    "gitlens.views.search.files.layout": "tree",
    "editor.minimap.enabled": true,
    "typescript.check.npmIsInstalled": false,
    "[javascriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    }
}

vscode配置文件注意点

使用JavaScript Standard Style作为代码规范后,要如下配置

"standard.autoFixOnSave": true,
"editor.formatOnSave": false