noMeaninglessVoidOperator (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noMeaninglessVoidOperator - This rule has an unsafe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noMeaninglessVoidOperator": "error" } } }}Description
Section titled “Description”Disallow void when it does not discard a call’s return value or a thenable.
Using void communicates that a value is deliberately ignored. Applying it to
a call that already returns void or undefined obscures that intent and can
hide changes to the called API. Non-call operands are also reported, except
for thenables and the common void 0 idiom.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”declare function log(): void;void log();/invalid-call.ts:2:1 lint/nursery/noMeaninglessVoidOperator FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This void operator is unnecessary.
1 │ declare function log(): void;
> 2 │ void log();
│ ^^^^^^^^^^
3 │
ℹ This call already returns void or undefined.
ℹ Use void to explicitly discard a call's return value or a thenable.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Remove the void operator.
1 1 │ declare function log(): void;
2 │ - void·log();
2 │ + (log());
3 3 │
void 1;/invalid-value.js:1:1 lint/nursery/noMeaninglessVoidOperator FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This void operator is unnecessary.
> 1 │ void 1;
│ ^^^^^^
2 │
ℹ This operand is neither a function call nor a thenable.
ℹ Use void to explicitly discard a call's return value or a thenable.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Remove the void operator.
1 │ - void·1;
1 │ + (1);
2 2 │
declare function value(): number;void value();void Promise.resolve();void 0;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.