I'm wondering what modifiers should I use for properties and methods in Vue classes? (I use vue-class-component
package). public
, private
, protected
?
Or should I turn off the linter rule that says I need to set an access modifier?
Here is an example component:
@Component({
components: { MyChildComponent }
})
export default class MyComponent extends Vue {
// props
@Prop({ type: String, default: '' }) public readonly value!: string
@Prop({ type: Array, default: () => [] }) public readonly myProp1!: any
@Prop({
type: [Array, Object],
default: () => ({})
}) public readonly myProp2!: any
// data variables
public myVar1: MyClass | null = null
public myVar2: boolean = false
// computed
public get isDisabled (): boolean {
// code...
}
// watch
@Watch('value')
public onValueChange (val) {
// code...
}
// hook
public mounted () {
// code...
}
// method
public setMenuItem () {
// code...
}
}
"member-access": [true, "no-public"]
for TSLint – Cleat