{"record":{"id":"f93d393e7c050201","repo":"astral-sh/ruff","slug":"e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ty/src/rule.rs","lineNumber":53,"sourceCode":"\n        let status = match self.status {\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":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty/src/rule.rs#L35-L71","documentation":"`ty rule <name>` resolves the argument through the default lint registry; this anyhow wrapper just forwards the registry's `GetLintError` Display text. In practice the message is one of: `Unknown rule \\`name\\`` (optionally with `Did you mean \\`...\\`?` from fuzzy matching), `Removed rule \\`name\\``, or the prefixed-with-category form that suggests the unprefixed name — all meaning the given name does not resolve to a currently selectable lint.","triggerScenarios":"`ty rule unresolved-imports` (typo), passing a name that was removed in an earlier ty release (registry entry now `LintStatus::Removed`), or passing a name that still carries its category prefix; the registry suggests a close name when one exists.","commonSituations":"Copy-pasting rule names from older docs, issue threads, or `# ty: ignore` comments; scripts that loop over rule names and feed them to `ty rule`; shell-history typos.","solutions":["Apply the `Did you mean ...` suggestion printed in the error, if present","List exact current names with `ty rules` (or `ty rules --format json`) and copy the name verbatim","For a `Removed rule` message, read the removal version/reason shown by the registry and switch to the replacement rule"],"exampleFix":"# before\nty rule unresolveed-import\n# after (use the suggested/actual name)\nty rule unresolved-import","handlingStrategy":"validation","validationCode":"ty rules | grep -Fx \"$RULE_NAME\" >/dev/null \\\n  || { echo \"unknown rule: $RULE_NAME\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source rule names from `ty rules` output rather than docs or memory","Prefer the `Did you mean` suggestion over hand-correcting typos","When scripts loop over rule names, validate the list against `ty rules --format json` first"],"tags":["ty","cli","lint-rules","registry","validation"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}