Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/rules/converters/max-line-length.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ export const convertMaxLineLength: RuleConverter = tslintRule => {
};

const collectArguments = (ruleArguments: any[]) => {
if (ruleArguments.length === 0 || ruleArguments[0] === false || ruleArguments.length < 2) {
if (ruleArguments.length === 0) {
return undefined;
}

if (ruleArguments.length === 2 && typeof ruleArguments[1] === "number") {
const argument = ruleArguments[0];

if (typeof argument === "number") {
return {
ruleArguments: [
{
code: ruleArguments[1],
code: argument,
},
],
};
}

const argument = ruleArguments[1];

return {
ruleArguments: [
{
Expand Down
39 changes: 3 additions & 36 deletions src/rules/converters/tests/max-line-length.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,9 @@ describe(convertMaxLineLength, () => {
});
});

test("conversion with one argument true value", () => {
test("conversion with one argument number", () => {
const result = convertMaxLineLength({
ruleArguments: [true],
});

expect(result).toEqual({
rules: [
{
ruleName: "max-len",
},
],
});
});

test("conversion with two arguments and first is false", () => {
const result = convertMaxLineLength({
ruleArguments: [false, 123],
});

expect(result).toEqual({
rules: [
{
ruleName: "max-len",
},
],
});
});

test("conversion with two arguments and second is number", () => {
const result = convertMaxLineLength({
ruleArguments: [true, 123],
ruleArguments: [123],
});

expect(result).toEqual({
Expand All @@ -58,10 +30,9 @@ describe(convertMaxLineLength, () => {
});
});

test("conversion with two arguments and second is object", () => {
test("conversion with one object argument", () => {
const result = convertMaxLineLength({
ruleArguments: [
true,
{
limit: 123,
"ignore-pattern": "^import |^export {(.*?)}",
Expand Down Expand Up @@ -91,7 +62,6 @@ describe(convertMaxLineLength, () => {
test("conversion with check-strings inverting value true to false", () => {
const result = convertMaxLineLength({
ruleArguments: [
true,
{
limit: 123,
"check-strings": true,
Expand All @@ -117,7 +87,6 @@ describe(convertMaxLineLength, () => {
test("conversion with check-strings inverting value false to true", () => {
const result = convertMaxLineLength({
ruleArguments: [
true,
{
limit: 123,
"check-strings": false,
Expand All @@ -143,7 +112,6 @@ describe(convertMaxLineLength, () => {
test("conversion with check-regex inverting value true to false", () => {
const result = convertMaxLineLength({
ruleArguments: [
true,
{
limit: 123,
"check-regex": true,
Expand All @@ -169,7 +137,6 @@ describe(convertMaxLineLength, () => {
test("conversion with check-regex inverting value false to true", () => {
const result = convertMaxLineLength({
ruleArguments: [
true,
{
limit: 123,
"check-regex": false,
Expand Down