Skip to content

Commit 75101d4

Browse files
Merge pull request #29860 from RyanCavanaugh/noEval
Enable no-eval rule
2 parents f93f4f3 + 02a5ef6 commit 75101d4

File tree

7 files changed

+13
-1
lines changed

7 files changed

+13
-1
lines changed

src/harness/evaluator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ namespace evaluator {
5656
}
5757

5858
const evaluateText = `(function (module, exports, require, __dirname, __filename, ${globalNames.join(", ")}) { ${output.text} })`;
59+
// tslint:disable-next-line:no-eval
5960
const evaluateThunk = eval(evaluateText) as (module: any, exports: any, require: (id: string) => any, dirname: string, filename: string, ...globalArgs: any[]) => void;
6061
const module: { exports: any; } = { exports: {} };
6162
evaluateThunk.call(globals, module, module.exports, noRequire, vpath.dirname(output.file), output.file, FakeSymbol, ...globalArgs);

src/harness/fourslash.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3159,6 +3159,7 @@ ${code}
31593159
const debug = new FourSlashInterface.Debug(state);
31603160
const format = new FourSlashInterface.Format(state);
31613161
const cancellation = new FourSlashInterface.Cancellation(state);
3162+
// tslint:disable-next-line:no-eval
31623163
const f = eval(wrappedCode);
31633164
f(test, goTo, plugins, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, FourSlashInterface.Completion, verifyOperationIsCancelled);
31643165
}

src/harness/harness.ts

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ namespace Utils {
7777
const environment = getExecutionEnvironment();
7878
switch (environment) {
7979
case ExecutionEnvironment.Browser:
80+
// tslint:disable-next-line:no-eval
8081
eval(fileContents);
8182
break;
8283
case ExecutionEnvironment.Node:

src/harness/harnessLanguageService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ namespace Harness.LanguageService {
766766
}
767767

768768
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
769+
// tslint:disable-next-line:ban
769770
return setTimeout(callback, ms, args);
770771
}
771772

src/testRunner/parallel/host.ts

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ namespace Harness.Parallel.Host {
302302
worker.timer = undefined;
303303
}
304304
else {
305+
// tslint:disable-next-line:ban
305306
worker.timer = setTimeout(killChild, data.payload.duration, data.payload);
306307
}
307308
break;
@@ -623,6 +624,7 @@ namespace Harness.Parallel.Host {
623624
shimNoopTestInterface(global);
624625
}
625626

627+
// tslint:disable-next-line:ban
626628
setTimeout(() => startDelayed(perfData, totalCost), 0); // Do real startup on next tick, so all unit tests have been collected
627629
}
628630
}

src/tsserver/server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ namespace ts.server {
705705
// stat due to inconsistencies of fs.watch
706706
// and efficiency of stat on modern filesystems
707707
function startWatchTimer() {
708+
// tslint:disable-next-line:ban
708709
setInterval(() => {
709710
let count = 0;
710711
let nextToCheck = nextFileToCheck;

tslint.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"no-unnecessary-type-assertion": true,
66

77
"array-type": [true, "array"],
8+
"ban": [
9+
true,
10+
"setInterval",
11+
"setTimeout"
12+
],
813
"ban-types": {
914
"options": [
1015
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
@@ -34,6 +39,7 @@
3439
],
3540
"no-bom": true,
3641
"no-double-space": true,
42+
"no-eval": true,
3743
"no-in-operator": true,
3844
"no-increment-decrement": true,
3945
"no-inferrable-types": true,
@@ -100,7 +106,6 @@
100106
"no-console": false,
101107
"no-debugger": false,
102108
"no-empty-interface": false,
103-
"no-eval": false,
104109
"no-object-literal-type-assertion": false,
105110
"no-shadowed-variable": false,
106111
"no-submodule-imports": false,

0 commit comments

Comments
 (0)