@interlace/eslint-devkit 1.4.4 → 1.6.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.
Files changed (43) hide show
  1. package/package.json +22 -12
  2. package/src/aria-definitions.js +0 -14
  3. package/src/ast/ast-utils.js +0 -72
  4. package/src/ast/index.js +0 -6
  5. package/src/ast-node-types.d.ts +29 -0
  6. package/src/ast-node-types.js +174 -0
  7. package/src/index.d.ts +11 -2
  8. package/src/index.js +5 -38
  9. package/src/messaging/config.js +0 -88
  10. package/src/messaging/constants.js +20 -142
  11. package/src/messaging/formatters-ai.js +0 -89
  12. package/src/messaging/formatters-v2.js +0 -151
  13. package/src/messaging/formatters.js +2 -145
  14. package/src/messaging/index.js +0 -6
  15. package/src/messaging/types-v2.js +0 -5
  16. package/src/messaging/types.js +0 -5
  17. package/src/node/fs.js +0 -61
  18. package/src/node/index.js +0 -6
  19. package/src/node/os.js +0 -33
  20. package/src/node/path.js +0 -126
  21. package/src/resolver/dependency-analysis.js +64 -562
  22. package/src/resolver/index.js +0 -6
  23. package/src/resolver/resolver-adapter.js +0 -39
  24. package/src/resolver/resolver-detection.js +0 -48
  25. package/src/resolver/resolver.d.ts +11 -0
  26. package/src/resolver/resolver.js +49 -112
  27. package/src/resolver.js +0 -5
  28. package/src/rule-creation/index.d.ts +1 -0
  29. package/src/rule-creation/index.js +1 -6
  30. package/src/rule-creation/mock-context.d.ts +5 -0
  31. package/src/rule-creation/mock-context.js +1 -9
  32. package/src/rule-creation/rule-creator.d.ts +59 -10
  33. package/src/rule-creation/rule-creator.js +64 -40
  34. package/src/rule-creation/sql-injection-rule.d.ts +68 -0
  35. package/src/rule-creation/sql-injection-rule.js +116 -0
  36. package/src/security/index.js +0 -6
  37. package/src/security/security-utils.js +9 -287
  38. package/src/types/index.js +0 -9
  39. package/src/types/meta-augmentation.js +0 -5
  40. package/src/types/type-utils.d.ts +1 -1
  41. package/src/types/type-utils.js +34 -145
  42. package/AGENTS.md +0 -151
  43. package/CHANGELOG.md +0 -153
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2025 Ofri Peretz
4
- * Licensed under the MIT License. Use of this source code is governed by the
5
- * MIT license that can be found in the LICENSE file.
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.DEFAULT_USER_INPUT_PATTERNS = exports.SAFE_ORM_PATTERNS = exports.SAFE_ANNOTATIONS = exports.VALIDATION_PATTERNS = exports.SANITIZATION_FUNCTIONS = void 0;
9
4
  exports.isSanitizationCall = isSanitizationCall;
@@ -27,12 +22,7 @@ exports.formatComplianceTags = formatComplianceTags;
27
22
  exports.buildTicketUrl = buildTicketUrl;
28
23
  exports.getDocumentationUrl = getDocumentationUrl;
29
24
  exports.enhanceMessageData = enhanceMessageData;
