@neralabs/rerail-pack-typescript 0.1.3 → 0.1.4

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.
package/pack.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "id": "typescript",
4
4
  "name": "TypeScript",
5
5
  "category": "language",
6
- "covers": "21 typescript-eslint rules ported to Rerail, 10 of them on and 11 off until turned on, each scored against the tool's own recorded findings on its test fixtures.",
6
+ "covers": "24 typescript-eslint rules ported to Rerail, 13 of them on and 11 off until turned on, each scored against the tool's own recorded findings on its test fixtures.",
7
7
  "reason": "matches TypeScript",
8
8
  "match": {
9
9
  "any": [
@@ -89,6 +89,12 @@
89
89
  "group": "typescript-eslint",
90
90
  "on": false
91
91
  },
92
+ {
93
+ "id": "typescript-eslint-no-empty-object-type",
94
+ "document": "rules/typescript-eslint-no-empty-object-type.json",
95
+ "title": "typescript-eslint no-empty-object-type: Disallow accidentally using the \"empty object\" type",
96
+ "group": "typescript-eslint"
97
+ },
92
98
  {
93
99
  "id": "typescript-eslint-no-extra-non-null-assertion",
94
100
  "document": "rules/typescript-eslint-no-extra-non-null-assertion.json",
@@ -137,6 +143,12 @@
137
143
  "title": "typescript-eslint no-unnecessary-type-constraint: Disallow unnecessary constraints on generic types",
138
144
  "group": "typescript-eslint"
139
145
  },
146
+ {
147
+ "id": "typescript-eslint-no-unsafe-declaration-merging",
148
+ "document": "rules/typescript-eslint-no-unsafe-declaration-merging.json",
149
+ "title": "typescript-eslint no-unsafe-declaration-merging: Disallow unsafe declaration merging",
150
+ "group": "typescript-eslint"
151
+ },
140
152
  {
141
153
  "id": "typescript-eslint-no-unsafe-function-type",
142
154
  "document": "rules/typescript-eslint-no-unsafe-function-type.json",
@@ -181,6 +193,22 @@
181
193
  "document": "rules/typescript-eslint-prefer-namespace-keyword.json",
182
194
  "title": "typescript-eslint prefer-namespace-keyword: Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules",
183
195
  "group": "typescript-eslint"
196
+ },
197
+ {
198
+ "id": "typescript-eslint-triple-slash-reference",
199
+ "document": "rules/typescript-eslint-triple-slash-reference.json",
200
+ "title": "typescript-eslint triple-slash-reference: Disallow certain triple slash directives in favor of ES6-style import declarations",
201
+ "group": "typescript-eslint",
202
+ "examples": {
203
+ "caught": {
204
+ "path": "src/setup.ts",
205
+ "text": "/// <reference path=\"./globals.d.ts\" />\n\nexport function ready(): boolean {\n return typeof window !== \"undefined\";\n}\n"
206
+ },
207
+ "passes": {
208
+ "path": "src/setup.ts",
209
+ "text": "import \"./globals.js\";\n\nexport function ready(): boolean {\n return typeof window !== \"undefined\";\n}\n"
210
+ }
211
+ }
184
212
  }
185
213
  ]
186
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neralabs/rerail-pack-typescript",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Rerail rule pack: typescript-eslint rules ported to Rerail code rules.",
5
5
  "license": "Apache-2.0 AND MIT",
