Skip to content

Commit a8266de

Browse files
authored
fix(prefer-arrow-functions): Allow allowStandaloneDeclarations by default (#1719)
1 parent a2cf0c3 commit a8266de

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/converters/lintConfigs/rules/ruleConverters/only-arrow-functions.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@ import { RuleConverter } from "../ruleConverter";
33
export const convertOnlyArrowFunctions: RuleConverter = (tslintRule) => {
44
const notices: string[] = [];
55

6-
if (tslintRule.ruleArguments.includes("allow-declarations")) {
7-
notices.push("ESLint does not support allowing standalone function declarations.");
8-
}
9-
106
if (tslintRule.ruleArguments.includes("allow-named-functions")) {
117
notices.push(
12-
"ESLint does not support allowing named functions defined with the function keyword.",
8+
"ESLint (eslint-plugin-prefer-arrow plugin) does not support allowing named functions defined with the function keyword.",
139
);
1410
}
1511

1612
return {
1713
rules: [
1814
{
1915
...(notices.length !== 0 && { notices }),
16+
ruleArguments: [
17+
{
18+
...(tslintRule.ruleArguments.includes("allow-declarations") && {
19+
allowStandaloneDeclarations: true,
20+
}),
21+
},
22+
],
2023
ruleName: "prefer-arrow/prefer-arrow-functions",
2124
},
2225
],

src/converters/lintConfigs/rules/ruleConverters/tests/only-arrow-functions.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe("convertOnlyArrowFunctions", () => {
1212
plugins: ["eslint-plugin-prefer-arrow"],
1313
rules: [
1414
{
15+
ruleArguments: [{}],
1516
ruleName: "prefer-arrow/prefer-arrow-functions",
1617
},
1718
],
@@ -27,7 +28,11 @@ describe("convertOnlyArrowFunctions", () => {
2728
plugins: ["eslint-plugin-prefer-arrow"],
2829
rules: [
2930
{
30-
notices: ["ESLint does not support allowing standalone function declarations."],
31+
ruleArguments: [
32+
{
33+
allowStandaloneDeclarations: true,
34+
},
35+
],
3136
ruleName: "prefer-arrow/prefer-arrow-functions",
3237
},
3338
],
@@ -44,8 +49,9 @@ describe("convertOnlyArrowFunctions", () => {
4449
rules: [
4550
{
4651
notices: [
47-
"ESLint does not support allowing named functions defined with the function keyword.",
52+
"ESLint (eslint-plugin-prefer-arrow plugin) does not support allowing named functions defined with the function keyword.",
4853
],
54+
ruleArguments: [{}],
4955
ruleName: "prefer-arrow/prefer-arrow-functions",
5056
},
5157
],
@@ -62,8 +68,12 @@ describe("convertOnlyArrowFunctions", () => {
6268
rules: [
6369
{
6470
notices: [
65-
"ESLint does not support allowing standalone function declarations.",
66-
"ESLint does not support allowing named functions defined with the function keyword.",
71+
"ESLint (eslint-plugin-prefer-arrow plugin) does not support allowing named functions defined with the function keyword.",
72+
],
73+
ruleArguments: [
74+
{
75+
allowStandaloneDeclarations: true,
76+
},
6777
],
6878
ruleName: "prefer-arrow/prefer-arrow-functions",
6979
},

0 commit comments

Comments
 (0)