Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rules/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { convertNoEmptyInterface } from "./converters/no-empty-interface";
import { convertNoEval } from "./converters/no-eval";
import { convertNoExplicitAny } from "./converters/no-explicit-any";
import { convertNoFloatingPromises } from "./converters/no-floating-promises";
import { convertNoForIn } from "./converters/no-for-in";
import { convertNoForInArray } from "./converters/no-for-in-array";
import { convertNoInferrableTypes } from "./converters/no-inferrable-types";
import { convertNoInternalModule } from "./converters/no-internal-module";
Expand Down Expand Up @@ -137,6 +138,7 @@ export const converters = new Map([
["no-empty-interface", convertNoEmptyInterface],
["no-eval", convertNoEval],
["no-floating-promises", convertNoFloatingPromises],
["no-for-in", convertNoForIn],
["no-for-in-array", convertNoForInArray],
["no-inferrable-types", convertNoInferrableTypes],
["no-internal-module", convertNoInternalModule],
Expand Down Expand Up @@ -229,7 +231,6 @@ export const converters = new Map([
// tslint-microsoft-contrib rules:
// ["max-func-body-length", convertMaxFuncBodyLength],
// ["no-empty-line-after-opening-brace", convertNoEmptyLineAfterOpeningBrace], // padded-blocks
// ["no-for-in", convertNoForIn], // no-restricted-syntax config
// ["no-function-expression", convertNoFunctionExpression], // ban-syntax config
// ["no-suspicious-comment", convertNoSuspiciousComment],
// ["no-with-statement", convertNoWithStatement],
Expand Down
14 changes: 14 additions & 0 deletions src/rules/converters/no-for-in.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { RuleConverter } from "../converter";

export const convertNoForIn: RuleConverter = tslintRule => {
return {
rules: [
{
...(tslintRule.ruleArguments.length !== 0 && {
ruleArguments: tslintRule.ruleArguments,
}),
ruleName: "no-restricted-syntax",
},
],
};
};
67 changes: 67 additions & 0 deletions src/rules/converters/tests/no-for-in.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { convertNoForIn } from "../no-for-in";

describe(convertNoForIn, () => {
test("conversion without arguments", () => {
const result = convertNoForIn({
ruleArguments: [],
});

expect(result).toEqual({
rules: [
{
ruleName: "no-restricted-syntax",
},
],
});
});
test("conversion with arguments", () => {
const result = convertNoForIn({
ruleArguments: ["error", "ForInStatement"],
});

expect(result).toEqual({
rules: [
{
ruleName: "no-restricted-syntax",
ruleArguments: ["error", "ForInStatement"],
},
],
});
});
test("conversion with object arguments", () => {
const result = convertNoForIn({
ruleArguments: [{ selector: "ForInStatement", message: "For in is not allowed." }],
});

expect(result).toEqual({
rules: [
{
ruleName: "no-restricted-syntax",
ruleArguments: [
{ selector: "ForInStatement", message: "For in is not allowed." },
],
},
],
});
});
test("conversion with mixed arguments", () => {
const result = convertNoForIn({
ruleArguments: [
"error",
{ selector: "ForInStatement", message: "For in is not allowed." },
],
});

expect(result).toEqual({
rules: [
{
ruleName: "no-restricted-syntax",
ruleArguments: [
"error",
{ selector: "ForInStatement", message: "For in is not allowed." },
],
},
],
});
});
});