improvement(build-tools): address ESLint rule violations in build-tools#26152
improvement(build-tools): address ESLint rule violations in build-tools#26152tylerbutler merged 4 commits intomicrosoft:mainfrom
Conversation
Fix low-count ESLint violations across the build-tools workspace: - 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)
There was a problem hiding this comment.
Pull request overview
This PR addresses ESLint rule violations across the build-tools workspace by fixing code to comply with newly enabled ESLint rules, without modifying the ESLint configuration itself.
- Modernizes string replacement operations using
.replaceAll()instead of regex-based.replace(/x/g, ...) - Updates import statements to use default imports for Node.js built-in modules like
path - Removes unnecessary
undefinedarguments and fixes JSDoc parameter names - Adds appropriate inline ESLint disable comments for idiomatic library usage patterns
- Updates TSDoc annotations for better compatibility
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
build-tools/packages/version-tools/src/internalVersionScheme.ts |
Removes useless undefined arguments from validateVersionScheme calls |
build-tools/packages/version-tools/src/commands/version/latest.ts |
Removes unused import-x/no-default-export disable directive |
build-tools/packages/version-tools/src/commands/version.ts |
Removes unused import-x/no-default-export disable directive |
build-tools/packages/build-infrastructure/src/test/packageJsonUtils.test.ts |
Changes path import from namespace to default import |
build-tools/packages/build-infrastructure/src/test/git.test.ts |
Changes path import from namespace to default import |
build-tools/packages/build-infrastructure/src/index.ts |
Updates @module to @packageDocumentation for TSDoc compatibility |
build-tools/packages/build-infrastructure/src/buildProject.ts |
Replaces .replace(/\\/g, "/") with .replaceAll("\\", "/") |
build-tools/packages/build-infrastructure/api-report/build-infrastructure.api.md |
Removes auto-generated comment about missing package documentation |
build-tools/packages/build-cli/src/commands/release/report.ts |
Fixes JSDoc parameter names and adds inline disable for sortJson.overwrite |
build-tools/packages/build-cli/src/commands/release/report-unreleased.ts |
Adds missing JSDoc parameter documentation |
build-tools/packages/build-cli/src/commands/release/fromTag.ts |
Adds inline disable for semver.parse |
build-tools/packages/build-cli/src/commands/generate/typetests.ts |
Replaces .replace(/x/g, ...) with .replaceAll() |
build-tools/packages/build-cli/src/commands/generate/changeset.ts |
Adds inline disable for prompts default import |
build-tools/packages/build-cli/src/commands/generate/assertTags.ts |
Replaces .replace(/x/g, ...) with .replaceAll() |
build-tools/packages/build-cli/src/commands/check/policy.ts |
Changes path import and replaces .replace() with .replaceAll() |
build-tools/packages/build-cli/src/commands/bump/deps.ts |
Adds inline disable for prompts default import |
build-tools/packages/build-cli/src/codeCoverage/getCoverageMetrics.ts |
Fixes JSDoc parameter name |
build-tools/packages/build-cli/src/BasePackageCommand.ts |
Adds inline disable for async.mapLimit |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| import * as fs from "node:fs"; | ||
| import { EOL as newline } from "node:os"; | ||
| import * as path from "node:path"; | ||
| import path from "node:path"; |
There was a problem hiding this comment.
Why does path need this but fs kept as * as? (For some reason I thought * as was preferred. Why is it one way or the other?
There was a problem hiding this comment.
Technically I think * as is more "correct" for ESM since you end up with an object that has all the named exports, while import path imports the default export. But node's default export is an object with all the named exports anyway, so it works with either pattern and this is fewer characters. But you're aso right about the fs import - it should follow the same style. I'll fix that in a future change though as the lint config actually gets enabled.
…ls (microsoft#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)
These changes are in preparation for upgrading to eslint 9 in build-tools.
Summary
Changes
.replace(/x/g, ...)with.replaceAll()(unicorn/prefer-string-replace-all)import * as pathtoimport path(unicorn/import-style)undefinedarguments (unicorn/no-useless-undefined)@paramnames to match actual parameters (jsdoc/check-param-names)async.mapLimit,semver.parse,sortJson.overwrite(import-x/no-named-as-default-member)promptsdefault export (import-x/no-named-as-default)@moduleto@packageDocumentationfor TSDoc compatibility (tsdoc/syntax)