Skip to content

Commit f7eebd6

Browse files
Copiloticlanton
andauthored
Refactor repeated object property access to destructuring across repo (#5747)
* refactor: destructure repeated object property references in rush-plugin constructors Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/d16ff30b-dbf7-4053-9480-28378c1626b8 Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> * refactor: destructure repeated object property references across repo Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/69ee967b-8010-4fce-9002-5746b3573f14 Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> * chore: add rush change files (bump-type none) Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/cbc09497-8eb2-4b35-a252-1cb371b05810 Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
1 parent 981ef14 commit f7eebd6

File tree

36 files changed

+436
-211
lines changed

36 files changed

+436
-211
lines changed

apps/api-extractor/src/analyzer/AstSymbol.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,20 @@ export class AstSymbol extends AstEntity {
117117
public constructor(options: IAstSymbolOptions) {
118118
super();
119119

120-
this.followedSymbol = options.followedSymbol;
121-
this.localName = options.localName;
122-
this.isExternal = options.isExternal;
123-
this.nominalAnalysis = options.nominalAnalysis;
124-
this.parentAstSymbol = options.parentAstSymbol;
125-
this.rootAstSymbol = options.rootAstSymbol || this;
120+
const {
121+
followedSymbol,
122+
localName,
123+
isExternal,
124+
nominalAnalysis,
125+
parentAstSymbol,
126+
rootAstSymbol = this
127+
} = options;
128+
this.followedSymbol = followedSymbol;
129+
this.localName = localName;
130+
this.isExternal = isExternal;
131+
this.nominalAnalysis = nominalAnalysis;
132+
this.parentAstSymbol = parentAstSymbol;
133+
this.rootAstSymbol = rootAstSymbol;
126134
this._astDeclarations = [];
127135
}
128136

apps/api-extractor/src/api/Extractor.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ export class ExtractorResult {
153153

154154
/** @internal */
155155
public constructor(properties: ExtractorResult) {
156-
this.compilerState = properties.compilerState;
157-
this.extractorConfig = properties.extractorConfig;
158-
this.succeeded = properties.succeeded;
159-
this.apiReportChanged = properties.apiReportChanged;
160-
this.errorCount = properties.errorCount;
161-
this.warningCount = properties.warningCount;
156+
const { compilerState, extractorConfig, succeeded, apiReportChanged, errorCount, warningCount } =
157+
properties;
158+
this.compilerState = compilerState;
159+
this.extractorConfig = extractorConfig;
160+
this.succeeded = succeeded;
161+
this.apiReportChanged = apiReportChanged;
162+
this.errorCount = errorCount;
163+
this.warningCount = warningCount;
162164
}
163165
}
164166

apps/api-extractor/src/api/ExtractorMessage.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,26 @@ export class ExtractorMessage {
132132

133133
/** @internal */
134134
public constructor(options: IExtractorMessageOptions) {
135-
this.category = options.category;
136-
this.messageId = options.messageId;
137-
this.text = options.text;
138-
this.sourceFilePath = options.sourceFilePath;
139-
this.sourceFileLine = options.sourceFileLine;
140-
this.sourceFileColumn = options.sourceFileColumn;
141-
this.properties = options.properties || {};
135+
const {
136+
category,
137+
messageId,
138+
text,
139+
sourceFilePath,
140+
sourceFileLine,
141+
sourceFileColumn,
142+
properties = {},
143+
logLevel = ExtractorLogLevel.None
144+
} = options;
145+
this.category = category;
146+
this.messageId = messageId;
147+
this.text = text;
148+
this.sourceFilePath = sourceFilePath;
149+
this.sourceFileLine = sourceFileLine;
150+
this.sourceFileColumn = sourceFileColumn;
151+
this.properties = properties;
142152

143153
this._handled = false;
144-
this._logLevel = options.logLevel || ExtractorLogLevel.None;
154+
this._logLevel = logLevel;
145155
}
146156

147157
/**

apps/api-extractor/src/collector/ApiItemMetadata.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,23 @@ export class ApiItemMetadata {
9494
public docCommentEnhancerVisitorState: VisitorState = VisitorState.Unvisited;
9595

9696
public constructor(options: IApiItemMetadataOptions) {
97-
this.declaredReleaseTag = options.declaredReleaseTag;
98-
this.effectiveReleaseTag = options.effectiveReleaseTag;
99-
this.releaseTagSameAsParent = options.releaseTagSameAsParent;
100-
this.isEventProperty = options.isEventProperty;
101-
this.isOverride = options.isOverride;
102-
this.isSealed = options.isSealed;
103-
this.isVirtual = options.isVirtual;
104-
this.isPreapproved = options.isPreapproved;
97+
const {
98+
declaredReleaseTag,
99+
effectiveReleaseTag,
100+
releaseTagSameAsParent,
101+
isEventProperty,
102+
isOverride,
103+
isSealed,
104+
isVirtual,
105+
isPreapproved
106+
} = options;
107+
this.declaredReleaseTag = declaredReleaseTag;
108+
this.effectiveReleaseTag = effectiveReleaseTag;
109+
this.releaseTagSameAsParent = releaseTagSameAsParent;
110+
this.isEventProperty = isEventProperty;
111+
this.isOverride = isOverride;
112+
this.isSealed = isSealed;
113+
this.isVirtual = isVirtual;
114+
this.isPreapproved = isPreapproved;
105115
}
106116
}

apps/api-extractor/src/collector/Collector.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ export class Collector {
107107
public constructor(options: ICollectorOptions) {
108108
this.packageJsonLookup = new PackageJsonLookup();
109109

110-
this._program = options.program;
111-
this.extractorConfig = options.extractorConfig;
112-
this.sourceMapper = options.sourceMapper;
110+
const { program, extractorConfig, sourceMapper, messageRouter } = options;
111+
this._program = program;
112+
this.extractorConfig = extractorConfig;
113+
this.sourceMapper = sourceMapper;
113114

114-
const entryPointSourceFile: ts.SourceFile | undefined = options.program.getSourceFile(
115+
const entryPointSourceFile: ts.SourceFile | undefined = program.getSourceFile(
115116
this.extractorConfig.mainEntryPointFilePath
116117
);
117118

@@ -131,10 +132,10 @@ export class Collector {
131132
entryPointSourceFile
132133
});
133134

134-
this.messageRouter = options.messageRouter;
135+
this.messageRouter = messageRouter;
135136

136-
this.program = options.program;
137-
this.typeChecker = options.program.getTypeChecker();
137+
this.program = program;
138+
this.typeChecker = program.getTypeChecker();
138139
this.globalVariableAnalyzer = TypeScriptInternals.getGlobalVariableAnalyzer(this.program);
139140

140141
this._tsdocParser = new tsdoc.TSDocParser(this.extractorConfig.tsdocConfiguration);

apps/api-extractor/src/collector/MessageRouter.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,28 @@ export class MessageRouter {
8686
public readonly showDiagnostics: boolean;
8787

8888
public constructor(options: IMessageRouterOptions) {
89-
this._workingPackageFolder = options.workingPackageFolder;
90-
this._messageCallback = options.messageCallback;
89+
const {
90+
workingPackageFolder,
91+
messageCallback,
92+
sourceMapper,
93+
tsdocConfiguration,
94+
showVerboseMessages,
95+
showDiagnostics,
96+
messagesConfig
97+
} = options;
98+
this._workingPackageFolder = workingPackageFolder;
99+
this._messageCallback = messageCallback;
91100

92101
this._messages = [];
93102
this._associatedMessagesForAstDeclaration = new Map<AstDeclaration, ExtractorMessage[]>();
94-
this._sourceMapper = options.sourceMapper;
95-
this._tsdocConfiguration = options.tsdocConfiguration;
103+
this._sourceMapper = sourceMapper;
104+
this._tsdocConfiguration = tsdocConfiguration;
96105

97106
// showDiagnostics implies showVerboseMessages
98-
this.showVerboseMessages = options.showVerboseMessages || options.showDiagnostics;
99-
this.showDiagnostics = options.showDiagnostics;
107+
this.showVerboseMessages = showVerboseMessages || showDiagnostics;
108+
this.showDiagnostics = showDiagnostics;
100109

101-
this._applyMessagesConfig(options.messagesConfig);
110+
this._applyMessagesConfig(messagesConfig);
102111
}
103112

104113
/**

apps/heft/src/cli/actions/PhaseAction.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ export class PhaseAction extends CommandLineAction implements IHeftAction {
2020
private _selectedPhases: Set<HeftPhase> | undefined;
2121

2222
public constructor(options: IPhaseActionOptions) {
23+
const { phase, watch = false } = options;
24+
const { phaseName, phaseDescription } = phase;
2325
super({
24-
actionName: `${options.phase.phaseName}${options.watch ? '-watch' : ''}`,
26+
actionName: `${phaseName}${watch ? '-watch' : ''}`,
2527
documentation:
26-
`Runs to the ${options.phase.phaseName} phase, including all transitive dependencies` +
27-
(options.watch ? ', in watch mode.' : '.') +
28-
(options.phase.phaseDescription ? ` ${options.phase.phaseDescription}` : ''),
28+
`Runs to the ${phaseName} phase, including all transitive dependencies` +
29+
(watch ? ', in watch mode.' : '.') +
30+
(phaseDescription ? ` ${phaseDescription}` : ''),
2931
summary:
30-
`Runs to the ${options.phase.phaseName} phase, including all transitive dependencies` +
31-
(options.watch ? ', in watch mode.' : '.')
32+
`Runs to the ${phaseName} phase, including all transitive dependencies` +
33+
(watch ? ', in watch mode.' : '.')
3234
});
3335

34-
this.watch = options.watch ?? false;
35-
this._phase = options.phase;
36+
this.watch = watch;
37+
this._phase = phase;
3638
this._actionRunner = new HeftActionRunner({ action: this, ...options });
3739
this._actionRunner.defineParameters();
3840
}

apps/heft/src/pluginFramework/HeftLifecycleSession.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,22 @@ export class HeftLifecycleSession implements IHeftLifecycleSession {
230230

231231
public constructor(options: IHeftLifecycleSessionOptions) {
232232
this._options = options;
233-
this.logger = options.logger;
234-
this.metricsCollector = options.metricsCollector;
235-
this.hooks = options.lifecycleHooks;
236-
this.parameters = options.lifecycleParameters;
237-
this.debug = options.debug;
233+
const { logger, metricsCollector, lifecycleHooks, lifecycleParameters, debug, pluginDefinition, heftConfiguration, pluginHost } =
234+
options;
235+
this.logger = logger;
236+
this.metricsCollector = metricsCollector;
237+
this.hooks = lifecycleHooks;
238+
this.parameters = lifecycleParameters;
239+
this.debug = debug;
238240

239241
// Guranteed to be unique since phases are forbidden from using the name 'lifecycle'
240242
// and lifecycle plugin names are enforced to be unique.
241-
const uniquePluginFolderName: string = `lifecycle.${options.pluginDefinition.pluginName}`;
243+
const uniquePluginFolderName: string = `lifecycle.${pluginDefinition.pluginName}`;
242244

243245
// <projectFolder>/temp/<phaseName>.<taskName>
244-
this.tempFolderPath = path.join(options.heftConfiguration.tempFolderPath, uniquePluginFolderName);
246+
this.tempFolderPath = path.join(heftConfiguration.tempFolderPath, uniquePluginFolderName);
245247

246-
this._pluginHost = options.pluginHost;
248+
this._pluginHost = pluginHost;
247249
}
248250

249251
public requestAccessToPluginByName<T extends object>(

apps/lockfile-explorer-web/src/packlets/lfx-shared/LfxGraph.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ export class LfxGraphDependency {
6767
public resolvedEntry: LfxGraphEntry | undefined = undefined;
6868

6969
public constructor(options: ILfxGraphDependencyOptions) {
70-
this.name = options.name;
71-
this.versionPath = options.versionPath;
72-
this.entryId = options.entryId;
73-
this.originalSpecifier = options.originalSpecifier;
74-
this.dependencyKind = options.dependencyKind;
75-
this.peerDependencyMeta = options.peerDependencyMeta;
76-
77-
this.containingEntry = options.containingEntry;
70+
const { name, versionPath, entryId, originalSpecifier, dependencyKind, peerDependencyMeta, containingEntry } =
71+
options;
72+
this.name = name;
73+
this.versionPath = versionPath;
74+
this.entryId = entryId;
75+
this.originalSpecifier = originalSpecifier;
76+
this.dependencyKind = dependencyKind;
77+
this.peerDependencyMeta = peerDependencyMeta;
78+
79+
this.containingEntry = containingEntry;
7880
}
7981
}
8082

@@ -154,14 +156,24 @@ export class LfxGraphEntry {
154156
public readonly referrers: LfxGraphEntry[] = [];
155157

156158
public constructor(options: ILfxGraphEntryOptions) {
157-
this.kind = options.kind;
158-
this.entryId = options.entryId;
159-
this.rawEntryId = options.rawEntryId;
160-
this.packageJsonFolderPath = options.packageJsonFolderPath;
161-
this.entryPackageName = options.entryPackageName;
162-
this.displayText = options.displayText;
163-
this.entryPackageVersion = options.entryPackageVersion;
164-
this.entrySuffix = options.entrySuffix;
159+
const {
160+
kind,
161+
entryId,
162+
rawEntryId,
163+
packageJsonFolderPath,
164+
entryPackageName,
165+
displayText,
166+
entryPackageVersion,
167+
entrySuffix
168+
} = options;
169+
this.kind = kind;
170+
this.entryId = entryId;
171+
this.rawEntryId = rawEntryId;
172+
this.packageJsonFolderPath = packageJsonFolderPath;
173+
this.entryPackageName = entryPackageName;
174+
this.displayText = displayText;
175+
this.entryPackageVersion = entryPackageVersion;
176+
this.entrySuffix = entrySuffix;
165177
}
166178
}
167179

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "",
5+
"type": "none",
6+
"packageName": "@microsoft/api-extractor-model"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor-model",
10+
"email": "198982749+Copilot@users.noreply.github.com"
11+
}

0 commit comments

Comments
 (0)