From 4ee4f5ecd7dbb42e6e2fc55c9a81ad3deddf588f Mon Sep 17 00:00:00 2001 From: Anix Date: Thu, 12 Mar 2020 11:53:17 +0000 Subject: [PATCH] Fix: consistencies with docs default and rule --- lib/rules/computed-property-spacing.js | 2 +- lib/rules/use-isnan.js | 2 +- tests/lib/rules/computed-property-spacing.js | 464 +++++++++---------- tests/lib/rules/use-isnan.js | 20 +- 4 files changed, 244 insertions(+), 244 deletions(-) diff --git a/lib/rules/computed-property-spacing.js b/lib/rules/computed-property-spacing.js index 53fdb8f4e41..41b62b2c833 100644 --- a/lib/rules/computed-property-spacing.js +++ b/lib/rules/computed-property-spacing.js @@ -32,7 +32,7 @@ module.exports = { properties: { enforceForClassMembers: { type: "boolean", - default: true + default: false } }, additionalProperties: false diff --git a/lib/rules/use-isnan.js b/lib/rules/use-isnan.js index 7b466be75f2..5a0e590bba5 100644 --- a/lib/rules/use-isnan.js +++ b/lib/rules/use-isnan.js @@ -45,7 +45,7 @@ module.exports = { properties: { enforceForSwitchCase: { type: "boolean", - default: true + default: false }, enforceForIndexOf: { type: "boolean", diff --git a/tests/lib/rules/computed-property-spacing.js b/tests/lib/rules/computed-property-spacing.js index b0ecef6eb81..175f3610e1e 100644 --- a/tests/lib/rules/computed-property-spacing.js +++ b/tests/lib/rules/computed-property-spacing.js @@ -153,6 +153,238 @@ ruleTester.run("computed-property-spacing", rule, { options: ["always", { enforceForClassMembers: true }], parserOptions: { ecmaVersion: 6 } }, + { + code: "A = class { [ a ](){} get [ b ](){} set [ c ](foo){} static [ d ](){} static get [ e ](){} static set [ f ](bar){} }", + output: "A = class { [a](){} get [b](){} set [c](foo){} static [d](){} static get [e](){} static set [f](bar){} }", + options: ["never", {}], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "unexpectedSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 14, + endLine: 1, + endColumn: 15 + }, + { + messageId: "unexpectedSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 16, + endLine: 1, + endColumn: 17 + }, + { + messageId: "unexpectedSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 28, + endLine: 1, + endColumn: 29 + }, + { + messageId: "unexpectedSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 30, + endLine: 1, + endColumn: 31 + }, + { + messageId: "unexpectedSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 42, + endLine: 1, + endColumn: 43 + }, + { + messageId: "unexpectedSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 44, + endLine: 1, + endColumn: 45 + }, + { + messageId: "unexpectedSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 62, + endLine: 1, + endColumn: 63 + }, + { + messageId: "unexpectedSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 64, + endLine: 1, + endColumn: 65 + }, + { + messageId: "unexpectedSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 83, + endLine: 1, + endColumn: 84 + }, + { + messageId: "unexpectedSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 85, + endLine: 1, + endColumn: 86 + }, + { + messageId: "unexpectedSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 104, + endLine: 1, + endColumn: 105 + }, + { + messageId: "unexpectedSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 106, + endLine: 1, + endColumn: 107 + } + ] + }, + { + code: "class A { [a](){} get [b](){} set [c](foo){} static [d](){} static get [e](){} static set [f](bar){} }", + output: "class A { [ a ](){} get [ b ](){} set [ c ](foo){} static [ d ](){} static get [ e ](){} static set [ f ](bar){} }", + options: ["always", {}], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "missingSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 11, + endLine: 1, + endColumn: 12 + }, + { + messageId: "missingSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 13, + endLine: 1, + endColumn: 14 + }, + { + messageId: "missingSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 23, + endLine: 1, + endColumn: 24 + }, + { + messageId: "missingSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 25, + endLine: 1, + endColumn: 26 + }, + { + messageId: "missingSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 35, + endLine: 1, + endColumn: 36 + }, + { + messageId: "missingSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 37, + endLine: 1, + endColumn: 38 + }, + { + messageId: "missingSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 53, + endLine: 1, + endColumn: 54 + }, + { + messageId: "missingSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 55, + endLine: 1, + endColumn: 56 + }, + { + messageId: "missingSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 72, + endLine: 1, + endColumn: 73 + }, + { + messageId: "missingSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 74, + endLine: 1, + endColumn: 75 + }, + { + messageId: "missingSpaceAfter", + data: { tokenValue: "[" }, + type: "MethodDefinition", + line: 1, + column: 91, + endLine: 1, + endColumn: 92 + }, + { + messageId: "missingSpaceBefore", + data: { tokenValue: "]" }, + type: "MethodDefinition", + line: 1, + column: 93, + endLine: 1, + endColumn: 94 + } + ] + }, // handling of parens and comments { @@ -779,122 +1011,6 @@ ruleTester.run("computed-property-spacing", rule, { } ] }, - { - code: "A = class { [ a ](){} get [ b ](){} set [ c ](foo){} static [ d ](){} static get [ e ](){} static set [ f ](bar){} }", - output: "A = class { [a](){} get [b](){} set [c](foo){} static [d](){} static get [e](){} static set [f](bar){} }", - options: ["never", {}], - parserOptions: { ecmaVersion: 6 }, - errors: [ - { - messageId: "unexpectedSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 14, - endLine: 1, - endColumn: 15 - }, - { - messageId: "unexpectedSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 16, - endLine: 1, - endColumn: 17 - }, - { - messageId: "unexpectedSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 28, - endLine: 1, - endColumn: 29 - }, - { - messageId: "unexpectedSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 30, - endLine: 1, - endColumn: 31 - }, - { - messageId: "unexpectedSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 42, - endLine: 1, - endColumn: 43 - }, - { - messageId: "unexpectedSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 44, - endLine: 1, - endColumn: 45 - }, - { - messageId: "unexpectedSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 62, - endLine: 1, - endColumn: 63 - }, - { - messageId: "unexpectedSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 64, - endLine: 1, - endColumn: 65 - }, - { - messageId: "unexpectedSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 83, - endLine: 1, - endColumn: 84 - }, - { - messageId: "unexpectedSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 85, - endLine: 1, - endColumn: 86 - }, - { - messageId: "unexpectedSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 104, - endLine: 1, - endColumn: 105 - }, - { - messageId: "unexpectedSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 106, - endLine: 1, - endColumn: 107 - } - ] - }, { code: "A = class { [a](){} }", output: "A = class { [ a ](){} }", @@ -1037,122 +1153,6 @@ ruleTester.run("computed-property-spacing", rule, { } ] }, - { - code: "class A { [a](){} get [b](){} set [c](foo){} static [d](){} static get [e](){} static set [f](bar){} }", - output: "class A { [ a ](){} get [ b ](){} set [ c ](foo){} static [ d ](){} static get [ e ](){} static set [ f ](bar){} }", - options: ["always", {}], - parserOptions: { ecmaVersion: 6 }, - errors: [ - { - messageId: "missingSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 11, - endLine: 1, - endColumn: 12 - }, - { - messageId: "missingSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 13, - endLine: 1, - endColumn: 14 - }, - { - messageId: "missingSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 23, - endLine: 1, - endColumn: 24 - }, - { - messageId: "missingSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 25, - endLine: 1, - endColumn: 26 - }, - { - messageId: "missingSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 35, - endLine: 1, - endColumn: 36 - }, - { - messageId: "missingSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 37, - endLine: 1, - endColumn: 38 - }, - { - messageId: "missingSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 53, - endLine: 1, - endColumn: 54 - }, - { - messageId: "missingSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 55, - endLine: 1, - endColumn: 56 - }, - { - messageId: "missingSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 72, - endLine: 1, - endColumn: 73 - }, - { - messageId: "missingSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 74, - endLine: 1, - endColumn: 75 - }, - { - messageId: "missingSpaceAfter", - data: { tokenValue: "[" }, - type: "MethodDefinition", - line: 1, - column: 91, - endLine: 1, - endColumn: 92 - }, - { - messageId: "missingSpaceBefore", - data: { tokenValue: "]" }, - type: "MethodDefinition", - line: 1, - column: 93, - endLine: 1, - endColumn: 94 - } - ] - }, // never - classes { diff --git a/tests/lib/rules/use-isnan.js b/tests/lib/rules/use-isnan.js index aa1b1746fcd..b263089e7e5 100644 --- a/tests/lib/rules/use-isnan.js +++ b/tests/lib/rules/use-isnan.js @@ -49,6 +49,16 @@ ruleTester.run("use-isnan", rule, { code: "switch(foo) { case NaN: break; }", options: [{ enforceForSwitchCase: false }] }, + { + code: "switch(NaN) { case foo: break; }", + options: [{}], + errors: [{ messageId: "switchNaN", type: "SwitchStatement", column: 1 }] + }, + { + code: "switch(foo) { case NaN: break; }", + options: [{}], + errors: [{ messageId: "caseNaN", type: "SwitchCase", column: 15 }] + }, { code: "switch(NaN) { case NaN: break; }", options: [{ enforceForSwitchCase: false }] @@ -280,16 +290,6 @@ ruleTester.run("use-isnan", rule, { code: "switch(foo) { case NaN: break; }", errors: [{ messageId: "caseNaN", type: "SwitchCase", column: 15 }] }, - { - code: "switch(NaN) { case foo: break; }", - options: [{}], - errors: [{ messageId: "switchNaN", type: "SwitchStatement", column: 1 }] - }, - { - code: "switch(foo) { case NaN: break; }", - options: [{}], - errors: [{ messageId: "caseNaN", type: "SwitchCase", column: 15 }] - }, { code: "switch(NaN) {}", options: [{ enforceForSwitchCase: true }],