From ef42bac1a88bb81233ccfcd5497f6c988609d8aa Mon Sep 17 00:00:00 2001 From: wangyupei <2311595895@qq.com> Date: Mon, 7 Mar 2022 16:33:27 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0eslint=E5=92=8Cprett?= =?UTF-8?q?ier=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 103 +++++++++++++++++++++++++++++++++++++++++---------- .prettierrc | 11 +++--- 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 89aa01109a..8c5f27c5df 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,43 +6,108 @@ module.exports = { ecmaVersion: 6, ecmaFeatures: { jsx: true, - tsx: true - } + tsx: true, + }, }, env: { browser: true, node: true, jest: true, - es6: true + es6: true, }, plugins: ['@typescript-eslint'], extends: [ 'plugin:@typescript-eslint/recommended', 'plugin:vue/vue3-recommended', 'plugin:import/recommended', - 'plugin:import/typescript' + 'plugin:import/typescript', ], rules: { - quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }], - 'no-undef': 2, - 'vue/max-attributes-per-line': 'off', - 'vue/no-multiple-template-root': 'off', - 'vue/script-setup-uses-vars': 'off', - '@typescript-eslint/no-explicit-any': 'off', + 'no-useless-constructor': 'off', + 'no-useless-concat': 'off', + 'max-params': 'off', + '@typescript-eslint/no-useless-constructor': 'off', + '@typescript-eslint/no-parameter-properties': 'off', + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/no-var-requires': 'off', + complexity: [ + 'error', + { + max: 40, + }, + ], + curly: 'error', + 'eol-last': 'error', + eqeqeq: ['error', 'smart'], + 'max-len': ['error', { code: 140 }], + 'no-console': [ + 'error', + { + allow: [ + 'log', + 'warn', + 'dir', + 'timeLog', + 'assert', + 'clear', + 'count', + 'countReset', + 'group', + 'groupEnd', + 'table', + 'dirxml', + 'error', + 'groupCollapsed', + 'Console', + 'profile', + 'profileEnd', + 'timeStamp', + 'context', + ], + }, + ], + 'no-multiple-empty-lines': 'error', + 'no-shadow': 'off', + 'no-trailing-spaces': 'error', + 'no-unused-labels': 'error', + 'no-use-before-define': 'error', + 'no-var': 'error', + 'prefer-const': 'error', + semi: 'error', + 'space-in-parens': ['error', 'never'], + 'spaced-comment': ['error', 'always'], + '@typescript-eslint/dot-notation': 'off', + '@typescript-eslint/indent': [ + 'error', + 2, + { FunctionDeclaration: { parameters: 'first' }, FunctionExpression: { parameters: 'first' } }, + ], '@typescript-eslint/member-delimiter-style': [ 'error', { multiline: { - delimiter: 'none', - requireLast: false + delimiter: 'semi', + requireLast: true, }, singleline: { delimiter: 'semi', - requireLast: true - } - } + requireLast: false, + }, + }, ], - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': ['error'] - } -} + '@typescript-eslint/no-misused-new': 'error', + '@typescript-eslint/no-non-null-assertion': 'error', + '@typescript-eslint/prefer-function-type': 'error', + '@typescript-eslint/semi': ['error', 'always'], + '@typescript-eslint/type-annotation-spacing': 'error', + '@typescript-eslint/unified-signatures': 'error', + '@typescript-eslint/no-shadow': 'error', + 'prefer-promise-reject-errors': 'off', + 'max-nested-callbacks': ['error', 6], + '@typescript-eslint/no-this-alias': 'off', + 'accessor-pairs': 'off', + 'max-depth': 'off', + '@typescript-eslint/member-ordering': 'off', + 'array-callback-return': 'off', + }, +}; diff --git a/.prettierrc b/.prettierrc index 3f28dda2ab..2083fb89e3 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,12 +1,13 @@ { - "arrowParens": "always", "bracketSpacing": true, - "htmlWhitespaceSensitivity": "ignore", + "jsxBracketSameLine": true, "jsxSingleQuote": true, - "printWidth": 100, + "printWidth": 140, "semi": true, "useTabs": false, - "trailingComma": "none", + "trailingComma": "es5", "singleQuote": true, - "tabWidth": 2 + "tabWidth": 2, + "endOfLine": "auto", + "proseWrap": "preserve" }