Skip to content

Commit a85ce11

Browse files
aspondaJosh Goldberg
authored and
Josh Goldberg
committed
fix: corrected arguments for max-line-length converter (#201)
1 parent 9cc263f commit a85ce11

File tree

2 files changed

+8
-41
lines changed

2 files changed

+8
-41
lines changed

src/rules/converters/max-line-length.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ export const convertMaxLineLength: RuleConverter = tslintRule => {
1212
};
1313

1414
const collectArguments = (ruleArguments: any[]) => {
15-
if (ruleArguments.length === 0 || ruleArguments[0] === false || ruleArguments.length < 2) {
15+
if (ruleArguments.length === 0) {
1616
return undefined;
1717
}
1818

19-
if (ruleArguments.length === 2 && typeof ruleArguments[1] === "number") {
19+
const argument = ruleArguments[0];
20+
21+
if (typeof argument === "number") {
2022
return {
2123
ruleArguments: [
2224
{
23-
code: ruleArguments[1],
25+
code: argument,
2426
},
2527
],
2628
};
2729
}
2830

29-
const argument = ruleArguments[1];
30-
3131
return {
3232
ruleArguments: [
3333
{

src/rules/converters/tests/max-line-length.test.ts

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,9 @@ describe(convertMaxLineLength, () => {
1515
});
1616
});
1717

18-
test("conversion with one argument true value", () => {
18+
test("conversion with one argument number", () => {
1919
const result = convertMaxLineLength({
20-
ruleArguments: [true],
21-
});
22-
23-
expect(result).toEqual({
24-
rules: [
25-
{
26-
ruleName: "max-len",
27-
},
28-
],
29-
});
30-
});
31-
32-
test("conversion with two arguments and first is false", () => {
33-
const result = convertMaxLineLength({
34-
ruleArguments: [false, 123],
35-
});
36-
37-
expect(result).toEqual({
38-
rules: [
39-
{
40-
ruleName: "max-len",
41-
},
42-
],
43-
});
44-
});
45-
46-
test("conversion with two arguments and second is number", () => {
47-
const result = convertMaxLineLength({
48-
ruleArguments: [true, 123],
20+
ruleArguments: [123],
4921
});
5022

5123
expect(result).toEqual({
@@ -58,10 +30,9 @@ describe(convertMaxLineLength, () => {
5830
});
5931
});
6032

61-
test("conversion with two arguments and second is object", () => {
33+
test("conversion with one object argument", () => {
6234
const result = convertMaxLineLength({
6335
ruleArguments: [
64-
true,
6536
{
6637
limit: 123,
6738
"ignore-pattern": "^import |^export {(.*?)}",
@@ -91,7 +62,6 @@ describe(convertMaxLineLength, () => {
9162
test("conversion with check-strings inverting value true to false", () => {
9263
const result = convertMaxLineLength({
9364
ruleArguments: [
94-
true,
9565
{
9666
limit: 123,
9767
"check-strings": true,
@@ -117,7 +87,6 @@ describe(convertMaxLineLength, () => {
11787
test("conversion with check-strings inverting value false to true", () => {
11888
const result = convertMaxLineLength({
11989
ruleArguments: [
120-
true,
12190
{
12291
limit: 123,
12392
"check-strings": false,
@@ -143,7 +112,6 @@ describe(convertMaxLineLength, () => {
143112
test("conversion with check-regex inverting value true to false", () => {
144113
const result = convertMaxLineLength({
145114
ruleArguments: [
146-
true,
147115
{
148116
limit: 123,
149117
"check-regex": true,
@@ -169,7 +137,6 @@ describe(convertMaxLineLength, () => {
169137
test("conversion with check-regex inverting value false to true", () => {
170138
const result = convertMaxLineLength({
171139
ruleArguments: [
172-
true,
173140
{
174141
limit: 123,
175142
"check-regex": false,

0 commit comments

Comments
 (0)