consistent-boolean-name

August 13, 2026 Β· View on GitHub

πŸ“ Enforce consistent naming for boolean names.

πŸ’ΌπŸš« This rule is enabled in the βœ… recommended config. This rule is disabled in the β˜‘οΈ unopinionated config.

πŸ”§πŸ’‘ This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

By default, this rule checks boolean variables, parameters, and functions. Object, class, and TypeScript property and method names are ignored unless enabled with their respective options.

Each check* option accepts one of these modes:

  • always: require prefixes for booleans and reject misleading prefixes on non-booleans.
  • prohibit: only reject misleading prefixes on non-booleans.
  • never: skip the occurrence entirely.

Boolean names should start with a prefix that makes the boolean meaning clear.

Names that start with a boolean prefix should also refer to booleans or boolean-returning functions. Unknown values are ignored.

Callable type annotations returning boolean, Promise<boolean>, PromiseLike<boolean>, or unions of these are considered boolean-returning.

When type information is unavailable, unannotated async functions are not considered boolean-returning when requiring a prefix.

Configured wrapper bindings may use boolean prefixes when a configured property or method provides a boolean-like value. This applies only to variables and parameters that are not reassigned.

Reports for property and method names, and reports for non-boolean values using boolean prefixes, do not provide rename suggestions.

The default prefixes are:

  • is
  • are
  • has
  • have
  • can
  • should
  • was
  • were
  • did
  • will
  • requires

The plural prefixes (are, have, were) allow names for boolean collections, like areFilesValid.

The prefix must be a distinct word part. isReady, is_ready, and IS_READY are allowed, but island is not considered to have the is prefix.

React hook function bindings are checked after the required use prefix. For example, useIsReady is treated as a boolean hook name, while useReady is not. ignore patterns still match the original source name, like useReady.

React refs initialized with a boolean-like value may use boolean prefixes when the binding name ends in Ref or Reference, such as isMountedRef, hasConsentRef, or hasConsentReference. The suffix identifies the binding as a ref object. The binding must not be reassigned after initialization.

Direct Vue ref() calls with boolean-like values and computed() calls with boolean-returning functions may use boolean prefixes, such as isBranch or hasDepartment. The binding must not be reassigned after initialization.

This rule intentionally does not check destructuring bindings, imports, class names, or catch parameters.

TypeScript type annotation checks resolve local type aliases and callable interfaces, including generic type parameters, but not qualified or namespaced type references.

This rule is only automatically fixable when a non-global, non-exported, non-ambient variable binding can be safely renamed to the first enabled prefix without adding a collision suffix. Other safe rename candidates are still provided as editor suggestions.

Examples

// ❌
const completed = true;

// βœ…
const isCompleted = true;
// ❌
const hasName = 'Sindre';

// βœ…
const name = 'Sindre';
// ❌
function hasTitle() {
	return 'Unicorn';
}

// βœ…
function getTitle() {
	return 'Unicorn';
}
// ❌
const completed = progress === 100;

// βœ…
const hasCompleted = progress === 100;
// ❌
const completed = Boolean(value);

// βœ…
const isCompleted = Boolean(value);
// ❌
function download(showProgress = false) {}

// βœ…
function download(shouldShowProgress = false) {}
// ❌
const completed: boolean = true;

// βœ…
const isCompleted: boolean = true;
// ❌
function completed() {
	return true;
}

// βœ…
function isCompleted() {
	return true;
}
// ❌
function download(showProgress: boolean) {}

// βœ…
function download(shouldShowProgress: boolean) {}
// βœ…
// Object fields are ignored unless `checkFields` is set to a mode other than `never`.
// Methods and getters use `checkMethods`. Setter names are ignored because setters do not return values.
const task = {
	completed: progress === 100,
};

Options

checkVariables

Type: 'always' | 'prohibit' | 'never'
Default: 'always'

How to check variable names.

'unicorn/consistent-boolean-name': [
	'error',
	{
		checkVariables: 'prohibit',
	},
]

With checkVariables: 'prohibit', this would fail:

const hasName = 'Sindre';

And these would pass:

const completed = true;
const isCompleted = true;

checkArguments

Type: 'always' | 'prohibit' | 'never'
Default: 'always'

How to check parameter names, including TypeScript constructor parameter properties. Setter parameters are ignored because their names are positional. For example, checkArguments: 'never' allows both forms:

function download(showProgress = false) {}
function download(shouldShowProgress = false) {}

checkFunctions

Type: 'always' | 'prohibit' | 'never'
Default: 'always'

How to check function names.

checkMethods

Type: 'always' | 'prohibit' | 'never'
Default: 'never'

How to check object and class methods, getters, and TypeScript method signatures. Setter names are ignored because setters do not return values.

checkFields

Type: 'always' | 'prohibit' | 'never'
Default: 'never'

How to check object properties, class fields, TypeScript property signatures, and TypeScript constructor parameter properties. Constructor parameter properties are checked as both arguments and fields.

'unicorn/consistent-boolean-name': [
	'error',
	{
		checkMethods: 'always',
		checkFields: 'never',
	},
]

With the above config, this would fail:

class Task {
	hasTitle() {
		return 'Unicorn';
	}
}

And this would pass:

class Task {
	completed = true;
	isCompleted() {
		return true;
	}
}

prefixes

Type: Record<string, boolean>
Default:

{
	is: true,
	are: true,
	has: true,
	have: true,
	can: true,
	should: true,
	was: true,
	were: true,
	did: true,
	will: true,
	requires: true,
}

The prefixes option is merged with the defaults. Set a prefix to true to allow it for boolean names and reserve it for boolean-like values. Set a prefix to false to disable it in both directions.

'unicorn/consistent-boolean-name': [
	'error',
	{
		prefixes: {
			needs: true,
			did: false,
		},
	},
]

With the above config, this would pass:

const needsUpdate = true;

And this would fail:

const didUpdate = true;

wrappers

Type: Record<string, string>
Default: {}

Map unqualified TypeScript wrapper type names to the property or method that provides a boolean-like value. Same-named types share configuration. Derived types, intersections, and constrained type parameters are supported. Members may provide boolean, Promise<boolean>, or PromiseLike<boolean>; nullable results are accepted. Requires TypeScript type information.

'unicorn/consistent-boolean-name': [
	'error',
	{
		wrappers: {
			StorageItem: 'get',
		},
	},
]

With the above configuration, this would pass:

interface StorageItem<Base, Return = Base | undefined> {
	get(): Promise<Return>;
}

declare const isUnicorn: StorageItem<unknown, boolean>;

But this would still fail because get() returns a string:

interface StorageItem<Base, Return = Base | undefined> {
	get(): Promise<Return>;
}

declare const isUnicorn: StorageItem<unknown, string>;

ignore

Type: Array<string | RegExp>
Default: []

Names matching any of these patterns are not checked. Strings are treated as regular expressions, so they match anywhere in the name unless anchored with ^ and $.

'unicorn/consistent-boolean-name': [
	'error',
	{
		ignore: [
			'value',
			'^completed$',
		],
	},
]

With the above config, these would pass:

const value = true;
const completed = true;