diff --git a/lib/rules/id-blacklist.js b/lib/rules/id-blacklist.js index d03ee1ec233..ee28c0b5a81 100644 --- a/lib/rules/id-blacklist.js +++ b/lib/rules/id-blacklist.js @@ -67,9 +67,13 @@ module.exports = { * @private */ function report(node) { - context.report({ node, message: "Identifier '{{name}}' is blacklisted.", data: { - name: node.name - } }); + context.report({ + node, + message: "Identifier '{{name}}' is blacklisted.", + data: { + name: node.name + } + }); } return { diff --git a/lib/rules/id-match.js b/lib/rules/id-match.js index 7536e07b109..0420fdc74e4 100644 --- a/lib/rules/id-match.js +++ b/lib/rules/id-match.js @@ -75,10 +75,14 @@ module.exports = { * @private */ function report(node) { - context.report({ node, message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", data: { - name: node.name, - pattern - } }); + context.report({ + node, + message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", + data: { + name: node.name, + pattern + } + }); } return { diff --git a/lib/rules/no-cond-assign.js b/lib/rules/no-cond-assign.js index 61e5751e4ed..7c031c13f06 100644 --- a/lib/rules/no-cond-assign.js +++ b/lib/rules/no-cond-assign.js @@ -112,9 +112,13 @@ module.exports = { const ancestor = findConditionalAncestor(node); if (ancestor) { - context.report({ node: ancestor, message: "Unexpected assignment within {{type}}.", data: { - type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type - } }); + context.report({ + node: ancestor, + message: "Unexpected assignment within {{type}}.", + data: { + type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type + } + }); } } diff --git a/lib/rules/no-inner-declarations.js b/lib/rules/no-inner-declarations.js index e7d1b004e77..28aa5b4b5c3 100644 --- a/lib/rules/no-inner-declarations.js +++ b/lib/rules/no-inner-declarations.js @@ -63,10 +63,14 @@ module.exports = { body.distance === 2); if (!valid) { - context.report({ node, message: "Move {{type}} declaration to {{body}} root.", data: { - type: (node.type === "FunctionDeclaration" ? "function" : "variable"), - body: (body.type === "Program" ? "program" : "function body") - } }); + context.report({ + node, + message: "Move {{type}} declaration to {{body}} root.", + data: { + type: (node.type === "FunctionDeclaration" ? "function" : "variable"), + body: (body.type === "Program" ? "program" : "function body") + } + }); } } diff --git a/lib/rules/no-restricted-properties.js b/lib/rules/no-restricted-properties.js index e3a3d14e51a..44db74f5354 100644 --- a/lib/rules/no-restricted-properties.js +++ b/lib/rules/no-restricted-properties.js @@ -109,20 +109,28 @@ module.exports = { if (matchedObjectProperty) { const message = matchedObjectProperty.message ? ` ${matchedObjectProperty.message}` : ""; - // eslint-disable-next-line eslint-plugin/report-message-format - context.report({ node, message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", data: { - objectName, - propertyName, - message - } }); + context.report({ + node, + // eslint-disable-next-line eslint-plugin/report-message-format + message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", + data: { + objectName, + propertyName, + message + } + }); } else if (globalMatchedProperty) { const message = globalMatchedProperty.message ? ` ${globalMatchedProperty.message}` : ""; - // eslint-disable-next-line eslint-plugin/report-message-format - context.report({ node, message: "'{{propertyName}}' is restricted from being used.{{message}}", data: { - propertyName, - message - } }); + context.report({ + node, + // eslint-disable-next-line eslint-plugin/report-message-format + message: "'{{propertyName}}' is restricted from being used.{{message}}", + data: { + propertyName, + message + } + }); } } diff --git a/lib/rules/no-tabs.js b/lib/rules/no-tabs.js index 19983c57ba9..0757a69060e 100644 --- a/lib/rules/no-tabs.js +++ b/lib/rules/no-tabs.js @@ -31,10 +31,14 @@ module.exports = { const match = regex.exec(line); if (match) { - context.report({ node, loc: { - line: index + 1, - column: match.index + 1 - }, message: "Unexpected tab character." }); + context.report({ + node, + loc: { + line: index + 1, + column: match.index + 1 + }, + message: "Unexpected tab character." + }); } }); } diff --git a/lib/rules/prefer-reflect.js b/lib/rules/prefer-reflect.js index 49e20989ecb..a47e66c5f53 100644 --- a/lib/rules/prefer-reflect.js +++ b/lib/rules/prefer-reflect.js @@ -83,10 +83,14 @@ module.exports = { * @returns {void} */ function report(node, existing, substitute) { - context.report({ node, message: "Avoid using {{existing}}, instead use {{substitute}}.", data: { - existing, - substitute - } }); + context.report({ + node, + message: "Avoid using {{existing}}, instead use {{substitute}}.", + data: { + existing, + substitute + } + }); } return { diff --git a/lib/rules/valid-jsdoc.js b/lib/rules/valid-jsdoc.js index 331ed7b69b6..ac8ae57c9fc 100644 --- a/lib/rules/valid-jsdoc.js +++ b/lib/rules/valid-jsdoc.js @@ -362,14 +362,22 @@ module.exports = { // TODO(nzakas): Figure out logical things to do with destructured, default, rest params if (param.type === "Identifier") { if (jsdocParams[i] && (name !== jsdocParams[i])) { - context.report({ node: jsdocNode, message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.", data: { - name, - jsdocName: jsdocParams[i] - } }); + context.report({ + node: jsdocNode, + message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.", + data: { + name, + jsdocName: jsdocParams[i] + } + }); } else if (!params[name] && !isOverride) { - context.report({ node: jsdocNode, message: "Missing JSDoc for parameter '{{name}}'.", data: { - name - } }); + context.report({ + node: jsdocNode, + message: "Missing JSDoc for parameter '{{name}}'.", + data: { + name + } + }); } } }); diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml index d97f54cbb4d..410ede81b0f 100644 --- a/packages/eslint-config-eslint/default.yml +++ b/packages/eslint-config-eslint/default.yml @@ -115,7 +115,7 @@ rules: no-whitespace-before-property: "error" no-with: "error" no-var: "error" - object-curly-newline: ["error", { "consistent": true, "multiline": true}] + object-curly-newline: ["error", { "consistent": true, "multiline": true }] object-curly-spacing: ["error", "always"] object-property-newline: ["error", { "allowMultiplePropertiesPerLine": true }] object-shorthand: "error" diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index 104118888b9..419df9eef21 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -34,10 +34,12 @@ describe("CLIEngine", () => { const examplePluginName = "eslint-plugin-example", examplePluginNameWithNamespace = "@eslint/eslint-plugin-example", requireStubs = {}, - examplePlugin = { rules: { - "example-rule": require("../fixtures/rules/custom-rule"), - "make-syntax-error": require("../fixtures/rules/make-syntax-error-rule") - } }, + examplePlugin = { + rules: { + "example-rule": require("../fixtures/rules/custom-rule"), + "make-syntax-error": require("../fixtures/rules/make-syntax-error-rule") + } + }, examplePreprocessorName = "eslint-plugin-processor", originalDir = process.cwd(); let CLIEngine, diff --git a/tests/lib/linter.js b/tests/lib/linter.js index 672088c71f6..ba98b0a1fe0 100644 --- a/tests/lib/linter.js +++ b/tests/lib/linter.js @@ -2914,23 +2914,25 @@ describe("Linter", () => { }; let ok = false; - linter.defineRules({ test(context) { - return { - Program() { - const scope = context.getScope(); - const sourceCode = context.getSourceCode(); - const comments = sourceCode.getAllComments(); + linter.defineRules({ + test(context) { + return { + Program() { + const scope = context.getScope(); + const sourceCode = context.getSourceCode(); + const comments = sourceCode.getAllComments(); - assert.equal(1, comments.length); + assert.equal(1, comments.length); - const foo = getVariable(scope, "foo"); + const foo = getVariable(scope, "foo"); - assert.notOk(foo); + assert.notOk(foo); - ok = true; - } - }; - } }); + ok = true; + } + }; + } + }); linter.verify(code, config, { allowInlineConfig: false }); assert(ok); @@ -3005,23 +3007,25 @@ describe("Linter", () => { }; let ok = false; - linter.defineRules({ test(context) { - return { - Program() { - const scope = context.getScope(); - const sourceCode = context.getSourceCode(); - const comments = sourceCode.getAllComments(); + linter.defineRules({ + test(context) { + return { + Program() { + const scope = context.getScope(); + const sourceCode = context.getSourceCode(); + const comments = sourceCode.getAllComments(); - assert.equal(1, comments.length); + assert.equal(1, comments.length); - const windowVar = getVariable(scope, "window"); + const windowVar = getVariable(scope, "window"); - assert.notOk(windowVar.eslintExplicitGlobal); + assert.notOk(windowVar.eslintExplicitGlobal); - ok = true; - } - }; - } }); + ok = true; + } + }; + } + }); linter.verify(code, config, { allowInlineConfig: false }); assert(ok); @@ -3354,34 +3358,36 @@ describe("Linter", () => { const code = "/* global foo */\n/* global bar, baz */"; let ok = false; - linter.defineRules({ test(context) { - return { - Program() { - const scope = context.getScope(); - const sourceCode = context.getSourceCode(); - const comments = sourceCode.getAllComments(); + linter.defineRules({ + test(context) { + return { + Program() { + const scope = context.getScope(); + const sourceCode = context.getSourceCode(); + const comments = sourceCode.getAllComments(); - assert.equal(2, comments.length); + assert.equal(2, comments.length); - const foo = getVariable(scope, "foo"); + const foo = getVariable(scope, "foo"); - assert.equal(true, foo.eslintExplicitGlobal); - assert.equal(comments[0], foo.eslintExplicitGlobalComment); + assert.equal(true, foo.eslintExplicitGlobal); + assert.equal(comments[0], foo.eslintExplicitGlobalComment); - const bar = getVariable(scope, "bar"); + const bar = getVariable(scope, "bar"); - assert.equal(true, bar.eslintExplicitGlobal); - assert.equal(comments[1], bar.eslintExplicitGlobalComment); + assert.equal(true, bar.eslintExplicitGlobal); + assert.equal(comments[1], bar.eslintExplicitGlobalComment); - const baz = getVariable(scope, "baz"); + const baz = getVariable(scope, "baz"); - assert.equal(true, baz.eslintExplicitGlobal); - assert.equal(comments[1], baz.eslintExplicitGlobalComment); + assert.equal(true, baz.eslintExplicitGlobal); + assert.equal(comments[1], baz.eslintExplicitGlobalComment); - ok = true; - } - }; - } }); + ok = true; + } + }; + } + }); linter.verify(code, { rules: { test: 2 } }); assert(ok); @@ -3430,14 +3436,16 @@ describe("Linter", () => { beforeEach(() => { let ok = false; - linter.defineRules({ test(context) { - return { - Program() { - scope = context.getScope(); - ok = true; - } - }; - } }); + linter.defineRules({ + test(context) { + return { + Program() { + scope = context.getScope(); + ok = true; + } + }; + } + }); linter.verify(code, { rules: { test: 2 }, globals: { e: true, f: false } }); assert(ok); }); @@ -3530,70 +3538,72 @@ describe("Linter", () => { * @returns {void} */ function verify(code, type, expectedNamesList) { - linter.defineRules({ test(context) { - const rule = { - Program: checkEmpty, - EmptyStatement: checkEmpty, - BlockStatement: checkEmpty, - ExpressionStatement: checkEmpty, - LabeledStatement: checkEmpty, - BreakStatement: checkEmpty, - ContinueStatement: checkEmpty, - WithStatement: checkEmpty, - SwitchStatement: checkEmpty, - ReturnStatement: checkEmpty, - ThrowStatement: checkEmpty, - TryStatement: checkEmpty, - WhileStatement: checkEmpty, - DoWhileStatement: checkEmpty, - ForStatement: checkEmpty, - ForInStatement: checkEmpty, - DebuggerStatement: checkEmpty, - ThisExpression: checkEmpty, - ArrayExpression: checkEmpty, - ObjectExpression: checkEmpty, - Property: checkEmpty, - SequenceExpression: checkEmpty, - UnaryExpression: checkEmpty, - BinaryExpression: checkEmpty, - AssignmentExpression: checkEmpty, - UpdateExpression: checkEmpty, - LogicalExpression: checkEmpty, - ConditionalExpression: checkEmpty, - CallExpression: checkEmpty, - NewExpression: checkEmpty, - MemberExpression: checkEmpty, - SwitchCase: checkEmpty, - Identifier: checkEmpty, - Literal: checkEmpty, - ForOfStatement: checkEmpty, - ArrowFunctionExpression: checkEmpty, - YieldExpression: checkEmpty, - TemplateLiteral: checkEmpty, - TaggedTemplateExpression: checkEmpty, - TemplateElement: checkEmpty, - ObjectPattern: checkEmpty, - ArrayPattern: checkEmpty, - RestElement: checkEmpty, - AssignmentPattern: checkEmpty, - ClassBody: checkEmpty, - MethodDefinition: checkEmpty, - MetaProperty: checkEmpty - }; + linter.defineRules({ + test(context) { + const rule = { + Program: checkEmpty, + EmptyStatement: checkEmpty, + BlockStatement: checkEmpty, + ExpressionStatement: checkEmpty, + LabeledStatement: checkEmpty, + BreakStatement: checkEmpty, + ContinueStatement: checkEmpty, + WithStatement: checkEmpty, + SwitchStatement: checkEmpty, + ReturnStatement: checkEmpty, + ThrowStatement: checkEmpty, + TryStatement: checkEmpty, + WhileStatement: checkEmpty, + DoWhileStatement: checkEmpty, + ForStatement: checkEmpty, + ForInStatement: checkEmpty, + DebuggerStatement: checkEmpty, + ThisExpression: checkEmpty, + ArrayExpression: checkEmpty, + ObjectExpression: checkEmpty, + Property: checkEmpty, + SequenceExpression: checkEmpty, + UnaryExpression: checkEmpty, + BinaryExpression: checkEmpty, + AssignmentExpression: checkEmpty, + UpdateExpression: checkEmpty, + LogicalExpression: checkEmpty, + ConditionalExpression: checkEmpty, + CallExpression: checkEmpty, + NewExpression: checkEmpty, + MemberExpression: checkEmpty, + SwitchCase: checkEmpty, + Identifier: checkEmpty, + Literal: checkEmpty, + ForOfStatement: checkEmpty, + ArrowFunctionExpression: checkEmpty, + YieldExpression: checkEmpty, + TemplateLiteral: checkEmpty, + TaggedTemplateExpression: checkEmpty, + TemplateElement: checkEmpty, + ObjectPattern: checkEmpty, + ArrayPattern: checkEmpty, + RestElement: checkEmpty, + AssignmentPattern: checkEmpty, + ClassBody: checkEmpty, + MethodDefinition: checkEmpty, + MetaProperty: checkEmpty + }; - rule[type] = function(node) { - const expectedNames = expectedNamesList.shift(); - const variables = context.getDeclaredVariables(node); + rule[type] = function(node) { + const expectedNames = expectedNamesList.shift(); + const variables = context.getDeclaredVariables(node); - assert(Array.isArray(expectedNames)); - assert(Array.isArray(variables)); - assert.equal(expectedNames.length, variables.length); - for (let i = variables.length - 1; i >= 0; i--) { - assert.equal(expectedNames[i], variables[i].name); - } - }; - return rule; - } }); + assert(Array.isArray(expectedNames)); + assert(Array.isArray(variables)); + assert.equal(expectedNames.length, variables.length); + for (let i = variables.length - 1; i >= 0; i--) { + assert.equal(expectedNames[i], variables[i].name); + } + }; + return rule; + } + }); linter.verify(code, { rules: { test: 2 }, parserOptions: { diff --git a/tests/lib/rules/brace-style.js b/tests/lib/rules/brace-style.js index 6db469124a4..0b93f9c48b2 100644 --- a/tests/lib/rules/brace-style.js +++ b/tests/lib/rules/brace-style.js @@ -315,7 +315,8 @@ ruleTester.run("brace-style", rule, { { code: "if (a) { \nb();\n } else { \nc();\n }", output: "if (a) { \nb();\n }\n else { \nc();\n }", - options: ["stroustrup"], errors: [{ message: CLOSE_MESSAGE_STROUSTRUP_ALLMAN, type: "Punctuator" }] + options: ["stroustrup"], + errors: [{ message: CLOSE_MESSAGE_STROUSTRUP_ALLMAN, type: "Punctuator" }] }, { code: "if (foo) {\nbaz();\n} else if (bar) {\nbaz();\n}\nelse {\nqux();\n}", diff --git a/tests/lib/rules/dot-notation.js b/tests/lib/rules/dot-notation.js index 19b0031753f..28edc2528b5 100644 --- a/tests/lib/rules/dot-notation.js +++ b/tests/lib/rules/dot-notation.js @@ -76,7 +76,8 @@ ruleTester.run("dot-notation", rule, { { code: "a['_dangle'];", output: "a._dangle;", - options: [{ allowPattern: "^[a-z]+(_[a-z]+)+$" }], errors: [{ message: "[\"_dangle\"] is better written in dot notation." }] + options: [{ allowPattern: "^[a-z]+(_[a-z]+)+$" }], + errors: [{ message: "[\"_dangle\"] is better written in dot notation." }] }, { code: "a['SHOUT_CASE'];", diff --git a/tests/lib/rules/id-length.js b/tests/lib/rules/id-length.js index 5c2bd87334c..a4e36cd74d6 100644 --- a/tests/lib/rules/id-length.js +++ b/tests/lib/rules/id-length.js @@ -74,50 +74,106 @@ ruleTester.run("id-length", rule, { { code: "var handler = function (e) {};", errors: [{ message: "Identifier name 'e' is too short (< 2).", type: "Identifier" }] }, { code: "for (var i=0; i < 10; i++) { console.log(i); }", errors: [{ message: "Identifier name 'i' is too short (< 2).", type: "Identifier" }] }, { code: "var j=0; while (j > -10) { console.log(--j); }", errors: [{ message: "Identifier name 'j' is too short (< 2).", type: "Identifier" }] }, - { code: "var _$xt_$ = Foo(42)", options: [{ min: 2, max: 4 }], errors: [ - { message: "Identifier name '_$xt_$' is too long (> 4).", type: "Identifier" } - ] }, - { code: "var _$x$_t$ = Foo(42)", options: [{ min: 2, max: 4 }], errors: [ - { message: "Identifier name '_$x$_t$' is too long (> 4).", type: "Identifier" } - ] }, - { code: "(a) => { a * a };", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'a' is too short (< 2).", type: "Identifier" } - ] }, - { code: "function foo(x = 0) { }", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "class x { }", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "class Foo { x() {} }", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "function foo(...x) { }", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "var { x} = {};", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }, - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "var { x: a} = {};", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "var { a: [x]} = {};", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'a' is too short (< 2).", type: "Identifier" } - ] }, - { code: "import x from 'y';", parserOptions: { sourceType: "module" }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "export var x = 0;", parserOptions: { sourceType: "module" }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, - { code: "({ a: obj.x.y.z } = {});", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'a' is too short (< 2).", type: "Identifier" }, - { message: "Identifier name 'z' is too short (< 2).", type: "Identifier" } - ] }, - { code: "({ prop: obj.x } = {});", parserOptions: { ecmaVersion: 6 }, errors: [ - { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } - ] }, + { + code: "var _$xt_$ = Foo(42)", + options: [{ min: 2, max: 4 }], + errors: [ + { message: "Identifier name '_$xt_$' is too long (> 4).", type: "Identifier" } + ] + }, + { + code: "var _$x$_t$ = Foo(42)", + options: [{ min: 2, max: 4 }], + errors: [ + { message: "Identifier name '_$x$_t$' is too long (> 4).", type: "Identifier" } + ] + }, + { + code: "(a) => { a * a };", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'a' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "function foo(x = 0) { }", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "class x { }", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "class Foo { x() {} }", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "function foo(...x) { }", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "var { x} = {};", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }, + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "var { x: a} = {};", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "var { a: [x]} = {};", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'a' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "import x from 'y';", + parserOptions: { sourceType: "module" }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "export var x = 0;", + parserOptions: { sourceType: "module" }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "({ a: obj.x.y.z } = {});", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'a' is too short (< 2).", type: "Identifier" }, + { message: "Identifier name 'z' is too short (< 2).", type: "Identifier" } + ] + }, + { + code: "({ prop: obj.x } = {});", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Identifier name 'x' is too short (< 2).", type: "Identifier" } + ] + }, { code: "var x = 1;", options: [{ properties: "never" }], errors: [{ message: "Identifier name 'x' is too short (< 2).", type: "Identifier" }] } ] }); diff --git a/tests/lib/rules/new-parens.js b/tests/lib/rules/new-parens.js index 224ac834291..a93bcbd6f0d 100644 --- a/tests/lib/rules/new-parens.js +++ b/tests/lib/rules/new-parens.js @@ -54,8 +54,10 @@ ruleTester.run("new-parens", rule, { { code: "var a = (new Date)", output: "var a = (new Date())", - errors: [{ message: "Missing '()' invoking a constructor.", - type: "NewExpression" }] + errors: [{ + message: "Missing '()' invoking a constructor.", + type: "NewExpression" + }] }, { diff --git a/tests/lib/rules/no-catch-shadow.js b/tests/lib/rules/no-catch-shadow.js index 6bda019bca9..a302ae86b0c 100644 --- a/tests/lib/rules/no-catch-shadow.js +++ b/tests/lib/rules/no-catch-shadow.js @@ -34,7 +34,8 @@ ruleTester.run("no-catch-shadow", rule, { "}", "", "module.exports = broken;" - ].join("\n"), parserOptions: { ecmaVersion: 6 } + ].join("\n"), + parserOptions: { ecmaVersion: 6 } } ], invalid: [ diff --git a/tests/lib/rules/no-continue.js b/tests/lib/rules/no-continue.js index 561986c6456..16ed522829f 100644 --- a/tests/lib/rules/no-continue.js +++ b/tests/lib/rules/no-continue.js @@ -27,23 +27,31 @@ ruleTester.run("no-continue", rule, { invalid: [ { code: "var sum = 0, i; for(i = 0; i < 10; i++){ if(i <= 5) { continue; } sum += i; }", - errors: [{ message: "Unexpected use of continue statement.", - type: "ContinueStatement" }] + errors: [{ + message: "Unexpected use of continue statement.", + type: "ContinueStatement" + }] }, { code: "var sum = 0, i; myLabel: for(i = 0; i < 10; i++){ if(i <= 5) { continue myLabel; } sum += i; }", - errors: [{ message: "Unexpected use of continue statement.", - type: "ContinueStatement" }] + errors: [{ + message: "Unexpected use of continue statement.", + type: "ContinueStatement" + }] }, { code: "var sum = 0, i = 0; while(i < 10) { if(i <= 5) { i++; continue; } sum += i; i++; }", - errors: [{ message: "Unexpected use of continue statement.", - type: "ContinueStatement" }] + errors: [{ + message: "Unexpected use of continue statement.", + type: "ContinueStatement" + }] }, { code: "var sum = 0, i = 0; myLabel: while(i < 10) { if(i <= 5) { i++; continue myLabel; } sum += i; i++; }", - errors: [{ message: "Unexpected use of continue statement.", - type: "ContinueStatement" }] + errors: [{ + message: "Unexpected use of continue statement.", + type: "ContinueStatement" + }] } ] }); diff --git a/tests/lib/rules/no-else-return.js b/tests/lib/rules/no-else-return.js index eca303dbc1a..d081de88fbb 100644 --- a/tests/lib/rules/no-else-return.js +++ b/tests/lib/rules/no-else-return.js @@ -58,7 +58,8 @@ ruleTester.run("no-else-return", rule, { { code: "function foo3() { if (true) return x; else return y; }", output: "function foo3() { if (true) return x; return y; }", - errors: [{ message: "Unnecessary 'else' after 'return'.", type: "ReturnStatement" }] }, + errors: [{ message: "Unnecessary 'else' after 'return'.", type: "ReturnStatement" }] + }, { code: "function foo4() { if (true) { if (false) return x; else return y; } else { return z; } }", output: "function foo4() { if (true) { if (false) return x; return y; } else { return z; } }", // Other case is fixed in the second pass. diff --git a/tests/lib/rules/no-extra-bind.js b/tests/lib/rules/no-extra-bind.js index 6912ab92d7d..1aced94560d 100644 --- a/tests/lib/rules/no-extra-bind.js +++ b/tests/lib/rules/no-extra-bind.js @@ -73,6 +73,7 @@ ruleTester.run("no-extra-bind", rule, { { code: "var a = function() { (function(){ (function(){ this.d }.bind(c)) }) }.bind(b)", output: "var a = function() { (function(){ (function(){ this.d }.bind(c)) }) }", - errors: [{ message: "The function binding is unnecessary.", type: "CallExpression", column: 71 }] } + errors: [{ message: "The function binding is unnecessary.", type: "CallExpression", column: 71 }] + } ] }); diff --git a/tests/lib/rules/no-extra-parens.js b/tests/lib/rules/no-extra-parens.js index 4823374a0b6..96690548a29 100644 --- a/tests/lib/rules/no-extra-parens.js +++ b/tests/lib/rules/no-extra-parens.js @@ -316,57 +316,84 @@ ruleTester.run("no-extra-parens", rule, { // ["all", { ignoreJSX: "all" }] { code: "const Component = (
)", options: ["all", { ignoreJSX: "all" }] }, - { code: [ - "const Component = (