🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

eslint-module-utils

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-module-utils - npm Package Compare versions

Comparing version
2.12.1
to
2.13.0
+5
-0
CHANGELOG.md

@@ -8,2 +8,7 @@ # Change Log

## v2.13.0 - 2026-05-27
### Added
- pass `moduleSystem` through resolve for exports-aware resolution
## v2.12.1 - 2025-06-19

@@ -10,0 +15,0 @@

+2
-1
import type { Rule } from 'eslint';
import type { Node } from 'estree';
type Visitor = (source: Node, importer: unknown) => any;
type ModuleSystem = 'import' | 'require';
type Visitor = (source: Node, importer: unknown, moduleSystem?: ModuleSystem) => any;

@@ -6,0 +7,0 @@ type Options = {

@@ -24,4 +24,4 @@ 'use strict';

/** @type {(source: undefined | null | import('estree').Literal, importer: Parameters<typeof visitor>[1]) => void} */
function checkSourceValue(source, importer) {
/** @type {(source: undefined | null | import('estree').Literal, importer: Parameters<typeof visitor>[1], moduleSystem?: 'import' | 'require') => void} */
function checkSourceValue(source, importer, moduleSystem) {
if (source == null) { return; } //?

@@ -33,3 +33,3 @@

// fire visitor
visitor(source, importer);
visitor(source, importer, moduleSystem);
}

@@ -40,3 +40,3 @@

function checkSource(node) {
checkSourceValue(node.source, node);
checkSourceValue(node.source, node, 'import');
}

@@ -65,3 +65,3 @@

checkSourceValue(modulePath, node);
checkSourceValue(modulePath, node, 'import');
}

@@ -81,3 +81,3 @@

checkSourceValue(modulePath, call);
checkSourceValue(modulePath, call, 'require');
}

@@ -106,3 +106,3 @@

checkSourceValue(element, element);
checkSourceValue(element, element, 'require');
}

@@ -109,0 +109,0 @@ }

{
"name": "eslint-module-utils",
"version": "2.12.1",
"version": "2.13.0",
"description": "Core utilities to support eslint-plugin-import and other module-related plugins.",

@@ -68,5 +68,5 @@ "engines": {

"@ljharb/tsconfig": "^0.3.2",
"@types/debug": "^4.1.12",
"@types/eslint": "^8.56.3",
"@types/node": "^20.19.1",
"@types/debug": "^4.1.13",
"@types/eslint": "^8.56.12",
"@types/node": "^20.19.37",
"typescript": "next"

@@ -73,0 +73,0 @@ },

@@ -10,2 +10,3 @@ import type { Rule } from 'eslint';

export type ModuleSystem = 'import' | 'require';
export type ResolverResolve = (modulePath: string, sourceFile:string, config: unknown) => ResolvedResult;

@@ -18,2 +19,3 @@ export type ResolverResolveImport = (modulePath: string, sourceFile:string, config: unknown) => string | undefined;

context: Rule.RuleContext,
moduleSystem?: ModuleSystem,
): ResolvedResult['path'];

@@ -29,5 +31,5 @@

declare function relative(modulePath: string, sourceFile: string, settings: ESLintSettings): ResolvedResult['path'];
declare function relative(modulePath: string, sourceFile: string, settings: ESLintSettings, moduleSystem?: ModuleSystem): ResolvedResult['path'];
export { fileExistsWithCaseSync, relative };

@@ -152,4 +152,4 @@ 'use strict';

let memoizedHash = '';
/** @type {(modulePath: string, sourceFile: string, settings: import('./types').ESLintSettings) => import('./resolve').ResolvedResult} */
function fullResolve(modulePath, sourceFile, settings) {
/** @type {(modulePath: string, sourceFile: string, settings: import('./types').ESLintSettings, moduleSystem?: 'import' | 'require') => import('./resolve').ResolvedResult} */
function fullResolve(modulePath, sourceFile, settings, moduleSystem) {
// check if this is a bonus core module

@@ -166,3 +166,3 @@ const coreSet = new Set(settings['import/core-modules']);

const cacheKey = sourceDir + memoizedHash + modulePath;
const cacheKey = sourceDir + memoizedHash + modulePath + (moduleSystem || '');

@@ -182,3 +182,6 @@ const cacheSettings = ModuleCache.getSettings(settings);

if (resolver.interfaceVersion === 2) {
return resolver.resolve(modulePath, sourceFile, config);
const resolverConfig = moduleSystem
? Object.assign({}, config, { moduleSystem })
: config;
return resolver.resolve(modulePath, sourceFile, resolverConfig);
}

@@ -219,4 +222,4 @@

/** @type {import('./resolve').relative} */
function relative(modulePath, sourceFile, settings) {
return fullResolve(modulePath, sourceFile, settings).path;
function relative(modulePath, sourceFile, settings, moduleSystem) {
return fullResolve(modulePath, sourceFile, settings, moduleSystem).path;
}

@@ -235,5 +238,5 @@ exports.relative = relative;

*/
function resolve(p, context) {
function resolve(p, context, moduleSystem) {
try {
return relative(p, getPhysicalFilename(context), context.settings);
return relative(p, getPhysicalFilename(context), context.settings, moduleSystem);
} catch (err) {

@@ -240,0 +243,0 @@ if (!erroredContexts.has(context)) {