no-writeonly
Disallow setter-only accessors.
Deprecated
- Lifecycle: Deprecated, frozen, and non-recommended.
- Deprecated since:
v3.0.0 - Available until:
v4.0.0 - Use instead: ESLint core
accessor-pairs
This rule is a direct runtime proxy of accessor-pairs and adds no independent
analysis. Migrate the options unchanged to the core rule ID.
Targeted pattern scope
This rule targets object and class accessors.
What this rule reports
This rule reports setters that do not have corresponding getters.
Why this rule exists
Write-only properties hide state flow and make object behavior harder to debug.
❌ Incorrect
const state = {
set value(next: number) {
this._value = next;
},
};
✅ Correct
const state = {
_value: 0,
get value() {
return this._value;
},
set value(next: number) {
this._value = next;
},
};
Behavior and migration notes
This rule forwards options and behavior to ESLint core accessor-pairs.
Additional examples
class Box {
set value(next: number) {
this._value = next;
}
}
// ❌ reported
class BoxFixed {
_value = 0;
get value() {
return this._value;
}
set value(next: number) {
this._value = next;
}
}
// ✅ valid
ESLint flat config example
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-writeonly": "error",
},
},
];
When not to use it
Disable this rule if you intentionally use write-only sink objects and the pattern is documented.
Package documentation
Rule catalog ID: R072
Further reading
Adoption resources
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.