typescript/class-literal-property-style Style
What it does
Enforces a consistent style for exposing literal values on classes.
Why is this bad?
Mixing readonly fields and trivial literal getters for the same kind of value makes class APIs inconsistent and harder to scan.
Examples
Examples of incorrect code for this rule (default "fields"):
ts
class C {
get name() {
return "oxc";
}
}Examples of correct code for this rule:
ts
class C {
readonly name = "oxc";
}How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"typescript/class-literal-property-style": "error"
}
}bash
oxlint --deny typescript/class-literal-property-style