30
- /**
31
- * Common sanitization function names
32
- * These functions are typically used to sanitize/escape user input
33
- */
34
25
  exports.SANITIZATION_FUNCTIONS = [
35
- // General sanitization
36
26
  'sanitize',
37
27
  'sanitizeInput',
38
28
  'sanitizeHtml',
@@ -46,7 +36,6 @@ exports.SANITIZATION_FUNCTIONS = [
46
36
  'cleanInput',
47
37
  'purify',
48
38
  'DOMPurify',
49
- // Escaping
50
39
  'escape',
51
40
  'escapeHtml',
52
41
  'escapeString',
@@ -55,14 +44,12 @@ exports.SANITIZATION_FUNCTIONS = [
55
44
  'escapeShell',
56
45
  'htmlEscape',
57
46
  'sqlEscape',
58
- // Encoding
59
47
  'encode',
60
48
  'encodeURIComponent',
61
49
  'encodeURI',
62
50
  'htmlEncode',
63
51
  'urlEncode',
64
52
  'base64Encode',
65
- // Validation (implies the value was checked)
66
53
  'validate',
67
54
  'validateInput',
68
55
  'validateEmail',
@@ -73,27 +60,20 @@ exports.SANITIZATION_FUNCTIONS = [
73
60
  'isValidEmail',
74
61
  'isValidUrl',
75
62
  'assertValid',
76
- // Type coercion (safe transformations)
77
63
  'parseInt',
78
64
  'parseFloat',
79
65
  'Number',
80
66
  'Boolean',
81
67
  'String',
82
68
  'BigInt',
83
- // Common library functions
84
- 'xss', // xss library
69
+ 'xss',
85
70
  'filterXSS',
86
- 'strip_tags', // PHP-style
71
+ 'strip_tags',
87
72
  'stripTags',
88
- 'bleach', // Python bleach library pattern
89
- 'validator', // validator.js
73
+ 'bleach',
74
+ 'validator',
90
75
  ];
91
- /**
92
- * Common validation library method patterns
93
- * Format: objectName.methodName
94
- */
95
76
  exports.VALIDATION_PATTERNS = [
96
- // validator.js patterns
97
77
  'validator.escape',
98
78
  'validator.isEmail',
99
79
  'validator.isURL',
@@ -105,7 +85,6 @@ exports.VALIDATION_PATTERNS = [
105
85
  'validator.normalizeEmail',
106
86
  'validator.whitelist',
107
87
  'validator.blacklist',
108
- // Zod patterns
109
88
  'z.string',
110
89
  'z.number',
111
90
  'z.boolean',
@@ -113,28 +92,23 @@ exports.VALIDATION_PATTERNS = [
113
92
  'z.object',
114
93
  'schema.parse',
115
94
  'schema.safeParse',
116
- // Yup patterns
117
95
  'yup.string',
118
96
  'yup.number',
119
97
  'string().email',
120
98
  'string().url',
121
99
  'string().uuid',
122
- // Joi patterns
123
100
  'Joi.string',
124
101
  'Joi.number',
125
102
  'joi.string',
126
103
  'joi.number',
127
- // class-validator patterns
128
104
  'IsEmail',
129
105
  'IsUrl',
130
106
  'IsUUID',
131
107
  'IsString',
132
108
  'IsNumber',
133
109
  'IsNotEmpty',
134
- // DOMPurify
135
110
  'DOMPurify.sanitize',
136
111
  'purify.sanitize',
137
- // Express-validator
138
112
  'body().escape',
139
113
  'body().trim',
140
114
  'body().isEmail',
@@ -144,9 +118,6 @@ exports.VALIDATION_PATTERNS = [
144
118
  'validationResult',
145
119
  'matchedData',
146
120
  ];
147
- /**
148
- * Safe JSDoc annotations that indicate the value has been validated/sanitized
149
- */
150
121
  exports.SAFE_ANNOTATIONS = [
151
122
  '@safe',
152
123
  '@safe-loop',
@@ -158,11 +129,7 @@ exports.SAFE_ANNOTATIONS = [
158
129
  '@verified',
159
130
  '@timing-safe',
160
131
  ];
161
- /**
162
- * ORM method patterns that are considered safe (use parameterized queries internally)
163
- */
164
132
  exports.SAFE_ORM_PATTERNS = [
165
- // Prisma
166
133
  'prisma.',
167
134
  '.findUnique(',
168
135
  '.findFirst(',
@@ -177,7 +144,6 @@ exports.SAFE_ORM_PATTERNS = [
177
144
  '.aggregate(',
178
145
  '.groupBy(',
179
146
  '.count(',
180
- // TypeORM
181
147
  '.createQueryBuilder(',
182
148
  '.getRepository(',
183
149
  '.find(',
@@ -186,14 +152,12 @@ exports.SAFE_ORM_PATTERNS = [
186
152
  '.save(',
187
153
  '.remove(',
188
154
  '.softDelete(',
189
- // Sequelize
190
155
  'Model.findAll',
191
156
  'Model.findOne',
192
157
  'Model.findByPk',
193
158
  'Model.create',
194
159
  'Model.update',
195
160
  'Model.destroy',
196
- // Knex (when using builder pattern)
197
161
  '.where(',
198
162
  '.andWhere(',
199
163
  '.orWhere(',
@@ -202,7 +166,6 @@ exports.SAFE_ORM_PATTERNS = [
202
166
  '.whereBetween(',
203
167
  '.insert(',
204
168
  '.returning(',
205
- // Mongoose
206
169
  '.findById(',
207
170
  '.findByIdAndUpdate(',
208
171
  '.findByIdAndDelete(',
@@ -213,35 +176,18 @@ exports.SAFE_ORM_PATTERNS = [
213
176
  '.deleteOne({',
214
177
  '.deleteMany({',
215
178
  ];
216
- /**
217
- * Check if a node represents a call to a sanitization function
218
- *
219
- * @example
220
- * ```typescript
221
- * // Returns true for:
222
- * sanitize(userInput)
223
- * escape(userInput)
224
- * DOMPurify.sanitize(html)
225
- * validator.escape(input)
226
- * ```
227
- */
228
179
  function isSanitizationCall(node, customFunctions = []) {
229
180
  const allFunctions = new Set([...exports.SANITIZATION_FUNCTIONS, ...customFunctions]);
230
181
  if (node.type === 'CallExpression') {
231
182
  const callee = node.callee;
232
- // Direct function call: sanitize(input)
233
183
  if (callee.type === 'Identifier') {
234
184
  return allFunctions.has(callee.name);
235
185
  }
236
- // Method call: DOMPurify.sanitize(input)
237
186
  if (callee.type === 'MemberExpression') {
238
- // Get the full method path (e.g., "DOMPurify.sanitize")
239
187
  const methodPath = getMemberExpressionPath(callee);
240
- // Check against validation patterns
241
188
  if (exports.VALIDATION_PATTERNS.some((pattern) => methodPath.includes(pattern))) {
242
189
  return true;
243
190
  }
244
- // Check if the method name itself is a sanitization function
245
191
  if (callee.property.type === 'Identifier') {
246
192
  return allFunctions.has(callee.property.name);
247
193
  }
@@ -249,9 +195,6 @@ function isSanitizationCall(node, customFunctions = []) {
249
195
  }
250
196
  return false;
251
197
  }
252
- /**
253
- * Get the full path of a member expression (e.g., "a.b.c")
254
- */
255
198
  function getMemberExpressionPath(node) {
256
199
  const parts = [];
257
200
  let current = node;
@@ -266,31 +209,16 @@ function getMemberExpressionPath(node) {
266
209
  }
267
210
  return parts.join('.');
268
211
  }
269
- /**
270
- * Check if a variable was assigned from a sanitization call
271
- * Traces back through variable assignments to find sanitization
272
- *
273
- * @example
274
- * ```typescript
275
- * const clean = sanitize(userInput);
276
- * db.query(`SELECT * FROM users WHERE name = '${clean}'`);
277
- * // ^ This should NOT be flagged - clean was sanitized
278
- * ```
279
- */
280
212
  function isSanitizedInput(node, context, customFunctions = []) {
281
- // If it's a direct sanitization call, it's safe
282
213
  if (isSanitizationCall(node, customFunctions)) {
283
214
  return true;
284
215
  }
285
- // If it's an identifier, check if it was assigned from a sanitization call
286
216
  if (node.type === 'Identifier') {
287
217
  const scope = context.sourceCode.getScope?.(node) ??
288
218
  (context.getScope ? context.getScope() : null);
289
219
  if (scope) {
290
- // Find the variable
291
220
  const variable = scope.variables.find((v) => v.name === node.name);
292
221
  if (variable) {
293
- // Check each definition
294
222
  for (const def of variable.defs) {
295
223
  if (def.node.type === 'VariableDeclarator' && def.node.init) {
296
224
  if (isSanitizationCall(def.node.init, customFunctions)) {
@@ -303,21 +231,9 @@ function isSanitizedInput(node, context, customFunctions = []) {
303
231
  }
304
232
  return false;
305
233
  }
306
- /**
307
- * Check if a node or its parent function has a safe JSDoc annotation
308
- *
309
- * @example
310
- * ```typescript
311
- * /** @safe - Input validated by middleware *\/
312
- * function processInput(input) {
313
- * db.query(`SELECT * FROM users WHERE name = '${input}'`);
314
- * }
315
- * ```
316
- */
317
234
  function hasSafeAnnotation(node, context, customAnnotations = []) {
318
235
  const allAnnotations = [...exports.SAFE_ANNOTATIONS, ...customAnnotations];
319
236
  const sourceCode = context.sourceCode;
320
- // Check for inline comments directly before the node and its ancestors
321
237
  let current = node;
322
238
  while (current) {
323
239
  const comments = sourceCode.getCommentsBefore(current);
@@ -327,7 +243,6 @@ function hasSafeAnnotation(node, context, customAnnotations = []) {
327
243
  return true;
328
244
  }
329
245
  }
330
- // Stop at function boundaries to avoid checking unrelated comments
331
246
  if (current.type === 'FunctionDeclaration' ||
332
247
  current.type === 'FunctionExpression' ||
333
248
  current.type === 'ArrowFunctionExpression' ||
@@ -336,36 +251,18 @@ function hasSafeAnnotation(node, context, customAnnotations = []) {
336
251
  }
337
252
  current = current.parent;
338
253
  }
339
- // NOTE: a second pass that re-checked the innermost function's JSDoc was
340
- // removed as provably redundant: the walk above already inspects the
341
- // comments before every ancestor on the same parent chain — including the
342
- // containing function/method — before breaking at the function boundary,
343
- // and with the same annotation predicate.
344
254
  return false;
345
255
  }
346
- /**
347
- * Check if a call expression is using an ORM's safe methods
348
- *
349
- * @example
350
- * ```typescript
351
- * // Returns true - ORM handles parameterization
352
- * prisma.user.findMany({ where: { name: userInput } });
353
- * userRepository.createQueryBuilder().where('name = :name', { name: userInput });
354
- * ```
355
- */
356
256
  function isOrmMethodCall(node, context, customPatterns = []) {
357
257
  const allPatterns = [...exports.SAFE_ORM_PATTERNS, ...customPatterns];
358
258
  const sourceCode = context.sourceCode;
359
259
  if (node.type === 'CallExpression') {
360
260
  const callText = sourceCode.getText(node);
361
- // Check if the call matches any safe ORM pattern
362
261
  if (allPatterns.some((pattern) => callText.includes(pattern))) {
363
262
  return true;
364
263
  }
365
- // Check if it's a chained method call on a known ORM
366
264
  if (node.callee.type === 'MemberExpression') {
367
265
  const methodPath = getMemberExpressionPath(node.callee);
368
- // Check for common ORM object names
369
266
  const ormNames = [
370
267
  'prisma',
371
268
  'sequelize',
@@ -381,61 +278,29 @@ function isOrmMethodCall(node, context, customPatterns = []) {
381
278
  }
382
279
  return false;
383
280
  }
384
- /**
385
- * Check if a query uses parameterized placeholders
386
- *
387
- * @example
388
- * ```typescript
389
- * // Returns true - parameterized
390
- * db.query('SELECT * FROM users WHERE id = ?', [userId]);
391
- * db.query('SELECT * FROM users WHERE id = $1', [userId]);
392
- * db.query('SELECT * FROM users WHERE id = :id', { id: userId });
393
- * ```
394
- */
395
281
  function isParameterizedQuery(queryText) {
396
- // Check for common parameterized query placeholders
397
282
  const placeholderPatterns = [
398
- /\?/, // MySQL/SQLite style: ?
399
- /\$\d+/, // PostgreSQL style: $1, $2
400
- /:\w+/, // Named parameters: :id, :name
401
- /@\w+/, // SQL Server style: @id
283
+ /\?/,
284
+ /\$\d+/,
285
+ /:\w+/,
286
+ /@\w+/,
402
287
  ];
403
288
  return placeholderPatterns.some((pattern) => pattern.test(queryText));
404
289
  }
405
- /**
406
- * Combined check: is the input safe from injection?
407
- *
408
- * This function combines all safety checks:
409
- * 1. Sanitization function calls
410
- * 2. Safe JSDoc annotations
411
- * 3. ORM method calls
412
- * 4. Type-constrained values (when available)
413
- *
414
- * @example
415
- * ```typescript
416
- * if (isInputSafe(node, context)) {
417
- * return; // Don't report - input is safe
418
- * }
419
- * ```
420
- */
421
290
  function isInputSafe(node, context, options = {}) {
422
291
  const { customSanitizers = [], customAnnotations = [], customOrmPatterns = [], } = options;
423
- // Check for sanitization
424
292
  if (isSanitizedInput(node, context, customSanitizers)) {
425
293
  return true;
426
294
  }
427
- // For binary expressions, check if left or right side is sanitized
428
295
  if (node.type === 'BinaryExpression') {
429
296
  if (isSanitizedInput(node.left, context, customSanitizers) ||
430
297
  isSanitizedInput(node.right, context, customSanitizers)) {
431
298
  return true;
432
299
  }
433
300
  }
434
- // Check for safe annotations
435
301
  if (hasSafeAnnotation(node, context, customAnnotations)) {
436
302
  return true;
437
303
  }
438
- // Check parent call for ORM patterns
439
304
  let current = node;
440
305
  while (current) {
441
306
  if (current.type === 'CallExpression') {
@@ -447,18 +312,12 @@ function isInputSafe(node, context, options = {}) {
447
312
  }
448
313
  return false;
449
314
  }
450
- /**
451
- * Apply security rule options to configure safety checking
452
- */
453
315
  function createSafetyChecker(options = {}) {
454
316
  const { trustedSanitizers = [], trustedAnnotations = [], trustedOrmPatterns = [], strictMode = false, } = options;
455
317
  return {
456
- /**
457
- * Check if input should be considered safe (skip reporting)
458
- */
459
318
  isSafe(node, context) {
460
319
  if (strictMode) {
461
- return false; // In strict mode, never consider anything safe
320
+ return false;
462
321
  }
463
322
  return isInputSafe(node, context, {
464
323
  customSanitizers: trustedSanitizers,
@@ -466,17 +325,11 @@ function createSafetyChecker(options = {}) {
466
325
  customOrmPatterns: trustedOrmPatterns,
467
326
  });
468
327
  },
469
- /**
470
- * Check specifically for sanitization
471
- */
472
328
  isSanitized(node, context) {
473
329
  if (strictMode)
474
330
  return false;
475
331
  return isSanitizedInput(node, context, trustedSanitizers);
476
332
  },
477
- /**
478
- * Check specifically for safe annotations
479
- */
480
333
  hasAnnotation(node, context) {
481
334
  if (strictMode)
482
335
  return false;
@@ -484,41 +337,9 @@ function createSafetyChecker(options = {}) {
484
337
  },
485
338
  };
486
339
  }
487
- /**
488
- * Wrapper function to check if a node should be skipped due to safety checks.
489
- * This consolidates the common pattern used across 75+ locations in security rules:
490
- *
491
- * ```typescript
492
- * // Instead of this (3-5 lines each, 75+ occurrences):
493
- * if (safetyChecker.isSafe(node, context)) {
494
- * return;
495
- * }
496
- *
497
- * // Use this (1 line):
498
- * if (shouldSkipForSafety(safetyChecker, node, context)) return;
499
- * ```
500
- *
501
- * @example
502
- * ```typescript
503
- * const safetyChecker = createSafetyChecker(options);
504
- *
505
- * CallExpression(node) {
506
- * // Early return if the node is safe
507
- * if (shouldSkipForSafety(safetyChecker, node, context)) return;
508
- *
509
- * // Continue with detection logic...
510
- * }
511
- * ```
512
- */
513
340
  function shouldSkipForSafety(safetyChecker, node, context) {
514
341
  return safetyChecker.isSafe(node, context);
515
342
  }
516
- // ============================================================================
517
- // AST TRAVERSAL UTILITIES
518
- // ============================================================================
519
- /**
520
- * Loop node types for checking if inside a loop
521
- */
522
343
  const LOOP_NODE_TYPES = new Set([
523
344
  'ForStatement',
524
345
  'WhileStatement',
@@ -526,31 +347,12 @@ const LOOP_NODE_TYPES = new Set([
526
347
  'ForInStatement',
527
348
  'ForOfStatement',
528
349
  ]);
529
- /**
530
- * Function node types for finding function boundaries
531
- */
532
350
  const FUNCTION_NODE_TYPES = new Set([
533
351
  'FunctionDeclaration',
534
352
  'FunctionExpression',
535
353
  'ArrowFunctionExpression',
536
354
  'MethodDefinition',
537
355
  ]);
538
- /**
539
- * Find an ancestor node matching a predicate, with bounded traversal depth.
540
- * This prevents infinite loops and ensures O(1) bounded performance.
541
- *
542
- * @example
543
- * ```typescript
544
- * // Find the containing function
545
- * const containingFn = findAncestor(node, n => FUNCTION_NODE_TYPES.has(n.type));
546
- *
547
- * // Find if inside a loop
548
- * const loopAncestor = findAncestor(node, n => LOOP_NODE_TYPES.has(n.type));
549
- * if (loopAncestor) {
550
- * // Node is inside a loop
551
- * }
552
- * ```
553
- */
554
356
  function findAncestor(node, predicate, maxDepth = 20) {
555
357
  let current = node.parent;
556
358
  let depth = 0;
@@ -563,76 +365,28 @@ function findAncestor(node, predicate, maxDepth = 20) {
563
365
  }
564
366
  return null;
565
367
  }
566
- /**
567
- * Check if a node is inside a loop (for, while, do-while, for-in, for-of).
568
- *
569
- * @example
570
- * ```typescript
571
- * if (isInsideLoop(node)) {
572
- * context.report({
573
- * node,
574
- * messageId: 'resourceAllocationInLoop',
575
- * });
576
- * }
577
- * ```
578
- */
579
368
  function isInsideLoop(node) {
580
369
  return findAncestor(node, n => LOOP_NODE_TYPES.has(n.type)) !== null;
581
370
  }
582
- /**
583
- * Check if a node is inside a function (for scope analysis).
584
- */
585
371
  function isInsideFunction(node) {
586
372
  return findAncestor(node, n => FUNCTION_NODE_TYPES.has(n.type)) !== null;
587
373
  }
588
- /**
589
- * Get the containing function node, or null if not inside a function.
590
- */
591
374
  function getContainingFunction(node) {
592
375
  return findAncestor(node, n => FUNCTION_NODE_TYPES.has(n.type));
593
376
  }
594
- // ============================================================================
595
- // USER INPUT DETECTION UTILITIES
596
- // ============================================================================
597
- /**
598
- * Default user input variable patterns
599
- */
600
377
  exports.DEFAULT_USER_INPUT_PATTERNS = [
601
378
  'req', 'request', 'body', 'query', 'params',
602
379
  'input', 'data', 'userInput', 'userData',
603
380
  'args', 'argv', 'env', 'process.env',
604
381
  ];
605
- /**
606
- * Check if a variable name suggests user input
607
- *
608
- * @example
609
- * ```typescript
610
- * if (isUserInputIdentifier('reqBody', DEFAULT_USER_INPUT_PATTERNS)) {
611
- * // This variable name suggests user input
612
- * }
613
- * ```
614
- */
615
382
  function isUserInputIdentifier(name, patterns = exports.DEFAULT_USER_INPUT_PATTERNS) {
616
383
  const lowerName = name.toLowerCase();
617
384
  return patterns.some(pattern => lowerName.includes(pattern.toLowerCase()));
618
385
  }
619
- /**
620
- * Check if an expression contains user input references
621
- *
622
- * @example
623
- * ```typescript
624
- * if (isUserInputExpression(node, sourceCode, ['req', 'userInput'])) {
625
- * context.report({ node, messageId: 'userControlledInput' });
626
- * }
627
- * ```
628
- */
629
386
  function isUserInputExpression(expression, sourceCode, patterns = exports.DEFAULT_USER_INPUT_PATTERNS) {
630
387
  const exprText = sourceCode.getText(expression);
631
388
  return patterns.some(pattern => exprText.includes(pattern));
632
389
  }
633
- // ============================================================================
634
- // SEVERITY AND COMPLIANCE HELPERS
635
- // ============================================================================
636
390
  const SEVERITY_ORDER = {
637
391
  CRITICAL: 5,
638
392
  HIGH: 4,
@@ -640,48 +394,27 @@ const SEVERITY_ORDER = {
640
394
  LOW: 2,
641
395
  INFO: 1,
642
396
  };
643
- /**
644
- * Check if a severity level meets or exceeds a minimum threshold
645
- */
646
397
  function meetsSeverityThreshold(severity, minSeverity) {
647
398
  return SEVERITY_ORDER[severity] >= SEVERITY_ORDER[minSeverity];
648
399
  }
649
- /**
650
- * Get the effective severity level based on options and context
651
- *
652
- * @example
653
- * ```typescript
654
- * const effectiveSeverity = getEffectiveSeverity('HIGH', options.severity, {
655
- * pattern: 'user-input', // optional context for pattern matching
656
- * });
657
- * ```
658
- */
659
400
  function getEffectiveSeverity(defaultSeverity, override, context) {
660
401
  if (!override) {
661
402
  return defaultSeverity;
662
403
  }
663
- // Pattern-based override takes precedence
664
404
  if (context?.pattern && override.patterns?.[context.pattern]) {
665
405
  return override.patterns[context.pattern];
666
406
  }
667
- // Simple level override
668
407
  if (override.level) {
669
408
  return override.level;
670
409
  }
671
410
  return defaultSeverity;
672
411
  }
673
- /**
674
- * Check if an issue should be reported based on severity threshold
675
- */
676
412
  function shouldReportSeverity(severity, override) {
677
413
  if (!override?.minSeverity) {
678
414
  return true;
679
415
  }
680
416
  return meetsSeverityThreshold(severity, override.minSeverity);
681
417
  }
682
- /**
683
- * Build compliance tags string for error messages
684
- */
685
418
  function formatComplianceTags(defaultFrameworks, complianceContext) {
686
419
  const allFrameworks = [
687
420
  ...defaultFrameworks,
@@ -690,19 +423,14 @@ function formatComplianceTags(defaultFrameworks, complianceContext) {
690
423
  if (allFrameworks.length === 0) {
691
424
  return '';
692
425
  }
693
- // Limit to 4 frameworks for message brevity
694
426
  const display = allFrameworks.slice(0, 4);
695
427
  return `[${display.join(',')}]`;
696
428
  }
697
- /**
698
- * Build ticket URL from template
699
- */
700
429
  function buildTicketUrl(template, data) {
701
430
  if (!template?.url) {
702
431
  return undefined;
703
432
  }
704
433
  let url = template.url;
705
- // Replace placeholders
706
434
  url = url.replace(/\{\{summary\}\}/g, encodeURIComponent(data.summary));
707
435
  url = url.replace(/\{\{description\}\}/g, encodeURIComponent(data.description ?? ''));
708
436
  url = url.replace(/\{\{priority\}\}/g, template.priority ?? 'Medium');
@@ -712,15 +440,9 @@ function buildTicketUrl(template, data) {
712
440
  url = url.replace(/\{\{line\}\}/g, String(data.line ?? 0));
713
441
  return url;
714
442
  }
715
- /**
716
- * Get documentation URL with fallback to organization-specific docs
717
- */
718
443
  function getDocumentationUrl(defaultUrl, complianceContext) {
719
444
  return complianceContext?.documentationUrl ?? defaultUrl;
720
445
  }
721
- /**
722
- * Create enhanced message data with compliance context
723
- */
724
446
  function enhanceMessageData(baseData, options, context) {
725
447
  const complianceContext = options.compliance;
726
448
  return {
@@ -1,14 +1,5 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2025 Ofri Peretz
4
- * Licensed under the MIT License. Use of this source code is governed by the
5
- * MIT license that can be found in the LICENSE file.
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  const tslib_1 = require("tslib");
9
- // Type utilities for ESLint rules
10
4
  tslib_1.__exportStar(require("./type-utils"), exports);
11
- // Module augmentation — adds meta.docs.cwe + cvss to RuleMetaDataDocs.
12
- // Side-effect-only import; activates the declaration project-wide so
13
- // every plugin's rule meta gains the Interlace fields.
14
5
  require("./meta-augmentation");
@@ -1,7 +1,2 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2025 Ofri Peretz
4
- * Licensed under the MIT License. Use of this source code is governed by the
5
- * MIT license that can be found in the LICENSE file.
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,7 +10,7 @@
10
10
  * Provides utilities for type-aware linting rules
11
11
  */
12
12
  import type { ParserServices, TSESTree } from '@typescript-eslint/utils';
13
- import * as ts from 'typescript';
13
+ import type * as ts from 'typescript';
14
14
  /**
15
15
  * Context type that can have parser services
16
16
  * Compatible with both ESLint 8 (context.parserServices) and ESLint 9 (context.sourceCode.parserServices)