complete/no-unsafe-plusplus
💼 This rule is enabled in the ✅ recommended config.
📝 Disallows unsafe and confusing uses of the ++ and -- operators.
💭 This rule requires type information.
Rule Details
Section titled “Rule Details”This rule heavily restricts the usage of the ++ and -- operators.
Essentially, you are only allowed to use “foo++” in places where swapping it to
“++foo” or “foo += 1” would have no functional change in the program.
This rule is meant to be used in conjunction with this
prefer-plusplus and
prefer-postfix-plusplus
ESLint rules.
// Bad(foo++, foo++, foo++);for (foo++; ;) {}for (; foo++;) {}foo++ + foo++;array[foo++];
// Goodfoo++;void foo++;(foo++, foo++, 0);for (; ; foo++) {}Options
Section titled “Options”This rule is not configurable.
Credits
Section titled “Credits”This rule was originally created by webstrand in the TypeScript Discord.
