Disallow whitespace before properties (no-whitespace-before-property)

The --fix option on the command line automatically fixes problems reported by this rule.

JavaScript allows whitespace between objects and their properties. However, inconsistent spacing can make code harder to read and can lead to errors.

foo.bar.baz.quz

Rule Details

This rule alerts for whitespace around the dot or before the opening bracket before properties of objects if they are on the same line. It does not alert for whitespace when the object and property are on separate lines, as it is common to add newlines to longer chains of properties:

foo.bar().baz().qux()

The following patterns are considered problems when this rule is turned on: