@interlace/eslint-devkit 1.3.3 → 1.4.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.
@@ -97,6 +97,7 @@ function normalizeResolverSettings(settings) {
97
97
  });
98
98
  }
99
99
  // Sort by priority (lower number = higher priority)
100
+ // oxlint-disable-next-line no-array-sort
100
101
  return normalized.sort((a, b) => a.priority - b.priority);
101
102
  }
102
103
  /**
@@ -92,6 +92,7 @@ function generateRecommendedConfig(workspaceRoot) {
92
92
  return { settings, recommendations };
93
93
  }
94
94
  // Prioritize resolvers
95
+ // oxlint-disable-next-line no-array-sort
95
96
  const prioritized = availableResolvers.sort((a, b) => {
96
97
  const priorityOrder = ['typescript', 'webpack', 'vite', 'rollup', 'css'];
97
98
  const aIndex = priorityOrder.indexOf(a.name);
@@ -120,11 +121,12 @@ function migrateFromEslintImport(oldConfig) {
120
121
  const migrated = {};
121
122
  const warnings = [];
122
123
  const suggestions = [];
123
- // Migrate settings
124
+ // Migrate settings. The leading truthy check (`oldSettings &&`) already
125
+ // excludes null/undefined, so the later `!== null` was redundant
126
+ // (CodeQL: `js/comparison-between-incompatible-types`).
124
127
  const oldSettings = oldConfig['settings'];
125
128
  if (oldSettings &&
126
129
  typeof oldSettings === 'object' &&
127
- oldSettings !== null &&
128
130
  'import/resolver' in oldSettings) {
129
131
  migrated['settings'] = {
130
132
  ...oldSettings,
@@ -132,20 +134,23 @@ function migrateFromEslintImport(oldConfig) {
132
134
  };
133
135
  suggestions.push('Resolver settings preserved - no changes needed');
134
136
  }
135
- // Migrate rules
137
+ // Migrate rules. `oldRules &&` already excludes null/undefined; the
138
+ // `!== null` was redundant (CodeQL: `js/comparison-between-incompatible-types`).
136
139
  const oldRules = oldConfig['rules'];
137
- if (oldRules && typeof oldRules === 'object' && oldRules !== null) {
140
+ if (oldRules && typeof oldRules === 'object') {
138
141
  const newRules = {};
139
142
  Object.entries(oldRules).forEach(([ruleName, ruleConfig]) => {
140
143
  if (ruleName.startsWith('import/')) {
141
- // Rule mapping
144
+ // Migrate from upstream `eslint-plugin-import` rule names to the
145
+ // drop-in `eslint-plugin-import-next` equivalents (see the package
146
+ // for the full rule inventory).
142
147
  const ruleMappings = {
143
- 'import/no-unresolved': 'eslint-plugin-llm-optimized/no-unresolved',
144
- 'import/no-cycle': 'eslint-plugin-llm-optimized/no-circular-dependencies',
145
- 'import/no-self-import': 'eslint-plugin-llm-optimized/no-self-import',
146
- 'import/no-absolute-path': 'eslint-plugin-llm-optimized/no-absolute-path',
147
- 'import/no-dynamic-require': 'eslint-plugin-llm-optimized/no-dynamic-require',
148
- 'import/no-webpack-loader-syntax': 'eslint-plugin-llm-optimized/no-webpack-loader-syntax',
148
+ 'import/no-unresolved': 'import-next/no-unresolved',
149
+ 'import/no-cycle': 'import-next/no-cycle',
150
+ 'import/no-self-import': 'import-next/no-self-import',
151
+ 'import/no-absolute-path': 'import-next/no-absolute-path',
152
+ 'import/no-dynamic-require': 'import-next/no-dynamic-require',
153
+ 'import/no-webpack-loader-syntax': 'import-next/no-webpack-loader-syntax',
149
154
  };
150
155
  if (ruleMappings[ruleName]) {
151
156
  newRules[ruleMappings[ruleName]] = ruleConfig;
@@ -20,30 +20,14 @@ export interface ResolverOptions {
20
20
  cssSupport?: boolean;
21
21
  }
22
22
  /**
23
- * Performance metrics for resolver monitoring
24
- */
25
- export interface ResolverPerformanceMetrics {
26
- name: string;
27
- resolveCount: number;
28
- totalResolveTime: number;
29
- averageResolveTime: number;
30
- cacheHitRate: number;
31
- errorRate: number;
32
- lastUsed: number;
33
- }
34
- /**
35
- * Get performance metrics for all resolvers
36
- */
37
- export declare function getResolverPerformanceMetrics(): ResolverPerformanceMetrics[];
38
- /**
39
- * Resolve an import path using enhanced-resolve and TypeScript paths
23
+ * Resolve an import path using oxc-resolver (Rust NAPI)
40
24
  *
41
- * Features:
25
+ * Resolution priority:
42
26
  * 1. External resolvers (eslint-import-resolver-*) if configured
43
- * 2. TypeScript "paths" support (tsconfig.json)
44
- * 3. Package.json "exports" support
45
- * 4. Monorepo resolution
46
- * 5. Webpack-style aliases (via tsconfig or standard resolution)
27
+ * 2. Fast path: relative imports with existsSync + extension fan-out
28
+ * 3. CSS resolution (if cssSupport enabled)
29
+ * 4. oxc-resolver: handles everything else (tsconfig paths, package.json exports,
30
+ * node_modules, monorepo resolution) via native Rust execution
47
31
  *
48
32
  * @param importPath - The path to resolve (e.g., "react", "./utils", "@app/components")
49
33
  * @param fromFile - The file where the import originates
@@ -51,7 +35,3 @@ export declare function getResolverPerformanceMetrics(): ResolverPerformanceMetr
51
35
  * @returns The absolute path to the resolved file, or null if not found
52
36
  */
