Skip to content

Rule proposal: Boolean variable naming #515

Closed
@sindresorhus

Description

@sindresorhus

I would like to enforce that variables and properties with a boolean use the prefix is, has, can, did, and will. For example: .visible.isVisible.

I often see .visible, .open, etc, in code, and it's not clear whether they are booleans, contain something visible/open, or whether they contain a function that makes something visible or opens something.

Fail

const visible = true;

const rainbow = false;

Pass

const isVisible = true;

const hasRainbow = false;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement: new plugin ruleNew rule request for eslint-pluginhas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions