noVoid
Diagnostic Category: lint/complexity/noVoid
Since: v1.0.0
Sources:
- Same as:
no-void
Disallow the use of void
operators, which is not a familiar operator.
The
void
operator is often used merely to obtain the undefined primitive value, usually usingvoid(0)
(which is equivalent tovoid 0
). In these cases, the global variableundefined
can be used.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:1 lint/complexity/noVoid ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The use of void is not allowed.
> 1 │ void 0;
│ ^^^^^^
2 │
ℹ If you use void to alter the return type of a function or return undefined
, use the global undefined
instead.