-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathtypescript.ts
More file actions
84 lines (74 loc) · 3.18 KB
/
typescript.ts
File metadata and controls
84 lines (74 loc) · 3.18 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import type { OxlintConfig } from 'oxlint'
export const typescriptConfig: OxlintConfig = {
plugins: ['typescript'],
rules: {
/** Prefer Array<T> format */
'@typescript-eslint/array-type': [
'error',
{ default: 'generic', readonly: 'generic' },
],
/** Prevent @ts-ignore, allow @ts-expect-error */
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': false,
'ts-ignore': 'allow-with-description',
},
],
/** Enforce import type { T } */
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],
/** Shorthand method style is less strict */
// '@typescript-eslint/method-signature-style': ['error', 'property'], // No implemented yet
/** Enforces generic type convention */
// // Not implemented yet
// '@typescript-eslint/naming-convention': [
// 'error',
// {
// selector: 'typeParameter',
// format: ['PascalCase'],
// leadingUnderscore: 'forbid',
// trailingUnderscore: 'forbid',
// custom: {
// regex: '^(T|T[A-Z][A-Za-z]+)$',
// match: true,
// },
// },
// ],
/** Duplicate values can lead to bugs that are hard to track down */
'@typescript-eslint/no-duplicate-enum-values': 'error',
/** Using the operator any more than once does nothing */
'@typescript-eslint/no-extra-non-null-assertion': 'error',
/** There are several potential bugs with this compared to other loops */
// '@typescript-eslint/no-for-in-array': 'error', // Requires TypeScript-native (tsgo)
/** Don't over-define types for simple things like strings */
'@typescript-eslint/no-inferrable-types': [
'error',
{ ignoreParameters: true },
],
/** Enforce valid definition of new and constructor */
'@typescript-eslint/no-misused-new': 'error',
/** Disallow TypeScript namespaces */
'@typescript-eslint/no-namespace': 'error',
/** Disallow non-null assertions after an optional chain expression */
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
/** Detects conditionals which will always evaluate truthy or falsy */
// '@typescript-eslint/no-unnecessary-condition': 'error', // Not implemented yet / unsupported
/** Checks if the the explicit type is identical to the inferred type */
// '@typescript-eslint/no-unnecessary-type-assertion': 'error', // Requires TypeScript-native (tsgo)
/** Disallow using the unsafe built-in Function type */
'@typescript-eslint/no-unsafe-function-type': 'error',
/** Disallow using confusing built-in primitive class wrappers */
'@typescript-eslint/no-wrapper-object-types': 'error',
/** Enforce the use of as const over literal type */
'@typescript-eslint/prefer-as-const': 'error',
/** Prefer for-of loop over the standard for loop */
'@typescript-eslint/prefer-for-of': 'warn',
/** Warn about async functions which have no await expression */
// '@typescript-eslint/require-await': 'warn', // Requires TypeScript-native (tsgo)
/** Prefer of ES6-style import declarations */
'@typescript-eslint/triple-slash-reference': 'error',
},
}