@sarj/eslint-plugin 9.17.0 → 9.17.1

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/dist/index.cjs CHANGED
@@ -3335,6 +3335,8 @@ var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
3335
3335
  var VALUE_TAG_RE = /@(example|deprecated|see|remarks|throws|internal|public|alpha|beta|since|template|fileoverview)\b/i;
3336
3336
  var BOUNDARY_RE = /(?<=[.!?])["'`)\]]*\s+(?=[A-Z0-9`])/;
3337
3337
  var BULLET_RE = /^\s*(?:[-*+] |\d+[.)] )/;
3338
+ var HEADING_RE = /^[A-Za-z][A-Za-z ]+:$/;
3339
+ var TECHNICAL_ANCHOR_RE = /https?:\/\/|`[^`\n]+`|:[a-z][a-z0-9_-]*:|(["'])[^"'\n]+\1|\d|\b[a-z][a-z0-9]*[A-Z][A-Za-z0-9]*\b|\b[A-Za-z][A-Za-z0-9]*_[A-Za-z0-9_]+\b|(?:^|\s)(?:[\w.-]+\/)+[\w.-]+|\b[\w.-]+\.(?:py|pyi|js|jsx|ts|tsx|json|ya?ml|toml|csv|parquet|md)\b|->|=>|==|!=|<=|>=|\|/mu;
3338
3340
  function body(comment) {
3339
3341
  return comment.value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, "")).join("\n").trim();
3340
3342
  }
@@ -3354,6 +3356,17 @@ function sentenceUnits(text) {
3354
3356
  if (prose.length > 0) units += prose.join(" ").split(BOUNDARY_RE).length;
3355
3357
  return units;
3356
3358
  }
3359
+ function hasDocumentationStructure(text) {
3360
+ const paragraphs = text.split(/\n\s*\n/u).filter((part) => part.trim().length > 0);
3361
+ if (paragraphs.length >= 2) return true;
3362
+ return text.split("\n").some((raw) => {
3363
+ const line = raw.trim().replace(/^\*\s?/u, "").trim();
3364
+ return line.length > 0 && (BULLET_RE.test(line) || HEADING_RE.test(line) || /(?:->|=>|\|)/u.test(line));
3365
+ });
3366
+ }
3367
+ function hasTechnicalAnchor(text) {
3368
+ return TECHNICAL_ANCHOR_RE.test(text);
3369
+ }
3357
3370
  function proseGroups(filename, sourceCode, includeValueTags = false) {
3358
3371
  if (isGeneratedFile(filename, sourceCode.text) || isStoryFile(filename) || isScriptFile(filename) || isTestFile(filename)) return [];
3359
3372
  const groups = [];
@@ -3420,10 +3433,8 @@ function typedFunction(node) {
3420
3433
  }
3421
3434
 
3422
3435
  // src/rules/no-long-comment.ts
3423
- var LIST_ITEM_RE = /^\s*(?:[-*+] |\d+[.)] )/m;
3424
- var DURABLE_RATIONALE_RE = /\b(?:adapter|algorithm|atomic|auth(?:entication|orization)?|backpressure|billing|cache|callback|cluster|commit|compatib|concurr|contract|credential|cross-node|csrf|definite-assignment|error|exception|external|failure|fallback|handshake|interop|invalid|invariant|legacy|migration|navigation|parse[rsd]?|payload|privacy|protocol|race|reject|reload|renderer|resume|retry|runtime|schema|security|selector|sentinel|serializ|socket|stage|third-party|token|transaction|upstream|wire|workaround)\b|\b(?:must|required|prevent|avoid)\b/iu;
3425
- var VENDORED_BASENAME_RE = /(?:^|\/)(?:jquery(?:-ui)?(?:[.-]\d[^/]*)?|lodash(?:\.min)?|bootstrap(?:\.min)?|react(?:\.min)?)\.js$/iu;
3426
3436
  var EXCESSIVE_SENTENCE_COUNT = 8;
3437
+ var VERSIONED_DEPENDENCY_TREE_RE = /(?:^|\/)lib\/[^/]*-?v?\d+\.\d+(?:\.\d+)?[^/]*\//iu;
3427
3438
  function documentsTypeOrMember(sourceCode, comment) {
3428
3439
  const token = sourceCode.getTokenAfter(comment, { includeComments: false });
3429
3440
  if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
@@ -3447,11 +3458,11 @@ var no_long_comment_default = createRule({
3447
3458
  defaultOptions: [],
3448
3459
  create(context) {
3449
3460
  const normalizedFilename = context.filename.replaceAll("\\", "/");
3450
- if (VENDORED_BASENAME_RE.test(normalizedFilename)) return {};
3461
+ if (VERSIONED_DEPENDENCY_TREE_RE.test(normalizedFilename)) return {};
3451
3462
  return {
3452
3463
  Program() {
3453
3464
  for (const group of proseGroups(context.filename, context.sourceCode)) {
3454
- if (group.comment.type !== "Block" || group.hasTypedTags || LIST_ITEM_RE.test(group.text) || DURABLE_RATIONALE_RE.test(group.text) || documentsTypedFunction(context.sourceCode, group.comment) || documentsTypeOrMember(context.sourceCode, group.comment) || sentenceUnits(group.text) < EXCESSIVE_SENTENCE_COUNT) continue;
3465
+ if (group.comment.type !== "Block" || !group.comment.value.startsWith("*") || group.hasTypedTags || hasDocumentationStructure(group.text) || hasTechnicalAnchor(group.text) || documentsTypedFunction(context.sourceCode, group.comment) || documentsTypeOrMember(context.sourceCode, group.comment) || sentenceUnits(group.text) < EXCESSIVE_SENTENCE_COUNT) continue;
3455
3466
  context.report({ node: group.comment, messageId: "tooLong" });
3456
3467
  }
3457
3468
  }
@@ -12350,7 +12361,7 @@ var rules = {
12350
12361
  };
12351
12362
  var meta = {
12352
12363
  name: "@sarj/eslint-plugin",
12353
- version: "9.17.0"
12364
+ version: "9.17.1"
12354
12365
  };
12355
12366
  var applicationOnlyRules = [
12356
12367
  "no-restricted-library-load",
package/dist/index.d.cts CHANGED
@@ -458,7 +458,7 @@ type FlatPreset = {
458
458
  declare const plugin: {
459
459
  readonly meta: {
460
460
  readonly name: "@sarj/eslint-plugin";
461
- readonly version: "9.17.0";
461
+ readonly version: "9.17.1";
462
462
  };
463
463
  readonly rules: {
464
464
  readonly "duplicate-test-body": _typescript_eslint_utils_ts_eslint.RuleModule<"duplicateTestBody", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
package/dist/index.d.ts CHANGED
@@ -458,7 +458,7 @@ type FlatPreset = {
458
458
  declare const plugin: {
459
459
  readonly meta: {
460
460
  readonly name: "@sarj/eslint-plugin";
461
- readonly version: "9.17.0";
461
+ readonly version: "9.17.1";
462
462
  };
463
463
  readonly rules: {
464
464
  readonly "duplicate-test-body": _typescript_eslint_utils_ts_eslint.RuleModule<"duplicateTestBody", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
package/dist/index.js CHANGED
@@ -3293,6 +3293,8 @@ var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
3293
3293
  var VALUE_TAG_RE = /@(example|deprecated|see|remarks|throws|internal|public|alpha|beta|since|template|fileoverview)\b/i;
3294
3294
  var BOUNDARY_RE = /(?<=[.!?])["'`)\]]*\s+(?=[A-Z0-9`])/;
3295
3295
  var BULLET_RE = /^\s*(?:[-*+] |\d+[.)] )/;
3296
+ var HEADING_RE = /^[A-Za-z][A-Za-z ]+:$/;
3297
+ var TECHNICAL_ANCHOR_RE = /https?:\/\/|`[^`\n]+`|:[a-z][a-z0-9_-]*:|(["'])[^"'\n]+\1|\d|\b[a-z][a-z0-9]*[A-Z][A-Za-z0-9]*\b|\b[A-Za-z][A-Za-z0-9]*_[A-Za-z0-9_]+\b|(?:^|\s)(?:[\w.-]+\/)+[\w.-]+|\b[\w.-]+\.(?:py|pyi|js|jsx|ts|tsx|json|ya?ml|toml|csv|parquet|md)\b|->|=>|==|!=|<=|>=|\|/mu;
3296
3298
  function body(comment) {
3297
3299
  return comment.value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, "")).join("\n").trim();
3298
3300
  }
@@ -3312,6 +3314,17 @@ function sentenceUnits(text) {
3312
3314
  if (prose.length > 0) units += prose.join(" ").split(BOUNDARY_RE).length;
3313
3315
  return units;
3314
3316
  }
3317
+ function hasDocumentationStructure(text) {
3318
+ const paragraphs = text.split(/\n\s*\n/u).filter((part) => part.trim().length > 0);
3319
+ if (paragraphs.length >= 2) return true;
3320
+ return text.split("\n").some((raw) => {
3321
+ const line = raw.trim().replace(/^\*\s?/u, "").trim();
3322
+ return line.length > 0 && (BULLET_RE.test(line) || HEADING_RE.test(line) || /(?:->|=>|\|)/u.test(line));
3323
+ });
3324
+ }
3325
+ function hasTechnicalAnchor(text) {
3326
+ return TECHNICAL_ANCHOR_RE.test(text);
3327
+ }
3315
3328
  function proseGroups(filename, sourceCode, includeValueTags = false) {
3316
3329
  if (isGeneratedFile(filename, sourceCode.text) || isStoryFile(filename) || isScriptFile(filename) || isTestFile(filename)) return [];
3317
3330
  const groups = [];
@@ -3378,10 +3391,8 @@ function typedFunction(node) {
3378
3391
  }
3379
3392
 
3380
3393
  // src/rules/no-long-comment.ts
3381
- var LIST_ITEM_RE = /^\s*(?:[-*+] |\d+[.)] )/m;
3382
- var DURABLE_RATIONALE_RE = /\b(?:adapter|algorithm|atomic|auth(?:entication|orization)?|backpressure|billing|cache|callback|cluster|commit|compatib|concurr|contract|credential|cross-node|csrf|definite-assignment|error|exception|external|failure|fallback|handshake|interop|invalid|invariant|legacy|migration|navigation|parse[rsd]?|payload|privacy|protocol|race|reject|reload|renderer|resume|retry|runtime|schema|security|selector|sentinel|serializ|socket|stage|third-party|token|transaction|upstream|wire|workaround)\b|\b(?:must|required|prevent|avoid)\b/iu;
3383
- var VENDORED_BASENAME_RE = /(?:^|\/)(?:jquery(?:-ui)?(?:[.-]\d[^/]*)?|lodash(?:\.min)?|bootstrap(?:\.min)?|react(?:\.min)?)\.js$/iu;
3384
3394
  var EXCESSIVE_SENTENCE_COUNT = 8;
3395
+ var VERSIONED_DEPENDENCY_TREE_RE = /(?:^|\/)lib\/[^/]*-?v?\d+\.\d+(?:\.\d+)?[^/]*\//iu;
3385
3396
  function documentsTypeOrMember(sourceCode, comment) {
3386
3397
  const token = sourceCode.getTokenAfter(comment, { includeComments: false });
3387
3398
  if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
@@ -3405,11 +3416,11 @@ var no_long_comment_default = createRule({
3405
3416
  defaultOptions: [],
3406
3417
  create(context) {
3407
3418
  const normalizedFilename = context.filename.replaceAll("\\", "/");
3408
- if (VENDORED_BASENAME_RE.test(normalizedFilename)) return {};
3419
+ if (VERSIONED_DEPENDENCY_TREE_RE.test(normalizedFilename)) return {};
3409
3420
  return {
3410
3421
  Program() {
3411
3422
  for (const group of proseGroups(context.filename, context.sourceCode)) {
3412
- if (group.comment.type !== "Block" || group.hasTypedTags || LIST_ITEM_RE.test(group.text) || DURABLE_RATIONALE_RE.test(group.text) || documentsTypedFunction(context.sourceCode, group.comment) || documentsTypeOrMember(context.sourceCode, group.comment) || sentenceUnits(group.text) < EXCESSIVE_SENTENCE_COUNT) continue;
3423
+ if (group.comment.type !== "Block" || !group.comment.value.startsWith("*") || group.hasTypedTags || hasDocumentationStructure(group.text) || hasTechnicalAnchor(group.text) || documentsTypedFunction(context.sourceCode, group.comment) || documentsTypeOrMember(context.sourceCode, group.comment) || sentenceUnits(group.text) < EXCESSIVE_SENTENCE_COUNT) continue;
3413
3424
  context.report({ node: group.comment, messageId: "tooLong" });
3414
3425
  }
3415
3426
  }
@@ -12314,7 +12325,7 @@ var rules = {
12314
12325
  };
12315
12326
  var meta = {
12316
12327
  name: "@sarj/eslint-plugin",
12317
- version: "9.17.0"
12328
+ version: "9.17.1"
12318
12329
  };
12319
12330
  var applicationOnlyRules = [
12320
12331
  "no-restricted-library-load",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/eslint-plugin",
3
- "version": "9.17.0",
3
+ "version": "9.17.1",
4
4
  "packageManager": "npm@11.19.0",
5
5
  "description": "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6
6
  "type": "module",