Skip to content

Commit e82c96f

Browse files
authored
chore: 更新eslint和prettier规则 (#225)
1 parent 2d3107c commit e82c96f

File tree

2 files changed

+90
-24
lines changed

2 files changed

+90
-24
lines changed

.eslintrc.js

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,108 @@ module.exports = {
66
ecmaVersion: 6,
77
ecmaFeatures: {
88
jsx: true,
9-
tsx: true
10-
}
9+
tsx: true,
10+
},
1111
},
1212
env: {
1313
browser: true,
1414
node: true,
1515
jest: true,
16-
es6: true
16+
es6: true,
1717
},
1818
plugins: ['@typescript-eslint'],
1919
extends: [
2020
'plugin:@typescript-eslint/recommended',
2121
'plugin:vue/vue3-recommended',
2222
'plugin:import/recommended',
23-
'plugin:import/typescript'
23+
'plugin:import/typescript',
2424
],
2525
rules: {
26-
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
27-
'no-undef': 2,
28-
'vue/max-attributes-per-line': 'off',
29-
'vue/no-multiple-template-root': 'off',
30-
'vue/script-setup-uses-vars': 'off',
31-
'@typescript-eslint/no-explicit-any': 'off',
26+
'no-useless-constructor': 'off',
27+
'no-useless-concat': 'off',
28+
'max-params': 'off',
29+
'@typescript-eslint/no-useless-constructor': 'off',
30+
'@typescript-eslint/no-parameter-properties': 'off',
31+
'@typescript-eslint/no-require-imports': 'off',
32+
'@typescript-eslint/no-var-requires': 'off',
33+
complexity: [
34+
'error',
35+
{
36+
max: 40,
37+
},
38+
],
39+
curly: 'error',
40+
'eol-last': 'error',
41+
eqeqeq: ['error', 'smart'],
42+
'max-len': ['error', { code: 140 }],
43+
'no-console': [
44+
'error',
45+
{
46+
allow: [
47+
'log',
48+
'warn',
49+
'dir',
50+
'timeLog',
51+
'assert',
52+
'clear',
53+
'count',
54+
'countReset',
55+
'group',
56+
'groupEnd',
57+
'table',
58+
'dirxml',
59+
'error',
60+
'groupCollapsed',
61+
'Console',
62+
'profile',
63+
'profileEnd',
64+
'timeStamp',
65+
'context',
66+
],
67+
},
68+
],
69+
'no-multiple-empty-lines': 'error',
70+
'no-shadow': 'off',
71+
'no-trailing-spaces': 'error',
72+
'no-unused-labels': 'error',
73+
'no-use-before-define': 'error',
74+
'no-var': 'error',
75+
'prefer-const': 'error',
76+
semi: 'error',
77+
'space-in-parens': ['error', 'never'],
78+
'spaced-comment': ['error', 'always'],
79+
'@typescript-eslint/dot-notation': 'off',
80+
'@typescript-eslint/indent': [
81+
'error',
82+
2,
83+
{ FunctionDeclaration: { parameters: 'first' }, FunctionExpression: { parameters: 'first' } },
84+
],
3285
'@typescript-eslint/member-delimiter-style': [
3386
'error',
3487
{
3588
multiline: {
36-
delimiter: 'none',
37-
requireLast: false
89+
delimiter: 'semi',
90+
requireLast: true,
3891
},
3992
singleline: {
4093
delimiter: 'semi',
41-
requireLast: true
42-
}
43-
}
94+
requireLast: false,
95+
},
96+
},
4497
],
45-
'no-unused-vars': 'off',
46-
'@typescript-eslint/no-unused-vars': ['error']
47-
}
48-
}
98+
'@typescript-eslint/no-misused-new': 'error',
99+
'@typescript-eslint/no-non-null-assertion': 'error',
100+
'@typescript-eslint/prefer-function-type': 'error',
101+
'@typescript-eslint/semi': ['error', 'always'],
102+
'@typescript-eslint/type-annotation-spacing': 'error',
103+
'@typescript-eslint/unified-signatures': 'error',
104+
'@typescript-eslint/no-shadow': 'error',
105+
'prefer-promise-reject-errors': 'off',
106+
'max-nested-callbacks': ['error', 6],
107+
'@typescript-eslint/no-this-alias': 'off',
108+
'accessor-pairs': 'off',
109+
'max-depth': 'off',
110+
'@typescript-eslint/member-ordering': 'off',
111+
'array-callback-return': 'off',
112+
},
113+
};

.prettierrc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"arrowParens": "always",
32
"bracketSpacing": true,
4-
"htmlWhitespaceSensitivity": "ignore",
3+
"jsxBracketSameLine": true,
54
"jsxSingleQuote": true,
6-
"printWidth": 100,
5+
"printWidth": 140,
76
"semi": true,
87
"useTabs": false,
9-
"trailingComma": "none",
8+
"trailingComma": "es5",
109
"singleQuote": true,
11-
"tabWidth": 2
10+
"tabWidth": 2,
11+
"endOfLine": "auto",
12+
"proseWrap": "preserve"
1213
}

0 commit comments

Comments
 (0)