{"record":{"id":"39210f4279c2941a","repo":"oxc-project/oxc","slug":"name-is-used-outside-of-binding-context","errorCode":null,"errorMessage":"'{name}' is used outside of binding context.","messagePattern":"'(.+?)' is used outside of binding context\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/block_scoped_var.rs","lineNumber":15,"sourceCode":"use crate::{AstNode, context::LintContext, rule::Rule};\nuse oxc_ast::{\n    AstKind,\n    ast::{BindingPattern, VariableDeclarationKind},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_ecmascript::BoundNames;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::Scoping;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::Ident;\nuse oxc_syntax::{scope::ScopeId, symbol::SymbolId};\n\nfn redeclaration_diagnostic(decl_span: Span, redeclare_span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"'{name}' is used outside of binding context.\"))\n        .with_help(format!(\"Variable '{name}' is used outside its declaration block. Declare it outside the block or use 'let'/'const'.\"))\n        .with_labels([\n            redeclare_span.label(\"it is redeclared here\"),\n            decl_span.label(format!(\"'{name}' is first declared here\")),\n        ])\n}\nfn use_outside_scope_diagnostic(decl_span: Span, used_span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"'{name}' is used outside of binding context.\"))\n        .with_help(format!(\"Variable '{name}' is used outside its declaration block. Declare it outside the block or use 'let'/'const'.\"))\n        .with_labels([\n            used_span.label(format!(\"'{name}' is used here\")),\n            decl_span.label(\"It is declared in a different scope here\"),\n        ])\n}\n\n#[derive(Debug, Default, Clone)]\npub struct BlockScopedVar;\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/block_scoped_var.rs#L1-L33","documentation":"Lint diagnostic from eslint/block-scoped-var: a variable declared with var is referenced in a scope where its binding is no longer in context (typically redeclaration analysis across scopes). var's function-level hoisting makes such uses confusing and error-prone compared to block-scoped bindings.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/block_scoped_var.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace var with let or const so the binding matches the block where it is used","Move the usage inside the scope in which the variable is declared","Rename colliding declarations in nested scopes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}