Files
codeql/javascript/ql/test/query-tests/LanguageFeatures/TemplateSyntaxInStringLiteral/TemplateSyntaxInStringLiteral.js
Asger F 10a7294327 JS: Accept trivial test changes
This adds Alert annotations for alerts that seem intentional by the test
but has not been annotated with 'NOT OK', or the comment was in the wrong
place.

In a few cases I included 'Source' expectations to make it easier to see
what happened. Other 'Source' expectations will be added in bulk a later
commit.
2025-02-28 13:27:43 +01:00

43 lines
1000 B
JavaScript

function connectAndLog(id) {
log.info(`Connecting to ${id}`)
let connection = openConnection(id)
if (!connection) {
log.error('Could not connect to ${id}') // $ Alert
}
}
function emitTemplate(name, date) {
writer.emit("Name: ${name}, Date: ${date}",
{ name: name, date: date });
}
var globalVar = "global";
function foo() {
log.error('globalVar = ${globalVar}'); // $ Alert
}
log.error('globalVar = ${globalVar}'); // $ Alert
function bar() {
log.error('Something ${notInScope}');
}
function baz(x){
log.error("${x}");
log.error("${y}");
log.error("${x} "); // $ Alert
log.error("${y} ");
}
function foo1() {
const aTemplateLitInScope = `Connecting to ${id}`;
const name = 2;
const date = 3;
const foobar = 4;
const data = {name: name, date: date};
writer.emit("Name: ${name}, Date: ${date}.", data);
writer.emit("Name: ${name}, Date: ${date}, ${foobar}", data); // $ Alert - `foobar` is not in `data`.
}