no-misused-spread
Added in v0.1.4Configuration
Rule Details
Disallows spread syntax (...) in places where the type being spread would produce unexpected behavior. This includes spreading strings in arrays (which can mishandle special characters and emojis), spreading arrays in object literals (producing a list of indices rather than values), spreading Promises in objects (which yields an empty object), spreading Maps in objects (also producing an empty object), spreading functions without properties, spreading class instances (losing the prototype), and spreading class declarations (only copying static properties).
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Differences from upstream
Map-spread suggestions preserve necessary token separation: return{ ...map }
becomes return Object.fromEntries(map). They also preserve authored comments,
lint directives and line endings. When comments surround the spread argument,
the suggestion keeps parentheses and existing whitespace so line comments cannot
change return, throw or yield behavior.