{"record":{"id":"805c60b2590abab0","repo":"oxc-project/oxc","slug":"missing-accessibility-modifier-on-member-type-n","errorCode":null,"errorMessage":"Missing accessibility modifier on {member_type} {name}.","messagePattern":"Missing accessibility modifier on (.+?) (.+?)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/explicit_member_accessibility.rs","lineNumber":83,"sourceCode":"    accessibility: AccessibilityLevel,\n    /// Changes to required accessibility modifiers for specific kinds of class members.\n    overrides: AccessibilityOverrides,\n    /// Specific method names that may be ignored.\n    ignored_method_names: Vec<String>,\n}\n\nimpl Default for ExplicitMemberAccessibilityConfig {\n    fn default() -> Self {\n        Self {\n            accessibility: AccessibilityLevel::Explicit,\n            overrides: AccessibilityOverrides::default(),\n            ignored_method_names: Vec::new(),\n        }\n    }\n}\n\nfn missing_accessibility_diagnostic(span: Span, member_type: &str, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Missing accessibility modifier on {member_type} {name}.\"))\n        .with_help(\"Add an explicit 'public', 'private', or 'protected' modifier. Members without a modifier are implicitly public, which may not be intentional.\")\n        .with_label(span)\n}\n\nfn unwanted_public_accessibility_diagnostic(\n    span: Span,\n    member_type: &str,\n    name: &str,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Public accessibility modifier on {member_type} {name}.\"))\n        .with_help(\"Remove the 'public' modifier. Members are public by default, so the modifier is redundant.\")\n        .with_label(span)\n}\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Require explicit accessibility modifiers on class properties and methods.","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/explicit_member_accessibility.rs#L65-L101","documentation":"typescript/explicit-member-accessibility with accessibility \"explicit\" (the default) reports class properties and methods declared without a public/protected/private modifier. The diagnostic interpolates the member kind and name. Members without a modifier are implicitly public, which the rule considers an unintentional-looking default.","triggerScenarios":"Any class field or method lacking a modifier, e.g. `class A { count = 0; greet() {} }`, while AccessibilityLevel::Explicit is configured, unless the member is covered by overrides or listed in ignoredMethodNames.","commonSituations":"Angular-style or strict API codebases that mandate explicit accessibility; enabling the typescript restriction category; auto-generated class code or quick-fixes that omit modifiers; new team members from plain JS backgrounds.","solutions":["Add the intended modifier: `private count = 0;`, `public greet(): void {}`, `protected onInit(): void`","List names that should be skipped in \"ignoredMethodNames\"","If the team decides modifiers are noise, set \"accessibility\": \"none\" to turn the rule off for missing modifiers","Use \"overrides\" to require modifiers only for specific member kinds (e.g. properties but not constructors)"],"exampleFix":"// before\nclass Account {\n  balance = 0;\n  withdraw(amount: number) {}\n}\n\n// after\nclass Account {\n  private balance = 0;\n  public withdraw(amount: number): void {}\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json\n{\n  \"rules\": {\n    \"typescript/explicit-member-accessibility\": [\n      \"warn\",\n      { \"accessibility\": \"explicit\", \"ignoredMethodNames\": [\"constructor\"] }\n    ]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use IDE code actions (add modifier) or a codemod when enabling the rule on a large codebase","Decide the convention before mixing: explicit vs no-public vs none, and set accessibility once","Add accessibility modifiers as part of the class-creation snippet template"],"tags":["typescript","lint","class","accessibility","oxlint"],"backgroundTag":"class-member-accessibility","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"}