@sarj/eslint-plugin 2.12.1 → 2.13.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/README.md +14 -1
- package/dist/index.cjs +1126 -463
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +1070 -407
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,8 @@ var import_utils = require("@typescript-eslint/utils");
|
|
|
41
41
|
// src/rules/_paths.ts
|
|
42
42
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
43
43
|
var STORY_FILE_RE = /\.stories\.[cm]?[jt]sx?$/i;
|
|
44
|
-
var GENERATED_FILE_RE = /([\\/]generated[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)/;
|
|
44
|
+
var GENERATED_FILE_RE = /([\\/](?:generated|openapi-gen|graphql[\\/]types)[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)|(\.types\.[cm]?ts$)/;
|
|
45
|
+
var GENERATED_MARKER_RE = /(?:@generated\b|generated (?:with|by)|generated (?:graphql )?types|do not edit(?: directly| manually)?)/i;
|
|
45
46
|
function isTestFile(filename) {
|
|
46
47
|
const normalized = filename.replaceAll("\\", "/");
|
|
47
48
|
const base = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
@@ -54,7 +55,7 @@ function isStoryFile(filename) {
|
|
|
54
55
|
return STORY_FILE_RE.test(filename);
|
|
55
56
|
}
|
|
56
57
|
function isGeneratedFile(filename, sourceText = "") {
|
|
57
|
-
return GENERATED_FILE_RE.test(filename.replaceAll("\\", "/")) ||
|
|
58
|
+
return GENERATED_FILE_RE.test(filename.replaceAll("\\", "/")) || GENERATED_MARKER_RE.test(sourceText.slice(0, 2048));
|
|
58
59
|
}
|
|
59
60
|
function isScriptFile(filename) {
|
|
60
61
|
return SCRIPT_FILE_RE.test(filename);
|
|
@@ -97,7 +98,7 @@ var enforce_file_structure_default = import_utils.ESLintUtils.RuleCreator(
|
|
|
97
98
|
},
|
|
98
99
|
defaultOptions: [],
|
|
99
100
|
create(context) {
|
|
100
|
-
if (isTestFile(context.filename)) {
|
|
101
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
101
102
|
return {};
|
|
102
103
|
}
|
|
103
104
|
return {
|
|
@@ -275,56 +276,90 @@ var no_client_side_data_fetching_default = import_utils2.ESLintUtils.RuleCreator
|
|
|
275
276
|
});
|
|
276
277
|
|
|
277
278
|
// src/rules/no-comment-cruft.ts
|
|
279
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
280
|
+
|
|
281
|
+
// src/rules/_comments.ts
|
|
278
282
|
var import_utils3 = require("@typescript-eslint/utils");
|
|
279
|
-
var
|
|
280
|
-
var
|
|
281
|
-
var
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
var
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
283
|
+
var REF_RE = /https?:\/\/|\bRFC[- ]?\d+|\bPEP[- ]?\d+|\bCVE-\d{4}|\b(?!UTF-|SHA-|ISO-|AES-|CRC-|MD-|PCM-|EOF-|API-|BASE-)[A-Z][A-Z0-9]{1,9}-\d[A-Z0-9]{0,5}\b|(?<![&\w])#\d{2,6}\b|@[a-z][\w.-]*\.(?:us|com|ai|io|net|org|dev)\b/;
|
|
284
|
+
var VERSION_RE = /(?:>=|<=|==|<|>)\s*v?\d+\.\d+|\bv\d+\.\d+|\b(?:since|until|as of)\s+(?:v?\d+\.\d+|Python\s*\d)/i;
|
|
285
|
+
var UNITS_RE = /[~<>]?\d+(?:\.\d+)?\s?(?:ms|s\b|sec\b|seconds?\b|min\b|minutes?\b|hours?\b|days?\b|KB|MB|MiB|GiB|kHz|Hz|bytes?\b|bit\b|-bit\b|%|px\b|rps\b|qps\b)|\b[1-5]xx\b|\b(?:301|302|304|307|308|400|401|403|404|405|409|410|412|422|425|429|500|501|502|503|504)\b/;
|
|
286
|
+
var CAUSAL_RE = /\b(?:because|otherwise|so that|or else|would (?:break|fail|race|deadlock|leak|clobber|loop|crash|page|stall)|breaks?\b|so we don'?t|to avoid\b|caused\b|causes\b|gets? clobbered|keeps? (?:us|it|them) from|doesn'?t\b.{0,24}\b(?:page|fire|break|leak|loop)|eat into|would otherwise|trade-?offs?\b)\b/i;
|
|
287
|
+
var NEGATION_RE = /\b(?:must not|must never|do(?:es)? not\b|don'?t\b.{0,30}\b(?:leak|log|cache|retry|block|steal|wipe)|never\b|deliberately|intentionally|counterintuitiv|NOT\b)|(?<!based )\bon purpose\b|\(not\s|\binstead of\b|\brather than\b/;
|
|
288
|
+
var UPSTREAM_RE = /\b(?:upstream|workaround|quirk|backport|vendored|regression|fixed upstream|requires?\b|convention\b|rate.?limit|deprecat|opts? in(?:to)?\b|raises?\b.{0,60}\b(?:when|if|unless)\b)/i;
|
|
289
|
+
var INVARIANT_RE = /\b(?:invariant|idempotent|race\b|deadlock|re-?entran|atomic|thread-?safe|signal-?safe|lexicographic(?:al(?:ly)?)?|monotonic|must (?:run|be|happen|come|stay|hit|converge|configure)|before any\b|lost the (?:claim )?race)\b/i;
|
|
290
|
+
var SECURITY_RE = /\b(?:timing attack|constant-?time|replay|PII\b|redact|secret|injection|spoof|fail-?closed|fail-?open|auth bypass|early-?exit timing)\b/i;
|
|
291
|
+
var VENDOR_RE = /\b(?:GitHub|Slack|Twilio|LiveKit|Kamailio|Groq|OpenAI|Anthropic|Cloudflare|FastAPI|Starlette|Sentry|Zoho|Salla|Ashby|Linear|BigQuery|Postgres|Neon|Drizzle|Vertex|Gemini|Firestore|Stripe|Next\.js|React Compiler|pydantic|ruff|loguru|Lexical|Farasa|Orpheus|Whisper|schemathesis)(?:'s\b|\s+(?:requires?|returns?|expects?|allows?|rejects?|accepts?|sends?|caps?|limits?|wraps?|silently|outputs?|stores?|treats?|doesn'?t|does not|won'?t|can'?t|only|models)\b)/;
|
|
292
|
+
var PROTECTED_SIGNALS = [
|
|
293
|
+
REF_RE,
|
|
294
|
+
VERSION_RE,
|
|
295
|
+
UNITS_RE,
|
|
296
|
+
CAUSAL_RE,
|
|
297
|
+
NEGATION_RE,
|
|
298
|
+
UPSTREAM_RE,
|
|
299
|
+
INVARIANT_RE,
|
|
300
|
+
SECURITY_RE,
|
|
301
|
+
VENDOR_RE
|
|
302
|
+
];
|
|
303
|
+
function isProtected(body) {
|
|
304
|
+
return PROTECTED_SIGNALS.some((signal) => signal.test(body));
|
|
305
|
+
}
|
|
306
|
+
function hasExternalReference(body) {
|
|
307
|
+
return REF_RE.test(body);
|
|
308
|
+
}
|
|
309
|
+
var STOPWORDS = new Set(
|
|
310
|
+
`a an the this that these those it its their his her our your my
|
|
311
|
+
is are was were be been being am do does did done doing has have had having
|
|
312
|
+
will would shall should can could may might must
|
|
313
|
+
and or but nor so yet not no none
|
|
314
|
+
to of for in on at by with from into onto out up down over under about
|
|
315
|
+
as if then than when where which who whom whose what how why while
|
|
316
|
+
we you they i he she them him us me
|
|
317
|
+
also just only even still already again there here
|
|
318
|
+
all any each every some
|
|
319
|
+
via per etc eg ie vs
|
|
320
|
+
need needs needed want wants make makes making let lets
|
|
321
|
+
please note see above below`.split(/\s+/)
|
|
322
|
+
);
|
|
323
|
+
var CAMEL_PART_RE = /[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|\d+/g;
|
|
324
|
+
var WORD_RE = /[A-Za-z_$][\w$]*|\d+/g;
|
|
325
|
+
function splitIdentifier(token) {
|
|
326
|
+
const parts = [];
|
|
327
|
+
for (const chunk of token.split(/[_$]/)) {
|
|
328
|
+
for (const match of chunk.match(CAMEL_PART_RE) ?? []) {
|
|
329
|
+
parts.push(match.toLowerCase());
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return parts;
|
|
312
333
|
}
|
|
313
|
-
function
|
|
314
|
-
|
|
334
|
+
function stem(word) {
|
|
335
|
+
let base = word;
|
|
336
|
+
for (const suffix of ["ing", "ied", "ies", "ers", "er", "ed", "es", "s"]) {
|
|
337
|
+
if (word.endsWith(suffix) && word.length - suffix.length >= 3) {
|
|
338
|
+
base = word.slice(0, word.length - suffix.length);
|
|
339
|
+
if (suffix === "ied" || suffix === "ies") return `${base}y`;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return base.endsWith("e") && base.length - 1 >= 3 ? base.slice(0, -1) : base;
|
|
315
344
|
}
|
|
316
|
-
function
|
|
317
|
-
const
|
|
318
|
-
|
|
345
|
+
function contentTokens(text) {
|
|
346
|
+
const tokens = [];
|
|
347
|
+
for (const match of text.match(WORD_RE) ?? []) {
|
|
348
|
+
tokens.push(...splitIdentifier(match));
|
|
349
|
+
}
|
|
350
|
+
return tokens.filter((token) => !STOPWORDS.has(token));
|
|
319
351
|
}
|
|
320
|
-
function
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (/[.!?]$/.test(t) && /\s/.test(t) && /[a-z]/.test(t) && !looksLikeCode(t) && t.split(/\s+/).length >= 3) {
|
|
325
|
-
return true;
|
|
352
|
+
function codeTokens(text) {
|
|
353
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
354
|
+
for (const match of text.match(WORD_RE) ?? []) {
|
|
355
|
+
for (const part of splitIdentifier(match)) tokens.add(part);
|
|
326
356
|
}
|
|
327
|
-
return
|
|
357
|
+
return tokens;
|
|
358
|
+
}
|
|
359
|
+
function restates(commentTokens, code) {
|
|
360
|
+
const stems = /* @__PURE__ */ new Set();
|
|
361
|
+
for (const token of code) stems.add(stem(token));
|
|
362
|
+
return commentTokens.every((token) => code.has(token) || stems.has(stem(token)));
|
|
328
363
|
}
|
|
329
364
|
var NARRATION_MAX_WORDS = 6;
|
|
330
365
|
var NARRATION_MIN_CONTENT = 1;
|
|
@@ -385,7 +420,7 @@ function normalizeToken(word) {
|
|
|
385
420
|
const lower = word.toLowerCase();
|
|
386
421
|
return lower.length > TOKEN_PLURAL_MIN && lower.endsWith("s") && !lower.endsWith("ss") ? lower.slice(0, -1) : lower;
|
|
387
422
|
}
|
|
388
|
-
function
|
|
423
|
+
function headTokens(source) {
|
|
389
424
|
const tokens = /* @__PURE__ */ new Set();
|
|
390
425
|
for (const identifier of source.match(/[A-Za-z_$][\w$]*/g) ?? []) {
|
|
391
426
|
tokens.add(normalizeToken(identifier));
|
|
@@ -417,7 +452,7 @@ function restatableStatementBelow(comment, sourceCode) {
|
|
|
417
452
|
}
|
|
418
453
|
return null;
|
|
419
454
|
}
|
|
420
|
-
function
|
|
455
|
+
function restatesStatementHead(body, statement) {
|
|
421
456
|
if (statement === null) return false;
|
|
422
457
|
const words = body.match(/[A-Za-z][\w$]*/g) ?? [];
|
|
423
458
|
const opener = words[0];
|
|
@@ -426,18 +461,152 @@ function restatesNextLine(body, statement) {
|
|
|
426
461
|
const content = words.slice(1).map(normalizeToken).filter((word) => !NARRATION_STOPWORDS.has(word));
|
|
427
462
|
if (content.length < NARRATION_MIN_CONTENT) return false;
|
|
428
463
|
const head = statement.split("(")[0] ?? statement;
|
|
429
|
-
const code =
|
|
464
|
+
const code = headTokens(head);
|
|
430
465
|
return content.every((word) => code.has(word));
|
|
431
466
|
}
|
|
467
|
+
|
|
468
|
+
// src/rules/no-comment-cruft.ts
|
|
469
|
+
var LEADING_PREAMBLE_MIN = 4;
|
|
470
|
+
var STEP_NARRATION_RE = /^(?:first(?:ly)?|second(?:ly)?|third(?:ly)?|then|next|after(?:wards| that)?|finally|lastly|now)\s*[,:]\s*\S|^step\s+\d+\b/i;
|
|
471
|
+
var META_COMMENTARY_RE = /\b(?:for now|keeping (?:it|this) simple|could be (?:refactored|improved|cleaned up|simplified)|refactor(?:ed|ing)? (?:later|this)|not sure (?:if|whether|why|how)|quick[- ](?:and[- ]dirty|fix)|(?:a |bit of a )?hacky|is a hack|temporary (?:solution|workaround|fix|hack)|revisit (?:this|later|below)|clean (?:this|it) up|not ideal|placeholder for now)\b/i;
|
|
472
|
+
var DIRECTIVE_RE = /^(eslint\b|eslint-|sarj-noqa\b|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
473
|
+
var LICENSE_RE = /copyright|licen[cs]ed?|spdx|permission is hereby granted|all rights reserved/i;
|
|
474
|
+
var ENUMERATED_ITEM_RE = /^(?:\d+[.):]|[-*•])\s+\S/;
|
|
475
|
+
var ENUMERATED_ITEM_MIN_WORDS = 3;
|
|
476
|
+
var ENUMERATED_PREAMBLE_MIN_ITEMS = 2;
|
|
477
|
+
var BANNER_FULL_RE = /^[\s\-=*#~_+.]{4,}$/;
|
|
478
|
+
var BANNER_RUN_RE = /={4,}|-{4,}|#{4,}|\*{4,}|~{4,}|[\u2500-\u257f]{4,}/;
|
|
479
|
+
var REGION_MARKER_RE = /^#?(?:end)?region\b(.*)$/i;
|
|
480
|
+
var REGION_TITLE_RE = /^[\s:\-\u2013\u2014]*\w[\w \-/&+]*$/;
|
|
481
|
+
var REGION_TITLE_MAX_WORDS = 5;
|
|
482
|
+
function isRegionMarker(text) {
|
|
483
|
+
const match = REGION_MARKER_RE.exec(text);
|
|
484
|
+
if (match === null) return false;
|
|
485
|
+
const title = (match[1] ?? "").trim();
|
|
486
|
+
if (title.length === 0) return true;
|
|
487
|
+
if (!REGION_TITLE_RE.test(title)) return false;
|
|
488
|
+
return title.split(/\s+/).length <= REGION_TITLE_MAX_WORDS;
|
|
489
|
+
}
|
|
490
|
+
var SECTION_LABEL_WORDS = /* @__PURE__ */ new Set([
|
|
491
|
+
"actions",
|
|
492
|
+
"components",
|
|
493
|
+
"config",
|
|
494
|
+
"configuration",
|
|
495
|
+
"constant",
|
|
496
|
+
"constants",
|
|
497
|
+
"enums",
|
|
498
|
+
"exports",
|
|
499
|
+
"fixtures",
|
|
500
|
+
"getters",
|
|
501
|
+
"globals",
|
|
502
|
+
"handler",
|
|
503
|
+
"handlers",
|
|
504
|
+
"helper",
|
|
505
|
+
"helpers",
|
|
506
|
+
"hook",
|
|
507
|
+
"hooks",
|
|
508
|
+
"imports",
|
|
509
|
+
"interfaces",
|
|
510
|
+
"main",
|
|
511
|
+
"mocks",
|
|
512
|
+
"models",
|
|
513
|
+
"mutations",
|
|
514
|
+
"props",
|
|
515
|
+
"queries",
|
|
516
|
+
"reducers",
|
|
517
|
+
"routes",
|
|
518
|
+
"schemas",
|
|
519
|
+
"selectors",
|
|
520
|
+
"setters",
|
|
521
|
+
"setup",
|
|
522
|
+
"state",
|
|
523
|
+
"styles",
|
|
524
|
+
"teardown",
|
|
525
|
+
"type",
|
|
526
|
+
"types",
|
|
527
|
+
"util",
|
|
528
|
+
"utilities",
|
|
529
|
+
"utils"
|
|
530
|
+
]);
|
|
531
|
+
var SECTION_LABEL_RE = /^([A-Za-z]+)\s*:?\s*$/;
|
|
532
|
+
function isSectionLabel(text) {
|
|
533
|
+
const match = SECTION_LABEL_RE.exec(text);
|
|
534
|
+
return match !== null && SECTION_LABEL_WORDS.has((match[1] ?? "").toLowerCase());
|
|
535
|
+
}
|
|
536
|
+
var HELPER_OPENER_RE = /^(?:a\s+)?helper\s+(?:function|method|component|hook|class|type|util(?:ity)?)\b/i;
|
|
537
|
+
var LETS_RE = /^let'?s\s+(?:not\s+|just\s+|now\s+|first\s+)?(?:add|append|assign|await|build|calculate|call|check|clear|close|compute|convert|copy|count|create|declare|decrement|define|delete|extract|fetch|filter|find|format|generate|get|handle|increment|init|initialise|initialize|insert|iterate|join|load|log|loop|map|merge|open|parse|print|process|push|read|remove|render|reset|return|save|send|set|setup|sort|split|start|stop|store|update|validate|wrap|write)(?:s|es|ed|ing)?\b/i;
|
|
538
|
+
var ENUMERATION_RE = /^(?:\d+[.)]\s+\S|phase\s+\d+\b)/i;
|
|
539
|
+
var DIAGRAM_ARROW_RE = /[-=~]{2,}>|<[-=~]{2,}/;
|
|
540
|
+
var CODE_KEYWORD_RE = /^(import |export |const |let |var |function\b|class |interface |type \w|enum |return\b|throw |await |async |if\s*\(|for\s*\(|while\s*\(|switch\s*\(|new |console\.)/;
|
|
541
|
+
var CODE_TAIL_RE = /[;{}()]\s*$|=>\s*$|,\s*$/;
|
|
542
|
+
var CALL_OR_ASSIGN_RE = /^[A-Za-z_$][\w.$[\]]*\s*(?:=(?![=>])|\+=|-=|\*=)\s*\S.*[;)}\]]\s*$|^[A-Za-z_$][\w.$]*\([^)]*\)\s*;?\s*$/;
|
|
543
|
+
var PSEUDOCODE_RE = /%\w+%|\[opt\]|(?:^|\s)<[A-Za-z]\w*>|…|\.\.\./;
|
|
544
|
+
function stripCommentMarker(line) {
|
|
545
|
+
return line.replace(/^\s*\/{1,2}/, "").replace(/^\s*\*+/, "").trim();
|
|
546
|
+
}
|
|
547
|
+
function isDirective(text) {
|
|
548
|
+
return DIRECTIVE_RE.test(text.trim());
|
|
549
|
+
}
|
|
550
|
+
function isBanner(text) {
|
|
551
|
+
const t = text.trim();
|
|
552
|
+
if (!t) return false;
|
|
553
|
+
if (BANNER_FULL_RE.test(t) || isRegionMarker(t)) return true;
|
|
554
|
+
return BANNER_RUN_RE.test(t) && !DIAGRAM_ARROW_RE.test(t);
|
|
555
|
+
}
|
|
556
|
+
function looksLikeCode(text) {
|
|
557
|
+
const t = text.trim();
|
|
558
|
+
if (!t) return false;
|
|
559
|
+
if (CODE_KEYWORD_RE.test(t) && CODE_TAIL_RE.test(t)) return true;
|
|
560
|
+
return CALL_OR_ASSIGN_RE.test(t);
|
|
561
|
+
}
|
|
562
|
+
function hasPseudocode(text) {
|
|
563
|
+
return PSEUDOCODE_RE.test(text);
|
|
564
|
+
}
|
|
565
|
+
function isEnumeratedProseItem(text) {
|
|
566
|
+
const t = text.trim();
|
|
567
|
+
return ENUMERATED_ITEM_RE.test(t) && t.split(/\s+/).length >= ENUMERATED_ITEM_MIN_WORDS;
|
|
568
|
+
}
|
|
569
|
+
function isProse(text) {
|
|
570
|
+
const t = text.trim();
|
|
571
|
+
if (!t) return false;
|
|
572
|
+
if (t.endsWith(":")) return true;
|
|
573
|
+
if (/[.!?]$/.test(t) && /\s/.test(t) && /[a-z]/.test(t) && !looksLikeCode(t) && t.split(/\s+/).length >= 3) {
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
432
578
|
var JUSTIFICATION_RE = /\b(?:because|since|until|due to|so that|otherwise|which is why|in order to|to avoid|to work around|to prevent)\b/i;
|
|
433
|
-
function isRedundantNarration(body, statementBelow, standalone) {
|
|
579
|
+
function isRedundantNarration(body, statementBelow, standalone, isolatedEnumeration, nested) {
|
|
434
580
|
const t = body.trim();
|
|
435
581
|
if (!t || looksLikeCode(t) || hasPseudocode(t)) return false;
|
|
436
582
|
if (standalone) {
|
|
437
583
|
if (STEP_NARRATION_RE.test(t)) return true;
|
|
438
584
|
if (META_COMMENTARY_RE.test(t) && !JUSTIFICATION_RE.test(t)) return true;
|
|
585
|
+
if (HELPER_OPENER_RE.test(t) || LETS_RE.test(t)) return true;
|
|
586
|
+
if (!nested && isSectionLabel(t)) return true;
|
|
587
|
+
if (isolatedEnumeration && ENUMERATION_RE.test(t)) return true;
|
|
588
|
+
}
|
|
589
|
+
return restatesStatementHead(t, statementBelow);
|
|
590
|
+
}
|
|
591
|
+
var STATEMENT_CONTAINERS = /* @__PURE__ */ new Set([
|
|
592
|
+
import_utils4.AST_NODE_TYPES.Program,
|
|
593
|
+
import_utils4.AST_NODE_TYPES.BlockStatement,
|
|
594
|
+
import_utils4.AST_NODE_TYPES.ClassBody,
|
|
595
|
+
import_utils4.AST_NODE_TYPES.StaticBlock,
|
|
596
|
+
import_utils4.AST_NODE_TYPES.SwitchCase,
|
|
597
|
+
import_utils4.AST_NODE_TYPES.TSModuleBlock,
|
|
598
|
+
import_utils4.AST_NODE_TYPES.TSInterfaceBody
|
|
599
|
+
]);
|
|
600
|
+
function runCitesAReference(comments, index) {
|
|
601
|
+
for (let i = index; i >= 0; i--) {
|
|
602
|
+
if (i < index && !areAdjacentLineComments(comments[i], comments[i + 1])) break;
|
|
603
|
+
if (hasExternalReference(stripCommentMarker(comments[i]?.value ?? ""))) return true;
|
|
439
604
|
}
|
|
440
|
-
|
|
605
|
+
for (let i = index + 1; i < comments.length; i++) {
|
|
606
|
+
if (!areAdjacentLineComments(comments[i - 1], comments[i])) break;
|
|
607
|
+
if (hasExternalReference(stripCommentMarker(comments[i]?.value ?? ""))) return true;
|
|
608
|
+
}
|
|
609
|
+
return false;
|
|
441
610
|
}
|
|
442
611
|
function areAdjacentLineComments(a, b) {
|
|
443
612
|
return a !== void 0 && b !== void 0 && a.type === "Line" && b.type === "Line" && b.loc.start.line === a.loc.end.line + 1;
|
|
@@ -467,7 +636,7 @@ function hasCommentedOutCode(texts, precedingProse) {
|
|
|
467
636
|
}
|
|
468
637
|
return false;
|
|
469
638
|
}
|
|
470
|
-
var no_comment_cruft_default =
|
|
639
|
+
var no_comment_cruft_default = import_utils4.ESLintUtils.RuleCreator(
|
|
471
640
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
472
641
|
)({
|
|
473
642
|
name: "no-comment-cruft",
|
|
@@ -486,6 +655,9 @@ var no_comment_cruft_default = import_utils3.ESLintUtils.RuleCreator(
|
|
|
486
655
|
},
|
|
487
656
|
defaultOptions: [],
|
|
488
657
|
create(context) {
|
|
658
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
659
|
+
return {};
|
|
660
|
+
}
|
|
489
661
|
const sourceCode = context.sourceCode;
|
|
490
662
|
function isStandalone(comment) {
|
|
491
663
|
const before = sourceCode.getTokenBefore(comment, {
|
|
@@ -523,6 +695,9 @@ var no_comment_cruft_default = import_utils3.ESLintUtils.RuleCreator(
|
|
|
523
695
|
Program() {
|
|
524
696
|
const comments = sourceCode.getAllComments();
|
|
525
697
|
const firstCodeLine = sourceCode.ast.tokens[0]?.loc.start.line ?? Number.MAX_SAFE_INTEGER;
|
|
698
|
+
const enumerated = comments.filter(
|
|
699
|
+
(c) => c.type === "Line" && ENUMERATION_RE.test(stripCommentMarker(c.value))
|
|
700
|
+
);
|
|
526
701
|
for (let i = 0; i < comments.length; i++) {
|
|
527
702
|
const comment = comments[i];
|
|
528
703
|
if (comment === void 0) continue;
|
|
@@ -543,7 +718,9 @@ var no_comment_cruft_default = import_utils3.ESLintUtils.RuleCreator(
|
|
|
543
718
|
const body = texts[0];
|
|
544
719
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
545
720
|
const standalone = !isInsideCommentRun(comments, i);
|
|
546
|
-
|
|
721
|
+
const container = sourceCode.getNodeByRangeIndex(comment.range[0]);
|
|
722
|
+
const nested = container !== null && !STATEMENT_CONTAINERS.has(container.type);
|
|
723
|
+
if (body !== void 0 && !runCitesAReference(comments, i) && isRedundantNarration(body, statement, standalone, enumerated.length === 1, nested)) {
|
|
547
724
|
context.report({ node: comment, messageId: "redundantNarration" });
|
|
548
725
|
}
|
|
549
726
|
}
|
|
@@ -555,9 +732,10 @@ var no_comment_cruft_default = import_utils3.ESLintUtils.RuleCreator(
|
|
|
555
732
|
});
|
|
556
733
|
|
|
557
734
|
// src/rules/no-enum.ts
|
|
558
|
-
var
|
|
735
|
+
var import_utils5 = require("@typescript-eslint/utils");
|
|
559
736
|
var DEFAULT_IGNORE_PATTERNS = [
|
|
560
737
|
/[\\/]generated[\\/]/,
|
|
738
|
+
/[\\/]openapi-gen[\\/]/,
|
|
561
739
|
/\.gen\.tsx?$/,
|
|
562
740
|
/\.generated\.tsx?$/
|
|
563
741
|
];
|
|
@@ -574,7 +752,7 @@ function hasGeneratedMarker(sourceText) {
|
|
|
574
752
|
const head = sourceText.slice(0, 1024);
|
|
575
753
|
return /@generated\b/.test(head);
|
|
576
754
|
}
|
|
577
|
-
var no_enum_default =
|
|
755
|
+
var no_enum_default = import_utils5.ESLintUtils.RuleCreator(
|
|
578
756
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
579
757
|
)({
|
|
580
758
|
name: "no-enum",
|
|
@@ -609,7 +787,7 @@ var no_enum_default = import_utils4.ESLintUtils.RuleCreator(
|
|
|
609
787
|
(re) => re.test(filename)
|
|
610
788
|
);
|
|
611
789
|
const isIgnoredByOption = ignoreFiles.length > 0 && matchesAnyPattern(filename, ignoreFiles);
|
|
612
|
-
const isGenerated = hasGeneratedMarker(sourceText);
|
|
790
|
+
const isGenerated = hasGeneratedMarker(sourceText) || isGeneratedFile(filename, sourceText);
|
|
613
791
|
if (isIgnoredByDefault || isIgnoredByOption || isGenerated) {
|
|
614
792
|
return {};
|
|
615
793
|
}
|
|
@@ -625,7 +803,7 @@ var no_enum_default = import_utils4.ESLintUtils.RuleCreator(
|
|
|
625
803
|
});
|
|
626
804
|
|
|
627
805
|
// src/rules/no-insecure-random-id.ts
|
|
628
|
-
var
|
|
806
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
629
807
|
var STRONG_SECURITY_PATTERN = /token|secret|csrf|password|passwd|apikey|api[-_]?key|nonce|salt|uuid|authid/i;
|
|
630
808
|
var NON_SECURITY_ID_PATTERN = /temp|tmp|cache|correlation|request|req|trace|execution|dev|hmr|mock|test|perf|marker/i;
|
|
631
809
|
var PATH_OR_DOM_MARKER = /[\\/#]|\.[A-Za-z0-9]/;
|
|
@@ -766,7 +944,7 @@ function isConcatenatedIntoPathOrDomId(node) {
|
|
|
766
944
|
collectStaticStringParts(top, parts);
|
|
767
945
|
return parts.some((part) => PATH_OR_DOM_MARKER.test(part));
|
|
768
946
|
}
|
|
769
|
-
var no_insecure_random_id_default =
|
|
947
|
+
var no_insecure_random_id_default = import_utils6.ESLintUtils.RuleCreator(
|
|
770
948
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
771
949
|
)({
|
|
772
950
|
name: "no-insecure-random-id",
|
|
@@ -810,7 +988,7 @@ var no_insecure_random_id_default = import_utils5.ESLintUtils.RuleCreator(
|
|
|
810
988
|
});
|
|
811
989
|
|
|
812
990
|
// src/rules/no-json-stringify-error.ts
|
|
813
|
-
var
|
|
991
|
+
var import_utils7 = require("@typescript-eslint/utils");
|
|
814
992
|
var ERROR_NAME_PATTERN = /^(e|err|error|ex|exc)$/i;
|
|
815
993
|
var ERROR_PROP_PATTERN = /^(cause|lastError|error|err|exception|originalError|innerError)$/i;
|
|
816
994
|
var SAFE_STRING_PROPS = /* @__PURE__ */ new Set(["message", "stack", "name"]);
|
|
@@ -944,7 +1122,7 @@ function isGuardedByInstanceofError(node, argExpr, sourceCode) {
|
|
|
944
1122
|
function isJsonStringify(callee) {
|
|
945
1123
|
return callee.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "JSON" && callee.property.type === "Identifier" && callee.property.name === "stringify";
|
|
946
1124
|
}
|
|
947
|
-
var no_json_stringify_error_default =
|
|
1125
|
+
var no_json_stringify_error_default = import_utils7.ESLintUtils.RuleCreator(
|
|
948
1126
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
949
1127
|
)({
|
|
950
1128
|
name: "no-json-stringify-error",
|
|
@@ -994,10 +1172,10 @@ var no_json_stringify_error_default = import_utils6.ESLintUtils.RuleCreator(
|
|
|
994
1172
|
});
|
|
995
1173
|
|
|
996
1174
|
// src/rules/no-log-only-catch.ts
|
|
997
|
-
var
|
|
1175
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
998
1176
|
|
|
999
1177
|
// src/rules/_logging.ts
|
|
1000
|
-
var
|
|
1178
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
1001
1179
|
var LOG_METHODS = /* @__PURE__ */ new Set([
|
|
1002
1180
|
"debug",
|
|
1003
1181
|
"info",
|
|
@@ -1104,7 +1282,7 @@ var DEFAULT_IGNORE_PATTERNS2 = [
|
|
|
1104
1282
|
/\.spec\./,
|
|
1105
1283
|
/[\\/]__tests__[\\/]/
|
|
1106
1284
|
];
|
|
1107
|
-
var no_log_only_catch_default =
|
|
1285
|
+
var no_log_only_catch_default = import_utils9.ESLintUtils.RuleCreator(
|
|
1108
1286
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
1109
1287
|
)({
|
|
1110
1288
|
name: "no-log-only-catch",
|
|
@@ -1167,7 +1345,7 @@ var no_log_only_catch_default = import_utils8.ESLintUtils.RuleCreator(
|
|
|
1167
1345
|
});
|
|
1168
1346
|
|
|
1169
1347
|
// src/rules/no-raw-env.ts
|
|
1170
|
-
var
|
|
1348
|
+
var import_utils10 = require("@typescript-eslint/utils");
|
|
1171
1349
|
var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
1172
1350
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
1173
1351
|
function isValidatedEnvBoundary(filename, sourceText) {
|
|
@@ -1205,7 +1383,7 @@ function isWholeEnvSpread(node) {
|
|
|
1205
1383
|
const parent = node.parent;
|
|
1206
1384
|
return parent.type === "SpreadElement" && parent.argument === node;
|
|
1207
1385
|
}
|
|
1208
|
-
var no_raw_env_default =
|
|
1386
|
+
var no_raw_env_default = import_utils10.ESLintUtils.RuleCreator(
|
|
1209
1387
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
1210
1388
|
)({
|
|
1211
1389
|
name: "no-raw-env",
|
|
@@ -1239,12 +1417,12 @@ var no_raw_env_default = import_utils9.ESLintUtils.RuleCreator(
|
|
|
1239
1417
|
});
|
|
1240
1418
|
|
|
1241
1419
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
1242
|
-
var
|
|
1420
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
1243
1421
|
function sentinelKind(arg) {
|
|
1244
1422
|
if (arg === null) {
|
|
1245
1423
|
return null;
|
|
1246
1424
|
}
|
|
1247
|
-
if (arg.type ===
|
|
1425
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.Literal) {
|
|
1248
1426
|
if (arg.value === null) {
|
|
1249
1427
|
return "nullish";
|
|
1250
1428
|
}
|
|
@@ -1256,13 +1434,13 @@ function sentinelKind(arg) {
|
|
|
1256
1434
|
}
|
|
1257
1435
|
return null;
|
|
1258
1436
|
}
|
|
1259
|
-
if (arg.type ===
|
|
1437
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
1260
1438
|
return "nullish";
|
|
1261
1439
|
}
|
|
1262
|
-
if (arg.type ===
|
|
1440
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.ArrayExpression) {
|
|
1263
1441
|
return "array";
|
|
1264
1442
|
}
|
|
1265
|
-
if (arg.type ===
|
|
1443
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.ObjectExpression) {
|
|
1266
1444
|
return "object";
|
|
1267
1445
|
}
|
|
1268
1446
|
return null;
|
|
@@ -1271,25 +1449,25 @@ function isSentinelArgument(arg) {
|
|
|
1271
1449
|
if (arg === null) {
|
|
1272
1450
|
return false;
|
|
1273
1451
|
}
|
|
1274
|
-
if (arg.type ===
|
|
1452
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.Literal && arg.value === null) {
|
|
1275
1453
|
return true;
|
|
1276
1454
|
}
|
|
1277
|
-
if (arg.type ===
|
|
1455
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.Literal && arg.value === false) {
|
|
1278
1456
|
return true;
|
|
1279
1457
|
}
|
|
1280
|
-
if (arg.type ===
|
|
1458
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
1281
1459
|
return true;
|
|
1282
1460
|
}
|
|
1283
|
-
if (arg.type ===
|
|
1461
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.ArrayExpression && arg.elements.length === 0) {
|
|
1284
1462
|
return true;
|
|
1285
1463
|
}
|
|
1286
|
-
if (arg.type ===
|
|
1464
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.ObjectExpression && arg.properties.length === 0) {
|
|
1287
1465
|
return true;
|
|
1288
1466
|
}
|
|
1289
1467
|
return false;
|
|
1290
1468
|
}
|
|
1291
1469
|
function isFunctionNode(node) {
|
|
1292
|
-
return node.type ===
|
|
1470
|
+
return node.type === import_utils11.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils11.AST_NODE_TYPES.FunctionExpression || node.type === import_utils11.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
1293
1471
|
}
|
|
1294
1472
|
function isNode(value) {
|
|
1295
1473
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -1329,24 +1507,24 @@ function walkWithinScope(node, visit) {
|
|
|
1329
1507
|
function containsThrow(node) {
|
|
1330
1508
|
return walkWithinScope(
|
|
1331
1509
|
node,
|
|
1332
|
-
(current) => current.type ===
|
|
1510
|
+
(current) => current.type === import_utils11.AST_NODE_TYPES.ThrowStatement
|
|
1333
1511
|
);
|
|
1334
1512
|
}
|
|
1335
1513
|
function bindsName(param, name) {
|
|
1336
1514
|
switch (param.type) {
|
|
1337
|
-
case
|
|
1515
|
+
case import_utils11.AST_NODE_TYPES.Identifier:
|
|
1338
1516
|
return param.name === name;
|
|
1339
|
-
case
|
|
1517
|
+
case import_utils11.AST_NODE_TYPES.AssignmentPattern:
|
|
1340
1518
|
return bindsName(param.left, name);
|
|
1341
|
-
case
|
|
1519
|
+
case import_utils11.AST_NODE_TYPES.RestElement:
|
|
1342
1520
|
return bindsName(param.argument, name);
|
|
1343
|
-
case
|
|
1521
|
+
case import_utils11.AST_NODE_TYPES.ArrayPattern:
|
|
1344
1522
|
return param.elements.some(
|
|
1345
1523
|
(element) => element !== null && bindsName(element, name)
|
|
1346
1524
|
);
|
|
1347
|
-
case
|
|
1525
|
+
case import_utils11.AST_NODE_TYPES.ObjectPattern:
|
|
1348
1526
|
return param.properties.some(
|
|
1349
|
-
(property) => property.type ===
|
|
1527
|
+
(property) => property.type === import_utils11.AST_NODE_TYPES.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
1350
1528
|
);
|
|
1351
1529
|
default:
|
|
1352
1530
|
return false;
|
|
@@ -1361,7 +1539,7 @@ function subtreeReadsName(node, name) {
|
|
|
1361
1539
|
if (found) {
|
|
1362
1540
|
return;
|
|
1363
1541
|
}
|
|
1364
|
-
if (current.type ===
|
|
1542
|
+
if (current.type === import_utils11.AST_NODE_TYPES.Identifier && current.name === name) {
|
|
1365
1543
|
found = true;
|
|
1366
1544
|
return;
|
|
1367
1545
|
}
|
|
@@ -1372,10 +1550,10 @@ function subtreeReadsName(node, name) {
|
|
|
1372
1550
|
if (key === "parent") {
|
|
1373
1551
|
continue;
|
|
1374
1552
|
}
|
|
1375
|
-
if (key === "key" && current.type ===
|
|
1553
|
+
if (key === "key" && current.type === import_utils11.AST_NODE_TYPES.Property && !current.computed) {
|
|
1376
1554
|
continue;
|
|
1377
1555
|
}
|
|
1378
|
-
if (key === "property" && current.type ===
|
|
1556
|
+
if (key === "property" && current.type === import_utils11.AST_NODE_TYPES.MemberExpression && !current.computed) {
|
|
1379
1557
|
continue;
|
|
1380
1558
|
}
|
|
1381
1559
|
const value = current[key];
|
|
@@ -1408,10 +1586,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
1408
1586
|
"URLPattern"
|
|
1409
1587
|
]);
|
|
1410
1588
|
function isParseShapedNode(node) {
|
|
1411
|
-
if (node.type ===
|
|
1589
|
+
if (node.type === import_utils11.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils11.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1412
1590
|
return node.callee.property.name === "parse";
|
|
1413
1591
|
}
|
|
1414
|
-
if (node.type ===
|
|
1592
|
+
if (node.type === import_utils11.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1415
1593
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
1416
1594
|
}
|
|
1417
1595
|
return false;
|
|
@@ -1422,10 +1600,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
1422
1600
|
"arrayBuffer"
|
|
1423
1601
|
]);
|
|
1424
1602
|
function isBodyDecodeNode(node) {
|
|
1425
|
-
return node.type ===
|
|
1603
|
+
return node.type === import_utils11.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils11.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils11.AST_NODE_TYPES.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
1426
1604
|
}
|
|
1427
1605
|
function returnsMatching(stmt, predicate) {
|
|
1428
|
-
return stmt.type ===
|
|
1606
|
+
return stmt.type === import_utils11.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
1429
1607
|
}
|
|
1430
1608
|
function enclosingReturnTypeNode(node) {
|
|
1431
1609
|
let current = node.parent;
|
|
@@ -1443,11 +1621,11 @@ function enclosingFunctionName(node) {
|
|
|
1443
1621
|
let current = node.parent;
|
|
1444
1622
|
while (current !== void 0 && current !== null) {
|
|
1445
1623
|
if (isFunctionNode(current)) {
|
|
1446
|
-
if ("id" in current && isNode(current.id) && current.id.type ===
|
|
1624
|
+
if ("id" in current && isNode(current.id) && current.id.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1447
1625
|
return current.id.name;
|
|
1448
1626
|
}
|
|
1449
1627
|
const parent = current.parent;
|
|
1450
|
-
if (parent?.type ===
|
|
1628
|
+
if (parent?.type === import_utils11.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1451
1629
|
return parent.id.name;
|
|
1452
1630
|
}
|
|
1453
1631
|
return null;
|
|
@@ -1468,10 +1646,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
1468
1646
|
return false;
|
|
1469
1647
|
}
|
|
1470
1648
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
1471
|
-
if (declared?.type ===
|
|
1649
|
+
if (declared?.type === import_utils11.AST_NODE_TYPES.TSTypeReference && declared.typeName.type === import_utils11.AST_NODE_TYPES.Identifier && declared.typeName.name === "Promise") {
|
|
1472
1650
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
1473
1651
|
}
|
|
1474
|
-
return declared?.type ===
|
|
1652
|
+
return declared?.type === import_utils11.AST_NODE_TYPES.TSBooleanKeyword;
|
|
1475
1653
|
}
|
|
1476
1654
|
function tryReturnsSafeParse(catchNode) {
|
|
1477
1655
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -1487,7 +1665,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
1487
1665
|
function enclosingFunctionBody(node) {
|
|
1488
1666
|
let current = node.parent;
|
|
1489
1667
|
while (current !== void 0 && current !== null) {
|
|
1490
|
-
if (isFunctionNode(current) && "body" in current && isNode(current.body) && current.body.type ===
|
|
1668
|
+
if (isFunctionNode(current) && "body" in current && isNode(current.body) && current.body.type === import_utils11.AST_NODE_TYPES.BlockStatement) {
|
|
1491
1669
|
return current.body;
|
|
1492
1670
|
}
|
|
1493
1671
|
current = current.parent;
|
|
@@ -1500,7 +1678,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
1500
1678
|
return false;
|
|
1501
1679
|
}
|
|
1502
1680
|
return walkWithinScope(functionBody, (current) => {
|
|
1503
|
-
if (current.type !==
|
|
1681
|
+
if (current.type !== import_utils11.AST_NODE_TYPES.ReturnStatement) {
|
|
1504
1682
|
return false;
|
|
1505
1683
|
}
|
|
1506
1684
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -1519,13 +1697,13 @@ function returnedSentinelKinds(arg) {
|
|
|
1519
1697
|
kinds.add(direct);
|
|
1520
1698
|
return kinds;
|
|
1521
1699
|
}
|
|
1522
|
-
if (arg.type ===
|
|
1700
|
+
if (arg.type === import_utils11.AST_NODE_TYPES.ConditionalExpression) {
|
|
1523
1701
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
1524
1702
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
1525
1703
|
kinds.add(nested);
|
|
1526
1704
|
}
|
|
1527
1705
|
}
|
|
1528
|
-
} else if (arg.type ===
|
|
1706
|
+
} else if (arg.type === import_utils11.AST_NODE_TYPES.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
1529
1707
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
1530
1708
|
kinds.add(nested);
|
|
1531
1709
|
}
|
|
@@ -1542,7 +1720,7 @@ function isWithin(node, ancestor) {
|
|
|
1542
1720
|
}
|
|
1543
1721
|
return false;
|
|
1544
1722
|
}
|
|
1545
|
-
var no_sentinel_return_on_catch_default =
|
|
1723
|
+
var no_sentinel_return_on_catch_default = import_utils11.ESLintUtils.RuleCreator(
|
|
1546
1724
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
1547
1725
|
)({
|
|
1548
1726
|
name: "no-sentinel-return-on-catch",
|
|
@@ -1564,10 +1742,13 @@ var no_sentinel_return_on_catch_default = import_utils10.ESLintUtils.RuleCreator
|
|
|
1564
1742
|
},
|
|
1565
1743
|
defaultOptions: [{}],
|
|
1566
1744
|
create(context, [loggingOptions]) {
|
|
1745
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
1746
|
+
return {};
|
|
1747
|
+
}
|
|
1567
1748
|
const matcher = createLogMatcher(loggingOptions);
|
|
1568
1749
|
function logsOrReportsError(catchBody, caughtName) {
|
|
1569
1750
|
return walkWithinScope(catchBody, (current) => {
|
|
1570
|
-
if (current.type !==
|
|
1751
|
+
if (current.type !== import_utils11.AST_NODE_TYPES.CallExpression) {
|
|
1571
1752
|
return false;
|
|
1572
1753
|
}
|
|
1573
1754
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -1584,7 +1765,7 @@ var no_sentinel_return_on_catch_default = import_utils10.ESLintUtils.RuleCreator
|
|
|
1584
1765
|
return;
|
|
1585
1766
|
}
|
|
1586
1767
|
const last = body[body.length - 1];
|
|
1587
|
-
if (last === void 0 || last.type !==
|
|
1768
|
+
if (last === void 0 || last.type !== import_utils11.AST_NODE_TYPES.ReturnStatement) {
|
|
1588
1769
|
return;
|
|
1589
1770
|
}
|
|
1590
1771
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -1593,7 +1774,7 @@ var no_sentinel_return_on_catch_default = import_utils10.ESLintUtils.RuleCreator
|
|
|
1593
1774
|
if (containsThrow(node.body)) {
|
|
1594
1775
|
return;
|
|
1595
1776
|
}
|
|
1596
|
-
const caughtName = node.param?.type ===
|
|
1777
|
+
const caughtName = node.param?.type === import_utils11.AST_NODE_TYPES.Identifier ? node.param.name : null;
|
|
1597
1778
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
1598
1779
|
return;
|
|
1599
1780
|
}
|
|
@@ -1620,7 +1801,7 @@ var no_sentinel_return_on_catch_default = import_utils10.ESLintUtils.RuleCreator
|
|
|
1620
1801
|
});
|
|
1621
1802
|
|
|
1622
1803
|
// src/rules/no-sequential-await.ts
|
|
1623
|
-
var
|
|
1804
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
1624
1805
|
var ARRAY_ITERATION_METHODS = /* @__PURE__ */ new Set(["forEach", "map", "filter"]);
|
|
1625
1806
|
var SEQUENTIAL_ITERABLE_HINT = /sort|reverse|ordered|sequence|hook|middleware|pipeline|preset|plugin|extension|\bstage|\bstep|\bphase|migration|chain|buffer|stream|teleport|chunk|\bqueue|drain/i;
|
|
1626
1807
|
var BENCH_FILE_RE = /(^|[\\/])bench(marks?)?[\\/]|\.bench\.[cm]?[jt]sx?$/i;
|
|
@@ -1774,7 +1955,7 @@ function shouldReport(awaits, earlyExit, iterableText, asserts = false) {
|
|
|
1774
1955
|
(node) => !isTimerYield(node) && !isThreadedAccumulator(node) && !isQueueDrain(node)
|
|
1775
1956
|
);
|
|
1776
1957
|
}
|
|
1777
|
-
var no_sequential_await_default =
|
|
1958
|
+
var no_sequential_await_default = import_utils12.ESLintUtils.RuleCreator(
|
|
1778
1959
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
1779
1960
|
)({
|
|
1780
1961
|
name: "no-sequential-await",
|
|
@@ -1869,7 +2050,7 @@ var no_sequential_await_default = import_utils11.ESLintUtils.RuleCreator(
|
|
|
1869
2050
|
});
|
|
1870
2051
|
|
|
1871
2052
|
// src/rules/no-string-concat-in-loop.ts
|
|
1872
|
-
var
|
|
2053
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1873
2054
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
1874
2055
|
"ForStatement",
|
|
1875
2056
|
"ForOfStatement",
|
|
@@ -1954,7 +2135,7 @@ function enclosingLoop(node) {
|
|
|
1954
2135
|
}
|
|
1955
2136
|
return null;
|
|
1956
2137
|
}
|
|
1957
|
-
var no_string_concat_in_loop_default =
|
|
2138
|
+
var no_string_concat_in_loop_default = import_utils13.ESLintUtils.RuleCreator(
|
|
1958
2139
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
1959
2140
|
)({
|
|
1960
2141
|
name: "no-string-concat-in-loop",
|
|
@@ -1970,6 +2151,9 @@ var no_string_concat_in_loop_default = import_utils12.ESLintUtils.RuleCreator(
|
|
|
1970
2151
|
},
|
|
1971
2152
|
defaultOptions: [],
|
|
1972
2153
|
create(context) {
|
|
2154
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
2155
|
+
return {};
|
|
2156
|
+
}
|
|
1973
2157
|
const reported = /* @__PURE__ */ new WeakMap();
|
|
1974
2158
|
return {
|
|
1975
2159
|
AssignmentExpression(node) {
|
|
@@ -2014,7 +2198,7 @@ var no_string_concat_in_loop_default = import_utils12.ESLintUtils.RuleCreator(
|
|
|
2014
2198
|
});
|
|
2015
2199
|
|
|
2016
2200
|
// src/rules/no-unnecessary-use-client.ts
|
|
2017
|
-
var
|
|
2201
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
2018
2202
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
2019
2203
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
2020
2204
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -2040,13 +2224,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
2040
2224
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
2041
2225
|
var jsxRootName = (name) => {
|
|
2042
2226
|
let current = name;
|
|
2043
|
-
while (current.type ===
|
|
2227
|
+
while (current.type === import_utils14.AST_NODE_TYPES.JSXMemberExpression) {
|
|
2044
2228
|
current = current.object;
|
|
2045
2229
|
}
|
|
2046
|
-
return current.type ===
|
|
2230
|
+
return current.type === import_utils14.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
2047
2231
|
};
|
|
2048
2232
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
2049
|
-
if (node.type ===
|
|
2233
|
+
if (node.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2050
2234
|
return imported.has(node.name);
|
|
2051
2235
|
}
|
|
2052
2236
|
for (const key of Object.keys(node)) {
|
|
@@ -2061,16 +2245,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
2061
2245
|
return false;
|
|
2062
2246
|
};
|
|
2063
2247
|
var isUseClientDirective = (node) => {
|
|
2064
|
-
return node.type ===
|
|
2248
|
+
return node.type === import_utils14.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils14.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
2065
2249
|
};
|
|
2066
2250
|
var isGlobalReference = (node, context) => {
|
|
2067
2251
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
2068
2252
|
const parent = node.parent;
|
|
2069
2253
|
if (parent !== void 0) {
|
|
2070
|
-
if (parent.type ===
|
|
2254
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
2071
2255
|
return false;
|
|
2072
2256
|
}
|
|
2073
|
-
if (parent.type ===
|
|
2257
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
2074
2258
|
return false;
|
|
2075
2259
|
}
|
|
2076
2260
|
if (parent.type.startsWith("TS")) {
|
|
@@ -2087,7 +2271,7 @@ var isGlobalReference = (node, context) => {
|
|
|
2087
2271
|
}
|
|
2088
2272
|
return true;
|
|
2089
2273
|
};
|
|
2090
|
-
var no_unnecessary_use_client_default =
|
|
2274
|
+
var no_unnecessary_use_client_default = import_utils14.ESLintUtils.RuleCreator(
|
|
2091
2275
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2092
2276
|
)({
|
|
2093
2277
|
name: "no-unnecessary-use-client",
|
|
@@ -2112,13 +2296,13 @@ var no_unnecessary_use_client_default = import_utils13.ESLintUtils.RuleCreator(
|
|
|
2112
2296
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
2113
2297
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
2114
2298
|
const markIfHookOrContext = (callee) => {
|
|
2115
|
-
if (callee.type ===
|
|
2299
|
+
if (callee.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2116
2300
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
2117
2301
|
hasClientIndicator = true;
|
|
2118
2302
|
}
|
|
2119
2303
|
return;
|
|
2120
2304
|
}
|
|
2121
|
-
if (callee.type ===
|
|
2305
|
+
if (callee.type === import_utils14.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2122
2306
|
const name = callee.property.name;
|
|
2123
2307
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
2124
2308
|
hasClientIndicator = true;
|
|
@@ -2128,7 +2312,7 @@ var no_unnecessary_use_client_default = import_utils13.ESLintUtils.RuleCreator(
|
|
|
2128
2312
|
return {
|
|
2129
2313
|
Program(node) {
|
|
2130
2314
|
for (const stmt of node.body) {
|
|
2131
|
-
if (stmt.type !==
|
|
2315
|
+
if (stmt.type !== import_utils14.AST_NODE_TYPES.ExpressionStatement) break;
|
|
2132
2316
|
if (isUseClientDirective(stmt)) {
|
|
2133
2317
|
directiveNode = stmt;
|
|
2134
2318
|
break;
|
|
@@ -2141,7 +2325,7 @@ var no_unnecessary_use_client_default = import_utils13.ESLintUtils.RuleCreator(
|
|
|
2141
2325
|
},
|
|
2142
2326
|
JSXAttribute(node) {
|
|
2143
2327
|
if (directiveNode === null) return;
|
|
2144
|
-
if (node.name.type ===
|
|
2328
|
+
if (node.name.type === import_utils14.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
2145
2329
|
hasClientIndicator = true;
|
|
2146
2330
|
}
|
|
2147
2331
|
},
|
|
@@ -2208,8 +2392,8 @@ var no_unnecessary_use_client_default = import_utils13.ESLintUtils.RuleCreator(
|
|
|
2208
2392
|
});
|
|
2209
2393
|
|
|
2210
2394
|
// src/rules/prefer-discriminated-union.ts
|
|
2211
|
-
var import_utils14 = require("@typescript-eslint/utils");
|
|
2212
2395
|
var import_utils15 = require("@typescript-eslint/utils");
|
|
2396
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
2213
2397
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
2214
2398
|
"success",
|
|
2215
2399
|
"ok",
|
|
@@ -2219,27 +2403,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
2219
2403
|
]);
|
|
2220
2404
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
2221
2405
|
function getMemberName(member) {
|
|
2222
|
-
if (member.type !==
|
|
2406
|
+
if (member.type !== import_utils16.AST_NODE_TYPES.TSPropertySignature) {
|
|
2223
2407
|
return null;
|
|
2224
2408
|
}
|
|
2225
2409
|
const { key } = member;
|
|
2226
|
-
if (key.type ===
|
|
2410
|
+
if (key.type === import_utils16.AST_NODE_TYPES.Identifier) {
|
|
2227
2411
|
return key.name;
|
|
2228
2412
|
}
|
|
2229
|
-
if (key.type ===
|
|
2413
|
+
if (key.type === import_utils16.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
2230
2414
|
return key.value;
|
|
2231
2415
|
}
|
|
2232
2416
|
return null;
|
|
2233
2417
|
}
|
|
2234
2418
|
function isBooleanTyped(member) {
|
|
2235
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
2419
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils16.AST_NODE_TYPES.TSBooleanKeyword;
|
|
2236
2420
|
}
|
|
2237
2421
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
2238
2422
|
let hasStatusBoolean = false;
|
|
2239
2423
|
let optionalCount = 0;
|
|
2240
2424
|
let optionalPayloadCount = 0;
|
|
2241
2425
|
for (const member of typeLiteral.members) {
|
|
2242
|
-
if (member.type !==
|
|
2426
|
+
if (member.type !== import_utils16.AST_NODE_TYPES.TSPropertySignature) {
|
|
2243
2427
|
continue;
|
|
2244
2428
|
}
|
|
2245
2429
|
if (member.optional) {
|
|
@@ -2255,7 +2439,7 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
2255
2439
|
}
|
|
2256
2440
|
return hasStatusBoolean && optionalCount >= MIN_OPTIONAL_MEMBERS && optionalPayloadCount >= 1;
|
|
2257
2441
|
}
|
|
2258
|
-
var prefer_discriminated_union_default =
|
|
2442
|
+
var prefer_discriminated_union_default = import_utils15.ESLintUtils.RuleCreator(
|
|
2259
2443
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2260
2444
|
)({
|
|
2261
2445
|
name: "prefer-discriminated-union",
|
|
@@ -2283,7 +2467,7 @@ var prefer_discriminated_union_default = import_utils14.ESLintUtils.RuleCreator(
|
|
|
2283
2467
|
TSInterfaceDeclaration(node) {
|
|
2284
2468
|
const synthetic = {
|
|
2285
2469
|
...node.body,
|
|
2286
|
-
type:
|
|
2470
|
+
type: import_utils16.AST_NODE_TYPES.TSTypeLiteral,
|
|
2287
2471
|
members: node.body.body
|
|
2288
2472
|
};
|
|
2289
2473
|
checkTypeLiteral(synthetic, node);
|
|
@@ -2296,13 +2480,13 @@ var prefer_discriminated_union_default = import_utils14.ESLintUtils.RuleCreator(
|
|
|
2296
2480
|
});
|
|
2297
2481
|
|
|
2298
2482
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
2299
|
-
var
|
|
2483
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
2300
2484
|
var unwrap = (node) => {
|
|
2301
2485
|
let current = node;
|
|
2302
2486
|
while (current !== null && current !== void 0) {
|
|
2303
|
-
if (current.type ===
|
|
2487
|
+
if (current.type === import_utils17.AST_NODE_TYPES.TSAsExpression || current.type === import_utils17.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils17.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils17.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2304
2488
|
current = current.expression;
|
|
2305
|
-
} else if (current.type ===
|
|
2489
|
+
} else if (current.type === import_utils17.AST_NODE_TYPES.ChainExpression) {
|
|
2306
2490
|
current = current.expression;
|
|
2307
2491
|
} else {
|
|
2308
2492
|
break;
|
|
@@ -2313,25 +2497,25 @@ var unwrap = (node) => {
|
|
|
2313
2497
|
var isRawPayloadSource = (node) => {
|
|
2314
2498
|
let current = unwrap(node);
|
|
2315
2499
|
if (current === null) return false;
|
|
2316
|
-
if (current.type ===
|
|
2500
|
+
if (current.type === import_utils17.AST_NODE_TYPES.AwaitExpression) {
|
|
2317
2501
|
current = unwrap(current.argument);
|
|
2318
2502
|
}
|
|
2319
|
-
if (current === null || current.type !==
|
|
2503
|
+
if (current === null || current.type !== import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2320
2504
|
return false;
|
|
2321
2505
|
}
|
|
2322
2506
|
const callee = unwrap(current.callee);
|
|
2323
|
-
if (callee === null || callee.type !==
|
|
2507
|
+
if (callee === null || callee.type !== import_utils17.AST_NODE_TYPES.MemberExpression) {
|
|
2324
2508
|
return false;
|
|
2325
2509
|
}
|
|
2326
2510
|
const property = unwrap(callee.property);
|
|
2327
|
-
if (property === null || property.type !==
|
|
2511
|
+
if (property === null || property.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2328
2512
|
return false;
|
|
2329
2513
|
}
|
|
2330
2514
|
if (property.name === "json") {
|
|
2331
2515
|
return true;
|
|
2332
2516
|
}
|
|
2333
2517
|
const object = unwrap(callee.object);
|
|
2334
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
2518
|
+
return property.name === "parse" && object !== null && object.type === import_utils17.AST_NODE_TYPES.Identifier && object.name === "JSON" && // ...but not `JSON.parse(readFileSync(p, "utf8"))` — see isLocalFileRead.
|
|
2335
2519
|
!isLocalFileRead(current.arguments[0]);
|
|
2336
2520
|
};
|
|
2337
2521
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
@@ -2339,9 +2523,9 @@ var isLocalFileRead = (node) => {
|
|
|
2339
2523
|
let found = false;
|
|
2340
2524
|
const visit = (current) => {
|
|
2341
2525
|
if (found || current === null || current === void 0) return;
|
|
2342
|
-
if (current.type ===
|
|
2526
|
+
if (current.type === import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2343
2527
|
const callee = unwrap(current.callee);
|
|
2344
|
-
const name = callee?.type ===
|
|
2528
|
+
const name = callee?.type === import_utils17.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils17.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils17.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
2345
2529
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
2346
2530
|
found = true;
|
|
2347
2531
|
return;
|
|
@@ -2363,15 +2547,15 @@ var isLocalFileRead = (node) => {
|
|
|
2363
2547
|
var ASSERTION_CALLEE_RE2 = /^(expect|assert|should|invariant)$/;
|
|
2364
2548
|
var isInsideAssertion = (node) => {
|
|
2365
2549
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
2366
|
-
if (current.type !==
|
|
2550
|
+
if (current.type !== import_utils17.AST_NODE_TYPES.CallExpression) continue;
|
|
2367
2551
|
let callee = current.callee;
|
|
2368
|
-
while (callee.type ===
|
|
2552
|
+
while (callee.type === import_utils17.AST_NODE_TYPES.MemberExpression) {
|
|
2369
2553
|
callee = callee.object;
|
|
2370
2554
|
}
|
|
2371
|
-
if (callee.type ===
|
|
2555
|
+
if (callee.type === import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2372
2556
|
callee = callee.callee;
|
|
2373
2557
|
}
|
|
2374
|
-
if (callee.type ===
|
|
2558
|
+
if (callee.type === import_utils17.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE2.test(callee.name)) {
|
|
2375
2559
|
return true;
|
|
2376
2560
|
}
|
|
2377
2561
|
}
|
|
@@ -2392,17 +2576,17 @@ var isGuardTestPosition = (node) => {
|
|
|
2392
2576
|
let parent = current.parent;
|
|
2393
2577
|
while (parent !== void 0 && parent !== null) {
|
|
2394
2578
|
switch (parent.type) {
|
|
2395
|
-
case
|
|
2396
|
-
case
|
|
2397
|
-
case
|
|
2579
|
+
case import_utils17.AST_NODE_TYPES.UnaryExpression:
|
|
2580
|
+
case import_utils17.AST_NODE_TYPES.LogicalExpression:
|
|
2581
|
+
case import_utils17.AST_NODE_TYPES.ChainExpression:
|
|
2398
2582
|
current = parent;
|
|
2399
2583
|
parent = parent.parent;
|
|
2400
2584
|
continue;
|
|
2401
|
-
case
|
|
2402
|
-
case
|
|
2403
|
-
case
|
|
2404
|
-
case
|
|
2405
|
-
case
|
|
2585
|
+
case import_utils17.AST_NODE_TYPES.IfStatement:
|
|
2586
|
+
case import_utils17.AST_NODE_TYPES.ConditionalExpression:
|
|
2587
|
+
case import_utils17.AST_NODE_TYPES.WhileStatement:
|
|
2588
|
+
case import_utils17.AST_NODE_TYPES.DoWhileStatement:
|
|
2589
|
+
case import_utils17.AST_NODE_TYPES.ForStatement:
|
|
2406
2590
|
return parent.test === current;
|
|
2407
2591
|
default:
|
|
2408
2592
|
return false;
|
|
@@ -2412,13 +2596,13 @@ var isGuardTestPosition = (node) => {
|
|
|
2412
2596
|
};
|
|
2413
2597
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
2414
2598
|
const unwrapped = unwrap(node);
|
|
2415
|
-
if (unwrapped === null || unwrapped.type !==
|
|
2599
|
+
if (unwrapped === null || unwrapped.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2416
2600
|
return false;
|
|
2417
2601
|
}
|
|
2418
2602
|
const variable = findVariable2(scope, unwrapped.name);
|
|
2419
2603
|
return variable !== null && tracked.has(variable);
|
|
2420
2604
|
};
|
|
2421
|
-
var prefer_schema_for_api_payload_default =
|
|
2605
|
+
var prefer_schema_for_api_payload_default = import_utils17.ESLintUtils.RuleCreator(
|
|
2422
2606
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2423
2607
|
)({
|
|
2424
2608
|
name: "prefer-schema-for-api-payload",
|
|
@@ -2434,7 +2618,7 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2434
2618
|
},
|
|
2435
2619
|
defaultOptions: [],
|
|
2436
2620
|
create(context) {
|
|
2437
|
-
if (isTestFile(context.filename)) {
|
|
2621
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
2438
2622
|
return {};
|
|
2439
2623
|
}
|
|
2440
2624
|
const unvalidatedVariables = /* @__PURE__ */ new Set();
|
|
@@ -2449,11 +2633,11 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2449
2633
|
return {
|
|
2450
2634
|
VariableDeclarator(node) {
|
|
2451
2635
|
const scope = context.sourceCode.getScope(node);
|
|
2452
|
-
if (node.id.type ===
|
|
2636
|
+
if (node.id.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2453
2637
|
trackInitializer(node);
|
|
2454
2638
|
return;
|
|
2455
2639
|
}
|
|
2456
|
-
if (node.id.type ===
|
|
2640
|
+
if (node.id.type === import_utils17.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils17.AST_NODE_TYPES.ArrayPattern) {
|
|
2457
2641
|
if (isRawPayloadSource(node.init)) {
|
|
2458
2642
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
2459
2643
|
return;
|
|
@@ -2465,7 +2649,7 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2465
2649
|
},
|
|
2466
2650
|
AssignmentExpression(node) {
|
|
2467
2651
|
const scope = context.sourceCode.getScope(node);
|
|
2468
|
-
if (node.left.type ===
|
|
2652
|
+
if (node.left.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2469
2653
|
const variable = findVariable2(scope, node.left.name);
|
|
2470
2654
|
if (variable === null) return;
|
|
2471
2655
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -2475,7 +2659,7 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2475
2659
|
}
|
|
2476
2660
|
return;
|
|
2477
2661
|
}
|
|
2478
|
-
if (node.left.type ===
|
|
2662
|
+
if (node.left.type === import_utils17.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils17.AST_NODE_TYPES.ArrayPattern) {
|
|
2479
2663
|
if (isRawPayloadSource(node.right)) {
|
|
2480
2664
|
context.report({
|
|
2481
2665
|
node: node.left,
|
|
@@ -2492,15 +2676,15 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2492
2676
|
}
|
|
2493
2677
|
},
|
|
2494
2678
|
CallExpression(node) {
|
|
2495
|
-
if (node.callee.type !==
|
|
2679
|
+
if (node.callee.type !== import_utils17.AST_NODE_TYPES.Identifier) return;
|
|
2496
2680
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
2497
2681
|
return;
|
|
2498
2682
|
}
|
|
2499
2683
|
const scope = context.sourceCode.getScope(node);
|
|
2500
2684
|
for (const arg of node.arguments) {
|
|
2501
|
-
if (arg.type ===
|
|
2685
|
+
if (arg.type === import_utils17.AST_NODE_TYPES.SpreadElement) continue;
|
|
2502
2686
|
const unwrapped = unwrap(arg);
|
|
2503
|
-
if (unwrapped === null || unwrapped.type !==
|
|
2687
|
+
if (unwrapped === null || unwrapped.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2504
2688
|
continue;
|
|
2505
2689
|
}
|
|
2506
2690
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -2513,13 +2697,13 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2513
2697
|
const obj = unwrap(node.object);
|
|
2514
2698
|
if (isRawPayloadSource(obj)) {
|
|
2515
2699
|
const parent = node.parent;
|
|
2516
|
-
if (parent.type ===
|
|
2700
|
+
if (parent.type === import_utils17.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils17.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse")) {
|
|
2517
2701
|
return;
|
|
2518
2702
|
}
|
|
2519
2703
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
2520
2704
|
return;
|
|
2521
2705
|
}
|
|
2522
|
-
if (obj !== null && obj.type ===
|
|
2706
|
+
if (obj !== null && obj.type === import_utils17.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
2523
2707
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
2524
2708
|
const variable = findVariable2(scope, obj.name);
|
|
2525
2709
|
if (variable !== null) {
|
|
@@ -2532,7 +2716,7 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2532
2716
|
});
|
|
2533
2717
|
|
|
2534
2718
|
// src/rules/prefer-semantic-colors.ts
|
|
2535
|
-
var
|
|
2719
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
2536
2720
|
var import_fs = require("fs");
|
|
2537
2721
|
var import_path = require("path");
|
|
2538
2722
|
|
|
@@ -2604,10 +2788,32 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
2604
2788
|
"currentcolor",
|
|
2605
2789
|
"inherit"
|
|
2606
2790
|
]);
|
|
2791
|
+
function jsxElementName(node) {
|
|
2792
|
+
const name = node.openingElement.name;
|
|
2793
|
+
if (name.type === import_utils18.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
2794
|
+
if (name.type === import_utils18.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils18.AST_NODE_TYPES.JSXIdentifier) {
|
|
2795
|
+
return name.property.name;
|
|
2796
|
+
}
|
|
2797
|
+
return null;
|
|
2798
|
+
}
|
|
2799
|
+
function isSvgLikeElementName(name) {
|
|
2800
|
+
return name === "svg" || SVG_DEFS_CONTAINERS.has(name) || /svg$/i.test(name);
|
|
2801
|
+
}
|
|
2607
2802
|
var isInsideSvg = (node) => {
|
|
2608
2803
|
let current = node.parent;
|
|
2609
2804
|
while (current !== void 0 && current !== null) {
|
|
2610
|
-
if (current.type ===
|
|
2805
|
+
if (current.type === import_utils18.AST_NODE_TYPES.JSXElement) {
|
|
2806
|
+
const name = jsxElementName(current);
|
|
2807
|
+
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
2808
|
+
}
|
|
2809
|
+
current = current.parent;
|
|
2810
|
+
}
|
|
2811
|
+
return false;
|
|
2812
|
+
};
|
|
2813
|
+
var isInsideIconFactoryPath = (node) => {
|
|
2814
|
+
let current = node.parent;
|
|
2815
|
+
while (current !== void 0 && current !== null) {
|
|
2816
|
+
if (current.type === import_utils18.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils18.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils18.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils18.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
2611
2817
|
return true;
|
|
2612
2818
|
}
|
|
2613
2819
|
current = current.parent;
|
|
@@ -2643,11 +2849,11 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
2643
2849
|
return false;
|
|
2644
2850
|
};
|
|
2645
2851
|
var propName = (key) => {
|
|
2646
|
-
if (key.type ===
|
|
2647
|
-
if (key.type ===
|
|
2852
|
+
if (key.type === import_utils18.AST_NODE_TYPES.Identifier) return key.name;
|
|
2853
|
+
if (key.type === import_utils18.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
2648
2854
|
return null;
|
|
2649
2855
|
};
|
|
2650
|
-
var prefer_semantic_colors_default =
|
|
2856
|
+
var prefer_semantic_colors_default = import_utils18.ESLintUtils.RuleCreator(
|
|
2651
2857
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2652
2858
|
)({
|
|
2653
2859
|
name: "prefer-semantic-colors",
|
|
@@ -2690,27 +2896,27 @@ var prefer_semantic_colors_default = import_utils17.ESLintUtils.RuleCreator(
|
|
|
2690
2896
|
const checkClassNode = (node) => {
|
|
2691
2897
|
if (node === null) return;
|
|
2692
2898
|
switch (node.type) {
|
|
2693
|
-
case
|
|
2899
|
+
case import_utils18.AST_NODE_TYPES.Literal:
|
|
2694
2900
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
2695
2901
|
break;
|
|
2696
|
-
case
|
|
2902
|
+
case import_utils18.AST_NODE_TYPES.TemplateLiteral:
|
|
2697
2903
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
2698
2904
|
break;
|
|
2699
|
-
case
|
|
2905
|
+
case import_utils18.AST_NODE_TYPES.ArrayExpression:
|
|
2700
2906
|
for (const element of node.elements) {
|
|
2701
|
-
if (element !== null && element.type !==
|
|
2907
|
+
if (element !== null && element.type !== import_utils18.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
2702
2908
|
}
|
|
2703
2909
|
break;
|
|
2704
|
-
case
|
|
2910
|
+
case import_utils18.AST_NODE_TYPES.ObjectExpression:
|
|
2705
2911
|
for (const property of node.properties) {
|
|
2706
|
-
if (property.type ===
|
|
2912
|
+
if (property.type === import_utils18.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
2707
2913
|
}
|
|
2708
2914
|
break;
|
|
2709
|
-
case
|
|
2915
|
+
case import_utils18.AST_NODE_TYPES.ConditionalExpression:
|
|
2710
2916
|
checkClassNode(node.consequent);
|
|
2711
2917
|
checkClassNode(node.alternate);
|
|
2712
2918
|
break;
|
|
2713
|
-
case
|
|
2919
|
+
case import_utils18.AST_NODE_TYPES.LogicalExpression:
|
|
2714
2920
|
checkClassNode(node.right);
|
|
2715
2921
|
break;
|
|
2716
2922
|
default:
|
|
@@ -2718,29 +2924,29 @@ var prefer_semantic_colors_default = import_utils17.ESLintUtils.RuleCreator(
|
|
|
2718
2924
|
}
|
|
2719
2925
|
};
|
|
2720
2926
|
const checkColorValueNode = (node) => {
|
|
2721
|
-
if (node.type ===
|
|
2927
|
+
if (node.type === import_utils18.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value)) {
|
|
2722
2928
|
context.report({ node, messageId: "inlineColor", data: { value: node.value } });
|
|
2723
2929
|
}
|
|
2724
2930
|
};
|
|
2725
2931
|
return {
|
|
2726
2932
|
"JSXAttribute[name.name='className']"(node) {
|
|
2727
2933
|
if (node.value === null) return;
|
|
2728
|
-
if (node.value.type ===
|
|
2729
|
-
else if (node.value.type ===
|
|
2730
|
-
if (node.value.expression.type !==
|
|
2934
|
+
if (node.value.type === import_utils18.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
2935
|
+
else if (node.value.type === import_utils18.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
2936
|
+
if (node.value.expression.type !== import_utils18.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
2731
2937
|
checkClassNode(node.value.expression);
|
|
2732
2938
|
}
|
|
2733
2939
|
}
|
|
2734
2940
|
},
|
|
2735
2941
|
CallExpression(node) {
|
|
2736
|
-
if (node.callee.type ===
|
|
2942
|
+
if (node.callee.type === import_utils18.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
2737
2943
|
for (const arg of node.arguments) {
|
|
2738
|
-
if (arg.type !==
|
|
2944
|
+
if (arg.type !== import_utils18.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
2739
2945
|
}
|
|
2740
2946
|
}
|
|
2741
2947
|
},
|
|
2742
2948
|
VariableDeclarator(node) {
|
|
2743
|
-
if (node.id.type ===
|
|
2949
|
+
if (node.id.type === import_utils18.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
2744
2950
|
checkClassNode(node.init);
|
|
2745
2951
|
}
|
|
2746
2952
|
},
|
|
@@ -2752,11 +2958,11 @@ var prefer_semantic_colors_default = import_utils17.ESLintUtils.RuleCreator(
|
|
|
2752
2958
|
// Neutral drawing literals and anything inside an SVG defs container are
|
|
2753
2959
|
// structural, not UI tokens, so they never fire.
|
|
2754
2960
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
2755
|
-
if (node.value?.type !==
|
|
2961
|
+
if (node.value?.type !== import_utils18.AST_NODE_TYPES.Literal) return;
|
|
2756
2962
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
2757
2963
|
return;
|
|
2758
2964
|
}
|
|
2759
|
-
if (isInsideSvg(node)) return;
|
|
2965
|
+
if (isInsideSvg(node) || isInsideIconFactoryPath(node)) return;
|
|
2760
2966
|
checkColorValueNode(node.value);
|
|
2761
2967
|
},
|
|
2762
2968
|
// Inline style objects: style={{ color: "#111827", backgroundColor: "#fff" }}
|
|
@@ -2769,7 +2975,7 @@ var prefer_semantic_colors_default = import_utils17.ESLintUtils.RuleCreator(
|
|
|
2769
2975
|
});
|
|
2770
2976
|
|
|
2771
2977
|
// src/rules/prefer-server-actions.ts
|
|
2772
|
-
var
|
|
2978
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
2773
2979
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
2774
2980
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
2775
2981
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
@@ -2849,7 +3055,7 @@ function getPropertyNode(objNode, propName2) {
|
|
|
2849
3055
|
}
|
|
2850
3056
|
return null;
|
|
2851
3057
|
}
|
|
2852
|
-
var prefer_server_actions_default =
|
|
3058
|
+
var prefer_server_actions_default = import_utils19.ESLintUtils.RuleCreator(
|
|
2853
3059
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2854
3060
|
)({
|
|
2855
3061
|
name: "prefer-server-actions",
|
|
@@ -2924,7 +3130,7 @@ var prefer_server_actions_default = import_utils18.ESLintUtils.RuleCreator(
|
|
|
2924
3130
|
});
|
|
2925
3131
|
|
|
2926
3132
|
// src/rules/prefer-shadcn.ts
|
|
2927
|
-
var
|
|
3133
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
2928
3134
|
var REPLACEMENTS = {
|
|
2929
3135
|
select: "Select",
|
|
2930
3136
|
textarea: "Textarea",
|
|
@@ -2939,10 +3145,10 @@ var SKIPPED_INPUT_TYPES = /* @__PURE__ */ new Set(["file", "hidden"]);
|
|
|
2939
3145
|
var kebabCase = (component) => component.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2940
3146
|
var literalTypeAttr = (node) => {
|
|
2941
3147
|
for (const attribute of node.attributes) {
|
|
2942
|
-
if (attribute.type !==
|
|
3148
|
+
if (attribute.type !== import_utils20.AST_NODE_TYPES.JSXAttribute || attribute.name.type !== import_utils20.AST_NODE_TYPES.JSXIdentifier || attribute.name.name !== "type") {
|
|
2943
3149
|
continue;
|
|
2944
3150
|
}
|
|
2945
|
-
if (attribute.value?.type ===
|
|
3151
|
+
if (attribute.value?.type === import_utils20.AST_NODE_TYPES.Literal && typeof attribute.value.value === "string") {
|
|
2946
3152
|
return { kind: "literal", value: attribute.value.value.toLowerCase() };
|
|
2947
3153
|
}
|
|
2948
3154
|
return { kind: "dynamic" };
|
|
@@ -2950,7 +3156,7 @@ var literalTypeAttr = (node) => {
|
|
|
2950
3156
|
return null;
|
|
2951
3157
|
};
|
|
2952
3158
|
var hasFileAcceptAttr = (node) => node.attributes.some(
|
|
2953
|
-
(attribute) => attribute.type ===
|
|
3159
|
+
(attribute) => attribute.type === import_utils20.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils20.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "accept"
|
|
2954
3160
|
);
|
|
2955
3161
|
var resolveInputReplacement = (node) => {
|
|
2956
3162
|
const typeAttr = literalTypeAttr(node);
|
|
@@ -2959,7 +3165,7 @@ var resolveInputReplacement = (node) => {
|
|
|
2959
3165
|
if (SKIPPED_INPUT_TYPES.has(typeAttr.value)) return null;
|
|
2960
3166
|
return INPUT_TYPE_REPLACEMENTS[typeAttr.value] ?? "Input";
|
|
2961
3167
|
};
|
|
2962
|
-
var prefer_shadcn_default =
|
|
3168
|
+
var prefer_shadcn_default = import_utils20.ESLintUtils.RuleCreator(
|
|
2963
3169
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2964
3170
|
)({
|
|
2965
3171
|
name: "prefer-shadcn",
|
|
@@ -3003,36 +3209,36 @@ var prefer_shadcn_default = import_utils19.ESLintUtils.RuleCreator(
|
|
|
3003
3209
|
});
|
|
3004
3210
|
|
|
3005
3211
|
// src/rules/require-assert-never.ts
|
|
3006
|
-
var
|
|
3212
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3007
3213
|
var isAssertNeverCall = (expression) => {
|
|
3008
|
-
if (expression.type !==
|
|
3214
|
+
if (expression.type !== import_utils21.AST_NODE_TYPES.CallExpression) return false;
|
|
3009
3215
|
const callee = expression.callee;
|
|
3010
|
-
if (callee.type ===
|
|
3216
|
+
if (callee.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3011
3217
|
return callee.name === "assertNever";
|
|
3012
3218
|
}
|
|
3013
|
-
if (callee.type ===
|
|
3219
|
+
if (callee.type === import_utils21.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3014
3220
|
return callee.property.name === "assertNever";
|
|
3015
3221
|
}
|
|
3016
3222
|
return false;
|
|
3017
3223
|
};
|
|
3018
3224
|
var statementContainsAssertNever = (statement) => {
|
|
3019
|
-
if (statement.type ===
|
|
3225
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ExpressionStatement) {
|
|
3020
3226
|
return isAssertNeverCall(statement.expression);
|
|
3021
3227
|
}
|
|
3022
|
-
if (statement.type ===
|
|
3228
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ThrowStatement) {
|
|
3023
3229
|
return isAssertNeverCall(statement.argument);
|
|
3024
3230
|
}
|
|
3025
|
-
if (statement.type ===
|
|
3231
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ReturnStatement) {
|
|
3026
3232
|
return statement.argument !== null && isAssertNeverCall(statement.argument);
|
|
3027
3233
|
}
|
|
3028
|
-
if (statement.type ===
|
|
3234
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.BlockStatement) {
|
|
3029
3235
|
return statement.body.some(statementContainsAssertNever);
|
|
3030
3236
|
}
|
|
3031
3237
|
return false;
|
|
3032
3238
|
};
|
|
3033
3239
|
var isRuntimeHandlingStatement = (statement) => {
|
|
3034
|
-
if (statement.type ===
|
|
3035
|
-
if (statement.type ===
|
|
3240
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.EmptyStatement) return false;
|
|
3241
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.BlockStatement) {
|
|
3036
3242
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
3037
3243
|
}
|
|
3038
3244
|
return true;
|
|
@@ -3048,12 +3254,12 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
3048
3254
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
3049
3255
|
}
|
|
3050
3256
|
const only = defaultCase.consequent[0];
|
|
3051
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
3257
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils21.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
3052
3258
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
3053
3259
|
}
|
|
3054
3260
|
return false;
|
|
3055
3261
|
};
|
|
3056
|
-
var require_assert_never_default =
|
|
3262
|
+
var require_assert_never_default = import_utils21.ESLintUtils.RuleCreator(
|
|
3057
3263
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3058
3264
|
)({
|
|
3059
3265
|
name: "require-assert-never",
|
|
@@ -3091,7 +3297,7 @@ var require_assert_never_default = import_utils20.ESLintUtils.RuleCreator(
|
|
|
3091
3297
|
});
|
|
3092
3298
|
|
|
3093
3299
|
// src/rules/require-zod-form-validation.ts
|
|
3094
|
-
var
|
|
3300
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3095
3301
|
|
|
3096
3302
|
// src/rules/_zod.ts
|
|
3097
3303
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -3102,14 +3308,14 @@ var ZOD_SCHEMA_NAME_RE = /Schema$|^Z[A-Z]/;
|
|
|
3102
3308
|
var looksLikeZodSchema = (node) => {
|
|
3103
3309
|
let current = node;
|
|
3104
3310
|
while (true) {
|
|
3105
|
-
if (current.type ===
|
|
3311
|
+
if (current.type === import_utils22.AST_NODE_TYPES.Identifier) {
|
|
3106
3312
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
3107
3313
|
}
|
|
3108
|
-
if (current.type ===
|
|
3314
|
+
if (current.type === import_utils22.AST_NODE_TYPES.CallExpression) {
|
|
3109
3315
|
current = current.callee;
|
|
3110
3316
|
continue;
|
|
3111
3317
|
}
|
|
3112
|
-
if (current.type ===
|
|
3318
|
+
if (current.type === import_utils22.AST_NODE_TYPES.MemberExpression) {
|
|
3113
3319
|
current = current.object;
|
|
3114
3320
|
continue;
|
|
3115
3321
|
}
|
|
@@ -3117,25 +3323,25 @@ var looksLikeZodSchema = (node) => {
|
|
|
3117
3323
|
}
|
|
3118
3324
|
};
|
|
3119
3325
|
var isZodParseCall = (node) => {
|
|
3120
|
-
if (node.type !==
|
|
3326
|
+
if (node.type !== import_utils22.AST_NODE_TYPES.CallExpression) return false;
|
|
3121
3327
|
const callee = node.callee;
|
|
3122
|
-
if (callee.type !==
|
|
3328
|
+
if (callee.type !== import_utils22.AST_NODE_TYPES.MemberExpression) return false;
|
|
3123
3329
|
if (callee.computed) return false;
|
|
3124
|
-
if (callee.property.type !==
|
|
3330
|
+
if (callee.property.type !== import_utils22.AST_NODE_TYPES.Identifier) return false;
|
|
3125
3331
|
const method = callee.property.name;
|
|
3126
3332
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
3127
3333
|
return looksLikeZodSchema(callee.object);
|
|
3128
3334
|
};
|
|
3129
3335
|
var isFormDataMethodCall = (node) => {
|
|
3130
3336
|
let current = node;
|
|
3131
|
-
if (current.type ===
|
|
3337
|
+
if (current.type === import_utils22.AST_NODE_TYPES.AwaitExpression) {
|
|
3132
3338
|
current = current.argument;
|
|
3133
3339
|
}
|
|
3134
|
-
if (current.type !==
|
|
3340
|
+
if (current.type !== import_utils22.AST_NODE_TYPES.CallExpression) return false;
|
|
3135
3341
|
const callee = current.callee;
|
|
3136
|
-
return callee.type ===
|
|
3342
|
+
return callee.type === import_utils22.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils22.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
3137
3343
|
};
|
|
3138
|
-
var require_zod_form_validation_default =
|
|
3344
|
+
var require_zod_form_validation_default = import_utils22.ESLintUtils.RuleCreator(
|
|
3139
3345
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3140
3346
|
)({
|
|
3141
3347
|
name: "require-zod-form-validation",
|
|
@@ -3155,14 +3361,14 @@ var require_zod_form_validation_default = import_utils21.ESLintUtils.RuleCreator
|
|
|
3155
3361
|
return {};
|
|
3156
3362
|
}
|
|
3157
3363
|
const isFormSourceIdentifier = (node) => {
|
|
3158
|
-
if (node.type !==
|
|
3364
|
+
if (node.type !== import_utils22.AST_NODE_TYPES.Identifier) return false;
|
|
3159
3365
|
if (/formdata/i.test(node.name)) return true;
|
|
3160
3366
|
let scope = context.sourceCode.getScope(node);
|
|
3161
3367
|
while (scope !== null) {
|
|
3162
3368
|
const variable = scope.set.get(node.name);
|
|
3163
3369
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
3164
3370
|
const def = variable.defs[0];
|
|
3165
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
3371
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils22.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
3166
3372
|
return isFormDataMethodCall(def.node.init);
|
|
3167
3373
|
}
|
|
3168
3374
|
return false;
|
|
@@ -3173,8 +3379,8 @@ var require_zod_form_validation_default = import_utils21.ESLintUtils.RuleCreator
|
|
|
3173
3379
|
};
|
|
3174
3380
|
const isFormDataGetCall = (node) => {
|
|
3175
3381
|
const callee = node.callee;
|
|
3176
|
-
if (callee.type !==
|
|
3177
|
-
if (callee.property.type !==
|
|
3382
|
+
if (callee.type !== import_utils22.AST_NODE_TYPES.MemberExpression) return false;
|
|
3383
|
+
if (callee.property.type !== import_utils22.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
3178
3384
|
return false;
|
|
3179
3385
|
}
|
|
3180
3386
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -3189,11 +3395,11 @@ var require_zod_form_validation_default = import_utils21.ESLintUtils.RuleCreator
|
|
|
3189
3395
|
};
|
|
3190
3396
|
const isInstanceofNarrowing = (node) => {
|
|
3191
3397
|
const parent = node.parent;
|
|
3192
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
3398
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils22.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node;
|
|
3193
3399
|
};
|
|
3194
3400
|
const boundDeclarator = (node) => {
|
|
3195
3401
|
const parent = node.parent;
|
|
3196
|
-
if (parent.type ===
|
|
3402
|
+
if (parent.type === import_utils22.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils22.AST_NODE_TYPES.Identifier) {
|
|
3197
3403
|
return parent;
|
|
3198
3404
|
}
|
|
3199
3405
|
return null;
|
|
@@ -3221,7 +3427,7 @@ var require_zod_form_validation_default = import_utils21.ESLintUtils.RuleCreator
|
|
|
3221
3427
|
});
|
|
3222
3428
|
|
|
3223
3429
|
// src/rules/zod-naming-convention.ts
|
|
3224
|
-
var
|
|
3430
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3225
3431
|
var CONVENTIONS = {
|
|
3226
3432
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
3227
3433
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -3245,15 +3451,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
3245
3451
|
"registry",
|
|
3246
3452
|
"implement"
|
|
3247
3453
|
]);
|
|
3248
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
3454
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils23.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
3249
3455
|
var calleeChainStartsWithZ = (node) => {
|
|
3250
3456
|
let current = node;
|
|
3251
|
-
while (current.type ===
|
|
3457
|
+
while (current.type === import_utils23.AST_NODE_TYPES.MemberExpression) {
|
|
3252
3458
|
const receiver = current.object;
|
|
3253
|
-
if (receiver.type ===
|
|
3459
|
+
if (receiver.type === import_utils23.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
3254
3460
|
return true;
|
|
3255
3461
|
}
|
|
3256
|
-
if (receiver.type ===
|
|
3462
|
+
if (receiver.type === import_utils23.AST_NODE_TYPES.CallExpression) {
|
|
3257
3463
|
current = receiver.callee;
|
|
3258
3464
|
continue;
|
|
3259
3465
|
}
|
|
@@ -3261,7 +3467,7 @@ var calleeChainStartsWithZ = (node) => {
|
|
|
3261
3467
|
}
|
|
3262
3468
|
return false;
|
|
3263
3469
|
};
|
|
3264
|
-
var zod_naming_convention_default =
|
|
3470
|
+
var zod_naming_convention_default = import_utils23.ESLintUtils.RuleCreator(
|
|
3265
3471
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3266
3472
|
)({
|
|
3267
3473
|
name: "zod-naming-convention",
|
|
@@ -3300,13 +3506,13 @@ var zod_naming_convention_default = import_utils22.ESLintUtils.RuleCreator(
|
|
|
3300
3506
|
VariableDeclarator(node) {
|
|
3301
3507
|
const init = node.init;
|
|
3302
3508
|
if (init === null || init === void 0) return;
|
|
3303
|
-
if (init.type !==
|
|
3509
|
+
if (init.type !== import_utils23.AST_NODE_TYPES.CallExpression) return;
|
|
3304
3510
|
const callee = init.callee;
|
|
3305
|
-
if (callee.type !==
|
|
3511
|
+
if (callee.type !== import_utils23.AST_NODE_TYPES.MemberExpression) return;
|
|
3306
3512
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
3307
3513
|
const terminal = terminalMethodName(callee);
|
|
3308
3514
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
3309
|
-
if (node.id.type !==
|
|
3515
|
+
if (node.id.type !== import_utils23.AST_NODE_TYPES.Identifier) return;
|
|
3310
3516
|
if (test.test(node.id.name)) return;
|
|
3311
3517
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
3312
3518
|
context.report({
|
|
@@ -3319,7 +3525,7 @@ var zod_naming_convention_default = import_utils22.ESLintUtils.RuleCreator(
|
|
|
3319
3525
|
});
|
|
3320
3526
|
|
|
3321
3527
|
// src/rules/no-cors-wildcard-with-credentials.ts
|
|
3322
|
-
var
|
|
3528
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3323
3529
|
var ACAO_HEADER = "access-control-allow-origin";
|
|
3324
3530
|
var ACAC_HEADER = "access-control-allow-credentials";
|
|
3325
3531
|
var HEADER_SET_METHODS = /* @__PURE__ */ new Set(["setheader", "set", "append"]);
|
|
@@ -3461,7 +3667,7 @@ function enclosingScope(node) {
|
|
|
3461
3667
|
}
|
|
3462
3668
|
return void 0;
|
|
3463
3669
|
}
|
|
3464
|
-
var no_cors_wildcard_with_credentials_default =
|
|
3670
|
+
var no_cors_wildcard_with_credentials_default = import_utils24.ESLintUtils.RuleCreator(
|
|
3465
3671
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3466
3672
|
)({
|
|
3467
3673
|
name: "no-cors-wildcard-with-credentials",
|
|
@@ -3529,9 +3735,9 @@ var no_cors_wildcard_with_credentials_default = import_utils23.ESLintUtils.RuleC
|
|
|
3529
3735
|
});
|
|
3530
3736
|
|
|
3531
3737
|
// src/rules/no-silent-promise-catch.ts
|
|
3532
|
-
var
|
|
3738
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3533
3739
|
function isBodyParseCall(node) {
|
|
3534
|
-
return node.type ===
|
|
3740
|
+
return node.type === import_utils25.AST_NODE_TYPES.CallExpression && node.arguments.length === 0 && node.callee.type === import_utils25.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils25.AST_NODE_TYPES.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
3535
3741
|
}
|
|
3536
3742
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
3537
3743
|
"cancel",
|
|
@@ -3546,21 +3752,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
3546
3752
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
3547
3753
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
3548
3754
|
function isTeardownCall(node) {
|
|
3549
|
-
return node.type ===
|
|
3755
|
+
return node.type === import_utils25.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils25.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils25.AST_NODE_TYPES.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
3550
3756
|
}
|
|
3551
3757
|
function isSilentExpression(node) {
|
|
3552
3758
|
switch (node.type) {
|
|
3553
|
-
case
|
|
3759
|
+
case import_utils25.AST_NODE_TYPES.Literal:
|
|
3554
3760
|
return !("regex" in node);
|
|
3555
|
-
case
|
|
3761
|
+
case import_utils25.AST_NODE_TYPES.Identifier:
|
|
3556
3762
|
return node.name === "undefined";
|
|
3557
|
-
case
|
|
3558
|
-
return node.operator === "void" && node.argument.type ===
|
|
3559
|
-
case
|
|
3763
|
+
case import_utils25.AST_NODE_TYPES.UnaryExpression:
|
|
3764
|
+
return node.operator === "void" && node.argument.type === import_utils25.AST_NODE_TYPES.Literal;
|
|
3765
|
+
case import_utils25.AST_NODE_TYPES.ObjectExpression:
|
|
3560
3766
|
return node.properties.length === 0;
|
|
3561
|
-
case
|
|
3767
|
+
case import_utils25.AST_NODE_TYPES.ArrayExpression:
|
|
3562
3768
|
return node.elements.length === 0;
|
|
3563
|
-
case
|
|
3769
|
+
case import_utils25.AST_NODE_TYPES.TSAsExpression:
|
|
3564
3770
|
return isSilentExpression(node.expression);
|
|
3565
3771
|
default:
|
|
3566
3772
|
return false;
|
|
@@ -3568,7 +3774,7 @@ function isSilentExpression(node) {
|
|
|
3568
3774
|
}
|
|
3569
3775
|
function isSilentHandler(handler) {
|
|
3570
3776
|
const body = handler.body;
|
|
3571
|
-
if (body.type !==
|
|
3777
|
+
if (body.type !== import_utils25.AST_NODE_TYPES.BlockStatement) {
|
|
3572
3778
|
return isSilentExpression(body);
|
|
3573
3779
|
}
|
|
3574
3780
|
if (body.body.length === 0) {
|
|
@@ -3576,13 +3782,13 @@ function isSilentHandler(handler) {
|
|
|
3576
3782
|
}
|
|
3577
3783
|
if (body.body.length === 1) {
|
|
3578
3784
|
const only = body.body[0];
|
|
3579
|
-
if (only !== void 0 && only.type ===
|
|
3785
|
+
if (only !== void 0 && only.type === import_utils25.AST_NODE_TYPES.ReturnStatement) {
|
|
3580
3786
|
return only.argument === null || isSilentExpression(only.argument);
|
|
3581
3787
|
}
|
|
3582
3788
|
}
|
|
3583
3789
|
return false;
|
|
3584
3790
|
}
|
|
3585
|
-
var no_silent_promise_catch_default =
|
|
3791
|
+
var no_silent_promise_catch_default = import_utils25.ESLintUtils.RuleCreator(
|
|
3586
3792
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3587
3793
|
)({
|
|
3588
3794
|
name: "no-silent-promise-catch",
|
|
@@ -3607,7 +3813,7 @@ var no_silent_promise_catch_default = import_utils24.ESLintUtils.RuleCreator(
|
|
|
3607
3813
|
return true;
|
|
3608
3814
|
}
|
|
3609
3815
|
let statement = call;
|
|
3610
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
3816
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== import_utils25.AST_NODE_TYPES.VariableDeclaration) {
|
|
3611
3817
|
statement = statement.parent;
|
|
3612
3818
|
}
|
|
3613
3819
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -3619,7 +3825,7 @@ var no_silent_promise_catch_default = import_utils24.ESLintUtils.RuleCreator(
|
|
|
3619
3825
|
};
|
|
3620
3826
|
return {
|
|
3621
3827
|
CallExpression(node) {
|
|
3622
|
-
if (node.callee.type !==
|
|
3828
|
+
if (node.callee.type !== import_utils25.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.property.type !== import_utils25.AST_NODE_TYPES.Identifier || node.callee.property.name !== "catch") {
|
|
3623
3829
|
return;
|
|
3624
3830
|
}
|
|
3625
3831
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -3628,14 +3834,14 @@ var no_silent_promise_catch_default = import_utils24.ESLintUtils.RuleCreator(
|
|
|
3628
3834
|
if (isTeardownCall(node.callee.object)) {
|
|
3629
3835
|
return;
|
|
3630
3836
|
}
|
|
3631
|
-
if (node.parent.type ===
|
|
3837
|
+
if (node.parent.type === import_utils25.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
3632
3838
|
return;
|
|
3633
3839
|
}
|
|
3634
3840
|
if (node.arguments.length !== 1) {
|
|
3635
3841
|
return;
|
|
3636
3842
|
}
|
|
3637
3843
|
const handler = node.arguments[0];
|
|
3638
|
-
if (handler === void 0 || handler.type !==
|
|
3844
|
+
if (handler === void 0 || handler.type !== import_utils25.AST_NODE_TYPES.ArrowFunctionExpression && handler.type !== import_utils25.AST_NODE_TYPES.FunctionExpression) {
|
|
3639
3845
|
return;
|
|
3640
3846
|
}
|
|
3641
3847
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -3650,7 +3856,7 @@ var no_silent_promise_catch_default = import_utils24.ESLintUtils.RuleCreator(
|
|
|
3650
3856
|
});
|
|
3651
3857
|
|
|
3652
3858
|
// src/rules/require-fetch-timeout.ts
|
|
3653
|
-
var
|
|
3859
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
3654
3860
|
var CODEMOD_FIXTURE_RE = /[\\/]__testfixtures__[\\/]/;
|
|
3655
3861
|
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set([
|
|
3656
3862
|
"globalThis",
|
|
@@ -3667,14 +3873,14 @@ function matchesAnyPattern2(filename, patterns) {
|
|
|
3667
3873
|
return false;
|
|
3668
3874
|
}
|
|
3669
3875
|
function initProvablyLacksSignal(init) {
|
|
3670
|
-
if (init.type !==
|
|
3876
|
+
if (init.type !== import_utils26.AST_NODE_TYPES.ObjectExpression) {
|
|
3671
3877
|
return false;
|
|
3672
3878
|
}
|
|
3673
3879
|
for (const prop of init.properties) {
|
|
3674
|
-
if (prop.type ===
|
|
3880
|
+
if (prop.type === import_utils26.AST_NODE_TYPES.SpreadElement) {
|
|
3675
3881
|
return false;
|
|
3676
3882
|
}
|
|
3677
|
-
if (prop.key.type ===
|
|
3883
|
+
if (prop.key.type === import_utils26.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils26.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
3678
3884
|
return false;
|
|
3679
3885
|
}
|
|
3680
3886
|
if (prop.computed) {
|
|
@@ -3684,9 +3890,9 @@ function initProvablyLacksSignal(init) {
|
|
|
3684
3890
|
return true;
|
|
3685
3891
|
}
|
|
3686
3892
|
function isStringish(node) {
|
|
3687
|
-
return node.type ===
|
|
3893
|
+
return node.type === import_utils26.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils26.AST_NODE_TYPES.TemplateLiteral;
|
|
3688
3894
|
}
|
|
3689
|
-
var require_fetch_timeout_default =
|
|
3895
|
+
var require_fetch_timeout_default = import_utils26.ESLintUtils.RuleCreator(
|
|
3690
3896
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3691
3897
|
)({
|
|
3692
3898
|
name: "require-fetch-timeout",
|
|
@@ -3723,14 +3929,14 @@ var require_fetch_timeout_default = import_utils25.ESLintUtils.RuleCreator(
|
|
|
3723
3929
|
}
|
|
3724
3930
|
function resolvesToGlobal(identifier) {
|
|
3725
3931
|
const scope = context.sourceCode.getScope(identifier);
|
|
3726
|
-
const variable =
|
|
3932
|
+
const variable = import_utils26.ASTUtils.findVariable(scope, identifier.name);
|
|
3727
3933
|
return variable === null || variable.defs.length === 0;
|
|
3728
3934
|
}
|
|
3729
3935
|
function isGlobalFetchCall2(callee) {
|
|
3730
|
-
if (callee.type ===
|
|
3936
|
+
if (callee.type === import_utils26.AST_NODE_TYPES.Identifier) {
|
|
3731
3937
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
3732
3938
|
}
|
|
3733
|
-
return callee.type ===
|
|
3939
|
+
return callee.type === import_utils26.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils26.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils26.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
3734
3940
|
}
|
|
3735
3941
|
return {
|
|
3736
3942
|
CallExpression(node) {
|
|
@@ -3750,23 +3956,23 @@ var require_fetch_timeout_default = import_utils25.ESLintUtils.RuleCreator(
|
|
|
3750
3956
|
});
|
|
3751
3957
|
|
|
3752
3958
|
// src/rules/require-schema-validate-search.ts
|
|
3753
|
-
var
|
|
3959
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
3754
3960
|
var VALIDATOR_METHODS = /* @__PURE__ */ new Set([
|
|
3755
3961
|
"parse",
|
|
3756
3962
|
"safeParse",
|
|
3757
3963
|
"decode"
|
|
3758
3964
|
]);
|
|
3759
3965
|
function isConstTypeAnnotation(typeAnnotation) {
|
|
3760
|
-
return typeAnnotation.type ===
|
|
3966
|
+
return typeAnnotation.type === import_utils27.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeName.type === import_utils27.AST_NODE_TYPES.Identifier && typeAnnotation.typeName.name === "const";
|
|
3761
3967
|
}
|
|
3762
3968
|
function isValidatorCall(node) {
|
|
3763
|
-
return node.callee.type ===
|
|
3969
|
+
return node.callee.type === import_utils27.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils27.AST_NODE_TYPES.Identifier && VALIDATOR_METHODS.has(node.callee.property.name);
|
|
3764
3970
|
}
|
|
3765
3971
|
function findCastExpression(node, insideValidatorArg) {
|
|
3766
|
-
if ((node.type ===
|
|
3972
|
+
if ((node.type === import_utils27.AST_NODE_TYPES.TSAsExpression || node.type === import_utils27.AST_NODE_TYPES.TSTypeAssertion) && !isConstTypeAnnotation(node.typeAnnotation) && !insideValidatorArg) {
|
|
3767
3973
|
return node;
|
|
3768
3974
|
}
|
|
3769
|
-
if (node.type ===
|
|
3975
|
+
if (node.type === import_utils27.AST_NODE_TYPES.CallExpression && isValidatorCall(node)) {
|
|
3770
3976
|
const inCallee = findCastExpression(node.callee, insideValidatorArg);
|
|
3771
3977
|
if (inCallee !== null) {
|
|
3772
3978
|
return inCallee;
|
|
@@ -3799,7 +4005,7 @@ function findCastExpression(node, insideValidatorArg) {
|
|
|
3799
4005
|
}
|
|
3800
4006
|
return null;
|
|
3801
4007
|
}
|
|
3802
|
-
var require_schema_validate_search_default =
|
|
4008
|
+
var require_schema_validate_search_default = import_utils27.ESLintUtils.RuleCreator(
|
|
3803
4009
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3804
4010
|
)({
|
|
3805
4011
|
name: "require-schema-validate-search",
|
|
@@ -3820,11 +4026,11 @@ var require_schema_validate_search_default = import_utils26.ESLintUtils.RuleCrea
|
|
|
3820
4026
|
}
|
|
3821
4027
|
return {
|
|
3822
4028
|
Property(node) {
|
|
3823
|
-
const isValidateSearchKey = !node.computed && node.key.type ===
|
|
4029
|
+
const isValidateSearchKey = !node.computed && node.key.type === import_utils27.AST_NODE_TYPES.Identifier && node.key.name === "validateSearch" || node.key.type === import_utils27.AST_NODE_TYPES.Literal && node.key.value === "validateSearch";
|
|
3824
4030
|
if (!isValidateSearchKey) {
|
|
3825
4031
|
return;
|
|
3826
4032
|
}
|
|
3827
|
-
if (node.value.type !==
|
|
4033
|
+
if (node.value.type !== import_utils27.AST_NODE_TYPES.ArrowFunctionExpression && node.value.type !== import_utils27.AST_NODE_TYPES.FunctionExpression) {
|
|
3828
4034
|
return;
|
|
3829
4035
|
}
|
|
3830
4036
|
const cast = findCastExpression(node.value.body, false);
|
|
@@ -3837,12 +4043,12 @@ var require_schema_validate_search_default = import_utils26.ESLintUtils.RuleCrea
|
|
|
3837
4043
|
});
|
|
3838
4044
|
|
|
3839
4045
|
// src/rules/no-fat-try-blocks.ts
|
|
3840
|
-
var
|
|
4046
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
3841
4047
|
var MAX_TRY_BODY_STATEMENTS = 3;
|
|
3842
4048
|
var NESTED_FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
4049
|
+
import_utils28.AST_NODE_TYPES.FunctionDeclaration,
|
|
4050
|
+
import_utils28.AST_NODE_TYPES.FunctionExpression,
|
|
4051
|
+
import_utils28.AST_NODE_TYPES.ArrowFunctionExpression
|
|
3846
4052
|
]);
|
|
3847
4053
|
var PURE_METHODS = /* @__PURE__ */ new Set([
|
|
3848
4054
|
"map",
|
|
@@ -3940,20 +4146,20 @@ function isNode4(value) {
|
|
|
3940
4146
|
}
|
|
3941
4147
|
function isPureCall(node) {
|
|
3942
4148
|
const callee = node.callee;
|
|
3943
|
-
if (callee.type !==
|
|
4149
|
+
if (callee.type !== import_utils28.AST_NODE_TYPES.MemberExpression) {
|
|
3944
4150
|
return false;
|
|
3945
4151
|
}
|
|
3946
4152
|
const property = callee.property;
|
|
3947
|
-
if (property.type !==
|
|
4153
|
+
if (property.type !== import_utils28.AST_NODE_TYPES.Identifier) {
|
|
3948
4154
|
return false;
|
|
3949
4155
|
}
|
|
3950
|
-
if (callee.object.type ===
|
|
4156
|
+
if (callee.object.type === import_utils28.AST_NODE_TYPES.Identifier && PURE_NAMESPACES.has(callee.object.name)) {
|
|
3951
4157
|
return true;
|
|
3952
4158
|
}
|
|
3953
4159
|
return PURE_METHODS.has(property.name);
|
|
3954
4160
|
}
|
|
3955
4161
|
function isPureNew(node) {
|
|
3956
|
-
return node.callee.type ===
|
|
4162
|
+
return node.callee.type === import_utils28.AST_NODE_TYPES.Identifier && PURE_CONSTRUCTORS.has(node.callee.name);
|
|
3957
4163
|
}
|
|
3958
4164
|
function subtreeMatches(stmt, predicate) {
|
|
3959
4165
|
let found = false;
|
|
@@ -3990,20 +4196,20 @@ function subtreeMatches(stmt, predicate) {
|
|
|
3990
4196
|
visit(stmt);
|
|
3991
4197
|
return found;
|
|
3992
4198
|
}
|
|
3993
|
-
var hasAwait = (node) => subtreeMatches(node, (n) => n.type ===
|
|
4199
|
+
var hasAwait = (node) => subtreeMatches(node, (n) => n.type === import_utils28.AST_NODE_TYPES.AwaitExpression);
|
|
3994
4200
|
var hasThrowingCallOrNew = (node) => subtreeMatches(
|
|
3995
4201
|
node,
|
|
3996
|
-
(n) => n.type ===
|
|
4202
|
+
(n) => n.type === import_utils28.AST_NODE_TYPES.CallExpression && !isPureCall(n) || n.type === import_utils28.AST_NODE_TYPES.NewExpression && !isPureNew(n)
|
|
3997
4203
|
);
|
|
3998
4204
|
function unwrap2(expr) {
|
|
3999
4205
|
let current = expr;
|
|
4000
|
-
while (current.type ===
|
|
4206
|
+
while (current.type === import_utils28.AST_NODE_TYPES.ChainExpression || current.type === import_utils28.AST_NODE_TYPES.TSNonNullExpression) {
|
|
4001
4207
|
current = current.expression;
|
|
4002
4208
|
}
|
|
4003
4209
|
return current;
|
|
4004
4210
|
}
|
|
4005
4211
|
function isBareCallStatement(stmt) {
|
|
4006
|
-
return stmt.type ===
|
|
4212
|
+
return stmt.type === import_utils28.AST_NODE_TYPES.ExpressionStatement && unwrap2(stmt.expression).type === import_utils28.AST_NODE_TYPES.CallExpression;
|
|
4007
4213
|
}
|
|
4008
4214
|
function canThrow(stmt) {
|
|
4009
4215
|
if (hasAwait(stmt)) {
|
|
@@ -4012,10 +4218,10 @@ function canThrow(stmt) {
|
|
|
4012
4218
|
if (isBareCallStatement(stmt)) {
|
|
4013
4219
|
return false;
|
|
4014
4220
|
}
|
|
4015
|
-
if (stmt.type ===
|
|
4221
|
+
if (stmt.type === import_utils28.AST_NODE_TYPES.BlockStatement) {
|
|
4016
4222
|
return stmt.body.some(canThrow);
|
|
4017
4223
|
}
|
|
4018
|
-
if (stmt.type ===
|
|
4224
|
+
if (stmt.type === import_utils28.AST_NODE_TYPES.IfStatement) {
|
|
4019
4225
|
return hasThrowingCallOrNew(stmt.test) || canThrow(stmt.consequent) || stmt.alternate !== null && canThrow(stmt.alternate);
|
|
4020
4226
|
}
|
|
4021
4227
|
return hasThrowingCallOrNew(stmt);
|
|
@@ -4026,9 +4232,9 @@ function handlerRethrows(handler) {
|
|
|
4026
4232
|
}
|
|
4027
4233
|
const body = handler.body.body;
|
|
4028
4234
|
const last = body[body.length - 1];
|
|
4029
|
-
return last !== void 0 && last.type ===
|
|
4235
|
+
return last !== void 0 && last.type === import_utils28.AST_NODE_TYPES.ThrowStatement;
|
|
4030
4236
|
}
|
|
4031
|
-
var no_fat_try_blocks_default =
|
|
4237
|
+
var no_fat_try_blocks_default = import_utils28.ESLintUtils.RuleCreator(
|
|
4032
4238
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4033
4239
|
)({
|
|
4034
4240
|
name: "no-fat-try-blocks",
|
|
@@ -4044,6 +4250,9 @@ var no_fat_try_blocks_default = import_utils27.ESLintUtils.RuleCreator(
|
|
|
4044
4250
|
},
|
|
4045
4251
|
defaultOptions: [],
|
|
4046
4252
|
create(context) {
|
|
4253
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4254
|
+
return {};
|
|
4255
|
+
}
|
|
4047
4256
|
const sourceCode = context.sourceCode;
|
|
4048
4257
|
return {
|
|
4049
4258
|
TryStatement(node) {
|
|
@@ -4069,7 +4278,7 @@ var no_fat_try_blocks_default = import_utils27.ESLintUtils.RuleCreator(
|
|
|
4069
4278
|
});
|
|
4070
4279
|
|
|
4071
4280
|
// src/rules/no-secret-in-log.ts
|
|
4072
|
-
var
|
|
4281
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4073
4282
|
|
|
4074
4283
|
// src/rules/_secret_names.ts
|
|
4075
4284
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4331,7 +4540,7 @@ function propertyKeyName2(prop) {
|
|
|
4331
4540
|
}
|
|
4332
4541
|
return null;
|
|
4333
4542
|
}
|
|
4334
|
-
var no_secret_in_log_default =
|
|
4543
|
+
var no_secret_in_log_default = import_utils29.ESLintUtils.RuleCreator(
|
|
4335
4544
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4336
4545
|
)({
|
|
4337
4546
|
name: "no-secret-in-log",
|
|
@@ -4408,15 +4617,15 @@ var no_secret_in_log_default = import_utils28.ESLintUtils.RuleCreator(
|
|
|
4408
4617
|
});
|
|
4409
4618
|
|
|
4410
4619
|
// src/rules/no-unsafe-cast.ts
|
|
4411
|
-
var import_utils29 = require("@typescript-eslint/utils");
|
|
4412
4620
|
var import_utils30 = require("@typescript-eslint/utils");
|
|
4621
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
4413
4622
|
function isAnyAnnotation(node) {
|
|
4414
|
-
return node.type ===
|
|
4623
|
+
return node.type === import_utils31.AST_NODE_TYPES.TSAnyKeyword;
|
|
4415
4624
|
}
|
|
4416
4625
|
function isConstAssertion(typeAnnotation) {
|
|
4417
|
-
return typeAnnotation.type ===
|
|
4626
|
+
return typeAnnotation.type === import_utils31.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeName.type === import_utils31.AST_NODE_TYPES.Identifier && typeAnnotation.typeName.name === "const";
|
|
4418
4627
|
}
|
|
4419
|
-
var no_unsafe_cast_default =
|
|
4628
|
+
var no_unsafe_cast_default = import_utils30.ESLintUtils.RuleCreator(
|
|
4420
4629
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4421
4630
|
)({
|
|
4422
4631
|
name: "no-unsafe-cast",
|
|
@@ -4433,7 +4642,7 @@ var no_unsafe_cast_default = import_utils29.ESLintUtils.RuleCreator(
|
|
|
4433
4642
|
},
|
|
4434
4643
|
defaultOptions: [],
|
|
4435
4644
|
create(context) {
|
|
4436
|
-
if (isTestFile(context.filename)) {
|
|
4645
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4437
4646
|
return {};
|
|
4438
4647
|
}
|
|
4439
4648
|
function checkAssertion(node) {
|
|
@@ -4445,7 +4654,7 @@ var no_unsafe_cast_default = import_utils29.ESLintUtils.RuleCreator(
|
|
|
4445
4654
|
return;
|
|
4446
4655
|
}
|
|
4447
4656
|
const inner = node.expression;
|
|
4448
|
-
if (inner.type ===
|
|
4657
|
+
if (inner.type === import_utils31.AST_NODE_TYPES.TSAsExpression || inner.type === import_utils31.AST_NODE_TYPES.TSTypeAssertion) {
|
|
4449
4658
|
context.report({ node, messageId: "doubleCast" });
|
|
4450
4659
|
}
|
|
4451
4660
|
}
|
|
@@ -4457,7 +4666,7 @@ var no_unsafe_cast_default = import_utils29.ESLintUtils.RuleCreator(
|
|
|
4457
4666
|
});
|
|
4458
4667
|
|
|
4459
4668
|
// src/rules/prefer-string-literal-union.ts
|
|
4460
|
-
var
|
|
4669
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
4461
4670
|
var ts = __toESM(require("typescript"), 1);
|
|
4462
4671
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
4463
4672
|
"status",
|
|
@@ -4500,19 +4709,19 @@ function isChoiceLikeName(name) {
|
|
|
4500
4709
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
4501
4710
|
}
|
|
4502
4711
|
function keyName(key) {
|
|
4503
|
-
if (key.type ===
|
|
4712
|
+
if (key.type === import_utils32.AST_NODE_TYPES.Identifier) {
|
|
4504
4713
|
return key.name;
|
|
4505
4714
|
}
|
|
4506
|
-
if (key.type ===
|
|
4715
|
+
if (key.type === import_utils32.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
4507
4716
|
return key.value;
|
|
4508
4717
|
}
|
|
4509
4718
|
return null;
|
|
4510
4719
|
}
|
|
4511
4720
|
function isStringLiteralMember(t) {
|
|
4512
|
-
return t.type ===
|
|
4721
|
+
return t.type === import_utils32.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils32.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
4513
4722
|
}
|
|
4514
4723
|
function isStringLiteralUnion(node) {
|
|
4515
|
-
if (node?.type !==
|
|
4724
|
+
if (node?.type !== import_utils32.AST_NODE_TYPES.TSUnionType) {
|
|
4516
4725
|
return false;
|
|
4517
4726
|
}
|
|
4518
4727
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -4541,12 +4750,12 @@ function bindingSourceExpression(decl) {
|
|
|
4541
4750
|
return ts.isForOfStatement(node) ? node.expression : node.initializer;
|
|
4542
4751
|
}
|
|
4543
4752
|
function refKey(node) {
|
|
4544
|
-
if (node.type ===
|
|
4753
|
+
if (node.type === import_utils32.AST_NODE_TYPES.Identifier) {
|
|
4545
4754
|
return node.name;
|
|
4546
4755
|
}
|
|
4547
|
-
if (node.type ===
|
|
4756
|
+
if (node.type === import_utils32.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
4548
4757
|
const inner = refKey(node.object);
|
|
4549
|
-
if (inner === null || node.property.type !==
|
|
4758
|
+
if (inner === null || node.property.type !== import_utils32.AST_NODE_TYPES.Identifier) {
|
|
4550
4759
|
return null;
|
|
4551
4760
|
}
|
|
4552
4761
|
return `${inner}.${node.property.name}`;
|
|
@@ -4554,12 +4763,12 @@ function refKey(node) {
|
|
|
4554
4763
|
return null;
|
|
4555
4764
|
}
|
|
4556
4765
|
function strLiteral(node) {
|
|
4557
|
-
if (node.type ===
|
|
4766
|
+
if (node.type === import_utils32.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
4558
4767
|
return node.value;
|
|
4559
4768
|
}
|
|
4560
4769
|
return null;
|
|
4561
4770
|
}
|
|
4562
|
-
var prefer_string_literal_union_default =
|
|
4771
|
+
var prefer_string_literal_union_default = import_utils32.ESLintUtils.RuleCreator(
|
|
4563
4772
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4564
4773
|
)({
|
|
4565
4774
|
name: "prefer-string-literal-union",
|
|
@@ -4597,7 +4806,7 @@ var prefer_string_literal_union_default = import_utils31.ESLintUtils.RuleCreator
|
|
|
4597
4806
|
);
|
|
4598
4807
|
let services;
|
|
4599
4808
|
try {
|
|
4600
|
-
services =
|
|
4809
|
+
services = import_utils32.ESLintUtils.getParserServices(context);
|
|
4601
4810
|
} catch {
|
|
4602
4811
|
services = null;
|
|
4603
4812
|
}
|
|
@@ -4709,7 +4918,7 @@ var prefer_string_literal_union_default = import_utils31.ESLintUtils.RuleCreator
|
|
|
4709
4918
|
containersWithUnion.add(container);
|
|
4710
4919
|
return;
|
|
4711
4920
|
}
|
|
4712
|
-
if (typeNode?.type !==
|
|
4921
|
+
if (typeNode?.type !== import_utils32.AST_NODE_TYPES.TSStringKeyword) {
|
|
4713
4922
|
return;
|
|
4714
4923
|
}
|
|
4715
4924
|
const name = keyName(key);
|
|
@@ -4797,10 +5006,10 @@ var prefer_string_literal_union_default = import_utils31.ESLintUtils.RuleCreator
|
|
|
4797
5006
|
}
|
|
4798
5007
|
};
|
|
4799
5008
|
function refKeyText(node) {
|
|
4800
|
-
if (node.type ===
|
|
5009
|
+
if (node.type === import_utils32.AST_NODE_TYPES.BinaryExpression) {
|
|
4801
5010
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
4802
5011
|
}
|
|
4803
|
-
if (node.type ===
|
|
5012
|
+
if (node.type === import_utils32.AST_NODE_TYPES.SwitchStatement) {
|
|
4804
5013
|
return refKey(node.discriminant) ?? "value";
|
|
4805
5014
|
}
|
|
4806
5015
|
return "value";
|
|
@@ -4809,7 +5018,7 @@ var prefer_string_literal_union_default = import_utils31.ESLintUtils.RuleCreator
|
|
|
4809
5018
|
});
|
|
4810
5019
|
|
|
4811
5020
|
// src/rules/single-public-export.ts
|
|
4812
|
-
var
|
|
5021
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
4813
5022
|
var JUNK_DRAWER_STEMS = /* @__PURE__ */ new Set([
|
|
4814
5023
|
"util",
|
|
4815
5024
|
"utils",
|
|
@@ -4843,12 +5052,12 @@ var kebabCase2 = (name) => {
|
|
|
4843
5052
|
}
|
|
4844
5053
|
return normalized.replace(CAMEL_BOUNDARY_RE, "-").toLowerCase();
|
|
4845
5054
|
};
|
|
4846
|
-
var isFunctionExpression = (node) => node !== null && (node.type ===
|
|
5055
|
+
var isFunctionExpression = (node) => node !== null && (node.type === import_utils33.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils33.AST_NODE_TYPES.FunctionExpression);
|
|
4847
5056
|
var functionConstName = (decl) => {
|
|
4848
5057
|
if (decl.declarations.length !== 1) return null;
|
|
4849
5058
|
const [declarator] = decl.declarations;
|
|
4850
5059
|
if (declarator === void 0) return null;
|
|
4851
|
-
if (declarator.id.type !==
|
|
5060
|
+
if (declarator.id.type !== import_utils33.AST_NODE_TYPES.Identifier) return null;
|
|
4852
5061
|
if (!isFunctionExpression(declarator.init)) return null;
|
|
4853
5062
|
return declarator.id.name;
|
|
4854
5063
|
};
|
|
@@ -4862,20 +5071,20 @@ var summarizeExports = (body) => {
|
|
|
4862
5071
|
};
|
|
4863
5072
|
for (const statement of body) {
|
|
4864
5073
|
switch (statement.type) {
|
|
4865
|
-
case
|
|
5074
|
+
case import_utils33.AST_NODE_TYPES.ExportAllDeclaration:
|
|
4866
5075
|
hasReExport = true;
|
|
4867
5076
|
break;
|
|
4868
|
-
case
|
|
5077
|
+
case import_utils33.AST_NODE_TYPES.ExportDefaultDeclaration: {
|
|
4869
5078
|
names += 1;
|
|
4870
5079
|
const decl = statement.declaration;
|
|
4871
|
-
if (decl.type ===
|
|
5080
|
+
if (decl.type === import_utils33.AST_NODE_TYPES.FunctionDeclaration && decl.id !== null) {
|
|
4872
5081
|
candidate = { name: decl.id.name, node: statement };
|
|
4873
|
-
} else if (decl.type ===
|
|
5082
|
+
} else if (decl.type === import_utils33.AST_NODE_TYPES.ClassDeclaration && decl.id !== null) {
|
|
4874
5083
|
candidate = { name: decl.id.name, node: statement };
|
|
4875
5084
|
}
|
|
4876
5085
|
break;
|
|
4877
5086
|
}
|
|
4878
|
-
case
|
|
5087
|
+
case import_utils33.AST_NODE_TYPES.ExportNamedDeclaration: {
|
|
4879
5088
|
if (statement.source !== null) {
|
|
4880
5089
|
hasReExport = true;
|
|
4881
5090
|
break;
|
|
@@ -4886,15 +5095,15 @@ var summarizeExports = (body) => {
|
|
|
4886
5095
|
break;
|
|
4887
5096
|
}
|
|
4888
5097
|
switch (decl.type) {
|
|
4889
|
-
case
|
|
5098
|
+
case import_utils33.AST_NODE_TYPES.FunctionDeclaration:
|
|
4890
5099
|
if (decl.id !== null) addCandidate(decl.id.name, statement);
|
|
4891
5100
|
else names += 1;
|
|
4892
5101
|
break;
|
|
4893
|
-
case
|
|
5102
|
+
case import_utils33.AST_NODE_TYPES.ClassDeclaration:
|
|
4894
5103
|
if (decl.id !== null) addCandidate(decl.id.name, statement);
|
|
4895
5104
|
else names += 1;
|
|
4896
5105
|
break;
|
|
4897
|
-
case
|
|
5106
|
+
case import_utils33.AST_NODE_TYPES.VariableDeclaration: {
|
|
4898
5107
|
const fnName = functionConstName(decl);
|
|
4899
5108
|
if (fnName !== null && decl.declarations.length === 1) {
|
|
4900
5109
|
addCandidate(fnName, statement);
|
|
@@ -4914,7 +5123,7 @@ var summarizeExports = (body) => {
|
|
|
4914
5123
|
}
|
|
4915
5124
|
return { names, hasReExport, candidate };
|
|
4916
5125
|
};
|
|
4917
|
-
var single_public_export_default =
|
|
5126
|
+
var single_public_export_default = import_utils33.ESLintUtils.RuleCreator(
|
|
4918
5127
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4919
5128
|
)({
|
|
4920
5129
|
name: "single-public-export",
|
|
@@ -4934,8 +5143,8 @@ var single_public_export_default = import_utils32.ESLintUtils.RuleCreator(
|
|
|
4934
5143
|
if (base.endsWith(".d.ts")) return {};
|
|
4935
5144
|
if (TEST_FILE_RE.test(base)) return {};
|
|
4936
5145
|
if (isTestFile(context.filename)) return {};
|
|
4937
|
-
const
|
|
4938
|
-
if (!JUNK_DRAWER_STEMS.has(
|
|
5146
|
+
const stem2 = stemOf(base);
|
|
5147
|
+
if (!JUNK_DRAWER_STEMS.has(stem2.toLowerCase())) return {};
|
|
4939
5148
|
return {
|
|
4940
5149
|
Program(node) {
|
|
4941
5150
|
const { names, hasReExport, candidate } = summarizeExports(node.body);
|
|
@@ -4943,11 +5152,11 @@ var single_public_export_default = import_utils32.ESLintUtils.RuleCreator(
|
|
|
4943
5152
|
if (names !== 1 || candidate === null) return;
|
|
4944
5153
|
if (CONVENTIONAL_BUCKET_EXPORTS.has(candidate.name)) return;
|
|
4945
5154
|
const expected = kebabCase2(candidate.name);
|
|
4946
|
-
if (
|
|
5155
|
+
if (stem2 === expected) return;
|
|
4947
5156
|
context.report({
|
|
4948
5157
|
node: candidate.node,
|
|
4949
5158
|
messageId: "renameJunkDrawer",
|
|
4950
|
-
data: { stem, name: candidate.name, expected }
|
|
5159
|
+
data: { stem: stem2, name: candidate.name, expected }
|
|
4951
5160
|
});
|
|
4952
5161
|
}
|
|
4953
5162
|
};
|
|
@@ -4955,10 +5164,10 @@ var single_public_export_default = import_utils32.ESLintUtils.RuleCreator(
|
|
|
4955
5164
|
});
|
|
4956
5165
|
|
|
4957
5166
|
// src/rules/no-offset-pagination.ts
|
|
4958
|
-
var
|
|
5167
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
4959
5168
|
|
|
4960
5169
|
// src/rules/_sql.ts
|
|
4961
|
-
var
|
|
5170
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
4962
5171
|
function stripSqlNoise(text) {
|
|
4963
5172
|
const out = [...text];
|
|
4964
5173
|
const n = text.length;
|
|
@@ -5019,13 +5228,13 @@ function stripSqlNoise(text) {
|
|
|
5019
5228
|
var SUBSTITUTION_MARKER = "?";
|
|
5020
5229
|
function sqlTextOf(node) {
|
|
5021
5230
|
switch (node.type) {
|
|
5022
|
-
case
|
|
5231
|
+
case import_utils34.AST_NODE_TYPES.Literal:
|
|
5023
5232
|
return typeof node.value === "string" ? node.value : null;
|
|
5024
|
-
case
|
|
5233
|
+
case import_utils34.AST_NODE_TYPES.TemplateLiteral:
|
|
5025
5234
|
return node.quasis.map((q) => q.value.cooked ?? q.value.raw).join(SUBSTITUTION_MARKER);
|
|
5026
|
-
case
|
|
5235
|
+
case import_utils34.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
5027
5236
|
return sqlTextOf(node.quasi);
|
|
5028
|
-
case
|
|
5237
|
+
case import_utils34.AST_NODE_TYPES.BinaryExpression: {
|
|
5029
5238
|
if (node.operator !== "+") {
|
|
5030
5239
|
return null;
|
|
5031
5240
|
}
|
|
@@ -5033,7 +5242,7 @@ function sqlTextOf(node) {
|
|
|
5033
5242
|
const right = sqlTextOf(node.right);
|
|
5034
5243
|
return left !== null && right !== null ? left + right : null;
|
|
5035
5244
|
}
|
|
5036
|
-
case
|
|
5245
|
+
case import_utils34.AST_NODE_TYPES.ArrayExpression: {
|
|
5037
5246
|
const parts = [];
|
|
5038
5247
|
for (const element of node.elements) {
|
|
5039
5248
|
if (element === null) {
|
|
@@ -5053,7 +5262,7 @@ function sqlTextOf(node) {
|
|
|
5053
5262
|
}
|
|
5054
5263
|
function isJoinedFragmentArray(node) {
|
|
5055
5264
|
const parent = node.parent;
|
|
5056
|
-
return parent?.type ===
|
|
5265
|
+
return parent?.type === import_utils34.AST_NODE_TYPES.MemberExpression && parent.object === node && !parent.computed && parent.property.type === import_utils34.AST_NODE_TYPES.Identifier && parent.property.name === "join" && parent.parent?.type === import_utils34.AST_NODE_TYPES.CallExpression;
|
|
5057
5266
|
}
|
|
5058
5267
|
function markConsumed(node, consumed) {
|
|
5059
5268
|
consumed.add(node);
|
|
@@ -5103,7 +5312,7 @@ function createSqlListener(handler) {
|
|
|
5103
5312
|
// src/rules/no-offset-pagination.ts
|
|
5104
5313
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
5105
5314
|
var OFFSET_GATE = /offset/i;
|
|
5106
|
-
var no_offset_pagination_default =
|
|
5315
|
+
var no_offset_pagination_default = import_utils35.ESLintUtils.RuleCreator(
|
|
5107
5316
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5108
5317
|
)({
|
|
5109
5318
|
name: "no-offset-pagination",
|
|
@@ -5132,15 +5341,15 @@ var no_offset_pagination_default = import_utils34.ESLintUtils.RuleCreator(
|
|
|
5132
5341
|
});
|
|
5133
5342
|
|
|
5134
5343
|
// src/rules/no-positional-tuple-return.ts
|
|
5135
|
-
var
|
|
5344
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5136
5345
|
var MIN_ELEMENTS = 2;
|
|
5137
5346
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
5138
5347
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
5139
5348
|
function tupleReturnType(node) {
|
|
5140
|
-
if (node.type ===
|
|
5349
|
+
if (node.type === import_utils36.AST_NODE_TYPES.TSTupleType) {
|
|
5141
5350
|
return node;
|
|
5142
5351
|
}
|
|
5143
|
-
if (node.type ===
|
|
5352
|
+
if (node.type === import_utils36.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils36.AST_NODE_TYPES.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
5144
5353
|
const argument = node.typeArguments?.params[0];
|
|
5145
5354
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
5146
5355
|
}
|
|
@@ -5154,30 +5363,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
5154
5363
|
if (elements.length < MIN_ELEMENTS) {
|
|
5155
5364
|
return true;
|
|
5156
5365
|
}
|
|
5157
|
-
if (elements.some((element) => element.type ===
|
|
5366
|
+
if (elements.some((element) => element.type === import_utils36.AST_NODE_TYPES.TSRestType)) {
|
|
5158
5367
|
return true;
|
|
5159
5368
|
}
|
|
5160
|
-
if (elements.some((element) => element.type ===
|
|
5369
|
+
if (elements.some((element) => element.type === import_utils36.AST_NODE_TYPES.TSNamedTupleMember)) {
|
|
5161
5370
|
return true;
|
|
5162
5371
|
}
|
|
5163
|
-
if (elements[0]?.type ===
|
|
5372
|
+
if (elements[0]?.type === import_utils36.AST_NODE_TYPES.TSLiteralType) {
|
|
5164
5373
|
return true;
|
|
5165
5374
|
}
|
|
5166
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
5375
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === import_utils36.AST_NODE_TYPES.TSFunctionType)) {
|
|
5167
5376
|
return true;
|
|
5168
5377
|
}
|
|
5169
5378
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
5170
5379
|
return texts.size === 1;
|
|
5171
5380
|
}
|
|
5172
5381
|
function functionName(node) {
|
|
5173
|
-
if (node.type ===
|
|
5382
|
+
if (node.type === import_utils36.AST_NODE_TYPES.FunctionDeclaration) {
|
|
5174
5383
|
return node.id?.name ?? null;
|
|
5175
5384
|
}
|
|
5176
5385
|
const parent = node.parent;
|
|
5177
|
-
if (parent?.type ===
|
|
5386
|
+
if (parent?.type === import_utils36.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
5178
5387
|
return parent.id.name;
|
|
5179
5388
|
}
|
|
5180
|
-
if ((parent?.type ===
|
|
5389
|
+
if ((parent?.type === import_utils36.AST_NODE_TYPES.MethodDefinition || parent?.type === import_utils36.AST_NODE_TYPES.PropertyDefinition || parent?.type === import_utils36.AST_NODE_TYPES.Property) && parent.key.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
5181
5390
|
return parent.key.name;
|
|
5182
5391
|
}
|
|
5183
5392
|
return null;
|
|
@@ -5185,7 +5394,7 @@ function functionName(node) {
|
|
|
5185
5394
|
function isInlineExported(node) {
|
|
5186
5395
|
for (let current = node; current != null; current = current.parent) {
|
|
5187
5396
|
const parent = current.parent;
|
|
5188
|
-
if (parent?.type ===
|
|
5397
|
+
if (parent?.type === import_utils36.AST_NODE_TYPES.ExportNamedDeclaration || parent?.type === import_utils36.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
5189
5398
|
return true;
|
|
5190
5399
|
}
|
|
5191
5400
|
}
|
|
@@ -5194,18 +5403,18 @@ function isInlineExported(node) {
|
|
|
5194
5403
|
function moduleScopeBindingName(node) {
|
|
5195
5404
|
let current = node;
|
|
5196
5405
|
let child = node;
|
|
5197
|
-
while (current.parent != null && current.parent.type !==
|
|
5406
|
+
while (current.parent != null && current.parent.type !== import_utils36.AST_NODE_TYPES.Program) {
|
|
5198
5407
|
child = current;
|
|
5199
5408
|
current = current.parent;
|
|
5200
5409
|
}
|
|
5201
|
-
if (current.parent?.type !==
|
|
5410
|
+
if (current.parent?.type !== import_utils36.AST_NODE_TYPES.Program) {
|
|
5202
5411
|
return null;
|
|
5203
5412
|
}
|
|
5204
|
-
if (current.type ===
|
|
5413
|
+
if (current.type === import_utils36.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils36.AST_NODE_TYPES.ClassDeclaration) {
|
|
5205
5414
|
return current.id?.name ?? null;
|
|
5206
5415
|
}
|
|
5207
|
-
if (current.type ===
|
|
5208
|
-
if (child.type !==
|
|
5416
|
+
if (current.type === import_utils36.AST_NODE_TYPES.VariableDeclaration) {
|
|
5417
|
+
if (child.type !== import_utils36.AST_NODE_TYPES.VariableDeclarator || child.id.type !== import_utils36.AST_NODE_TYPES.Identifier) {
|
|
5209
5418
|
return null;
|
|
5210
5419
|
}
|
|
5211
5420
|
return child.id.name;
|
|
@@ -5215,19 +5424,19 @@ function moduleScopeBindingName(node) {
|
|
|
5215
5424
|
function specifierExportedNames(program) {
|
|
5216
5425
|
const names = /* @__PURE__ */ new Set();
|
|
5217
5426
|
for (const statement of program.body) {
|
|
5218
|
-
if (statement.type ===
|
|
5427
|
+
if (statement.type === import_utils36.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
5219
5428
|
for (const specifier of statement.specifiers) {
|
|
5220
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
5429
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
5221
5430
|
names.add(specifier.local.name);
|
|
5222
5431
|
}
|
|
5223
5432
|
}
|
|
5224
5433
|
continue;
|
|
5225
5434
|
}
|
|
5226
|
-
if (statement.type ===
|
|
5435
|
+
if (statement.type === import_utils36.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
5227
5436
|
names.add(statement.declaration.name);
|
|
5228
5437
|
continue;
|
|
5229
5438
|
}
|
|
5230
|
-
if (statement.type ===
|
|
5439
|
+
if (statement.type === import_utils36.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
5231
5440
|
names.add(statement.expression.name);
|
|
5232
5441
|
}
|
|
5233
5442
|
}
|
|
@@ -5243,7 +5452,7 @@ function isExported(node, specifierExports) {
|
|
|
5243
5452
|
const binding = moduleScopeBindingName(node);
|
|
5244
5453
|
return binding !== null && specifierExports.has(binding);
|
|
5245
5454
|
}
|
|
5246
|
-
var no_positional_tuple_return_default =
|
|
5455
|
+
var no_positional_tuple_return_default = import_utils36.ESLintUtils.RuleCreator(
|
|
5247
5456
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5248
5457
|
)({
|
|
5249
5458
|
name: "no-positional-tuple-return",
|
|
@@ -5291,7 +5500,7 @@ var no_positional_tuple_return_default = import_utils35.ESLintUtils.RuleCreator(
|
|
|
5291
5500
|
});
|
|
5292
5501
|
|
|
5293
5502
|
// src/rules/no-repeated-string-literal.ts
|
|
5294
|
-
var
|
|
5503
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5295
5504
|
var MIN_LENGTH = 40;
|
|
5296
5505
|
var MIN_OCCURRENCES = 3;
|
|
5297
5506
|
var MIN_DISTINCT_SCOPES = 2;
|
|
@@ -5299,9 +5508,9 @@ var PREVIEW_LENGTH = 40;
|
|
|
5299
5508
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
5300
5509
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
5301
5510
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5511
|
+
import_utils37.AST_NODE_TYPES.FunctionDeclaration,
|
|
5512
|
+
import_utils37.AST_NODE_TYPES.FunctionExpression,
|
|
5513
|
+
import_utils37.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5305
5514
|
]);
|
|
5306
5515
|
function isStructured(value) {
|
|
5307
5516
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -5323,9 +5532,9 @@ function isScaffolding(node) {
|
|
|
5323
5532
|
if (parent === void 0) {
|
|
5324
5533
|
return true;
|
|
5325
5534
|
}
|
|
5326
|
-
return parent.type ===
|
|
5535
|
+
return parent.type === import_utils37.AST_NODE_TYPES.ImportDeclaration || parent.type === import_utils37.AST_NODE_TYPES.ExportNamedDeclaration || parent.type === import_utils37.AST_NODE_TYPES.ExportAllDeclaration || parent.type === import_utils37.AST_NODE_TYPES.TSImportType || parent.type === import_utils37.AST_NODE_TYPES.JSXAttribute || parent.type === import_utils37.AST_NODE_TYPES.TSLiteralType;
|
|
5327
5536
|
}
|
|
5328
|
-
var no_repeated_string_literal_default =
|
|
5537
|
+
var no_repeated_string_literal_default = import_utils37.ESLintUtils.RuleCreator(
|
|
5329
5538
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5330
5539
|
)({
|
|
5331
5540
|
name: "no-repeated-string-literal",
|
|
@@ -5365,7 +5574,7 @@ var no_repeated_string_literal_default = import_utils36.ESLintUtils.RuleCreator(
|
|
|
5365
5574
|
}
|
|
5366
5575
|
},
|
|
5367
5576
|
TemplateLiteral(node) {
|
|
5368
|
-
if (node.parent.type ===
|
|
5577
|
+
if (node.parent.type === import_utils37.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
5369
5578
|
return;
|
|
5370
5579
|
}
|
|
5371
5580
|
const [only] = node.quasis;
|
|
@@ -5402,7 +5611,7 @@ var no_repeated_string_literal_default = import_utils36.ESLintUtils.RuleCreator(
|
|
|
5402
5611
|
});
|
|
5403
5612
|
|
|
5404
5613
|
// src/rules/no-select-star.ts
|
|
5405
|
-
var
|
|
5614
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5406
5615
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
5407
5616
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
5408
5617
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -5442,7 +5651,7 @@ function hasRealSelectStar(sql) {
|
|
|
5442
5651
|
}
|
|
5443
5652
|
return false;
|
|
5444
5653
|
}
|
|
5445
|
-
var no_select_star_default =
|
|
5654
|
+
var no_select_star_default = import_utils38.ESLintUtils.RuleCreator(
|
|
5446
5655
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5447
5656
|
)({
|
|
5448
5657
|
name: "no-select-star",
|
|
@@ -5471,7 +5680,7 @@ var no_select_star_default = import_utils37.ESLintUtils.RuleCreator(
|
|
|
5471
5680
|
});
|
|
5472
5681
|
|
|
5473
5682
|
// src/rules/no-sleep-in-test-body.ts
|
|
5474
|
-
var
|
|
5683
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5475
5684
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
5476
5685
|
var TEST_CALLERS = /* @__PURE__ */ new Set([
|
|
5477
5686
|
"it",
|
|
@@ -5480,34 +5689,34 @@ var TEST_CALLERS = /* @__PURE__ */ new Set([
|
|
|
5480
5689
|
"afterEach"
|
|
5481
5690
|
]);
|
|
5482
5691
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5692
|
+
import_utils39.AST_NODE_TYPES.FunctionDeclaration,
|
|
5693
|
+
import_utils39.AST_NODE_TYPES.FunctionExpression,
|
|
5694
|
+
import_utils39.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5486
5695
|
]);
|
|
5487
5696
|
function isNonzeroNumericLiteral(node) {
|
|
5488
|
-
return node?.type ===
|
|
5697
|
+
return node?.type === import_utils39.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
5489
5698
|
}
|
|
5490
5699
|
function isTimedSetTimeout(node) {
|
|
5491
|
-
return node.type ===
|
|
5700
|
+
return node.type === import_utils39.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils39.AST_NODE_TYPES.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
5492
5701
|
}
|
|
5493
5702
|
function isPromiseSleep(node) {
|
|
5494
|
-
if (node.callee.type !==
|
|
5703
|
+
if (node.callee.type !== import_utils39.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
5495
5704
|
return false;
|
|
5496
5705
|
}
|
|
5497
5706
|
const executor = node.arguments[0];
|
|
5498
|
-
if (executor?.type !==
|
|
5707
|
+
if (executor?.type !== import_utils39.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils39.AST_NODE_TYPES.FunctionExpression) {
|
|
5499
5708
|
return false;
|
|
5500
5709
|
}
|
|
5501
5710
|
const body = executor.body;
|
|
5502
|
-
if (body.type !==
|
|
5711
|
+
if (body.type !== import_utils39.AST_NODE_TYPES.BlockStatement) {
|
|
5503
5712
|
return isTimedSetTimeout(body);
|
|
5504
5713
|
}
|
|
5505
5714
|
return body.body.some(
|
|
5506
|
-
(stmt) => stmt.type ===
|
|
5715
|
+
(stmt) => stmt.type === import_utils39.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
5507
5716
|
);
|
|
5508
5717
|
}
|
|
5509
5718
|
function isHelperSleep(node) {
|
|
5510
|
-
return node.callee.type ===
|
|
5719
|
+
return node.callee.type === import_utils39.AST_NODE_TYPES.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
5511
5720
|
}
|
|
5512
5721
|
function nearestEnclosingFunction(node) {
|
|
5513
5722
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -5515,7 +5724,7 @@ function nearestEnclosingFunction(node) {
|
|
|
5515
5724
|
continue;
|
|
5516
5725
|
}
|
|
5517
5726
|
const grandparent = current.parent;
|
|
5518
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
5727
|
+
const isPromiseExecutor = grandparent?.type === import_utils39.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
5519
5728
|
if (!isPromiseExecutor) {
|
|
5520
5729
|
return current;
|
|
5521
5730
|
}
|
|
@@ -5523,29 +5732,29 @@ function nearestEnclosingFunction(node) {
|
|
|
5523
5732
|
return null;
|
|
5524
5733
|
}
|
|
5525
5734
|
function testCallerName(callee) {
|
|
5526
|
-
if (callee.type ===
|
|
5735
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5527
5736
|
return callee.name;
|
|
5528
5737
|
}
|
|
5529
|
-
if (callee.type ===
|
|
5738
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.MemberExpression) {
|
|
5530
5739
|
return testCallerName(callee.object);
|
|
5531
5740
|
}
|
|
5532
|
-
if (callee.type ===
|
|
5741
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.CallExpression) {
|
|
5533
5742
|
return testCallerName(callee.callee);
|
|
5534
5743
|
}
|
|
5535
|
-
if (callee.type ===
|
|
5744
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
5536
5745
|
return testCallerName(callee.tag);
|
|
5537
5746
|
}
|
|
5538
5747
|
return null;
|
|
5539
5748
|
}
|
|
5540
5749
|
function isTestBody(fn) {
|
|
5541
5750
|
const call = fn.parent;
|
|
5542
|
-
if (call?.type !==
|
|
5751
|
+
if (call?.type !== import_utils39.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
5543
5752
|
return false;
|
|
5544
5753
|
}
|
|
5545
5754
|
const name = testCallerName(call.callee);
|
|
5546
5755
|
return name !== null && TEST_CALLERS.has(name);
|
|
5547
5756
|
}
|
|
5548
|
-
var no_sleep_in_test_body_default =
|
|
5757
|
+
var no_sleep_in_test_body_default = import_utils39.ESLintUtils.RuleCreator(
|
|
5549
5758
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5550
5759
|
)({
|
|
5551
5760
|
name: "no-sleep-in-test-body",
|
|
@@ -5587,7 +5796,7 @@ var no_sleep_in_test_body_default = import_utils38.ESLintUtils.RuleCreator(
|
|
|
5587
5796
|
});
|
|
5588
5797
|
|
|
5589
5798
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
5590
|
-
var
|
|
5799
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
5591
5800
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
5592
5801
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
5593
5802
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -5600,36 +5809,36 @@ function isConstantReference(identifier) {
|
|
|
5600
5809
|
}
|
|
5601
5810
|
function isExcludedOperand(node) {
|
|
5602
5811
|
switch (node.type) {
|
|
5603
|
-
case
|
|
5812
|
+
case import_utils40.AST_NODE_TYPES.Literal:
|
|
5604
5813
|
return true;
|
|
5605
|
-
case
|
|
5814
|
+
case import_utils40.AST_NODE_TYPES.TemplateLiteral:
|
|
5606
5815
|
return node.expressions.length === 0;
|
|
5607
|
-
case
|
|
5816
|
+
case import_utils40.AST_NODE_TYPES.Identifier:
|
|
5608
5817
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
5609
|
-
case
|
|
5610
|
-
return !node.computed && node.property.type ===
|
|
5818
|
+
case import_utils40.AST_NODE_TYPES.MemberExpression:
|
|
5819
|
+
return !node.computed && node.property.type === import_utils40.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
5611
5820
|
default:
|
|
5612
5821
|
return false;
|
|
5613
5822
|
}
|
|
5614
5823
|
}
|
|
5615
5824
|
function operandName(node) {
|
|
5616
|
-
if (node.type ===
|
|
5825
|
+
if (node.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5617
5826
|
return node.name;
|
|
5618
5827
|
}
|
|
5619
|
-
if (node.type ===
|
|
5828
|
+
if (node.type === import_utils40.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5620
5829
|
return node.property.name;
|
|
5621
5830
|
}
|
|
5622
5831
|
return null;
|
|
5623
5832
|
}
|
|
5624
5833
|
function isSecretOperand(node) {
|
|
5625
|
-
if (node.type ===
|
|
5834
|
+
if (node.type === import_utils40.AST_NODE_TYPES.TemplateLiteral) {
|
|
5626
5835
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
5627
5836
|
}
|
|
5628
5837
|
const name = operandName(node);
|
|
5629
5838
|
return name !== null && isAuthSecretName(name);
|
|
5630
5839
|
}
|
|
5631
5840
|
function secretNameOf(node) {
|
|
5632
|
-
if (node.type ===
|
|
5841
|
+
if (node.type === import_utils40.AST_NODE_TYPES.TemplateLiteral) {
|
|
5633
5842
|
for (const expression of node.expressions) {
|
|
5634
5843
|
const nested = secretNameOf(expression);
|
|
5635
5844
|
if (nested !== null) {
|
|
@@ -5640,7 +5849,7 @@ function secretNameOf(node) {
|
|
|
5640
5849
|
}
|
|
5641
5850
|
return operandName(node);
|
|
5642
5851
|
}
|
|
5643
|
-
var prefer_constant_time_secret_compare_default =
|
|
5852
|
+
var prefer_constant_time_secret_compare_default = import_utils40.ESLintUtils.RuleCreator(
|
|
5644
5853
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5645
5854
|
)({
|
|
5646
5855
|
name: "prefer-constant-time-secret-compare",
|
|
@@ -5683,11 +5892,11 @@ var prefer_constant_time_secret_compare_default = import_utils39.ESLintUtils.Rul
|
|
|
5683
5892
|
});
|
|
5684
5893
|
|
|
5685
5894
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
5686
|
-
var
|
|
5895
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5687
5896
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
5688
5897
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
5689
5898
|
var INSERT_GATE = /insert/i;
|
|
5690
|
-
var store_insert_requires_on_conflict_default =
|
|
5899
|
+
var store_insert_requires_on_conflict_default = import_utils41.ESLintUtils.RuleCreator(
|
|
5691
5900
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5692
5901
|
)({
|
|
5693
5902
|
name: "store-insert-requires-on-conflict",
|
|
@@ -5716,17 +5925,17 @@ var store_insert_requires_on_conflict_default = import_utils40.ESLintUtils.RuleC
|
|
|
5716
5925
|
});
|
|
5717
5926
|
|
|
5718
5927
|
// src/rules/no-dynamic-sql.ts
|
|
5719
|
-
var
|
|
5928
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
5720
5929
|
var DEFAULT_METHODS = ["prepare", "exec", "query"];
|
|
5721
5930
|
var CONSTANT_CASE_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
5722
5931
|
function isStaticFragment(expression) {
|
|
5723
|
-
if (expression.type ===
|
|
5932
|
+
if (expression.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5724
5933
|
return CONSTANT_CASE_RE.test(expression.name);
|
|
5725
5934
|
}
|
|
5726
|
-
if (expression.type ===
|
|
5935
|
+
if (expression.type === import_utils42.AST_NODE_TYPES.MemberExpression && !expression.computed && expression.property.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5727
5936
|
return CONSTANT_CASE_RE.test(expression.property.name);
|
|
5728
5937
|
}
|
|
5729
|
-
if (expression.type ===
|
|
5938
|
+
if (expression.type === import_utils42.AST_NODE_TYPES.Literal) {
|
|
5730
5939
|
return typeof expression.value === "string";
|
|
5731
5940
|
}
|
|
5732
5941
|
return false;
|
|
@@ -5737,36 +5946,36 @@ function runtimeInterpolations(template) {
|
|
|
5737
5946
|
);
|
|
5738
5947
|
}
|
|
5739
5948
|
function concatOperands(node) {
|
|
5740
|
-
if (node.type ===
|
|
5949
|
+
if (node.type === import_utils42.AST_NODE_TYPES.BinaryExpression && node.operator === "+") {
|
|
5741
5950
|
return [...concatOperands(node.left), ...concatOperands(node.right)];
|
|
5742
5951
|
}
|
|
5743
5952
|
return [node];
|
|
5744
5953
|
}
|
|
5745
5954
|
function runtimeConcatOperands(node) {
|
|
5746
|
-
if (node.type !==
|
|
5955
|
+
if (node.type !== import_utils42.AST_NODE_TYPES.BinaryExpression || node.operator !== "+") {
|
|
5747
5956
|
return [];
|
|
5748
5957
|
}
|
|
5749
5958
|
const operands = concatOperands(node);
|
|
5750
5959
|
const hasStringLiteral = operands.some(
|
|
5751
|
-
(operand) => operand.type ===
|
|
5960
|
+
(operand) => operand.type === import_utils42.AST_NODE_TYPES.Literal && typeof operand.value === "string"
|
|
5752
5961
|
);
|
|
5753
5962
|
if (!hasStringLiteral) {
|
|
5754
5963
|
return [];
|
|
5755
5964
|
}
|
|
5756
5965
|
return operands.filter(
|
|
5757
|
-
(operand) => operand.type !==
|
|
5966
|
+
(operand) => operand.type !== import_utils42.AST_NODE_TYPES.Literal && !isStaticFragment(operand)
|
|
5758
5967
|
);
|
|
5759
5968
|
}
|
|
5760
5969
|
var SQL_STATEMENT_RE = /\b(?:select\s|insert\s+into\b|insert\s+or\b|update\s+\w|delete\s+from\b|replace\s+into\b|merge\s+into\b|upsert\s+into\b|create\s+(?:temp(?:orary)?\s+)?(?:table|index|view|trigger|schema|database)\b|alter\s+table\b|drop\s+(?:table|index|view|trigger)\b|truncate\s+table\b|pragma\s+\w|with\s+\w+\s+as\s*\(|from\s+\w+\s+where\b)/i;
|
|
5761
5970
|
var RUNTIME_MARKER = " ? ";
|
|
5762
5971
|
function staticStatementText(node) {
|
|
5763
|
-
if (node.type ===
|
|
5972
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TemplateLiteral) {
|
|
5764
5973
|
return node.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join(RUNTIME_MARKER);
|
|
5765
5974
|
}
|
|
5766
|
-
if (node.type ===
|
|
5975
|
+
if (node.type === import_utils42.AST_NODE_TYPES.Literal) {
|
|
5767
5976
|
return typeof node.value === "string" ? node.value : RUNTIME_MARKER;
|
|
5768
5977
|
}
|
|
5769
|
-
if (node.type ===
|
|
5978
|
+
if (node.type === import_utils42.AST_NODE_TYPES.BinaryExpression && node.operator === "+") {
|
|
5770
5979
|
return staticStatementText(node.left) + staticStatementText(node.right);
|
|
5771
5980
|
}
|
|
5772
5981
|
return RUNTIME_MARKER;
|
|
@@ -5776,13 +5985,13 @@ function looksLikeSql(node) {
|
|
|
5776
5985
|
}
|
|
5777
5986
|
function statementMethodName(node, methods) {
|
|
5778
5987
|
const callee = node.callee;
|
|
5779
|
-
if (callee.type !==
|
|
5988
|
+
if (callee.type !== import_utils42.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5780
5989
|
return null;
|
|
5781
5990
|
}
|
|
5782
5991
|
const name = callee.property.name;
|
|
5783
5992
|
return methods.has(name) ? name : null;
|
|
5784
5993
|
}
|
|
5785
|
-
var no_dynamic_sql_default =
|
|
5994
|
+
var no_dynamic_sql_default = import_utils42.ESLintUtils.RuleCreator(
|
|
5786
5995
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5787
5996
|
)({
|
|
5788
5997
|
name: "no-dynamic-sql",
|
|
@@ -5821,7 +6030,7 @@ var no_dynamic_sql_default = import_utils41.ESLintUtils.RuleCreator(
|
|
|
5821
6030
|
if (statement === void 0 || !looksLikeSql(statement)) {
|
|
5822
6031
|
return;
|
|
5823
6032
|
}
|
|
5824
|
-
const offenders = statement.type ===
|
|
6033
|
+
const offenders = statement.type === import_utils42.AST_NODE_TYPES.TemplateLiteral ? runtimeInterpolations(statement) : runtimeConcatOperands(statement);
|
|
5825
6034
|
for (const offender of offenders) {
|
|
5826
6035
|
context.report({
|
|
5827
6036
|
node: offender,
|
|
@@ -5835,7 +6044,7 @@ var no_dynamic_sql_default = import_utils41.ESLintUtils.RuleCreator(
|
|
|
5835
6044
|
});
|
|
5836
6045
|
|
|
5837
6046
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
5838
|
-
var
|
|
6047
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
5839
6048
|
var DEFAULT_ALLOW = [
|
|
5840
6049
|
"[\\\\/]clients?[\\\\/]",
|
|
5841
6050
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -5899,7 +6108,7 @@ function compile(patterns) {
|
|
|
5899
6108
|
}
|
|
5900
6109
|
return compiled;
|
|
5901
6110
|
}
|
|
5902
|
-
var no_raw_fetch_outside_clients_default =
|
|
6111
|
+
var no_raw_fetch_outside_clients_default = import_utils43.ESLintUtils.RuleCreator(
|
|
5903
6112
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5904
6113
|
)({
|
|
5905
6114
|
name: "no-raw-fetch-outside-clients",
|
|
@@ -5947,7 +6156,7 @@ var no_raw_fetch_outside_clients_default = import_utils42.ESLintUtils.RuleCreato
|
|
|
5947
6156
|
});
|
|
5948
6157
|
|
|
5949
6158
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
5950
|
-
var
|
|
6159
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
5951
6160
|
var DEFAULT_METHODS2 = [
|
|
5952
6161
|
"prepare",
|
|
5953
6162
|
"put",
|
|
@@ -5966,7 +6175,7 @@ function compile2(patterns) {
|
|
|
5966
6175
|
}
|
|
5967
6176
|
function storageMethodName(node, methods) {
|
|
5968
6177
|
const callee = node.callee;
|
|
5969
|
-
if (callee.type !==
|
|
6178
|
+
if (callee.type !== import_utils44.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
5970
6179
|
return null;
|
|
5971
6180
|
}
|
|
5972
6181
|
const name = callee.property.name;
|
|
@@ -5978,7 +6187,7 @@ function storageMethodName(node, methods) {
|
|
|
5978
6187
|
}
|
|
5979
6188
|
return name;
|
|
5980
6189
|
}
|
|
5981
|
-
var no_storage_in_stateless_modules_default =
|
|
6190
|
+
var no_storage_in_stateless_modules_default = import_utils44.ESLintUtils.RuleCreator(
|
|
5982
6191
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5983
6192
|
)({
|
|
5984
6193
|
name: "no-storage-in-stateless-modules",
|
|
@@ -6036,7 +6245,7 @@ var no_storage_in_stateless_modules_default = import_utils43.ESLintUtils.RuleCre
|
|
|
6036
6245
|
});
|
|
6037
6246
|
|
|
6038
6247
|
// src/rules/no-zod-native-enum.ts
|
|
6039
|
-
var
|
|
6248
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6040
6249
|
var ts2 = __toESM(require("typescript"), 1);
|
|
6041
6250
|
var IGNORE_PATTERNS2 = [
|
|
6042
6251
|
/[\\/]generated[\\/]/,
|
|
@@ -6054,7 +6263,7 @@ function isZodModule(source) {
|
|
|
6054
6263
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6055
6264
|
}
|
|
6056
6265
|
function unwrap3(node) {
|
|
6057
|
-
if (node.type ===
|
|
6266
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TSAsExpression || node.type === import_utils45.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6058
6267
|
return unwrap3(node.expression);
|
|
6059
6268
|
}
|
|
6060
6269
|
return node;
|
|
@@ -6062,14 +6271,14 @@ function unwrap3(node) {
|
|
|
6062
6271
|
function stringValueTexts(node, sourceCode) {
|
|
6063
6272
|
const texts = [];
|
|
6064
6273
|
for (const prop of node.properties) {
|
|
6065
|
-
if (prop.type !==
|
|
6274
|
+
if (prop.type !== import_utils45.AST_NODE_TYPES.Property) {
|
|
6066
6275
|
return null;
|
|
6067
6276
|
}
|
|
6068
6277
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6069
6278
|
return null;
|
|
6070
6279
|
}
|
|
6071
6280
|
const value = prop.value;
|
|
6072
|
-
if (value.type !==
|
|
6281
|
+
if (value.type !== import_utils45.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
6073
6282
|
return null;
|
|
6074
6283
|
}
|
|
6075
6284
|
const text = sourceCode.getText(value);
|
|
@@ -6085,7 +6294,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6085
6294
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6086
6295
|
if (variable !== void 0) {
|
|
6087
6296
|
return variable.defs.some(
|
|
6088
|
-
(def) => def.node.type ===
|
|
6297
|
+
(def) => def.node.type === import_utils45.AST_NODE_TYPES.TSEnumDeclaration
|
|
6089
6298
|
);
|
|
6090
6299
|
}
|
|
6091
6300
|
current = current.upper;
|
|
@@ -6105,7 +6314,7 @@ function resolvesToImportedEnum(node, services) {
|
|
|
6105
6314
|
}
|
|
6106
6315
|
return (symbol.flags & ENUM_SYMBOL_FLAGS) !== 0;
|
|
6107
6316
|
}
|
|
6108
|
-
var no_zod_native_enum_default =
|
|
6317
|
+
var no_zod_native_enum_default = import_utils45.ESLintUtils.RuleCreator(
|
|
6109
6318
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6110
6319
|
)({
|
|
6111
6320
|
name: "no-zod-native-enum",
|
|
@@ -6132,32 +6341,32 @@ var no_zod_native_enum_default = import_utils44.ESLintUtils.RuleCreator(
|
|
|
6132
6341
|
}
|
|
6133
6342
|
let services;
|
|
6134
6343
|
try {
|
|
6135
|
-
services =
|
|
6344
|
+
services = import_utils45.ESLintUtils.getParserServices(context);
|
|
6136
6345
|
} catch {
|
|
6137
6346
|
services = null;
|
|
6138
6347
|
}
|
|
6139
6348
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6140
6349
|
function isZodMemberCall(node, api) {
|
|
6141
6350
|
const callee = node.callee;
|
|
6142
|
-
if (callee.type ===
|
|
6351
|
+
if (callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6143
6352
|
return callee.property.name === api;
|
|
6144
6353
|
}
|
|
6145
|
-
if (callee.type ===
|
|
6354
|
+
if (callee.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6146
6355
|
return zodImportedNames.get(callee.name) === api;
|
|
6147
6356
|
}
|
|
6148
6357
|
return false;
|
|
6149
6358
|
}
|
|
6150
6359
|
function buildFix(node) {
|
|
6151
6360
|
const callee = node.callee;
|
|
6152
|
-
if (callee.type !==
|
|
6361
|
+
if (callee.type !== import_utils45.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6153
6362
|
return null;
|
|
6154
6363
|
}
|
|
6155
6364
|
const arg = node.arguments[0];
|
|
6156
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6365
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6157
6366
|
return null;
|
|
6158
6367
|
}
|
|
6159
6368
|
const inner = unwrap3(arg);
|
|
6160
|
-
if (inner.type !==
|
|
6369
|
+
if (inner.type !== import_utils45.AST_NODE_TYPES.ObjectExpression) {
|
|
6161
6370
|
return null;
|
|
6162
6371
|
}
|
|
6163
6372
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6177,7 +6386,7 @@ var no_zod_native_enum_default = import_utils44.ESLintUtils.RuleCreator(
|
|
|
6177
6386
|
return;
|
|
6178
6387
|
}
|
|
6179
6388
|
for (const spec of node.specifiers) {
|
|
6180
|
-
if (spec.type ===
|
|
6389
|
+
if (spec.type === import_utils45.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6181
6390
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6182
6391
|
}
|
|
6183
6392
|
}
|
|
@@ -6196,7 +6405,7 @@ var no_zod_native_enum_default = import_utils44.ESLintUtils.RuleCreator(
|
|
|
6196
6405
|
return;
|
|
6197
6406
|
}
|
|
6198
6407
|
const arg = node.arguments[0];
|
|
6199
|
-
if (arg === void 0 || arg.type !==
|
|
6408
|
+
if (arg === void 0 || arg.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6200
6409
|
return;
|
|
6201
6410
|
}
|
|
6202
6411
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6213,7 +6422,7 @@ var no_zod_native_enum_default = import_utils44.ESLintUtils.RuleCreator(
|
|
|
6213
6422
|
});
|
|
6214
6423
|
|
|
6215
6424
|
// src/rules/prefer-module-level-constant.ts
|
|
6216
|
-
var
|
|
6425
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6217
6426
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6218
6427
|
var MAX_LITERAL_DEPTH = 4;
|
|
6219
6428
|
var IGNORE_PATTERNS3 = [
|
|
@@ -6249,9 +6458,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6249
6458
|
"assign"
|
|
6250
6459
|
]);
|
|
6251
6460
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6461
|
+
import_utils46.AST_NODE_TYPES.FunctionDeclaration,
|
|
6462
|
+
import_utils46.AST_NODE_TYPES.FunctionExpression,
|
|
6463
|
+
import_utils46.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6255
6464
|
]);
|
|
6256
6465
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6257
6466
|
function isIgnoredFile3(filename, sourceText) {
|
|
@@ -6264,13 +6473,13 @@ function isTestFile2(filename) {
|
|
|
6264
6473
|
return TEST_FILE_PATTERNS.some((re) => re.test(filename));
|
|
6265
6474
|
}
|
|
6266
6475
|
function unwrap4(node) {
|
|
6267
|
-
if (node.type ===
|
|
6476
|
+
if (node.type === import_utils46.AST_NODE_TYPES.TSAsExpression || node.type === import_utils46.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils46.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6268
6477
|
return unwrap4(node.expression);
|
|
6269
6478
|
}
|
|
6270
6479
|
return node;
|
|
6271
6480
|
}
|
|
6272
6481
|
function isRegexLiteral(node) {
|
|
6273
|
-
return node.type ===
|
|
6482
|
+
return node.type === import_utils46.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6274
6483
|
}
|
|
6275
6484
|
function isLiteralOnly(node, depth) {
|
|
6276
6485
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6278,29 +6487,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6278
6487
|
}
|
|
6279
6488
|
const inner = unwrap4(node);
|
|
6280
6489
|
switch (inner.type) {
|
|
6281
|
-
case
|
|
6490
|
+
case import_utils46.AST_NODE_TYPES.Literal: {
|
|
6282
6491
|
return true;
|
|
6283
6492
|
}
|
|
6284
|
-
case
|
|
6493
|
+
case import_utils46.AST_NODE_TYPES.TemplateLiteral: {
|
|
6285
6494
|
return inner.expressions.length === 0;
|
|
6286
6495
|
}
|
|
6287
|
-
case
|
|
6288
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6496
|
+
case import_utils46.AST_NODE_TYPES.UnaryExpression: {
|
|
6497
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils46.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6289
6498
|
}
|
|
6290
|
-
case
|
|
6499
|
+
case import_utils46.AST_NODE_TYPES.ArrayExpression: {
|
|
6291
6500
|
return inner.elements.every(
|
|
6292
|
-
(el) => el !== null && el.type !==
|
|
6501
|
+
(el) => el !== null && el.type !== import_utils46.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6293
6502
|
);
|
|
6294
6503
|
}
|
|
6295
|
-
case
|
|
6504
|
+
case import_utils46.AST_NODE_TYPES.ObjectExpression: {
|
|
6296
6505
|
return inner.properties.every((prop) => {
|
|
6297
|
-
if (prop.type !==
|
|
6506
|
+
if (prop.type !== import_utils46.AST_NODE_TYPES.Property) {
|
|
6298
6507
|
return false;
|
|
6299
6508
|
}
|
|
6300
6509
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6301
6510
|
return false;
|
|
6302
6511
|
}
|
|
6303
|
-
if (prop.computed && prop.key.type !==
|
|
6512
|
+
if (prop.computed && prop.key.type !== import_utils46.AST_NODE_TYPES.Literal) {
|
|
6304
6513
|
return false;
|
|
6305
6514
|
}
|
|
6306
6515
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6313,7 +6522,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6313
6522
|
}
|
|
6314
6523
|
function unwrapObjectFreeze(node) {
|
|
6315
6524
|
const inner = unwrap4(node);
|
|
6316
|
-
if (inner.type ===
|
|
6525
|
+
if (inner.type === import_utils46.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils46.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils46.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6317
6526
|
return unwrap4(inner.arguments[0]);
|
|
6318
6527
|
}
|
|
6319
6528
|
return inner;
|
|
@@ -6329,19 +6538,19 @@ function classify(init, checkRegex) {
|
|
|
6329
6538
|
}
|
|
6330
6539
|
return { kind: "regex", size: 1 };
|
|
6331
6540
|
}
|
|
6332
|
-
if (node.type ===
|
|
6541
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6333
6542
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6334
6543
|
}
|
|
6335
|
-
if (node.type ===
|
|
6544
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ObjectExpression) {
|
|
6336
6545
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6337
6546
|
}
|
|
6338
|
-
if (node.type ===
|
|
6547
|
+
if (node.type === import_utils46.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils46.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6339
6548
|
const arg = node.arguments[0];
|
|
6340
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6549
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6341
6550
|
return null;
|
|
6342
6551
|
}
|
|
6343
6552
|
const entries = unwrap4(arg);
|
|
6344
|
-
if (entries.type !==
|
|
6553
|
+
if (entries.type !== import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6345
6554
|
return null;
|
|
6346
6555
|
}
|
|
6347
6556
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6370,10 +6579,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6370
6579
|
);
|
|
6371
6580
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6372
6581
|
const callee = node.callee;
|
|
6373
|
-
if (callee.type ===
|
|
6582
|
+
if (callee.type === import_utils46.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6374
6583
|
return true;
|
|
6375
6584
|
}
|
|
6376
|
-
if (callee.type !==
|
|
6585
|
+
if (callee.type !== import_utils46.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils46.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6377
6586
|
return false;
|
|
6378
6587
|
}
|
|
6379
6588
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6387,43 +6596,43 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6387
6596
|
}
|
|
6388
6597
|
function isSafeRead(identifier) {
|
|
6389
6598
|
const parent = identifier.parent;
|
|
6390
|
-
if (parent.type ===
|
|
6599
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.MemberExpression) {
|
|
6391
6600
|
if (parent.object !== identifier) {
|
|
6392
6601
|
return true;
|
|
6393
6602
|
}
|
|
6394
6603
|
const grandparent = parent.parent;
|
|
6395
|
-
if (grandparent.type ===
|
|
6604
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6396
6605
|
return false;
|
|
6397
6606
|
}
|
|
6398
|
-
if (grandparent.type ===
|
|
6607
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.UpdateExpression) {
|
|
6399
6608
|
return false;
|
|
6400
6609
|
}
|
|
6401
|
-
if (grandparent.type ===
|
|
6610
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6402
6611
|
return false;
|
|
6403
6612
|
}
|
|
6404
|
-
if (!parent.computed && parent.property.type ===
|
|
6613
|
+
if (!parent.computed && parent.property.type === import_utils46.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils46.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6405
6614
|
return false;
|
|
6406
6615
|
}
|
|
6407
6616
|
return true;
|
|
6408
6617
|
}
|
|
6409
|
-
if (parent.type ===
|
|
6618
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6410
6619
|
return true;
|
|
6411
6620
|
}
|
|
6412
|
-
if (parent.type ===
|
|
6621
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6413
6622
|
return true;
|
|
6414
6623
|
}
|
|
6415
|
-
if (parent.type ===
|
|
6624
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.BinaryExpression) {
|
|
6416
6625
|
return true;
|
|
6417
6626
|
}
|
|
6418
|
-
if (parent.type ===
|
|
6627
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6419
6628
|
return true;
|
|
6420
6629
|
}
|
|
6421
|
-
if (parent.type ===
|
|
6630
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6422
6631
|
return true;
|
|
6423
6632
|
}
|
|
6424
6633
|
return false;
|
|
6425
6634
|
}
|
|
6426
|
-
var prefer_module_level_constant_default =
|
|
6635
|
+
var prefer_module_level_constant_default = import_utils46.ESLintUtils.RuleCreator(
|
|
6427
6636
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6428
6637
|
)({
|
|
6429
6638
|
name: "prefer-module-level-constant",
|
|
@@ -6475,7 +6684,7 @@ var prefer_module_level_constant_default = import_utils45.ESLintUtils.RuleCreato
|
|
|
6475
6684
|
if (reference.isWrite()) {
|
|
6476
6685
|
return false;
|
|
6477
6686
|
}
|
|
6478
|
-
if (reference.identifier.type !==
|
|
6687
|
+
if (reference.identifier.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6479
6688
|
return false;
|
|
6480
6689
|
}
|
|
6481
6690
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6487,10 +6696,10 @@ var prefer_module_level_constant_default = import_utils45.ESLintUtils.RuleCreato
|
|
|
6487
6696
|
return {
|
|
6488
6697
|
VariableDeclarator(node) {
|
|
6489
6698
|
const declaration = node.parent;
|
|
6490
|
-
if (declaration.type !==
|
|
6699
|
+
if (declaration.type !== import_utils46.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6491
6700
|
return;
|
|
6492
6701
|
}
|
|
6493
|
-
if (node.id.type !==
|
|
6702
|
+
if (node.id.type !== import_utils46.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6494
6703
|
return;
|
|
6495
6704
|
}
|
|
6496
6705
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6516,6 +6725,441 @@ var prefer_module_level_constant_default = import_utils45.ESLintUtils.RuleCreato
|
|
|
6516
6725
|
}
|
|
6517
6726
|
});
|
|
6518
6727
|
|
|
6728
|
+
// src/rules/jsdoc-restates-signature.ts
|
|
6729
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6730
|
+
var VALUE_TAGS = /* @__PURE__ */ new Set([
|
|
6731
|
+
"alpha",
|
|
6732
|
+
"author",
|
|
6733
|
+
"beta",
|
|
6734
|
+
"category",
|
|
6735
|
+
"copyright",
|
|
6736
|
+
"default",
|
|
6737
|
+
"defaultvalue",
|
|
6738
|
+
"deprecated",
|
|
6739
|
+
"example",
|
|
6740
|
+
"experimental",
|
|
6741
|
+
"fileoverview",
|
|
6742
|
+
"fixme",
|
|
6743
|
+
"group",
|
|
6744
|
+
"inheritdoc",
|
|
6745
|
+
"internal",
|
|
6746
|
+
"license",
|
|
6747
|
+
"link",
|
|
6748
|
+
"module",
|
|
6749
|
+
"override",
|
|
6750
|
+
"packagedocumentation",
|
|
6751
|
+
"remarks",
|
|
6752
|
+
"see",
|
|
6753
|
+
"since",
|
|
6754
|
+
"template",
|
|
6755
|
+
"throws",
|
|
6756
|
+
"todo",
|
|
6757
|
+
"typeparam"
|
|
6758
|
+
]);
|
|
6759
|
+
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
6760
|
+
"arg",
|
|
6761
|
+
"argument",
|
|
6762
|
+
"async",
|
|
6763
|
+
"description",
|
|
6764
|
+
"param",
|
|
6765
|
+
"return",
|
|
6766
|
+
"returns"
|
|
6767
|
+
]);
|
|
6768
|
+
var PARAM_TAGS = /* @__PURE__ */ new Set(["arg", "argument", "param"]);
|
|
6769
|
+
var RETURN_TAGS = /* @__PURE__ */ new Set(["return", "returns"]);
|
|
6770
|
+
var DIRECTIVE_RE2 = /^\s*(?:eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__)/i;
|
|
6771
|
+
var STOPWORDS2 = new Set(
|
|
6772
|
+
`the a an of to for in on with and or as at by is are was be been being
|
|
6773
|
+
this that it its if whether when where which what will would can could should
|
|
6774
|
+
must may into from over about not no does do done has have had used use uses
|
|
6775
|
+
using given provided specified current new existing all any each per via based
|
|
6776
|
+
function method component hook class instance object value values data item
|
|
6777
|
+
items element callback handler prop props param parameter argument arg return
|
|
6778
|
+
returns returning result optional required default true false null undefined
|
|
6779
|
+
string number boolean array list promise`.split(/\s+/)
|
|
6780
|
+
);
|
|
6781
|
+
var WORD_RE2 = /[A-Za-z]+/g;
|
|
6782
|
+
function parseJsDoc(value) {
|
|
6783
|
+
const lines = value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, ""));
|
|
6784
|
+
const description = [];
|
|
6785
|
+
const tags = [];
|
|
6786
|
+
let current = null;
|
|
6787
|
+
for (const line of lines) {
|
|
6788
|
+
const match = /^\s*@(\w[\w-]*)\s*(.*)$/.exec(line);
|
|
6789
|
+
if (match) {
|
|
6790
|
+
current = { name: (match[1] ?? "").toLowerCase(), text: match[2] ?? "" };
|
|
6791
|
+
tags.push(current);
|
|
6792
|
+
} else if (current !== null) {
|
|
6793
|
+
current.text += ` ${line.trim()}`;
|
|
6794
|
+
} else {
|
|
6795
|
+
description.push(line);
|
|
6796
|
+
}
|
|
6797
|
+
}
|
|
6798
|
+
return { description: description.join("\n").trim(), tags };
|
|
6799
|
+
}
|
|
6800
|
+
function proseTokens(text) {
|
|
6801
|
+
return (text.match(WORD_RE2) ?? []).map((word) => word.toLowerCase()).filter((word) => word.length > 1 && !STOPWORDS2.has(word));
|
|
6802
|
+
}
|
|
6803
|
+
function covered(text, known) {
|
|
6804
|
+
const stems = /* @__PURE__ */ new Set();
|
|
6805
|
+
for (const token of known) stems.add(stem(token));
|
|
6806
|
+
return proseTokens(text).every((word) => known.has(word) || stems.has(stem(word)));
|
|
6807
|
+
}
|
|
6808
|
+
function declarationNames(node) {
|
|
6809
|
+
switch (node.type) {
|
|
6810
|
+
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
6811
|
+
// after it resolves to the wrapper, not to the thing being documented.
|
|
6812
|
+
case import_utils47.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
6813
|
+
case import_utils47.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
6814
|
+
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
6815
|
+
case import_utils47.AST_NODE_TYPES.FunctionDeclaration:
|
|
6816
|
+
case import_utils47.AST_NODE_TYPES.TSDeclareFunction:
|
|
6817
|
+
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
6818
|
+
case import_utils47.AST_NODE_TYPES.ClassDeclaration:
|
|
6819
|
+
case import_utils47.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
6820
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
6821
|
+
case import_utils47.AST_NODE_TYPES.TSEnumDeclaration:
|
|
6822
|
+
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
6823
|
+
case import_utils47.AST_NODE_TYPES.VariableDeclaration: {
|
|
6824
|
+
const declarator = node.declarations[0];
|
|
6825
|
+
if (declarator === void 0 || declarator.id.type !== import_utils47.AST_NODE_TYPES.Identifier) return null;
|
|
6826
|
+
const init = declarator.init;
|
|
6827
|
+
const params = init != null && (init.type === import_utils47.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils47.AST_NODE_TYPES.FunctionExpression) ? paramNames(init.params) : [];
|
|
6828
|
+
return { name: declarator.id.name, params };
|
|
6829
|
+
}
|
|
6830
|
+
case import_utils47.AST_NODE_TYPES.MethodDefinition:
|
|
6831
|
+
case import_utils47.AST_NODE_TYPES.PropertyDefinition:
|
|
6832
|
+
case import_utils47.AST_NODE_TYPES.TSMethodSignature:
|
|
6833
|
+
case import_utils47.AST_NODE_TYPES.TSPropertySignature: {
|
|
6834
|
+
if (node.key.type !== import_utils47.AST_NODE_TYPES.Identifier) return null;
|
|
6835
|
+
const params = node.type === import_utils47.AST_NODE_TYPES.MethodDefinition ? paramNames(node.value.params) : node.type === import_utils47.AST_NODE_TYPES.TSMethodSignature ? paramNames(node.params) : [];
|
|
6836
|
+
return { name: node.key.name, params };
|
|
6837
|
+
}
|
|
6838
|
+
default:
|
|
6839
|
+
return null;
|
|
6840
|
+
}
|
|
6841
|
+
}
|
|
6842
|
+
function paramNames(params) {
|
|
6843
|
+
const names = [];
|
|
6844
|
+
for (const param of params) {
|
|
6845
|
+
const target = param.type === import_utils47.AST_NODE_TYPES.AssignmentPattern ? param.left : param;
|
|
6846
|
+
if (target.type === import_utils47.AST_NODE_TYPES.Identifier) names.push(target.name);
|
|
6847
|
+
else if (target.type === import_utils47.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
6848
|
+
}
|
|
6849
|
+
return names;
|
|
6850
|
+
}
|
|
6851
|
+
function tokensOf(names) {
|
|
6852
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
6853
|
+
for (const name of names) for (const part of splitIdentifier(name)) tokens.add(part);
|
|
6854
|
+
return tokens;
|
|
6855
|
+
}
|
|
6856
|
+
var jsdoc_restates_signature_default = import_utils47.ESLintUtils.RuleCreator(
|
|
6857
|
+
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6858
|
+
)({
|
|
6859
|
+
name: "jsdoc-restates-signature",
|
|
6860
|
+
meta: {
|
|
6861
|
+
type: "suggestion",
|
|
6862
|
+
hasSuggestions: true,
|
|
6863
|
+
docs: {
|
|
6864
|
+
description: "Flag a JSDoc block whose description and tags only re-spell the signature they document."
|
|
6865
|
+
},
|
|
6866
|
+
schema: [],
|
|
6867
|
+
messages: {
|
|
6868
|
+
restatesSignature: "JSDoc only re-spells the signature \u2014 delete it, or say what the caller cannot read off the name (what it throws, what it assumes, why it exists).",
|
|
6869
|
+
deleteBlock: "Delete the JSDoc block."
|
|
6870
|
+
}
|
|
6871
|
+
},
|
|
6872
|
+
defaultOptions: [],
|
|
6873
|
+
create(context) {
|
|
6874
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
6875
|
+
return {};
|
|
6876
|
+
}
|
|
6877
|
+
const sourceCode = context.sourceCode;
|
|
6878
|
+
return {
|
|
6879
|
+
Program() {
|
|
6880
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
6881
|
+
if (comment.type !== "Block" || !comment.value.startsWith("*")) continue;
|
|
6882
|
+
const { description, tags } = parseJsDoc(comment.value);
|
|
6883
|
+
if (DIRECTIVE_RE2.test(description)) continue;
|
|
6884
|
+
const tagNames = new Set(tags.map((tag) => tag.name));
|
|
6885
|
+
if ([...tagNames].some((name) => VALUE_TAGS.has(name))) continue;
|
|
6886
|
+
if ([...tagNames].some((name) => !MODELLED_TAGS.has(name))) continue;
|
|
6887
|
+
if (isProtected(description)) continue;
|
|
6888
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
6889
|
+
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
6890
|
+
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
6891
|
+
let declaration = null;
|
|
6892
|
+
while (node != null && node.type !== import_utils47.AST_NODE_TYPES.Program) {
|
|
6893
|
+
declaration = declarationNames(node);
|
|
6894
|
+
if (declaration !== null) break;
|
|
6895
|
+
node = node.parent ?? null;
|
|
6896
|
+
}
|
|
6897
|
+
if (declaration === null) continue;
|
|
6898
|
+
const paramTags = tags.filter((tag) => PARAM_TAGS.has(tag.name));
|
|
6899
|
+
const returnTags = tags.filter((tag) => RETURN_TAGS.has(tag.name));
|
|
6900
|
+
if (description.length === 0 && paramTags.length === 0 && returnTags.length === 0) {
|
|
6901
|
+
continue;
|
|
6902
|
+
}
|
|
6903
|
+
const nameTokens = tokensOf([declaration.name]);
|
|
6904
|
+
const paramTokens = tokensOf(declaration.params);
|
|
6905
|
+
const known = /* @__PURE__ */ new Set([...nameTokens, ...paramTokens]);
|
|
6906
|
+
let addsNothing = covered(description, known);
|
|
6907
|
+
for (const tag of paramTags) {
|
|
6908
|
+
const text = tag.text.replace(/^\{[^}]*\}\s*/, "");
|
|
6909
|
+
const match = /^\[?([A-Za-z_$][\w.$]*)\]?\s*-?\s*([\s\S]*)$/.exec(text);
|
|
6910
|
+
if (match === null) {
|
|
6911
|
+
addsNothing = false;
|
|
6912
|
+
break;
|
|
6913
|
+
}
|
|
6914
|
+
const own = /* @__PURE__ */ new Set([...splitIdentifier(match[1]?.split(".").pop() ?? ""), ...nameTokens]);
|
|
6915
|
+
if (!covered(match[2] ?? "", own)) {
|
|
6916
|
+
addsNothing = false;
|
|
6917
|
+
break;
|
|
6918
|
+
}
|
|
6919
|
+
for (const part of splitIdentifier(match[1]?.split(".").pop() ?? "")) known.add(part);
|
|
6920
|
+
}
|
|
6921
|
+
if (addsNothing) {
|
|
6922
|
+
for (const tag of returnTags) {
|
|
6923
|
+
if (!covered(tag.text.replace(/^\{[^}]*\}\s*/, ""), known)) {
|
|
6924
|
+
addsNothing = false;
|
|
6925
|
+
break;
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
}
|
|
6929
|
+
if (!addsNothing) continue;
|
|
6930
|
+
context.report({
|
|
6931
|
+
node: comment,
|
|
6932
|
+
messageId: "restatesSignature",
|
|
6933
|
+
suggest: [
|
|
6934
|
+
{
|
|
6935
|
+
messageId: "deleteBlock",
|
|
6936
|
+
fix: (fixer) => fixer.removeRange([comment.range[0], token.range[0]])
|
|
6937
|
+
}
|
|
6938
|
+
]
|
|
6939
|
+
});
|
|
6940
|
+
}
|
|
6941
|
+
}
|
|
6942
|
+
};
|
|
6943
|
+
}
|
|
6944
|
+
});
|
|
6945
|
+
|
|
6946
|
+
// src/rules/no-restated-comment.ts
|
|
6947
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6948
|
+
var MAX_WORDS = 8;
|
|
6949
|
+
var MIN_CONTENT_TOKENS = 2;
|
|
6950
|
+
var DIRECTIVE_RE3 = /^(eslint\b|eslint-|sarj-noqa\b|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
6951
|
+
var CODEY_RE = /^[\w.$[\]'"]+\s*[:=]\s*\S|^[\w.$]+\s*\(|^(?:return|throw|await|import|export|const|let|var)\b.*[=()[\]{}]/;
|
|
6952
|
+
var BANNERISH_RE = /[=\-─-╿*#~_.]{3,}|^[A-Z0-9 _:-]+$/;
|
|
6953
|
+
var MODALITY_RE = /\b(?:can|could|should|shall|may|might|must|will|would|cannot)\b/i;
|
|
6954
|
+
var LEAD_IN_RE = /:$/;
|
|
6955
|
+
var EMPHASIS_RE = /\*\w[^*]*\*|`[^`]+`/;
|
|
6956
|
+
var NEGATION_WORD_RE = /\b(?:no|not|never|neither|nor|without|none|non)\b/i;
|
|
6957
|
+
var ACTION_STMT_RE = /[\w.$\])]\s*\(|^\s*(?:return|throw|await|yield)\b/;
|
|
6958
|
+
var NON_ASCII_LETTER_RE = /[^\p{ASCII}\p{N}\p{P}\p{Z}]/u;
|
|
6959
|
+
function areAdjacentLineComments2(a, b) {
|
|
6960
|
+
return a !== void 0 && b !== void 0 && a.type === "Line" && b.type === "Line" && b.loc.start.line === a.loc.end.line + 1;
|
|
6961
|
+
}
|
|
6962
|
+
function headsSiblingRun(node) {
|
|
6963
|
+
const parent = node.parent;
|
|
6964
|
+
if (parent === void 0) return false;
|
|
6965
|
+
const body = "body" in parent && Array.isArray(parent.body) ? parent.body : void 0;
|
|
6966
|
+
if (body === void 0) return false;
|
|
6967
|
+
const index = body.indexOf(node);
|
|
6968
|
+
const next = index >= 0 ? body[index + 1] : void 0;
|
|
6969
|
+
return next !== void 0 && next.type === node.type;
|
|
6970
|
+
}
|
|
6971
|
+
var no_restated_comment_default = import_utils48.ESLintUtils.RuleCreator(
|
|
6972
|
+
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6973
|
+
)({
|
|
6974
|
+
name: "no-restated-comment",
|
|
6975
|
+
meta: {
|
|
6976
|
+
type: "suggestion",
|
|
6977
|
+
docs: {
|
|
6978
|
+
description: "Flag a single-line comment whose every word already appears on the statement below it."
|
|
6979
|
+
},
|
|
6980
|
+
schema: [],
|
|
6981
|
+
messages: {
|
|
6982
|
+
restatesLineBelow: "Comment restates the statement below it \u2014 delete it, or replace it with the *why*; the code already carries the *what*."
|
|
6983
|
+
}
|
|
6984
|
+
},
|
|
6985
|
+
defaultOptions: [],
|
|
6986
|
+
create(context) {
|
|
6987
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
6988
|
+
return {};
|
|
6989
|
+
}
|
|
6990
|
+
const sourceCode = context.sourceCode;
|
|
6991
|
+
const lines = sourceCode.lines;
|
|
6992
|
+
function isStandalone(comment) {
|
|
6993
|
+
const before = sourceCode.getTokenBefore(comment, { includeComments: false });
|
|
6994
|
+
return !before || before.loc.end.line < comment.loc.start.line;
|
|
6995
|
+
}
|
|
6996
|
+
function labelsASiblingRun(comment) {
|
|
6997
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
6998
|
+
if (token === null) return false;
|
|
6999
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== import_utils48.AST_NODE_TYPES.Program; node = node.parent) {
|
|
7000
|
+
if (headsSiblingRun(node)) return true;
|
|
7001
|
+
}
|
|
7002
|
+
return false;
|
|
7003
|
+
}
|
|
7004
|
+
return {
|
|
7005
|
+
Program() {
|
|
7006
|
+
const comments = sourceCode.getAllComments();
|
|
7007
|
+
for (let i = 0; i < comments.length; i++) {
|
|
7008
|
+
const comment = comments[i];
|
|
7009
|
+
if (comment === void 0 || comment.type !== "Line") continue;
|
|
7010
|
+
if (!isStandalone(comment)) continue;
|
|
7011
|
+
if (areAdjacentLineComments2(comments[i - 1], comment) || areAdjacentLineComments2(comment, comments[i + 1])) {
|
|
7012
|
+
continue;
|
|
7013
|
+
}
|
|
7014
|
+
const body = comment.value.replace(/^\/*/, "").trim();
|
|
7015
|
+
if (body.length === 0 || body.endsWith("?")) continue;
|
|
7016
|
+
if (DIRECTIVE_RE3.test(body) || CODEY_RE.test(body) || BANNERISH_RE.test(body)) continue;
|
|
7017
|
+
if (NON_ASCII_LETTER_RE.test(body) || isProtected(body)) continue;
|
|
7018
|
+
if (MODALITY_RE.test(body) || LEAD_IN_RE.test(body) || EMPHASIS_RE.test(body)) continue;
|
|
7019
|
+
if (NEGATION_WORD_RE.test(body)) continue;
|
|
7020
|
+
if (body.split(/\s+/).length > MAX_WORDS) continue;
|
|
7021
|
+
const tokens = contentTokens(body);
|
|
7022
|
+
if (tokens.length < MIN_CONTENT_TOKENS) continue;
|
|
7023
|
+
const statement = restatableStatementBelow(comment, sourceCode);
|
|
7024
|
+
if (statement === null) continue;
|
|
7025
|
+
if (restatesStatementHead(body, statement)) continue;
|
|
7026
|
+
const line = lines[comment.loc.start.line] ?? "";
|
|
7027
|
+
if (!ACTION_STMT_RE.test(line)) continue;
|
|
7028
|
+
if (labelsASiblingRun(comment)) continue;
|
|
7029
|
+
if (restates(tokens, codeTokens(line))) {
|
|
7030
|
+
context.report({ node: comment, messageId: "restatesLineBelow" });
|
|
7031
|
+
}
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
};
|
|
7035
|
+
}
|
|
7036
|
+
});
|
|
7037
|
+
|
|
7038
|
+
// src/rules/trailing-value-narration.ts
|
|
7039
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
7040
|
+
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
7041
|
+
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
7042
|
+
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
7043
|
+
"bytes",
|
|
7044
|
+
"characters",
|
|
7045
|
+
"chars",
|
|
7046
|
+
"day",
|
|
7047
|
+
"days",
|
|
7048
|
+
"gb",
|
|
7049
|
+
"hour",
|
|
7050
|
+
"hours",
|
|
7051
|
+
"hr",
|
|
7052
|
+
"hrs",
|
|
7053
|
+
"hz",
|
|
7054
|
+
"items",
|
|
7055
|
+
"k",
|
|
7056
|
+
"kb",
|
|
7057
|
+
"khz",
|
|
7058
|
+
"m",
|
|
7059
|
+
"mb",
|
|
7060
|
+
"milliseconds",
|
|
7061
|
+
"min",
|
|
7062
|
+
"mins",
|
|
7063
|
+
"minute",
|
|
7064
|
+
"minutes",
|
|
7065
|
+
"ms",
|
|
7066
|
+
"pct",
|
|
7067
|
+
"percent",
|
|
7068
|
+
"px",
|
|
7069
|
+
"retries",
|
|
7070
|
+
"rows",
|
|
7071
|
+
"s",
|
|
7072
|
+
"sec",
|
|
7073
|
+
"second",
|
|
7074
|
+
"seconds",
|
|
7075
|
+
"secs",
|
|
7076
|
+
"times",
|
|
7077
|
+
"tokens"
|
|
7078
|
+
]);
|
|
7079
|
+
var STOPWORDS3 = /* @__PURE__ */ new Set([
|
|
7080
|
+
"a",
|
|
7081
|
+
"an",
|
|
7082
|
+
"and",
|
|
7083
|
+
"are",
|
|
7084
|
+
"as",
|
|
7085
|
+
"at",
|
|
7086
|
+
"be",
|
|
7087
|
+
"by",
|
|
7088
|
+
"for",
|
|
7089
|
+
"in",
|
|
7090
|
+
"is",
|
|
7091
|
+
"it",
|
|
7092
|
+
"of",
|
|
7093
|
+
"on",
|
|
7094
|
+
"or",
|
|
7095
|
+
"that",
|
|
7096
|
+
"the",
|
|
7097
|
+
"this",
|
|
7098
|
+
"we",
|
|
7099
|
+
"with"
|
|
7100
|
+
]);
|
|
7101
|
+
var DIRECTIVE_RE4 = /^\s*(?:eslint\b|eslint-|sarj-noqa\b|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
7102
|
+
function numbersIn(text) {
|
|
7103
|
+
return new Set(text.match(NUMBER_RE) ?? []);
|
|
7104
|
+
}
|
|
7105
|
+
function narratesValue(body, code) {
|
|
7106
|
+
if (body.length === 0 || DIRECTIVE_RE4.test(body) || hasExternalReference(body)) return false;
|
|
7107
|
+
const codeNumbers = numbersIn(code);
|
|
7108
|
+
if (codeNumbers.size === 0) return false;
|
|
7109
|
+
const words = (body.match(WORD_RE3) ?? []).map((word) => word.toLowerCase());
|
|
7110
|
+
if (words.length === 0) return false;
|
|
7111
|
+
const commentNumbers = numbersIn(body);
|
|
7112
|
+
if (commentNumbers.size === 0) return false;
|
|
7113
|
+
for (const number of commentNumbers) {
|
|
7114
|
+
if (!codeNumbers.has(number)) return false;
|
|
7115
|
+
}
|
|
7116
|
+
const identifiers = codeTokens(code);
|
|
7117
|
+
const stems = /* @__PURE__ */ new Set();
|
|
7118
|
+
for (const token of identifiers) stems.add(stem(token));
|
|
7119
|
+
return words.every(
|
|
7120
|
+
(word) => STOPWORDS3.has(word) || UNIT_WORDS.has(word) || commentNumbers.has(word) || identifiers.has(word) || stems.has(stem(word))
|
|
7121
|
+
);
|
|
7122
|
+
}
|
|
7123
|
+
var trailing_value_narration_default = import_utils49.ESLintUtils.RuleCreator(
|
|
7124
|
+
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7125
|
+
)({
|
|
7126
|
+
name: "trailing-value-narration",
|
|
7127
|
+
meta: {
|
|
7128
|
+
type: "suggestion",
|
|
7129
|
+
docs: {
|
|
7130
|
+
description: "Flag a trailing comment whose every word and number is already on the line it annotates."
|
|
7131
|
+
},
|
|
7132
|
+
schema: [],
|
|
7133
|
+
messages: {
|
|
7134
|
+
narratesValue: "Trailing comment restates the literal on this line \u2014 put the unit in the name (STALE_TIME_MS) so it cannot drift."
|
|
7135
|
+
}
|
|
7136
|
+
},
|
|
7137
|
+
defaultOptions: [],
|
|
7138
|
+
create(context) {
|
|
7139
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
7140
|
+
return {};
|
|
7141
|
+
}
|
|
7142
|
+
const sourceCode = context.sourceCode;
|
|
7143
|
+
function isTrailing(comment) {
|
|
7144
|
+
const before = sourceCode.getTokenBefore(comment, { includeComments: false });
|
|
7145
|
+
return before !== null && before.loc.end.line === comment.loc.start.line;
|
|
7146
|
+
}
|
|
7147
|
+
return {
|
|
7148
|
+
Program() {
|
|
7149
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
7150
|
+
if (!isTrailing(comment)) continue;
|
|
7151
|
+
const line = sourceCode.lines[comment.loc.start.line - 1] ?? "";
|
|
7152
|
+
const code = line.slice(0, comment.loc.start.column);
|
|
7153
|
+
const body = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
7154
|
+
if (narratesValue(body, code)) {
|
|
7155
|
+
context.report({ node: comment, messageId: "narratesValue" });
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
};
|
|
7160
|
+
}
|
|
7161
|
+
});
|
|
7162
|
+
|
|
6519
7163
|
// src/index.ts
|
|
6520
7164
|
var rules = {
|
|
6521
7165
|
"enforce-file-structure": enforce_file_structure_default,
|
|
@@ -6558,12 +7202,15 @@ var rules = {
|
|
|
6558
7202
|
"no-raw-fetch-outside-clients": no_raw_fetch_outside_clients_default,
|
|
6559
7203
|
"no-storage-in-stateless-modules": no_storage_in_stateless_modules_default,
|
|
6560
7204
|
"no-zod-native-enum": no_zod_native_enum_default,
|
|
6561
|
-
"prefer-module-level-constant": prefer_module_level_constant_default
|
|
7205
|
+
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
7206
|
+
"jsdoc-restates-signature": jsdoc_restates_signature_default,
|
|
7207
|
+
"no-restated-comment": no_restated_comment_default,
|
|
7208
|
+
"trailing-value-narration": trailing_value_narration_default
|
|
6562
7209
|
};
|
|
6563
7210
|
var plugin = {
|
|
6564
7211
|
meta: {
|
|
6565
7212
|
name: "@sarj/eslint-plugin",
|
|
6566
|
-
version: "2.
|
|
7213
|
+
version: "2.13.0"
|
|
6567
7214
|
},
|
|
6568
7215
|
rules,
|
|
6569
7216
|
configs: {
|
|
@@ -6619,7 +7266,18 @@ var plugin = {
|
|
|
6619
7266
|
// Mined from two years of PR review — the single most frequent uncovered
|
|
6620
7267
|
// theme (~37 PRs). Measured 17 hits / 1085 real TS files, all true
|
|
6621
7268
|
// positives, so it is safe to run everywhere.
|
|
6622
|
-
"@sarj/prefer-module-level-constant": "warn"
|
|
7269
|
+
"@sarj/prefer-module-level-constant": "warn",
|
|
7270
|
+
// Anti-comment-verbosity family (2026-07), from a 37,918-comment,
|
|
7271
|
+
// nine-repo measurement study. Each is a deletion-class finding, so each
|
|
7272
|
+
// was validated against pydantic / trio / attrs as well as the maintained
|
|
7273
|
+
// repos: `no-restated-comment` 0 hits in bulbul and 4 in the three famous
|
|
7274
|
+
// corpora combined; `trailing-value-narration` 18 hits, 18 true
|
|
7275
|
+
// positives; `jsdoc-restates-signature` 36 hits, 0 measured false
|
|
7276
|
+
// positives, and it offers a suggestion rather than a `--fix` because a
|
|
7277
|
+
// wrong deletion is silent information loss.
|
|
7278
|
+
"@sarj/no-restated-comment": "warn",
|
|
7279
|
+
"@sarj/jsdoc-restates-signature": "warn",
|
|
7280
|
+
"@sarj/trailing-value-narration": "warn"
|
|
6623
7281
|
}
|
|
6624
7282
|
},
|
|
6625
7283
|
strict: {
|
|
@@ -6682,7 +7340,12 @@ var plugin = {
|
|
|
6682
7340
|
"@sarj/no-storage-in-stateless-modules": "error",
|
|
6683
7341
|
// Mined from two years of PR review (SARJ-928).
|
|
6684
7342
|
"@sarj/no-zod-native-enum": "error",
|
|
6685
|
-
"@sarj/prefer-module-level-constant": "error"
|
|
7343
|
+
"@sarj/prefer-module-level-constant": "error",
|
|
7344
|
+
// Anti-comment-verbosity family (2026-07) — see the `recommended` block
|
|
7345
|
+
// for the measured hit counts and false-positive rates.
|
|
7346
|
+
"@sarj/no-restated-comment": "error",
|
|
7347
|
+
"@sarj/jsdoc-restates-signature": "error",
|
|
7348
|
+
"@sarj/trailing-value-narration": "error"
|
|
6686
7349
|
}
|
|
6687
7350
|
}
|
|
6688
7351
|
}
|