{"record":{"id":"9a1f0bf1988a6ef2","repo":"oxc-project/oxc","slug":"assignment-of-parameter-property-is-unnecessary","errorCode":null,"errorMessage":"Assignment of parameter property is unnecessary","messagePattern":"Assignment of parameter property is unnecessary","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/no_unnecessary_parameter_property_assignment.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{\n        AssignmentExpression, AssignmentOperator, AssignmentTarget, ClassElement, Expression,\n        FormalParameter, Function, MethodDefinitionKind, Statement,\n    },\n};\nuse oxc_ast_visit::VisitJs;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::ScopeFlags;\nuse oxc_span::Span;\nuse oxc_str::Str;\nuse rustc_hash::FxHashSet;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_unnecessary_parameter_property_assignment_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Assignment of parameter property is unnecessary\")\n        .with_help(\"Remove the unnecessary assignment\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnnecessaryParameterPropertyAssignment;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Prevents unnecessary assignment of parameter properties.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Constructor parameters marked with one of the visibility modifiers\n    /// public, private, protected, or readonly are automatically initialized.\n    /// Providing an explicit assignment is unnecessary and can be removed.\n    ///","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_unnecessary_parameter_property_assignment.rs#L1-L37","documentation":"Raised by typescript/no-unnecessary-parameter-property-assignment when a constructor body assigns a value to a parameter property that already has that value via its modifier (e.g. constructor(public x = 1) { this.x = 1; }).","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/no_unnecessary_parameter_property_assignment.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the redundant assignment in the constructor body.","Keep the initializer on the parameter property only."],"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"}