Skip to content

Resolve JSON.stringify vs prettier conflict in generated src/version.ts #369

@cameroncooke

Description

@cameroncooke

Follow-up to #289.

scripts/generate-version.ts emits string literals via JSON.stringify(...) as part of the PR's defense-in-depth hardening. That produces double-quoted strings, which prettier rejects in src/version.ts.

Current workaround

src/version.ts was added to the eslint ignores list (commit on the rebased PR branch). The file is .gitignored and regenerated on every build, so the ignore is correct in practice.

Open risk

If anyone later runs prettier directly on src/version.ts, or wires the generated file into a non-eslint format check (CI step, pre-commit hook, etc.), the format check will fail. The workaround is invisible to non-eslint tooling.

Options

  1. Keep JSON.stringify and document the eslint-only carve-out — current state. Defense-in-depth preserved.
  2. Switch to single-quoted output in scripts/generate-version.ts. Safe because validateVersion constrains the emitted strings to a regex that excludes ', \\, and other shell-meaningful characters. Removes the prettier carve-out.
  3. Run prettier on the generated file as a post-step in scripts/generate-version.ts before writing. More machinery, no defense-in-depth loss.

Option (2) is the cheapest if the regex is the source of truth, but it depends on VERSION_REGEX actually constraining the values (see #368 for the related extraction work).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions