javascript.lang.correctness.missing-template-string-indicator.missing-template-string-indicator
semgrep
Author
1,772
Download Count*
License
This looks like a JavaScript template string. Are you missing a '$' in front of '{...}'?
Run Locally
Run in CI
Defintion
rules:
- id: missing-template-string-indicator
patterns:
- pattern-inside: |
`...`
- pattern: $STR
- metavariable-regex:
metavariable: $STR
regex: .*[^$]+{[^{}]*}.*
languages:
- javascript
- typescript
message: This looks like a JavaScript template string. Are you missing a '$' in
front of '{...}'?
severity: INFO
metadata:
category: correctness
technology:
- js
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
Examples
missing-template-string-indicator.js
function name() {
// ok: missing-template-string-indicator
return `this is ${start.line}`
}
function ok() {
// ok: missing-template-string-indicator
`test`;
if (true) { a = 3; }
`test`;
}
function name2() {
// ruleid: missing-template-string-indicator
return `this is {start.line}`
}
function name3() {
// ok: missing-template-string-indicator
return "this is ${start.line}"
}
function name3() {
// ok: missing-template-string-indicator
return "this is {start.line}"
}
Short Link: https://sg.run/K8O9