1 # require spacing around infix operators (space-infix-ops)
3 While formatting preferences are very personal, a number of style guides require spaces around operators, such as:
9 The proponents of these extra spaces believe it make the code easier to read and can more easily highlight potential errors, such as:
15 While this is valid JavaScript syntax, it is hard to determine what the author intended.
19 This rule is aimed at ensuring there are spaces around infix operators.
23 This rule accepts a single options argument with the following defaults:
26 "space-infix-ops": ["error", { "int32Hint": false }]
31 Set the `int32Hint` option to `true` (default is `false`) to allow write `a|0` without space.
34 var foo = bar|0; // `foo` is forced to be signed 32 bit integer
37 Examples of **incorrect** code for this rule:
40 /*eslint space-infix-ops: "error"*/
58 Examples of **correct** code for this rule:
61 /*eslint space-infix-ops: "error"*/
74 function foo(a = 0) { }
79 You can turn this rule off if you are not concerned with the consistency of spacing around infix operators.