Skip to content

Commit e7f7500

Browse files
committedFeb 3, 2024
feat(unicorn): Enable more rules
1 parent 7b94c34 commit e7f7500

File tree

1 file changed

+47
-14
lines changed

1 file changed

+47
-14
lines changed
 

‎src/configs/unicorn.ts

+47-14
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,64 @@ export async function unicorn(): Promise<FlatConfigItem[]> {
1010
},
1111
rules: {
1212
'unicorn/better-regex': 'error',
13-
// Pass error message when throwing errors
13+
'unicorn/catch-error-name': 'error',
14+
'unicorn/custom-error-definition': 'error',
1415
'unicorn/error-message': 'error',
15-
// Uppercase regex escapes
1616
'unicorn/escape-case': 'error',
17-
// Array.isArray instead of instanceof
17+
'unicorn/explicit-length-check': 'error',
18+
// 'unicorn/filename-case': [
19+
// 'error',
20+
// {
21+
// cases: { kebabCase: true, pascalCase: true },
22+
// ignore: [/^[A-Z]+\..*$/],
23+
// },
24+
// ],
25+
'unicorn/new-for-builtins': 'error',
26+
'unicorn/no-array-callback-reference': 'error',
27+
'unicorn/no-array-method-this-argument': 'error',
28+
'unicorn/no-array-push-push': 'error',
29+
'unicorn/no-console-spaces': 'error',
30+
'unicorn/no-for-loop': 'error',
31+
'unicorn/no-hex-escape': 'error',
1832
'unicorn/no-instanceof-array': 'error',
19-
// Ban `new Array` as `Array` constructor's params are ambiguous
33+
'unicorn/no-invalid-remove-event-listener': 'error',
34+
'unicorn/no-lonely-if': 'error',
2035
'unicorn/no-new-array': 'error',
21-
// Prevent deprecated `new Buffer()`
2236
'unicorn/no-new-buffer': 'error',
23-
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
24-
'unicorn/number-literal-case': 'error',
25-
// textContent instead of innerText
37+
'unicorn/no-static-only-class': 'error',
38+
'unicorn/no-unnecessary-await': 'error',
39+
'unicorn/no-zero-fractions': `error`,
40+
'unicorn/prefer-add-event-listener': 'error',
41+
'unicorn/prefer-array-find': 'error',
42+
'unicorn/prefer-array-flat-map': 'error',
43+
'unicorn/prefer-array-index-of': 'error',
44+
'unicorn/prefer-array-some': 'error',
45+
'unicorn/prefer-at': 'error',
46+
'unicorn/prefer-blob-reading-methods': 'error',
47+
'unicorn/prefer-date-now': 'error',
48+
'unicorn/prefer-dom-node-append': 'error',
49+
'unicorn/prefer-dom-node-dataset': 'error',
50+
'unicorn/prefer-dom-node-remove': 'error',
2651
'unicorn/prefer-dom-node-text-content': 'error',
27-
// includes over indexOf when checking for existence
2852
'unicorn/prefer-includes': 'error',
29-
// Prefer using the node: protocol
53+
'unicorn/prefer-keyboard-event-key': 'error',
54+
'unicorn/prefer-math-trunc': 'error',
55+
'unicorn/prefer-modern-dom-apis': 'error',
56+
'unicorn/prefer-modern-math-apis': 'error',
57+
'unicorn/prefer-negative-index': 'error',
3058
'unicorn/prefer-node-protocol': 'error',
31-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
3259
'unicorn/prefer-number-properties': 'error',
33-
// String methods startsWith/endsWith instead of more complicated stuff
60+
'unicorn/prefer-optional-catch-binding': 'error',
61+
'unicorn/prefer-prototype-methods': 'error',
62+
'unicorn/prefer-query-selector': 'error',
63+
'unicorn/prefer-reflect-apply': 'error',
64+
'unicorn/prefer-regexp-test': 'error',
65+
'unicorn/prefer-string-replace-all': 'error',
66+
'unicorn/prefer-string-slice': 'error',
3467
'unicorn/prefer-string-starts-ends-with': 'error',
35-
// Enforce throwing type error when throwing error while checking typeof
68+
'unicorn/prefer-string-trim-start-end': 'error',
69+
'unicorn/prefer-top-level-await': 'error',
3670
'unicorn/prefer-type-error': 'error',
37-
// Use new when throwing error
3871
'unicorn/throw-new-error': 'error',
3972
},
4073
},

0 commit comments

Comments
 (0)