Skip to content

Commit e6b3818

Browse files
bpallaresJosh Goldberg
authored and
Josh Goldberg
committed
Adds no-for-in converter along with tests (#194)
* Adds no-for-in converter along with tests * Fixes tests and coverter
1 parent a99478c commit e6b3818

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/rules/converters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { convertNoEmptyInterface } from "./converters/no-empty-interface";
4545
import { convertNoEval } from "./converters/no-eval";
4646
import { convertNoExplicitAny } from "./converters/no-explicit-any";
4747
import { convertNoFloatingPromises } from "./converters/no-floating-promises";
48+
import { convertNoForIn } from "./converters/no-for-in";
4849
import { convertNoForInArray } from "./converters/no-for-in-array";
4950
import { convertNoInferrableTypes } from "./converters/no-inferrable-types";
5051
import { convertNoInternalModule } from "./converters/no-internal-module";
@@ -142,6 +143,7 @@ export const converters = new Map([
142143
["no-empty-interface", convertNoEmptyInterface],
143144
["no-eval", convertNoEval],
144145
["no-floating-promises", convertNoFloatingPromises],
146+
["no-for-in", convertNoForIn],
145147
["no-for-in-array", convertNoForInArray],
146148
["no-inferrable-types", convertNoInferrableTypes],
147149
["no-internal-module", convertNoInternalModule],
@@ -236,7 +238,6 @@ export const converters = new Map([
236238
// tslint-microsoft-contrib rules:
237239
// ["max-func-body-length", convertMaxFuncBodyLength],
238240
// ["no-empty-line-after-opening-brace", convertNoEmptyLineAfterOpeningBrace], // padded-blocks
239-
// ["no-for-in", convertNoForIn], // no-restricted-syntax config
240241
// ["no-function-expression", convertNoFunctionExpression], // ban-syntax config
241242
// ["no-suspicious-comment", convertNoSuspiciousComment],
242243
// ["no-with-statement", convertNoWithStatement],

src/rules/converters/no-for-in.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertNoForIn: RuleConverter = () => {
4+
return {
5+
rules: [
6+
{
7+
ruleArguments: ["ForInStatement"],
8+
ruleName: "no-restricted-syntax",
9+
},
10+
],
11+
};
12+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { convertNoForIn } from "../no-for-in";
2+
3+
describe(convertNoForIn, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoForIn({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "no-restricted-syntax",
13+
ruleArguments: ["ForInStatement"],
14+
},
15+
],
16+
});
17+
});
18+
});

0 commit comments

Comments
 (0)