requireSpacesInsideBrackets

Requires space after opening square bracket and before closing. Reports on all on brackets, even on property accessors. Use requireSpacesInsideArrayBrackets to exclude property accessors.

Types: Boolean or Object

Values:

  • Boolean
    • true: strict mode
  • Object:
    • "allExcept": Array specifying list of tokens that can occur after an opening square bracket or before a closing square bracket without a space

Example

"requireSpacesInsideBrackets": true
"requireSpacesInsideBrackets": {
    "allExcept": [ "[", "]", "{", "}" ]
}
Valid for mode true
var x = [ 1 ];
var x = a[ 1 ];
Valid for mode { allExcept": [ "[", "]", "{", "}" ] }
var x = [[ 1 ], [ 2 ]];
var x = [{ a: 1 }, { b: 2}];
Invalid
var x = [1];
Rule source
Test source