Rule: member-access
Requires explicit visibility declarations for class members.
Rationale
Explicit visibility declarations can make code more readable and accessible for those new to TS.
Other languages such as C# default to private, unlike TypeScript’s default of public.
Members lacking a visibility declaration may be an indication of an accidental leak of class internals.
Notes:
TS Only
Has Fixer
Config
These arguments may be optionally provided:
"no-public"forbids public accessibility to be specified, because this is the default."check-accessor"enforces explicit visibility on get/set accessors"check-constructor"enforces explicit visibility on constructors"check-parameter-property"enforces explicit visibility on parameter properties
Config examples
"member-access": true
"member-access": [true, "no-public"]
"member-access": [true, "check-accessor"]
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"no-public",
"check-accessor",
"check-constructor",
"check-parameter-property"
]
},
"minLength": 0,
"maxLength": 4
}