@neralabs/rerail-pack-typescript 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +36 -0
  4. package/licenses/eslint-plugin-vitest/LICENSE +21 -0
  5. package/licenses/eslint-plugin-vitest/UPSTREAM.md +103 -0
  6. package/licenses/typescript-eslint/LICENSE +21 -0
  7. package/licenses/typescript-eslint/UPSTREAM.md +1607 -0
  8. package/pack.json +189 -0
  9. package/package.json +30 -0
  10. package/rules/typescript-eslint-ban-tslint-comment.json +33 -0
  11. package/rules/typescript-eslint-consistent-type-definitions.json +1 -0
  12. package/rules/typescript-eslint-default-param-last.json +55 -0
  13. package/rules/typescript-eslint-no-array-constructor.json +238 -0
  14. package/rules/typescript-eslint-no-confusing-non-null-assertion.json +190 -0
  15. package/rules/typescript-eslint-no-dupe-class-members.json +1 -0
  16. package/rules/typescript-eslint-no-duplicate-enum-values.json +178 -0
  17. package/rules/typescript-eslint-no-empty-function.json +1 -0
  18. package/rules/typescript-eslint-no-extra-non-null-assertion.json +84 -0
  19. package/rules/typescript-eslint-no-import-type-side-effects.json +336 -0
  20. package/rules/typescript-eslint-no-namespace.json +157 -0
  21. package/rules/typescript-eslint-no-non-null-asserted-optional-chain.json +173 -0
  22. package/rules/typescript-eslint-no-non-null-assertion.json +195 -0
  23. package/rules/typescript-eslint-no-unnecessary-type-constraint.json +66 -0
  24. package/rules/typescript-eslint-no-unsafe-function-type.json +50 -0
  25. package/rules/typescript-eslint-no-unused-expressions.json +1 -0
  26. package/rules/typescript-eslint-no-useless-empty-export.json +38 -0
  27. package/rules/typescript-eslint-no-wrapper-object-types.json +568 -0
  28. package/rules/typescript-eslint-prefer-as-const.json +224 -0
  29. package/rules/typescript-eslint-prefer-enum-initializers.json +26 -0
  30. package/rules/typescript-eslint-prefer-literal-enum-member.json +1 -0
  31. package/rules/typescript-eslint-prefer-namespace-keyword.json +98 -0
