diff --git a/javascript/ql/src/Declarations/DeadStoreOfLocal.ql b/javascript/ql/src/Declarations/DeadStoreOfLocal.ql index 375279406f9..4877062a84e 100644 --- a/javascript/ql/src/Declarations/DeadStoreOfLocal.ql +++ b/javascript/ql/src/Declarations/DeadStoreOfLocal.ql @@ -68,5 +68,7 @@ where not exists(SsaImplicitInit init | init.getVariable().getSourceVariable() = v) // the variable is dead at the hoisted implicit initialization. then msg = "The initial value of " + v.getName() + " is unused, since it is always overwritten." else msg = "The value assigned to " + v.getName() + " here is unused." - ) + ) and + // ignore Angular templates + not dead.(ASTNode).getTopLevel() instanceof Angular2::TemplateTopLevel select dead, msg diff --git a/javascript/ql/src/Declarations/DeadStoreOfProperty.ql b/javascript/ql/src/Declarations/DeadStoreOfProperty.ql index 8fac34cfb84..d0866768bc5 100644 --- a/javascript/ql/src/Declarations/DeadStoreOfProperty.ql +++ b/javascript/ql/src/Declarations/DeadStoreOfProperty.ql @@ -299,7 +299,9 @@ where assign1 instanceof CallToObjectDefineProperty implies assign1.(CallToObjectDefineProperty).hasPropertyAttributeWrite("value", _) - ) + ) and + // ignore Angular templates + not assign1.getTopLevel() instanceof Angular2::TemplateTopLevel select assign1.getWriteNode(), "This write to property '" + name + "' is useless, since $@ always overrides it.", assign2.getWriteNode(), "another property write" diff --git a/javascript/ql/src/Expressions/ExprHasNoEffect.qll b/javascript/ql/src/Expressions/ExprHasNoEffect.qll index 3818834f529..220eef15a4a 100644 --- a/javascript/ql/src/Expressions/ExprHasNoEffect.qll +++ b/javascript/ql/src/Expressions/ExprHasNoEffect.qll @@ -164,5 +164,7 @@ predicate hasNoEffect(Expr e) { top = e.getParent().(ExprStmt).getParent() and top.getNumChild() = 1 and not exists(Function fun | fun.getEnclosingContainer() = top) - ) + ) and + // ignore Angular templates + not e.getTopLevel() instanceof Angular2::TemplateTopLevel } diff --git a/javascript/ql/src/LanguageFeatures/SyntaxError.ql b/javascript/ql/src/LanguageFeatures/SyntaxError.ql index 6f6ac10a8cc..d4428c75774 100644 --- a/javascript/ql/src/LanguageFeatures/SyntaxError.ql +++ b/javascript/ql/src/LanguageFeatures/SyntaxError.ql @@ -13,4 +13,5 @@ import javascript from JSParseError pe +where not pe.getTopLevel() instanceof Angular2::TemplateTopLevel select pe, pe.getMessage()