ntnyq/no-member-accessibility
Disallow usage of typescript member accessibility.
- 🔧 The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule reports usage of TypeScript member accessibility.
Constructor parameter properties without readonly are reported without an automatic fix. Removing their accessibility modifier would turn them into ordinary parameters and remove the emitted instance field assignment. Rewrite these as explicit fields and assignments when removing the modifier manually.
ts
class Test {
x: number
constructor(x: number) {
this.x = x
}
get internalValue() {
return this.x
}
set internalValue(value: number) {
this.x = value
}
square(): number {
return this.x * this.x
}
half(): number {
return this.x / 2
}
}correct
ts
class Test {
private x: number
public constructor(x: number) {
this.x = x
}
protected get internalValue() {
return this.x
}
protected set internalValue(value: number) {
this.x = value
}
public square(): number {
return this.x * this.x
}
private half(): number {
return this.x / 2
}
}incorrect
🔧 Options
Nothing.
🚀 Version
This rule was introduced in eslint-plugin-ntnyq v0.0.1