forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplateSyntaxInStringLiteral.js
More file actions
43 lines (34 loc) · 967 Bytes
/
TemplateSyntaxInStringLiteral.js
File metadata and controls
43 lines (34 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function connectAndLog(id) {
log.info(`Connecting to ${id}`)
let connection = openConnection(id)
if (!connection) {
log.error('Could not connect to ${id}')
}
}
function emitTemplate(name, date) {
writer.emit("Name: ${name}, Date: ${date}",
{ name: name, date: date });
}
var globalVar = "global";
function foo() {
log.error('globalVar = ${globalVar}');
}
log.error('globalVar = ${globalVar}');
function bar() {
log.error('Something ${notInScope}');
}
function baz(x){
log.error("${x}");
log.error("${y}");
log.error("${x} ");
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); // OK
writer.emit("Name: ${name}, Date: ${date}, ${foobar}", data); // NOT OK - `foobar` is not in `data`.
}