@codelaw/rules-js 0.0.0-stage → 0.2.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.
- package/LICENSE +23 -0
- package/NOTICE +10 -0
- package/README.md +57 -2
- package/codelaw-pack.toml +6 -0
- package/corpus.toml +76 -0
- package/data/globals/browser.json +1209 -0
- package/data/globals/commonjs.json +6 -0
- package/data/globals/jest.json +15 -0
- package/data/globals/mocha.json +22 -0
- package/data/globals/node.json +83 -0
- package/data/globals/serviceworker.json +328 -0
- package/data/globals/shared-node-browser.json +73 -0
- package/data/globals/vitest.json +19 -0
- package/data/globals/worker.json +349 -0
- package/package.json +14 -4
- package/presets/js/conventions.toml +6 -0
- package/presets/js/project.toml +4 -0
- package/presets/js/recommended.toml +67 -0
- package/presets/js/typescript.toml +7 -0
- package/rules/graph/no-unused-exports.md +135 -0
- package/rules/js/constructor-super.md +77 -0
- package/rules/js/exports-at-end.md +134 -0
- package/rules/js/for-direction.md +106 -0
- package/rules/js/getter-return.md +74 -0
- package/rules/js/import-groups.md +117 -0
- package/rules/js/no-async-promise-executor.md +95 -0
- package/rules/js/no-case-declarations.md +134 -0
- package/rules/js/no-class-assign.md +61 -0
- package/rules/js/no-compare-neg-zero.md +105 -0
- package/rules/js/no-cond-assign.md +135 -0
- package/rules/js/no-const-assign.md +61 -0
- package/rules/js/no-constant-binary-expression.md +83 -0
- package/rules/js/no-constant-condition.md +150 -0
- package/rules/js/no-control-regex.md +84 -0
- package/rules/js/no-debugger.md +99 -0
- package/rules/js/no-default-export.md +88 -0
- package/rules/js/no-delete-var.md +93 -0
- package/rules/js/no-dupe-args.md +61 -0
- package/rules/js/no-dupe-class-members.md +82 -0
- package/rules/js/no-dupe-else-if.md +113 -0
- package/rules/js/no-dupe-keys.md +66 -0
- package/rules/js/no-duplicate-case.md +137 -0
- package/rules/js/no-empty-character-class.md +98 -0
- package/rules/js/no-empty-pattern.md +86 -0
- package/rules/js/no-empty-static-block.md +99 -0
- package/rules/js/no-empty.md +116 -0
- package/rules/js/no-ex-assign.md +121 -0
- package/rules/js/no-extra-boolean-cast.md +107 -0
- package/rules/js/no-fallthrough.md +178 -0
- package/rules/js/no-func-assign.md +62 -0
- package/rules/js/no-global-assign.md +85 -0
- package/rules/js/no-import-assign.md +60 -0
- package/rules/js/no-invalid-regexp.md +86 -0
- package/rules/js/no-irregular-whitespace.md +87 -0
- package/rules/js/no-loss-of-precision.md +82 -0
- package/rules/js/no-misleading-character-class.md +83 -0
- package/rules/js/no-new-native-nonconstructor.md +55 -0
- package/rules/js/no-nonoctal-decimal-escape.md +84 -0
- package/rules/js/no-obj-calls.md +61 -0
- package/rules/js/no-octal.md +84 -0
- package/rules/js/no-prototype-builtins.md +99 -0
- package/rules/js/no-redeclare.md +61 -0
- package/rules/js/no-regex-spaces.md +75 -0
- package/rules/js/no-self-assign.md +91 -0
- package/rules/js/no-setter-return.md +69 -0
- package/rules/js/no-shadow-restricted-names.md +102 -0
- package/rules/js/no-sparse-arrays.md +82 -0
- package/rules/js/no-this-before-super.md +74 -0
- package/rules/js/no-unassigned-vars.md +102 -0
- package/rules/js/no-undef.md +76 -0
- package/rules/js/no-unexpected-multiline.md +91 -0
- package/rules/js/no-unreachable.md +59 -0
- package/rules/js/no-unsafe-finally.md +145 -0
- package/rules/js/no-unsafe-negation.md +71 -0
- package/rules/js/no-unsafe-optional-chaining.md +83 -0
- package/rules/js/no-unused-labels.md +102 -0
- package/rules/js/no-unused-private-class-members.md +126 -0
- package/rules/js/no-unused-vars.md +69 -0
- package/rules/js/no-useless-assignment.md +115 -0
- package/rules/js/no-useless-backreference.md +83 -0
- package/rules/js/no-useless-catch.md +105 -0
- package/rules/js/no-useless-escape.md +81 -0
- package/rules/js/no-var.md +76 -0
- package/rules/js/no-with.md +60 -0
- package/rules/js/prefer-const.md +83 -0
- package/rules/js/prefer-rest-params.md +103 -0
- package/rules/js/prefer-spread.md +95 -0
- package/rules/js/preserve-caught-error.md +122 -0
- package/rules/js/require-yield.md +107 -0
- package/rules/js/use-isnan.md +105 -0
- package/rules/js/valid-typeof.md +111 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
{
|
|
2
|
+
"AI": false,
|
|
3
|
+
"AICreateMonitor": false,
|
|
4
|
+
"AbortController": false,
|
|
5
|
+
"AbortSignal": false,
|
|
6
|
+
"AudioData": false,
|
|
7
|
+
"AudioDecoder": false,
|
|
8
|
+
"AudioEncoder": false,
|
|
9
|
+
"BackgroundFetchManager": false,
|
|
10
|
+
"BackgroundFetchRecord": false,
|
|
11
|
+
"BackgroundFetchRegistration": false,
|
|
12
|
+
"BarcodeDetector": false,
|
|
13
|
+
"Blob": false,
|
|
14
|
+
"BroadcastChannel": false,
|
|
15
|
+
"ByteLengthQueuingStrategy": false,
|
|
16
|
+
"CSSImageValue": false,
|
|
17
|
+
"CSSKeywordValue": false,
|
|
18
|
+
"CSSMathClamp": false,
|
|
19
|
+
"CSSMathInvert": false,
|
|
20
|
+
"CSSMathMax": false,
|
|
21
|
+
"CSSMathMin": false,
|
|
22
|
+
"CSSMathNegate": false,
|
|
23
|
+
"CSSMathProduct": false,
|
|
24
|
+
"CSSMathSum": false,
|
|
25
|
+
"CSSMathValue": false,
|
|
26
|
+
"CSSMatrixComponent": false,
|
|
27
|
+
"CSSNumericArray": false,
|
|
28
|
+
"CSSNumericValue": false,
|
|
29
|
+
"CSSPerspective": false,
|
|
30
|
+
"CSSRotate": false,
|
|
31
|
+
"CSSScale": false,
|
|
32
|
+
"CSSSkew": false,
|
|
33
|
+
"CSSSkewX": false,
|
|
34
|
+
"CSSSkewY": false,
|
|
35
|
+
"CSSStyleValue": false,
|
|
36
|
+
"CSSTransformComponent": false,
|
|
37
|
+
"CSSTransformValue": false,
|
|
38
|
+
"CSSTranslate": false,
|
|
39
|
+
"CSSUnitValue": false,
|
|
40
|
+
"CSSUnparsedValue": false,
|
|
41
|
+
"CSSVariableReferenceValue": false,
|
|
42
|
+
"Cache": false,
|
|
43
|
+
"CacheStorage": false,
|
|
44
|
+
"CanvasGradient": false,
|
|
45
|
+
"CanvasPattern": false,
|
|
46
|
+
"CloseEvent": false,
|
|
47
|
+
"CompressionStream": false,
|
|
48
|
+
"CountQueuingStrategy": false,
|
|
49
|
+
"CreateMonitor": false,
|
|
50
|
+
"CropTarget": false,
|
|
51
|
+
"Crypto": false,
|
|
52
|
+
"CryptoKey": false,
|
|
53
|
+
"CustomEvent": false,
|
|
54
|
+
"DOMException": false,
|
|
55
|
+
"DOMMatrix": false,
|
|
56
|
+
"DOMMatrixReadOnly": false,
|
|
57
|
+
"DOMPoint": false,
|
|
58
|
+
"DOMPointReadOnly": false,
|
|
59
|
+
"DOMQuad": false,
|
|
60
|
+
"DOMRect": false,
|
|
61
|
+
"DOMRectReadOnly": false,
|
|
62
|
+
"DOMStringList": false,
|
|
63
|
+
"DecompressionStream": false,
|
|
64
|
+
"DedicatedWorkerGlobalScope": false,
|
|
65
|
+
"EncodedAudioChunk": false,
|
|
66
|
+
"EncodedVideoChunk": false,
|
|
67
|
+
"ErrorEvent": false,
|
|
68
|
+
"Event": false,
|
|
69
|
+
"EventSource": false,
|
|
70
|
+
"EventTarget": false,
|
|
71
|
+
"File": false,
|
|
72
|
+
"FileList": false,
|
|
73
|
+
"FileReader": false,
|
|
74
|
+
"FileReaderSync": false,
|
|
75
|
+
"FileSystemDirectoryHandle": false,
|
|
76
|
+
"FileSystemFileHandle": false,
|
|
77
|
+
"FileSystemHandle": false,
|
|
78
|
+
"FileSystemObserver": false,
|
|
79
|
+
"FileSystemSyncAccessHandle": false,
|
|
80
|
+
"FileSystemWritableFileStream": false,
|
|
81
|
+
"FontFace": false,
|
|
82
|
+
"FontFaceSet": false,
|
|
83
|
+
"FontFaceSetLoadEvent": false,
|
|
84
|
+
"FormData": false,
|
|
85
|
+
"GPU": false,
|
|
86
|
+
"GPUAdapter": false,
|
|
87
|
+
"GPUAdapterInfo": false,
|
|
88
|
+
"GPUBindGroup": false,
|
|
89
|
+
"GPUBindGroupLayout": false,
|
|
90
|
+
"GPUBuffer": false,
|
|
91
|
+
"GPUBufferUsage": false,
|
|
92
|
+
"GPUCanvasContext": false,
|
|
93
|
+
"GPUColorWrite": false,
|
|
94
|
+
"GPUCommandBuffer": false,
|
|
95
|
+
"GPUCommandEncoder": false,
|
|
96
|
+
"GPUCompilationInfo": false,
|
|
97
|
+
"GPUCompilationMessage": false,
|
|
98
|
+
"GPUComputePassEncoder": false,
|
|
99
|
+
"GPUComputePipeline": false,
|
|
100
|
+
"GPUDevice": false,
|
|
101
|
+
"GPUDeviceLostInfo": false,
|
|
102
|
+
"GPUError": false,
|
|
103
|
+
"GPUExternalTexture": false,
|
|
104
|
+
"GPUInternalError": false,
|
|
105
|
+
"GPUMapMode": false,
|
|
106
|
+
"GPUOutOfMemoryError": false,
|
|
107
|
+
"GPUPipelineError": false,
|
|
108
|
+
"GPUPipelineLayout": false,
|
|
109
|
+
"GPUQuerySet": false,
|
|
110
|
+
"GPUQueue": false,
|
|
111
|
+
"GPURenderBundle": false,
|
|
112
|
+
"GPURenderBundleEncoder": false,
|
|
113
|
+
"GPURenderPassEncoder": false,
|
|
114
|
+
"GPURenderPipeline": false,
|
|
115
|
+
"GPUSampler": false,
|
|
116
|
+
"GPUShaderModule": false,
|
|
117
|
+
"GPUShaderStage": false,
|
|
118
|
+
"GPUSupportedFeatures": false,
|
|
119
|
+
"GPUSupportedLimits": false,
|
|
120
|
+
"GPUTexture": false,
|
|
121
|
+
"GPUTextureUsage": false,
|
|
122
|
+
"GPUTextureView": false,
|
|
123
|
+
"GPUUncapturedErrorEvent": false,
|
|
124
|
+
"GPUValidationError": false,
|
|
125
|
+
"HID": false,
|
|
126
|
+
"HIDConnectionEvent": false,
|
|
127
|
+
"HIDDevice": false,
|
|
128
|
+
"HIDInputReportEvent": false,
|
|
129
|
+
"Headers": false,
|
|
130
|
+
"IDBCursor": false,
|
|
131
|
+
"IDBCursorWithValue": false,
|
|
132
|
+
"IDBDatabase": false,
|
|
133
|
+
"IDBFactory": false,
|
|
134
|
+
"IDBIndex": false,
|
|
135
|
+
"IDBKeyRange": false,
|
|
136
|
+
"IDBObjectStore": false,
|
|
137
|
+
"IDBOpenDBRequest": false,
|
|
138
|
+
"IDBRecord": false,
|
|
139
|
+
"IDBRequest": false,
|
|
140
|
+
"IDBTransaction": false,
|
|
141
|
+
"IDBVersionChangeEvent": false,
|
|
142
|
+
"IdleDetector": false,
|
|
143
|
+
"ImageBitmap": false,
|
|
144
|
+
"ImageBitmapRenderingContext": false,
|
|
145
|
+
"ImageData": false,
|
|
146
|
+
"ImageDecoder": false,
|
|
147
|
+
"ImageTrack": false,
|
|
148
|
+
"ImageTrackList": false,
|
|
149
|
+
"LanguageDetector": false,
|
|
150
|
+
"Lock": false,
|
|
151
|
+
"LockManager": false,
|
|
152
|
+
"MediaCapabilities": false,
|
|
153
|
+
"MediaSource": false,
|
|
154
|
+
"MediaSourceHandle": false,
|
|
155
|
+
"MessageChannel": false,
|
|
156
|
+
"MessageEvent": false,
|
|
157
|
+
"MessagePort": false,
|
|
158
|
+
"NavigationPreloadManager": false,
|
|
159
|
+
"NavigatorUAData": false,
|
|
160
|
+
"NetworkInformation": false,
|
|
161
|
+
"Notification": false,
|
|
162
|
+
"Observable": false,
|
|
163
|
+
"OffscreenCanvas": false,
|
|
164
|
+
"OffscreenCanvasRenderingContext2D": false,
|
|
165
|
+
"Origin": false,
|
|
166
|
+
"PERSISTENT": false,
|
|
167
|
+
"Path2D": false,
|
|
168
|
+
"Performance": false,
|
|
169
|
+
"PerformanceEntry": false,
|
|
170
|
+
"PerformanceMark": false,
|
|
171
|
+
"PerformanceMeasure": false,
|
|
172
|
+
"PerformanceObserver": false,
|
|
173
|
+
"PerformanceObserverEntryList": false,
|
|
174
|
+
"PerformanceResourceTiming": false,
|
|
175
|
+
"PerformanceServerTiming": false,
|
|
176
|
+
"PeriodicSyncManager": false,
|
|
177
|
+
"PermissionStatus": false,
|
|
178
|
+
"Permissions": false,
|
|
179
|
+
"PressureObserver": false,
|
|
180
|
+
"PressureRecord": false,
|
|
181
|
+
"ProgressEvent": false,
|
|
182
|
+
"PromiseRejectionEvent": false,
|
|
183
|
+
"PushManager": false,
|
|
184
|
+
"PushSubscription": false,
|
|
185
|
+
"PushSubscriptionOptions": false,
|
|
186
|
+
"QuotaExceededError": false,
|
|
187
|
+
"RTCDataChannel": false,
|
|
188
|
+
"RTCEncodedAudioFrame": false,
|
|
189
|
+
"RTCEncodedVideoFrame": false,
|
|
190
|
+
"RTCError": false,
|
|
191
|
+
"RTCErrorEvent": false,
|
|
192
|
+
"RTCRtpScriptTransformer": false,
|
|
193
|
+
"RTCTransformEvent": false,
|
|
194
|
+
"ReadableByteStreamController": false,
|
|
195
|
+
"ReadableStream": false,
|
|
196
|
+
"ReadableStreamBYOBReader": false,
|
|
197
|
+
"ReadableStreamBYOBRequest": false,
|
|
198
|
+
"ReadableStreamDefaultController": false,
|
|
199
|
+
"ReadableStreamDefaultReader": false,
|
|
200
|
+
"ReportBody": false,
|
|
201
|
+
"ReportingObserver": false,
|
|
202
|
+
"Request": false,
|
|
203
|
+
"Response": false,
|
|
204
|
+
"RestrictionTarget": false,
|
|
205
|
+
"Scheduler": false,
|
|
206
|
+
"SecurityPolicyViolationEvent": false,
|
|
207
|
+
"Serial": false,
|
|
208
|
+
"SerialPort": false,
|
|
209
|
+
"ServiceWorker": false,
|
|
210
|
+
"ServiceWorkerContainer": false,
|
|
211
|
+
"ServiceWorkerRegistration": false,
|
|
212
|
+
"SourceBuffer": false,
|
|
213
|
+
"SourceBufferList": false,
|
|
214
|
+
"StorageBucket": false,
|
|
215
|
+
"StorageBucketManager": false,
|
|
216
|
+
"StorageManager": false,
|
|
217
|
+
"StylePropertyMapReadOnly": false,
|
|
218
|
+
"Subscriber": false,
|
|
219
|
+
"SubtleCrypto": false,
|
|
220
|
+
"SyncManager": false,
|
|
221
|
+
"TEMPORARY": false,
|
|
222
|
+
"TaskController": false,
|
|
223
|
+
"TaskPriorityChangeEvent": false,
|
|
224
|
+
"TaskSignal": false,
|
|
225
|
+
"Temporal": false,
|
|
226
|
+
"TextDecoder": false,
|
|
227
|
+
"TextDecoderStream": false,
|
|
228
|
+
"TextEncoder": false,
|
|
229
|
+
"TextEncoderStream": false,
|
|
230
|
+
"TextMetrics": false,
|
|
231
|
+
"TransformStream": false,
|
|
232
|
+
"TransformStreamDefaultController": false,
|
|
233
|
+
"TrustedHTML": false,
|
|
234
|
+
"TrustedScript": false,
|
|
235
|
+
"TrustedScriptURL": false,
|
|
236
|
+
"TrustedTypePolicy": false,
|
|
237
|
+
"TrustedTypePolicyFactory": false,
|
|
238
|
+
"URL": false,
|
|
239
|
+
"URLPattern": false,
|
|
240
|
+
"URLSearchParams": false,
|
|
241
|
+
"USB": false,
|
|
242
|
+
"USBAlternateInterface": false,
|
|
243
|
+
"USBConfiguration": false,
|
|
244
|
+
"USBConnectionEvent": false,
|
|
245
|
+
"USBDevice": false,
|
|
246
|
+
"USBEndpoint": false,
|
|
247
|
+
"USBInTransferResult": false,
|
|
248
|
+
"USBInterface": false,
|
|
249
|
+
"USBIsochronousInTransferPacket": false,
|
|
250
|
+
"USBIsochronousInTransferResult": false,
|
|
251
|
+
"USBIsochronousOutTransferPacket": false,
|
|
252
|
+
"USBIsochronousOutTransferResult": false,
|
|
253
|
+
"USBOutTransferResult": false,
|
|
254
|
+
"UserActivation": false,
|
|
255
|
+
"VideoColorSpace": false,
|
|
256
|
+
"VideoDecoder": false,
|
|
257
|
+
"VideoEncoder": false,
|
|
258
|
+
"VideoFrame": false,
|
|
259
|
+
"WGSLLanguageFeatures": false,
|
|
260
|
+
"WebAssembly": false,
|
|
261
|
+
"WebGL2RenderingContext": false,
|
|
262
|
+
"WebGLActiveInfo": false,
|
|
263
|
+
"WebGLBuffer": false,
|
|
264
|
+
"WebGLContextEvent": false,
|
|
265
|
+
"WebGLFramebuffer": false,
|
|
266
|
+
"WebGLObject": false,
|
|
267
|
+
"WebGLProgram": false,
|
|
268
|
+
"WebGLQuery": false,
|
|
269
|
+
"WebGLRenderbuffer": false,
|
|
270
|
+
"WebGLRenderingContext": false,
|
|
271
|
+
"WebGLSampler": false,
|
|
272
|
+
"WebGLShader": false,
|
|
273
|
+
"WebGLShaderPrecisionFormat": false,
|
|
274
|
+
"WebGLSync": false,
|
|
275
|
+
"WebGLTexture": false,
|
|
276
|
+
"WebGLTransformFeedback": false,
|
|
277
|
+
"WebGLUniformLocation": false,
|
|
278
|
+
"WebGLVertexArrayObject": false,
|
|
279
|
+
"WebSocket": false,
|
|
280
|
+
"WebSocketError": false,
|
|
281
|
+
"WebSocketStream": false,
|
|
282
|
+
"WebTransport": false,
|
|
283
|
+
"WebTransportBidirectionalStream": false,
|
|
284
|
+
"WebTransportDatagramDuplexStream": false,
|
|
285
|
+
"WebTransportDatagramsWritable": false,
|
|
286
|
+
"WebTransportError": false,
|
|
287
|
+
"WebTransportReceiveStream": false,
|
|
288
|
+
"WebTransportSendGroup": false,
|
|
289
|
+
"WebTransportSendStream": false,
|
|
290
|
+
"Worker": false,
|
|
291
|
+
"WorkerGlobalScope": false,
|
|
292
|
+
"WorkerLocation": false,
|
|
293
|
+
"WorkerNavigator": false,
|
|
294
|
+
"WritableStream": false,
|
|
295
|
+
"WritableStreamDefaultController": false,
|
|
296
|
+
"WritableStreamDefaultWriter": false,
|
|
297
|
+
"XMLHttpRequest": false,
|
|
298
|
+
"XMLHttpRequestEventTarget": false,
|
|
299
|
+
"XMLHttpRequestUpload": false,
|
|
300
|
+
"addEventListener": false,
|
|
301
|
+
"ai": false,
|
|
302
|
+
"atob": false,
|
|
303
|
+
"btoa": false,
|
|
304
|
+
"caches": false,
|
|
305
|
+
"cancelAnimationFrame": false,
|
|
306
|
+
"clearInterval": false,
|
|
307
|
+
"clearTimeout": false,
|
|
308
|
+
"close": false,
|
|
309
|
+
"console": false,
|
|
310
|
+
"createImageBitmap": false,
|
|
311
|
+
"crossOriginIsolated": false,
|
|
312
|
+
"crypto": false,
|
|
313
|
+
"dispatchEvent": false,
|
|
314
|
+
"fetch": false,
|
|
315
|
+
"fonts": false,
|
|
316
|
+
"importScripts": false,
|
|
317
|
+
"indexedDB": false,
|
|
318
|
+
"isSecureContext": false,
|
|
319
|
+
"location": false,
|
|
320
|
+
"name": false,
|
|
321
|
+
"navigator": false,
|
|
322
|
+
"onerror": true,
|
|
323
|
+
"onlanguagechange": true,
|
|
324
|
+
"onmessage": true,
|
|
325
|
+
"onmessageerror": true,
|
|
326
|
+
"onoffline": true,
|
|
327
|
+
"ononline": true,
|
|
328
|
+
"onrejectionhandled": true,
|
|
329
|
+
"onrtctransform": true,
|
|
330
|
+
"onunhandledrejection": true,
|
|
331
|
+
"origin": false,
|
|
332
|
+
"performance": false,
|
|
333
|
+
"postMessage": false,
|
|
334
|
+
"queueMicrotask": false,
|
|
335
|
+
"removeEventListener": false,
|
|
336
|
+
"reportError": false,
|
|
337
|
+
"requestAnimationFrame": false,
|
|
338
|
+
"scheduler": false,
|
|
339
|
+
"self": false,
|
|
340
|
+
"setInterval": false,
|
|
341
|
+
"setTimeout": false,
|
|
342
|
+
"structuredClone": false,
|
|
343
|
+
"trustedTypes": false,
|
|
344
|
+
"webkitRequestFileSystem": false,
|
|
345
|
+
"webkitRequestFileSystemSync": false,
|
|
346
|
+
"webkitResolveLocalFileSystemSyncURL": false,
|
|
347
|
+
"webkitResolveLocalFileSystemURL": false,
|
|
348
|
+
"when": false
|
|
349
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelaw/rules-js",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "codelaw's rules for JavaScript, and the core JavaScript rules on TypeScript, JSX and TSX (SR-RULE-PACKS)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/arpitarya/codelaw.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/arpitarya/codelaw",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"codelaw",
|
|
13
|
+
"codelaw-pack",
|
|
14
|
+
"lint-rules"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
description = "The correctness core of ESLint's recommended preset (@eslint/js 10.0.1), reimplemented"
|
|
2
|
+
|
|
3
|
+
[rules]
|
|
4
|
+
"js/constructor-super" = "error"
|
|
5
|
+
"js/for-direction" = "error"
|
|
6
|
+
"js/getter-return" = "error"
|
|
7
|
+
"js/no-async-promise-executor" = "error"
|
|
8
|
+
"js/no-case-declarations" = "error"
|
|
9
|
+
"js/no-class-assign" = "error"
|
|
10
|
+
"js/no-compare-neg-zero" = "error"
|
|
11
|
+
"js/no-cond-assign" = "error"
|
|
12
|
+
"js/no-const-assign" = "error"
|
|
13
|
+
"js/no-constant-binary-expression" = "error"
|
|
14
|
+
"js/no-constant-condition" = "error"
|
|
15
|
+
"js/no-control-regex" = "error"
|
|
16
|
+
"js/no-debugger" = "error"
|
|
17
|
+
"js/no-delete-var" = "error"
|
|
18
|
+
"js/no-dupe-args" = "error"
|
|
19
|
+
"js/no-dupe-class-members" = "error"
|
|
20
|
+
"js/no-dupe-else-if" = "error"
|
|
21
|
+
"js/no-dupe-keys" = "error"
|
|
22
|
+
"js/no-duplicate-case" = "error"
|
|
23
|
+
"js/no-empty" = "error"
|
|
24
|
+
"js/no-empty-character-class" = "error"
|
|
25
|
+
"js/no-empty-pattern" = "error"
|
|
26
|
+
"js/no-empty-static-block" = "error"
|
|
27
|
+
"js/no-ex-assign" = "error"
|
|
28
|
+
"js/no-extra-boolean-cast" = "error"
|
|
29
|
+
"js/no-fallthrough" = "error"
|
|
30
|
+
"js/no-func-assign" = "error"
|
|
31
|
+
"js/no-global-assign" = "error"
|
|
32
|
+
"js/no-import-assign" = "error"
|
|
33
|
+
"js/no-invalid-regexp" = "error"
|
|
34
|
+
"js/no-irregular-whitespace" = "error"
|
|
35
|
+
"js/no-loss-of-precision" = "error"
|
|
36
|
+
"js/no-misleading-character-class" = "error"
|
|
37
|
+
"js/no-new-native-nonconstructor" = "error"
|
|
38
|
+
"js/no-nonoctal-decimal-escape" = "error"
|
|
39
|
+
"js/no-obj-calls" = "error"
|
|
40
|
+
"js/no-octal" = "error"
|
|
41
|
+
"js/no-prototype-builtins" = "error"
|
|
42
|
+
"js/no-redeclare" = "error"
|
|
43
|
+
"js/no-regex-spaces" = "error"
|
|
44
|
+
"js/no-self-assign" = "error"
|
|
45
|
+
"js/no-setter-return" = "error"
|
|
46
|
+
"js/no-shadow-restricted-names" = "error"
|
|
47
|
+
"js/no-sparse-arrays" = "error"
|
|
48
|
+
"js/no-this-before-super" = "error"
|
|
49
|
+
"js/no-unassigned-vars" = "error"
|
|
50
|
+
"js/no-undef" = "error"
|
|
51
|
+
"js/no-unexpected-multiline" = "error"
|
|
52
|
+
"js/no-unreachable" = "error"
|
|
53
|
+
"js/no-unsafe-finally" = "error"
|
|
54
|
+
"js/no-unsafe-negation" = "error"
|
|
55
|
+
"js/no-unsafe-optional-chaining" = "error"
|
|
56
|
+
"js/no-unused-labels" = "error"
|
|
57
|
+
"js/no-unused-private-class-members" = "error"
|
|
58
|
+
"js/no-unused-vars" = "error"
|
|
59
|
+
"js/no-useless-assignment" = "error"
|
|
60
|
+
"js/no-useless-backreference" = "error"
|
|
61
|
+
"js/no-useless-catch" = "error"
|
|
62
|
+
"js/no-useless-escape" = "error"
|
|
63
|
+
"js/no-with" = "error"
|
|
64
|
+
"js/preserve-caught-error" = "error"
|
|
65
|
+
"js/require-yield" = "error"
|
|
66
|
+
"js/use-isnan" = "error"
|
|
67
|
+
"js/valid-typeof" = "error"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
description = "The four core rules typescript-eslint's eslint-recommended switches on for TypeScript (8.71.2); use with codelaw:ts/recommended"
|
|
2
|
+
|
|
3
|
+
[rules]
|
|
4
|
+
"js/no-var" = "error"
|
|
5
|
+
"js/prefer-const" = "error"
|
|
6
|
+
"js/prefer-rest-params" = "error"
|
|
7
|
+
"js/prefer-spread" = "error"
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: graph/no-unused-exports
|
|
3
|
+
title: Exported symbols must be used somewhere
|
|
4
|
+
languages: [javascript, jsx, typescript, tsx]
|
|
5
|
+
scope: project
|
|
6
|
+
severity: error
|
|
7
|
+
fix: suggest
|
|
8
|
+
fix_reason: "Static analysis can't rule out reflective or external use, so removal needs a human or agent to accept the diff."
|
|
9
|
+
stability: preview
|
|
10
|
+
ported_from: [knip/exports, knip/types]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Every exported symbol is imported by another module, is reachable from an entry point, or is marked `@public` / `@keep`.
|
|
15
|
+
|
|
16
|
+
**Why:** an export nothing imports is dead code that still looks like API: readers keep it, refactors carry it, and it hides what a module is really for.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
graph:
|
|
20
|
+
symbol:
|
|
21
|
+
exported: true
|
|
22
|
+
kind: [function, class, variable, type, interface, enum]
|
|
23
|
+
unless:
|
|
24
|
+
- reachable_from: entry
|
|
25
|
+
- tagged: [public, keep]
|
|
26
|
+
when:
|
|
27
|
+
external_references: 0
|
|
28
|
+
certainty_from: module.dynamic
|
|
29
|
+
message: "`$SYMBOL` is exported but never used outside `$FILE`"
|
|
30
|
+
fix:
|
|
31
|
+
- when: { local_references: ">0" }
|
|
32
|
+
do: [strip-export-keyword]
|
|
33
|
+
- else:
|
|
34
|
+
do: [remove-declaration]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## How to fix
|
|
38
|
+
|
|
39
|
+
1. Run `codelaw graph why-unused <symbol>` (`<file>#<export>` or `<module>:<name>`) to see each entry, keep and import clause.
|
|
40
|
+
2. If something outside the repo uses it, add the file to `[graph] entry` or `[graph] keep`, add its decorator to `[graph] registrars`, or tag it `/** @public */` / `# codelaw: keep`.
|
|
41
|
+
3. Otherwise delete the declaration (and its `__all__` or `export { … }` entry), or drop `export` if its own file still uses it.
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
### JavaScript
|
|
46
|
+
|
|
47
|
+
#### Don't
|
|
48
|
+
|
|
49
|
+
```js files
|
|
50
|
+
// src/date.js
|
|
51
|
+
export function formatDate(d) { return d.toISOString(); }
|
|
52
|
+
export function parseDate(s) { return new Date(s); }
|
|
53
|
+
// src/app.js
|
|
54
|
+
import { formatDate } from "./date";
|
|
55
|
+
console.log(formatDate(new Date()));
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Do
|
|
59
|
+
|
|
60
|
+
```js files
|
|
61
|
+
// src/date.js
|
|
62
|
+
export function formatDate(d) { return d.toISOString(); }
|
|
63
|
+
// src/app.js
|
|
64
|
+
import { formatDate } from "./date";
|
|
65
|
+
console.log(formatDate(new Date()));
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### JSX
|
|
69
|
+
|
|
70
|
+
#### Don't
|
|
71
|
+
|
|
72
|
+
```jsx files
|
|
73
|
+
// src/Button.jsx
|
|
74
|
+
export function Button() { return <button />; }
|
|
75
|
+
export function Unused() { return <span />; }
|
|
76
|
+
// src/App.jsx
|
|
77
|
+
import { Button } from "./Button";
|
|
78
|
+
console.log(<Button />);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Do
|
|
82
|
+
|
|
83
|
+
```jsx files
|
|
84
|
+
// src/Button.jsx
|
|
85
|
+
export function Button() { return <button />; }
|
|
86
|
+
// src/App.jsx
|
|
87
|
+
import { Button } from "./Button";
|
|
88
|
+
console.log(<Button />);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### TypeScript
|
|
92
|
+
|
|
93
|
+
#### Don't
|
|
94
|
+
|
|
95
|
+
```ts files
|
|
96
|
+
// packages/utils/src/date.ts
|
|
97
|
+
export function formatDate(d: Date) { return d.toISOString(); }
|
|
98
|
+
export function parseDate(s: string) { return new Date(s); }
|
|
99
|
+
// packages/web/src/app.ts
|
|
100
|
+
import { formatDate } from "../../utils/src/date";
|
|
101
|
+
console.log(formatDate(new Date()));
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Do
|
|
105
|
+
|
|
106
|
+
```ts files
|
|
107
|
+
// packages/utils/src/date.ts
|
|
108
|
+
export function formatDate(d: Date) { return d.toISOString(); }
|
|
109
|
+
// packages/web/src/app.ts
|
|
110
|
+
import { formatDate } from "../../utils/src/date";
|
|
111
|
+
console.log(formatDate(new Date()));
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### TSX
|
|
115
|
+
|
|
116
|
+
#### Don't
|
|
117
|
+
|
|
118
|
+
```tsx files
|
|
119
|
+
// src/theme.tsx
|
|
120
|
+
export const theme = { dark: false };
|
|
121
|
+
export const unusedTheme = { dark: true };
|
|
122
|
+
// src/main.tsx
|
|
123
|
+
import { theme } from "./theme";
|
|
124
|
+
console.log(theme);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Do
|
|
128
|
+
|
|
129
|
+
```tsx files
|
|
130
|
+
// src/theme.tsx
|
|
131
|
+
export const theme = { dark: false };
|
|
132
|
+
// src/main.tsx
|
|
133
|
+
import { theme } from "./theme";
|
|
134
|
+
console.log(theme);
|
|
135
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: js/constructor-super
|
|
3
|
+
title: "A derived class's constructor calls super(); a base class's does not"
|
|
4
|
+
languages: [javascript, jsx]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "what `super()` must receive depends on the base class"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [eslint/constructor-super]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
A class that extends another must call `super()` in its constructor before it returns, and a class
|
|
13
|
+
that extends nothing must not call `super()` at all.
|
|
14
|
+
|
|
15
|
+
**Why:** Without `super()` the instance is never initialised and the constructor throws; in a base
|
|
16
|
+
class `super()` is a syntax error.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: js/constructor-super
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. In a class with `extends`, call `super(...)` with the arguments the base class expects, before any use of `this`.
|
|
25
|
+
2. In a class without `extends`, remove the `super()` call.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### JavaScript
|
|
30
|
+
|
|
31
|
+
#### Don't
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
class Cat extends Animal {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.lives = 9;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Do
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
class Cat extends Animal {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this.lives = 9;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### JSX
|
|
53
|
+
|
|
54
|
+
#### Don't
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
class Cat extends Animal {
|
|
58
|
+
constructor() {
|
|
59
|
+
this.lives = 9;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Do
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
class Cat extends Animal {
|
|
68
|
+
constructor() {
|
|
69
|
+
super();
|
|
70
|
+
this.lives = 9;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Differences from the source
|
|
76
|
+
|
|
77
|
+
Paths are followed in straight-line order: a `super()` on any branch counts as called.
|