no-value-tostring
Disallow calling .toString() on values that may not provide meaningful output.
โ ๏ธ This rule requires type information to run.
Targeted pattern scopeโ
This rule targets .toString() and related stringification calls in typed
TypeScript code.
What this rule reportsโ
This rule reports stringification that could produce unhelpful default object representations.
Why this rule existsโ
Calling .toString() on broad object types can produce "[object Object]"
instead of useful text. This rule reports potentially unsafe stringification.
โ Incorrectโ
const value: {} = {};
value.toString();
โ Correctโ
const value = 42;
value.toString();
Behavior and migration notesโ
This rule forwards options to @typescript-eslint/no-base-to-string.
- Lifecycle: Deprecated and frozen.
- Deprecated since:
v1.0.0 - Available until:
v2.0.0 - Use instead:
@typescript-eslint/no-base-to-string
Additional examplesโ
declare const value: {};
String(value);
// โ reported by forwarded `no-base-to-string` behavior
declare const value: Date;
value.toString();
// โ
valid
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-value-tostring": "error",
},
},
];
When not to use itโ
Disable this rule if your codebase intentionally permits object default stringification and that behavior is covered by runtime tests.
Package documentationโ
Rule catalog ID: R051
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.