{"record":{"id":"6560efc6bfc585c1","repo":"oxc-project/oxc","slug":"public-accessibility-modifier-on-member-type-na","errorCode":null,"errorMessage":"Public accessibility modifier on {member_type} {name}.","messagePattern":"Public accessibility modifier on (.+?) (.+?)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/explicit_member_accessibility.rs","lineNumber":93,"sourceCode":"            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.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// TypeScript allows placing explicit `public`, `protected`, and `private`\n    /// accessibility modifiers in front of class members. The modifiers exist\n    /// solely in the type system and serve to describe who is allowed to access\n    /// those members.\n    ///\n    /// Leaving off accessibility modifiers makes for less code to read and\n    /// write. Members are `public` by default. However, adding explicit","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/explicit_member_accessibility.rs#L75-L111","documentation":"The no-public variant of typescript/explicit-member-accessibility: when accessibility is \"no-public\", an explicit `public` modifier is reported as redundant because members are public by default. The diagnostic interpolates member type and name, mirroring @typescript-eslint/explicit-member-accessibility.","triggerScenarios":"`public greet(): void {}` or `public name: string;` in a class while the rule is configured with \"accessibility\": \"no-public\" and no override re-allows it for that member kind.","commonSituations":"Codebases that use `public` only for documentation elsewhere and standardize on omitting it; switching a repo's convention from explicit to no-public; bulk-editing classes written under the opposite convention.","solutions":["Remove the `public` keyword: `public greet(): void {}` becomes `greet(): void {}`","Run `oxlint --fix` to strip modifiers mechanically","If mixed usage is intentional, adjust \"overrides\" per member kind or switch accessibility back to \"explicit\""],"exampleFix":"// before\nclass Greeter {\n  public name: string;\n  public greet(): void {}\n}\n\n// after\nclass Greeter {\n  name: string;\n  greet(): void {}\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — the modifier is redundant under this convention\n{\n  \"rules\": {\n    \"typescript/explicit-member-accessibility\": [\"warn\", { \"accessibility\": \"no-public\" }]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `oxlint --fix` after switching conventions to strip or add modifiers mechanically","Keep the convention in the style guide so generated code matches it","Do not mix accessibility: explicit and no-public across shared configs; pick one for the org"],"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"}