From e671a60bfa164f6b0a187e01b1687547b8d375a0 Mon Sep 17 00:00:00 2001 From: xiaodi Date: Sat, 25 Apr 2020 23:32:26 +0800 Subject: [PATCH] eslint --- .eslintrc.js | 75 ++++++++++++++++++++++++++++++++++++++++++++------- vue.config.js | 2 +- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9ad58a4..2fb850a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,13 +3,70 @@ module.exports = { env: { node: true }, - extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"], - parserOptions: { - parser: "babel-eslint" - }, + 'extends': [ + 'plugin:vue/strongly-recommended' + ], rules: { - "no-console": process.env.NODE_ENV === "production" ? "error" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", - - } -}; + 'no-console': 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'generator-star-spacing': 'off', + 'no-mixed-operators': 0, + 'vue/max-attributes-per-line': [ + 2, + { + 'singleline': 5, + 'multiline': { + 'max': 1, + 'allowFirstLine': false + } + } + ], + 'vue/attribute-hyphenation': 0, + 'vue/html-self-closing': 0, + 'vue/component-name-in-template-casing': 0, + 'vue/html-closing-bracket-spacing': 0, + 'vue/singleline-html-element-content-newline': 0, + 'vue/no-unused-components': 0, + 'vue/multiline-html-element-content-newline': 0, + 'vue/no-use-v-if-with-v-for': 0, + 'vue/html-closing-bracket-newline': 0, + 'vue/no-parsing-error': 0, + 'no-tabs': 0, + 'quotes': [ + 2, + 'single', + { + 'avoidEscape': true, + 'allowTemplateLiterals': true + } + ], + 'semi': [ + 2, + 'never', + { + 'beforeStatementContinuationChars': 'never' + } + ], + 'no-delete-var': 2, + 'prefer-const': [ + 2, + { + 'ignoreReadBeforeAssign': false + } + ] + }, + parserOptions: { + parser: 'babel-eslint' + }, + overrides: [ + { + files: [ + '**/__tests__/*.{j,t}s?(x)', + '**/tests/unit/**/*.spec.{j,t}s?(x)' + ], + env: { + jest: true + } + } + ] +} \ No newline at end of file diff --git a/vue.config.js b/vue.config.js index 7a2f9d3..c289b52 100644 --- a/vue.config.js +++ b/vue.config.js @@ -41,7 +41,7 @@ module.exports = { // publicPath: '/app/', //署应用包时的基本 URL。 vue-router history模式使用 outputDir: 'dist', // 生产环境构建文件的目录 assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录 - lintOnSave: false, + lintOnSave: true, productionSourceMap: false, // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 devServer: { port: 9020, // 端口