Skip to content

False positives + query ideas for variables with leading underscores. #655

Closed
@s0

Description

@s0

js/unused-local-variable has some false positives for variables that are intentionally unused, e.g. for array destructuring, etc...

An example can be seen in Shopify/quilt#434

It's a convention that local variables with leading underscores are designed to be unread, e.g:

const [a, _, c, d, e, f] = something
// or
const [a, _b, _c, d, e, f] = something

Moreover, tslint recently temporarily deprecated their no-unused-variable rule in favour of the new compiler flags which take leading underscores into account.

I suggest we:

  • ignore variables that start with an underscore in js/unused-local-variable
  • create a new query that finds variables that suggests they should be unused, but are actually used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions