Skip to content

Commit aa7aacf

Browse files
committed
Fix ESlint errors.
1 parent 1ea4dc0 commit aa7aacf

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

apps/rush-lib/src/api/CommandLineConfiguration.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,38 @@ export class CommandLineConfiguration {
2828
public readonly commands: CommandJson[] = [];
2929
public readonly parameters: ParameterJson[] = [];
3030

31+
/**
32+
* Use CommandLineConfiguration.loadFromFile()
33+
*/
34+
private constructor(commandLineJson: ICommandLineJson | undefined) {
35+
if (commandLineJson) {
36+
if (commandLineJson.commands) {
37+
for (const command of commandLineJson.commands) {
38+
this.commands.push(command);
39+
}
40+
}
41+
42+
if (commandLineJson.parameters) {
43+
for (const parameter of commandLineJson.parameters) {
44+
this.parameters.push(parameter);
45+
46+
// Do some basic validation
47+
switch (parameter.parameterKind) {
48+
case 'choice':
49+
const alternativeNames: string[] = parameter.alternatives.map(x => x.name);
50+
51+
if (parameter.defaultValue && alternativeNames.indexOf(parameter.defaultValue) < 0) {
52+
throw new Error(`In ${RushConstants.commandLineFilename}, the parameter "${parameter.longName}",`
53+
+ ` specifies a default value "${parameter.defaultValue}"`
54+
+ ` which is not one of the defined alternatives: "${alternativeNames.toString()}"`);
55+
}
56+
break;
57+
}
58+
}
59+
}
60+
}
61+
}
62+
3163
/**
3264
* Loads the configuration from the specified file and applies any ommited default build
3365
* settings. If the file does not exist, then an empty default instance is returned.
@@ -88,36 +120,4 @@ export class CommandLineConfiguration {
88120

89121
return new CommandLineConfiguration(commandLineJson);
90122
}
91-
92-
/**
93-
* Use CommandLineConfiguration.loadFromFile()
94-
*/
95-
private constructor(commandLineJson: ICommandLineJson | undefined) {
96-
if (commandLineJson) {
97-
if (commandLineJson.commands) {
98-
for (const command of commandLineJson.commands) {
99-
this.commands.push(command);
100-
}
101-
}
102-
103-
if (commandLineJson.parameters) {
104-
for (const parameter of commandLineJson.parameters) {
105-
this.parameters.push(parameter);
106-
107-
// Do some basic validation
108-
switch (parameter.parameterKind) {
109-
case 'choice':
110-
const alternativeNames: string[] = parameter.alternatives.map(x => x.name);
111-
112-
if (parameter.defaultValue && alternativeNames.indexOf(parameter.defaultValue) < 0) {
113-
throw new Error(`In ${RushConstants.commandLineFilename}, the parameter "${parameter.longName}",`
114-
+ ` specifies a default value "${parameter.defaultValue}"`
115-
+ ` which is not one of the defined alternatives: "${alternativeNames.toString()}"`);
116-
}
117-
break;
118-
}
119-
}
120-
}
121-
}
122-
}
123123
}

apps/rush-lib/src/cli/test/RushCommandLineParser.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ describe('RushCommandLineParser', () => {
232232
// Use regex for task name in case spaces were prepended or appended to spawned command
233233
const expectedBuildTaskRegexp: RegExp = /fake_build_task_but_works_with_mock/;
234234

235-
// tslint:disable-next-line: no-any
235+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
236236
const firstSpawn: any[] = instance.spawnMock.mock.calls[0];
237237
expect(firstSpawn[SPAWN_ARG_ARGS]).toEqual(expect.arrayContaining([
238238
expect.stringMatching(expectedBuildTaskRegexp)
239239
]));
240240
expect(firstSpawn[SPAWN_ARG_OPTIONS]).toEqual(expect.any(Object));
241241
expect(firstSpawn[SPAWN_ARG_OPTIONS].cwd).toEqual(path.resolve(__dirname, `${repoName}/a`));
242242

243-
// tslint:disable-next-line: no-any
243+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
244244
const secondSpawn: any[] = instance.spawnMock.mock.calls[1];
245245
expect(secondSpawn[SPAWN_ARG_ARGS]).toEqual(expect.arrayContaining([
246246
expect.stringMatching(expectedBuildTaskRegexp)
@@ -265,15 +265,15 @@ describe('RushCommandLineParser', () => {
265265
// Use regex for task name in case spaces were prepended or appended to spawned command
266266
const expectedBuildTaskRegexp: RegExp = /fake_REbuild_task_but_works_with_mock/;
267267

268-
// tslint:disable-next-line: no-any
268+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
269269
const firstSpawn: any[] = instance.spawnMock.mock.calls[0];
270270
expect(firstSpawn[SPAWN_ARG_ARGS]).toEqual(expect.arrayContaining([
271271
expect.stringMatching(expectedBuildTaskRegexp)
272272
]));
273273
expect(firstSpawn[SPAWN_ARG_OPTIONS]).toEqual(expect.any(Object));
274274
expect(firstSpawn[SPAWN_ARG_OPTIONS].cwd).toEqual(path.resolve(__dirname, `${repoName}/a`));
275275

276-
// tslint:disable-next-line: no-any
276+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
277277
const secondSpawn: any[] = instance.spawnMock.mock.calls[1];
278278
expect(secondSpawn[SPAWN_ARG_ARGS]).toEqual(expect.arrayContaining([
279279
expect.stringMatching(expectedBuildTaskRegexp)

0 commit comments

Comments
 (0)