Zum Inhalt springen

Boolean prefix (ARCH3007)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.naming.boolean-prefix · Severity info · Category naming

Boolean-typed members and accessors should carry an interrogative prefix (is/has/can/should). Without one, conditionals read unnaturally and intent becomes unclear.

class User {
active: boolean = false;
admin: boolean = false;
delete(): boolean {
return this.admin;
}
}
class User {
isActive: boolean = false;
isAdmin: boolean = false;
canDelete(): boolean {
return this.isAdmin;
}
}

Add an appropriate interrogative prefix to the boolean member: is, has, can, or should.