Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/rules/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import { convertRadix } from "./converters/radix";
import { convertRestrictPlusOperands } from "./converters/restrict-plus-operands";
import { convertSemicolon } from "./converters/semicolon";
import { convertSpaceBeforeFunctionParen } from "./converters/space-before-function-paren";
import { convertSpaceWithinParens } from "./converters/space-within-parens";
import { convertSwitchDefault } from "./converters/switch-default";
import { convertTypedefWhitespace } from "./converters/typedef-whitespace";
import { convertTypeLiteralDelimiter } from "./converters/type-literal-delimiter";
Expand Down Expand Up @@ -225,6 +226,7 @@ export const converters = new Map([
["restrict-plus-operands", convertRestrictPlusOperands],
["semicolon", convertSemicolon],
["space-before-function-paren", convertSpaceBeforeFunctionParen],
["space-within-parens", convertSpaceWithinParens],
["switch-default", convertSwitchDefault],
["triple-equals", convertTripleEquals],
["type-literal-delimiter", convertTypeLiteralDelimiter],
Expand All @@ -247,7 +249,9 @@ export const converters = new Map([
// ["no-duplicate-variable", convertNoDuplicateVariable], // no-redeclare
// ["no-shadowed-variable", convertNoShadowedVariable], // no-shadow
// ["no-unused-expression", convertNoUnusedExpression], // no-unused-expressions
// ["space-within-parens", convertSpaceWithinParens], // space-in-parens
// ["no-void-expression", convertNoVoidExpression], // (no exact equivalent)
// ["quotemark", convertQuotemark], // quotes
// ["triple-equals", convertTripleEquals], // eqeqeq
// ["variable-name", convertVariableName], // a bunch of rules...

// tslint-microsoft-contrib rules:
Expand Down
21 changes: 21 additions & 0 deletions src/rules/converters/space-within-parens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { RuleConverter } from "../converter";

export const convertSpaceWithinParens: RuleConverter = tslintRule => {
let arg = "never";
const notices = [];

if (tslintRule.ruleArguments.length === 1) {
arg = "always";
notices.push("The number of spaces will be ignored");
}

return {
rules: [
{
ruleArguments: [arg],
ruleName: "@typescript-eslint/space-within-parens",
notices,
},
],
};
};
35 changes: 35 additions & 0 deletions src/rules/converters/tests/space-within-parens.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { convertSpaceWithinParens } from "../space-within-parens";

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

expect(result).toEqual({
rules: [
{
ruleArguments: ["never"],
ruleName: "@typescript-eslint/space-within-parens",
notices: [],
},
],
});
});

test("conversion with min spaces arguement", () => {
const result = convertSpaceWithinParens({
ruleArguments: [5],
});

expect(result).toEqual({
rules: [
{
ruleArguments: ["always"],
ruleName: "@typescript-eslint/space-within-parens",
notices: ["The number of spaces will be ignored"],
},
],
});
});
});