1 # disallow the unary operators `++` and `--` (no-plusplus)
3 Because the unary `++` and `--` operators are subject to automatic semicolon insertion, differences in whitespace can change semantics of source code.
26 This rule disallows the unary operators `++` and `--`.
28 Examples of **incorrect** code for this rule:
31 /*eslint no-plusplus: "error"*/
39 for (i = 0; i < l; i++) {
44 Examples of **correct** code for this rule:
47 /*eslint no-plusplus: "error"*/
55 for (i = 0; i < l; i += 1) {
62 This rule has an object option.
64 * `"allowForLoopAfterthoughts": true` allows unary operators `++` and `--` in the afterthought (final expression) of a `for` loop.
66 ### allowForLoopAfterthoughts
68 Examples of **correct** code for this rule with the `{ "allowForLoopAfterthoughts": true }` option:
71 /*eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }]*/
73 for (i = 0; i < l; i++) {
77 for (i = l; i >= 0; i--) {
81 for (i = 0, j = l; i < l; i++, j--) {
86 Examples of **incorrect** code for this rule with the `{ "allowForLoopAfterthoughts": true }` option:
89 /*eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }]*/
91 for (i = 0; i < l; j = i++) {
99 for (i = 0; i < l;) i++;