Skip to content

Commit 9df14a2

Browse files
da-snapJosh Goldberg
authored and
Josh Goldberg
committed
Add missing converter: newline-before-return (#203)
To #164
1 parent d775a8d commit 9df14a2

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/rules/converters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { convertMaxClassesPerFile } from "./converters/max-classes-per-file";
2525
import { convertMaxFileLineCount } from "./converters/max-file-line-count";
2626
import { convertMaxLineLength } from "./converters/max-line-length";
2727
import { convertMemberOrdering } from "./converters/member-ordering";
28+
import { convertNewlineBeforeReturn } from "./converters/newline-before-return";
2829
import { convertNewlinePerChainedCall } from "./converters/newline-per-chained-call";
2930
import { convertNewParens } from "./converters/new-parens";
3031
import { convertNoAngleBracketTypeAssertion } from "./converters/no-angle-bracket-type-assertion";
@@ -133,6 +134,7 @@ export const converters = new Map([
133134
["member-access", convertMemberAccess],
134135
["member-ordering", convertMemberOrdering],
135136
["new-parens", convertNewParens],
137+
["newline-before-return", convertNewlineBeforeReturn],
136138
["newline-per-chained-call", convertNewlinePerChainedCall],
137139
["no-angle-bracket-type-assertion", convertNoAngleBracketTypeAssertion],
138140
["no-any", convertNoExplicitAny],
@@ -232,7 +234,6 @@ export const converters = new Map([
232234
// TSLint core rules:
233235
// ["ban", convertBan], // no-restricted-properties
234236
// ["import-blacklist", convertImportBlacklist], // no-restricted-imports
235-
// ["newline-before-return", convertNewlineBeforeReturn],
236237
// ["no-duplicate-variable", convertNoDuplicateVariable], // no-redeclare
237238
// ["no-shadowed-variable", convertNoShadowedVariable], // no-shadow
238239
// ["no-trailing-whitespace", convertNoTrailingWhitespace], // no-trailing-spaces
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertNewlineBeforeReturn: RuleConverter = () => {
4+
return {
5+
rules: [
6+
{
7+
ruleName: "padding-line-between-statements",
8+
ruleArguments: [
9+
"error",
10+
{
11+
blankLine: "always",
12+
prev: "*",
13+
next: "return",
14+
},
15+
],
16+
},
17+
],
18+
};
19+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { convertNewlineBeforeReturn } from "../newline-before-return";
2+
3+
describe(convertNewlineBeforeReturn, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNewlineBeforeReturn({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "padding-line-between-statements",
13+
ruleArguments: [
14+
"error",
15+
{
16+
blankLine: "always",
17+
next: "return",
18+
prev: "*",
19+
},
20+
],
21+
},
22+
],
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)