@@ -0,0 +1,336 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "typescript-eslint-no-import-type-side-effects",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of typescript-eslint's `no-import-type-side-effects` rule (https://typescript-eslint.io/rules/no-import-type-side-effects). Flags an import whose specifiers are all inline `type` specifiers.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "inline-type-only-import-multi",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "typescript",
19
+ "rule": {
20
+ "all": [
21
+ {
22
+ "kind": "import_statement",
23
+ "not": {
24
+ "has": {
25
+ "regex": "^type$",
26
+ "stopBy": "neighbor"
27
+ }
28
+ },
29
+ "has": {
30
+ "kind": "import_clause",
31
+ "stopBy": "neighbor",
32
+ "not": {
33
+ "has": {
34
+ "any": [
35
+ {
36
+ "kind": "identifier"
37
+ },
38
+ {
39
+ "kind": "namespace_import"
40
+ }
41
+ ],
42
+ "stopBy": "neighbor"
43
+ }
44
+ },
45
+ "has": {
46
+ "kind": "named_imports",
47
+ "stopBy": "neighbor",
48
+ "all": [
49
+ {
50
+ "has": {
51
+ "kind": "import_specifier",
52
+ "stopBy": "neighbor"
53
+ }
54
+ },
55
+ {
56
+ "not": {
57
+ "has": {
58
+ "kind": "import_specifier",
59
+ "stopBy": "neighbor",
60
+ "not": {
61
+ "has": {
62
+ "regex": "^type$",
63
+ "stopBy": "neighbor"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ]
70
+ }
71
+ }
72
+ },
73
+ {
74
+ "any": [
75
+ {
76
+ "has": {
77
+ "kind": "import_clause",
78
+ "stopBy": "neighbor",
79
+ "has": {
80
+ "kind": "named_imports",
81
+ "stopBy": "neighbor",
82
+ "count": {
83
+ "has": {
84
+ "kind": "import_specifier",
85
+ "stopBy": "neighbor"
86
+ },
87
+ "min": 2
88
+ }
89
+ }
90
+ }
91
+ },
92
+ {
93
+ "not": {
94
+ "regex": ";$"
95
+ }
96
+ }
97
+ ]
98
+ }
99
+ ]
100
+ }
101
+ }
102
+ },
103
+ "violation": {
104
+ "anchor": "witness.span",
105
+ "code": "@typescript-eslint/no-import-type-side-effects",
106
+ "message": "TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime. Convert this to a top-level type qualifier to properly remove the entire import."
107
+ }
108
+ },
109
+ {
110
+ "id": "inline-type-only-import-single",
111
+ "forbid": {
112
+ "ast": {
113
+ "language": "typescript",
114
+ "rule": {
115
+ "all": [
116
+ {
117
+ "kind": "import_statement",
118
+ "not": {
119
+ "has": {
120
+ "regex": "^type$",
121
+ "stopBy": "neighbor"
122
+ }
123
+ },
124
+ "has": {
125
+ "kind": "import_clause",
126
+ "stopBy": "neighbor",
127
+ "not": {
128
+ "has": {
129
+ "any": [
130
+ {
131
+ "kind": "identifier"
132
+ },
133
+ {
134
+ "kind": "namespace_import"
135
+ }
136
+ ],
137
+ "stopBy": "neighbor"
138
+ }
139
+ },
140
+ "has": {
141
+ "kind": "named_imports",
142
+ "stopBy": "neighbor",
143
+ "all": [
144
+ {
145
+ "has": {
146
+ "kind": "import_specifier",
147
+ "stopBy": "neighbor"
148
+ }
149
+ },
150
+ {
151
+ "not": {
152
+ "has": {
153
+ "kind": "import_specifier",
154
+ "stopBy": "neighbor",
155
+ "not": {
156
+ "has": {
157
+ "regex": "^type$",
158
+ "stopBy": "neighbor"
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ ]
165
+ }
166
+ }
167
+ },
168
+ {
169
+ "regex": ";$"
170
+ },
171
+ {
172
+ "has": {
173
+ "kind": "import_clause",
174
+ "stopBy": "neighbor",
175
+ "has": {
176
+ "kind": "named_imports",
177
+ "stopBy": "neighbor",
178
+ "all": [
179
+ {
180
+ "count": {
181
+ "has": {
182
+ "kind": "import_specifier",
183
+ "stopBy": "neighbor"
184
+ },
185
+ "max": 1
186
+ }
187
+ },
188
+ {
189
+ "has": {
190
+ "stopBy": "neighbor",
191
+ "pattern": {
192
+ "context": "import { type $A } from 'x';",
193
+ "selector": "import_specifier"
194
+ },
195
+ "not": {
196
+ "has": {
197
+ "regex": "^as$",
198
+ "stopBy": "neighbor"
199
+ }
200
+ }
201
+ }
202
+ }
203
+ ]
204
+ }
205
+ }
206
+ },
207
+ {
208
+ "has": {
209
+ "kind": "string",
210
+ "stopBy": "neighbor",
211
+ "pattern": "$S"
212
+ }
213
+ }
214
+ ]
215
+ }
216
+ }
217
+ },
218
+ "violation": {
219
+ "anchor": "witness.span",
220
+ "code": "@typescript-eslint/no-import-type-side-effects",
221
+ "message": "TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime. Convert this to a top-level type qualifier to properly remove the entire import.",
222
+ "fix": "import type { $A } from $S;"
223
+ }
224
+ },
225
+ {
226
+ "id": "inline-type-only-import-alias",
227
+ "forbid": {
228
+ "ast": {
229
+ "language": "typescript",
230
+ "rule": {
231
+ "all": [
232
+ {
233
+ "kind": "import_statement",
234
+ "not": {
235
+ "has": {
236
+ "regex": "^type$",
237
+ "stopBy": "neighbor"
238
+ }
239
+ },
240
+ "has": {
241
+ "kind": "import_clause",
242
+ "stopBy": "neighbor",
243
+ "not": {
244
+ "has": {
245
+ "any": [
246
+ {
247
+ "kind": "identifier"
248
+ },
249
+ {
250
+ "kind": "namespace_import"
251
+ }
252
+ ],
253
+ "stopBy": "neighbor"
254
+ }
255
+ },
256
+ "has": {
257
+ "kind": "named_imports",
258
+ "stopBy": "neighbor",
259
+ "all": [
260
+ {
261
+ "has": {
262
+ "kind": "import_specifier",
263
+ "stopBy": "neighbor"
264
+ }
265
+ },
266
+ {
267
+ "not": {
268
+ "has": {
269
+ "kind": "import_specifier",
270
+ "stopBy": "neighbor",
271
+ "not": {
272
+ "has": {
273
+ "regex": "^type$",
274
+ "stopBy": "neighbor"
275
+ }
276
+ }
277
+ }
278
+ }
279
+ }
280
+ ]
281
+ }
282
+ }
283
+ },
284
+ {
285
+ "regex": ";$"
286
+ },
287
+ {
288
+ "has": {
289
+ "kind": "import_clause",
290
+ "stopBy": "neighbor",
291
+ "has": {
292
+ "kind": "named_imports",
293
+ "stopBy": "neighbor",
294
+ "all": [
295
+ {
296
+ "count": {
297
+ "has": {
298
+ "kind": "import_specifier",
299
+ "stopBy": "neighbor"
300
+ },
301
+ "max": 1
302
+ }
303
+ },
304
+ {
305
+ "has": {
306
+ "stopBy": "neighbor",
307
+ "pattern": {
308
+ "context": "import { type $A as $B } from 'x';",
309
+ "selector": "import_specifier"
310
+ }
311
+ }
312
+ }
313
+ ]
314
+ }
315
+ }
316
+ },
317
+ {
318
+ "has": {
319
+ "kind": "string",
320
+ "stopBy": "neighbor",
321
+ "pattern": "$S"
322
+ }
323
+ }
324
+ ]
325
+ }
326
+ }
327
+ },
328
+ "violation": {
329
+ "anchor": "witness.span",
330
+ "code": "@typescript-eslint/no-import-type-side-effects",
331
+ "message": "TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime. Convert this to a top-level type qualifier to properly remove the entire import.",
332
+ "fix": "import type { $A as $B } from $S;"
333
+ }
334
+ }
335
+ ]
336
+ }
@@ -0,0 +1,157 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "typescript-eslint-no-namespace",
4
+ "revision": 3,
5
+ "mode": "steer",
6
+ "description": "typescript-eslint 8.70.1 @typescript-eslint/no-namespace, default options. allowDefinitionFiles is fixed at its default (true): a file whose name typescript-eslint's isDefinitionFile matches (`\\.d\\.(ts|cts|mts|.*\\.ts)$`) is not checked. Port of typescript-eslint's `no-namespace` rule (https://typescript-eslint.io/rules/no-namespace). Flags `namespace X {}` and `module X {}` (not `declare global` or `declare module 'name'`) with its defaults: declared namespaces are flagged, and definition files (*.d.ts, *.d.cts, *.d.mts, *.d.*.ts) are exempt through the document scope. Options are declared in the `options` define (the rule's defaults); a variant is a config patch.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*.ts",
10
+ "**/*.tsx",
11
+ "**/*.mts",
12
+ "**/*.cts",
13
+ "**/*.js",
14
+ "**/*.jsx",
15
+ "**/*.mjs",
16
+ "**/*.cjs"
17
+ ],
18
+ "exclude": []
19
+ },
20
+ "clauses": [
21
+ {
22
+ "id": "options",
23
+ "define": {
24
+ "options": {
25
+ "allowDeclarations": {
26
+ "type": "boolean",
27
+ "nullable": true,
28
+ "default": null
29
+ }
30
+ }
31
+ }
32
+ },
33
+ {
34
+ "id": "shared",
35
+ "define": {
36
+ "language": "typescript",
37
+ "utils": {
38
+ "r1": {
39
+ "any": [
40
+ {
41
+ "kind": "internal_module"
42
+ },
43
+ {
44
+ "kind": "module",
45
+ "not": {
46
+ "has": {
47
+ "kind": "string",
48
+ "stopBy": "neighbor"
49
+ }
50
+ }
51
+ }
52
+ ]
53
+ }
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "id": "namespace",
59
+ "forbid": {
60
+ "ast": {
61
+ "language": "typescript",
62
+ "rule": {
63
+ "all": [
64
+ {
65
+ "matches": "r1"
66
+ },
67
+ {
68
+ "not": {
69
+ "inside": {
70
+ "kind": "ambient_declaration",
71
+ "stopBy": "neighbor"
72
+ }
73
+ }
74
+ },
75
+ {
76
+ "$option": "allowDeclarations",
77
+ "cases": {
78
+ "true": [
79
+ {
80
+ "not": {
81
+ "inside": {
82
+ "kind": "ambient_declaration",
83
+ "stopBy": "end"
84
+ }
85
+ }
86
+ }
87
+ ]
88
+ },
89
+ "default": [],
90
+ "spread": true
91
+ }
92
+ ]
93
+ },
94
+ "file": {
95
+ "path": {
96
+ "notRegex": "\\.d\\.(ts|cts|mts|.*\\.ts)$"
97
+ }
98
+ }
99
+ }
100
+ },
101
+ "violation": {
102
+ "anchor": "witness.span",
103
+ "code": "@typescript-eslint/no-namespace",
104
+ "message": "ES2015 module syntax is preferred over namespaces.",
105
+ "suppress": {
106
+ "eslint": {
107
+ "rules": [
108
+ "@typescript-eslint/no-namespace"
109
+ ]
110
+ }
111
+ }
112
+ }
113
+ },
114
+ {
115
+ "id": "declared-namespace",
116
+ "forbid": {
117
+ "ast": {
118
+ "language": "typescript",
119
+ "rule": {
120
+ "kind": "ambient_declaration",
121
+ "has": {
122
+ "stopBy": "neighbor",
123
+ "matches": "r1"
124
+ }
125
+ },
126
+ "when": {
127
+ "option": {
128
+ "allowDeclarations": {
129
+ "in": [
130
+ null,
131
+ false
132
+ ]
133
+ }
134
+ }
135
+ },
136
+ "file": {
137
+ "path": {
138
+ "notRegex": "\\.d\\.(ts|cts|mts|.*\\.ts)$"
139
+ }
140
+ }
141
+ }
142
+ },
143
+ "violation": {
144
+ "anchor": "witness.span",
145
+ "code": "@typescript-eslint/no-namespace",
146
+ "message": "ES2015 module syntax is preferred over namespaces.",
147
+ "suppress": {
148
+ "eslint": {
149
+ "rules": [
150
+ "@typescript-eslint/no-namespace"
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ]
157
+ }
@@ -0,0 +1,173 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "typescript-eslint-no-non-null-asserted-optional-chain",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of typescript-eslint's `no-non-null-asserted-optional-chain` rule (https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain). Flags a non-null assertion that ends an optional chain (`x?.y!`), and a parenthesized optional chain that is non-null asserted (`(x?.y)!`, reported at the chain).",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "chain-end",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "typescript",
19
+ "rule": {
20
+ "kind": "non_null_expression",
21
+ "has": {
22
+ "matches": "optional-chain",
23
+ "stopBy": "neighbor"
24
+ },
25
+ "not": {
26
+ "all": [
27
+ {
28
+ "not": {
29
+ "follows": {
30
+ "regex": "[\\s\\S]",
31
+ "stopBy": "neighbor"
32
+ }
33
+ }
34
+ },
35
+ {
36
+ "inside": {
37
+ "any": [
38
+ {
39
+ "kind": "member_expression"
40
+ },
41
+ {
42
+ "kind": "subscript_expression"
43
+ },
44
+ {
45
+ "kind": "call_expression"
46
+ },
47
+ {
48
+ "kind": "non_null_expression"
49
+ }
50
+ ],
51
+ "stopBy": "neighbor"
52
+ }
53
+ }
54
+ ]
55
+ }
56
+ },
57
+ "utils": {
58
+ "optional-chain": {
59
+ "any": [
60
+ {
61
+ "kind": "member_expression"
62
+ },
63
+ {
64
+ "kind": "subscript_expression"
65
+ },
66
+ {
67
+ "kind": "call_expression"
68
+ },
69
+ {
70
+ "kind": "non_null_expression"
71
+ }
72
+ ],
73
+ "has": {
74
+ "stopBy": "neighbor",
75
+ "any": [
76
+ {
77
+ "regex": "^\\?\\.$"
78
+ },
79
+ {
80
+ "all": [
81
+ {
82
+ "matches": "optional-chain"
83
+ },
84
+ {
85
+ "not": {
86
+ "follows": {
87
+ "regex": "[\\s\\S]",
88
+ "stopBy": "neighbor"
89
+ }
90
+ }
91
+ }
92
+ ]
93
+ }
94
+ ]
95
+ }
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "violation": {
101
+ "anchor": "witness.span",
102
+ "code": "@typescript-eslint/no-non-null-asserted-optional-chain",
103
+ "message": "Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong."
104
+ }
105
+ },
106
+ {
107
+ "id": "wrapped-chain",
108
+ "forbid": {
109
+ "ast": {
110
+ "language": "typescript",
111
+ "rule": {
112
+ "kind": "non_null_expression",
113
+ "has": {
114
+ "kind": "parenthesized_expression",
115
+ "stopBy": "neighbor",
116
+ "has": {
117
+ "matches": "optional-chain",
118
+ "pattern": "$CHAIN",
119
+ "stopBy": "neighbor"
120
+ }
121
+ }
122
+ },
123
+ "utils": {
124
+ "optional-chain": {
125
+ "any": [
126
+ {
127
+ "kind": "member_expression"
128
+ },
129
+ {
130
+ "kind": "subscript_expression"
131
+ },
132
+ {
133
+ "kind": "call_expression"
134
+ },
135
+ {
136
+ "kind": "non_null_expression"
137
+ }
138
+ ],
139
+ "has": {
140
+ "stopBy": "neighbor",
141
+ "any": [
142
+ {
143
+ "regex": "^\\?\\.$"
144
+ },
145
+ {
146
+ "all": [
147
+ {
148
+ "matches": "optional-chain"
149
+ },
150
+ {
151
+ "not": {
152
+ "follows": {
153
+ "regex": "[\\s\\S]",
154
+ "stopBy": "neighbor"
155
+ }
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ ]
161
+ }
162
+ }
163
+ }
164
+ }
165
+ },
166
+ "violation": {
167
+ "anchor": "capture.CHAIN",
168
+ "code": "@typescript-eslint/no-non-null-asserted-optional-chain",
169
+ "message": "Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong."
170
+ }
171
+ }
172
+ ]
173
+ }