explicit-member-accessibility
Configuration
Rule Details
This rule reports class members and parameter properties whose accessibility
declarations don't match the configured policy. With the default explicit
mode, every class member and parameter property must be declared public,
private, or protected. Switching the policy to no-public flips the rule:
any redundant public modifier is reported (and removed by the autofix). Set
the policy to off to disable the check for that member kind.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule accepts an options object with the following properties:
accessibility: top-level policy applied to every member kind unless overridden. One of'explicit'(default),'no-public','off'.ignoredMethodNames: list of method names to skip entirely. Method name matching uses the same name normalization as the diagnostic message (identifier text,#namefor private fields, the literal value for string / numeric literal keys).overrides: per-kind overrides. Each entry overridesaccessibilityfor that member kind:accessors— getters and setters.constructors— constructors.methods— regular methods (not getters/setters/constructors).parameterProperties—public/private/protected/readonlyparameters of a constructor.properties— class fields, including auto-accessor (accessor x) and abstract properties.
accessibility: 'no-public'
Examples of incorrect code with this option:
Examples of correct code with this option:
overrides
Examples of correct code with mixed overrides:
ignoredMethodNames
Examples of correct code with { "ignoredMethodNames": ["getX"] }: