fix(generators): wire lint+typecheck into pipeline and fix uncovered errors

The turbo/generators package shipped without `lint` or `typecheck` scripts,
so `pnpm lint` / `pnpm typecheck` at the root silently skipped it. This
masked 2 ESLint errors (unused imports) and 11 TypeScript errors (relative
imports missing the `.js` extension required by `moduleResolution: NodeNext`,
plus JSON imports missing the `with { type: "json" }` attribute).

- Add `lint` and `typecheck` scripts to turbo/generators/package.json so the
  turbo pipeline picks them up (lint: 14/14, was 13/13).
- Add `.js` extensions to 7 relative imports across config.test.ts,
  lib/core-package-utils.test.ts, lib/snapshot.test.ts, and the 4 e2e tests.
- Add `with { type: "json" }` attributes to 4 snapshot JSON imports in the
  e2e tests.
- Remove unused `existsSync` and `splicePluginImportsAt` imports from
  lib/core-package-utils.test.ts.
- Declare `@repo/core-typescript` + `typescript` devDependencies so the
  generators package can run `tsc --noEmit` for typecheck.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 08:09:17 +02:00
parent e9d0356bc1
commit b593bea8ca
9 changed files with 22 additions and 14 deletions

6
pnpm-lock.yaml generated
View File

@@ -751,6 +751,12 @@ importers:
'@repo/core-eslint':
specifier: workspace:*
version: link:../../packages/core-eslint
'@repo/core-typescript':
specifier: workspace:*
version: link:../../packages/core-typescript
typescript:
specifier: ^5.8.0
version: 5.9.3
vitest:
specifier: ^3.1.0
version: 3.2.4(@types/debug@4.1.13)(@types/node@25.5.2)(happy-dom@20.8.9)(jiti@2.6.1)(jsdom@25.0.1)(lightningcss@1.32.0)(sass@1.99.0)(terser@5.46.2)(tsx@4.21.0)

View File

@@ -4,8 +4,8 @@ import { tmpdir } from "node:os";
import { execSync } from "node:child_process";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { computeSnapshot } from "../lib/snapshot";
import expectedSnapshot from "../__snapshots__/core-package/events.snapshot.json";
import { computeSnapshot } from "../lib/snapshot.js";
import expectedSnapshot from "../__snapshots__/core-package/events.snapshot.json" with { type: "json" };
// Repo root is 2 levels up from turbo/generators/__tests__
const REPO_ROOT = resolve(fileURLToPath(import.meta.url), "..", "..", "..", "..");

View File

@@ -4,8 +4,8 @@ import { tmpdir } from "node:os";
import { execSync } from "node:child_process";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { computeSnapshot } from "../lib/snapshot";
import expectedSnapshot from "../__snapshots__/core-package/realtime.snapshot.json";
import { computeSnapshot } from "../lib/snapshot.js";
import expectedSnapshot from "../__snapshots__/core-package/realtime.snapshot.json" with { type: "json" };
// Repo root is 2 levels up from turbo/generators/__tests__
const REPO_ROOT = resolve(fileURLToPath(import.meta.url), "..", "..", "..", "..");

View File

@@ -4,8 +4,8 @@ import { tmpdir } from "node:os";
import { execSync } from "node:child_process";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { computeSnapshot } from "../lib/snapshot";
import expectedSnapshot from "../__snapshots__/core-package/trpc.snapshot.json";
import { computeSnapshot } from "../lib/snapshot.js";
import expectedSnapshot from "../__snapshots__/core-package/trpc.snapshot.json" with { type: "json" };
// Repo root is 2 levels up from turbo/generators/__tests__
const REPO_ROOT = resolve(fileURLToPath(import.meta.url), "..", "..", "..", "..");

View File

@@ -4,8 +4,8 @@ import { tmpdir } from "node:os";
import { execSync } from "node:child_process";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { computeSnapshot } from "../lib/snapshot";
import expectedSnapshot from "../__snapshots__/core-package/ui.snapshot.json";
import { computeSnapshot } from "../lib/snapshot.js";
import expectedSnapshot from "../__snapshots__/core-package/ui.snapshot.json" with { type: "json" };
// Repo root is 2 levels up from turbo/generators/__tests__
const REPO_ROOT = resolve(fileURLToPath(import.meta.url), "..", "..", "..", "..");

View File

@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
import type { PlopTypes } from "@turbo/gen";
import generator from "./config";
import generator from "./config.js";
describe("core-package generator", () => {
it("is registered with realtime and events in choices list", () => {

View File

@@ -1,6 +1,5 @@
import { describe, it, expect } from "vitest";
import {
existsSync,
mkdtempSync,
mkdirSync,
writeFileSync,
@@ -12,10 +11,9 @@ import {
assertOptionalPackageNotPresent,
addToTranspilePackages,
splicePluginRulesAt,
splicePluginImportsAt,
addBoundariesEntry,
emitTemplateTree,
} from "./core-package-utils";
} from "./core-package-utils.js";
describe("assertOptionalPackageNotPresent", () => {
it("throws if packages/<name>/ exists in cwd", () => {

View File

@@ -2,7 +2,7 @@ import { describe, it, expect } from "vitest";
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { computeSnapshot } from "./snapshot";
import { computeSnapshot } from "./snapshot.js";
describe("computeSnapshot", () => {
it("returns sorted file paths + sha256 hashes", () => {

View File

@@ -4,13 +4,17 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"test": "vitest run"
"lint": "eslint .",
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@turbo/gen": "^2.4.0"
},
"devDependencies": {
"@repo/core-eslint": "workspace:*",
"@repo/core-typescript": "workspace:*",
"typescript": "^5.8.0",
"vitest": "^3.1.0"
}
}