-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): [no-misused-spread] add suggestions (#10719)
* temp * implement * implement * fix * merge * fix * add tests * Update no-misused-spread.test.ts * appy reviews --------- Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
- Loading branch information
1 parent
e7cb832
commit a43c199
Showing
5 changed files
with
382 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/eslint-plugin/src/util/isHigherPrecedenceThanAwait.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as ts from 'typescript'; | ||
|
||
import { getOperatorPrecedence } from './getOperatorPrecedence'; | ||
|
||
export function isHigherPrecedenceThanAwait(tsNode: ts.Node): boolean { | ||
const operator = ts.isBinaryExpression(tsNode) | ||
? tsNode.operatorToken.kind | ||
: ts.SyntaxKind.Unknown; | ||
const nodePrecedence = getOperatorPrecedence(tsNode.kind, operator); | ||
const awaitPrecedence = getOperatorPrecedence( | ||
ts.SyntaxKind.AwaitExpression, | ||
ts.SyntaxKind.Unknown, | ||
); | ||
return nodePrecedence > awaitPrecedence; | ||
} |
Oops, something went wrong.