Skip to content

Commit 4a10b3f

Browse files
committed
add converter for space-within-parens rule
1 parent c3fb72e commit 4a10b3f

File tree

3 files changed

+90
-6
lines changed

3 files changed

+90
-6
lines changed

src/rules/converters.ts

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import { convertRadix } from "./converters/radix";
103103
import { convertRestrictPlusOperands } from "./converters/restrict-plus-operands";
104104
import { convertSemicolon } from "./converters/semicolon";
105105
import { convertSpaceBeforeFunctionParen } from "./converters/space-before-function-paren";
106+
import { convertSpaceWithinParens } from "./converters/space-within-parens";
106107
import { convertSwitchDefault } from "./converters/switch-default";
107108
import { convertTypedefWhitespace } from "./converters/typedef-whitespace";
108109
import { convertTypeLiteralDelimiter } from "./converters/type-literal-delimiter";
@@ -235,19 +236,56 @@ export const converters = new Map([
235236
["unnecessary-constructor", convertUnnecessaryConstructor],
236237
["use-default-type-parameter", convertUseDefaultTypeParameter],
237238
["use-isnan", convertUseIsnan],
239+
["arrow-return-shorthand", convertArrowReturnShorthand],
240+
["curly", convertCurly],
241+
["cyclomatic-complexity", convertCyclomaticComplexity],
242+
["increment-decrement", convertIncrementDecrement],
243+
["linebreak-style", convertLinebreakStyle],
244+
["max-classes-per-file", convertMaxClassesPerFile],
245+
["max-file-line-count", convertMaxFileLineCount],
246+
["max-line-length", convertMaxLineLength],
247+
["no-consecutive-blank-lines", convertNoConsecutiveBlankLines],
248+
["no-console", convertNoConsole],
249+
["no-empty", convertNoEmpty],
250+
["no-invalid-template-strings", convertNoInvalidTemplateStrings],
251+
["no-invalid-this", convertNoInvalidThis],
252+
["no-magic-numbers", convertNoMagicNumbers],
253+
["object-literal-key-quotes", convertObjectLiteralKeyQuotes],
254+
["object-literal-shorthand", convertObjectLiteralShorthand],
255+
["one-variable-per-declaration", convertOneVariablePerDeclaration],
256+
["only-arrow-functions", convertOnlyArrowFunctions],
257+
["prefer-const", convertPreferConst],
258+
["prefer-function-over-method", convertPreferFunctionOverMethod],
259+
["prefer-readonly", convertPreferReadonly],
260+
["prefer-template", convertPreferTemplate],
261+
["space-before-function-paren", convertSpaceBeforeFunctionParen],
262+
["space-within-parens", convertSpaceWithinParens],
263+
["switch-default", convertSwitchDefault],
264+
["no-banned-terms", convertNoBannedTerms],
265+
["no-constant-condition", convertNoConstantCondition],
266+
["no-control-regex", convertNoControlRegex],
267+
["no-multiline-string", convertNoMultilineString],
268+
["no-invalid-regexp", convertNoInvalidRegexp],
269+
["no-octal-literal", convertNoOctalLiteral],
270+
["no-regex-spaces", convertNoRegexSpaces],
271+
["no-unnecessary-semicolons", convertNoUnnecessarySemicolons],
272+
["quotemark", convertQuotemark],
273+
["triple-equals", convertTripleEquals],
238274

239-
// These converters are all for rules that need more complex option conversions.
240-
// Some of them will likely need to have notices about changed lint behaviors...
241-
// If you're willing to take on that work, that'd be great! Please send PRs! 💖
242-
// As these are enabled, they should be added in sorted order to the list above.
275+
// these converters are all for rules that need more complex option conversions.
276+
// some of them will likely need to have notices about changed lint behaviors...
277+
// if you're willing to take on that work, that'd be great! Please send PRs! 💖
278+
// as these are enabled, they should be added in sorted order to the list above.
243279

244-
// TSLint core rules:
280+
// tSLint core rules:
245281
// ["ban", convertBan], // no-restricted-properties
246282
// ["import-blacklist", convertImportBlacklist], // no-restricted-imports
247283
// ["no-duplicate-variable", convertNoDuplicateVariable], // no-redeclare
248284
// ["no-shadowed-variable", convertNoShadowedVariable], // no-shadow
249285
// ["no-unused-expression", convertNoUnusedExpression], // no-unused-expressions
250-
// ["space-within-parens", convertSpaceWithinParens], // space-in-parens
286+
// ["no-void-expression", convertNoVoidExpression], // (no exact equivalent)
287+
// ["quotemark", convertQuotemark], // quotes
288+
// ["triple-equals", convertTripleEquals], // eqeqeq
251289
// ["variable-name", convertVariableName], // a bunch of rules...
252290

253291
// 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)