eslint-plugin

@masknet/prefer-early-return

Prefer early returns over full-body conditional wrapping in function declarations

Rule Details

Options

/**
 * @minItems Infinity
 */
export type Options = [
  {
    maximumStatements?: number
  },
]

:x: Incorrect

function foo() {
  if (foo) {
    bar()
    baz()
  }
}

:white_check_mark: Correct

function foo() {
  if (!foo) return
  bar()
  baz()
}

Attributes