Fix test cases to work with Semgrep constant propagation
Semgrep will propagate string constants (docs), so we must use actual variables or user input to trigger rules that detect non-hardcoded-string inputs.
For example, eslint.detect-non-literal-regexp has the following definition
patterns:
- pattern: |
new RegExp(...)
- pattern-not: |
new RegExp("...", ...)
To see this rule fire, we must change the test case from
var myregexpText = "/abcd/";
var myregexp = new RegExp(myregexpText);
to
function dangerous_regexp(myregexpText) {
var myregexp = new RegExp(myregexpText);
}