Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 770262d

Browse files
committed
[bug] fixed checking of the template strings in tsr-detect-non-literal-require rule
1 parent a0cb1cb commit 770262d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

npm-shrinkwrap.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tslint-config-security",
3-
"version": "1.6.0",
3+
"version": "1.7.0",
44
"description": "TSLint security rules",
55
"main": "./index.js",
66
"scripts": {

src/rules/tsrDetectNonLiteralRequireRule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class RuleWalker extends Lint.RuleWalker {
1616
expression &&
1717
expression.text === 'require' &&
1818
firstArgument &&
19-
firstArgument.kind !== ts.SyntaxKind.StringLiteral
19+
firstArgument.kind !== ts.SyntaxKind.StringLiteral &&
20+
firstArgument.kind !== ts.SyntaxKind.NoSubstitutionTemplateLiteral
2021
) {
2122
this.addFailureAtNode(node, 'Found non-literal argument in require');
2223
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
require('path');
2+
require(`path`);
3+
require(`${path}`);
4+
~~~~~~~~~~~~~~~~~~ [Found non-literal argument in require]
25
require(path);
36
~~~~~~~~~~~~~ [Found non-literal argument in require]

0 commit comments

Comments
 (0)