Skip to main content

array-bracket-spacing

This rule enforces consistent spacing inside array brackets.
Rule Type: Layout
Fixable: Yes (automatically fixable)
Deprecated: Consider using Prettier

Rule Details

Some style guides require or disallow spaces inside array brackets:

Options

"never" (default)

Disallow spaces inside array brackets. Incorrect:
Correct:

"always"

Require spaces inside array brackets. Incorrect:
Correct:

Exception Options

singleValue

Control spacing for single-element arrays.

objectsInArrays

Control spacing around objects in arrays.

arraysInArrays

Control spacing around nested arrays.

Configuration Examples

When Not to Use It

Most teams now use Prettier for formatting. If you use Prettier, disable this rule.
Disable if:
  • You use Prettier or another formatter
  • You don’t care about spacing consistency
  • Your team hasn’t agreed on a style