Skip to content

Rule proposal: prevent function spread into object #3333

Closed
@pbadenski

Description

@pbadenski

Repro

function f() { }
const o = { ...f }; 

Expected Result
Error on line 2 - spreading function into object.

Actual Result

No error - and nothing happens (spreading a plain function into object doesn't do anything afaik).

Additional Info

Detecting this is very useful when someone is attempting to spread the result of a function call, but actually accidentally spreads the function itself.

Versions

package version
@typescript-eslint/eslint-plugin 4.22.0
@typescript-eslint/parser 4.22.0
TypeScript 4.1.5
ESLint 7.24.0
node 15.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions