Skip to content

Commit dd92fa3

Browse files
authored
improvement(build-tools): address ESLint rule violations in build-tools (#26152)
These changes are in preparation for upgrading to eslint 9 in build-tools. ## Summary - Fix low-count ESLint violations across the build-tools workspace - Address issues from newly enabled ESLint rules without modifying the config ## Changes - Replace `.replace(/x/g, ...)` with `.replaceAll()` (unicorn/prefer-string-replace-all) - Change `import * as path` to `import path` (unicorn/import-style) - Remove useless `undefined` arguments (unicorn/no-useless-undefined) - Fix JSDoc `@param` names to match actual parameters (jsdoc/check-param-names) - Add inline disables for idiomatic usage patterns: - `async.mapLimit`, `semver.parse`, `sortJson.overwrite` (import-x/no-named-as-default-member) - `prompts` default export (import-x/no-named-as-default) - Remove unused eslint-disable directives for import-x/no-default-export - Change `@module` to `@packageDocumentation` for TSDoc compatibility (tsdoc/syntax)
1 parent 309cec9 commit dd92fa3

File tree

18 files changed

+21
-19
lines changed

18 files changed

+21
-19
lines changed

build-tools/packages/build-cli/src/BasePackageCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export abstract class PackageCommand<
151151
}
152152

153153
try {
154+
// eslint-disable-next-line import-x/no-named-as-default-member -- async.mapLimit is the idiomatic usage
154155
await async.mapLimit(packages, this.flags.concurrency, async (pkg: PackageWithKind) => {
155156
started += 1;
156157
updateStatus();

build-tools/packages/build-cli/src/codeCoverage/getCoverageMetrics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const extractCoverageMetrics = (
5656

5757
/**
5858
* Method that returns the coverage report for the build from the artifact.
59-
* @param baselineZip - zipped coverage files for the build
59+
* @param artifactZip - zipped coverage files for the build
6060
* @param logger - The logger to log messages.
6161
* @returns an map of coverage metrics for build containing packageName, lineCoverage and branchCoverage
6262
*/

build-tools/packages/build-cli/src/commands/bump/deps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { Flags } from "@oclif/core";
77
import chalk from "picocolors";
8+
// eslint-disable-next-line import-x/no-named-as-default -- prompts default export is the intended API
89
import prompts from "prompts";
910
import stripAnsi from "strip-ansi";
1011

build-tools/packages/build-cli/src/commands/check/policy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { strict as assert } from "node:assert";
77
import * as fs from "node:fs";
88
import { EOL as newline } from "node:os";
9-
import * as path from "node:path";
9+
import path from "node:path";
1010
import process from "node:process";
1111
import { Flags } from "@oclif/core";
1212

@@ -313,7 +313,7 @@ export class CheckPolicy extends BaseCommand<typeof CheckPolicy> {
313313
): Promise<void> {
314314
const { exclusions, gitRoot, pathRegex } = commandContext;
315315

316-
const filePath = path.join(gitRoot, inputPath).trim().replace(/\\/g, "/");
316+
const filePath = path.join(gitRoot, inputPath).trim().replaceAll("\\", "/");
317317
assert(path.isAbsolute(filePath) === true);
318318

319319
if (!pathRegex.test(inputPath) || !fs.existsSync(filePath)) {

build-tools/packages/build-cli/src/commands/generate/assertTags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ The format of the configuration is specified by the "AssertTaggingPackageConfig"
295295
if (comments.length > 0) {
296296
let originalErrorText = comments[0]
297297
.getText()
298-
.replace(/\/\*/g, "")
299-
.replace(/\*\//g, "")
298+
.replaceAll("/*", "")
299+
.replaceAll("*/", "")
300300
.trim();
301301

302302
// Replace leading+trailing double quotes and backticks.

build-tools/packages/build-cli/src/commands/generate/changeset.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Flags, ux } from "@oclif/core";
1111
import { PackageName } from "@rushstack/node-core-library";
1212
import { humanId } from "human-id";
1313
import chalk from "picocolors";
14+
// eslint-disable-next-line import-x/no-named-as-default -- prompts default export is the intended API
1415
import prompts from "prompts";
1516

1617
import { releaseGroupFlag } from "../../flags.js";

build-tools/packages/build-cli/src/commands/generate/typetests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ function getNodeTypeData(node: Node, log: Logger, exportedName: string): TypeDat
432432
tags: getTags(docs),
433433
};
434434

435-
const escapedTypeName = exportedName.replace(/\./g, "_");
436-
const trimmedKind = node.getKindName().replace(/Declaration/g, "");
435+
const escapedTypeName = exportedName.replaceAll(".", "_");
436+
const trimmedKind = node.getKindName().replaceAll("Declaration", "");
437437

438438
if (
439439
// Covers instance type of the class (including generics of it)

build-tools/packages/build-cli/src/commands/release/fromTag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default class FromTagCommand extends ReleaseReportBaseCommand<typeof From
127127
const tag = input.startsWith(tagRefPrefix) ? input.slice(tagRefPrefix.length) : input;
128128
const [rg, ver] = tag.split("_v");
129129

130+
// eslint-disable-next-line import-x/no-named-as-default-member -- semver.parse is the idiomatic usage
130131
const version = semver.parse(ver);
131132
if (version === null) {
132133
throw new Error(`Invalid version parsed from tag: ${ver}`);

build-tools/packages/build-cli/src/commands/release/report-unreleased.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class UnreleasedReportCommand extends BaseCommand<typeof UnreleasedReport
7070
* @param fullReleaseReport - The format of the "full" release report.
7171
* @param version - The version string for the reports.
7272
* @param outDir - The output directory for the reports.
73+
* @param branchName - The branch name for the reports.
7374
* @param log - The logger object for logging messages.
7475
*/
7576
async function generateReleaseReport(

build-tools/packages/build-cli/src/commands/release/report.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export abstract class ReleaseReportBaseCommand<
119119
*
120120
* @param context - The {@link Context}.
121121
* @param mode - The {@link ReleaseSelectionMode} to use to determine the release to report on.
122-
* @param releaseGroup - If provided, the release data collected will be limited to only the pakages in this release
122+
* @param releaseGroupOrPackage - If provided, the release data collected will be limited to only the packages in this release
123123
* group and its direct Fluid dependencies.
124124
* @param includeDependencies - If true, the release data will include the Fluid dependencies of the release group.
125125
*/
@@ -205,7 +205,7 @@ export abstract class ReleaseReportBaseCommand<
205205
/**
206206
* Collects the releases of a given release group or package.
207207
*
208-
* @param context - The {@link Context}.
208+
* @param repo - The {@link Repository}.
209209
* @param releaseGroupOrPackage - The release group or package to collect release data for.
210210
* @param repoVersion - The version of the release group or package in the repo.
211211
* @param latestReleaseChooseMode - Controls which release is considered the latest.
@@ -734,5 +734,6 @@ async function writeReport(
734734
const reportOutput = toReportKind(report, kind);
735735

736736
await writeJson(reportPath, reportOutput, { spaces: 2 });
737+
// eslint-disable-next-line import-x/no-named-as-default-member -- sortJson.overwrite is the correct usage
737738
sortJson.overwrite(reportPath);
738739
}

0 commit comments

Comments
 (0)