@zgeoff/oxlint-config 0.5.0 → 0.5.2
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/README.md +9 -0
- package/collect-refusing-edges.js +19 -0
- package/collect-zone-names.js +4 -0
- package/function-verb.js +56 -56
- package/{load-zone-options.js → get-zone-options.js} +3 -3
- package/import-zones-entry.d.ts +59 -0
- package/import-zones-entry.js +2 -0
- package/import-zones-schema.js +19 -19
- package/import-zones.js +121 -131
- package/is-edge-refusing.js +22 -0
- package/is-entry-applying.js +6 -0
- package/is-in-any-zone.js +3 -0
- package/load-workspace-manifests.js +6 -6
- package/max-consecutive-line-comments.js +36 -36
- package/no-abbreviated-names.js +30 -30
- package/no-comment-rule-override.js +30 -30
- package/no-jsdoc.js +15 -15
- package/package.json +14 -3
- package/plugin.js +18 -18
- package/resolve-import-target.js +131 -131
- package/resolve-repo-root.js +6 -6
- package/setup-test-only.js +10 -10
- package/test-beside-module.js +35 -33
- package/verb-contract.js +93 -93
package/verb-contract.js
CHANGED
|
@@ -108,6 +108,13 @@ const verbContract = {
|
|
|
108
108
|
|
|
109
109
|
export default verbContract;
|
|
110
110
|
|
|
111
|
+
function isNullishLiteral(node) {
|
|
112
|
+
return (
|
|
113
|
+
(node.type === 'Literal' && node.raw === 'null') ||
|
|
114
|
+
(node.type === 'Identifier' && node.name === 'undefined')
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
111
118
|
// the role table's verbs that promise no I/O
|
|
112
119
|
const pureVerbs = [
|
|
113
120
|
'is',
|
|
@@ -212,8 +219,36 @@ function findVerb(name, verbs) {
|
|
|
212
219
|
return verbs.find((verb) => isVerbMatch(name, verb)) ?? null;
|
|
213
220
|
}
|
|
214
221
|
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
const localTypesByProgram = new WeakMap();
|
|
223
|
+
|
|
224
|
+
function collectLocalTypes(program) {
|
|
225
|
+
const cached = localTypesByProgram.get(program);
|
|
226
|
+
|
|
227
|
+
if (cached !== undefined) {
|
|
228
|
+
return cached;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const localTypes = { aliases: new Map(), interfaces: new Set() };
|
|
232
|
+
|
|
233
|
+
for (const statement of program.body) {
|
|
234
|
+
const declaration =
|
|
235
|
+
statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;
|
|
236
|
+
|
|
237
|
+
if (
|
|
238
|
+
declaration?.type === 'TSTypeAliasDeclaration' &&
|
|
239
|
+
(declaration.typeParameters ?? null) === null
|
|
240
|
+
) {
|
|
241
|
+
localTypes.aliases.set(declaration.id.name, declaration.typeAnnotation);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (declaration?.type === 'TSInterfaceDeclaration') {
|
|
245
|
+
localTypes.interfaces.add(declaration.id.name);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
localTypesByProgram.set(program, localTypes);
|
|
250
|
+
|
|
251
|
+
return localTypes;
|
|
217
252
|
}
|
|
218
253
|
|
|
219
254
|
// the kind of each member of a declared type, read without type information:
|
|
@@ -301,43 +336,8 @@ function pickTypeKind(type) {
|
|
|
301
336
|
return 'open';
|
|
302
337
|
}
|
|
303
338
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
function collectLocalTypes(program) {
|
|
307
|
-
const cached = localTypesByProgram.get(program);
|
|
308
|
-
|
|
309
|
-
if (cached !== undefined) {
|
|
310
|
-
return cached;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const localTypes = { aliases: new Map(), interfaces: new Set() };
|
|
314
|
-
|
|
315
|
-
for (const statement of program.body) {
|
|
316
|
-
const declaration =
|
|
317
|
-
statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
declaration?.type === 'TSTypeAliasDeclaration' &&
|
|
321
|
-
(declaration.typeParameters ?? null) === null
|
|
322
|
-
) {
|
|
323
|
-
localTypes.aliases.set(declaration.id.name, declaration.typeAnnotation);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (declaration?.type === 'TSInterfaceDeclaration') {
|
|
327
|
-
localTypes.interfaces.add(declaration.id.name);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
localTypesByProgram.set(program, localTypes);
|
|
332
|
-
|
|
333
|
-
return localTypes;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function isNullishLiteral(node) {
|
|
337
|
-
return (
|
|
338
|
-
(node.type === 'Literal' && node.raw === 'null') ||
|
|
339
|
-
(node.type === 'Identifier' && node.name === 'undefined')
|
|
340
|
-
);
|
|
339
|
+
function isBooleanOrOpen(kinds) {
|
|
340
|
+
return kinds.every((kind) => kind === 'boolean' || kind === 'open');
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
const kyselyRunMethods = new Set(['execute', 'executeTakeFirst', 'executeTakeFirstOrThrow']);
|
|
@@ -398,6 +398,40 @@ function findCallIO(context, node, frameNode) {
|
|
|
398
398
|
return effectful === undefined ? null : `calls '${effectful.name}', whose verb may do I/O`;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
+
function findRootName(node) {
|
|
402
|
+
let current = node;
|
|
403
|
+
|
|
404
|
+
while (current.type === 'MemberExpression' || current.type === 'CallExpression') {
|
|
405
|
+
current = current.type === 'MemberExpression' ? current.object : current.callee;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (current.type === 'ThisExpression') {
|
|
409
|
+
return 'this';
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return current.type === 'Identifier' ? current.name : null;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function findMemberName(member) {
|
|
416
|
+
return !member.computed && member.property.type === 'Identifier' ? member.property.name : null;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function findBinding(context, node, name) {
|
|
420
|
+
let scope = context.sourceCode.getScope(node);
|
|
421
|
+
|
|
422
|
+
while (scope !== null) {
|
|
423
|
+
const variable = scope.set.get(name);
|
|
424
|
+
|
|
425
|
+
if (variable !== undefined && variable.defs.length > 0) {
|
|
426
|
+
return variable;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
scope = scope.upper;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
|
|
401
435
|
// the source a call reaches: its root binding and the member taken straight
|
|
402
436
|
// off the root, as `spawn` in `Bun.spawn(...)`, followed through each local
|
|
403
437
|
// alias such as `const read = fs.readFileSync` or `const { spawn } = Bun`
|
|
@@ -477,8 +511,14 @@ function findKeyName(property) {
|
|
|
477
511
|
return !property.computed && property.key.type === 'Identifier' ? property.key.name : null;
|
|
478
512
|
}
|
|
479
513
|
|
|
480
|
-
function
|
|
481
|
-
|
|
514
|
+
function findImportSource(variable) {
|
|
515
|
+
if (variable === null) {
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const [definition] = variable.defs;
|
|
520
|
+
|
|
521
|
+
return definition.type === 'ImportBinding' ? definition.parent.source.value : null;
|
|
482
522
|
}
|
|
483
523
|
|
|
484
524
|
// Bun's shell: the `$` export of `bun` under any import form or alias, or
|
|
@@ -499,58 +539,8 @@ function isShellTarget(target) {
|
|
|
499
539
|
: target.memberName === '$';
|
|
500
540
|
}
|
|
501
541
|
|
|
502
|
-
function
|
|
503
|
-
return
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function findRootName(node) {
|
|
507
|
-
let current = node;
|
|
508
|
-
|
|
509
|
-
while (current.type === 'MemberExpression' || current.type === 'CallExpression') {
|
|
510
|
-
current = current.type === 'MemberExpression' ? current.object : current.callee;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
if (current.type === 'ThisExpression') {
|
|
514
|
-
return 'this';
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
return current.type === 'Identifier' ? current.name : null;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// the global itself, so a local binding of the same name passes
|
|
521
|
-
function isGlobalName(context, node, name) {
|
|
522
|
-
return (
|
|
523
|
-
node !== undefined &&
|
|
524
|
-
node.type === 'Identifier' &&
|
|
525
|
-
node.name === name &&
|
|
526
|
-
findBinding(context, node, name) === null
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
function findBinding(context, node, name) {
|
|
531
|
-
let scope = context.sourceCode.getScope(node);
|
|
532
|
-
|
|
533
|
-
while (scope !== null) {
|
|
534
|
-
const variable = scope.set.get(name);
|
|
535
|
-
|
|
536
|
-
if (variable !== undefined && variable.defs.length > 0) {
|
|
537
|
-
return variable;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
scope = scope.upper;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
function findImportSource(variable) {
|
|
547
|
-
if (variable === null) {
|
|
548
|
-
return null;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
const [definition] = variable.defs;
|
|
552
|
-
|
|
553
|
-
return definition.type === 'ImportBinding' ? definition.parent.source.value : null;
|
|
542
|
+
function isBunGlobal(target) {
|
|
543
|
+
return target.rootName === 'Bun' && target.binding === null;
|
|
554
544
|
}
|
|
555
545
|
|
|
556
546
|
const ioModules = new Set(['fs', 'fs/promises', 'child_process']);
|
|
@@ -607,3 +597,13 @@ function isEnvRead(context, node) {
|
|
|
607
597
|
(isGlobalName(context, node.object, 'process') || isGlobalName(context, node.object, 'Bun'))
|
|
608
598
|
);
|
|
609
599
|
}
|
|
600
|
+
|
|
601
|
+
// the global itself, so a local binding of the same name passes
|
|
602
|
+
function isGlobalName(context, node, name) {
|
|
603
|
+
return (
|
|
604
|
+
node !== undefined &&
|
|
605
|
+
node.type === 'Identifier' &&
|
|
606
|
+
node.name === name &&
|
|
607
|
+
findBinding(context, node, name) === null
|
|
608
|
+
);
|
|
609
|
+
}
|