This rule raises an issue when a function call result is used, even though the function does not return anything.
When a function in JavaScript does not have a return statement or if it has a return statement without a value, it implicitly returns
undefined. This means that a function without a return statement or with an empty return statement is, in a way, a "void" function, as it
doesn’t return any specific value.
Therefore, attempting to use the return value of a void function in JavaScript is meaningless, and it can lead to unexpected behavior or errors.
function foo() {
console.log("Hello, World!");
}
let a = foo(); // Noncompliant: Assigning the return value of a void function
You should not use in any way the return value of a void function.
function foo() {
console.log("Hello, World!");
}
foo();
undefined global
property return statement