@interlace/eslint-devkit 1.5.0 → 1.6.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.
Files changed (40) hide show
  1. package/package.json +15 -19
  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.js +0 -8
  29. package/src/rule-creation/mock-context.js +0 -9
  30. package/src/rule-creation/rule-creator.d.ts +59 -10
  31. package/src/rule-creation/rule-creator.js +64 -40
  32. package/src/rule-creation/sql-injection-rule.js +0 -52
  33. package/src/security/index.js +0 -6
  34. package/src/security/security-utils.js +9 -287
  35. package/src/types/index.js +0 -9
  36. package/src/types/meta-augmentation.js +0 -5
  37. package/src/types/type-utils.d.ts +1 -1
  38. package/src/types/type-utils.js +34 -145
  39. package/AGENTS.md +0 -151
  40. package/CHANGELOG.md +0 -181
@@ -1,12 +1,6 @@
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
- // Resolver and dependency analysis utilities
10
4
  tslib_1.__exportStar(require("./resolver"), exports);
11
5
  tslib_1.__exportStar(require("./resolver-adapter"), exports);
12
6
  tslib_1.__exportStar(require("./dependency-analysis"), exports);
@@ -1,23 +1,7 @@
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.resolveWithExternalResolvers = resolveWithExternalResolvers;
9
- /**
10
- * Cache for loaded resolver modules
11
- */
12
4
  const loadedResolvers = new Map();
13
- /**
14
- * Load an external resolver module
15
- *
16
- * Tries to load:
17
- * 1. The exact module name
18
- * 2. eslint-import-resolver-<name>
19
- * 3. <name> (as a fallback)
20
- */
21
5
  function loadResolver(name) {
22
6
  const cached = loadedResolvers.get(name);
23
7
  if (cached !== undefined) {
@@ -26,16 +10,11 @@ function loadResolver(name) {
26
10
  const potentialNames = [
27
11
  name,
28
12
  `eslint-import-resolver-${name}`,
29
- // specialized scope resolvers
30
13
  name.startsWith('@') ? name : null,
31
14
  ].filter(Boolean);
32
15
  let resolver = null;
33
16
  for (const pkgName of potentialNames) {
34
17
  try {
35
- // Try to require from the project's context
36
- // We use a simple require here, assuming the plugin is running in the same context
37
- // In a real robust system we might need 'resolve-from' or similar
38
- // Dynamic require is necessary for loading external resolver plugins
39
18
  const loaded = require(pkgName);
40
19
  if (loaded && typeof loaded.resolve === 'function') {
41
20
  resolver = loaded;
@@ -43,20 +22,15 @@ function loadResolver(name) {
43
22
  }
44
23
  }
45
24
  catch (error) {
46
- // If module not found, continue
47
25
  const err = error;
48
26
  if (err.code !== 'MODULE_NOT_FOUND') {
49
27
  console.warn(`Failed to load resolver ${pkgName}:`, error);
50
28
  }
51
29
  }
52
30
  }
53
- // Cache the result (null if not found)
54
31
  loadedResolvers.set(name, resolver);
55
32
  return resolver;
56
33
  }
57
- /**
58
- * Normalize resolver settings to prioritized list
59
- */
60
34
  function normalizeResolverSettings(settings) {
61
35
  const normalized = [];
62
36
  if (typeof settings === 'string') {
@@ -84,7 +58,6 @@ function normalizeResolverSettings(settings) {
84
58
  });
85
59
  }
86
60
  else if (typeof settings === 'object') {
87
- // This branch handles plain objects (not arrays) - ensure coverage
88
61
  Object.entries(settings).forEach(([name, config], index) => {
89
62
  const priority = typeof config === 'object' && config !== null && 'priority' in config
90
63
  ? config['priority'] || index
@@ -96,18 +69,8 @@ function normalizeResolverSettings(settings) {
96
69
  });
97
70
  });
98
71
  }
99
- // Sort by priority (lower number = higher priority)
100
- // oxlint-disable-next-line no-array-sort
101
72
  return normalized.sort((a, b) => a.priority - b.priority);
102
73
  }
103
- /**
104
- * Resolve a module using configured external resolvers with prioritization
105
- *
106
- * @param source - The import source path (e.g. "react", "./foo")
107
- * @param file - The absolute path to the file making the import
108
- * @param settings - The 'import/resolver' setting value
109
- * @returns The resolved absolute path, or null if not found
110
- */
111
74
  function resolveWithExternalResolvers(source, file, settings) {
112
75
  if (!settings)
113
76
  return null;
@@ -122,8 +85,6 @@ function resolveWithExternalResolvers(source, file, settings) {
122
85
  }
123
86
  }
124
87
  catch {
125
- // Resolver failed, continue to next resolver
126
- // Silently continue to next resolver
127
88
  }
128
89
  }
