Rule: invalid-void

Disallows usage of void type outside of generic or return types. If void is used as return type, it shouldn’t be a part of intersection/union type.

Rationale

The void type means “nothing” or that a function does not return any value, in contra with implicit undefined type which means that a function returns a value undefined. So “nothing” cannot be mixed with any other types. If you need this - use undefined type instead.

Notes:
TS Only

Config

If allow-generics is specified as false, then generic types will no longer be allowed to to be void. Alternately, provide an array of strings for allow-generics to exclusively allow generic types by those names.

Config examples
"invalid-void": true
"invalid-void": [true, {"allow-generics": false}]
"invalid-void": [true, {"allow-generics": ["Promise", "PromiseLike"]}]
Schema
{
  "type": "object",
  "properties": {
    "allow-generics": {
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minLength": 1
        }
      ]
    }
  },
  "additionalProperties": false
}