sindresorhus/eslint-plugin-unicorn

Rule proposal: mistaken parentheses

Chiusa

#1796 aperta il 19 apr 2022

 (7 commenti) (2 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

Description

There's a certain type of errors that can be hard to spot and will work fine. Since it's valid to do operations like || in this context is it even possible to have a rule that could notice when you might have meant the other one?

Fail

This is what you wrote

str.startsWith('str' || str.startsWith('str'))

Pass

This is what you meant

str.startsWith('str') || str.startsWith('str')

Additional Info

No response

Guida contributor