Rule: no-unused-expression
Disallows unused expression statements.
Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).
Rationale
Detects potential errors where an assignment or function call was intended.
Config
Three arguments may be optionally provided:
allow-fast-null-checksallows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g.e && e.preventDefault()).allow-newallows ‘new’ expressions for side effects (e.g.new ModifyGlobalState();.allow-tagged-templateallows tagged templates for side effects (e.g.this.add\foo`;`.
Config examples
"no-unused-expression": true
"no-unused-expression": [true, "allow-fast-null-checks"]
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-fast-null-checks",
"allow-new",
"allow-tagged-template"
]
},
"minLength": 0,
"maxLength": 3
}