Skip to content

Commit 104fc0e

Browse files
committed
add converter for space-within-parens rule
1 parent c77f1b1 commit 104fc0e

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

src/rules/converters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import { convertPromiseFunctionAsync } from "./converters/promise-function-async
9191
import { convertRadix } from "./converters/radix";
9292
import { convertRestrictPlusOperands } from "./converters/restrict-plus-operands";
9393
import { convertSpaceBeforeFunctionParen } from "./converters/space-before-function-paren";
94+
import { convertSpaceWithinParens } from "./converts/space-within-parens";
9495
import { convertSwitchDefault } from "./converters/switch-default";
9596
import { convertTypedefWhitespace } from "./converters/typedef-whitespace";
9697
import { convertTypeLiteralDelimiter } from "./converters/type-literal-delimiter";
@@ -196,6 +197,7 @@ export const converters = new Map([
196197
["prefer-function-over-method", convertPreferFunctionOverMethod],
197198
["prefer-template", convertPreferTemplate],
198199
["space-before-function-paren", convertSpaceBeforeFunctionParen],
200+
["space-within-parens", convertSpaceWithinParens],
199201
["switch-default", convertSwitchDefault],
200202
["no-banned-terms", convertNoBannedTerms],
201203
["no-constant-condition", convertNoConstantCondition],
@@ -222,7 +224,6 @@ export const converters = new Map([
222224
// ["no-unused-expression", convertNoUnusedExpression], // no-unused-expressions
223225
// ["no-void-expression", convertNoVoidExpression], // (no exact equivalent)
224226
// ["quotemark", convertQuotemark], // quotes
225-
// ["space-within-parens", convertSpaceWithinParens], // space-in-parens
226227
// ["triple-equals", convertTripleEquals], // eqeqeq
227228
// ["variable-name", convertVariableName], // a bunch of rules...
228229

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertSpaceWithinParens: RuleConverter = tslintRule => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: tslintRule.ruleArguments,
9+
}),
10+
ruleName: "@typescript-eslint/space-within-parens",
11+
},
12+
],
13+
};
14+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { convertSpaceWithinParens } from "../space-within-parens";
2+
3+
describe(convertSpaceWithinParens, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertSpaceWithinParens({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "@typescript-eslint/space-within-parens",
13+
},
14+
],
15+
});
16+
});
17+
18+
test("conversion with min spaces arguement", () => {
19+
const result = convertSpaceWithinParens({
20+
ruleArguments: [5],
21+
});
22+
23+
expect(result).toEqual({
24+
rules: [
25+
{
26+
ruleArguments: [5],
27+
ruleName: "@typescript-eslint/space-within-parens",
28+
},
29+
],
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)