eslint-module-utils
Advanced tools
+10
-0
@@ -8,2 +8,11 @@ # Change Log | ||
| ## v2.14.0 - 2026-07-02 | ||
| ### Added | ||
| - add `contextCompat` `getCWD()` (thanks [@ljharb]) | ||
| - add eslint v10 support ([#3230], thanks [@rasmi]) | ||
| ### Fixed | ||
| - `declaredScope`: route through the `getScope` compat shim instead of the removed `context.getScope()` (ESLint 9+) (thanks [@ljharb]) | ||
| ## v2.13.0 - 2026-05-27 | ||
@@ -194,2 +203,3 @@ | ||
| [#3240]: https://github.com/import-js/eslint-plugin-import/pull/3240 | ||
| [#3124]: https://github.com/import-js/eslint-plugin-import/pull/3124 | ||
@@ -196,0 +206,0 @@ [#3072]: https://github.com/import-js/eslint-plugin-import/pull/3072 |
+17
-13
@@ -5,17 +5,19 @@ import { Scope, SourceCode, Rule } from 'eslint'; | ||
| type LegacyContext = { | ||
| getFilename: () => string, | ||
| getPhysicalFilename: () => string, | ||
| getSourceCode: () => SourceCode, | ||
| getScope: never, | ||
| getAncestors: never, | ||
| getDeclaredVariables: never, | ||
| getCwd: () => string; | ||
| getFilename: () => string; | ||
| getPhysicalFilename: () => string; | ||
| getSourceCode: () => SourceCode; | ||
| getScope: never; | ||
| getAncestors: never; | ||
| getDeclaredVariables: never; | ||
| }; | ||
| type NewContext = { | ||
| filename: string, | ||
| sourceCode: SourceCode, | ||
| getPhysicalFilename?: () => string, | ||
| getScope: () => Scope.Scope, | ||
| getAncestors: () => ESTree.Node[], | ||
| getDeclaredVariables: (node: ESTree.Node) => Scope.Variable[], | ||
| cwd: string; | ||
| filename: string; | ||
| sourceCode: SourceCode; | ||
| getPhysicalFilename?: () => string; | ||
| getScope: () => Scope.Scope; | ||
| getAncestors: () => ESTree.Node[]; | ||
| getDeclaredVariables: (node: ESTree.Node) => Scope.Variable[]; | ||
| }; | ||
@@ -29,7 +31,9 @@ | ||
| declare function getPhysicalFilename(context: Context): string; | ||
| declare function getScope(context: Context, node: ESTree.Node): Scope.Scope; | ||
| declare function getScope(context: Context, node?: ESTree.Node): Scope.Scope; | ||
| declare function getSourceCode(context: Context): SourceCode; | ||
| declare function getCWD(context: Context): string | undefined; | ||
| export { | ||
| getAncestors, | ||
| getCWD, | ||
| getDeclaredVariables, | ||
@@ -36,0 +40,0 @@ getFilename, |
+16
-0
@@ -38,2 +38,6 @@ 'use strict'; | ||
| function getPhysicalFilename(context) { | ||
| if ('physicalFilename' in context) { | ||
| return context.physicalFilename; | ||
| } | ||
| if (context.getPhysicalFilename) { | ||
@@ -51,2 +55,3 @@ return context.getPhysicalFilename(); | ||
| if (sourceCode && sourceCode.getScope) { | ||
| // @ts-expect-error TODO: investigate why this is needed | ||
| return sourceCode.getScope(node); | ||
@@ -67,4 +72,15 @@ } | ||
| /** @type {import('./contextCompat').getCWD} */ | ||
| function getCWD(context) { | ||
| if ('cwd' in context) { | ||
| return context.cwd; | ||
| } | ||
| if (context.getCwd) { | ||
| return context.getCwd(); | ||
| } | ||
| } | ||
| module.exports = { | ||
| getAncestors, | ||
| getCWD, | ||
| getDeclaredVariables, | ||
@@ -71,0 +87,0 @@ getFilename, |
+1
-1
@@ -9,3 +9,3 @@ 'use strict'; | ||
| exports.default = function declaredScope(context, name, node) { | ||
| const references = (node ? getScope(context, node) : context.getScope()).references; | ||
| const references = getScope(context, node).references; | ||
| const reference = references.find((x) => x.identifier.name === name); | ||
@@ -12,0 +12,0 @@ if (!reference || !reference.resolved) { return undefined; } |
+5
-4
| { | ||
| "name": "eslint-module-utils", | ||
| "version": "2.13.0", | ||
| "version": "2.14.0", | ||
| "description": "Core utilities to support eslint-plugin-import and other module-related plugins.", | ||
@@ -43,3 +43,4 @@ "engines": { | ||
| "posttsc": "attw -P .", | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "dependencies": "DT_CLEAN_NPM_COMMAND=\"$npm_command\" npx dt-clean@^1.2.0 --auto" | ||
| }, | ||
@@ -67,7 +68,7 @@ "repository": { | ||
| "devDependencies": { | ||
| "@arethetypeswrong/cli": "^0.18.2", | ||
| "@arethetypeswrong/cli": "^0.18.4", | ||
| "@ljharb/tsconfig": "^0.3.2", | ||
| "@types/debug": "^4.1.13", | ||
| "@types/eslint": "^8.56.12", | ||
| "@types/node": "^20.19.37", | ||
| "@types/node": "^20.19.43", | ||
| "typescript": "next" | ||
@@ -74,0 +75,0 @@ }, |
+1
-1
@@ -117,3 +117,3 @@ 'use strict'; | ||
| const languageOptions = context.languageOptions; | ||
| let parserOptions = languageOptions && languageOptions.parserOptions || context.parserOptions; | ||
| let parserOptions = languageOptions && languageOptions.parserOptions || context.parserOptions || {}; | ||
| const parserOrPath = getParser(path, context); | ||
@@ -120,0 +120,0 @@ |
+2
-0
@@ -7,2 +7,4 @@ { | ||
| "maxNodeModuleJsDepth": 0, | ||
| "ignoreDeprecations": "6.0", | ||
| "types": ["node"] | ||
| }, | ||
@@ -9,0 +11,0 @@ "exclude": [ |
56628
1.66%1110
1.83%