Enforce consistent spacing before and after the arrow in arrow functions
Some problems reported by this rule are automatically fixable by the --fix
command line option
This rule normalize style of spacing before/after an arrow function’s arrow(=>
).
/*eslint-env es6*/
// { "before": true, "after": true }
(a) => {}
// { "before": false, "after": false }
(a)=>{}
This rule takes an object argument with before
and after
properties, each with a Boolean value.
The default configuration is { "before": true, "after": true }
.
true
means there should be one or more spaces and false
means no spaces.
Examples of incorrect code for this rule with the default { "before": true, "after": true }
option:
Examples of correct code for this rule with the default { "before": true, "after": true }
option:
Examples of incorrect code for this rule with the { "before": false, "after": false }
option:
Examples of correct code for this rule with the { "before": false, "after": false }
option:
Examples of incorrect code for this rule with the { "before": false, "after": true }
option:
Examples of correct code for this rule with the { "before": false, "after": true }
option:
This rule was introduced in ESLint v1.0.0-rc-1.
© OpenJS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/latest/rules/arrow-spacing