波多野吉不卡中文Av无码Av

      <strong id="fzzds"><track id="fzzds"></track></strong>
    1. <strong id="fzzds"></strong>
      <strong id="fzzds"></strong>
    2. <ruby id="fzzds"><bdo id="fzzds"><rp id="fzzds"></rp></bdo></ruby>
        <strike id="fzzds"></strike>
      1. 您現在的位置: 微信小程序 > 微信小程序運營 > 經驗 >

        小程序集成eslint和prettier,代碼風格統一

        來源:微信小程序 編輯:Yiyongtong.com 發布時間:2020-05-18 10:53熱度:

        微信小程序、支付寶小程序、釘釘小程序都可以適用

        LZ用的是釘釘小程序,很完美

        首先你要有vscode這個

        首先目錄結構是這樣的

        一定要src里面放小程序的文件夾,如果全部放在一起,會導致小程序上傳過大的問題,我剛開始就吃了這個坑,居然打包了40多m,根本傳不上去,后來放在src文件夾下面就解決了,讓小程序直接去訪問src文件夾

        {
          "private": true,
          "name": "dingproject",
          "version": "1.0.0",
          "description": "",
          "main": "app.js",
          "scripts": {
            "test": "echo \"Error: no test specified\" && exit 1",
            "precommit": "lint-staged",
            "clean": "rm -rf dist/*",
            "lint": "eslint -c .eslintrc ./src"
          },
          "author": "",
          "license": "ISC",
          "dependencies": {},
          "devDependencies": {
            "babel-eslint": "^8.2.1",
            "eslint": "^3.12.1",
            "eslint-config-prettier": "^2.9.0",
            "eslint-plugin-html": "^3.0.1",
            "eslint-plugin-import": "^2.8.0",
            "eslint-plugin-prettier": "^2.3.1",
            "lint-staged": "^6.0.0",
            "prettier": "^1.8.2"
          },
          "lint-staged": {
            "src/**/*.js": [
              "eslint --fix",
              "git add"
            ]
          }
        }

        .eslintrc 文件

        {
            "extends": [
              "prettier",
              "prettier/standard"
            ],
            "useTabs": false,
            //插件
            "plugins": [
              "prettier"
            ],
           
            //配置解析器
            "parser":"babel-eslint",
            "parserOptions": {
              "ecmaVersion": 6,
              "sourceType":"module",
            },
           
            "env": {//腳本目標的運行環境
              "browser":true,
              "node":true,
              "es6":true,
              "commonjs":true
            },
           
            //全局變量
            "globals": {
        "__DEV__":true,
        "__WECHAT__":true,
        "__ALIPAY__":true,
        "App":true,
        "Page":true,
        "Component":true,
        "Behavior":true,
        "wx":true,
        "getApp":true,
            },
           
            //規則,只用插件:插件名/規則
            "rules": {
        "prettier/prettier":"error",
        "no-console": 0
            }
          }

        然后 npm i 安裝一下即可

        npm run lint

        如何讓vscode 可以保存自動并校準文件,可以參考我下一篇文章

        如何讓eslint自動保存并修改不合規范的文件

        波多野吉不卡中文Av无码Av

          <strong id="fzzds"><track id="fzzds"></track></strong>
        1. <strong id="fzzds"></strong>
          <strong id="fzzds"></strong>
        2. <ruby id="fzzds"><bdo id="fzzds"><rp id="fzzds"></rp></bdo></ruby>
            <strike id="fzzds"></strike>