Files
Chris Arderne c7861be520 chore: activate no-unused-vars and import linters (#4096)
Once this is merged, oxlint is at a pretty sensible baseline.

**Enable `no-unused-vars`, `typescript/consistent-type-imports`, and
`import/no-duplicates` lint rules**

Turns on three previously-disabled oxlint rules across the monorepo and
fixes all violations:

- **`no-unused-vars`** – enabled as an error with standard ignore
patterns: unused function arguments are ignored by default (`args:
"none"`), variables/caught errors/destructured array elements prefixed
with `_` are allowed, and rest siblings are permitted.
- **`typescript/consistent-type-imports`** – enforced as an error; all
type-only imports now use the `import type` syntax.
- **`import/no-duplicates`** – enforced as an error; duplicate import
statements from the same module have been merged.

The remaining commits clean up the violations found across the codebase:
removing unused variables/imports/type aliases, adding `_` prefixes to
intentionally unused bindings, fixing duplicate imports, and converting
value imports to `import type` where appropriate.
2026-07-02 11:37:05 +01:00

40 lines
1.3 KiB
TypeScript

import * as fs from "node:fs/promises";
import * as path from "node:path";
import { readPackageJSON } from "pkg-types";
// This script will update the VERSION constant in the build output, found at:
// {cwd}/dist/esm/version.js
// {cwd}/dist/commonjs/version.js
//
// It fetches the version by reading the package.json file in the root of the project.
async function updateVersion() {
const localPackageJson = await readPackageJSON(process.cwd());
if (!localPackageJson.version) {
throw new Error("Failed to read version from package.json");
}
const versionFileESM = path.join(process.cwd(), "dist", "esm", "version.js");
await updatePlaceholderInFile(versionFileESM, localPackageJson.version);
const versionFileCJS = path.join(process.cwd(), "dist", "commonjs", "version.js");
await updatePlaceholderInFile(versionFileCJS, localPackageJson.version);
console.log(
`Updated packages/${path.basename(process.cwd())} version.js to ${localPackageJson.version}`
);
}
async function updatePlaceholderInFile(filePath: string, version: string) {
try {
const fileContents = await fs.readFile(filePath, "utf-8");
const updatedContents = fileContents.replace("0.0.0", version);
await fs.writeFile(filePath, updatedContents);
} catch (_e) {}
}
updateVersion().catch((e) => {
console.error(e);
process.exit(1);
});