53
37
  export declare function resolveModule(importPath: string, fromFile: string, options?: ResolverOptions): string | null;
54
- /**
55
- * Clear internal caches (useful for testing or watch mode)
56
- */
57
- export declare function clearResolverCache(): void;
@@ -8,62 +8,112 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.getResolverPerformanceMetrics = getResolverPerformanceMetrics;
9
9
  exports.resolveModule = resolveModule;
10
10
  exports.clearResolverCache = clearResolverCache;
11
- const tslib_1 = require("tslib");
12
- const get_tsconfig_1 = require("get-tsconfig");
13
- const enhanced_resolve_1 = require("enhanced-resolve");
14
- const fs = tslib_1.__importStar(require("node:fs"));
11
+ const oxc_resolver_1 = require("oxc-resolver");
15
12
  const fs_1 = require("../node/fs");
16
13
  const path_1 = require("../node/path");
17
14
  const resolver_adapter_1 = require("./resolver-adapter");
18
- // Global cache for resolvers to avoid recreating them frequently
19
- // Key: JSON.stringify(options) + workspaceRoot
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- enhanced-resolve resolver type
21
- const resolverCache = new Map();
22
- // Cache for TS path matchers
23
- // Key: tsconfig path
24
- const tsConfigCache = new Map();
25
- // Cache for package.json resolution (optimization for monorepos)
26
- const packageJsonCache = new Map();
27
- // Resolver performance metrics (for monitoring and optimization)
28
- const resolverMetrics = new Map();
15
+ // =============================================================================
16
+ // oxc-resolver: Rust-based NAPI resolver (18-30x faster than enhanced-resolve)
17
+ //
18
+ // Lazy-initialized singleton per lint run. The oxc-resolver handles:
19
+ // - TypeScript paths (tsconfig.json) natively
20
+ // - Package.json exports/imports
21
+ // - Extension fan-out
22
+ // - Node.js module resolution algorithm
23
+ // =============================================================================
24
+ // Per-tsconfig resolver cache: in monorepos, different packages have different
25
+ // tsconfig.json files (with different path aliases). We maintain one resolver
26
+ // per unique tsconfig to ensure correct resolution across package boundaries.
27
+ const oxcResolverCache = new Map();
28
+ // Per-directory tsconfig cache: maps a directory to its nearest tsconfig.json.
29
+ // This avoids repeated upward walks for files in the same directory.
30
+ const tsconfigPathCache = new Map();
29
31
  /**
30
- * Get performance metrics for all resolvers
32
+ * Find the nearest tsconfig.json by walking up from a file's directory.
33
+ * Results are cached per-directory for the lint run.
34
+ *
35
+ * In monorepos this correctly finds per-package tsconfigs:
36
+ * packages/app/src/foo.ts → packages/app/tsconfig.json
37
+ * packages/lib/src/bar.ts → packages/lib/tsconfig.json
31
38
  */
