From f227b9e795b2b5bcac8a0413b80db5797b3c22f4 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 30 Sep 2024 13:14:40 -0700 Subject: [PATCH 1/5] refactor(build-cli): Move tests alongside source --- .vscode/launch.json | 3 +- build-tools/packages/build-cli/.eslintrc.cjs | 3 ++ build-tools/packages/build-cli/package.json | 2 +- .../commands/generate/buildVersion.test.ts | 0 .../test/commands/generate/typetests.test.ts | 7 ++- .../{ => src}/test/commands/list.test.ts | 8 ++-- .../{ => src}/test/commands/release.test.ts | 8 ++-- .../test/commands/release/fromTag.test.ts | 3 +- .../test/commands/test-only-filter.test.ts | 10 ++++- .../{ => src}/test/commands/typetests.test.ts | 8 +++- .../test/data/another-example-changeset.md | 0 .../{ => src}/test/data/example-changeset.md | 0 .../{ => src}/test/data/exports/class.d.ts | 1 + .../test/data/exports/exports-rollup.d.ts | 0 .../{ => src}/test/data/exports/exports.d.ts | 2 + .../test/data/exports/innerFile.d.ts | 0 .../test/data/multiple-change-types.md | 0 .../build-cli/{ => src}/test/filter.test.ts | 23 +++++----- .../packages/build-cli/{ => src}/test/init.ts | 3 +- .../{ => src}/test/library/branches.test.ts | 5 ++- .../{ => src}/test/library/changesets.test.ts | 5 ++- .../{ => src}/test/library/package.test.ts | 17 ++++---- .../test/library/packageExports.test.ts | 43 ++++++++++++++----- .../spacesOverTabsInYaml.test.ts | 3 +- .../test/machines/fluidReleaseMachine.test.ts | 10 +++-- .../packages/build-cli/src/test/tsconfig.json | 15 +++++++ .../packages/build-cli/test/tsconfig.json | 17 -------- build-tools/packages/build-cli/tsconfig.json | 1 + 28 files changed, 124 insertions(+), 73 deletions(-) rename build-tools/packages/build-cli/{ => src}/test/commands/generate/buildVersion.test.ts (100%) rename build-tools/packages/build-cli/{ => src}/test/commands/generate/typetests.test.ts (89%) rename build-tools/packages/build-cli/{ => src}/test/commands/list.test.ts (84%) rename build-tools/packages/build-cli/{ => src}/test/commands/release.test.ts (82%) rename build-tools/packages/build-cli/{ => src}/test/commands/release/fromTag.test.ts (89%) rename build-tools/packages/build-cli/{ => src}/test/commands/test-only-filter.test.ts (83%) rename build-tools/packages/build-cli/{ => src}/test/commands/typetests.test.ts (94%) rename build-tools/packages/build-cli/{ => src}/test/data/another-example-changeset.md (100%) rename build-tools/packages/build-cli/{ => src}/test/data/example-changeset.md (100%) rename build-tools/packages/build-cli/{ => src}/test/data/exports/class.d.ts (71%) rename build-tools/packages/build-cli/{ => src}/test/data/exports/exports-rollup.d.ts (100%) rename build-tools/packages/build-cli/{ => src}/test/data/exports/exports.d.ts (80%) rename build-tools/packages/build-cli/{ => src}/test/data/exports/innerFile.d.ts (100%) rename build-tools/packages/build-cli/{ => src}/test/data/multiple-change-types.md (100%) rename build-tools/packages/build-cli/{ => src}/test/filter.test.ts (94%) rename build-tools/packages/build-cli/{ => src}/test/init.ts (75%) rename build-tools/packages/build-cli/{ => src}/test/library/branches.test.ts (97%) rename build-tools/packages/build-cli/{ => src}/test/library/changesets.test.ts (90%) rename build-tools/packages/build-cli/{ => src}/test/library/package.test.ts (89%) rename build-tools/packages/build-cli/{ => src}/test/library/packageExports.test.ts (84%) rename build-tools/packages/build-cli/{ => src}/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts (89%) rename build-tools/packages/build-cli/{ => src}/test/machines/fluidReleaseMachine.test.ts (90%) create mode 100644 build-tools/packages/build-cli/src/test/tsconfig.json delete mode 100644 build-tools/packages/build-cli/test/tsconfig.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 38dfc5953f02..fcb6c3976ee7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,7 +41,8 @@ { "name": "fluid-build", "program": "${workspaceFolder}/build-tools/packages/build-tools/bin/fluid-build", - "cwd": "${workspaceFolder}/packages/common/container-definitions", + // "cwd": "${workspaceFolder}/packages/common/container-definitions", + "cwd": "${workspaceFolder}/build-tools", "request": "launch", "skipFiles": ["/**"], "type": "node", diff --git a/build-tools/packages/build-cli/.eslintrc.cjs b/build-tools/packages/build-cli/.eslintrc.cjs index b154bc3f8d5e..91966e721f00 100644 --- a/build-tools/packages/build-cli/.eslintrc.cjs +++ b/build-tools/packages/build-cli/.eslintrc.cjs @@ -12,6 +12,9 @@ module.exports = { require.resolve("@fluidframework/eslint-config-fluid/recommended"), "prettier", ], + parserOptions: { + project: ["./tsconfig.json", "./src/test/tsconfig.json"], + }, rules: { // This rule is often triggered when using custom Flags, so disabling. "object-shorthand": "off", diff --git a/build-tools/packages/build-cli/package.json b/build-tools/packages/build-cli/package.json index 5f7124b39db4..c391713f04ba 100644 --- a/build-tools/packages/build-cli/package.json +++ b/build-tools/packages/build-cli/package.json @@ -39,7 +39,7 @@ "build:docs": "api-extractor run --local", "build:manifest": "oclif manifest", "build:readme": "oclif readme --version 0.0.0 --multi --no-aliases", - "build:test": "tsc --project ./test/tsconfig.json", + "build:test": "tsc --project ./src/test/tsconfig.json", "check:biome": "biome check .", "check:format": "npm run check:biome", "ci:build:docs": "api-extractor run", diff --git a/build-tools/packages/build-cli/test/commands/generate/buildVersion.test.ts b/build-tools/packages/build-cli/src/test/commands/generate/buildVersion.test.ts similarity index 100% rename from build-tools/packages/build-cli/test/commands/generate/buildVersion.test.ts rename to build-tools/packages/build-cli/src/test/commands/generate/buildVersion.test.ts diff --git a/build-tools/packages/build-cli/test/commands/generate/typetests.test.ts b/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts similarity index 89% rename from build-tools/packages/build-cli/test/commands/generate/typetests.test.ts rename to build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts index f9dac73e92b1..2b3a7661d0e9 100644 --- a/build-tools/packages/build-cli/test/commands/generate/typetests.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts @@ -7,11 +7,13 @@ import { strict as assert } from "node:assert"; import { loadTypesSourceFile, typeDataFromFile, -} from "../../../src/commands/generate/typetests.js"; -import type { TypeData } from "../../../src/typeValidator/typeData.js"; +} from "../../../commands/generate/typetests.js"; +// eslint-disable-next-line import/no-internal-modules +import type { TypeData } from "../../../typeValidator/typeData.js"; describe("generate:typetests", () => { const logger = { + /* eslint-disable @typescript-eslint/explicit-function-return-type */ log: () => assert.fail(), info: () => assert.fail(), warning: () => assert.fail(), @@ -20,6 +22,7 @@ describe("generate:typetests", () => { logHr: () => assert.fail(), logIndent: () => assert.fail(), }; + /* eslint-enable @typescript-eslint/explicit-function-return-type */ function forCompare(data: Map, includeTypeOf?: true): unknown[] { return [...data.entries()].map(([k, v]) => ({ diff --git a/build-tools/packages/build-cli/test/commands/list.test.ts b/build-tools/packages/build-cli/src/test/commands/list.test.ts similarity index 84% rename from build-tools/packages/build-cli/test/commands/list.test.ts rename to build-tools/packages/build-cli/src/test/commands/list.test.ts index fd803d7cba66..1f2b0c60173f 100644 --- a/build-tools/packages/build-cli/test/commands/list.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/list.test.ts @@ -6,13 +6,14 @@ import { GitRepo, type Package, getResolvedFluidRoot } from "@fluidframework/build-tools"; import { expect } from "chai"; -import { type PackageNamePolicyConfig } from "../../src/config.js"; -import { Context } from "../../src/library/index.js"; +import { type PackageNamePolicyConfig } from "../../config.js"; +import { Context } from "../../library/index.js"; import { type Feed, feeds, packagePublishesToFeed, -} from "../../src/library/repoPolicyCheck/npmPackages.js"; +// eslint-disable-next-line import/no-internal-modules +} from "../../library/repoPolicyCheck/npmPackages.js"; /** * Calculates the packages that should be published to a feed and returns a map of Feed to the packages that should be @@ -42,6 +43,7 @@ function FeedsForPackages( return mapping; } +// eslint-disable-next-line @typescript-eslint/no-misused-promises describe("feeds", async () => { const resolvedRoot = await getResolvedFluidRoot(); const gitRepo = new GitRepo(resolvedRoot); diff --git a/build-tools/packages/build-cli/test/commands/release.test.ts b/build-tools/packages/build-cli/src/test/commands/release.test.ts similarity index 82% rename from build-tools/packages/build-cli/test/commands/release.test.ts rename to build-tools/packages/build-cli/src/test/commands/release.test.ts index 08df989de88f..166f072523f8 100644 --- a/build-tools/packages/build-cli/test/commands/release.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/release.test.ts @@ -3,16 +3,16 @@ * Licensed under the MIT License. */ -import { FluidReleaseMachine } from "../../src/machines/index.js"; +import { FluidReleaseMachine } from "../../machines/index.js"; import { initializeCommandTestFunction } from "../init.js"; const test = initializeCommandTestFunction(import.meta.url); -const knownUnhandledStates: string[] = [ +const knownUnhandledStates: Set = new Set([ // Known unhandled states can be added here temporarily during development. -]; +]); const machineStates = FluidReleaseMachine.states() - .filter((s) => !knownUnhandledStates.includes(s)) + .filter((s) => !knownUnhandledStates.has(s)) .sort(); describe("release command handles all states", () => { diff --git a/build-tools/packages/build-cli/test/commands/release/fromTag.test.ts b/build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts similarity index 89% rename from build-tools/packages/build-cli/test/commands/release/fromTag.test.ts rename to build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts index 6dab3ecd6cc6..61e0beffce96 100644 --- a/build-tools/packages/build-cli/test/commands/release/fromTag.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts @@ -7,7 +7,7 @@ import { ReleaseVersion, VersionBumpType } from "@fluid-tools/version-tools"; import chai, { expect } from "chai"; import assertArrays from "chai-arrays"; -import { ReleaseGroup, ReleasePackage } from "../../../src/releaseGroups.js"; +import { ReleaseGroup, ReleasePackage } from "../../../releaseGroups.js"; import { initializeCommandTestFunction } from "../../init.js"; const test = initializeCommandTestFunction(import.meta.url); @@ -40,6 +40,7 @@ describe("flub release fromTag", () => { .stdout() .command(["release:fromTag", "build-tools_v0.26.1", "--json"]) .it(`--json`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); // const { title, tag, version } = output; expect(output).to.deep.equal(expected); diff --git a/build-tools/packages/build-cli/test/commands/test-only-filter.test.ts b/build-tools/packages/build-cli/src/test/commands/test-only-filter.test.ts similarity index 83% rename from build-tools/packages/build-cli/test/commands/test-only-filter.test.ts rename to build-tools/packages/build-cli/src/test/commands/test-only-filter.test.ts index cd312d96499f..f726977f63ab 100644 --- a/build-tools/packages/build-cli/test/commands/test-only-filter.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/test-only-filter.test.ts @@ -22,6 +22,7 @@ describe("flub test-only-filter", () => { .stdout() .command(["test-only-filter", "--quiet", "--json", "--all"]) .it(`--all selector`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); const { selected, filtered } = output; expect(selected.length).to.equal(filtered.length); @@ -31,6 +32,7 @@ describe("flub test-only-filter", () => { .stdout() .command(["test-only-filter", "--quiet", "--json", "--dir", "."]) .it(`--dir selector`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); const { selected, filtered } = output; expect(selected).to.be.ofSize(1); @@ -38,8 +40,8 @@ describe("flub test-only-filter", () => { const pkg = filtered[0]; - expect(pkg.name).to.equal("@fluid-tools/build-cli"); - expect(pkg.directory).to.equal("build-tools/packages/build-cli"); + expect(pkg?.name).to.equal("@fluid-tools/build-cli"); + expect(pkg?.directory).to.equal("build-tools/packages/build-cli"); expect(selected.length).to.equal(1); expect(filtered.length).to.equal(1); @@ -49,6 +51,7 @@ describe("flub test-only-filter", () => { .stdout() .command(["test-only-filter", "--quiet", "--json", "--releaseGroup", "build-tools"]) .it(`--releaseGroup selector`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); const { selected, filtered } = output; expect(selected).to.be.ofSize(4); @@ -59,6 +62,7 @@ describe("flub test-only-filter", () => { .stdout() .command(["test-only-filter", "--quiet", "--json", "--all", "--private"]) .it(`--private filter`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); const { filtered } = output; @@ -73,6 +77,7 @@ describe("flub test-only-filter", () => { .stdout() .command(["test-only-filter", "--quiet", "--json", "--all", "--no-private"]) .it(`--no-private filter`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); const { filtered } = output; @@ -91,6 +96,7 @@ describe("flub test-only-filter", () => { "@fluidframework", ]) .it(`--scope filter`, (ctx) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); const { filtered } = output; diff --git a/build-tools/packages/build-cli/test/commands/typetests.test.ts b/build-tools/packages/build-cli/src/test/commands/typetests.test.ts similarity index 94% rename from build-tools/packages/build-cli/test/commands/typetests.test.ts rename to build-tools/packages/build-cli/src/test/commands/typetests.test.ts index 02173930d65a..09cd3f474512 100644 --- a/build-tools/packages/build-cli/test/commands/typetests.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/typetests.test.ts @@ -10,12 +10,13 @@ import { previousVersion, resetBrokenTests, updateTypeTestDependency, -} from "../../src/commands/typetests.js"; +} from "../../commands/typetests.js"; import { type ITypeValidationConfig, type PackageWithTypeTestSettings, defaultTypeValidationConfig, -} from "../../src/typeValidator/typeValidatorConfig.js"; + // eslint-disable-next-line import/no-internal-modules +} from "../../typeValidator/typeValidatorConfig.js"; /** * A minimal test package.json. It defines only the required fields according to the type definition. @@ -53,6 +54,7 @@ function packageWithTypeValidation(enabled = true): PackageWithTypeTestSettings } describe("typetests tests", () => { + /* eslint-disable @typescript-eslint/no-unused-expressions */ describe("updateTypeTestDependency", () => { it("does not remove unrelated dependencies", () => { const pkg: PackageWithTypeTestSettings = { @@ -126,6 +128,7 @@ describe("typetests tests", () => { }); }); }); + /* eslint-enable @typescript-eslint/no-unused-expressions */ describe("resetBrokenTests", () => { it("empty", () => { @@ -156,6 +159,7 @@ describe("typetests tests", () => { const pkg = packageMinimal(); const expected = packageMinimal(); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions expect(pkg.typeValidation).to.not.exist; resetBrokenTests(pkg); expect(pkg).to.deep.equal(expected); diff --git a/build-tools/packages/build-cli/test/data/another-example-changeset.md b/build-tools/packages/build-cli/src/test/data/another-example-changeset.md similarity index 100% rename from build-tools/packages/build-cli/test/data/another-example-changeset.md rename to build-tools/packages/build-cli/src/test/data/another-example-changeset.md diff --git a/build-tools/packages/build-cli/test/data/example-changeset.md b/build-tools/packages/build-cli/src/test/data/example-changeset.md similarity index 100% rename from build-tools/packages/build-cli/test/data/example-changeset.md rename to build-tools/packages/build-cli/src/test/data/example-changeset.md diff --git a/build-tools/packages/build-cli/test/data/exports/class.d.ts b/build-tools/packages/build-cli/src/test/data/exports/class.d.ts similarity index 71% rename from build-tools/packages/build-cli/test/data/exports/class.d.ts rename to build-tools/packages/build-cli/src/test/data/exports/class.d.ts index bfa328210027..631b10f1d944 100644 --- a/build-tools/packages/build-cli/test/data/exports/class.d.ts +++ b/build-tools/packages/build-cli/src/test/data/exports/class.d.ts @@ -6,4 +6,5 @@ /** * @public */ +// eslint-disable-next-line @typescript-eslint/no-extraneous-class export declare class Foo {} diff --git a/build-tools/packages/build-cli/test/data/exports/exports-rollup.d.ts b/build-tools/packages/build-cli/src/test/data/exports/exports-rollup.d.ts similarity index 100% rename from build-tools/packages/build-cli/test/data/exports/exports-rollup.d.ts rename to build-tools/packages/build-cli/src/test/data/exports/exports-rollup.d.ts diff --git a/build-tools/packages/build-cli/test/data/exports/exports.d.ts b/build-tools/packages/build-cli/src/test/data/exports/exports.d.ts similarity index 80% rename from build-tools/packages/build-cli/test/data/exports/exports.d.ts rename to build-tools/packages/build-cli/src/test/data/exports/exports.d.ts index 7129da34896a..17618837422c 100644 --- a/build-tools/packages/build-cli/test/data/exports/exports.d.ts +++ b/build-tools/packages/build-cli/src/test/data/exports/exports.d.ts @@ -10,6 +10,7 @@ export declare type A = number; /** * @public */ +// eslint-disable-next-line one-var export declare const a: number, b: string; /** * @internal @@ -17,4 +18,5 @@ export declare const a: number, b: string; export declare const c: number; import * as InternalTypes from "./innerFile.js"; +// eslint-disable-next-line unicorn/prefer-export-from export { InternalTypes }; diff --git a/build-tools/packages/build-cli/test/data/exports/innerFile.d.ts b/build-tools/packages/build-cli/src/test/data/exports/innerFile.d.ts similarity index 100% rename from build-tools/packages/build-cli/test/data/exports/innerFile.d.ts rename to build-tools/packages/build-cli/src/test/data/exports/innerFile.d.ts diff --git a/build-tools/packages/build-cli/test/data/multiple-change-types.md b/build-tools/packages/build-cli/src/test/data/multiple-change-types.md similarity index 100% rename from build-tools/packages/build-cli/test/data/multiple-change-types.md rename to build-tools/packages/build-cli/src/test/data/multiple-change-types.md diff --git a/build-tools/packages/build-cli/test/filter.test.ts b/build-tools/packages/build-cli/src/test/filter.test.ts similarity index 94% rename from build-tools/packages/build-cli/test/filter.test.ts rename to build-tools/packages/build-cli/src/test/filter.test.ts index 38a0914e3817..9fcf68a2bc32 100644 --- a/build-tools/packages/build-cli/test/filter.test.ts +++ b/build-tools/packages/build-cli/src/test/filter.test.ts @@ -5,9 +5,8 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; -import { GitRepo, getResolvedFluidRoot } from "@fluidframework/build-tools"; -import { PackageName } from "@rushstack/node-core-library"; -import chai, { assert, expect } from "chai"; +import { GitRepo, type Package, getResolvedFluidRoot } from "@fluidframework/build-tools"; +import chai, { expect } from "chai"; import assertArrays from "chai-arrays"; import { AllPackagesSelectionCriteria, @@ -15,14 +14,14 @@ import { PackageSelectionCriteria, filterPackages, selectAndFilterPackages, -} from "../src/filter.js"; -import { Context } from "../src/library/index.js"; +} from "../filter.js"; +import { Context } from "../library/index.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); chai.use(assertArrays); -async function getContext() { +async function getContext(): Promise { const resolvedRoot = await getResolvedFluidRoot(); const gitRepo = new GitRepo(resolvedRoot); const branch = await gitRepo.getCurrentBranchName(); @@ -30,7 +29,7 @@ async function getContext() { return context; } -async function getBuildToolsPackages() { +async function getBuildToolsPackages(): Promise { const context = await getContext(); // Use the build-tools packages as test cases. It's brittle, but functional. Ideally, we would have mocks for // context/package/release group/etc., but we don't. @@ -38,13 +37,13 @@ async function getBuildToolsPackages() { return packages; } -async function getClientPackages() { +async function getClientPackages(): Promise { const context = await getContext(); const packages = context.packagesInReleaseGroup("client"); return packages; } -describe("filterPackages", async () => { +describe("filterPackages", () => { it("no filters", async () => { const packages = await getBuildToolsPackages(); const filters: PackageFilterOptions = { @@ -137,7 +136,7 @@ describe("filterPackages", async () => { }); }); -describe("selectAndFilterPackages", async () => { +describe("selectAndFilterPackages", () => { it("all, no filters", async () => { const context = await getContext(); const selectionOptions = AllPackagesSelectionCriteria; @@ -260,8 +259,8 @@ describe("selectAndFilterPackages", async () => { const pkg = filtered[0]; - expect(pkg.name).to.equal("@fluid-tools/build-cli"); - expect(context.repo.relativeToRepo(pkg.directory)).to.equal( + expect(pkg?.name).to.equal("@fluid-tools/build-cli"); + expect(context.repo.relativeToRepo(pkg?.directory ?? "")).to.equal( "build-tools/packages/build-cli", ); }); diff --git a/build-tools/packages/build-cli/test/init.ts b/build-tools/packages/build-cli/src/test/init.ts similarity index 75% rename from build-tools/packages/build-cli/test/init.ts rename to build-tools/packages/build-cli/src/test/init.ts index 74ccf13d035e..d6c0b3914cc1 100644 --- a/build-tools/packages/build-cli/test/init.ts +++ b/build-tools/packages/build-cli/src/test/init.ts @@ -6,7 +6,7 @@ import { test as oclifTest } from "@oclif/test"; /** - * Initializes the oclif command test environment. @oclif/test cannot find the path to the project in some + * Initializes the oclif command test environment. \@oclif/test cannot find the path to the project in some * circumstances, so as a workaround we configure it explicitly by passing in the URL to the test module itself. * * @param moduleUrl - The URL to the test module. In most cases you should pass the `import.meta.url` value for the test @@ -14,6 +14,7 @@ import { test as oclifTest } from "@oclif/test"; * * @returns A test function that can be used to tst oclif commands. */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type export function initializeCommandTestFunction(moduleUrl: string) { // @oclif/test cannot find the path to the project, so as a workaround we configure it explicitly return oclifTest.loadConfig({ root: moduleUrl }); diff --git a/build-tools/packages/build-cli/test/library/branches.test.ts b/build-tools/packages/build-cli/src/test/library/branches.test.ts similarity index 97% rename from build-tools/packages/build-cli/test/library/branches.test.ts rename to build-tools/packages/build-cli/src/test/library/branches.test.ts index 22e334bef35c..4cbf9b2a6e04 100644 --- a/build-tools/packages/build-cli/test/library/branches.test.ts +++ b/build-tools/packages/build-cli/src/test/library/branches.test.ts @@ -5,14 +5,15 @@ import { assert } from "chai"; -import { MonoRepoKind } from "../../src/library/index.js"; +import { MonoRepoKind } from "../../library/index.js"; import { generateBumpDepsBranchName, generateBumpVersionBranchName, generateReleaseBranchName, getDefaultBumpTypeForBranch, -} from "../../src/library/branches.js"; +// eslint-disable-next-line import/no-internal-modules +} from "../../library/branches.js"; describe("generateBumpVersionBranchName", () => { it("semver versions", () => { diff --git a/build-tools/packages/build-cli/test/library/changesets.test.ts b/build-tools/packages/build-cli/src/test/library/changesets.test.ts similarity index 90% rename from build-tools/packages/build-cli/test/library/changesets.test.ts rename to build-tools/packages/build-cli/src/test/library/changesets.test.ts index 029c4b5e8434..840dfc8dc92d 100644 --- a/build-tools/packages/build-cli/test/library/changesets.test.ts +++ b/build-tools/packages/build-cli/src/test/library/changesets.test.ts @@ -13,14 +13,15 @@ import { groupByMainPackage, groupByPackage, loadChangesets, -} from "../../src/library/changesets.js"; + // eslint-disable-next-line import/no-internal-modules +} from "../../library/changesets.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const changesetsPath = path.resolve(__dirname, "../data"); assert.isTrue(existsSync(changesetsPath)); -describe("changesets", async () => { +describe("changesets", () => { it("loadChangesets", async () => { const changesets = await loadChangesets(changesetsPath); expect(changesets.length).to.equal(3); diff --git a/build-tools/packages/build-cli/test/library/package.test.ts b/build-tools/packages/build-cli/src/test/library/package.test.ts similarity index 89% rename from build-tools/packages/build-cli/test/library/package.test.ts rename to build-tools/packages/build-cli/src/test/library/package.test.ts index 217a541841be..be3e7b14b3f9 100644 --- a/build-tools/packages/build-cli/test/library/package.test.ts +++ b/build-tools/packages/build-cli/src/test/library/package.test.ts @@ -7,16 +7,17 @@ import { PackageName } from "@rushstack/node-core-library"; import { assert } from "chai"; import { parseJSON } from "date-fns"; -import { VersionDetails } from "../../src/library/index.js"; +import { VersionDetails } from "../../library/index.js"; import type { PackageJson } from "@fluidframework/build-tools"; import { ensureDevDependencyExists, generateReleaseGitTagName, sortVersions, -} from "../../src/library/package.js"; + // eslint-disable-next-line import/no-internal-modules +} from "../../library/package.js"; -describe("VersionDetails sorting", async () => { +describe("VersionDetails sorting", () => { const versions: VersionDetails[] = [ { version: "0.1.38773", date: parseJSON("2021-09-28T17:03:10.000Z") }, { version: "0.59.3000", date: parseJSON("2022-06-06T21:35:27.000Z") }, @@ -28,15 +29,15 @@ describe("VersionDetails sorting", async () => { it("sortedByVersion", async () => { const sortedByVersion = sortVersions(versions, "version"); - assert.equal(sortedByVersion[0].version, "1.0.2"); - assert.equal(sortedByVersion[3].version, "0.59.3001"); + assert.equal(sortedByVersion[0]?.version, "1.0.2"); + assert.equal(sortedByVersion[3]?.version, "0.59.3001"); }); it("sortedByDate", async () => { const sortedByDate = sortVersions(versions, "date"); - assert.equal(sortedByDate[0].version, "0.59.3001"); - assert.equal(sortedByDate[1].version, "1.0.2"); - assert.equal(sortedByDate[4].version, "0.59.3000"); + assert.equal(sortedByDate[0]?.version, "0.59.3001"); + assert.equal(sortedByDate[1]?.version, "1.0.2"); + assert.equal(sortedByDate[4]?.version, "0.59.3000"); }); }); diff --git a/build-tools/packages/build-cli/test/library/packageExports.test.ts b/build-tools/packages/build-cli/src/test/library/packageExports.test.ts similarity index 84% rename from build-tools/packages/build-cli/test/library/packageExports.test.ts rename to build-tools/packages/build-cli/src/test/library/packageExports.test.ts index 3d24414b7917..f95ff9c38c4a 100644 --- a/build-tools/packages/build-cli/test/library/packageExports.test.ts +++ b/build-tools/packages/build-cli/src/test/library/packageExports.test.ts @@ -5,8 +5,10 @@ import { assert } from "chai"; -import type { ExportData, Node10CompatExportData } from "../../src/library/packageExports.js"; -import { queryTypesResolutionPathsFromPackageExports } from "../../src/library/packageExports.js"; +// eslint-disable-next-line import/no-internal-modules +import type { ExportData, Node10CompatExportData } from "../../library/packageExports.js"; +// eslint-disable-next-line import/no-internal-modules +import { queryTypesResolutionPathsFromPackageExports } from "../../library/packageExports.js"; import type { Logger, PackageJson } from "@fluidframework/build-tools"; @@ -119,7 +121,16 @@ const doubleReferencingExportsPackage: PackageJson = { }, }; -function genTestData(path: string, condition: string) { +function genTestData( + path: string, + condition: string, +): { + query: Map; + commonExportResults: Map; + commonNode10CompatExportResults: Map>; + typeOnlyExportResults: Map; + doubleReferenceExportResults: Map; +} { return { query: new Map([ [`./${path}/public.d.ts`, "Public"], @@ -179,7 +190,7 @@ function genTestData(path: string, condition: string) { { relPath: `./${path}/alpha.d.ts`, // "./alpha" is setup with a "default" instead of normal "import" condition - conditions: condition !== "import" ? ["types", condition] : ["types"], + conditions: condition === "import" ? ["types"] : ["types", condition], isTypeOnly: true, }, ], @@ -216,21 +227,25 @@ function genTestData(path: string, condition: string) { } class MockLogger implements Logger { - public calls: [string | Error | undefined, ...any[]][] = []; + public calls: [string | Error | undefined, ...unknown[]][] = []; - log(message?: string, ...args: any[]): void { + log(message?: string, ...args: unknown[]): void { this.calls.push([message, ...args]); } - info(msg: string | Error | undefined, ...args: any[]): void { + + info(msg: string | Error | undefined, ...args: unknown[]): void { this.calls.push([msg, ...args]); } - warning(msg: string | Error | undefined, ...args: any[]): void { + + warning(msg: string | Error | undefined, ...args: unknown[]): void { this.calls.push([msg, ...args]); } - errorLog(msg: string | Error | undefined, ...args: any[]): void { + + errorLog(msg: string | Error | undefined, ...args: unknown[]): void { this.calls.push([msg, ...args]); } - verbose(msg: string | Error | undefined, ...args: any[]): void { + + verbose(msg: string | Error | undefined, ...args: unknown[]): void { this.calls.push([msg, ...args]); } } @@ -250,9 +265,11 @@ describe("library/packageExports", () => { [ ["commonjs (dist path)", "dist", "require"] as const, ["esm (lib path)", "lib", "import"] as const, + // eslint-disable-next-line unicorn/no-array-for-each ].forEach(([desc, path, condition]) => describe(`using ${desc}`, () => { const logger = new MockLogger(); + // eslint-disable-next-line max-nested-callbacks beforeEach(() => { logger.calls = []; }); @@ -265,6 +282,7 @@ describe("library/packageExports", () => { doubleReferenceExportResults, } = genTestData(path, condition); + // eslint-disable-next-line max-nested-callbacks it("finds path in common package export pattern", () => { const { mapKeyToOutput } = queryTypesResolutionPathsFromPackageExports( commonExportsPackage, @@ -278,6 +296,7 @@ describe("library/packageExports", () => { assertEquivalentMaps(mapKeyToOutput, commonExportResults); }); + // eslint-disable-next-line max-nested-callbacks it("finds type only export paths", () => { const { mapKeyToOutput } = queryTypesResolutionPathsFromPackageExports( typeOnlyExportPackage, @@ -291,6 +310,7 @@ describe("library/packageExports", () => { assertEquivalentMaps(mapKeyToOutput, typeOnlyExportResults); }); + // eslint-disable-next-line max-nested-callbacks it("warns on double referenced export paths", () => { const { mapKeyToOutput } = queryTypesResolutionPathsFromPackageExports( doubleReferencingExportsPackage, @@ -301,7 +321,7 @@ describe("library/packageExports", () => { // Verify assert(logger.calls.length === 1, "logs one warning"); - const message = logger.calls[0][0]; + const message = logger.calls[0]?.[0]; assert(typeof message === "string"); assert( message.endsWith(" found in exports multiple times."), @@ -310,6 +330,7 @@ describe("library/packageExports", () => { assertEquivalentMaps(mapKeyToOutput, doubleReferenceExportResults); }); + // eslint-disable-next-line max-nested-callbacks it("finds beta and internal in common package export pattern for node10 compat", () => { const { mapNode10CompatExportPathToData } = queryTypesResolutionPathsFromPackageExports( diff --git a/build-tools/packages/build-cli/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts b/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts similarity index 89% rename from build-tools/packages/build-cli/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts rename to build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts index a3f54ccf52c8..12268c5ac114 100644 --- a/build-tools/packages/build-cli/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts +++ b/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts @@ -7,7 +7,8 @@ import { expect } from "chai"; import { errorMessage, lookForTabs, -} from "../../../src/library/repoPolicyCheck/spacesOverTabsInYaml.js"; +// eslint-disable-next-line import/no-internal-modules +} from "../../../library/repoPolicyCheck/spacesOverTabsInYaml.js"; describe("indent-with-spaces-in-yaml", () => { it("does not fail when no tabs are present", () => { diff --git a/build-tools/packages/build-cli/test/machines/fluidReleaseMachine.test.ts b/build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts similarity index 90% rename from build-tools/packages/build-cli/test/machines/fluidReleaseMachine.test.ts rename to build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts index a642942ec2d7..fa1e998ee681 100644 --- a/build-tools/packages/build-cli/test/machines/fluidReleaseMachine.test.ts +++ b/build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts @@ -6,7 +6,8 @@ import chai, { expect } from "chai"; import assertArrays from "chai-arrays"; -import { FluidReleaseMachine as machine } from "../../src/machines/fluidReleaseMachine.js"; +// eslint-disable-next-line import/no-internal-modules +import { FluidReleaseMachine as machine } from "../../machines/fluidReleaseMachine.js"; chai.use(assertArrays); @@ -124,16 +125,18 @@ describe("FluidReleaseMachine", () => { describe("All states with a success action have a failure action", () => { // Do* actions are not required to have a failure action except those in this array - const requiresBothActions = ["DoBumpReleasedDependencies"]; + const requiresBothActions = new Set(["DoBumpReleasedDependencies"]); const states = new Set(); + // eslint-disable-next-line unicorn/no-array-for-each machine.list_states_having_action("success").forEach((v) => states.add(v)); + // eslint-disable-next-line unicorn/no-array-for-each machine.list_states_having_action("failure").forEach((v) => states.add(v)); for (const state of states) { const exits = machine.list_exit_actions(state).sort(); - if (!state.startsWith("Do") || requiresBothActions.includes(state)) { + if (!state.startsWith("Do") || requiresBothActions.has(state)) { it(state, () => { expect(exits).to.be.equalTo(["failure", "success"]); }); @@ -158,6 +161,7 @@ function walkExits(state: string, collector: Set, step = 0): void { const transitions = machine.list_transitions(state); for (const next of transitions.exits) { + // eslint-disable-next-line no-param-reassign walkExits(next, collector, step++); } } diff --git a/build-tools/packages/build-cli/src/test/tsconfig.json b/build-tools/packages/build-cli/src/test/tsconfig.json new file mode 100644 index 000000000000..9303d98cbda7 --- /dev/null +++ b/build-tools/packages/build-cli/src/test/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../../../common/build/build-common/tsconfig.test.node16.json", + "include": ["./**/*"], + "compilerOptions": { + "rootDir": "./", + "outDir": "../../lib/test", + "types": ["node", "mocha", "chai"], + "exactOptionalPropertyTypes": false, + }, + "references": [ + { + "path": "../..", + }, + ], +} diff --git a/build-tools/packages/build-cli/test/tsconfig.json b/build-tools/packages/build-cli/test/tsconfig.json deleted file mode 100644 index 1cd513901ccf..000000000000 --- a/build-tools/packages/build-cli/test/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["test/**/*"], - "compilerOptions": { - "importHelpers": true, - "declarationMap": false, - "rootDir": "./", - "outDir": "../lib/test", - "types": ["node", "mocha", "chai"], - "skipLibCheck": true, - }, - "references": [ - { - "path": "..", - }, - ], -} diff --git a/build-tools/packages/build-cli/tsconfig.json b/build-tools/packages/build-cli/tsconfig.json index 277028309b9f..84d011b70aff 100644 --- a/build-tools/packages/build-cli/tsconfig.json +++ b/build-tools/packages/build-cli/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../../common/build/build-common/tsconfig.node16.json", "include": ["src/**/*"], + "exclude": ["src/test/**/*"], "compilerOptions": { "rootDir": "./src", "outDir": "./lib", From 1258c323ea82880aed5f284e9b69285d98dca75d Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 30 Sep 2024 13:18:49 -0700 Subject: [PATCH 2/5] format --- .../packages/build-cli/src/test/commands/list.test.ts | 8 +++++--- .../packages/build-cli/src/test/library/branches.test.ts | 2 +- .../library/repoPolicyCheck/spacesOverTabsInYaml.test.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build-tools/packages/build-cli/src/test/commands/list.test.ts b/build-tools/packages/build-cli/src/test/commands/list.test.ts index 1f2b0c60173f..b8dcf7a63732 100644 --- a/build-tools/packages/build-cli/src/test/commands/list.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/list.test.ts @@ -12,7 +12,7 @@ import { type Feed, feeds, packagePublishesToFeed, -// eslint-disable-next-line import/no-internal-modules + // eslint-disable-next-line import/no-internal-modules } from "../../library/repoPolicyCheck/npmPackages.js"; /** @@ -50,8 +50,9 @@ describe("feeds", async () => { const branch = await gitRepo.getCurrentBranchName(); const context = new Context(gitRepo, "microsoft/FluidFramework", branch); - const config = context.flubConfig.policy?.packageNames!; - const packages = FeedsForPackages(context.packages, config); + const config = context.flubConfig.policy?.packageNames; + // eslint-disable-next-line new-cap, @typescript-eslint/no-non-null-assertion + const packages = FeedsForPackages(context.packages, config!); it("dev and build feed are mutually exclusive", () => { const dev = packages.get("internal-dev")?.map((p) => p.name); @@ -61,6 +62,7 @@ describe("feeds", async () => { return dev?.includes(name); }); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions expect(hasDupes).to.be.false; }); }); diff --git a/build-tools/packages/build-cli/src/test/library/branches.test.ts b/build-tools/packages/build-cli/src/test/library/branches.test.ts index 4cbf9b2a6e04..72faf3f36fb1 100644 --- a/build-tools/packages/build-cli/src/test/library/branches.test.ts +++ b/build-tools/packages/build-cli/src/test/library/branches.test.ts @@ -12,7 +12,7 @@ import { generateBumpVersionBranchName, generateReleaseBranchName, getDefaultBumpTypeForBranch, -// eslint-disable-next-line import/no-internal-modules + // eslint-disable-next-line import/no-internal-modules } from "../../library/branches.js"; describe("generateBumpVersionBranchName", () => { diff --git a/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts b/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts index 12268c5ac114..beaddabc919f 100644 --- a/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts +++ b/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts @@ -7,7 +7,7 @@ import { expect } from "chai"; import { errorMessage, lookForTabs, -// eslint-disable-next-line import/no-internal-modules + // eslint-disable-next-line import/no-internal-modules } from "../../../library/repoPolicyCheck/spacesOverTabsInYaml.js"; describe("indent-with-spaces-in-yaml", () => { From 51ff593ab225648e82ac53030af98dd8a4c8faa7 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 30 Sep 2024 13:21:10 -0700 Subject: [PATCH 3/5] Apply suggestions from code review --- .vscode/launch.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fcb6c3976ee7..38dfc5953f02 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,8 +41,7 @@ { "name": "fluid-build", "program": "${workspaceFolder}/build-tools/packages/build-tools/bin/fluid-build", - // "cwd": "${workspaceFolder}/packages/common/container-definitions", - "cwd": "${workspaceFolder}/build-tools", + "cwd": "${workspaceFolder}/packages/common/container-definitions", "request": "launch", "skipFiles": ["/**"], "type": "node", From f3255ad78d2f385e95cb47287495c185c8e5b8b8 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 30 Sep 2024 16:27:01 -0700 Subject: [PATCH 4/5] path fixup --- build-tools/packages/build-cli/package.json | 2 +- .../build-cli/src/test/commands/generate/typetests.test.ts | 6 +++--- build-tools/packages/build-cli/src/test/filter.test.ts | 2 +- .../packages/build-cli/src/test/library/changesets.test.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build-tools/packages/build-cli/package.json b/build-tools/packages/build-cli/package.json index c391713f04ba..7a1f04657e2b 100644 --- a/build-tools/packages/build-cli/package.json +++ b/build-tools/packages/build-cli/package.json @@ -55,7 +55,7 @@ "postpack": "npm run clean:manifest", "test": "npm run test:mocha", "test:coverage": "c8 npm run test", - "test:mocha": "mocha --forbid-only \"test/**/*.test.ts\"", + "test:mocha": "mocha \"lib/test/**/*.test.*js\"", "tsc": "tsc" }, "c8": { diff --git a/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts b/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts index 2b3a7661d0e9..217bade8ffd8 100644 --- a/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts @@ -35,7 +35,7 @@ describe("generate:typetests", () => { // Test a file which looks like a rollup: a file that reexports content from other files. it("rollup", () => { - const currentFile = loadTypesSourceFile("./test/data/exports/exports-rollup.d.ts"); + const currentFile = loadTypesSourceFile("./src/test/data/exports/exports-rollup.d.ts"); const types = forCompare(typeDataFromFile(currentFile, logger)); assert.deepEqual(types, [ @@ -59,7 +59,7 @@ describe("generate:typetests", () => { // Test a file which directly includes several kinds of exports to ensure that various export types work correctly. it("direct", () => { - const currentFile = loadTypesSourceFile("./test/data/exports/exports.d.ts"); + const currentFile = loadTypesSourceFile("./src/test/data/exports/exports.d.ts"); const types = forCompare(typeDataFromFile(currentFile, logger)); assert.deepEqual(types, [ @@ -82,7 +82,7 @@ describe("generate:typetests", () => { // Test classes generate both cases correctly it("class", () => { - const currentFile = loadTypesSourceFile("./test/data/exports/class.d.ts"); + const currentFile = loadTypesSourceFile("./src/test/data/exports/class.d.ts"); const types = forCompare(typeDataFromFile(currentFile, logger), true); assert.deepEqual(types, [ diff --git a/build-tools/packages/build-cli/src/test/filter.test.ts b/build-tools/packages/build-cli/src/test/filter.test.ts index 9fcf68a2bc32..638239261577 100644 --- a/build-tools/packages/build-cli/src/test/filter.test.ts +++ b/build-tools/packages/build-cli/src/test/filter.test.ts @@ -240,7 +240,7 @@ describe("selectAndFilterPackages", () => { independentPackages: false, releaseGroups: [], releaseGroupRoots: [], - directory: path.resolve(__dirname, ".."), + directory: path.resolve(__dirname, "../.."), changedSinceBranch: undefined, }; const filters: PackageFilterOptions = { diff --git a/build-tools/packages/build-cli/src/test/library/changesets.test.ts b/build-tools/packages/build-cli/src/test/library/changesets.test.ts index 840dfc8dc92d..4ed8219d1846 100644 --- a/build-tools/packages/build-cli/src/test/library/changesets.test.ts +++ b/build-tools/packages/build-cli/src/test/library/changesets.test.ts @@ -18,7 +18,7 @@ import { const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const changesetsPath = path.resolve(__dirname, "../data"); +const changesetsPath = path.resolve(__dirname, "../../../src/test/data"); assert.isTrue(existsSync(changesetsPath)); describe("changesets", () => { From 3102345eb2cdb306e482e8e2ff641470e40b926b Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Tue, 1 Oct 2024 16:53:10 -0700 Subject: [PATCH 5/5] lint cleanup --- build-tools/packages/build-cli/.eslintrc.cjs | 10 ++++++++++ .../test/commands/generate/typetests.test.ts | 2 +- .../build-cli/src/test/commands/list.test.ts | 20 +++++++++---------- .../src/test/commands/release/fromTag.test.ts | 1 - .../src/test/commands/typetests.test.ts | 3 +-- .../packages/build-cli/src/test/init.ts | 2 +- .../src/test/library/branches.test.ts | 1 - .../src/test/library/changesets.test.ts | 1 - .../src/test/library/package.test.ts | 1 - .../src/test/library/packageExports.test.ts | 9 ++------- .../spacesOverTabsInYaml.test.ts | 1 - .../test/machines/fluidReleaseMachine.test.ts | 1 - 12 files changed, 24 insertions(+), 28 deletions(-) diff --git a/build-tools/packages/build-cli/.eslintrc.cjs b/build-tools/packages/build-cli/.eslintrc.cjs index 91966e721f00..0fb18a333892 100644 --- a/build-tools/packages/build-cli/.eslintrc.cjs +++ b/build-tools/packages/build-cli/.eslintrc.cjs @@ -89,4 +89,14 @@ module.exports = { "perfectionist/sort-union-types": "off", "perfectionist/sort-vue-attributes": "off", }, + overrides: [ + { + // Rules only for test files + files: ["*.spec.ts", "src/test/**"], + rules: { + // Test files can import from anywhere + "import/no-internal-modules": "off", + }, + }, + ], }; diff --git a/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts b/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts index 217bade8ffd8..017f772fdfc2 100644 --- a/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/generate/typetests.test.ts @@ -4,11 +4,11 @@ */ import { strict as assert } from "node:assert"; + import { loadTypesSourceFile, typeDataFromFile, } from "../../../commands/generate/typetests.js"; -// eslint-disable-next-line import/no-internal-modules import type { TypeData } from "../../../typeValidator/typeData.js"; describe("generate:typetests", () => { diff --git a/build-tools/packages/build-cli/src/test/commands/list.test.ts b/build-tools/packages/build-cli/src/test/commands/list.test.ts index b8dcf7a63732..cdf711da4387 100644 --- a/build-tools/packages/build-cli/src/test/commands/list.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/list.test.ts @@ -12,7 +12,6 @@ import { type Feed, feeds, packagePublishesToFeed, - // eslint-disable-next-line import/no-internal-modules } from "../../library/repoPolicyCheck/npmPackages.js"; /** @@ -43,18 +42,17 @@ function FeedsForPackages( return mapping; } -// eslint-disable-next-line @typescript-eslint/no-misused-promises -describe("feeds", async () => { - const resolvedRoot = await getResolvedFluidRoot(); - const gitRepo = new GitRepo(resolvedRoot); - const branch = await gitRepo.getCurrentBranchName(); +describe("feeds", () => { + it("dev and build feed are mutually exclusive", async () => { + const resolvedRoot = await getResolvedFluidRoot(); + const gitRepo = new GitRepo(resolvedRoot); + const branch = await gitRepo.getCurrentBranchName(); - const context = new Context(gitRepo, "microsoft/FluidFramework", branch); - const config = context.flubConfig.policy?.packageNames; - // eslint-disable-next-line new-cap, @typescript-eslint/no-non-null-assertion - const packages = FeedsForPackages(context.packages, config!); + const context = new Context(gitRepo, "microsoft/FluidFramework", branch); + const config = context.flubConfig.policy?.packageNames; + // eslint-disable-next-line new-cap, @typescript-eslint/no-non-null-assertion + const packages = FeedsForPackages(context.packages, config!); - it("dev and build feed are mutually exclusive", () => { const dev = packages.get("internal-dev")?.map((p) => p.name); const build = packages.get("internal-build")?.map((p) => p.name); diff --git a/build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts b/build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts index 61e0beffce96..493b2db77b33 100644 --- a/build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/release/fromTag.test.ts @@ -42,7 +42,6 @@ describe("flub release fromTag", () => { .it(`--json`, (ctx) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const output: jsonOutput = JSON.parse(ctx.stdout); - // const { title, tag, version } = output; expect(output).to.deep.equal(expected); }); }); diff --git a/build-tools/packages/build-cli/src/test/commands/typetests.test.ts b/build-tools/packages/build-cli/src/test/commands/typetests.test.ts index 09cd3f474512..6843319e9d64 100644 --- a/build-tools/packages/build-cli/src/test/commands/typetests.test.ts +++ b/build-tools/packages/build-cli/src/test/commands/typetests.test.ts @@ -15,7 +15,6 @@ import { type ITypeValidationConfig, type PackageWithTypeTestSettings, defaultTypeValidationConfig, - // eslint-disable-next-line import/no-internal-modules } from "../../typeValidator/typeValidatorConfig.js"; /** @@ -54,7 +53,6 @@ function packageWithTypeValidation(enabled = true): PackageWithTypeTestSettings } describe("typetests tests", () => { - /* eslint-disable @typescript-eslint/no-unused-expressions */ describe("updateTypeTestDependency", () => { it("does not remove unrelated dependencies", () => { const pkg: PackageWithTypeTestSettings = { @@ -70,6 +68,7 @@ describe("typetests tests", () => { }); }); + /* eslint-disable @typescript-eslint/no-unused-expressions */ describe("VersionOptions.Clear", () => { it("removes previous test package dependency", () => { const pkg = packageWithTypeValidation(); diff --git a/build-tools/packages/build-cli/src/test/init.ts b/build-tools/packages/build-cli/src/test/init.ts index d6c0b3914cc1..89954ba102c7 100644 --- a/build-tools/packages/build-cli/src/test/init.ts +++ b/build-tools/packages/build-cli/src/test/init.ts @@ -12,7 +12,7 @@ import { test as oclifTest } from "@oclif/test"; * @param moduleUrl - The URL to the test module. In most cases you should pass the `import.meta.url` value for the test * module when calling this function. * - * @returns A test function that can be used to tst oclif commands. + * @returns A test function that can be used to test oclif commands. */ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type export function initializeCommandTestFunction(moduleUrl: string) { diff --git a/build-tools/packages/build-cli/src/test/library/branches.test.ts b/build-tools/packages/build-cli/src/test/library/branches.test.ts index 72faf3f36fb1..e83f8feeb102 100644 --- a/build-tools/packages/build-cli/src/test/library/branches.test.ts +++ b/build-tools/packages/build-cli/src/test/library/branches.test.ts @@ -12,7 +12,6 @@ import { generateBumpVersionBranchName, generateReleaseBranchName, getDefaultBumpTypeForBranch, - // eslint-disable-next-line import/no-internal-modules } from "../../library/branches.js"; describe("generateBumpVersionBranchName", () => { diff --git a/build-tools/packages/build-cli/src/test/library/changesets.test.ts b/build-tools/packages/build-cli/src/test/library/changesets.test.ts index 4ed8219d1846..7e4a8cb3acab 100644 --- a/build-tools/packages/build-cli/src/test/library/changesets.test.ts +++ b/build-tools/packages/build-cli/src/test/library/changesets.test.ts @@ -13,7 +13,6 @@ import { groupByMainPackage, groupByPackage, loadChangesets, - // eslint-disable-next-line import/no-internal-modules } from "../../library/changesets.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/build-tools/packages/build-cli/src/test/library/package.test.ts b/build-tools/packages/build-cli/src/test/library/package.test.ts index be3e7b14b3f9..6b31fdf36fd9 100644 --- a/build-tools/packages/build-cli/src/test/library/package.test.ts +++ b/build-tools/packages/build-cli/src/test/library/package.test.ts @@ -14,7 +14,6 @@ import { ensureDevDependencyExists, generateReleaseGitTagName, sortVersions, - // eslint-disable-next-line import/no-internal-modules } from "../../library/package.js"; describe("VersionDetails sorting", () => { diff --git a/build-tools/packages/build-cli/src/test/library/packageExports.test.ts b/build-tools/packages/build-cli/src/test/library/packageExports.test.ts index f95ff9c38c4a..914773652168 100644 --- a/build-tools/packages/build-cli/src/test/library/packageExports.test.ts +++ b/build-tools/packages/build-cli/src/test/library/packageExports.test.ts @@ -3,11 +3,11 @@ * Licensed under the MIT License. */ +/* eslint-disable max-nested-callbacks */ + import { assert } from "chai"; -// eslint-disable-next-line import/no-internal-modules import type { ExportData, Node10CompatExportData } from "../../library/packageExports.js"; -// eslint-disable-next-line import/no-internal-modules import { queryTypesResolutionPathsFromPackageExports } from "../../library/packageExports.js"; import type { Logger, PackageJson } from "@fluidframework/build-tools"; @@ -269,7 +269,6 @@ describe("library/packageExports", () => { ].forEach(([desc, path, condition]) => describe(`using ${desc}`, () => { const logger = new MockLogger(); - // eslint-disable-next-line max-nested-callbacks beforeEach(() => { logger.calls = []; }); @@ -282,7 +281,6 @@ describe("library/packageExports", () => { doubleReferenceExportResults, } = genTestData(path, condition); - // eslint-disable-next-line max-nested-callbacks it("finds path in common package export pattern", () => { const { mapKeyToOutput } = queryTypesResolutionPathsFromPackageExports( commonExportsPackage, @@ -296,7 +294,6 @@ describe("library/packageExports", () => { assertEquivalentMaps(mapKeyToOutput, commonExportResults); }); - // eslint-disable-next-line max-nested-callbacks it("finds type only export paths", () => { const { mapKeyToOutput } = queryTypesResolutionPathsFromPackageExports( typeOnlyExportPackage, @@ -310,7 +307,6 @@ describe("library/packageExports", () => { assertEquivalentMaps(mapKeyToOutput, typeOnlyExportResults); }); - // eslint-disable-next-line max-nested-callbacks it("warns on double referenced export paths", () => { const { mapKeyToOutput } = queryTypesResolutionPathsFromPackageExports( doubleReferencingExportsPackage, @@ -330,7 +326,6 @@ describe("library/packageExports", () => { assertEquivalentMaps(mapKeyToOutput, doubleReferenceExportResults); }); - // eslint-disable-next-line max-nested-callbacks it("finds beta and internal in common package export pattern for node10 compat", () => { const { mapNode10CompatExportPathToData } = queryTypesResolutionPathsFromPackageExports( diff --git a/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts b/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts index beaddabc919f..1097c21a93bd 100644 --- a/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts +++ b/build-tools/packages/build-cli/src/test/library/repoPolicyCheck/spacesOverTabsInYaml.test.ts @@ -7,7 +7,6 @@ import { expect } from "chai"; import { errorMessage, lookForTabs, - // eslint-disable-next-line import/no-internal-modules } from "../../../library/repoPolicyCheck/spacesOverTabsInYaml.js"; describe("indent-with-spaces-in-yaml", () => { diff --git a/build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts b/build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts index fa1e998ee681..82ba615a7c45 100644 --- a/build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts +++ b/build-tools/packages/build-cli/src/test/machines/fluidReleaseMachine.test.ts @@ -6,7 +6,6 @@ import chai, { expect } from "chai"; import assertArrays from "chai-arrays"; -// eslint-disable-next-line import/no-internal-modules import { FluidReleaseMachine as machine } from "../../machines/fluidReleaseMachine.js"; chai.use(assertArrays);