-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
163 lines (158 loc) · 5.01 KB
/
index.js
File metadata and controls
163 lines (158 loc) · 5.01 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';
import preferBigIntLiteral from 'eslint-plugin-prefer-bigint-literal';
import returnParens from 'eslint-plugin-return-parens';
import packageJsonDependencies from 'eslint-plugin-package-json-dependencies';
export default [
{
...eslint.configs.recommended,
files: ['**/*.{ts,tsx}', '**/*.{js,cjs,mjs}'],
plugins: {
['@stylistic']: stylistic
},
rules: {
// @stylistic rules
'@stylistic/comma-dangle': ['error', 'never'],
'@stylistic/indent': ['error', 'tab'],
'@stylistic/keyword-spacing': ['error', {
'overrides': {
'return': {
'after': false
},
'throw': {
'after': false
}
}
}],
'@stylistic/lines-between-class-members': ['error', 'always', {
'exceptAfterSingleLine': true
}],
'@stylistic/object-curly-spacing': ['error', 'always', {
'objectsInObjects': false
}],
'@stylistic/space-before-function-paren': ['error', {
'anonymous': 'never',
'named': 'never',
'asyncArrow': 'always'
}]
}
},
...tseslint.config({
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked
],
plugins: {
['prefer-bigint-literal']: preferBigIntLiteral,
['return-parens']: returnParens,
['@stylistic']: stylistic
},
languageOptions: {
parserOptions: {
project: ['tsconfig.json']
}
},
rules: {
/*
* This rule (from @typescript-eslint/recommended-type-checked)
* has no good alternative syntax, so we disable it
*/
"@typescript-eslint/no-for-in-array": 'off',
/*
* This rule (from @typescript-eslint/recommended-type-checked)
* is not that useful because in most cases an async function is
* created to satisfy an interface
*/
"@typescript-eslint/require-await": 'off',
/*
* This rule does doesn't add value for us because we already
* require a comment describing why "@ts-" comments are used
* so adding a linting rule just means we double up on it
*/
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-inferrable-types': ['error', {
'ignoreParameters': true
}],
'@typescript-eslint/no-unused-vars': ['error', {
'argsIgnorePattern': '^_ignore'
}],
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-loop-func': 'off',
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/no-misused-promises': ['error', {
'checksVoidReturn': false
}],
'curly': 'error',
'spaced-comment': ['error', 'always', {
'block': {
'markers': ['*'],
'balanced': true
}
}],
// No spaces/tabs in end of line/empty line
'no-trailing-spaces': 'error',
'array-callback-return': 'error',
'eol-last': ['error', 'always'],
'space-in-parens': ['error', 'never'],
'@typescript-eslint/array-type': ['error', {
'default': 'array'
}],
'@typescript-eslint/consistent-indexed-object-style': ['error', 'index-signature'],
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/no-use-before-define': 'error',
'return-parens/return-parens': 'error',
// Not compatible with ESLINT 9.x
// '@getify/proper-arrows/this': 'error'
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'never' }],
'@typescript-eslint/no-empty-function': ['error', {
allow: [
'arrowFunctions',
'functions',
'methods'
]
}],
'@typescript-eslint/switch-exhaustiveness-check': ['error', {
allowDefaultCaseForExhaustiveSwitch: true,
considerDefaultExhaustiveForUnions: true,
requireDefaultForNonUnion: false
}],
'@typescript-eslint/no-extraneous-class': ['error', {
allowStaticOnly: true
}],
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
'@typescript-eslint/prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
'prefer-bigint-literal/prefer-bigint-literal': 'error'
}
}),
{
files: ['package.json'],
plugins: {
['package-json-dependencies']: packageJsonDependencies
},
languageOptions: {
parser: packageJsonDependencies,
parserOptions: {
extraFileExtensions: ['.json']
}
},
rules: {
'package-json-dependencies/controlled-versions': ['error', { 'granularity': {
'peerDependencies': 'minor'
}}],
'package-json-dependencies/alphabetically-sorted-dependencies': 'error'
}
}
];