Skip to main content

no-string-length-0

Disallows checking for empty strings via the length method in favor of direct comparison to an empty string, since the latter is shorter and easier to read.

Rule Details

// Bad
declare const foo: string;
if (foo.length === 0) {
}

// Good
declare const foo: string;
if (foo === "") {
}

Options and Defaults

{
"rules": {
"complete/no-string-length-0": "error"
}
}

This rule is not configurable.

Resources