The length property should not be misspelled as lenght

  • LENGTH_PROPERTY_TYPO
  • Error
  • Medium
  • No tags

This rule applies when the length property is misspelled as lenght.

lenght is a common typo of length. Accessing the non-existent lenght property results in undefined value.

Noncompliant Code Example

View with compliant examples side by side
function isNonEmptyArray(x) {
    return Array.isArray(x) && x.lenght !== 0; // LENGTH_PROPERTY_TYPO alarm because 'lenght' is a typo.
}

Compliant Code Example

View with noncompliant examples side by side
function isNonEmptyArray(x) {
    return Array.isArray(x) && x.length !== 0;
}

Version

This rule was introduced in DeepScan 1.32.0.

Was this documentation helpful?