-
Notifications
You must be signed in to change notification settings - Fork 887
Conversation
@@ -111,6 +111,10 @@ export class Replacement { | |||
return replacements.reduce((text, r) => r.apply(text), content); | |||
} | |||
|
|||
public static deleteFromTo(start: number, end: number): Replacement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use RuleWalker.deleteText(start: number, length: number)
instead?
|
||
function operatorKind(operatorToken: ts.BinaryOperatorToken): boolean | undefined { | ||
switch (operatorToken.kind) { | ||
case ts.SyntaxKind.EqualsEqualsToken: case ts.SyntaxKind.EqualsEqualsEqualsToken: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cases on separate lines
@@ -0,0 +1,30 @@ | |||
declare const x: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add cases for more complex expressions like functions, result of binary boolean expression, and negating a boolean
how about a more explicit name to clarify that this only lints for literals? |
no-boolean-compare
ruleno-boolean-literal-compare
rule
function needsParenthesesForNegate(node: ts.Expression) { | ||
switch (node.kind) { | ||
case ts.SyntaxKind.AsExpression: | ||
case ts.SyntaxKind.BinaryExpression: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a more reliable way to check?
ternary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a better way to do this, unfortunately.
A ternary operator wouldn't happen here since it ===
binds more tightly, so the ternary would have to be parenthesized already anyway.
thanks, @andy-hanson |
Remember to close #1910 |
PR checklist
What changes did you make?
Added the
no-boolean-compare
rule, which warns forx === true
.