quanyawei
2023-11-13 55d5e79d7d58684c29e1eb00fbf93333319bc8e9
fix:eslint配置
1 files added
4 files modified
168 ■■■■■ changed files
.eslintrc.js 11 ●●●●● patch | view | raw | blame | history
.prettierrc 15 ●●●●● patch | view | raw | blame | history
.vscode/settings.json 120 ●●●●● patch | view | raw | blame | history
package-lock.json 18 ●●●● patch | view | raw | blame | history
package.json 4 ●●● patch | view | raw | blame | history
.eslintrc.js
@@ -9,11 +9,20 @@
    node: true,
    es6: true,
  },
  extends: ['plugin:vue/recommended', 'eslint:recommended'],
  extends: [/* vue 2 配置 */
    "plugin:vue/recommended",
      "plugin:vue/essential",
      "plugin:vue/strongly-recommended",
    /* vue 3 配置 */
    // "plugin:vue/vue3-recommended"
    // "plugin:vue/vue3-essential"
    // "plugin:vue/vue3-strongly-recommended"
  ],
  // add your custom rules here
  //it is base on https://github.com/vuejs/eslint-config-vue
  rules: {
    'vue/no-unused-vars': 'error',
    'eqeqeq': ['error', 'always'], // 强制使用三个等于号
    'semi': 0, // 语句可以不需要分号结尾
    'no-use-before-define': [1, 'nofunc'], // 未定义前不能使用
.prettierrc
@@ -1,6 +1,11 @@
{
   "eslintIntegration": true,
   "singleQuote": true,
   "semi": false
 }
    "useTabs": true,
    "arrowParens": "avoid",
    "printWidth": 120,
    "tabWidth": 2,
    "semi": true,
    "singleQuote": true,
    "bracketSpacing": true,
    "endOfLine": "auto",
    "trailingComma": "none"
}
.vscode/settings.json
New file
@@ -0,0 +1,120 @@
{
    "workbench.iconTheme": "material-icon-theme",
    "editor.fontSize": 16,
    // --------------------  配置eslint  --------------------
    //autoFixedOnSave 设置已废弃,采用如下新的设置,新版(>1.41.0)配置
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "eslint.format.enable": true,
    //autoFix默认开启,只需输入字符串数组即可
    "eslint.validate": ["javascript", "vue", "html", "javascriptreact", "vue-html"],
    // --------------------  配置eslint  --------------------
    // 设置编辑器的默认格式化工具
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[css]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[less]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    //方法括号之间插入空格
    "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
    // --------------------  vetur 配置  --------------------
    // vue文件默认格式化工具:vetur
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    // 这个按用户自身习惯选择
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    // 让vue中的js按编辑器自带的ts格式进行格式化
    //  "vetur.format.defaultFormatter.js": "vscode-typescript",
    // 让vue中的js按prettier进行格式化 用这个
    "vetur.format.defaultFormatter.js": "prettier",
    "vetur.format.defaultFormatterOptions": {
        "js": "prettier",
        "js-beautify-html": {
            "wrap_attributes": "aligned-multiple" //当超出折行长度时,将属性进行垂直对齐
        },
        "prettyhtml": {
            "tabWidth": 4, // 会忽略vetur的tabSize配置
            "printWidth": 100, //每行100字符
            "singleQuote": true, //是否使用单引号
            "semi": false, // 句尾是否加;
            "wrapAttributes": false,
            "sortAttributes": false
        },
        //vue中的js生效
        "prettier": {
            "semi": false, // 句尾是否加;
            "singleQuote": true, //是否使用单引号
            "trailingComma": "none" //禁止随时添加逗号
        }
    },
    // --------------------  vetur 配置  --------------------
    // --------------------  koro1FileHeader 配置  --------------------
    // 头部注释
    "fileheader.customMade": {
        "Author": "AuthorName",
        "Date": "Do not edit", // 文件创建时间(不变)
        "LastEditors": "AuthorName", // 文件最后编辑者
        "LastEditTime": "Do not edit", // 文件最后编辑时间
        "Description": ""
        // "FilePath": "only file name", // 只有文件名
        // "custom_string_obkoro1_copyright": "Copyright (C) ${now_year} AuthorName. All rights reserved.",
        // "custom_string_obkoro1_date": "Do not edit" // 不带Date前缀的时间
    },
    // 函数注释
    "fileheader.cursorMode": {
        "description": "",
        //"custom_string_obkoro1": "",
        "param": "params",
        "return": ""
    },
    // 插件配置项
    "fileheader.configObj": {
        "createHeader": false, // 新建文件自动添加头部注释,默认打开
        "autoAdd": false, // 保存自动添加头部注释,开启才能自动添加,默认开启
        "openFunctionParamsCheck": true, //函数注释自动提取函数的参数,默认开启
        "createFileTime": true, // 默认为此文件的创建时间,设为false更改为当前生成注释的时间
        "dateFormat": "YYYY-MM-DD HH:mm:ss", // 默认时间格式,修改影响所有时间字段
        // 自定义注释中的艾特和冒号:
        "atSymbol": ["@", "@"], // 所有文件的头部注释和函数注释的默认值 @
        "colon": [": ", ": "] // 所有文件的头部注释和函数注释的默认值 :
        // 自定义特殊字段名,Date、LastEditTime、LastEditors、Description、FilePath
        // "specialOptions": {
        //   "Date": "since",
        //   "LastEditTime": "lastTime",
        //   "LastEditors": "LastAuthor",
        //   "Description": "message",
        //   "FilePath": "文件相对于项目的路径"
        // }
        // 函数参数配置
        // "functionParamsShape": "normal", // 正常
        // "functionParamsShape": "no bracket", // 没有方括号
        // "functionParamsShape": "no type", // 没有类型
        // "functionParamsShape": [ "{", "}"], // 函数参数外形自定义,默认值 {}
        // "functionTypeSymbol": "*", // 参数没有类型时的默认值 *
        // 函数设置不添加参数和类型 {*}
        // "functionParamsShape": "no type", // 没有类型
        // "functionTypeSymbol": "" // 参数没有类型时的默认值 *
    },
    // --------------------  koro1FileHeader 配置  --------------------
    // --------------------  prettier 配置(以下配置主要针对.js)  --------------------
    "prettier.useEditorConfig": false, // 不使用editorConfig配置文件设置才生效
    "prettier.semi": false, // 句尾是否加;
    "prettier.singleQuote": true, //是否使用单引号
    "prettier.trailingComma": "none", //禁止随时添加逗号
    // --------------------  prettier 配置  --------------------
    "git.confirmSync": false,
    "security.workspace.trust.untrustedFiles": "open"
}
package-lock.json
@@ -1881,6 +1881,12 @@
            "uniq": "^1.0.1"
          }
        },
        "prettier": {
          "version": "1.16.3",
          "resolved": "https://registry.npmmirror.com/prettier/-/prettier-1.16.3.tgz",
          "integrity": "sha512-kn/GU6SMRYPxUakNXhpP0EedT/KmaPzr0H5lIsDogrykbaxOpOfAFfk5XA7DZrJyMAv1wlMV3CPcZruGXVVUZw==",
          "dev": true
        },
        "source-map": {
          "version": "0.6.1",
          "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz",
@@ -6923,6 +6929,12 @@
          }
        }
      }
    },
    "eslint-config-prettier": {
      "version": "9.0.0",
      "resolved": "https://registry.npmmirror.com/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz",
      "integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==",
      "dev": true
    },
    "eslint-config-standard": {
      "version": "10.2.1",
@@ -16349,9 +16361,9 @@
      "dev": true
    },
    "prettier": {
      "version": "1.16.3",
      "resolved": "https://registry.npm.taobao.org/prettier/download/prettier-1.16.3.tgz?cache=0&sync_timestamp=1606523097359&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-1.16.3.tgz",
      "integrity": "sha1-jGIWhFO63vcC80tFtu6JlXSmpl0=",
      "version": "3.0.3",
      "resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.0.3.tgz",
      "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==",
      "dev": true
    },
    "pretty": {
package.json
@@ -75,6 +75,7 @@
    "chalk": "2.4.2",
    "connect": "3.6.6",
    "eslint": "^5.16.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
@@ -86,6 +87,7 @@
    "eslint-plugin-vue": "^5.2.3",
    "html-webpack-plugin": "3.2.0",
    "mockjs": "1.0.1-beta3",
    "prettier": "3.0.3",
    "runjs": "^4.3.2",
    "sass-loader": "^7.1.0",
    "script-ext-html-webpack-plugin": "2.1.3",
@@ -107,4 +109,4 @@
    "**/@vue/cli-plugin-eslint",
    "**/@vue/cli-plugin-eslint/**"
  ]
}
}