requireSpacesInAnonymousFunctionExpression

Requires space before () or {} in anonymous function expressions.

Type: Object

Values:

  • Object with the following properties. One of "beforeOpeningRoundBrace" and "beforeOpeningCurlyBrace" must be provided:
    • "beforeOpeningRoundBrace" validates that there is a space before the opening round brace (). If provided, it must be set to true.
    • "beforeOpeningCurlyBrace" validates that there is a space before the opening curly brace {}. If provided, it must be set to true.
    • "allExcept" may be an Array containing "shorthand", or the Boolean true to enable all configuration exceptions. If "shorthand" is provided, spaces will not be required for ES6 method definitions.

Example

"requireSpacesInAnonymousFunctionExpression": {
    "beforeOpeningRoundBrace": true,
    "beforeOpeningCurlyBrace": true
}
Valid
var foo = function () {};
var Foo = {
    foo: function () {}
}
array.map(function () {});
Invalid
var foo = function() {};
var Foo = {
    foo: function (){}
}
array.map(function(){});
Rule source
Test source