Skip to content

eslint/no-void Restriction

🚧 An auto-fix is still under development.

What it does

Disallow void operators.

Why is this bad

The void operator is often used to obtain the undefined primitive value, but it is unnecessary. You can use undefined directly instead.

Examples

Examples of incorrect code for this rule:

ts
void 0;
var foo = void 0;

Examples of correct code for this rule:

ts
"var foo = bar()";
"foo.void()";
"foo.void = bar";

References

Released under the MIT License.