close

no-void

Added in v0.8.1

Configuration

rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-void': 'error',
    },
  },
]);

Rule Details

Disallow use of the void operator.

Examples of incorrect code for this rule:

void foo;
void someFunction();

const foo = void bar();
function baz() {
  return void 0;
}

Options

allowAsStatement

When true, permits void as a standalone statement but still prohibits its use in expression contexts such as variable assignments or return statements. Default: false.

Examples of incorrect code for this rule with { "allowAsStatement": true }:

{ "no-void": ["error", { "allowAsStatement": true }] }
const foo = void bar();
function baz() {
  return void 0;
}

Examples of correct code for this rule with { "allowAsStatement": true }:

{ "no-void": ["error", { "allowAsStatement": true }] }
void foo;
void someFunction();

Original Documentation