32
- function getResolverPerformanceMetrics() {
33
- return Array.from(resolverMetrics.entries()).map(([name, metrics]) => ({
34
- name,
35
- resolveCount: metrics.resolveCount,
36
- totalResolveTime: metrics.totalResolveTime,
37
- averageResolveTime: metrics.resolveCount > 0
38
- ? metrics.totalResolveTime / metrics.resolveCount
39
- : 0,
40
- cacheHitRate: metrics.resolveCount > 0
41
- ? (metrics.cacheHits / metrics.resolveCount) * 100
42
- : 0,
43
- errorRate: metrics.resolveCount > 0
44
- ? (metrics.errors / metrics.resolveCount) * 100
45
- : 0,
46
- lastUsed: metrics.lastUsed,
47
- }));
39
+ function findTsconfigPath(fromFile) {
40
+ const startDir = (0, path_1.getDirname)(fromFile);
41
+ // Check if we've already resolved this directory
42
+ const cached = tsconfigPathCache.get(startDir);
43
+ if (cached !== undefined) {
44
+ return cached;
45
+ }
46
+ // Walk up using the existing utility
47
+ const result = (0, fs_1.findFileUpward)('tsconfig.json', startDir);
48
+ // Cache the result for this directory and all intermediate directories
49
+ // so sibling files don't repeat the walk
50
+ let dir = startDir;
51
+ const root = (0, path_1.resolvePath)('/');
52
+ while (dir !== root) {
53
+ tsconfigPathCache.set(dir, result);
54
+ // Stop caching once we reach the directory containing the tsconfig
55
+ if (result && (0, path_1.getDirname)(result) === dir)
56
+ break;
57
+ const parent = (0, path_1.getDirname)(dir);
58
+ if (parent === dir)
59
+ break;
60
+ dir = parent;
61
+ }
62
+ return result;
48
63
  }
49
64
  /**
50
- * Normalize file paths for cross-platform compatibility
65
+ * Get or create an oxc-resolver instance for the given options + tsconfig.
66
+ * Resolver instances are cached by (options + tsconfig path) key.
67
+ * In a single-project setup, this creates exactly ONE resolver.
68
+ * In a monorepo, one resolver per unique tsconfig.
51
69
  */
52
- function normalizeUncPath(filePath) {
53
- return filePath;
70
+ function getOxcResolver(options, fromFile) {
71
+ const extensions = options.extensions || [
72
+ '.ts', '.tsx', '.js', '.jsx', '.d.ts', '.json', '.node',
73
+ ];
74
+ const conditionNames = options.conditionNames || [
75
+ 'import', 'require', 'node', 'default', 'types',
76
+ ];
77
+ const mainFields = options.mainFields || ['module', 'main'];
78
+ // Find the nearest tsconfig for this file (per-directory cached)
79
+ const tsconfigPath = findTsconfigPath(fromFile);
80
+ // Cache key: options + tsconfig path
81
+ const key = `${extensions.join(',')}|${conditionNames.join(',')}|${mainFields.join(',')}|${tsconfigPath || ''}`;
82
+ const cached = oxcResolverCache.get(key);
83
+ if (cached) {
84
+ return cached;
85
+ }
86
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oxc-resolver options
87
+ const resolverOptions = {
88
+ extensions,
89
+ conditionNames,
90
+ mainFields,
91
+ mainFiles: ['index'],
92
+ modules: ['node_modules'],
93
+ };
94
+ // Only add tsconfig if found — oxc-resolver handles paths natively
95
+ if (tsconfigPath) {
96
+ resolverOptions['tsconfig'] = {
97
+ configFile: tsconfigPath,
98
+ references: 'auto',
99
+ };
100
+ }
101
+ const resolver = new oxc_resolver_1.ResolverFactory(resolverOptions);
102
+ oxcResolverCache.set(key, resolver);
103
+ return resolver;
54
104
  }
105
+ // =============================================================================
106
+ // CSS Resolution (kept from original — lightweight, no external deps)
107
+ // =============================================================================
55
108
  /**
56
109
  * Check if import path is a CSS/SCSS import
57
110
  */
58
111
  function isCssImport(importPath) {
59
- // Check if it has a CSS extension
60
112
  if (/\.(css|scss|sass|less|styl)$/i.test(importPath)) {
61
113
  return true;
62
114
  }
63
- // For relative imports without extensions, assume they could be CSS
64
- // This allows the CSS resolver to try resolving them when other resolvers fail
65
115
  if (importPath.startsWith('./') || importPath.startsWith('../')) {
66
- return !/\.\w+$/.test(importPath); // No extension
116
+ return !/\.\w+$/.test(importPath);
67
117
  }
68
118
  return false;
69
119
  }
@@ -72,18 +122,14 @@ function isCssImport(importPath) {
72
122
  */
73
123
  function resolveCssImport(importPath, fromFile) {
74
124
  const fromDir = (0, path_1.getDirname)(fromFile);
75
- // If it's a relative import, resolve it
76
125
  if (importPath.startsWith('.')) {
77
- let resolved = (0, path_1.resolvePath)(fromDir, importPath);
78
- resolved = normalizeUncPath(resolved);
79
- // Check if the exact path exists and is a file
126
+ const resolved = (0, path_1.resolvePath)(fromDir, importPath);
80
127
  if ((0, fs_1.fileExistsSync)(resolved)) {
81
128
  const stats = (0, fs_1.statSync)(resolved);
82
129
  if (stats && stats.isFile()) {
83
130
  return resolved;
84
131
  }
85
132
  }
86
- // Try adding extensions to create file paths
87
133
  const cssExtensions = ['.css', '.scss', '.sass', '.less', '.styl'];
88
134
  for (const ext of cssExtensions) {
89
135
  const withExt = resolved + ext;
@@ -94,7 +140,6 @@ function resolveCssImport(importPath, fromFile) {
94
140
  }
95
141
  }
96
142
  }
97
- // Try resolving as directory with index file
98
143
  for (const ext of cssExtensions) {
99
144
  const indexFile = (0, path_1.joinPath)(resolved, `index${ext}`);
100
145
  if ((0, fs_1.fileExistsSync)(indexFile)) {
@@ -105,43 +150,29 @@ function resolveCssImport(importPath, fromFile) {
105
150
  }
106
151
  }
107
152
  }
108
- // For non-relative imports, try node_modules or assume it's handled by bundler
109
- // Return null to indicate CSS import found but not resolved (common in React projects)
110
153
  return null;
111
154
  }
112
155
  /**
113
- * Track resolver performance
156
+ * Get performance metrics for all resolvers.
157
+ *
158
+ * Note: With oxc-resolver, detailed per-call metrics are not tracked
159
+ * in production to avoid overhead. Returns empty array.
160
+ *
161
+ * @internal — debug/observability API. Not part of the stable consumer
162
+ * contract. Stripped from emitted `.d.ts` via `stripInternal`.
114
163
  */
115
- function trackResolverPerformance(name, startTime, success) {
116
- const duration = Date.now() - startTime;
117
- const metrics = resolverMetrics.get(name) || {
118
- resolveCount: 0,
119
- totalResolveTime: 0,
120
- cacheHits: 0,
121
- cacheMisses: 0,
122
- errors: 0,
123
- lastUsed: 0,
124
- };
125
- metrics.resolveCount++;
126
- metrics.totalResolveTime += duration;
127
- metrics.lastUsed = Date.now();
128
- if (success) {
129
- metrics.cacheMisses++;
130
- }
131
- if (!success) {
132
- metrics.errors++;
133
- }
134
- resolverMetrics.set(name, metrics);
164
+ function getResolverPerformanceMetrics() {
165
+ return [];
135
166
  }
136
167
  /**
137
- * Resolve an import path using enhanced-resolve and TypeScript paths
168
+ * Resolve an import path using oxc-resolver (Rust NAPI)
138
169
  *
139
- * Features:
170
+ * Resolution priority:
140
171
  * 1. External resolvers (eslint-import-resolver-*) if configured
141
- * 2. TypeScript "paths" support (tsconfig.json)
142
- * 3. Package.json "exports" support
143
- * 4. Monorepo resolution
144
- * 5. Webpack-style aliases (via tsconfig or standard resolution)
172
+ * 2. Fast path: relative imports with existsSync + extension fan-out
173
+ * 3. CSS resolution (if cssSupport enabled)
174
+ * 4. oxc-resolver: handles everything else (tsconfig paths, package.json exports,
175
+ * node_modules, monorepo resolution) via native Rust execution
145
176
  *
146
177
  * @param importPath - The path to resolve (e.g., "react", "./utils", "@app/components")
147
178
  * @param fromFile - The file where the import originates
@@ -149,146 +180,92 @@ function trackResolverPerformance(name, startTime, success) {
149
180
  * @returns The absolute path to the resolved file, or null if not found
150
181
  */
151
182
  function resolveModule(importPath, fromFile, options = {}) {
152
- const startTime = Date.now();
153
- let success = false;
154
- let resolverUsed = 'none';
155
183
  try {
184
+ // =========================================================================
185
+ // FAST PATH: Resolve relative imports with existsSync + extension fan-out
186
+ // This bypasses oxc-resolver for the ~80% of imports that are relative.
187
+ // Skip for CSS imports when cssSupport is enabled.
188
+ // =========================================================================
189
+ if (importPath.startsWith('.') && !(options.cssSupport && isCssImport(importPath))) {
190
+ const context = (0, path_1.getDirname)(fromFile);
191
+ const defaultExtensions = ['.ts', '.tsx', '.js', '.jsx', '.d.ts', '.json'];
192
+ const extensions = options.extensions || defaultExtensions;
193
+ const resolved = (0, path_1.resolvePath)(context, importPath);
194
+ // 1. Exact path (import './foo.ts')
195
+ const exactStats = (0, fs_1.statSync)(resolved);
196
+ if (exactStats && exactStats.isFile()) {
197
+ return resolved;
198
+ }
199
+ // 2. Try adding extensions (import './foo' → './foo.ts')
200
+ for (const ext of extensions) {
201
+ if ((0, fs_1.fileExistsSync)(resolved + ext)) {
202
+ return resolved + ext;
203
+ }
204
+ }
205
+ // 3. Try index files (import './foo' → './foo/index.ts')
206
+ for (const ext of extensions) {
207
+ const indexFile = (0, path_1.joinPath)(resolved, `index${ext}`);
208
+ if ((0, fs_1.fileExistsSync)(indexFile)) {
209
+ return indexFile;
210
+ }
211
+ }
212
+ // Relative import didn't resolve via fast path — fall through to
213
+ // oxc-resolver which handles more exotic cases (package.json
214
+ // exports within relative paths, symlinks, etc.)
215
+ }
216
+ // =========================================================================
217
+ // STANDARD PATH
218
+ // =========================================================================
156
219
  // 0. Try External Resolvers (if configured)
157
220
  if (options.resolverSettings) {
158
221
  const externalResult = (0, resolver_adapter_1.resolveWithExternalResolvers)(importPath, fromFile, options.resolverSettings);
159
222
  if (externalResult) {
160
- success = true;
161
- resolverUsed = 'external';
162
- trackResolverPerformance(resolverUsed, startTime, success);
163
223
  return externalResult;
164
224
  }
165
225
  }
166
- const context = (0, path_1.getDirname)(fromFile);
167
- const defaultExtensions = [
168
- '.ts',
169
- '.tsx',
170
- '.d.ts',
171
- '.js',
172
- '.jsx',
173
- '.json',
174
- '.node',
175
- ];
176
- const extensions = options.extensions || defaultExtensions;
177
- // 1. Try TypeScript Paths first (if configured)
178
- // We look for tsconfig.json relative to the file
179
- const tsconfig = (0, get_tsconfig_1.getTsconfig)(fromFile);
180
- if (tsconfig) {
181
- let matcher = tsConfigCache.get(tsconfig.path);
182
- if (matcher === undefined) {
183
- matcher = (0, get_tsconfig_1.createPathsMatcher)(tsconfig);
184
- tsConfigCache.set(tsconfig.path, matcher);
185
- }
186
- if (matcher) {
187
- const matches = matcher(importPath);
188
- if (matches.length > 0) {
189
- // Try each match
190
- for (const match of matches) {
191
- // matches are absolute paths usually
192
- // We need to verify existence and handle extensions
193
- // enhanced-resolve can verify existence and extensions if we pass the absolute path
194
- // But simple fs check might be faster for direct hits
195
- const stats = (0, fs_1.statSync)(match);
196
- if (stats && stats.isFile()) {
197
- success = true;
198
- resolverUsed = 'typescript';
199
- trackResolverPerformance(resolverUsed, startTime, success);
200
- return match;
201
- }
202
- // Try extensions
203
- for (const ext of extensions) {
204
- if ((0, fs_1.fileExistsSync)(match + ext)) {
205
- success = true;
206
- resolverUsed = 'typescript';
207
- trackResolverPerformance(resolverUsed, startTime, success);
208
- return match + ext;
209
- }
210
- }
211
- // Try index files
212
- for (const ext of extensions) {
213
- const indexFile = (0, path_1.joinPath)(match, `index${ext}`);
214
- if ((0, fs_1.fileExistsSync)(indexFile)) {
215
- success = true;
216
- resolverUsed = 'typescript';
217
- trackResolverPerformance(resolverUsed, startTime, success);
218
- return indexFile;
219
- }
220
- }
221
- }
222
- }
223
- }
224
- }
225
- // 2. Try CSS/SCSS resolution first (if enabled and looks like CSS)
226
+ // 1. Try CSS/SCSS resolution (if enabled and looks like CSS)
226
227
  if (options.cssSupport && isCssImport(importPath)) {
227
228
  const cssResult = resolveCssImport(importPath, fromFile);
228
229
  if (cssResult) {
229
- success = true;
230
- resolverUsed = 'css';
231
- trackResolverPerformance(resolverUsed, startTime, success);
232
230
  return cssResult;
233
231
  }
234
232
  }
235
- // 3. Use enhanced-resolve for standard resolution (node_modules, exports, etc.)
236
- // We create/get a synchronous resolver
237
- const resolverKey = JSON.stringify(options);
238
- let resolver = resolverCache.get(resolverKey);
239
- if (!resolver) {
240
- resolver = enhanced_resolve_1.ResolverFactory.createResolver({
241
- fileSystem: new enhanced_resolve_1.CachedInputFileSystem(fs, 4000),
242
- useSyncFileSystemCalls: true,
243
- extensions,
244
- conditionNames: options.conditionNames || [
245
- 'import',
246
- 'require',
247
- 'node',
248
- 'default',
249
- 'types',
250
- ],
251
- mainFields: options.mainFields || ['module', 'main'],
252
- // Add more webpack-like defaults
253
- modules: ['node_modules'],
254
- exportsFields: ['exports'],
255
- });
256
- resolverCache.set(resolverKey, resolver);
257
- }
258
- // enhanced-resolve's resolveSync returns string | false, but can throw
233
+ // 2. Use oxc-resolver for everything else (Rust NAPI — 18-30x faster)
234
+ // Handles: tsconfig paths, package.json exports, node_modules,
235
+ // monorepo resolution, symlinks, condition names
236
+ const resolver = getOxcResolver(options, fromFile);
237
+ const context = (0, path_1.getDirname)(fromFile);
259
238
  try {
260
- const result = resolver.resolveSync({}, context, importPath);
261
- if (result) {
262
- success = true;
263
- resolverUsed = 'enhanced-resolve';
264
- trackResolverPerformance(resolverUsed, startTime, success);
265
- return result;
239
+ const result = resolver.sync(context, importPath);
240
+ if (result && result.path) {
241
+ return result.path;
266
242
  }
267
243
  }
268
244
  catch {
269
- // enhanced-resolve failed to resolve, continue to next resolver
245
+ // oxc-resolver throws on resolution failure — this is expected for
246
+ // unresolvable imports (typos, missing packages, etc.)
270
247
  }
271
248
  // No resolver succeeded
272
- success = false;
273
- trackResolverPerformance('failed', startTime, success);
274
249
  return null;
275
250
  }
276
251
  catch {
277
- // Resolution failed with error
278
- success = false;
279
- trackResolverPerformance('error', startTime, success);
252
+ // Resolution failed with unexpected error
280
253
  return null;
281
254
  }
282
255
  }
283
256
  /**
284
- * Clear internal caches (useful for testing or watch mode)
257
+ * Clear internal caches (useful for testing or watch mode).
258
+ *
259
+ * @internal — test/debug utility. Consumers have no reason to call this
260
+ * directly; lint runs are short-lived and caches don't persist across
261
+ * them. Stripped from emitted `.d.ts` via `stripInternal`.
285
262
  */
286
263
  function clearResolverCache() {
287
- resolverCache.clear();
288
- tsConfigCache.clear();
289
- packageJsonCache.clear();
290
- // Clear metrics completely for testing
291
- resolverMetrics.clear();
264
+ for (const resolver of oxcResolverCache.values()) {
265
+ resolver.clearCache();
266
+ }
267
+ oxcResolverCache.clear();
268
+ tsconfigPathCache.clear();
292
269
  }
293
270
  // Lines 322-324: Defensive error handling for truly exceptional cases
294
271
  // These lines handle unexpected exceptions from resolution logic that are:
@@ -226,12 +226,12 @@ exports.SAFE_ORM_PATTERNS = [
226
226
  * ```
227
227
  */
228
228
  function isSanitizationCall(node, customFunctions = []) {
229
- const allFunctions = [...exports.SANITIZATION_FUNCTIONS, ...customFunctions];
229
+ const allFunctions = new Set([...exports.SANITIZATION_FUNCTIONS, ...customFunctions]);
230
230
  if (node.type === 'CallExpression') {
231
231
  const callee = node.callee;
232
232
  // Direct function call: sanitize(input)
233
233
  if (callee.type === 'Identifier') {
234
- return allFunctions.includes(callee.name);
234
+ return allFunctions.has(callee.name);
235
235
  }
236
236
  // Method call: DOMPurify.sanitize(input)
237
237
  if (callee.type === 'MemberExpression') {
@@ -243,7 +243,7 @@ function isSanitizationCall(node, customFunctions = []) {
243
243
  }
244
244
  // Check if the method name itself is a sanitization function
245
245
  if (callee.property.type === 'Identifier') {
246
- return allFunctions.includes(callee.property.name);
246
+ return allFunctions.has(callee.property.name);
247
247
  }
248
248
  }
249
249
  }
@@ -4,3 +4,4 @@
4
4
  * MIT license that can be found in the LICENSE file.
5
5
  */
6
6
  export * from './type-utils';
7
+ import './meta-augmentation';
@@ -8,3 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  const tslib_1 = require("tslib");
9
9
  // Type utilities for ESLint rules
10
10
  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
+ require("./meta-augmentation");
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * Module augmentation — extends `@typescript-eslint/utils` `RuleMetaDataDocs`
8
+ * with the Interlace-specific fields the whole-run formatter
9
+ * (`@interlace/eslint-formatter`) renders inline:
10
+ *
11
+ * meta.docs.cwe — CWE identifier (e.g. "CWE-89") rendered as a prefix
12
+ * in human + compact + JSON + NDJSON modes.
13
+ * meta.docs.cvss — CVSS 3.1 score (0–10) rendered alongside CWE in
14
+ * human + JSON + NDJSON.
15
+ *
16
+ * ESLint accepts arbitrary additional properties on `meta.docs` at
17
+ * runtime; this declaration adds the type-system half so plugin authors
18
+ * can populate the fields without per-rule `@ts-expect-error`.
19
+ *
20
+ * Importing this module (e.g. via `@interlace/eslint-devkit`'s root
21
+ * export, which it does) is enough to activate the augmentation
22
+ * project-wide.
23
+ */
24
+ declare module '@typescript-eslint/utils/ts-eslint' {
25
+ interface RuleMetaDataDocs {
26
+ /** CWE identifier (e.g. "CWE-89"). Rendered inline by @interlace/eslint-formatter. */
27
+ cwe?: string;
28
+ /** CVSS 3.1 score, 0–10 inclusive. Rendered alongside CWE. */
29
+ cvss?: number;
30
+ /** Free-text rationale for the CWE mapping; surfaces in audit reports. */
31
+ cweJustification?: string;
32
+ /**
33
+ * Per-rule confidence band — read by the ILB-Confidence bench (`npm run
34
+ * ilb:confidence`) and used as the agent-axis routing signal:
35
+ * `high` → SLO precision ≥ 90%; agents may auto-apply fixes.
36
+ * `medium` → SLO precision 70–90%; agents should surface for review.
37
+ * `low` → SLO precision 50–70%; agents should escalate to a human.
38
+ * Calibration (declared vs empirical precision) is computed by the
39
+ * bench's reliability diagram. SLO: |empirical − target| ≤ 0.05.
40
+ */
41
+ confidence?: 'high' | 'medium' | 'low';
42
+ }
43
+ }
44
+ export {};
@@ -0,0 +1,7 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });