From 45e03fefd45b3c7133b18997306c26f4ec762dd5 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu <1171051090@qq.com> Date: Wed, 3 Feb 2021 15:50:54 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4eslint=E5=92=8Cstyle?= =?UTF-8?q?lint=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 37 +++++++++++++++++++++++-------------- .stylelintrc.js | 30 ++++++++++++++++-------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 58bb8b8b..9e224949 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,7 @@ +// https://eslint.org/docs/rules/ + +const isProduction = process.env.NODE_ENV === 'production' + module.exports = { root: true, env: { @@ -13,6 +17,11 @@ module.exports = { }, rules: { 'curly': ['error', 'multi-line'], + 'eqeqeq': ['error', 'always'], + 'semi': ['error', 'never'], + 'indent': ['error', 2, { + 'SwitchCase': 1, + }], 'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true, @@ -30,23 +39,20 @@ module.exports = { 'spaced-comment': ['error', 'always'], 'arrow-spacing': 'error', 'no-duplicate-imports': 'error', - 'semi': ['error', 'never'], - 'comma-spacing': ['error', { 'before': false, 'after': true }], - 'indent': ['error', 2, {'SwitchCase': 1}], - 'eqeqeq': ['error', 'always', {'null': 'ignore'}], + 'comma-spacing': ['error', { + 'before': false, + 'after': true, + }], 'default-case': 'error', - 'no-eval': 'error', - 'no-var': 'error', - 'no-with': 'error', - 'max-depth': ['error', 5], - 'consistent-this': ['error', 'self'], - 'max-lines': ['error', 1000], + 'consistent-this': ['error', '_this'], + 'max-depth': ['error', 4], + 'max-lines': ['error', 800], 'no-multi-str': 'error', 'space-infix-ops': 'error', 'space-before-blocks': ['error', 'always'], 'space-before-function-paren': ['error', { - 'anonymous': 'never', 'named': 'never', + 'anonymous': 'never', 'asyncArrow': 'always', }], 'keyword-spacing': ['error'], @@ -54,9 +60,12 @@ module.exports = { 'no-useless-return': 'error', 'array-bracket-spacing': 'error', 'no-useless-escape': 'off', - 'no-alert': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-eval': 'error', + 'no-var': 'error', + 'no-with': 'error', + 'no-alert': isProduction ? 'warn' : 'off', + 'no-console': isProduction ? 'warn' : 'off', + 'no-debugger': isProduction ? 'warn' : 'off', }, overrides: [ { diff --git a/.stylelintrc.js b/.stylelintrc.js index 70577619..0fb43e7d 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -1,33 +1,35 @@ +// https://stylelint.io/user-guide/rules/list + module.exports = { extends: 'stylelint-config-standard', rules: { - 'at-rule-empty-line-before': null, - 'rule-empty-line-before': null, - 'no-missing-end-of-source-newline': null, - 'selector-list-comma-newline-after': null, - 'font-family-no-missing-generic-family-keyword': null, - 'no-descending-specificity': null, - 'number-leading-zero': null, - 'at-rule-no-unknown': null, + 'indentation': 2, + 'max-nesting-depth': 4, 'max-empty-lines': null, - 'selector-pseudo-element-no-unknown': null, + 'no-eol-whitespace': true, + 'no-missing-end-of-source-newline': null, + 'no-descending-specificity': null, + 'at-rule-empty-line-before': null, + 'at-rule-no-unknown': null, + 'rule-empty-line-before': null, + 'number-leading-zero': null, + 'string-no-newline': true, + 'string-quotes': 'single', 'color-hex-case': 'lower', 'color-hex-length': 'short', 'color-no-invalid-hex': true, 'font-weight-notation': 'numeric', + 'font-family-no-missing-generic-family-keyword': null, 'function-calc-no-unspaced-operator': true, 'function-url-quotes': 'never', - 'string-no-newline': true, - 'string-quotes': 'single', 'block-no-empty': true, 'block-opening-brace-newline-after': 'always', 'block-opening-brace-space-before': 'always', - 'indentation': 2, - 'max-nesting-depth': 5, - 'no-eol-whitespace': true, 'declaration-block-no-duplicate-properties': true, 'declaration-block-semicolon-newline-after': 'always', 'declaration-block-trailing-semicolon': 'always', 'selector-pseudo-element-colon-notation': 'double', + 'selector-pseudo-element-no-unknown': null, + 'selector-list-comma-newline-after': null, }, } \ No newline at end of file