From a7d5c8f72218a33473028d65951b8b7d401ae97b Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Thu, 18 Dec 2025 17:34:54 -0800 Subject: [PATCH 1/2] Introduce a rule that forbids 'export * from ...' syntax in local projects. --- .../default/includes/eslint/flat/profile/_common.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rigs/decoupled-local-node-rig/profiles/default/includes/eslint/flat/profile/_common.js b/rigs/decoupled-local-node-rig/profiles/default/includes/eslint/flat/profile/_common.js index 144f059891..5b84938c9a 100644 --- a/rigs/decoupled-local-node-rig/profiles/default/includes/eslint/flat/profile/_common.js +++ b/rigs/decoupled-local-node-rig/profiles/default/includes/eslint/flat/profile/_common.js @@ -171,7 +171,16 @@ module.exports = { } ], - 'import/no-duplicates': 'warn' + 'import/no-duplicates': 'warn', + + 'no-restricted-syntax': [ + 'error', + { + // Forbid only bare `export * from '...'` + selector: 'ExportAllDeclaration[exported=null]', + message: "Use explicit named exports instead of `export * from '...'`." + } + ] } }, { From aa29e27ce58e89fe97431bb0536f36413a3d9784 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Thu, 18 Dec 2025 18:25:43 -0800 Subject: [PATCH 2/2] Fix exports. --- .../src/packlets/lfx-shared/index.ts | 21 +++++++++--- apps/rush-mcp-server/src/index.ts | 6 ++-- apps/rush-mcp-server/src/tools/index.ts | 12 +++---- .../src/index.ts | 1 + build-tests/api-documenter-test/src/index.ts | 2 ++ .../forbid-export-star_2025-12-19-02-25.json | 11 ++++++ .../forbid-export-star_2025-12-19-02-25.json | 11 ++++++ .../forbid-export-star_2025-12-19-02-25.json | 11 ++++++ .../forbid-export-star_2025-12-19-02-25.json | 11 ++++++ .../forbid-export-star_2025-12-19-02-25.json | 11 ++++++ .../forbid-export-star_2025-12-19-02-25.json | 11 ++++++ libraries/rush-themed-ui/src/index.ts | 12 +++---- libraries/stream-collator/src/index.ts | 6 ++-- libraries/tree-pattern/src/index.ts | 2 +- .../src/index.ts | 8 ++++- .../src/index.ts | 34 +++++++++++++++---- .../src/index.ts | 13 +++++-- 17 files changed, 150 insertions(+), 33 deletions(-) create mode 100644 common/changes/@rushstack/mcp-server/forbid-export-star_2025-12-19-02-25.json create mode 100644 common/changes/@rushstack/stream-collator/forbid-export-star_2025-12-19-02-25.json create mode 100644 common/changes/@rushstack/tree-pattern/forbid-export-star_2025-12-19-02-25.json create mode 100644 common/changes/@rushstack/webpack-embedded-dependencies-plugin/forbid-export-star_2025-12-19-02-25.json create mode 100644 common/changes/@rushstack/webpack4-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json create mode 100644 common/changes/@rushstack/webpack5-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json diff --git a/apps/lockfile-explorer-web/src/packlets/lfx-shared/index.ts b/apps/lockfile-explorer-web/src/packlets/lfx-shared/index.ts index c060ea5e6b..8b56a5e616 100644 --- a/apps/lockfile-explorer-web/src/packlets/lfx-shared/index.ts +++ b/apps/lockfile-explorer-web/src/packlets/lfx-shared/index.ts @@ -1,8 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -export * from './IAppContext'; -export * from './IJsonLfxGraph'; -export * from './IJsonLfxWorkspace'; -export * from './LfxGraph'; +export type { IAppContext } from './IAppContext'; +export { + LfxGraphEntryKind, + LfxDependencyKind, + type IJsonPeerDependencyMeta, + type IJsonLfxDependency, + type IJsonLfxEntry, + type IJsonLfxGraph +} from './IJsonLfxGraph'; +export type { IJsonLfxWorkspaceRushConfig, IJsonLfxWorkspace } from './IJsonLfxWorkspace'; +export { + LfxGraph, + LfxGraphDependency, + LfxGraphEntry, + type ILfxGraphDependencyOptions, + type ILfxGraphEntryOptions +} from './LfxGraph'; export * as lfxGraphSerializer from './lfxGraphSerializer'; diff --git a/apps/rush-mcp-server/src/index.ts b/apps/rush-mcp-server/src/index.ts index 20b52112e7..fb2982cfe0 100644 --- a/apps/rush-mcp-server/src/index.ts +++ b/apps/rush-mcp-server/src/index.ts @@ -6,7 +6,7 @@ * @packageDocumentation */ -export * from './pluginFramework/IRushMcpPlugin'; -export * from './pluginFramework/IRushMcpTool'; +export { type IRushMcpPlugin, type RushMcpPluginFactory } from './pluginFramework/IRushMcpPlugin'; +export type { IRushMcpTool } from './pluginFramework/IRushMcpTool'; export { type IRegisterToolOptions, RushMcpPluginSession } from './pluginFramework/RushMcpPluginSession'; -export * from './pluginFramework/zodTypes'; +export { CallToolResultSchema, type CallToolResult, type zodModule } from './pluginFramework/zodTypes'; diff --git a/apps/rush-mcp-server/src/tools/index.ts b/apps/rush-mcp-server/src/tools/index.ts index b0c15c01ee..7fdc2dbd2b 100644 --- a/apps/rush-mcp-server/src/tools/index.ts +++ b/apps/rush-mcp-server/src/tools/index.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -export * from './base.tool'; -export * from './migrate-project.tool'; -export * from './project-details.tool'; -export * from './rush-command-validator.tool'; -export * from './workspace-details'; -export * from './conflict-resolver.tool'; +export { BaseTool, type IBaseToolOptions, type CallToolResult } from './base.tool'; +export { RushMigrateProjectTool } from './migrate-project.tool'; +export { RushProjectDetailsTool } from './project-details.tool'; +export { RushCommandValidatorTool } from './rush-command-validator.tool'; +export { RushWorkspaceDetailsTool } from './workspace-details'; +export { RushConflictResolverTool } from './conflict-resolver.tool'; diff --git a/build-tests-samples/heft-web-rig-library-tutorial/src/index.ts b/build-tests-samples/heft-web-rig-library-tutorial/src/index.ts index ca9ecd1e11..1976762f2c 100644 --- a/build-tests-samples/heft-web-rig-library-tutorial/src/index.ts +++ b/build-tests-samples/heft-web-rig-library-tutorial/src/index.ts @@ -1,4 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. +// eslint-disable-next-line no-restricted-syntax export * from './ToggleSwitch'; diff --git a/build-tests/api-documenter-test/src/index.ts b/build-tests/api-documenter-test/src/index.ts index 710adc3c39..b4a1fefa50 100644 --- a/build-tests/api-documenter-test/src/index.ts +++ b/build-tests/api-documenter-test/src/index.ts @@ -10,7 +10,9 @@ * @packageDocumentation */ +// eslint-disable-next-line no-restricted-syntax export * from './DocClass1'; +// eslint-disable-next-line no-restricted-syntax export * from './DocEnums'; import type { IDocInterface1, IDocInterface3, SystemEvent } from './DocClass1'; diff --git a/common/changes/@rushstack/mcp-server/forbid-export-star_2025-12-19-02-25.json b/common/changes/@rushstack/mcp-server/forbid-export-star_2025-12-19-02-25.json new file mode 100644 index 0000000000..df2697e982 --- /dev/null +++ b/common/changes/@rushstack/mcp-server/forbid-export-star_2025-12-19-02-25.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "type": "none", + "packageName": "@rushstack/mcp-server" + } + ], + "packageName": "@rushstack/mcp-server", + "email": "iclanton@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/changes/@rushstack/stream-collator/forbid-export-star_2025-12-19-02-25.json b/common/changes/@rushstack/stream-collator/forbid-export-star_2025-12-19-02-25.json new file mode 100644 index 0000000000..ac72fbf9f9 --- /dev/null +++ b/common/changes/@rushstack/stream-collator/forbid-export-star_2025-12-19-02-25.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "type": "none", + "packageName": "@rushstack/stream-collator" + } + ], + "packageName": "@rushstack/stream-collator", + "email": "iclanton@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/changes/@rushstack/tree-pattern/forbid-export-star_2025-12-19-02-25.json b/common/changes/@rushstack/tree-pattern/forbid-export-star_2025-12-19-02-25.json new file mode 100644 index 0000000000..619a10c75e --- /dev/null +++ b/common/changes/@rushstack/tree-pattern/forbid-export-star_2025-12-19-02-25.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "type": "none", + "packageName": "@rushstack/tree-pattern" + } + ], + "packageName": "@rushstack/tree-pattern", + "email": "iclanton@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/changes/@rushstack/webpack-embedded-dependencies-plugin/forbid-export-star_2025-12-19-02-25.json b/common/changes/@rushstack/webpack-embedded-dependencies-plugin/forbid-export-star_2025-12-19-02-25.json new file mode 100644 index 0000000000..908583cfa6 --- /dev/null +++ b/common/changes/@rushstack/webpack-embedded-dependencies-plugin/forbid-export-star_2025-12-19-02-25.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "type": "none", + "packageName": "@rushstack/webpack-embedded-dependencies-plugin" + } + ], + "packageName": "@rushstack/webpack-embedded-dependencies-plugin", + "email": "iclanton@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/changes/@rushstack/webpack4-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json b/common/changes/@rushstack/webpack4-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json new file mode 100644 index 0000000000..5197fc2ef2 --- /dev/null +++ b/common/changes/@rushstack/webpack4-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "type": "none", + "packageName": "@rushstack/webpack4-module-minifier-plugin" + } + ], + "packageName": "@rushstack/webpack4-module-minifier-plugin", + "email": "iclanton@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/changes/@rushstack/webpack5-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json b/common/changes/@rushstack/webpack5-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json new file mode 100644 index 0000000000..150960dd0a --- /dev/null +++ b/common/changes/@rushstack/webpack5-module-minifier-plugin/forbid-export-star_2025-12-19-02-25.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "type": "none", + "packageName": "@rushstack/webpack5-module-minifier-plugin" + } + ], + "packageName": "@rushstack/webpack5-module-minifier-plugin", + "email": "iclanton@users.noreply.github.com" +} \ No newline at end of file diff --git a/libraries/rush-themed-ui/src/index.ts b/libraries/rush-themed-ui/src/index.ts index 03f9ce0a00..04e5ba7746 100644 --- a/libraries/rush-themed-ui/src/index.ts +++ b/libraries/rush-themed-ui/src/index.ts @@ -13,9 +13,9 @@ * @packageDocumentation */ -export * from './components/Button'; -export * from './components/ScrollArea'; -export * from './components/Tabs'; -export * from './components/Checkbox'; -export * from './components/Input'; -export * from './components/Text'; +export { Button, type IButtonProps } from './components/Button'; +export { ScrollArea, type IScrollAreaProps } from './components/ScrollArea'; +export { Tabs, type ITabsItem, type ITabsProps } from './components/Tabs'; +export { Checkbox, type ICheckboxProps } from './components/Checkbox'; +export { Input, type IInputProps } from './components/Input'; +export { Text, type TextType, type ITextProps } from './components/Text'; diff --git a/libraries/stream-collator/src/index.ts b/libraries/stream-collator/src/index.ts index fb5effe5f8..7f898a2070 100644 --- a/libraries/stream-collator/src/index.ts +++ b/libraries/stream-collator/src/index.ts @@ -13,6 +13,6 @@ * @packageDocumentation */ -export * from './CollatedTerminal'; -export * from './CollatedWriter'; -export * from './StreamCollator'; +export { CollatedTerminal } from './CollatedTerminal'; +export { CollatedWriter } from './CollatedWriter'; +export { StreamCollator, type IStreamCollatorOptions } from './StreamCollator'; diff --git a/libraries/tree-pattern/src/index.ts b/libraries/tree-pattern/src/index.ts index 98e8b9b096..cdb533e6f6 100644 --- a/libraries/tree-pattern/src/index.ts +++ b/libraries/tree-pattern/src/index.ts @@ -7,4 +7,4 @@ * @packageDocumentation */ -export * from './TreePattern'; +export { type TreeNode, type ITreePatternCaptureSet, TreePattern } from './TreePattern'; diff --git a/webpack/webpack-embedded-dependencies-plugin/src/index.ts b/webpack/webpack-embedded-dependencies-plugin/src/index.ts index db7fe20598..6cf3480480 100644 --- a/webpack/webpack-embedded-dependencies-plugin/src/index.ts +++ b/webpack/webpack-embedded-dependencies-plugin/src/index.ts @@ -14,6 +14,12 @@ */ import EmbeddedDependenciesWebpackPlugin from './EmbeddedDependenciesWebpackPlugin'; -export * from './EmbeddedDependenciesWebpackPlugin'; + +export type { + IPackageData, + IEmbeddedDependenciesWebpackPluginOptions, + LicenseFileGeneratorFunction, + LicenseFileName +} from './EmbeddedDependenciesWebpackPlugin'; export default EmbeddedDependenciesWebpackPlugin; diff --git a/webpack/webpack4-module-minifier-plugin/src/index.ts b/webpack/webpack4-module-minifier-plugin/src/index.ts index 6c8c7a691c..fbf2a2964e 100644 --- a/webpack/webpack4-module-minifier-plugin/src/index.ts +++ b/webpack/webpack4-module-minifier-plugin/src/index.ts @@ -1,12 +1,34 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -export * from './Constants'; -export * from './GenerateLicenseFileForAsset'; -export * from './ModuleMinifierPlugin.types'; -export * from './ModuleMinifierPlugin'; -export * from './PortableMinifierIdsPlugin'; -export * from './RehydrateAsset'; +export { + MODULE_WRAPPER_PREFIX, + MODULE_WRAPPER_SUFFIX, + CHUNK_MODULES_TOKEN, + STAGE_BEFORE, + STAGE_AFTER +} from './Constants'; +export { generateLicenseFileForAsset } from './GenerateLicenseFileForAsset'; +export type { + IRenderedModulePosition, + IAssetInfo, + IModuleMinifierPluginStats, + IAssetStats, + IModuleInfo, + IExtendedModule, + _IWebpackCompilationData, + _INormalModuleFactoryModuleData, + IAssetMap, + IModuleMap, + IModuleMinifierPluginOptions, + IDehydratedAssets, + IPostProcessFragmentContext, + IModuleMinifierPluginHooks, + _IAcornComment +} from './ModuleMinifierPlugin.types'; +export { ModuleMinifierPlugin } from './ModuleMinifierPlugin'; +export { PortableMinifierModuleIdsPlugin } from './PortableMinifierIdsPlugin'; +export { rehydrateAsset } from './RehydrateAsset'; export type { ILocalMinifierOptions, IMinifierConnection, diff --git a/webpack/webpack5-module-minifier-plugin/src/index.ts b/webpack/webpack5-module-minifier-plugin/src/index.ts index 38762c61f7..70231dbbe8 100644 --- a/webpack/webpack5-module-minifier-plugin/src/index.ts +++ b/webpack/webpack5-module-minifier-plugin/src/index.ts @@ -1,8 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -export * from './Constants'; -export * from './GenerateLicenseFileForAsset'; +export { + MODULE_WRAPPER_PREFIX, + MODULE_WRAPPER_SUFFIX, + CHUNK_MODULE_TOKEN, + CHUNK_MODULE_REGEX, + STAGE_BEFORE, + STAGE_AFTER +} from './Constants'; +export { generateLicenseFileForAsset } from './GenerateLicenseFileForAsset'; export type { IAssetInfo, IAssetMap, @@ -18,4 +25,4 @@ export type { IPostProcessFragmentContext, IRenderedModulePosition } from './ModuleMinifierPlugin.types'; -export * from './ModuleMinifierPlugin'; +export { ModuleMinifierPlugin } from './ModuleMinifierPlugin';