129
90
  }
@@ -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.detectResolvers = detectResolvers;
9
4
  exports.compareResolverPriority = compareResolverPriority;
@@ -11,12 +6,8 @@ exports.generateRecommendedConfig = generateRecommendedConfig;
11
6
  exports.migrateFromEslintImport = migrateFromEslintImport;
12
7
  exports.validateResolverConfig = validateResolverConfig;
13
8
  const fs_1 = require("../node/fs");
14
- /**
15
- * Detect available resolvers based on project structure
16
- */
17
9
  function detectResolvers(workspaceRoot) {
18
10
  const results = [];
19
- // TypeScript resolver
20
11
  const tsconfigPath = (0, fs_1.findFileUpward)('tsconfig.json', workspaceRoot);
21
12
  results.push({
22
13
  name: 'typescript',
@@ -24,7 +15,6 @@ function detectResolvers(workspaceRoot) {
24
15
  config: tsconfigPath ? { alwaysTryTypes: true } : undefined,
25
16
  reason: tsconfigPath ? 'Found tsconfig.json' : 'No tsconfig.json found',
26
17
  });
27
- // Webpack resolver
28
18
  const webpackConfig = (0, fs_1.findFileUpward)('webpack.config.js', workspaceRoot) ||
29
19
  (0, fs_1.findFileUpward)('webpack.config.ts', workspaceRoot);
30
20
  results.push({
@@ -35,7 +25,6 @@ function detectResolvers(workspaceRoot) {
35
25
  ? `Found ${webpackConfig.split('/').pop()}`
36
26
  : 'No webpack config found',
37
27
  });
38
- // Vite resolver
39
28
  const viteConfig = (0, fs_1.findFileUpward)('vite.config.js', workspaceRoot) ||
40
29
  (0, fs_1.findFileUpward)('vite.config.ts', workspaceRoot) ||
41
30
  (0, fs_1.findFileUpward)('vite.config.mjs', workspaceRoot);
@@ -47,7 +36,6 @@ function detectResolvers(workspaceRoot) {
47
36
  ? `Found ${viteConfig.split('/').pop()}`
48
37
  : 'No vite config found',
49
38
  });
50
- // Rollup resolver
51
39
  const rollupConfig = (0, fs_1.findFileUpward)('rollup.config.js', workspaceRoot) ||
52
40
  (0, fs_1.findFileUpward)('rollup.config.ts', workspaceRoot);
53
41
  results.push({
@@ -58,16 +46,13 @@ function detectResolvers(workspaceRoot) {
58
46
  ? `Found ${rollupConfig.split('/').pop()}`
59
47
  : 'No rollup config found',
60
48
  });
61
- // CSS resolver (always available for React projects)
62
49
  const packageJson = (0, fs_1.findFileUpward)('package.json', workspaceRoot);
63
50
  let hasReact = false;
64
51
  if (packageJson) {
65
52
  try {
66
- // Simple check - in real implementation we'd parse package.json
67
53
  hasReact = packageJson.includes('react');
68
54
  }
69
55
  catch {
70
- // Ignore errors
71
56
  }
72
57
  }
73
58
  results.push({
@@ -78,37 +63,23 @@ function detectResolvers(workspaceRoot) {
78
63
  });
79
64
  return results;
80
65
  }
81
- /**
82
- * Comparator for resolver priority ordering. Known resolver names sort by
83
- * their position in the priority list; unknown names sort last (999).
84
- *
85
- * Extracted from `generateRecommendedConfig` so the unknown-name fallback is
86
- * directly unit-testable (detectResolvers only ever emits known names).
87
- */
88
66
  function compareResolverPriority(aName, bName) {
89
67
  const priorityOrder = ['typescript', 'webpack', 'vite', 'rollup', 'css'];
90
68
  const aIndex = priorityOrder.indexOf(aName);
91
69
  const bIndex = priorityOrder.indexOf(bName);
92
70
  return (aIndex === -1 ? 999 : aIndex) - (bIndex === -1 ? 999 : bIndex);
93
71
  }
94
- /**
95
- * Generate recommended ESLint resolver configuration
96
- */
97
72
  function generateRecommendedConfig(workspaceRoot) {
98
73
  const detected = detectResolvers(workspaceRoot);
99
74
  const availableResolvers = detected.filter((r) => r.detected);
100
75
  const settings = {};
101
76
  const recommendations = [];
102
77
  if (availableResolvers.length === 0) {
103
- // Fallback to basic node resolution
104
78
  settings['import/resolver'] = 'node';
105
79
  recommendations.push('Using basic Node.js resolution (no bundler config detected)');
106
80
  return { settings, recommendations };
107
81
  }
108
- // Prioritize resolvers
109
- // oxlint-disable-next-line no-array-sort
110
82
  const prioritized = availableResolvers.sort((a, b) => compareResolverPriority(a.name, b.name));
111
- // Create prioritized resolver configuration
112
83
  const resolverConfig = {};
113
84
  prioritized.forEach((resolver, index) => {
114
85
  resolverConfig[resolver.name] = {
@@ -123,36 +94,24 @@ function generateRecommendedConfig(workspaceRoot) {
123
94
  });
124
95
  return { settings, recommendations };
125
96
  }
126
- /**
127
- * Migration helper for eslint-plugin-import users
128
- */
129
97
  function migrateFromEslintImport(oldConfig) {
130
98
  const migrated = {};
131
99
  const warnings = [];
132
100
  const suggestions = [];
133
- // Migrate settings. The leading truthy check (`oldSettings &&`) already
134
- // excludes null/undefined, so the later `!== null` was redundant
135
- // (CodeQL: `js/comparison-between-incompatible-types`).
136
101
  const oldSettings = oldConfig['settings'];
137
102
  if (oldSettings &&
138
103
  typeof oldSettings === 'object' &&
139
104
  'import/resolver' in oldSettings) {
140
105
  migrated['settings'] = {
141
106
  ...oldSettings,
142
- // Keep existing resolver settings
143
107
  };
144
108
  suggestions.push('Resolver settings preserved - no changes needed');
145
109
  }
146
- // Migrate rules. `oldRules &&` already excludes null/undefined; the
147
- // `!== null` was redundant (CodeQL: `js/comparison-between-incompatible-types`).
148
110
  const oldRules = oldConfig['rules'];
149
111
  if (oldRules && typeof oldRules === 'object') {
150
112
  const newRules = {};
151
113
  Object.entries(oldRules).forEach(([ruleName, ruleConfig]) => {
152
114
  if (ruleName.startsWith('import/')) {
153
- // Migrate from upstream `eslint-plugin-import` rule names to the
154
- // drop-in `eslint-plugin-import-next` equivalents (see the package
155
- // for the full rule inventory).
156
115
  const ruleMappings = {
157
116
  'import/no-unresolved': 'import-next/no-unresolved',
158
117
  'import/no-cycle': 'import-next/no-cycle',
@@ -178,9 +137,6 @@ function migrateFromEslintImport(oldConfig) {
178
137
  }
179
138
  return { migrated, warnings, suggestions };
180
139
  }
181
- /**
182
- * Validate resolver configuration
183
- */
184
140
  function validateResolverConfig(settings) {
185
141
  const errors = [];
186
142
  const warnings = [];
@@ -189,15 +145,12 @@ function validateResolverConfig(settings) {
189
145
  warnings.push('No import/resolver settings found - using defaults');
190
146
  return { valid: true, errors, warnings };
191
147
  }
192
- // Validate resolver configuration format
193
148
  if (typeof resolverSettings === 'string') {
194
- // Single resolver
195
149
  if (!resolverSettings.trim()) {
196
150
  errors.push('Resolver name cannot be empty');
197
151
  }
198
152
  }
199
153
  else if (Array.isArray(resolverSettings)) {
200
- // Array of resolvers
201
154
  resolverSettings.forEach((item, index) => {
202
155
  if (typeof item === 'string') {
203
156
  if (!item.trim()) {
@@ -216,7 +169,6 @@ function validateResolverConfig(settings) {
216
169
  });
217
170
  }
218
171
  else if (typeof resolverSettings === 'object') {
219
- // Object of resolvers
220
172
  Object.entries(resolverSettings).forEach(([name, config]) => {
221
173
  if (!name.trim()) {
222
174
  errors.push('Resolver name cannot be empty');
@@ -19,6 +19,17 @@ export interface ResolverOptions {
19
19
  /** Enable CSS/SCSS resolution for React components */
20
20
  cssSupport?: boolean;
21
21
  }
22
+ /**
23
+ * Thrown when the optional `oxc-resolver` peer is not installed.
24
+ *
25
+ * This is deliberately its own class: `resolveModule` swallows resolution
26
+ * failures and returns `null` (an unresolvable import is normal), and a
27
+ * missing peer must NOT disappear down that path — it would turn every
28
+ * import into a silent non-resolution instead of a fixable install error.
29
+ */
30
+ export declare class MissingResolverPeerError extends Error {
31
+ readonly name = "MissingResolverPeerError";
32
+ }
22
33
  /**
23
34
  * Resolve an import path using oxc-resolver (Rust NAPI)
24
35
  *
@@ -1,57 +1,45 @@
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 });
3
+ exports.MissingResolverPeerError = void 0;
8
4
  exports.getResolverPerformanceMetrics = getResolverPerformanceMetrics;
9
5
  exports.resolveModule = resolveModule;
10
6
  exports.clearResolverCache = clearResolverCache;
11
- const oxc_resolver_1 = require("oxc-resolver");
12
7
  const fs_1 = require("../node/fs");
13
8
  const path_1 = require("../node/path");
14
9
  const resolver_adapter_1 = require("./resolver-adapter");
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
10
  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.
11
+ let factoryRef;
12
+ class MissingResolverPeerError extends Error {
13
+ name = 'MissingResolverPeerError';
14
+ }
15
+ exports.MissingResolverPeerError = MissingResolverPeerError;
16
+ function loadResolverFactory() {
17
+ if (factoryRef) {
18
+ return factoryRef;
19
+ }
20
+ try {
21
+ factoryRef = require('oxc-resolver')
22
+ .ResolverFactory;
23
+ }
24
+ catch (cause) {
25
+ throw new MissingResolverPeerError('Import resolution requires the optional peer dependency "oxc-resolver", ' +
26
+ 'which is not installed. Install it alongside this plugin:\n\n' +
27
+ ' npm install --save-dev oxc-resolver\n', { cause });
28
+ }
29
+ return factoryRef;
30
+ }
30
31
  const tsconfigPathCache = new Map();
31
- /**
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
38
- */
39
32
  function findTsconfigPath(fromFile) {
40
33
  const startDir = (0, path_1.getDirname)(fromFile);
41
- // Check if we've already resolved this directory
42
34
  const cached = tsconfigPathCache.get(startDir);
43
35
  if (cached !== undefined) {
44
36
  return cached;
45
37
  }
46
- // Walk up using the existing utility
47
38
  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
39
  let dir = startDir;
51
40
  const root = (0, path_1.resolvePath)('/');
52
41
  while (dir !== root) {
53
42
  tsconfigPathCache.set(dir, result);
54
- // Stop caching once we reach the directory containing the tsconfig
55
43
  if (result && (0, path_1.getDirname)(result) === dir)
56
44
  break;
57
45
  const parent = (0, path_1.getDirname)(dir);
@@ -61,29 +49,30 @@ function findTsconfigPath(fromFile) {
61
49
  }
62
50
  return result;
63
51
  }
64
- /**
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.
69
- */
70
52
  function getOxcResolver(options, fromFile) {
71
53
  const extensions = options.extensions || [
72
- '.ts', '.tsx', '.js', '.jsx', '.d.ts', '.json', '.node',
54
+ '.ts',
55
+ '.tsx',
56
+ '.js',
57
+ '.jsx',
58
+ '.d.ts',
59
+ '.json',
60
+ '.node',
73
61
  ];
74
62
  const conditionNames = options.conditionNames || [
75
- 'import', 'require', 'node', 'default', 'types',
63
+ 'import',
64
+ 'require',
65
+ 'node',
66
+ 'default',
67
+ 'types',
76
68
  ];
77
69
  const mainFields = options.mainFields || ['module', 'main'];
78
- // Find the nearest tsconfig for this file (per-directory cached)
79
70
  const tsconfigPath = findTsconfigPath(fromFile);
80
- // Cache key: options + tsconfig path
81
71
  const key = `${extensions.join(',')}|${conditionNames.join(',')}|${mainFields.join(',')}|${tsconfigPath || ''}`;
82
72
  const cached = oxcResolverCache.get(key);
83
73
  if (cached) {
84
74
  return cached;
85
75
  }
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- oxc-resolver options
87
76
  const resolverOptions = {
88
77
  extensions,
89
78
  conditionNames,
@@ -91,23 +80,17 @@ function getOxcResolver(options, fromFile) {
91
80
  mainFiles: ['index'],
92
81
  modules: ['node_modules'],
93
82
  };
94
- // Only add tsconfig if found — oxc-resolver handles paths natively
95
83
  if (tsconfigPath) {
96
84
  resolverOptions['tsconfig'] = {
97
85
  configFile: tsconfigPath,
98
86
  references: 'auto',
99
87
  };
100
88
  }
101
- const resolver = new oxc_resolver_1.ResolverFactory(resolverOptions);
89
+ const ResolverFactory = loadResolverFactory();
90
+ const resolver = new ResolverFactory(resolverOptions);
102
91
  oxcResolverCache.set(key, resolver);
103
92
  return resolver;
104
93
  }
105
- // =============================================================================
106
- // CSS Resolution (kept from original — lightweight, no external deps)
107
- // =============================================================================
108
- /**
109
- * Check if import path is a CSS/SCSS import
110
- */
111
94
  function isCssImport(importPath) {
112
95
  if (/\.(css|scss|sass|less|styl)$/i.test(importPath)) {
113
96
  return true;
@@ -117,9 +100,6 @@ function isCssImport(importPath) {
117
100
  }
118
101
  return false;
119
102
  }
120
- /**
121
- * Resolve CSS/SCSS import paths
122
- */
123
103
  function resolveCssImport(importPath, fromFile) {
124
104
  const fromDir = (0, path_1.getDirname)(fromFile);
125
105
  if (importPath.startsWith('.')) {
@@ -152,87 +132,52 @@ function resolveCssImport(importPath, fromFile) {
152
132
  }
153
133
  return null;
154
134
  }
155
- /**
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`.
163
- */
164
135
  function getResolverPerformanceMetrics() {
165
136
  return [];
166
137
  }
167
- /**
168
- * Resolve an import path using oxc-resolver (Rust NAPI)
169
- *
170
- * Resolution priority:
171
- * 1. External resolvers (eslint-import-resolver-*) if configured
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
176
- *
177
- * @param importPath - The path to resolve (e.g., "react", "./utils", "@app/components")
178
- * @param fromFile - The file where the import originates
179
- * @param options - Resolution options
180
- * @returns The absolute path to the resolved file, or null if not found
181
- */
182
138
  function resolveModule(importPath, fromFile, options = {}) {
183
139
  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))) {
140
+ if (importPath.startsWith('.') &&
141
+ !(options.cssSupport && isCssImport(importPath))) {
190
142
  const context = (0, path_1.getDirname)(fromFile);
191
- const defaultExtensions = ['.ts', '.tsx', '.js', '.jsx', '.d.ts', '.json'];
143
+ const defaultExtensions = [
144
+ '.ts',
145
+ '.tsx',
146
+ '.js',
147
+ '.jsx',
148
+ '.d.ts',
149
+ '.json',
150
+ ];
192
151
  const extensions = options.extensions || defaultExtensions;
193
152
  const resolved = (0, path_1.resolvePath)(context, importPath);
194
- // 1. Exact path (import './foo.ts')
195
153
  const exactStats = (0, fs_1.statSync)(resolved);
196
154
  if (exactStats && exactStats.isFile()) {
197
155
  return resolved;
198
156
  }
199
- // 2. Try adding extensions (import './foo' → './foo.ts')
200
157
  for (const ext of extensions) {
201
158
  if ((0, fs_1.fileExistsSync)(resolved + ext)) {
202
159
  return resolved + ext;
203
160
  }
204
161
  }
205
- // 3. Try index files (import './foo' → './foo/index.ts')
206
162
  for (const ext of extensions) {
207
163
  const indexFile = (0, path_1.joinPath)(resolved, `index${ext}`);
208
164
  if ((0, fs_1.fileExistsSync)(indexFile)) {
209
165
  return indexFile;
210
166
  }
211
167
  }
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
168
  }
216
- // =========================================================================
217
- // STANDARD PATH
218
- // =========================================================================
219
- // 0. Try External Resolvers (if configured)
220
169
  if (options.resolverSettings) {
221
170
  const externalResult = (0, resolver_adapter_1.resolveWithExternalResolvers)(importPath, fromFile, options.resolverSettings);
222
171
  if (externalResult) {
223
172
  return externalResult;
224
173
  }
225
174
  }
226
- // 1. Try CSS/SCSS resolution (if enabled and looks like CSS)
227
175
  if (options.cssSupport && isCssImport(importPath)) {
228
176
  const cssResult = resolveCssImport(importPath, fromFile);
229
177
  if (cssResult) {
230
178
  return cssResult;
231
179
  }
232
180
  }
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
181
  const resolver = getOxcResolver(options, fromFile);
237
182
  const context = (0, path_1.getDirname)(fromFile);
238
183
  try {
@@ -242,24 +187,16 @@ function resolveModule(importPath, fromFile, options = {}) {
242
187
  }
243
188
  }
244
189
  catch {
245
- // oxc-resolver throws on resolution failure — this is expected for
246
- // unresolvable imports (typos, missing packages, etc.)
247
190
  }
248
- // No resolver succeeded
249
191
  return null;
250
192
  }
251
- catch {
252
- // Resolution failed with unexpected error
193
+ catch (error) {
194
+ if (error instanceof MissingResolverPeerError) {
195
+ throw error;
196
+ }
253
197
  return null;
254
198
  }
255
199
  }
256
- /**
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`.
262
- */
263
200
  function clearResolverCache() {
264
201
  for (const resolver of oxcResolverCache.values()) {
265
202
  resolver.clearCache();
package/src/resolver.js CHANGED
@@ -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
  const tslib_1 = require("tslib");
9
4
  tslib_1.__exportStar(require("./resolver/index"), exports);
@@ -1,14 +1,6 @@
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
- // Rule creation utilities for building ESLint rules
10
4
  tslib_1.__exportStar(require("./rule-creator"), exports);
11
5
  tslib_1.__exportStar(require("./mock-context"), exports);
12
- // Shared CWE-89 detector — see sql-injection-rule.ts for why it lives here
13
- // rather than inside a single database plugin.
14
6
  tslib_1.__exportStar(require("./sql-injection-rule"), exports);
@@ -1,15 +1,6 @@
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.createWithMockContext = createWithMockContext;
9
- /**
10
- * Build a minimal rule context, call `rule.create(context)`, and return the
11
- * listeners plus a recorder of every `context.report(...)` descriptor.
12
- */
13
4
  function createWithMockContext(rule, opts = {}) {
14
5
  const reports = [];
15
6
  const filename = opts.filename ?? 'mock.ts';