From fb065ed91fb1725f417ad477f125d11dbbb87af8 Mon Sep 17 00:00:00 2001 From: Matthias Kunnen Date: Fri, 7 Feb 2020 17:29:43 +0000 Subject: [PATCH 1/2] Change notice behavior for trailing-comma esSpecCompliant eslint only supports esSpecCompliant true. --- .../converters/tests/trailing-comma.test.ts | 33 +++++++++++++++---- src/rules/converters/trailing-comma.ts | 6 ++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/rules/converters/tests/trailing-comma.test.ts b/src/rules/converters/tests/trailing-comma.test.ts index 244146be6..de15ddc85 100644 --- a/src/rules/converters/tests/trailing-comma.test.ts +++ b/src/rules/converters/tests/trailing-comma.test.ts @@ -22,24 +22,28 @@ describe(convertTrailingComma, () => { singleline: "never", }, expectedRuleArguments: [], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { singleline: "always", }, expectedRuleArguments: [], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { multiline: "never", }, expectedRuleArguments: [], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { multiline: "always", }, expectedRuleArguments: ["always-multiline"], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -47,6 +51,7 @@ describe(convertTrailingComma, () => { multiline: "never", }, expectedRuleArguments: [], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -54,6 +59,7 @@ describe(convertTrailingComma, () => { multiline: "always", }, expectedRuleArguments: ["always-multiline"], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -61,6 +67,7 @@ describe(convertTrailingComma, () => { multiline: "never", }, expectedRuleArguments: [], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -68,6 +75,7 @@ describe(convertTrailingComma, () => { multiline: "always", }, expectedRuleArguments: ["always"], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, ]; @@ -84,6 +92,7 @@ describe(convertTrailingComma, () => { ...(testCase.expectedRuleArguments.length !== 0 && { ruleArguments: testCase.expectedRuleArguments, }), + notices: testCase.expectedNotices, }, ], }); @@ -113,6 +122,7 @@ describe(convertTrailingComma, () => { exports: "always-multiline", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -134,6 +144,7 @@ describe(convertTrailingComma, () => { exports: "always", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -154,6 +165,7 @@ describe(convertTrailingComma, () => { exports: "never", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -175,6 +187,7 @@ describe(convertTrailingComma, () => { functions: "never", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -195,6 +208,7 @@ describe(convertTrailingComma, () => { exports: "always-multiline", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -222,6 +236,7 @@ describe(convertTrailingComma, () => { exports: "always", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -242,6 +257,7 @@ describe(convertTrailingComma, () => { functions: "always-multiline", }, ], + expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, ]; @@ -258,6 +274,7 @@ describe(convertTrailingComma, () => { ...(testCase.expectedRuleArguments.length && { ruleArguments: testCase.expectedRuleArguments, }), + notices: testCase.expectedNotices, }, ], }); @@ -272,7 +289,6 @@ describe(convertTrailingComma, () => { esSpecCompliant: true, }, expectedRuleArguments: [], - expectedNotices: ["ESLint does not support config property esSpecCompliant"], }, { argument: { @@ -281,7 +297,10 @@ describe(convertTrailingComma, () => { }, }, expectedRuleArguments: [{}], - expectedNotices: ["ESLint does not support config property typeLiterals"], + expectedNotices: [ + "ESLint only supports esSpecCompliant enabled", + "ESLint does not support config property typeLiterals", + ], }, { argument: { @@ -290,7 +309,10 @@ describe(convertTrailingComma, () => { }, }, expectedRuleArguments: [{}], - expectedNotices: ["ESLint does not support config property typeLiterals"], + expectedNotices: [ + "ESLint only supports esSpecCompliant enabled", + "ESLint does not support config property typeLiterals", + ], }, { argument: { @@ -301,7 +323,6 @@ describe(convertTrailingComma, () => { }, expectedRuleArguments: [{}], expectedNotices: [ - "ESLint does not support config property esSpecCompliant", "ESLint does not support config property typeLiterals", ], }, @@ -314,7 +335,7 @@ describe(convertTrailingComma, () => { }, expectedRuleArguments: [{}], expectedNotices: [ - "ESLint does not support config property esSpecCompliant", + "ESLint only supports esSpecCompliant enabled", "ESLint does not support config property typeLiterals", ], }, @@ -330,7 +351,7 @@ describe(convertTrailingComma, () => { }, expectedRuleArguments: [{}], expectedNotices: [ - "ESLint does not support config property esSpecCompliant", + "ESLint only supports esSpecCompliant enabled", "ESLint does not support config property typeLiterals", ], }, diff --git a/src/rules/converters/trailing-comma.ts b/src/rules/converters/trailing-comma.ts index 76f08a2e2..de84b0faa 100644 --- a/src/rules/converters/trailing-comma.ts +++ b/src/rules/converters/trailing-comma.ts @@ -125,10 +125,8 @@ function collectNotices(args: TSLintArg[]): string[] { } function buildNoticeForEsSpecCompliant(arg: TSLintArg): string { - const unsupportedConfigKey = "esSpecCompliant"; - - if (Object.keys(arg).includes(unsupportedConfigKey)) { - return `ESLint does not support config property ${unsupportedConfigKey}`; + if (!arg.esSpecCompliant) { + return `ESLint only supports esSpecCompliant enabled`; } return ""; From 34606c5310ac27f32093ae3e4eb7f0d3b11df272 Mon Sep 17 00:00:00 2001 From: Matthias Kunnen Date: Tue, 11 Feb 2020 11:33:33 +0000 Subject: [PATCH 2/2] trailing-comma: Default to esSpecCompliant true Only warn when esSpecCompliant is specifically set to false and assume true since it's the desired behavior. --- .../converters/tests/trailing-comma.test.ts | 31 ++----------------- src/rules/converters/trailing-comma.ts | 2 +- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/rules/converters/tests/trailing-comma.test.ts b/src/rules/converters/tests/trailing-comma.test.ts index de15ddc85..8154af75d 100644 --- a/src/rules/converters/tests/trailing-comma.test.ts +++ b/src/rules/converters/tests/trailing-comma.test.ts @@ -22,28 +22,24 @@ describe(convertTrailingComma, () => { singleline: "never", }, expectedRuleArguments: [], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { singleline: "always", }, expectedRuleArguments: [], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { multiline: "never", }, expectedRuleArguments: [], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { multiline: "always", }, expectedRuleArguments: ["always-multiline"], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -51,7 +47,6 @@ describe(convertTrailingComma, () => { multiline: "never", }, expectedRuleArguments: [], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -59,7 +54,6 @@ describe(convertTrailingComma, () => { multiline: "always", }, expectedRuleArguments: ["always-multiline"], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -67,7 +61,6 @@ describe(convertTrailingComma, () => { multiline: "never", }, expectedRuleArguments: [], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -75,7 +68,6 @@ describe(convertTrailingComma, () => { multiline: "always", }, expectedRuleArguments: ["always"], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, ]; @@ -92,7 +84,6 @@ describe(convertTrailingComma, () => { ...(testCase.expectedRuleArguments.length !== 0 && { ruleArguments: testCase.expectedRuleArguments, }), - notices: testCase.expectedNotices, }, ], }); @@ -122,7 +113,6 @@ describe(convertTrailingComma, () => { exports: "always-multiline", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -144,7 +134,6 @@ describe(convertTrailingComma, () => { exports: "always", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -165,7 +154,6 @@ describe(convertTrailingComma, () => { exports: "never", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -187,7 +175,6 @@ describe(convertTrailingComma, () => { functions: "never", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -208,7 +195,6 @@ describe(convertTrailingComma, () => { exports: "always-multiline", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -236,7 +222,6 @@ describe(convertTrailingComma, () => { exports: "always", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, { argument: { @@ -257,7 +242,6 @@ describe(convertTrailingComma, () => { functions: "always-multiline", }, ], - expectedNotices: ["ESLint only supports esSpecCompliant enabled"], }, ]; @@ -274,7 +258,6 @@ describe(convertTrailingComma, () => { ...(testCase.expectedRuleArguments.length && { ruleArguments: testCase.expectedRuleArguments, }), - notices: testCase.expectedNotices, }, ], }); @@ -297,10 +280,7 @@ describe(convertTrailingComma, () => { }, }, expectedRuleArguments: [{}], - expectedNotices: [ - "ESLint only supports esSpecCompliant enabled", - "ESLint does not support config property typeLiterals", - ], + expectedNotices: ["ESLint does not support config property typeLiterals"], }, { argument: { @@ -309,10 +289,7 @@ describe(convertTrailingComma, () => { }, }, expectedRuleArguments: [{}], - expectedNotices: [ - "ESLint only supports esSpecCompliant enabled", - "ESLint does not support config property typeLiterals", - ], + expectedNotices: ["ESLint does not support config property typeLiterals"], }, { argument: { @@ -322,9 +299,7 @@ describe(convertTrailingComma, () => { }, }, expectedRuleArguments: [{}], - expectedNotices: [ - "ESLint does not support config property typeLiterals", - ], + expectedNotices: ["ESLint does not support config property typeLiterals"], }, { argument: { diff --git a/src/rules/converters/trailing-comma.ts b/src/rules/converters/trailing-comma.ts index de84b0faa..b5315e0cc 100644 --- a/src/rules/converters/trailing-comma.ts +++ b/src/rules/converters/trailing-comma.ts @@ -125,7 +125,7 @@ function collectNotices(args: TSLintArg[]): string[] { } function buildNoticeForEsSpecCompliant(arg: TSLintArg): string { - if (!arg.esSpecCompliant) { + if (arg.esSpecCompliant === false) { return `ESLint only supports esSpecCompliant enabled`; }