Skip to content

Commit f66f585

Browse files
committed
add converter for space-within-parens rule
1 parent 9cc263f commit f66f585

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

src/rules/converters.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import { convertPromiseFunctionAsync } from "./converters/promise-function-async
9797
import { convertRadix } from "./converters/radix";
9898
import { convertRestrictPlusOperands } from "./converters/restrict-plus-operands";
9999
import { convertSpaceBeforeFunctionParen } from "./converters/space-before-function-paren";
100+
import { convertSpaceWithinParens } from "./converters/space-within-parens";
100101
import { convertSwitchDefault } from "./converters/switch-default";
101102
import { convertTypedefWhitespace } from "./converters/typedef-whitespace";
102103
import { convertTypeLiteralDelimiter } from "./converters/type-literal-delimiter";
@@ -210,6 +211,7 @@ export const converters = new Map([
210211
["prefer-readonly", convertPreferReadonly],
211212
["prefer-template", convertPreferTemplate],
212213
["space-before-function-paren", convertSpaceBeforeFunctionParen],
214+
["space-within-parens", convertSpaceWithinParens],
213215
["switch-default", convertSwitchDefault],
214216
["no-banned-terms", convertNoBannedTerms],
215217
["no-constant-condition", convertNoConstantCondition],
@@ -222,12 +224,12 @@ export const converters = new Map([
222224
["quotemark", convertQuotemark],
223225
["triple-equals", convertTripleEquals],
224226

225-
// These converters are all for rules that need more complex option conversions.
226-
// Some of them will likely need to have notices about changed lint behaviors...
227-
// If you're willing to take on that work, that'd be great! Please send PRs! 💖
228-
// As these are enabled, they should be added in sorted order to the list above.
227+
// these converters are all for rules that need more complex option conversions.
228+
// some of them will likely need to have notices about changed lint behaviors...
229+
// if you're willing to take on that work, that'd be great! Please send PRs! 💖
230+
// as these are enabled, they should be added in sorted order to the list above.
229231

230-
// TSLint core rules:
232+
// tSLint core rules:
231233
// ["ban", convertBan], // no-restricted-properties
232234
// ["import-blacklist", convertImportBlacklist], // no-restricted-imports
233235
// ["newline-before-return", convertNewlineBeforeReturn],
@@ -236,7 +238,8 @@ export const converters = new Map([
236238
// ["no-trailing-whitespace", convertNoTrailingWhitespace], // no-trailing-spaces
237239
// ["no-unused-expression", convertNoUnusedExpression], // no-unused-expressions
238240
// ["no-void-expression", convertNoVoidExpression], // (no exact equivalent)
239-
// ["space-within-parens", convertSpaceWithinParens], // space-in-parens
241+
// ["quotemark", convertQuotemark], // quotes
242+
// ["triple-equals", convertTripleEquals], // eqeqeq
240243
// ["variable-name", convertVariableName], // a bunch of rules...
241244

242245
// tslint-microsoft-contrib rules:
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)