Skip to content

feat: enforce V0Error on throws in packages/0/src via eslint-plugin-vuetify #248

@johnleider

Description

@johnleider

Context

PR #247 adopts a typed `V0Error` class for every throw in `packages/0/src` so consumers can identify v0 errors via a stable `code` discriminant. Coverage is currently 8/8 throw sites, but the convention is enforced by author discipline only — nothing stops a future PR from landing a bare `throw new Error(...)`.

Ask

Add a lint rule to `eslint-plugin-vuetify` (or a project-local rule under `packages/0/.eslintrc`) that flags bare `throw new Error(...)` inside `packages/0/src/**/*.ts` and suggests `throw new V0Error(...)` with a code from the `V0ErrorDetails` union.

Suggested semantics

  • Target: `packages/0/src/**/.ts` excluding `.test.ts` and `*.bench.ts`.
  • Detect: `ThrowStatement > NewExpression[callee.name='Error']`.
  • Carve-outs:
    • Test/bench files (already excluded by path).
    • Re-throws (`throw err` where `err` is a caught binding).
    • Throws inside test-helper utilities used by tests (rare).
  • Autofix: none — the author has to pick a code from `V0ErrorDetails`, and adding a new arm to the union is a deliberate decision.
  • Message: `Use V0Error with a code from V0ErrorDetails. See https://github.com/vuetifyjs/0/blob/master/packages/0/src/utilities/errors.ts.\`

Notes

  • This is the enforcement gap flagged by the type-design review on refactor: attach structured cause to v0 throws #247 ("structural cause shape cannot be safely tested without inspecting `code` — that's the brand").
  • Without the rule, the registry decays — future authors won't know it exists or will skip it for a bare `Error` when they're in a hurry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    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