{"record":{"id":"1cfb78ac70636294","repo":"oxc-project/oxc","slug":"missing-jsdoc-throws-type","errorCode":null,"errorMessage":"Missing JSDoc `@throws` type.","messagePattern":"Missing JSDoc `@throws` type\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/jsdoc/require_throws_type.rs","lineNumber":12,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    rule::Rule,\n    utils::{should_ignore_as_internal, should_ignore_as_private},\n};\n\nfn require_throws_type_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing JSDoc `@throws` type.\")\n        .with_help(\"Add {type} to `@throws` tag.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct RequireThrowsType;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Requires a type on the `@throws` tag.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// A `@throws` tag should document the type of error that may be thrown.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsdoc/require_throws_type.rs#L1-L30","documentation":"This is the oxlint `jsdoc/require-throws-type` diagnostic. It fires when a `@throws` tag on a function's JSDoc lacks the `{Type}` in curly brackets. The rule ensures the exception class is machine-readable so tooling can surface what can be thrown.","triggerScenarios":"A documented function has `@throws When the file is missing` — a description but no `{ErrorType}` in braces. The tag name `@throws` (and `@exception` alias where configured) is matched via `settings.jsdoc.tagName`.","commonSituations":"Doc comments written prose-first without exception classes; projects migrating to oxlint with the full jsdoc rule set enabled for the first time.","solutions":["Add the error type: `@throws {ENOENT} When the config file does not exist.`","Disable the rule when only descriptive `@throws` text is wanted (`\"jsdoc/require-throws-type\": \"off\"`)."],"exampleFix":"// before\n/**\n * @throws When the file is missing.\n */\nfunction readConfig(path) {}\n\n// after\n/**\n * @throws {Error} When the file is missing.\n */\nfunction readConfig(path) {}","handlingStrategy":"validation","validationCode":"// Flag @throws tags without a {Type} part\nconst src = require('fs').readFileSync(file, 'utf8');\nconst noType = /@throws\\s+[^{\\s]/.exec(src);\nif (noType) console.error('jsdoc/require-throws-type will fire:', file);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make `{ErrorType}` part of your @throws snippet/template.","Codemod legacy prose-only @throws comments when adopting the rule.","Keep oxlint in CI to catch new violations."],"tags":["jsdoc","documentation","lint","oxlint"],"backgroundTag":"jsdoc-throws-tag-missing","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}