Skip to content

Commit 7a4f2b5

Browse files
author
Josh Goldberg
authored
Added converter for no-exec-script (#1079)
1 parent 4df302a commit 7a4f2b5

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/converters/lintConfigs/rules/ruleConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ import { convertNoEmpty } from "./ruleConverters/no-empty";
175175
import { convertNoEmptyInterface } from "./ruleConverters/no-empty-interface";
176176
import { convertNoEmptyLineAfterOpeningBrace } from "./ruleConverters/no-empty-line-after-opening-brace";
177177
import { convertNoEval } from "./ruleConverters/no-eval";
178+
import { convertNoExecScript } from "./ruleConverters/no-exec-script";
178179
import { convertNoExplicitAny } from "./ruleConverters/no-explicit-any";
179180
import { convertNoFloatingPromises } from "./ruleConverters/no-floating-promises";
180181
import { convertNoForIn } from "./ruleConverters/no-for-in";
@@ -362,6 +363,7 @@ export const ruleConverters = new Map([
362363
["no-empty-line-after-opening-brace", convertNoEmptyLineAfterOpeningBrace],
363364
["no-empty-nested-blocks", convertNoEmptyNestedBlocks],
364365
["no-empty", convertNoEmpty],
366+
["no-exec-script", convertNoExecScript],
365367
["no-eval", convertNoEval],
366368
["no-extra-semicolon", convertNoExtraSemicolon],
367369
["no-floating-promises", convertNoFloatingPromises],
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { RuleConverter } from "../ruleConverter";
2+
3+
export const convertNoExecScript: RuleConverter = () => {
4+
return {
5+
rules: [
6+
{
7+
ruleArguments: [
8+
{
9+
message: "Forbidden call to execScript",
10+
selector: 'CallExpression[callee.name="execScript"]',
11+
}
12+
],
13+
ruleName: "restricted-syntax",
14+
},
15+
],
16+
};
17+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { convertNoExecScript } from "../no-exec-script";
2+
3+
describe(convertNoExecScript, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoExecScript({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleArguments: [
13+
{
14+
message: "Forbidden call to execScript",
15+
selector: 'CallExpression[callee.name="execScript"]',
16+
}
17+
],
18+
ruleName: "restricted-syntax",
19+
},
20+
],
21+
});
22+
});
23+
});

0 commit comments

Comments
 (0)