skip expressions that are alone in a file for js/useless-expression

This commit is contained in:
Erik Krogh Kristensen
2020-05-04 09:08:41 +02:00
parent 33f4503ac3
commit cee986fa76

View File

@@ -158,5 +158,7 @@ predicate hasNoEffect(Expr e) {
// exclude block-level flow type annotations. For example: `(name: empty)`.
not e.(ParExpr).getExpression().getLastToken().getNextToken().getValue() = ":" and
// exclude the first statement of a try block
not e = any(TryStmt stmt).getBody().getStmt(0).(ExprStmt).getExpr()
not e = any(TryStmt stmt).getBody().getStmt(0).(ExprStmt).getExpr() and
// exclude expressions that are alone in a file
not e.getParent().(ExprStmt).getParent().(TopLevel).getNumChild() = 1
}