{"record":{"id":"f93d393e7c050201","repo":"astral-sh/ruff","slug":"e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty/src/rule.rs","lineNumber":54,"sourceCode":"        let status = match self.status {\n            LintStatus::Preview { since } => format!(\"Preview (since {since})\"),\n            LintStatus::Stable { since } => format!(\"Stable (since {since})\"),\n            LintStatus::Deprecated { since, reason } => {\n                format!(\"Deprecated (since {since}): {reason}\")\n            }\n            LintStatus::Removed { since, reason } => format!(\"Removed (since {since}): {reason}\"),\n        };\n\n        writeln!(f, \"Default level: {} | {status}\\n\", self.default_level)?;\n\n        f.write_str(self.documentation.trim())\n    }\n}\n\n/// Explain a single rule.\npub(crate) fn rule(name: &str, format: HelpFormat) -> Result<()> {\n    let registry = default_lint_registry();\n    let lint = registry.get(name).map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n\n    let mut stdout = BufWriter::new(io::stdout().lock());\n    match format {\n        HelpFormat::Text => {\n            writeln!(stdout, \"{}\", Explanation::from_lint(&lint))?;\n        }\n        HelpFormat::Json => {\n            serde_json::to_writer_pretty(&mut stdout, &Explanation::from_lint(&lint))?;\n        }\n    }\n    Ok(())\n}\n\n/// Explain all rules.\npub(crate) fn rules(format: HelpFormat) -> Result<()> {\n    let registry = default_lint_registry();\n    let mut lints: Vec<LintId> = registry.lints().to_vec();\n    lints.sort_by_key(|l| l.name());","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ty/src/rule.rs#L36-L72","documentation":"`ty rule <name>` looks up the requested lint rule in ty's default lint registry and wraps any registry lookup error in this anyhow error (message is the registry's own error text). It means the rule name given to `ty rule` does not match a known rule.","triggerScenarios":"Running `ty rule <name>` with a misspelled, renamed, or nonexistent rule name; using a Ruff rule code that ty does not define.","commonSituations":"Typing `ty rule ununsed-import` (typo); copying Ruff rule names that don't exist in ty; referencing a rule removed or renamed in a newer ty version.","solutions":["Check the exact rule name spelling against `ty rule --list` (or the docs)","Use the fully qualified rule name as shown in diagnostics output","If the rule was renamed in a newer version, update the name or pin the ty version"],"exampleFix":"# before\nty rule ununsed-import\n// after\nty rule unused-import","handlingStrategy":"try-catch","validationCode":"import subprocess\nknown = subprocess.run(['ty','rule','--list'], capture_output=True, text=True).stdout\nif '--rule-name--' not in known:\n    print('unknown rule')","typeGuard":null,"tryCatchPattern":"if let Err(e) = ty_rule(name, format) {\n    eprintln!(\"ty rule failed: {e}; run `ty rule --list` for valid rule names\");\n}","preventionTips":["Verify rule names with `ty rule --list` or the documentation before scripting lookups","Copy rule names directly from ty's diagnostic output rather than retyping them","Pin and read the changelog when upgrading ty, since rule names can be renamed"],"tags":["cli","lint-registry","unknown-identifier"],"backgroundTag":"unknown-rule-name","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}