Require explicit accessibility modifiers on class properties and methods.
// code-linter.json5
{
"rules": {
"@typescript-eslint/explicit-member-accessibility": "error"
}
} export class Animal {
private animalName: string; // Property
public constructor(name: string) {
// Parameter property and constructor
this.animalName = name;
}
public get name(): string {
// get accessor
return this.animalName;
}
public set name(value: string) {
// set accessor
this.animalName = value;
}
public walk() {
// method
}
} export class Animal {
private animalName: string; // Property
constructor(name: string) {
// Parameter property and constructor
this.animalName = name;
}
get name(): string {
// get accessor
return this.animalName;
}
set name(value: string) {
// set accessor
this.animalName = value;
}
walk() {
// method
}
} plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.