@neralabs/rerail-pack-next 0.1.1 → 0.1.3

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.
@@ -0,0 +1,432 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "next-no-location-assign-relative-destination",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Don't navigate to internal pages by setting location.href or calling location.assign with a relative URL; use redirect() or the router for client-side navigation.",
7
+ "scope": {
8
+ "include": [
9
+ "**/*.ts",
10
+ "**/*.mts",
11
+ "**/*.cts",
12
+ "**/*.tsx",
13
+ "**/*.js",
14
+ "**/*.jsx",
15
+ "**/*.mjs",
16
+ "**/*.cjs"
17
+ ],
18
+ "exclude": []
19
+ },
20
+ "clauses": [
21
+ {
22
+ "id": "href",
23
+ "forbid": {
24
+ "ast": {
25
+ "language": "typescript",
26
+ "languageOptions": {
27
+ "globals": {
28
+ "location": "readonly",
29
+ "window": "readonly",
30
+ "document": "readonly",
31
+ "self": "readonly"
32
+ }
33
+ },
34
+ "utils": {
35
+ "location-root": {
36
+ "any": [
37
+ {
38
+ "kind": "identifier",
39
+ "resolves": {
40
+ "global": [
41
+ "location"
42
+ ]
43
+ }
44
+ },
45
+ {
46
+ "all": [
47
+ {
48
+ "any": [
49
+ {
50
+ "kind": "member_expression",
51
+ "has": {
52
+ "field": "property",
53
+ "kind": "property_identifier",
54
+ "regex": "^location$"
55
+ }
56
+ },
57
+ {
58
+ "kind": "subscript_expression",
59
+ "has": {
60
+ "field": "index",
61
+ "kind": "string",
62
+ "value": {
63
+ "eq": "location"
64
+ }
65
+ }
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "has": {
71
+ "field": "object",
72
+ "kind": "identifier",
73
+ "resolves": {
74
+ "global": [
75
+ "window",
76
+ "globalThis",
77
+ "document",
78
+ "self"
79
+ ]
80
+ }
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ },
87
+ "relative-prefix": {
88
+ "any": [
89
+ {
90
+ "value": {
91
+ "type": "string",
92
+ "follow": true
93
+ },
94
+ "not": {
95
+ "value": {
96
+ "regex": "^(?:[A-Za-z][0-9+.A-Za-z-]*:|//)",
97
+ "follow": true
98
+ }
99
+ }
100
+ },
101
+ {
102
+ "kind": "template_string",
103
+ "has": {
104
+ "kind": "template_substitution"
105
+ },
106
+ "not": {
107
+ "regex": "^`(?:[A-Za-z][0-9+.A-Za-z-]*:|//)"
108
+ }
109
+ },
110
+ {
111
+ "kind": "binary_expression",
112
+ "has": {
113
+ "field": "operator",
114
+ "regex": "^\\+$"
115
+ },
116
+ "all": [
117
+ {
118
+ "has": {
119
+ "field": "left",
120
+ "matches": "relative-prefix"
121
+ }
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ "kind": "parenthesized_expression",
127
+ "has": {
128
+ "matches": "relative-prefix"
129
+ }
130
+ },
131
+ {
132
+ "kind": "identifier",
133
+ "resolves": {
134
+ "binding": {
135
+ "value": {
136
+ "matches": "relative-prefix"
137
+ }
138
+ }
139
+ }
140
+ },
141
+ {
142
+ "kind": "identifier",
143
+ "resolves": {
144
+ "binding": {
145
+ "occurrence": {
146
+ "kind": "identifier",
147
+ "inside": {
148
+ "kind": "assignment_expression",
149
+ "field": "left",
150
+ "has": {
151
+ "field": "right",
152
+ "matches": "relative-prefix"
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ ]
160
+ }
161
+ },
162
+ "rule": {
163
+ "kind": "assignment_expression",
164
+ "all": [
165
+ {
166
+ "has": {
167
+ "field": "left",
168
+ "all": [
169
+ {
170
+ "any": [
171
+ {
172
+ "kind": "member_expression",
173
+ "has": {
174
+ "field": "property",
175
+ "kind": "property_identifier",
176
+ "regex": "^href$"
177
+ }
178
+ },
179
+ {
180
+ "kind": "subscript_expression",
181
+ "has": {
182
+ "field": "index",
183
+ "kind": "string",
184
+ "value": {
185
+ "eq": "href"
186
+ }
187
+ }
188
+ }
189
+ ]
190
+ },
191
+ {
192
+ "has": {
193
+ "field": "object",
194
+ "matches": "location-root"
195
+ }
196
+ }
197
+ ]
198
+ }
199
+ },
200
+ {
201
+ "has": {
202
+ "field": "right",
203
+ "matches": "relative-prefix"
204
+ }
205
+ }
206
+ ]
207
+ }
208
+ }
209
+ },
210
+ "violation": {
211
+ "anchor": "witness.span",
212
+ "code": "@next/next/no-location-assign-relative-destination",
213
+ "message": "Replace this location.href assignment with redirect() during render or useRouter().push() in a client event handler.",
214
+ "suppress": {
215
+ "eslint": {
216
+ "rules": [
217
+ "@next/next/no-location-assign-relative-destination"
218
+ ]
219
+ }
220
+ }
221
+ }
222
+ },
223
+ {
224
+ "id": "assign",
225
+ "forbid": {
226
+ "ast": {
227
+ "language": "typescript",
228
+ "languageOptions": {
229
+ "globals": {
230
+ "location": "readonly",
231
+ "window": "readonly",
232
+ "document": "readonly",
233
+ "self": "readonly"
234
+ }
235
+ },
236
+ "utils": {
237
+ "location-root": {
238
+ "any": [
239
+ {
240
+ "kind": "identifier",
241
+ "resolves": {
242
+ "global": [
243
+ "location"
244
+ ]
245
+ }
246
+ },
247
+ {
248
+ "all": [
249
+ {
250
+ "any": [
251
+ {
252
+ "kind": "member_expression",
253
+ "has": {
254
+ "field": "property",
255
+ "kind": "property_identifier",
256
+ "regex": "^location$"
257
+ }
258
+ },
259
+ {
260
+ "kind": "subscript_expression",
261
+ "has": {
262
+ "field": "index",
263
+ "kind": "string",
264
+ "value": {
265
+ "eq": "location"
266
+ }
267
+ }
268
+ }
269
+ ]
270
+ },
271
+ {
272
+ "has": {
273
+ "field": "object",
274
+ "kind": "identifier",
275
+ "resolves": {
276
+ "global": [
277
+ "window",
278
+ "globalThis",
279
+ "document",
280
+ "self"
281
+ ]
282
+ }
283
+ }
284
+ }
285
+ ]
286
+ }
287
+ ]
288
+ },
289
+ "relative-prefix": {
290
+ "any": [
291
+ {
292
+ "value": {
293
+ "type": "string",
294
+ "follow": true
295
+ },
296
+ "not": {
297
+ "value": {
298
+ "regex": "^(?:[A-Za-z][0-9+.A-Za-z-]*:|//)",
299
+ "follow": true
300
+ }
301
+ }
302
+ },
303
+ {
304
+ "kind": "template_string",
305
+ "has": {
306
+ "kind": "template_substitution"
307
+ },
308
+ "not": {
309
+ "regex": "^`(?:[A-Za-z][0-9+.A-Za-z-]*:|//)"
310
+ }
311
+ },
312
+ {
313
+ "kind": "binary_expression",
314
+ "has": {
315
+ "field": "operator",
316
+ "regex": "^\\+$"
317
+ },
318
+ "all": [
319
+ {
320
+ "has": {
321
+ "field": "left",
322
+ "matches": "relative-prefix"
323
+ }
324
+ }
325
+ ]
326
+ },
327
+ {
328
+ "kind": "parenthesized_expression",
329
+ "has": {
330
+ "matches": "relative-prefix"
331
+ }
332
+ },
333
+ {
334
+ "kind": "identifier",
335
+ "resolves": {
336
+ "binding": {
337
+ "value": {
338
+ "matches": "relative-prefix"
339
+ }
340
+ }
341
+ }
342
+ },
343
+ {
344
+ "kind": "identifier",
345
+ "resolves": {
346
+ "binding": {
347
+ "occurrence": {
348
+ "kind": "identifier",
349
+ "inside": {
350
+ "kind": "assignment_expression",
351
+ "field": "left",
352
+ "has": {
353
+ "field": "right",
354
+ "matches": "relative-prefix"
355
+ }
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+ ]
362
+ }
363
+ },
364
+ "rule": {
365
+ "kind": "call_expression",
366
+ "all": [
367
+ {
368
+ "has": {
369
+ "field": "function",
370
+ "all": [
371
+ {
372
+ "any": [
373
+ {
374
+ "kind": "member_expression",
375
+ "has": {
376
+ "field": "property",
377
+ "kind": "property_identifier",
378
+ "regex": "^assign$"
379
+ }
380
+ },
381
+ {
382
+ "kind": "subscript_expression",
383
+ "has": {
384
+ "field": "index",
385
+ "kind": "string",
386
+ "value": {
387
+ "eq": "assign"
388
+ }
389
+ }
390
+ }
391
+ ]
392
+ },
393
+ {
394
+ "has": {
395
+ "field": "object",
396
+ "matches": "location-root"
397
+ }
398
+ }
399
+ ]
400
+ }
401
+ },
402
+ {
403
+ "has": {
404
+ "field": "arguments",
405
+ "has": {
406
+ "nthChild": 1,
407
+ "not": {
408
+ "kind": "spread_element"
409
+ },
410
+ "matches": "relative-prefix"
411
+ }
412
+ }
413
+ }
414
+ ]
415
+ }
416
+ }
417
+ },
418
+ "violation": {
419
+ "anchor": "witness.span",
420
+ "code": "@next/next/no-location-assign-relative-destination",
421
+ "message": "Replace this location.assign call with redirect() during render or useRouter().push() in a client event handler.",
422
+ "suppress": {
423
+ "eslint": {
424
+ "rules": [
425
+ "@next/next/no-location-assign-relative-destination"
426
+ ]
427
+ }
428
+ }
429
+ }
430
+ }
431
+ ]
432
+ }