feat: enforce V0Error over bare Error in packages/0/src via no-restricted-syntax#269
Open
sridhar-3009 wants to merge 1 commit into
Open
feat: enforce V0Error over bare Error in packages/0/src via no-restricted-syntax#269sridhar-3009 wants to merge 1 commit into
sridhar-3009 wants to merge 1 commit into
Conversation
Adds a 'no-restricted-syntax' block scoped to packages/0/src/**/*.ts (excluding *.test.ts and *.bench.ts) that flags any bare 'throw new Error(...)' and instructs the author to use V0Error with a code from V0ErrorDetails instead. This closes the enforcement gap noted in vuetifyjs#248: PR vuetifyjs#247 covered all 8 existing throw sites, but nothing prevented future authors from landing a bare Error throw that bypasses the typed error registry. Using no-restricted-syntax keeps the rule dependency-free — it mirrors the existing withDefaults guard in eslint.config.js and requires no custom plugin. Closes vuetifyjs#248
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #248.
PR #247 converted all 8 existing
throw new Error(...)sites inpackages/0/srcto useV0Errorwith a typed code fromV0ErrorDetails. The convention was described in the philosophy but enforced only by author discipline — nothing in CI would catch a future PR landing a barethrow new Error(...).Fix
Add a
no-restricted-syntaxblock ineslint.config.jsscoped topackages/0/src/**/*.ts(with carve-outs for*.test.tsand*.bench.ts):Notes
no-restricted-syntax— no custom plugin, no new dependency, mirrors the existingwithDefaultsguard on line 29.throw errwhereerris a caught binding) are not flagged — the selector only matchesnew Error(...)constructor calls.errorseverity so it blocks CI on a violation.