6
6
  "repository": {
@@ -0,0 +1,221 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "typescript-eslint-no-empty-object-type",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Avoid empty TypeScript interfaces and the empty object type; both accept any non-nullish value, so use object, unknown or the extended type instead.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "shared",
16
+ "define": {
17
+ "language": "typescript",
18
+ "utils": {
19
+ "member": {
20
+ "any": [
21
+ {
22
+ "kind": "property_signature"
23
+ },
24
+ {
25
+ "kind": "method_signature"
26
+ },
27
+ {
28
+ "kind": "call_signature"
29
+ },
30
+ {
31
+ "kind": "construct_signature"
32
+ },
33
+ {
34
+ "kind": "index_signature"
35
+ }
36
+ ]
37
+ },
38
+ "reported-parent": {
39
+ "any": [
40
+ {
41
+ "kind": "parenthesized_type",
42
+ "inside": {
43
+ "matches": "reported-parent"
44
+ }
45
+ },
46
+ {
47
+ "kind": "adding_type_annotation"
48
+ },
49
+ {
50
+ "kind": "ambient_declaration"
51
+ },
52
+ {
53
+ "kind": "array_type"
54
+ },
55
+ {
56
+ "kind": "as_expression"
57
+ },
58
+ {
59
+ "kind": "conditional_type"
60
+ },
61
+ {
62
+ "kind": "constraint"
63
+ },
64
+ {
65
+ "kind": "constructor_type"
66
+ },
67
+ {
68
+ "kind": "default_type"
69
+ },
70
+ {
71
+ "kind": "flow_maybe_type"
72
+ },
73
+ {
74
+ "kind": "function_type"
75
+ },
76
+ {
77
+ "kind": "implements_clause"
78
+ },
79
+ {
80
+ "kind": "index_signature"
81
+ },
82
+ {
83
+ "kind": "index_type_query"
84
+ },
85
+ {
86
+ "kind": "infer_type"
87
+ },
88
+ {
89
+ "kind": "lookup_type"
90
+ },
91
+ {
92
+ "kind": "mapped_type_clause"
93
+ },
94
+ {
95
+ "kind": "omitting_type_annotation"
96
+ },
97
+ {
98
+ "kind": "opting_type_annotation"
99
+ },
100
+ {
101
+ "kind": "optional_type"
102
+ },
103
+ {
104
+ "kind": "readonly_type"
105
+ },
106
+ {
107
+ "kind": "rest_type"
108
+ },
109
+ {
110
+ "kind": "satisfies_expression"
111
+ },
112
+ {
113
+ "kind": "template_type"
114
+ },
115
+ {
116
+ "kind": "tuple_type"
117
+ },
118
+ {
119
+ "kind": "type_alias_declaration"
120
+ },
121
+ {
122
+ "kind": "type_annotation"
123
+ },
124
+ {
125
+ "kind": "type_arguments"
126
+ },
127
+ {
128
+ "kind": "type_predicate"
129
+ },
130
+ {
131
+ "kind": "union_type"
132
+ }
133
+ ]
134
+ }
135
+ }
136
+ }
137
+ },
138
+ {
139
+ "id": "empty-interface",
140
+ "forbid": {
141
+ "ast": {
142
+ "language": "typescript",
143
+ "rule": {
144
+ "kind": "interface_declaration",
145
+ "all": [
146
+ {
147
+ "has": {
148
+ "field": "name",
149
+ "pattern": "$NAME"
150
+ }
151
+ },
152
+ {
153
+ "has": {
154
+ "field": "body",
155
+ "not": {
156
+ "has": {
157
+ "matches": "member"
158
+ }
159
+ }
160
+ }
161
+ },
162
+ {
163
+ "not": {
164
+ "has": {
165
+ "kind": "extends_type_clause",
166
+ "has": {
167
+ "regex": "^,$"
168
+ }
169
+ }
170
+ }
171
+ }
172
+ ]
173
+ }
174
+ }
175
+ },
176
+ "violation": {
177
+ "anchor": "capture.NAME",
178
+ "code": "@typescript-eslint/no-empty-object-type",
179
+ "message": "An empty interface allows any non-nullish value, and one extending a single type is equivalent to that supertype: use `object`, `unknown` or a type alias instead.",
180
+ "suppress": {
181
+ "eslint": {
182
+ "rules": [
183
+ "@typescript-eslint/no-empty-object-type"
184
+ ]
185
+ }
186
+ }
187
+ }
188
+ },
189
+ {
190
+ "id": "empty-object-type",
191
+ "forbid": {
192
+ "ast": {
193
+ "language": "typescript",
194
+ "rule": {
195
+ "kind": "object_type",
196
+ "not": {
197
+ "has": {
198
+ "matches": "member"
199
+ }
200
+ },
201
+ "inside": {
202
+ "matches": "reported-parent"
203
+ }
204
+ }
205
+ }
206
+ },
207
+ "violation": {
208
+ "anchor": "witness.span",
209
+ "code": "@typescript-eslint/no-empty-object-type",
210
+ "message": "The `{}` (\"empty object\") type allows any non-nullish value, including literals like `0` and `\"\"`: use `object` for any object or `unknown` for any value.",
211
+ "suppress": {
212
+ "eslint": {
213
+ "rules": [
214
+ "@typescript-eslint/no-empty-object-type"
215
+ ]
216
+ }
217
+ }
218
+ }
219
+ }
220
+ ]
221
+ }
@@ -0,0 +1,250 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "typescript-eslint-no-unsafe-declaration-merging",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Don't give a TypeScript class and an interface the same name in one scope; the merge adds the interface's members to the class without checking them.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "merged-class-and-interface",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "typescript",
19
+ "rule": {
20
+ "has": {
21
+ "field": "name",
22
+ "pattern": "$NAME"
23
+ },
24
+ "any": [
25
+ {
26
+ "matches": "class-declaration",
27
+ "inside": {
28
+ "matches": "scope-with-interface"
29
+ }
30
+ },
31
+ {
32
+ "kind": "interface_declaration",
33
+ "not": {
34
+ "has": {
35
+ "field": "type_parameters",
36
+ "kind": "type_parameters"
37
+ }
38
+ },
39
+ "inside": {
40
+ "matches": "scope-with-class"
41
+ }
42
+ }
43
+ ]
44
+ },
45
+ "utils": {
46
+ "class-declaration": {
47
+ "any": [
48
+ {
49
+ "kind": "class_declaration"
50
+ },
51
+ {
52
+ "kind": "abstract_class_declaration"
53
+ }
54
+ ]
55
+ },
56
+ "scope-block": {
57
+ "any": [
58
+ {
59
+ "kind": "program"
60
+ },
61
+ {
62
+ "kind": "statement_block"
63
+ },
64
+ {
65
+ "kind": "switch_body"
66
+ },
67
+ {
68
+ "kind": "for_statement",
69
+ "has": {
70
+ "field": "initializer",
71
+ "kind": "lexical_declaration"
72
+ }
73
+ },
74
+ {
75
+ "kind": "for_in_statement",
76
+ "has": {
77
+ "field": "kind",
78
+ "regex": "^(?:let|const)$"
79
+ }
80
+ },
81
+ {
82
+ "kind": "with_statement"
83
+ }
84
+ ]
85
+ },
86
+ "wrapper": {
87
+ "any": [
88
+ {
89
+ "kind": "export_statement"
90
+ },
91
+ {
92
+ "kind": "ambient_declaration"
93
+ },
94
+ {
95
+ "kind": "switch_case"
96
+ },
97
+ {
98
+ "kind": "switch_default"
99
+ },
100
+ {
101
+ "kind": "if_statement"
102
+ },
103
+ {
104
+ "kind": "else_clause"
105
+ },
106
+ {
107
+ "kind": "while_statement"
108
+ },
109
+ {
110
+ "kind": "do_statement"
111
+ },
112
+ {
113
+ "kind": "labeled_statement"
114
+ },
115
+ {
116
+ "kind": "for_statement",
117
+ "has": {
118
+ "field": "initializer",
119
+ "any": [
120
+ {
121
+ "kind": "variable_declaration"
122
+ },
123
+ {
124
+ "kind": "empty_statement"
125
+ },
126
+ {
127
+ "precedes": {
128
+ "pattern": ";"
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ },
134
+ {
135
+ "kind": "for_in_statement",
136
+ "has": {
137
+ "field": "left",
138
+ "follows": {
139
+ "any": [
140
+ {
141
+ "pattern": "("
142
+ },
143
+ {
144
+ "pattern": "var"
145
+ }
146
+ ]
147
+ }
148
+ }
149
+ }
150
+ ]
151
+ },
152
+ "member-interface": {
153
+ "any": [
154
+ {
155
+ "kind": "interface_declaration",
156
+ "has": {
157
+ "field": "name",
158
+ "pattern": "$OTHER"
159
+ },
160
+ "compare": {
161
+ "left": "OTHER",
162
+ "op": "eq",
163
+ "right": "NAME"
164
+ }
165
+ },
166
+ {
167
+ "matches": "wrapper",
168
+ "has": {
169
+ "matches": "member-interface"
170
+ }
171
+ }
172
+ ]
173
+ },
174
+ "member-class": {
175
+ "any": [
176
+ {
177
+ "matches": "class-declaration",
178
+ "has": {
179
+ "field": "name",
180
+ "pattern": "$OTHER"
181
+ },
182
+ "compare": {
183
+ "left": "OTHER",
184
+ "op": "eq",
185
+ "right": "NAME"
186
+ }
187
+ },
188
+ {
189
+ "matches": "wrapper",
190
+ "has": {
191
+ "matches": "member-class"
192
+ }
193
+ }
194
+ ]
195
+ },
196
+ "scope-with-interface": {
197
+ "any": [
198
+ {
199
+ "matches": "scope-block",
200
+ "has": {
201
+ "matches": "member-interface"
202
+ }
203
+ },
204
+ {
205
+ "matches": "wrapper",
206
+ "inside": {
207
+ "matches": "scope-with-interface"
208
+ }
209
+ }
210
+ ]
211
+ },
212
+ "scope-with-class": {
213
+ "any": [
214
+ {
215
+ "matches": "scope-block",
216
+ "has": {
217
+ "matches": "member-class"
218
+ }
219
+ },
220
+ {
221
+ "matches": "wrapper",
222
+ "inside": {
223
+ "matches": "scope-with-class"
224
+ }
225
+ }
226
+ ]
227
+ }
228
+ }
229
+ }
230
+ },
231
+ "violation": {
232
+ "anchor": "capture.NAME",
233
+ "code": "@typescript-eslint/no-unsafe-declaration-merging",
234
+ "message": "Rename the class or the interface so they don't merge; merged, the class claims the interface's members without implementing them.",
235
+ "suppress": {
236
+ "eslint": {
237
+ "rules": [
238
+ "@typescript-eslint/no-unsafe-declaration-merging"
239
+ ]
240
+ },
241
+ "biome": {
242
+ "rules": [
243
+ "lint/suspicious/noUnsafeDeclarationMerging"
244
+ ]
245
+ }
246
+ }
247
+ }
248
+ }
249
+ ]
250
+ }
@@ -0,0 +1,146 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "typescript-eslint-triple-slash-reference",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Use import declarations instead of triple-slash path references, and drop triple-slash type references to modules the file already imports.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "shared",
16
+ "define": {
17
+ "language": "typescript",
18
+ "utils": {
19
+ "leading-comment": {
20
+ "pattern": "$COMMENT",
21
+ "inside": {
22
+ "kind": "program",
23
+ "stopBy": "neighbor",
24
+ "has": {
25
+ "stopBy": "neighbor",
26
+ "pattern": "$FIRST",
27
+ "any": [
28
+ {
29
+ "regex": "^([^/#]|/[^/*]|#[^!])"
30
+ },
31
+ {
32
+ "compare": {
33
+ "left": "FIRST",
34
+ "op": "eq",
35
+ "right": "COMMENT",
36
+ "text": "node"
37
+ }
38
+ }
39
+ ]
40
+ }
41
+ },
42
+ "compare": {
43
+ "left": "FIRST",
44
+ "op": "eq",
45
+ "right": "COMMENT",
46
+ "text": "node"
47
+ }
48
+ }
49
+ }
50
+ }
51
+ },
52
+ {
53
+ "id": "path-reference",
54
+ "forbid": {
55
+ "ast": {
56
+ "language": "typescript",
57
+ "rule": {
58
+ "kind": "comment",
59
+ "regex": "^///[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*<reference[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*path[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*=[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*[\"|'](?<MODULE>.*)[\"|']",
60
+ "matches": "leading-comment"
61
+ }
62
+ }
63
+ },
64
+ "violation": {
65
+ "anchor": "witness.span",
66
+ "code": "@typescript-eslint/triple-slash-reference",
67
+ "message": "Replace this triple-slash reference to $MODULE with an import declaration.",
68
+ "suppress": {
69
+ "eslint": {
70
+ "rules": [
71
+ "@typescript-eslint/triple-slash-reference"
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ },
77
+ {
78
+ "id": "types-reference",
79
+ "forbid": {
80
+ "ast": {
81
+ "language": "typescript",
82
+ "rule": {
83
+ "kind": "comment",
84
+ "pattern": "$C",
85
+ "regex": "^///[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*<reference[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*types[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*=[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*[\"|'].*[\"|']",
86
+ "matches": "leading-comment",
87
+ "inside": {
88
+ "kind": "program",
89
+ "stopBy": "neighbor",
90
+ "has": {
91
+ "stopBy": "end",
92
+ "kind": "string",
93
+ "pattern": "$SOURCE",
94
+ "inside": {
95
+ "any": [
96
+ {
97
+ "kind": "import_statement"
98
+ },
99
+ {
100
+ "kind": "import_require_clause"
101
+ }
102
+ ],
103
+ "field": "source",
104
+ "stopBy": "neighbor"
105
+ },
106
+ "compare": {
107
+ "left": "MODULE",
108
+ "op": "eq",
109
+ "right": "SPECIFIER"
110
+ }
111
+ }
112
+ }
113
+ },
114
+ "transform": {
115
+ "MODULE": {
116
+ "replace": {
117
+ "source": "$C",
118
+ "replace": "^///[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*<reference[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*types[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*=[\\t\\n\\x0B\\f\\r \\x{A0}\\x{1680}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}\\x{FEFF}]*[\"|'](.*)[\"|'][\\s\\S]*$",
119
+ "by": "$1"
120
+ }
121
+ },
122
+ "SPECIFIER": {
123
+ "substring": {
124
+ "source": "$SOURCE",
125
+ "value": true
126
+ }
127
+ }
128
+ }
129
+ }
130
+ },
131
+ "violation": {
132
+ "anchor": "witness.span",
133
+ "code": "@typescript-eslint/triple-slash-reference",
134
+ "message": "Remove this triple-slash types reference to $MODULE; the file already imports it.",
135
+ "each": "SOURCE",
136
+ "suppress": {
137
+ "eslint": {
138
+ "rules": [
139
+ "@typescript-eslint/triple-slash-reference"
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ }
145
+ ]
146
+ }