forked from antfu/eslint-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunicorn.ts
41 lines (40 loc) · 1.66 KB
/
unicorn.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { TypedFlatConfigItem } from '../types'
import { pluginUnicorn } from '../plugins'
export async function unicorn(): Promise<TypedFlatConfigItem[]> {
return [
{
name: 'antfu/unicorn/rules',
plugins: {
unicorn: pluginUnicorn,
},
rules: {
// Pass error message when throwing errors
'unicorn/error-message': 'error',
// Uppercase regex escapes
'unicorn/escape-case': 'error',
// Array.isArray instead of instanceof
'unicorn/no-instanceof-array': 'error',
// Ban `new Array` as `Array` constructor's params are ambiguous
'unicorn/no-new-array': 'error',
// Prevent deprecated `new Buffer()`
'unicorn/no-new-buffer': 'error',
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
'unicorn/number-literal-case': 'error',
// textContent instead of innerText
'unicorn/prefer-dom-node-text-content': 'error',
// includes over indexOf when checking for existence
'unicorn/prefer-includes': 'error',
// Prefer using the node: protocol
'unicorn/prefer-node-protocol': 'error',
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
'unicorn/prefer-number-properties': 'error',
// String methods startsWith/endsWith instead of more complicated stuff
'unicorn/prefer-string-starts-ends-with': 'error',
// Enforce throwing type error when throwing error while checking typeof
'unicorn/prefer-type-error': 'error',
// Use new when throwing error
'unicorn/throw-new-error': 'error',
},
},
]
}