1.4 KiB
1.4 KiB
name, description, user-invocable, allowed-tools, license
| name | description | user-invocable | allowed-tools | license |
|---|---|---|---|---|
| add-diagnostic | Add a new diagnostic code following the defineDiagnostics() conventions from nostics | true | Read Grep Glob Edit Write | MIT |
Add a New Diagnostic Code
- Find the catalog. Grep for
defineDiagnosticsto locate thecodesobject the new entry belongs in. With several catalogs, pick by area. - Pick the code.
PREFIX_XNNNN:PREFIXis the project name uppercased (NUXT,I18N);Xis the area letter (Bbuild,Rruntime,Cconfig,Ddeprecation);NNNNis the next free number. Read existing codes to choose. Never rename or reuse a published code. - Add the entry:
LIB_R0001: {
why: (p: { hook: string }) => `${p.hook}() must run at the top of setup().`, // string or typed fn; becomes Error.message (required)
fix: 'Move the call into setup() or a composable it calls.', // optional, but add whenever the fix is known
docs: 'https://example.com/custom', // optional: overrides docsBase, or `false` to opt out
},
whyis the only required field. Params fromwhyandfixare intersected and required at the call site.- Runtime fields (
cause,sources) are passed at the call site, never in the definition.
- Call it:
diagnostics.LIB_R0001({ hook })to report,throw diagnostics.LIB_R0001({ hook, cause: err })to raise. Both run the reporters.
Full API and reporter/formatter/plugin details: the nostics skill.