@rushstack/eslint-plugin-packlets 0.10.0 → 0.12.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.
- package/CHANGELOG.json +24 -0
- package/CHANGELOG.md +15 -1
- package/lib/DependencyAnalyzer.d.ts +1 -1
- package/lib/DependencyAnalyzer.d.ts.map +1 -1
- package/lib/DependencyAnalyzer.js.map +1 -1
- package/lib/circular-deps.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/mechanics.d.ts +1 -1
- package/lib/mechanics.d.ts.map +1 -1
- package/lib/mechanics.js.map +1 -1
- package/package.json +7 -13
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/eslint-plugin-packlets",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.12.0",
|
|
6
|
+
"tag": "@rushstack/eslint-plugin-packlets_v0.12.0",
|
|
7
|
+
"date": "Thu, 26 Jun 2025 18:57:04 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Update for compatibility with ESLint 9"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"version": "0.11.0",
|
|
18
|
+
"tag": "@rushstack/eslint-plugin-packlets_v0.11.0",
|
|
19
|
+
"date": "Tue, 11 Mar 2025 02:12:33 GMT",
|
|
20
|
+
"comments": {
|
|
21
|
+
"minor": [
|
|
22
|
+
{
|
|
23
|
+
"comment": "Bump the `@typescript-eslint/*` packages to add support for TypeScript 5.8."
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
4
28
|
{
|
|
5
29
|
"version": "0.10.0",
|
|
6
30
|
"tag": "@rushstack/eslint-plugin-packlets_v0.10.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @rushstack/eslint-plugin-packlets
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 26 Jun 2025 18:57:04 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.12.0
|
|
6
|
+
Thu, 26 Jun 2025 18:57:04 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Update for compatibility with ESLint 9
|
|
11
|
+
|
|
12
|
+
## 0.11.0
|
|
13
|
+
Tue, 11 Mar 2025 02:12:33 GMT
|
|
14
|
+
|
|
15
|
+
### Minor changes
|
|
16
|
+
|
|
17
|
+
- Bump the `@typescript-eslint/*` packages to add support for TypeScript 5.8.
|
|
4
18
|
|
|
5
19
|
## 0.10.0
|
|
6
20
|
Sat, 01 Mar 2025 07:23:16 GMT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyAnalyzer.d.ts","sourceRoot":"","sources":["../src/DependencyAnalyzer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"DependencyAnalyzer.d.ts","sourceRoot":"","sources":["../src/DependencyAnalyzer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA4DzD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAYD,qBAAa,kBAAkB;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAwG3B;;;;;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AAC;YACnC,+CAA+C;YAC/C,UAAU,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;QAChD,CAAC;aAAM,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;YAClD,oCAAoC;YACpC,qBAAqB,GAAG,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;QACnE,CAAC;aAAM,CAAC;YACN,mDAAmD;YACnD,MAAM,IAAI,KAAK,CACb,qGAAqG;gBACnG,2BAA2B,CAC9B,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAgB,IAAI,GAAG,EAAE,CAAC;QAE/C,MAAM,QAAQ,GAAgC,kBAAkB,CAAC,YAAY,CAC3E,WAAW,EACX,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,OAAO,EACP,eAAe,CAAC,kBAAmB,EACnC,eAAe,EACf,SAAS,CAAC,eAAe;SAC1B,CAAC;QAEF,IAAI,QAAQ,EAAE,CAAC;YACb,sCAAsC;YACtC,MAAM,cAAc,GAAqB,EAAE,CAAC;YAC5C,KAAK,IAAI,OAAO,GAAgC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;gBAClG,cAAc,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;YAChG,CAAC;YACD,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA9LD,gDA8LC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport { Path } from './Path';\nimport { PackletAnalyzer } from './PackletAnalyzer';\n\nenum RefFileKind {\n Import,\n ReferenceFile,\n TypeReferenceDirective\n}\n\n// TypeScript compiler internal:\n// Version range: >= 3.6.0, <= 4.2.0\n// https://github.com/microsoft/TypeScript/blob/5ecdcef4cecfcdc86bd681b377636422447507d7/src/compiler/program.ts#L541\ninterface IRefFile {\n // The absolute path of the module that was imported.\n // (Normalized to an all lowercase ts.Path string.)\n referencedFileName: string;\n // The kind of reference.\n kind: RefFileKind;\n // An index indicating the order in which items occur in a compound expression\n index: number;\n\n // The absolute path of the source file containing the import statement.\n // (Normalized to an all lowercase ts.Path string.)\n file: string;\n}\n\n// TypeScript compiler internal:\n// Version range: > 4.2.0\n// https://github.com/microsoft/TypeScript/blob/2eca17d7c1a3fb2b077f3a910d5019d74b6f07a0/src/compiler/types.ts#L3693\nenum FileIncludeKind {\n RootFile,\n SourceFromProjectReference,\n OutputFromProjectReference,\n Import,\n ReferenceFile,\n TypeReferenceDirective,\n LibFile,\n LibReferenceDirective,\n AutomaticTypeDirectiveFile\n}\n\n// TypeScript compiler internal:\n// Version range: > 4.2.0\n// https://github.com/microsoft/TypeScript/blob/2eca17d7c1a3fb2b077f3a910d5019d74b6f07a0/src/compiler/types.ts#L3748\ninterface IFileIncludeReason {\n kind: FileIncludeKind;\n file: string | undefined;\n}\n\ninterface ITsProgramInternals extends ts.Program {\n // TypeScript compiler internal:\n // Version range: >= 3.6.0, <= 4.2.0\n // https://github.com/microsoft/TypeScript/blob/5ecdcef4cecfcdc86bd681b377636422447507d7/src/compiler/types.ts#L3723\n getRefFileMap?: () => Map<string, IRefFile[]> | undefined;\n\n // TypeScript compiler internal:\n // Version range: > 4.2.0\n // https://github.com/microsoft/TypeScript/blob/2eca17d7c1a3fb2b077f3a910d5019d74b6f07a0/src/compiler/types.ts#L3871\n getFileIncludeReasons?: () => Map<string, IFileIncludeReason[]>;\n}\n\n/**\n * Represents a packlet that imports another packlet.\n */\nexport interface IPackletImport {\n /**\n * The name of the packlet being imported.\n */\n packletName: string;\n\n /**\n * The absolute path of the file that imports the packlet.\n */\n fromFilePath: string;\n}\n\n/**\n * Used to build a linked list of imports that represent a circular dependency.\n */\ninterface IImportListNode extends IPackletImport {\n /**\n * The previous link in the linked list.\n */\n previousNode: IImportListNode | undefined;\n}\n\nexport class DependencyAnalyzer {\n /**\n * @param packletName - the packlet to be checked next in our traversal\n * @param startingPackletName - the packlet that we started with; if the traversal reaches this packlet,\n * then a circular dependency has been detected\n * @param refFileMap - the compiler's `refFileMap` data structure describing import relationships\n * @param fileIncludeReasonsMap - the compiler's data structure describing import relationships\n * @param program - the compiler's `ts.Program` object\n * @param packletsFolderPath - the absolute path of the \"src/packlets\" folder.\n * @param visitedPacklets - the set of packlets that have already been visited in this traversal\n * @param previousNode - a linked list of import statements that brought us to this step in the traversal\n */\n private static _walkImports(\n packletName: string,\n startingPackletName: string,\n refFileMap: Map<string, IRefFile[]> | undefined,\n fileIncludeReasonsMap: Map<string, IFileIncludeReason[]> | undefined,\n program: ts.Program,\n packletsFolderPath: string,\n visitedPacklets: Set<string>,\n previousNode: IImportListNode | undefined\n ): IImportListNode | undefined {\n visitedPacklets.add(packletName);\n\n const packletEntryPoint: string = Path.join(packletsFolderPath, packletName, 'index');\n\n const tsSourceFile: ts.SourceFile | undefined =\n program.getSourceFile(packletEntryPoint + '.ts') || program.getSourceFile(packletEntryPoint + '.tsx');\n if (!tsSourceFile) {\n return undefined;\n }\n\n const referencingFilePaths: string[] = [];\n\n if (refFileMap) {\n // TypeScript version range: >= 3.6.0, <= 4.2.0\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const refFiles: IRefFile[] | undefined = refFileMap.get((tsSourceFile as any).path);\n if (refFiles) {\n for (const refFile of refFiles) {\n if (refFile.kind === RefFileKind.Import) {\n referencingFilePaths.push(refFile.file);\n }\n }\n }\n } else if (fileIncludeReasonsMap) {\n // Typescript version range: > 4.2.0\n const fileIncludeReasons: IFileIncludeReason[] | undefined = fileIncludeReasonsMap.get(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (tsSourceFile as any).path\n );\n if (fileIncludeReasons) {\n for (const fileIncludeReason of fileIncludeReasons) {\n if (fileIncludeReason.kind === FileIncludeKind.Import) {\n if (fileIncludeReason.file) {\n referencingFilePaths.push(fileIncludeReason.file);\n }\n }\n }\n }\n }\n\n for (const referencingFilePath of referencingFilePaths) {\n // Is it a reference to a packlet?\n if (Path.isUnder(referencingFilePath, packletsFolderPath)) {\n const referencingRelativePath: string = Path.relative(packletsFolderPath, referencingFilePath);\n const referencingPathParts: string[] = referencingRelativePath.split(/[\\/\\\\]+/);\n const referencingPackletName: string = referencingPathParts[0];\n\n // Did we return to where we started from?\n if (referencingPackletName === startingPackletName) {\n // Ignore the degenerate case where the starting node imports itself,\n // since @rushstack/packlets/mechanics will already report that.\n if (previousNode) {\n // Make a new linked list node to record this step of the traversal\n const importListNode: IImportListNode = {\n previousNode: previousNode,\n fromFilePath: referencingFilePath,\n packletName: packletName\n };\n\n // The traversal has returned to the packlet that we started from;\n // this means we have detected a circular dependency\n return importListNode;\n }\n }\n\n // Have we already analyzed this packlet?\n if (!visitedPacklets.has(referencingPackletName)) {\n // Make a new linked list node to record this step of the traversal\n const importListNode: IImportListNode = {\n previousNode: previousNode,\n fromFilePath: referencingFilePath,\n packletName: packletName\n };\n\n const result: IImportListNode | undefined = DependencyAnalyzer._walkImports(\n referencingPackletName,\n startingPackletName,\n refFileMap,\n fileIncludeReasonsMap,\n program,\n packletsFolderPath,\n visitedPacklets,\n importListNode\n );\n if (result) {\n return result;\n }\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * For the specified packlet, trace all modules that import it, looking for a circular dependency\n * between packlets. If found, an array is returned describing the import statements that cause\n * the problem.\n *\n * @remarks\n * For example, suppose we have files like this:\n *\n * ```\n * src/packlets/logging/index.ts\n * src/packlets/logging/Logger.ts --> imports \"../data-model\"\n * src/packlets/data-model/index.ts\n * src/packlets/data-model/DataModel.ts --> imports \"../logging\"\n * ```\n *\n * The returned array would be:\n * ```ts\n * [\n * { packletName: \"logging\", fromFilePath: \"/path/to/src/packlets/data-model/DataModel.ts\" },\n * { packletName: \"data-model\", fromFilePath: \"/path/to/src/packlets/logging/Logger.ts\" },\n * ]\n * ```\n *\n * If there is more than one circular dependency chain, only the first one that is encountered\n * will be returned.\n */\n public static checkEntryPointForCircularImport(\n packletName: string,\n packletAnalyzer: PackletAnalyzer,\n program: ts.Program\n ): IPackletImport[] | undefined {\n const programInternals: ITsProgramInternals = program;\n\n let refFileMap: Map<string, IRefFile[]> | undefined;\n let fileIncludeReasonsMap: Map<string, IFileIncludeReason[]> | undefined;\n\n if (programInternals.getRefFileMap) {\n // TypeScript version range: >= 3.6.0, <= 4.2.0\n refFileMap = programInternals.getRefFileMap();\n } else if (programInternals.getFileIncludeReasons) {\n // Typescript version range: > 4.2.0\n fileIncludeReasonsMap = programInternals.getFileIncludeReasons();\n } else {\n // If you encounter this error, please report a bug\n throw new Error(\n 'Your TypeScript compiler version is not supported; please upgrade @rushstack/eslint-plugin-packlets' +\n ' or report a GitHub issue'\n );\n }\n\n const visitedPacklets: Set<string> = new Set();\n\n const listNode: IImportListNode | undefined = DependencyAnalyzer._walkImports(\n packletName,\n packletName,\n refFileMap,\n fileIncludeReasonsMap,\n program,\n packletAnalyzer.packletsFolderPath!,\n visitedPacklets,\n undefined // previousNode\n );\n\n if (listNode) {\n // Convert the linked list to an array\n const packletImports: IPackletImport[] = [];\n for (let current: IImportListNode | undefined = listNode; current; current = current.previousNode) {\n packletImports.push({ fromFilePath: current.fromFilePath, packletName: current.packletName });\n }\n return packletImports;\n }\n\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DependencyAnalyzer.js","sourceRoot":"","sources":["../src/DependencyAnalyzer.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,iCAA8B;AAG9B,IAAK,WAIJ;AAJD,WAAK,WAAW;IACd,iDAAM,CAAA;IACN,+DAAa,CAAA;IACb,iFAAsB,CAAA;AACxB,CAAC,EAJI,WAAW,KAAX,WAAW,QAIf;AAmBD,gCAAgC;AAChC,yBAAyB;AACzB,oHAAoH;AACpH,IAAK,eAUJ;AAVD,WAAK,eAAe;IAClB,6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,QAAQ,EAAE,CAAC;YACb,sCAAsC;YACtC,MAAM,cAAc,GAAqB,EAAE,CAAC;YAC5C,KAAK,IAAI,OAAO,GAAgC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;gBAClG,cAAc,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;YAChG,CAAC;YACD,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA9LD,gDA8LC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport { Path } from './Path';\nimport type { PackletAnalyzer } from './PackletAnalyzer';\n\nenum RefFileKind {\n Import,\n ReferenceFile,\n TypeReferenceDirective\n}\n\n// TypeScript compiler internal:\n// Version range: >= 3.6.0, <= 4.2.0\n// https://github.com/microsoft/TypeScript/blob/5ecdcef4cecfcdc86bd681b377636422447507d7/src/compiler/program.ts#L541\ninterface IRefFile {\n // The absolute path of the module that was imported.\n // (Normalized to an all lowercase ts.Path string.)\n referencedFileName: string;\n // The kind of reference.\n kind: RefFileKind;\n // An index indicating the order in which items occur in a compound expression\n index: number;\n\n // The absolute path of the source file containing the import statement.\n // (Normalized to an all lowercase ts.Path string.)\n file: string;\n}\n\n// TypeScript compiler internal:\n// Version range: > 4.2.0\n// https://github.com/microsoft/TypeScript/blob/2eca17d7c1a3fb2b077f3a910d5019d74b6f07a0/src/compiler/types.ts#L3693\nenum FileIncludeKind {\n RootFile,\n SourceFromProjectReference,\n OutputFromProjectReference,\n Import,\n ReferenceFile,\n TypeReferenceDirective,\n LibFile,\n LibReferenceDirective,\n AutomaticTypeDirectiveFile\n}\n\n// TypeScript compiler internal:\n// Version range: > 4.2.0\n// https://github.com/microsoft/TypeScript/blob/2eca17d7c1a3fb2b077f3a910d5019d74b6f07a0/src/compiler/types.ts#L3748\ninterface IFileIncludeReason {\n kind: FileIncludeKind;\n file: string | undefined;\n}\n\ninterface ITsProgramInternals extends ts.Program {\n // TypeScript compiler internal:\n // Version range: >= 3.6.0, <= 4.2.0\n // https://github.com/microsoft/TypeScript/blob/5ecdcef4cecfcdc86bd681b377636422447507d7/src/compiler/types.ts#L3723\n getRefFileMap?: () => Map<string, IRefFile[]> | undefined;\n\n // TypeScript compiler internal:\n // Version range: > 4.2.0\n // https://github.com/microsoft/TypeScript/blob/2eca17d7c1a3fb2b077f3a910d5019d74b6f07a0/src/compiler/types.ts#L3871\n getFileIncludeReasons?: () => Map<string, IFileIncludeReason[]>;\n}\n\n/**\n * Represents a packlet that imports another packlet.\n */\nexport interface IPackletImport {\n /**\n * The name of the packlet being imported.\n */\n packletName: string;\n\n /**\n * The absolute path of the file that imports the packlet.\n */\n fromFilePath: string;\n}\n\n/**\n * Used to build a linked list of imports that represent a circular dependency.\n */\ninterface IImportListNode extends IPackletImport {\n /**\n * The previous link in the linked list.\n */\n previousNode: IImportListNode | undefined;\n}\n\nexport class DependencyAnalyzer {\n /**\n * @param packletName - the packlet to be checked next in our traversal\n * @param startingPackletName - the packlet that we started with; if the traversal reaches this packlet,\n * then a circular dependency has been detected\n * @param refFileMap - the compiler's `refFileMap` data structure describing import relationships\n * @param fileIncludeReasonsMap - the compiler's data structure describing import relationships\n * @param program - the compiler's `ts.Program` object\n * @param packletsFolderPath - the absolute path of the \"src/packlets\" folder.\n * @param visitedPacklets - the set of packlets that have already been visited in this traversal\n * @param previousNode - a linked list of import statements that brought us to this step in the traversal\n */\n private static _walkImports(\n packletName: string,\n startingPackletName: string,\n refFileMap: Map<string, IRefFile[]> | undefined,\n fileIncludeReasonsMap: Map<string, IFileIncludeReason[]> | undefined,\n program: ts.Program,\n packletsFolderPath: string,\n visitedPacklets: Set<string>,\n previousNode: IImportListNode | undefined\n ): IImportListNode | undefined {\n visitedPacklets.add(packletName);\n\n const packletEntryPoint: string = Path.join(packletsFolderPath, packletName, 'index');\n\n const tsSourceFile: ts.SourceFile | undefined =\n program.getSourceFile(packletEntryPoint + '.ts') || program.getSourceFile(packletEntryPoint + '.tsx');\n if (!tsSourceFile) {\n return undefined;\n }\n\n const referencingFilePaths: string[] = [];\n\n if (refFileMap) {\n // TypeScript version range: >= 3.6.0, <= 4.2.0\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const refFiles: IRefFile[] | undefined = refFileMap.get((tsSourceFile as any).path);\n if (refFiles) {\n for (const refFile of refFiles) {\n if (refFile.kind === RefFileKind.Import) {\n referencingFilePaths.push(refFile.file);\n }\n }\n }\n } else if (fileIncludeReasonsMap) {\n // Typescript version range: > 4.2.0\n const fileIncludeReasons: IFileIncludeReason[] | undefined = fileIncludeReasonsMap.get(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (tsSourceFile as any).path\n );\n if (fileIncludeReasons) {\n for (const fileIncludeReason of fileIncludeReasons) {\n if (fileIncludeReason.kind === FileIncludeKind.Import) {\n if (fileIncludeReason.file) {\n referencingFilePaths.push(fileIncludeReason.file);\n }\n }\n }\n }\n }\n\n for (const referencingFilePath of referencingFilePaths) {\n // Is it a reference to a packlet?\n if (Path.isUnder(referencingFilePath, packletsFolderPath)) {\n const referencingRelativePath: string = Path.relative(packletsFolderPath, referencingFilePath);\n const referencingPathParts: string[] = referencingRelativePath.split(/[\\/\\\\]+/);\n const referencingPackletName: string = referencingPathParts[0];\n\n // Did we return to where we started from?\n if (referencingPackletName === startingPackletName) {\n // Ignore the degenerate case where the starting node imports itself,\n // since @rushstack/packlets/mechanics will already report that.\n if (previousNode) {\n // Make a new linked list node to record this step of the traversal\n const importListNode: IImportListNode = {\n previousNode: previousNode,\n fromFilePath: referencingFilePath,\n packletName: packletName\n };\n\n // The traversal has returned to the packlet that we started from;\n // this means we have detected a circular dependency\n return importListNode;\n }\n }\n\n // Have we already analyzed this packlet?\n if (!visitedPacklets.has(referencingPackletName)) {\n // Make a new linked list node to record this step of the traversal\n const importListNode: IImportListNode = {\n previousNode: previousNode,\n fromFilePath: referencingFilePath,\n packletName: packletName\n };\n\n const result: IImportListNode | undefined = DependencyAnalyzer._walkImports(\n referencingPackletName,\n startingPackletName,\n refFileMap,\n fileIncludeReasonsMap,\n program,\n packletsFolderPath,\n visitedPacklets,\n importListNode\n );\n if (result) {\n return result;\n }\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * For the specified packlet, trace all modules that import it, looking for a circular dependency\n * between packlets. If found, an array is returned describing the import statements that cause\n * the problem.\n *\n * @remarks\n * For example, suppose we have files like this:\n *\n * ```\n * src/packlets/logging/index.ts\n * src/packlets/logging/Logger.ts --> imports \"../data-model\"\n * src/packlets/data-model/index.ts\n * src/packlets/data-model/DataModel.ts --> imports \"../logging\"\n * ```\n *\n * The returned array would be:\n * ```ts\n * [\n * { packletName: \"logging\", fromFilePath: \"/path/to/src/packlets/data-model/DataModel.ts\" },\n * { packletName: \"data-model\", fromFilePath: \"/path/to/src/packlets/logging/Logger.ts\" },\n * ]\n * ```\n *\n * If there is more than one circular dependency chain, only the first one that is encountered\n * will be returned.\n */\n public static checkEntryPointForCircularImport(\n packletName: string,\n packletAnalyzer: PackletAnalyzer,\n program: ts.Program\n ): IPackletImport[] | undefined {\n const programInternals: ITsProgramInternals = program;\n\n let refFileMap: Map<string, IRefFile[]> | undefined;\n let fileIncludeReasonsMap: Map<string, IFileIncludeReason[]> | undefined;\n\n if (programInternals.getRefFileMap) {\n // TypeScript version range: >= 3.6.0, <= 4.2.0\n refFileMap = programInternals.getRefFileMap();\n } else if (programInternals.getFileIncludeReasons) {\n // Typescript version range: > 4.2.0\n fileIncludeReasonsMap = programInternals.getFileIncludeReasons();\n } else {\n // If you encounter this error, please report a bug\n throw new Error(\n 'Your TypeScript compiler version is not supported; please upgrade @rushstack/eslint-plugin-packlets' +\n ' or report a GitHub issue'\n );\n }\n\n const visitedPacklets: Set<string> = new Set();\n\n const listNode: IImportListNode | undefined = DependencyAnalyzer._walkImports(\n packletName,\n packletName,\n refFileMap,\n fileIncludeReasonsMap,\n program,\n packletAnalyzer.packletsFolderPath!,\n visitedPacklets,\n undefined // previousNode\n );\n\n if (listNode) {\n // Convert the linked list to an array\n const packletImports: IPackletImport[] = [];\n for (let current: IImportListNode | undefined = listNode; current; current = current.previousNode) {\n packletImports.push({ fromFilePath: current.fromFilePath, packletName: current.packletName });\n }\n return packletImports;\n }\n\n return undefined;\n }\n}\n"]}
|
package/lib/circular-deps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circular-deps.js","sourceRoot":"","sources":["../src/circular-deps.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,oDAAuD;AAEvD,uDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"circular-deps.js","sourceRoot":"","sources":["../src/circular-deps.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,oDAAuD;AAEvD,uDAAoD;AACpD,6DAA+E;AAC/E,iCAA8B;AAK9B,MAAM,YAAY,GAA6C;IAC7D,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE,iBAAiB,EAAE,0DAA0D,EAAE;QAC3F,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,kDAAkD;YAC/D,WAAW,EAAE,aAAa;YAC1B,GAAG,EAAE,iEAAiE;SAC1C;KAC/B;IAED,MAAM,EAAE,CAAC,OAAkD,EAAE,EAAE;QAC7D,gEAAgE;QAChE,MAAM,aAAa,GAAW,OAAO,CAAC,WAAW,EAAE,CAAC;QAEpD,6CAA6C;QAC7C,MAAM,OAAO,GAAe,mBAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,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E,iBAAiB;gCAC5B,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;6BACzB,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEO,oCAAY","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ESLintUtils } from '@typescript-eslint/utils';\n\nimport { PackletAnalyzer } from './PackletAnalyzer';\nimport { DependencyAnalyzer, type IPackletImport } from './DependencyAnalyzer';\nimport { Path } from './Path';\n\nexport type MessageIds = 'circular-import';\ntype Options = [];\n\nconst circularDeps: TSESLint.RuleModule<MessageIds, Options> = {\n defaultOptions: [],\n meta: {\n type: 'problem',\n messages: { 'circular-import': 'Packlet imports create a circular reference:\\n{{report}}' },\n schema: [\n {\n type: 'object',\n additionalProperties: false\n }\n ],\n docs: {\n description: 'Check for circular dependencies between packlets',\n recommended: 'recommended',\n url: 'https://www.npmjs.com/package/@rushstack/eslint-plugin-packlets'\n } as TSESLint.RuleMetaDataDocs\n },\n\n create: (context: TSESLint.RuleContext<MessageIds, Options>) => {\n // Example: /path/to/my-project/src/packlets/my-packlet/index.ts\n const inputFilePath: string = context.getFilename();\n\n // Example: /path/to/my-project/tsconfig.json\n const program: ts.Program = ESLintUtils.getParserServices(context).program;\n const tsconfigFilePath: string | undefined = program.getCompilerOptions().configFilePath as string;\n\n const packletAnalyzer: PackletAnalyzer = PackletAnalyzer.analyzeInputFile(\n inputFilePath,\n tsconfigFilePath\n );\n if (packletAnalyzer.nothingToDo) {\n return {};\n }\n\n return {\n // Match the first node in the source file. Ideally we should be matching \"Program > :first-child\"\n // so a warning doesn't highlight the whole file. But that's blocked behind a bug in the query selector:\n // https://github.com/estools/esquery/issues/114\n Program: (node: TSESTree.Node): void => {\n if (packletAnalyzer.isEntryPoint && !packletAnalyzer.error) {\n const packletImports: IPackletImport[] | undefined =\n DependencyAnalyzer.checkEntryPointForCircularImport(\n packletAnalyzer.inputFilePackletName!,\n packletAnalyzer,\n program\n );\n\n if (packletImports) {\n const tsconfigFileFolder: string = Path.dirname(tsconfigFilePath);\n\n const affectedPackletNames: string[] = packletImports.map((x) => x.packletName);\n\n // If 3 different packlets form a circular dependency, we don't need to report the same warning 3 times.\n // Instead, only report the warning for the alphabetically smallest packlet.\n affectedPackletNames.sort();\n if (affectedPackletNames[0] === packletAnalyzer.inputFilePackletName) {\n let report: string = '';\n for (const packletImport of packletImports) {\n const filePath: string = Path.relative(tsconfigFileFolder, packletImport.fromFilePath);\n report += `\"${packletImport.packletName}\" is referenced by ${filePath}\\n`;\n }\n\n context.report({\n node: node,\n messageId: 'circular-import',\n data: { report: report }\n });\n }\n }\n }\n }\n };\n }\n};\n\nexport { circularDeps };\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAKzD,UAAU,OAAO;IACf,KAAK,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;KAAE,CAAC;IACtE,OAAO,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED,QAAA,MAAM,MAAM,EAAE,OAkBb,CAAC;AAEF,SAAS,MAAM,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;AAG3D,2CAAwC;AACxC,mDAA+C;AAC/C,qCAAkC;AAOlC,MAAM,MAAM,GAAY;IACtB,KAAK,EAAE;QACL,6CAA6C;QAC7C,SAAS,EAAE,qBAAS;QACpB,iDAAiD;QACjD,eAAe,EAAE,4BAAY;QAC7B,MAAM,EAAE,eAAM;KACf;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,mCAAmC,CAAC;YAC9C,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,mCAAmC,EAAE,MAAM;gBAC3C,4BAA4B,EAAE,KAAK;aACpC;SACF;KACF;CACF,CAAC;AAEF,iBAAS,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { TSESLint } from '@typescript-eslint/utils';\nimport { mechanics } from './mechanics';\nimport { circularDeps } from './circular-deps';\nimport { readme } from './readme';\n\ninterface IPlugin {\n rules: { [ruleName: string]: TSESLint.RuleModule<string, unknown[]> };\n configs: { [ruleName: string]: unknown };\n}\n\nconst plugin: IPlugin = {\n rules: {\n // Full name: \"@rushstack/packlets/mechanics\"\n mechanics: mechanics,\n // Full name: \"@rushstack/packlets/circular-deps\"\n 'circular-deps': circularDeps,\n readme: readme\n },\n configs: {\n recommended: {\n plugins: ['@rushstack/eslint-plugin-packlets'],\n rules: {\n '@rushstack/packlets/mechanics': 'warn',\n '@rushstack/packlets/circular-deps': 'warn',\n '@rushstack/packlets/readme': 'off'\n }\n }\n }\n};\n\nexport = plugin;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;AAG3D,2CAAwC;AACxC,mDAA+C;AAC/C,qCAAkC;AAOlC,MAAM,MAAM,GAAY;IACtB,KAAK,EAAE;QACL,6CAA6C;QAC7C,SAAS,EAAE,qBAAS;QACpB,iDAAiD;QACjD,eAAe,EAAE,4BAAY;QAC7B,MAAM,EAAE,eAAM;KACf;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,mCAAmC,CAAC;YAC9C,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,mCAAmC,EAAE,MAAM;gBAC3C,4BAA4B,EAAE,KAAK;aACpC;SACF;KACF;CACF,CAAC;AAEF,iBAAS,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { TSESLint } from '@typescript-eslint/utils';\nimport { mechanics } from './mechanics';\nimport { circularDeps } from './circular-deps';\nimport { readme } from './readme';\n\ninterface IPlugin {\n rules: { [ruleName: string]: TSESLint.RuleModule<string, unknown[]> };\n configs: { [ruleName: string]: unknown };\n}\n\nconst plugin: IPlugin = {\n rules: {\n // Full name: \"@rushstack/packlets/mechanics\"\n mechanics: mechanics,\n // Full name: \"@rushstack/packlets/circular-deps\"\n 'circular-deps': circularDeps,\n readme: readme\n },\n configs: {\n recommended: {\n plugins: ['@rushstack/eslint-plugin-packlets'],\n rules: {\n '@rushstack/packlets/mechanics': 'warn',\n '@rushstack/packlets/circular-deps': 'warn',\n '@rushstack/packlets/readme': 'off'\n }\n }\n }\n};\n\nexport = plugin;\n"]}
|
package/lib/mechanics.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
-
import { InputFileMessageIds, ImportMessageIds } from './PackletAnalyzer';
|
|
2
|
+
import { type InputFileMessageIds, type ImportMessageIds } from './PackletAnalyzer';
|
|
3
3
|
export type MessageIds = InputFileMessageIds | ImportMessageIds;
|
|
4
4
|
type Options = [];
|
|
5
5
|
declare const mechanics: TSESLint.RuleModule<MessageIds, Options>;
|
package/lib/mechanics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mechanics.d.ts","sourceRoot":"","sources":["../src/mechanics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAGnE,OAAO,
|
|
1
|
+
{"version":3,"file":"mechanics.d.ts","sourceRoot":"","sources":["../src/mechanics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAGnE,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AAChE,KAAK,OAAO,GAAG,EAAE,CAAC;AAElB,QAAA,MAAM,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAoHvD,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/lib/mechanics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mechanics.js","sourceRoot":"","sources":["../src/mechanics.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oDAAuE;AAEvE,
|
|
1
|
+
{"version":3,"file":"mechanics.js","sourceRoot":"","sources":["../src/mechanics.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oDAAuE;AAEvE,uDAK2B;AAK3B,MAAM,SAAS,GAA6C;IAC1D,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,sBAAsB;YACtB,wBAAwB,EAAE,6DAA6D;YACvF,sBAAsB,EACpB,yCAAyC;gBACzC,4FAA4F;YAC9F,2BAA2B,EAAE,qEAAqE;YAClG,oBAAoB,EAAE,wDAAwD;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F,8CAA8C;YAC9C,sDAAsD;YACtD,EAAE;YACF,4CAA4C;YAC5C,kDAAkD;YAClD,uDAAuD;YACvD,gEAAgE;YAChE,iEAAiE,EAAE,CACjE,IAAkG,EAC5F,EAAE;;gBACR,IAAI,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,sBAAc,CAAC,OAAO,EAAE,CAAC;oBACjD,IAAI,eAAe,CAAC,mBAAmB,EAAE,CAAC;wBACxC,wCAAwC;wBACxC,0CAA0C;wBAC1C,MAAM,UAAU,GAAW,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;wBAC7C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;4BACnC,OAAO;wBACT,CAAC;wBAED,IAAI,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;4BACjE,2BAA2B;4BAE3B,YAAY;4BACZ,qCAAqC;4BACrC,sDAAsD;4BACtD,OAAO;wBACT,CAAC;wBAED,MAAM,IAAI,GAA+B,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;wBACnF,IAAI,IAAI,EAAE,CAAC;4BACT,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,EAAE,IAAI;gCACV,SAAS,EAAE,IAAI,CAAC,SAAS;gCACzB,IAAI,EAAE,IAAI,CAAC,IAAI;6BAChB,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEO,8BAAS","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\n\nimport {\n PackletAnalyzer,\n type IAnalyzerError,\n type InputFileMessageIds,\n type ImportMessageIds\n} from './PackletAnalyzer';\n\nexport type MessageIds = InputFileMessageIds | ImportMessageIds;\ntype Options = [];\n\nconst mechanics: TSESLint.RuleModule<MessageIds, Options> = {\n defaultOptions: [],\n meta: {\n type: 'problem',\n messages: {\n // InputFileMessageIds\n 'file-in-packets-folder': 'The \"packlets\" folder must not contain regular source files',\n 'invalid-packlet-name':\n 'Invalid packlet name \"{{packletName}}\".' +\n ' The name must be lowercase alphanumeric words separated by hyphens. Example: \"my-packlet\"',\n 'misplaced-packlets-folder': 'The packlets folder must be located at \"{{expectedPackletsFolder}}\"',\n 'missing-src-folder': 'Expecting to find a \"src\" folder at: {{srcFolderPath}}',\n 'missing-tsconfig':\n 'In order to use @rushstack/eslint-plugin-packlets, your ESLint config file' +\n ' must configure the TypeScript parser',\n 'packlet-folder-case': 'The packlets folder must be all lower case: {{packletsFolderPath}}',\n\n // ImportMessageIds\n 'bypassed-entry-point':\n 'The import statement does not use the packlet\\'s entry point \"{{entryPointModulePath}}\"',\n 'circular-entry-point': 'Files under a packlet folder must not import from their own index.ts file',\n 'packlet-importing-project-file':\n 'A local project file cannot be imported.' +\n \" A packlet's dependencies must be NPM packages and/or other packlets.\"\n },\n schema: [\n {\n type: 'object',\n additionalProperties: false\n }\n ],\n docs: {\n description: 'Check that file paths and imports follow the basic mechanics for the packlet formalism',\n recommended: 'recommended',\n url: 'https://www.npmjs.com/package/@rushstack/eslint-plugin-packlets'\n } as TSESLint.RuleMetaDataDocs\n },\n\n create: (context: TSESLint.RuleContext<MessageIds, Options>) => {\n // Example: /path/to/my-project/src/packlets/my-packlet/index.ts\n const inputFilePath: string = context.getFilename();\n\n // Example: /path/to/my-project/tsconfig.json\n const tsconfigFilePath: string | undefined = ESLintUtils.getParserServices(\n context\n ).program.getCompilerOptions().configFilePath as string;\n\n const packletAnalyzer: PackletAnalyzer = PackletAnalyzer.analyzeInputFile(\n inputFilePath,\n tsconfigFilePath\n );\n if (packletAnalyzer.nothingToDo) {\n return {};\n }\n\n return {\n // Match the first node in the source file. Ideally we should be matching \"Program > :first-child\"\n // so a warning doesn't highlight the whole file. But that's blocked behind a bug in the query selector:\n // https://github.com/estools/esquery/issues/114\n Program: (node: TSESTree.Node): void => {\n if (packletAnalyzer.error) {\n context.report({\n node: node,\n messageId: packletAnalyzer.error.messageId,\n data: packletAnalyzer.error.data\n });\n }\n },\n\n // ImportDeclaration matches these forms:\n // import { X } from '../../packlets/other-packlet';\n // import X from '../../packlets/other-packlet';\n // import type { X, Y } from '../../packlets/other-packlet';\n // import * as X from '../../packlets/other-packlet';\n //\n // ExportNamedDeclaration matches these forms:\n // export { X } from '../../packlets/other-packlet';\n //\n // ExportAllDeclaration matches these forms:\n // export * from '../../packlets/other-packlet';\n // export * as X from '../../packlets/other-packlet';\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 'ImportDeclaration, ExportNamedDeclaration, ExportAllDeclaration': (\n node: TSESTree.ImportDeclaration | TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration\n ): void => {\n if (node.source?.type === AST_NODE_TYPES.Literal) {\n if (packletAnalyzer.projectUsesPacklets) {\n // Extract the import/export module path\n // Example: \"../../packlets/other-packlet\"\n const modulePath: string = node.source.value;\n if (typeof modulePath !== 'string') {\n return;\n }\n\n if (!(modulePath.startsWith('.') || modulePath.startsWith('..'))) {\n // It's not a local import.\n\n // Examples:\n // import { X } from \"npm-package\";\n // import { X } from \"raw-loader!./webpack-file.ts\";\n return;\n }\n\n const lint: IAnalyzerError | undefined = packletAnalyzer.analyzeImport(modulePath);\n if (lint) {\n context.report({\n node: node,\n messageId: lint.messageId,\n data: lint.data\n });\n }\n }\n }\n }\n };\n }\n};\n\nexport { mechanics };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/eslint-plugin-packlets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A lightweight alternative to NPM packages for organizing source files within a single project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,24 +18,18 @@
|
|
|
18
18
|
"main": "lib/index.js",
|
|
19
19
|
"typings": "lib/index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@typescript-eslint/utils": "~8.
|
|
21
|
+
"@typescript-eslint/utils": "~8.31.0",
|
|
22
22
|
"@rushstack/tree-pattern": "0.3.4"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
25
|
+
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@rushstack/heft": "0.
|
|
29
|
-
"@
|
|
30
|
-
"@types/eslint": "8.56.10",
|
|
31
|
-
"@types/estree": "1.0.5",
|
|
32
|
-
"@types/heft-jest": "1.0.1",
|
|
33
|
-
"@types/node": "20.17.19",
|
|
34
|
-
"@typescript-eslint/parser": "~8.24.0",
|
|
35
|
-
"@typescript-eslint/typescript-estree": "~8.24.0",
|
|
28
|
+
"@rushstack/heft": "0.73.2",
|
|
29
|
+
"@typescript-eslint/parser": "~8.31.0",
|
|
36
30
|
"eslint": "~8.57.0",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
31
|
+
"typescript": "~5.8.2",
|
|
32
|
+
"decoupled-local-node-rig": "1.0.0"
|
|
39
33
|
},
|
|
40
34
|
"scripts": {
|
|
41
35
|
"build": "heft build --clean",
|