From fc78e78824b800e9cc51bba91ce3b47f7031c5a3 Mon Sep 17 00:00:00 2001 From: Gyandeep Singh Date: Sat, 23 Apr 2016 10:40:54 -0500 Subject: [PATCH] Chore: Enable quote-props rule in eslint-config-eslint (refs #5188) (#5938) --- Makefile.js | 6 +- lib/config/config-validator.js | 14 +- lib/eslint.js | 4 +- lib/rules/accessor-pairs.js | 16 +- lib/rules/array-bracket-spacing.js | 20 +-- lib/rules/array-callback-return.js | 6 +- lib/rules/arrow-body-style.js | 4 +- lib/rules/arrow-parens.js | 4 +- lib/rules/arrow-spacing.js | 16 +- lib/rules/block-scoped-var.js | 16 +- lib/rules/brace-style.js | 38 ++-- lib/rules/callback-return.js | 2 +- lib/rules/camelcase.js | 12 +- lib/rules/comma-dangle.js | 14 +- lib/rules/comma-spacing.js | 18 +- lib/rules/comma-style.js | 16 +- lib/rules/complexity.js | 50 +++--- lib/rules/computed-property-spacing.js | 2 +- lib/rules/consistent-return.js | 6 +- lib/rules/consistent-this.js | 14 +- lib/rules/constructor-super.js | 10 +- lib/rules/curly.js | 36 ++-- lib/rules/default-case.js | 12 +- lib/rules/dot-location.js | 4 +- lib/rules/dot-notation.js | 16 +- lib/rules/eol-last.js | 4 +- lib/rules/eqeqeq.js | 4 +- lib/rules/func-names.js | 2 +- lib/rules/func-style.js | 20 +-- lib/rules/generator-star-spacing.js | 18 +- lib/rules/global-require.js | 2 +- lib/rules/guard-for-in.js | 2 +- lib/rules/handle-callback-err.js | 8 +- lib/rules/id-blacklist.js | 10 +- lib/rules/id-length.js | 52 +++--- lib/rules/id-match.js | 12 +- lib/rules/indent.js | 78 ++++---- lib/rules/init-declarations.js | 32 ++-- lib/rules/jsx-quotes.js | 4 +- lib/rules/key-spacing.js | 78 ++++---- lib/rules/keyword-spacing.js | 28 +-- lib/rules/linebreak-style.js | 4 +- lib/rules/lines-around-comment.js | 50 +++--- lib/rules/max-depth.js | 50 +++--- lib/rules/max-len.js | 48 ++--- lib/rules/max-nested-callbacks.js | 28 +-- lib/rules/max-params.js | 30 ++-- lib/rules/max-statements-per-line.js | 16 +- lib/rules/max-statements.js | 42 ++--- lib/rules/new-cap.js | 34 ++-- lib/rules/new-parens.js | 2 +- lib/rules/newline-after-var.js | 4 +- lib/rules/newline-per-chained-call.js | 14 +- lib/rules/no-alert.js | 4 +- lib/rules/no-array-constructor.js | 4 +- lib/rules/no-bitwise.js | 26 +-- lib/rules/no-caller.js | 2 +- lib/rules/no-case-declarations.js | 2 +- lib/rules/no-catch-shadow.js | 2 +- lib/rules/no-class-assign.js | 4 +- lib/rules/no-cond-assign.js | 20 +-- lib/rules/no-confusing-arrow.js | 2 +- lib/rules/no-console.js | 20 +-- lib/rules/no-const-assign.js | 2 +- lib/rules/no-constant-condition.js | 10 +- lib/rules/no-continue.js | 2 +- lib/rules/no-control-regex.js | 2 +- lib/rules/no-debugger.js | 2 +- lib/rules/no-delete-var.js | 2 +- lib/rules/no-div-regex.js | 2 +- lib/rules/no-dupe-args.js | 4 +- lib/rules/no-dupe-class-members.js | 6 +- lib/rules/no-dupe-keys.js | 2 +- lib/rules/no-duplicate-case.js | 2 +- lib/rules/no-duplicate-imports.js | 12 +- lib/rules/no-else-return.js | 2 +- lib/rules/no-empty-character-class.js | 2 +- lib/rules/no-empty-pattern.js | 4 +- lib/rules/no-empty.js | 14 +- lib/rules/no-eq-null.js | 2 +- lib/rules/no-eval.js | 18 +- lib/rules/no-ex-assign.js | 2 +- lib/rules/no-extend-native.js | 20 +-- lib/rules/no-extra-bind.js | 6 +- lib/rules/no-extra-boolean-cast.js | 4 +- lib/rules/no-extra-label.js | 18 +- lib/rules/no-extra-parens.js | 86 ++++----- lib/rules/no-extra-semi.js | 6 +- lib/rules/no-fallthrough.js | 16 +- lib/rules/no-floating-decimal.js | 2 +- lib/rules/no-func-assign.js | 4 +- lib/rules/no-implicit-coercion.js | 32 ++-- lib/rules/no-implicit-globals.js | 2 +- lib/rules/no-implied-eval.js | 8 +- lib/rules/no-inline-comments.js | 4 +- lib/rules/no-inner-declarations.js | 6 +- lib/rules/no-invalid-regexp.js | 18 +- lib/rules/no-invalid-this.js | 8 +- lib/rules/no-irregular-whitespace.js | 20 +-- lib/rules/no-iterator.js | 2 +- lib/rules/no-label-var.js | 2 +- lib/rules/no-labels.js | 6 +- lib/rules/no-lone-blocks.js | 2 +- lib/rules/no-lonely-if.js | 2 +- lib/rules/no-loop-func.js | 6 +- lib/rules/no-magic-numbers.js | 30 ++-- lib/rules/no-mixed-requires.js | 20 +-- lib/rules/no-mixed-spaces-and-tabs.js | 4 +- lib/rules/no-multi-spaces.js | 20 +-- lib/rules/no-multi-str.js | 2 +- lib/rules/no-multiple-empty-lines.js | 28 +-- lib/rules/no-native-reassign.js | 16 +- lib/rules/no-negated-condition.js | 4 +- lib/rules/no-negated-in-lhs.js | 2 +- lib/rules/no-nested-ternary.js | 2 +- lib/rules/no-new-func.js | 4 +- lib/rules/no-new-object.js | 2 +- lib/rules/no-new-require.js | 2 +- lib/rules/no-new-wrappers.js | 2 +- lib/rules/no-new.js | 2 +- lib/rules/no-obj-calls.js | 2 +- lib/rules/no-octal-escape.js | 2 +- lib/rules/no-octal.js | 2 +- lib/rules/no-param-reassign.js | 8 +- lib/rules/no-path-concat.js | 2 +- lib/rules/no-plusplus.js | 12 +- lib/rules/no-process-env.js | 2 +- lib/rules/no-process-exit.js | 2 +- lib/rules/no-proto.js | 2 +- lib/rules/no-redeclare.js | 22 +-- lib/rules/no-regex-spaces.js | 2 +- lib/rules/no-restricted-globals.js | 10 +- lib/rules/no-restricted-imports.js | 10 +- lib/rules/no-restricted-modules.js | 10 +- lib/rules/no-restricted-syntax.js | 10 +- lib/rules/no-return-assign.js | 6 +- lib/rules/no-script-url.js | 2 +- lib/rules/no-self-assign.js | 2 +- lib/rules/no-self-compare.js | 2 +- lib/rules/no-sequences.js | 12 +- lib/rules/no-shadow-restricted-names.js | 10 +- lib/rules/no-shadow.js | 18 +- lib/rules/no-spaced-func.js | 4 +- lib/rules/no-sparse-arrays.js | 2 +- lib/rules/no-sync.js | 2 +- lib/rules/no-ternary.js | 2 +- lib/rules/no-this-before-super.js | 12 +- lib/rules/no-throw-literal.js | 2 +- lib/rules/no-trailing-spaces.js | 12 +- lib/rules/no-undef-init.js | 2 +- lib/rules/no-undef.js | 10 +- lib/rules/no-undefined.js | 2 +- lib/rules/no-underscore-dangle.js | 24 +-- lib/rules/no-unexpected-multiline.js | 6 +- lib/rules/no-unneeded-ternary.js | 12 +- lib/rules/no-unreachable.js | 4 +- lib/rules/no-unused-expressions.js | 16 +- lib/rules/no-unused-labels.js | 6 +- lib/rules/no-unused-vars.js | 32 ++-- lib/rules/no-use-before-define.js | 14 +- lib/rules/no-useless-call.js | 2 +- lib/rules/no-useless-computed-key.js | 2 +- lib/rules/no-useless-constructor.js | 2 +- lib/rules/no-useless-escape.js | 2 +- lib/rules/no-var.js | 2 +- lib/rules/no-void.js | 2 +- lib/rules/no-warning-comments.js | 22 +-- lib/rules/no-with.js | 2 +- lib/rules/object-curly-spacing.js | 16 +- lib/rules/object-shorthand.js | 34 ++-- lib/rules/one-var-declaration-per-line.js | 4 +- lib/rules/one-var.js | 58 +++--- lib/rules/operator-assignment.js | 4 +- lib/rules/operator-linebreak.js | 30 ++-- lib/rules/padded-blocks.js | 24 +-- lib/rules/prefer-arrow-callback.js | 2 +- lib/rules/prefer-const.js | 4 +- lib/rules/prefer-reflect.js | 56 +++--- lib/rules/prefer-spread.js | 2 +- lib/rules/quote-props.js | 44 ++--- lib/rules/quotes.js | 30 ++-- lib/rules/radix.js | 2 +- lib/rules/require-jsdoc.js | 38 ++-- lib/rules/require-yield.js | 6 +- lib/rules/semi-spacing.js | 30 ++-- lib/rules/semi.js | 54 +++--- lib/rules/sort-imports.js | 30 ++-- lib/rules/sort-vars.js | 12 +- lib/rules/space-before-blocks.js | 28 +-- lib/rules/space-before-function-paren.js | 22 +-- lib/rules/space-in-parens.js | 20 +-- lib/rules/space-infix-ops.js | 22 +-- lib/rules/space-unary-ops.js | 30 ++-- lib/rules/spaced-comment.js | 76 ++++---- lib/rules/strict.js | 12 +- lib/rules/use-isnan.js | 2 +- lib/rules/valid-jsdoc.js | 54 +++--- lib/rules/valid-typeof.js | 2 +- lib/rules/vars-on-top.js | 2 +- lib/rules/wrap-iife.js | 4 +- lib/rules/wrap-regex.js | 2 +- lib/rules/yield-star-spacing.js | 16 +- lib/rules/yoda.js | 18 +- packages/eslint-config-eslint/default.yml | 1 + tests/lib/cli-engine.js | 102 +++++------ .../code-path-analysis/code-path-analyzer.js | 46 ++--- tests/lib/code-path-analysis/code-path.js | 2 +- tests/lib/config.js | 4 +- tests/lib/config/config-ops.js | 66 +++---- tests/lib/config/config-validator.js | 16 +- tests/lib/eslint.js | 158 ++++++++--------- tests/lib/rules/array-bracket-spacing.js | 50 +++--- tests/lib/rules/complexity.js | 4 +- tests/lib/rules/generator-star-spacing.js | 134 +++++++------- tests/lib/rules/id-length.js | 30 ++-- tests/lib/rules/indent.js | 106 +++++------ tests/lib/rules/init-declarations.js | 6 +- tests/lib/rules/key-spacing.js | 118 ++++++------- tests/lib/rules/max-depth.js | 4 +- tests/lib/rules/max-nested-callbacks.js | 4 +- tests/lib/rules/max-params.js | 4 +- tests/lib/rules/max-statements-per-line.js | 166 +++++++++--------- tests/lib/rules/max-statements.js | 4 +- tests/lib/rules/new-cap.js | 10 +- tests/lib/rules/no-eval.js | 60 +++---- tests/lib/rules/no-multi-spaces.js | 4 +- tests/lib/rules/no-multiple-empty-lines.js | 4 +- tests/lib/rules/no-unused-vars.js | 34 ++-- tests/lib/rules/no-warning-comments.js | 52 +++--- tests/lib/rules/object-curly-spacing.js | 30 ++-- tests/lib/rules/object-shorthand.js | 8 +- tests/lib/rules/one-var.js | 4 +- tests/lib/rules/padded-blocks.js | 44 ++--- tests/lib/rules/quote-props.js | 12 +- tests/lib/rules/require-jsdoc.js | 76 ++++---- tests/lib/rules/semi.js | 12 +- tests/lib/rules/space-unary-ops.js | 132 +++++++------- tests/lib/rules/valid-jsdoc.js | 98 +++++------ tests/lib/testers/rule-tester.js | 2 +- 239 files changed, 2189 insertions(+), 2188 deletions(-) diff --git a/Makefile.js b/Makefile.js index f69cb291067..4404b472422 100644 --- a/Makefile.js +++ b/Makefile.js @@ -391,12 +391,12 @@ function getFormatterResults() { var formatterFiles = fs.readdirSync("./lib/formatters/"), cli = new CLIEngine({ useEslintrc: false, - baseConfig: { "extends": "eslint:recommended" }, + baseConfig: { extends: "eslint:recommended" }, rules: { "no-else-return": 1, - "indent": [1, 4], + indent: [1, 4], "space-unary-ops": 2, - "semi": [1, "always"], + semi: [1, "always"], "consistent-return": 2 } }), diff --git a/lib/config/config-validator.js b/lib/config/config-validator.js index 71203576961..ebc70516c19 100644 --- a/lib/config/config-validator.js +++ b/lib/config/config-validator.js @@ -35,16 +35,16 @@ function getRuleOptionsSchema(id) { if (Array.isArray(schema)) { if (schema.length) { return { - "type": "array", - "items": schema, - "minItems": 0, - "maxItems": schema.length + type: "array", + items: schema, + minItems: 0, + maxItems: schema.length }; } else { return { - "type": "array", - "minItems": 0, - "maxItems": 0 + type: "array", + minItems: 0, + maxItems: 0 }; } } diff --git a/lib/eslint.js b/lib/eslint.js index e9525f660ab..3a52bb3af18 100755 --- a/lib/eslint.js +++ b/lib/eslint.js @@ -344,11 +344,11 @@ function modifyConfigsFromComments(filename, ast, config, reportingConfig, messa } } else { // comment.type === "Line" if (match[1] === "eslint-disable-line") { - disableReporting(reportingConfig, { "line": comment.loc.start.line, "column": 0 }, Object.keys(parseListConfig(value))); + disableReporting(reportingConfig, { line: comment.loc.start.line, column: 0 }, Object.keys(parseListConfig(value))); enableReporting(reportingConfig, comment.loc.end, Object.keys(parseListConfig(value))); } else if (match[1] === "eslint-disable-next-line") { disableReporting(reportingConfig, comment.loc.start, Object.keys(parseListConfig(value))); - enableReporting(reportingConfig, { "line": comment.loc.start.line + 2 }, Object.keys(parseListConfig(value))); + enableReporting(reportingConfig, { line: comment.loc.start.line + 2 }, Object.keys(parseListConfig(value))); } } } diff --git a/lib/rules/accessor-pairs.js b/lib/rules/accessor-pairs.js index dbcf81ace0f..1b91ef2715a 100644 --- a/lib/rules/accessor-pairs.js +++ b/lib/rules/accessor-pairs.js @@ -78,16 +78,16 @@ module.exports = { recommended: false }, schema: [{ - "type": "object", - "properties": { - "getWithoutSet": { - "type": "boolean" + type: "object", + properties: { + getWithoutSet: { + type: "boolean" }, - "setWithoutGet": { - "type": "boolean" + setWithoutGet: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false }] }, create: function(context) { @@ -146,7 +146,7 @@ module.exports = { } return { - "ObjectExpression": function(node) { + ObjectExpression: function(node) { if (checkSetWithoutGet || checkGetWithoutSet) { checkLonelySetGet(node); } diff --git a/lib/rules/array-bracket-spacing.js b/lib/rules/array-bracket-spacing.js index d2d5ca81313..379ed0fa59f 100644 --- a/lib/rules/array-bracket-spacing.js +++ b/lib/rules/array-bracket-spacing.js @@ -20,22 +20,22 @@ module.exports = { fixable: "whitespace", schema: [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "singleValue": { - "type": "boolean" + type: "object", + properties: { + singleValue: { + type: "boolean" }, - "objectsInArrays": { - "type": "boolean" + objectsInArrays: { + type: "boolean" }, - "arraysInArrays": { - "type": "boolean" + arraysInArrays: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, diff --git a/lib/rules/array-callback-return.js b/lib/rules/array-callback-return.js index 69effa3fce3..714c189c6b5 100644 --- a/lib/rules/array-callback-return.js +++ b/lib/rules/array-callback-return.js @@ -210,7 +210,7 @@ module.exports = { return { // Stacks this function's information. - "onCodePathStart": function(codePath, node) { + onCodePathStart: function(codePath, node) { funcInfo = { upper: funcInfo, codePath: codePath, @@ -223,12 +223,12 @@ module.exports = { }, // Pops this function's information. - "onCodePathEnd": function() { + onCodePathEnd: function() { funcInfo = funcInfo.upper; }, // Checks the return statement is valid. - "ReturnStatement": function(node) { + ReturnStatement: function(node) { if (funcInfo.shouldCheck) { funcInfo.hasReturn = true; diff --git a/lib/rules/arrow-body-style.js b/lib/rules/arrow-body-style.js index 80d5f089cdb..79fde90f805 100644 --- a/lib/rules/arrow-body-style.js +++ b/lib/rules/arrow-body-style.js @@ -18,7 +18,7 @@ module.exports = { schema: [ { - "enum": ["always", "as-needed"] + enum: ["always", "as-needed"] } ] }, @@ -61,7 +61,7 @@ module.exports = { } return { - "ArrowFunctionExpression": validate + ArrowFunctionExpression: validate }; } }; diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index 906a816b418..78ce0450171 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -18,7 +18,7 @@ module.exports = { schema: [ { - "enum": ["always", "as-needed"] + enum: ["always", "as-needed"] } ] }, @@ -55,7 +55,7 @@ module.exports = { } return { - "ArrowFunctionExpression": parens + ArrowFunctionExpression: parens }; } }; diff --git a/lib/rules/arrow-spacing.js b/lib/rules/arrow-spacing.js index d0286472e12..82cec87ed27 100644 --- a/lib/rules/arrow-spacing.js +++ b/lib/rules/arrow-spacing.js @@ -20,16 +20,16 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "before": { - "type": "boolean" + type: "object", + properties: { + before: { + type: "boolean" }, - "after": { - "type": "boolean" + after: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -138,7 +138,7 @@ module.exports = { } return { - "ArrowFunctionExpression": spaces + ArrowFunctionExpression: spaces }; } }; diff --git a/lib/rules/block-scoped-var.js b/lib/rules/block-scoped-var.js index 1d9b6203d16..3da07adcba1 100644 --- a/lib/rules/block-scoped-var.js +++ b/lib/rules/block-scoped-var.js @@ -92,26 +92,26 @@ module.exports = { } return { - "Program": function(node) { + Program: function(node) { stack = [node.range]; }, // Manages scopes. - "BlockStatement": enterScope, + BlockStatement: enterScope, "BlockStatement:exit": exitScope, - "ForStatement": enterScope, + ForStatement: enterScope, "ForStatement:exit": exitScope, - "ForInStatement": enterScope, + ForInStatement: enterScope, "ForInStatement:exit": exitScope, - "ForOfStatement": enterScope, + ForOfStatement: enterScope, "ForOfStatement:exit": exitScope, - "SwitchStatement": enterScope, + SwitchStatement: enterScope, "SwitchStatement:exit": exitScope, - "CatchClause": enterScope, + CatchClause: enterScope, "CatchClause:exit": exitScope, // Finds and reports references which are outside of valid scope. - "VariableDeclaration": checkForVariables + VariableDeclaration: checkForVariables }; } diff --git a/lib/rules/brace-style.js b/lib/rules/brace-style.js index c85ffff1a28..785a71e4e7b 100644 --- a/lib/rules/brace-style.js +++ b/lib/rules/brace-style.js @@ -19,16 +19,16 @@ module.exports = { schema: [ { - "enum": ["1tbs", "stroustrup", "allman"] + enum: ["1tbs", "stroustrup", "allman"] }, { - "type": "object", - "properties": { - "allowSingleLine": { - "type": "boolean" + type: "object", + properties: { + allowSingleLine: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -225,19 +225,19 @@ module.exports = { //-------------------------------------------------------------------------- return { - "FunctionDeclaration": checkBlock("body"), - "FunctionExpression": checkBlock("body"), - "ArrowFunctionExpression": checkBlock("body"), - "IfStatement": checkIfStatement, - "TryStatement": checkTryStatement, - "CatchClause": checkCatchClause, - "DoWhileStatement": checkBlock("body"), - "WhileStatement": checkBlock("body"), - "WithStatement": checkBlock("body"), - "ForStatement": checkBlock("body"), - "ForInStatement": checkBlock("body"), - "ForOfStatement": checkBlock("body"), - "SwitchStatement": checkSwitchStatement + FunctionDeclaration: checkBlock("body"), + FunctionExpression: checkBlock("body"), + ArrowFunctionExpression: checkBlock("body"), + IfStatement: checkIfStatement, + TryStatement: checkTryStatement, + CatchClause: checkCatchClause, + DoWhileStatement: checkBlock("body"), + WhileStatement: checkBlock("body"), + WithStatement: checkBlock("body"), + ForStatement: checkBlock("body"), + ForInStatement: checkBlock("body"), + ForOfStatement: checkBlock("body"), + SwitchStatement: checkSwitchStatement }; } diff --git a/lib/rules/callback-return.js b/lib/rules/callback-return.js index a80ee71f8c1..a995da3a98f 100644 --- a/lib/rules/callback-return.js +++ b/lib/rules/callback-return.js @@ -88,7 +88,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "CallExpression": function(node) { + CallExpression: function(node) { // if we"re not a callback we can return if (!isCallback(node)) { diff --git a/lib/rules/camelcase.js b/lib/rules/camelcase.js index b2ec9197954..28f9e8296b1 100644 --- a/lib/rules/camelcase.js +++ b/lib/rules/camelcase.js @@ -19,13 +19,13 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "properties": { - "enum": ["always", "never"] + type: "object", + properties: { + properties: { + enum: ["always", "never"] } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -73,7 +73,7 @@ module.exports = { return { - "Identifier": function(node) { + Identifier: function(node) { /* * Leading and trailing underscores are commonly used to flag diff --git a/lib/rules/comma-dangle.js b/lib/rules/comma-dangle.js index 77eb091fc96..7c2451b6087 100644 --- a/lib/rules/comma-dangle.js +++ b/lib/rules/comma-dangle.js @@ -39,7 +39,7 @@ module.exports = { schema: [ { - "enum": ["always", "always-multiline", "only-multiline", "never"] + enum: ["always", "always-multiline", "only-multiline", "never"] } ] }, @@ -212,12 +212,12 @@ module.exports = { } return { - "ObjectExpression": checkForTrailingComma, - "ObjectPattern": checkForTrailingComma, - "ArrayExpression": checkForTrailingComma, - "ArrayPattern": checkForTrailingComma, - "ImportDeclaration": checkForTrailingComma, - "ExportNamedDeclaration": checkForTrailingComma + ObjectExpression: checkForTrailingComma, + ObjectPattern: checkForTrailingComma, + ArrayExpression: checkForTrailingComma, + ArrayPattern: checkForTrailingComma, + ImportDeclaration: checkForTrailingComma, + ExportNamedDeclaration: checkForTrailingComma }; } }; diff --git a/lib/rules/comma-spacing.js b/lib/rules/comma-spacing.js index a13e0145ca1..2a4ec1f4173 100644 --- a/lib/rules/comma-spacing.js +++ b/lib/rules/comma-spacing.js @@ -22,16 +22,16 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "before": { - "type": "boolean" + type: "object", + properties: { + before: { + type: "boolean" }, - "after": { - "type": "boolean" + after: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -185,8 +185,8 @@ module.exports = { }, token); }); }, - "ArrayExpression": addNullElementsToIgnoreList, - "ArrayPattern": addNullElementsToIgnoreList + ArrayExpression: addNullElementsToIgnoreList, + ArrayPattern: addNullElementsToIgnoreList }; diff --git a/lib/rules/comma-style.js b/lib/rules/comma-style.js index a9ad990cd27..9c7d266d3dd 100644 --- a/lib/rules/comma-style.js +++ b/lib/rules/comma-style.js @@ -21,19 +21,19 @@ module.exports = { schema: [ { - "enum": ["first", "last"] + enum: ["first", "last"] }, { - "type": "object", - "properties": { - "exceptions": { - "type": "object", - "additionalProperties": { - "type": "boolean" + type: "object", + properties: { + exceptions: { + type: "object", + additionalProperties: { + type: "boolean" } } }, - "additionalProperties": false + additionalProperties: false } ] }, diff --git a/lib/rules/complexity.js b/lib/rules/complexity.js index d06fa36c290..029b739808d 100644 --- a/lib/rules/complexity.js +++ b/lib/rules/complexity.js @@ -20,24 +20,24 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 }, { - "type": "object", - "properties": { - "maximum": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + maximum: { + type: "integer", + minimum: 0 }, - "max": { - "type": "integer", - "minimum": 0 + max: { + type: "integer", + minimum: 0 } }, - "additionalProperties": false + additionalProperties: false } ] } @@ -139,23 +139,23 @@ module.exports = { //-------------------------------------------------------------------------- return { - "FunctionDeclaration": startFunction, - "FunctionExpression": startFunction, - "ArrowFunctionExpression": startFunction, + FunctionDeclaration: startFunction, + FunctionExpression: startFunction, + ArrowFunctionExpression: startFunction, "FunctionDeclaration:exit": endFunction, "FunctionExpression:exit": endFunction, "ArrowFunctionExpression:exit": endFunction, - "CatchClause": increaseComplexity, - "ConditionalExpression": increaseComplexity, - "LogicalExpression": increaseLogicalComplexity, - "ForStatement": increaseComplexity, - "ForInStatement": increaseComplexity, - "ForOfStatement": increaseComplexity, - "IfStatement": increaseComplexity, - "SwitchCase": increaseSwitchComplexity, - "WhileStatement": increaseComplexity, - "DoWhileStatement": increaseComplexity + CatchClause: increaseComplexity, + ConditionalExpression: increaseComplexity, + LogicalExpression: increaseLogicalComplexity, + ForStatement: increaseComplexity, + ForInStatement: increaseComplexity, + ForOfStatement: increaseComplexity, + IfStatement: increaseComplexity, + SwitchCase: increaseSwitchComplexity, + WhileStatement: increaseComplexity, + DoWhileStatement: increaseComplexity }; } diff --git a/lib/rules/computed-property-spacing.js b/lib/rules/computed-property-spacing.js index ff4febb2416..1ae674e90db 100644 --- a/lib/rules/computed-property-spacing.js +++ b/lib/rules/computed-property-spacing.js @@ -22,7 +22,7 @@ module.exports = { schema: [ { - "enum": ["always", "never"] + enum: ["always", "never"] } ] }, diff --git a/lib/rules/consistent-return.js b/lib/rules/consistent-return.js index ee9cc082000..0e9a8c8b0f4 100644 --- a/lib/rules/consistent-return.js +++ b/lib/rules/consistent-return.js @@ -100,7 +100,7 @@ module.exports = { return { // Initializes/Disposes state of each code path. - "onCodePathStart": function(codePath) { + onCodePathStart: function(codePath) { funcInfo = { upper: funcInfo, codePath: codePath, @@ -109,12 +109,12 @@ module.exports = { message: "" }; }, - "onCodePathEnd": function() { + onCodePathEnd: function() { funcInfo = funcInfo.upper; }, // Reports a given return statement if it's inconsistent. - "ReturnStatement": function(node) { + ReturnStatement: function(node) { var hasReturnValue = Boolean(node.argument); if (!funcInfo.hasReturn) { diff --git a/lib/rules/consistent-this.js b/lib/rules/consistent-this.js index 7397cb0289b..042e1a0aaed 100644 --- a/lib/rules/consistent-this.js +++ b/lib/rules/consistent-this.js @@ -17,12 +17,12 @@ module.exports = { }, schema: { - "type": "array", - "items": { - "type": "string", - "minLength": 1 + type: "array", + items: { + type: "string", + minLength: 1 }, - "uniqueItems": true + uniqueItems: true } }, @@ -127,7 +127,7 @@ module.exports = { "FunctionExpression:exit": ensureWasAssigned, "FunctionDeclaration:exit": ensureWasAssigned, - "VariableDeclarator": function(node) { + VariableDeclarator: function(node) { var id = node.id; var isDestructuring = id.type === "ArrayPattern" || id.type === "ObjectPattern"; @@ -137,7 +137,7 @@ module.exports = { } }, - "AssignmentExpression": function(node) { + AssignmentExpression: function(node) { if (node.left.type === "Identifier") { checkAssignment(node, node.left.name, node.right); } diff --git a/lib/rules/constructor-super.js b/lib/rules/constructor-super.js index 1f3ffc01555..4b2aacf5755 100644 --- a/lib/rules/constructor-super.js +++ b/lib/rules/constructor-super.js @@ -159,7 +159,7 @@ module.exports = { * @param {ASTNode} node - The current node. * @returns {void} */ - "onCodePathStart": function(codePath, node) { + onCodePathStart: function(codePath, node) { if (isConstructorFunction(node)) { // Class > ClassBody > MethodDefinition > FunctionExpression @@ -191,7 +191,7 @@ module.exports = { * @param {ASTNode} node - The current node. * @returns {void} */ - "onCodePathEnd": function(codePath, node) { + onCodePathEnd: function(codePath, node) { var hasExtends = funcInfo.hasExtends; // Pop. @@ -221,7 +221,7 @@ module.exports = { * @param {CodePathSegment} segment - A code path segment to initialize. * @returns {void} */ - "onCodePathSegmentStart": function(segment) { + onCodePathSegmentStart: function(segment) { if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) { return; } @@ -251,7 +251,7 @@ module.exports = { * of a loop. * @returns {void} */ - "onCodePathSegmentLoop": function(fromSegment, toSegment) { + onCodePathSegmentLoop: function(fromSegment, toSegment) { if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) { return; } @@ -349,7 +349,7 @@ module.exports = { * @param {ASTNode} node - A ReturnStatement node to check. * @returns {void} */ - "ReturnStatement": function(node) { + ReturnStatement: function(node) { if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) { return; } diff --git a/lib/rules/curly.js b/lib/rules/curly.js index 0503bc1a6f7..0bc5fdb3de4 100644 --- a/lib/rules/curly.js +++ b/lib/rules/curly.js @@ -23,29 +23,29 @@ module.exports = { }, schema: { - "anyOf": [ + anyOf: [ { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["all"] + enum: ["all"] } ], - "minItems": 0, - "maxItems": 1 + minItems: 0, + maxItems: 1 }, { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["multi", "multi-line", "multi-or-nest"] + enum: ["multi", "multi-line", "multi-or-nest"] }, { - "enum": ["consistent"] + enum: ["consistent"] } ], - "minItems": 0, - "maxItems": 2 + minItems: 0, + maxItems: 2 } ] } @@ -271,7 +271,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "IfStatement": function(node) { + IfStatement: function(node) { if (node.parent.type !== "IfStatement") { prepareIfChecks(node).forEach(function(preparedCheck) { preparedCheck.check(); @@ -279,23 +279,23 @@ module.exports = { } }, - "WhileStatement": function(node) { + WhileStatement: function(node) { prepareCheck(node, node.body, "while", "condition").check(); }, - "DoWhileStatement": function(node) { + DoWhileStatement: function(node) { prepareCheck(node, node.body, "do").check(); }, - "ForStatement": function(node) { + ForStatement: function(node) { prepareCheck(node, node.body, "for", "condition").check(); }, - "ForInStatement": function(node) { + ForInStatement: function(node) { prepareCheck(node, node.body, "for-in").check(); }, - "ForOfStatement": function(node) { + ForOfStatement: function(node) { prepareCheck(node, node.body, "for-of").check(); } }; diff --git a/lib/rules/default-case.js b/lib/rules/default-case.js index bc7195552b2..a4f3eef3cc0 100644 --- a/lib/rules/default-case.js +++ b/lib/rules/default-case.js @@ -19,13 +19,13 @@ module.exports = { }, schema: [{ - "type": "object", - "properties": { - "commentPattern": { - "type": "string" + type: "object", + properties: { + commentPattern: { + type: "string" } }, - "additionalProperties": false + additionalProperties: false }] }, @@ -54,7 +54,7 @@ module.exports = { return { - "SwitchStatement": function(node) { + SwitchStatement: function(node) { if (!node.cases.length) { diff --git a/lib/rules/dot-location.js b/lib/rules/dot-location.js index ecf947e9be3..0e1c257d392 100644 --- a/lib/rules/dot-location.js +++ b/lib/rules/dot-location.js @@ -21,7 +21,7 @@ module.exports = { schema: [ { - "enum": ["object", "property"] + enum: ["object", "property"] } ] }, @@ -65,7 +65,7 @@ module.exports = { } return { - "MemberExpression": checkNode + MemberExpression: checkNode }; } }; diff --git a/lib/rules/dot-notation.js b/lib/rules/dot-notation.js index bab95e30a31..07e0b0a8db8 100644 --- a/lib/rules/dot-notation.js +++ b/lib/rules/dot-notation.js @@ -21,16 +21,16 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "allowKeywords": { - "type": "boolean" + type: "object", + properties: { + allowKeywords: { + type: "boolean" }, - "allowPattern": { - "type": "string" + allowPattern: { + type: "string" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -46,7 +46,7 @@ module.exports = { } return { - "MemberExpression": function(node) { + MemberExpression: function(node) { if ( node.computed && node.property.type === "Literal" && diff --git a/lib/rules/eol-last.js b/lib/rules/eol-last.js index 9e9eb5b18ae..1bd7c2897a6 100644 --- a/lib/rules/eol-last.js +++ b/lib/rules/eol-last.js @@ -20,7 +20,7 @@ module.exports = { schema: [ { - "enum": ["unix", "windows"] + enum: ["unix", "windows"] } ] }, @@ -33,7 +33,7 @@ module.exports = { return { - "Program": function checkBadEOF(node) { + Program: function checkBadEOF(node) { // Get the whole source code, not for node only. var src = context.getSource(), diff --git a/lib/rules/eqeqeq.js b/lib/rules/eqeqeq.js index 593b34b4342..f1d1d154292 100644 --- a/lib/rules/eqeqeq.js +++ b/lib/rules/eqeqeq.js @@ -19,7 +19,7 @@ module.exports = { schema: [ { - "enum": ["smart", "allow-null"] + enum: ["smart", "allow-null"] } ] }, @@ -81,7 +81,7 @@ module.exports = { } return { - "BinaryExpression": function(node) { + BinaryExpression: function(node) { if (node.operator !== "==" && node.operator !== "!=") { return; } diff --git a/lib/rules/func-names.js b/lib/rules/func-names.js index cc49ce46893..51a1ffe0468 100644 --- a/lib/rules/func-names.js +++ b/lib/rules/func-names.js @@ -40,7 +40,7 @@ module.exports = { } return { - "FunctionExpression": function(node) { + FunctionExpression: function(node) { var name = node.id && node.id.name; diff --git a/lib/rules/func-style.js b/lib/rules/func-style.js index 581fbe04fc6..9dad6c07556 100644 --- a/lib/rules/func-style.js +++ b/lib/rules/func-style.js @@ -18,16 +18,16 @@ module.exports = { schema: [ { - "enum": ["declaration", "expression"] + enum: ["declaration", "expression"] }, { - "type": "object", - "properties": { - "allowArrowFunctions": { - "type": "boolean" + type: "object", + properties: { + allowArrowFunctions: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -40,11 +40,11 @@ module.exports = { stack = []; var nodesToCheck = { - "Program": function() { + Program: function() { stack = []; }, - "FunctionDeclaration": function(node) { + FunctionDeclaration: function(node) { stack.push(false); if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") { @@ -55,7 +55,7 @@ module.exports = { stack.pop(); }, - "FunctionExpression": function(node) { + FunctionExpression: function(node) { stack.push(false); if (enforceDeclarations && node.parent.type === "VariableDeclarator") { @@ -66,7 +66,7 @@ module.exports = { stack.pop(); }, - "ThisExpression": function() { + ThisExpression: function() { if (stack.length > 0) { stack[stack.length - 1] = true; } diff --git a/lib/rules/generator-star-spacing.js b/lib/rules/generator-star-spacing.js index 9152e1e63b4..f05f9f4201b 100644 --- a/lib/rules/generator-star-spacing.js +++ b/lib/rules/generator-star-spacing.js @@ -21,17 +21,17 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "enum": ["before", "after", "both", "neither"] + enum: ["before", "after", "both", "neither"] }, { - "type": "object", - "properties": { - "before": {"type": "boolean"}, - "after": {"type": "boolean"} + type: "object", + properties: { + before: {type: "boolean"}, + after: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ] } @@ -114,8 +114,8 @@ module.exports = { } return { - "FunctionDeclaration": checkFunction, - "FunctionExpression": checkFunction + FunctionDeclaration: checkFunction, + FunctionExpression: checkFunction }; } diff --git a/lib/rules/global-require.js b/lib/rules/global-require.js index c6413e093ed..d1298719a9a 100644 --- a/lib/rules/global-require.js +++ b/lib/rules/global-require.js @@ -61,7 +61,7 @@ module.exports = { create: function(context) { return { - "CallExpression": function(node) { + CallExpression: function(node) { var currentScope = context.getScope(), isGoodRequire; diff --git a/lib/rules/guard-for-in.js b/lib/rules/guard-for-in.js index cd0d6b778a8..b43dda39e46 100644 --- a/lib/rules/guard-for-in.js +++ b/lib/rules/guard-for-in.js @@ -24,7 +24,7 @@ module.exports = { return { - "ForInStatement": function(node) { + ForInStatement: function(node) { /* * If the for-in statement has {}, then the real body is the body diff --git a/lib/rules/handle-callback-err.js b/lib/rules/handle-callback-err.js index ce694fef4f5..09bf0da9771 100644 --- a/lib/rules/handle-callback-err.js +++ b/lib/rules/handle-callback-err.js @@ -19,7 +19,7 @@ module.exports = { schema: [ { - "type": "string" + type: "string" } ] }, @@ -82,9 +82,9 @@ module.exports = { } return { - "FunctionDeclaration": checkForError, - "FunctionExpression": checkForError, - "ArrowFunctionExpression": checkForError + FunctionDeclaration: checkForError, + FunctionExpression: checkForError, + ArrowFunctionExpression: checkForError }; } diff --git a/lib/rules/id-blacklist.js b/lib/rules/id-blacklist.js index 83f9578d2ff..142d8d21f4b 100644 --- a/lib/rules/id-blacklist.js +++ b/lib/rules/id-blacklist.js @@ -19,11 +19,11 @@ module.exports = { }, schema: { - "type": "array", - "items": { - "type": "string" + type: "array", + items: { + type: "string" }, - "uniqueItems": true + uniqueItems: true } }, @@ -74,7 +74,7 @@ module.exports = { return { - "Identifier": function(node) { + Identifier: function(node) { var name = node.name, effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent; diff --git a/lib/rules/id-length.js b/lib/rules/id-length.js index c21f801a12d..43437513acb 100644 --- a/lib/rules/id-length.js +++ b/lib/rules/id-length.js @@ -20,26 +20,26 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "min": { - "type": "number" + type: "object", + properties: { + min: { + type: "number" }, - "max": { - "type": "number" + max: { + type: "number" }, - "exceptions": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" + exceptions: { + type: "array", + uniqueItems: true, + items: { + type: "string" } }, - "properties": { - "enum": ["always", "never"] + properties: { + enum: ["always", "never"] } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -57,7 +57,7 @@ module.exports = { }, {}); var SUPPORTED_EXPRESSIONS = { - "MemberExpression": properties && function(parent) { + MemberExpression: properties && function(parent) { return !parent.computed && ( // regular property assignment @@ -66,23 +66,23 @@ module.exports = { parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent) ); }, - "AssignmentPattern": function(parent, node) { + AssignmentPattern: function(parent, node) { return parent.left === node; }, - "VariableDeclarator": function(parent, node) { + VariableDeclarator: function(parent, node) { return parent.id === node; }, - "Property": properties && function(parent, node) { + Property: properties && function(parent, node) { return parent.key === node; }, - "ImportDefaultSpecifier": true, - "RestElement": true, - "FunctionExpression": true, - "ArrowFunctionExpression": true, - "ClassDeclaration": true, - "FunctionDeclaration": true, - "MethodDefinition": true, - "CatchClause": true + ImportDefaultSpecifier: true, + RestElement: true, + FunctionExpression: true, + ArrowFunctionExpression: true, + ClassDeclaration: true, + FunctionDeclaration: true, + MethodDefinition: true, + CatchClause: true }; return { diff --git a/lib/rules/id-match.js b/lib/rules/id-match.js index fd03b8bf6d3..b924a8e81cd 100644 --- a/lib/rules/id-match.js +++ b/lib/rules/id-match.js @@ -19,13 +19,13 @@ module.exports = { schema: [ { - "type": "string" + type: "string" }, { - "type": "object", - "properties": { - "properties": { - "type": "boolean" + type: "object", + properties: { + properties: { + type: "boolean" } } } @@ -86,7 +86,7 @@ module.exports = { return { - "Identifier": function(node) { + Identifier: function(node) { var name = node.name, effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent; diff --git a/lib/rules/indent.js b/lib/rules/indent.js index 35a4f906e42..3e8f4b92e18 100644 --- a/lib/rules/indent.js +++ b/lib/rules/indent.js @@ -26,50 +26,50 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "enum": ["tab"] + enum: ["tab"] }, { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 } ] }, { - "type": "object", - "properties": { - "SwitchCase": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + SwitchCase: { + type: "integer", + minimum: 0 }, - "VariableDeclarator": { - "oneOf": [ + VariableDeclarator: { + oneOf: [ { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 }, { - "type": "object", - "properties": { - "var": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + var: { + type: "integer", + minimum: 0 }, - "let": { - "type": "integer", - "minimum": 0 + let: { + type: "integer", + minimum: 0 }, - "const": { - "type": "integer", - "minimum": 0 + const: { + type: "integer", + minimum: 0 } } } ] } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -697,7 +697,7 @@ module.exports = { } return { - "Program": function(node) { + Program: function(node) { if (node.body.length > 0) { // Root nodes should have no indent @@ -705,41 +705,41 @@ module.exports = { } }, - "ClassBody": blockIndentationCheck, + ClassBody: blockIndentationCheck, - "BlockStatement": blockIndentationCheck, + BlockStatement: blockIndentationCheck, - "WhileStatement": blockLessNodes, + WhileStatement: blockLessNodes, - "ForStatement": blockLessNodes, + ForStatement: blockLessNodes, - "ForInStatement": blockLessNodes, + ForInStatement: blockLessNodes, - "ForOfStatement": blockLessNodes, + ForOfStatement: blockLessNodes, - "DoWhileStatement": blockLessNodes, + DoWhileStatement: blockLessNodes, - "IfStatement": function(node) { + IfStatement: function(node) { if (node.consequent.type !== "BlockStatement" && node.consequent.loc.start.line > node.loc.start.line) { blockIndentationCheck(node); } }, - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { if (node.declarations[node.declarations.length - 1].loc.start.line > node.declarations[0].loc.start.line) { checkIndentInVariableDeclarations(node); } }, - "ObjectExpression": function(node) { + ObjectExpression: function(node) { checkIndentInArrayOrObjectBlock(node); }, - "ArrayExpression": function(node) { + ArrayExpression: function(node) { checkIndentInArrayOrObjectBlock(node); }, - "SwitchStatement": function(node) { + SwitchStatement: function(node) { // Switch is not a 'BlockStatement' var switchIndent = getNodeIndent(node); @@ -751,7 +751,7 @@ module.exports = { checkLastNodeLineIndent(node, switchIndent); }, - "SwitchCase": function(node) { + SwitchCase: function(node) { // Skip inline cases if (isSingleLineNode(node)) { diff --git a/lib/rules/init-declarations.js b/lib/rules/init-declarations.js index 68f5c317af4..66b0a0aea43 100644 --- a/lib/rules/init-declarations.js +++ b/lib/rules/init-declarations.js @@ -51,35 +51,35 @@ module.exports = { }, schema: { - "anyOf": [ + anyOf: [ { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["always"] + enum: ["always"] } ], - "minItems": 0, - "maxItems": 1 + minItems: 0, + maxItems: 1 }, { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["never"] + enum: ["never"] }, { - "type": "object", - "properties": { - "ignoreForLoopInit": { - "type": "boolean" + type: "object", + properties: { + ignoreForLoopInit: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ], - "minItems": 0, - "maxItems": 2 + minItems: 0, + maxItems: 2 } ] } diff --git a/lib/rules/jsx-quotes.js b/lib/rules/jsx-quotes.js index ad9457d6400..6b3a2efef71 100644 --- a/lib/rules/jsx-quotes.js +++ b/lib/rules/jsx-quotes.js @@ -48,7 +48,7 @@ module.exports = { schema: [ { - "enum": [ "prefer-single", "prefer-double" ] + enum: [ "prefer-single", "prefer-double" ] } ] }, @@ -68,7 +68,7 @@ module.exports = { } return { - "JSXAttribute": function(node) { + JSXAttribute: function(node) { var attributeValue = node.value; if (attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) { diff --git a/lib/rules/key-spacing.js b/lib/rules/key-spacing.js index e8179496278..1bc14aefec0 100644 --- a/lib/rules/key-spacing.js +++ b/lib/rules/key-spacing.js @@ -119,63 +119,63 @@ module.exports = { }, schema: [{ - "anyOf": [ + anyOf: [ { - "type": "object", - "properties": { - "align": { - "enum": ["colon", "value"] + type: "object", + properties: { + align: { + enum: ["colon", "value"] }, - "mode": { - "enum": ["strict", "minimum"] + mode: { + enum: ["strict", "minimum"] }, - "beforeColon": { - "type": "boolean" + beforeColon: { + type: "boolean" }, - "afterColon": { - "type": "boolean" + afterColon: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false }, { - "type": "object", - "properties": { - "singleLine": { - "type": "object", - "properties": { - "mode": { - "enum": ["strict", "minimum"] + type: "object", + properties: { + singleLine: { + type: "object", + properties: { + mode: { + enum: ["strict", "minimum"] }, - "beforeColon": { - "type": "boolean" + beforeColon: { + type: "boolean" }, - "afterColon": { - "type": "boolean" + afterColon: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false }, - "multiLine": { - "type": "object", - "properties": { - "align": { - "enum": ["colon", "value"] + multiLine: { + type: "object", + properties: { + align: { + enum: ["colon", "value"] }, - "mode": { - "enum": ["strict", "minimum"] + mode: { + enum: ["strict", "minimum"] }, - "beforeColon": { - "type": "boolean" + beforeColon: { + type: "boolean" }, - "afterColon": { - "type": "boolean" + afterColon: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } }, - "additionalProperties": false + additionalProperties: false } ] }] @@ -427,7 +427,7 @@ module.exports = { if (multiLineOptions.align) { // Verify vertical alignment return { - "ObjectExpression": function(node) { + ObjectExpression: function(node) { if (isSingleLine(node)) { verifyListSpacing(node.properties.filter(isKeyValueProperty)); } else { @@ -439,7 +439,7 @@ module.exports = { } else { // Obey beforeColon and afterColon in each property as configured return { - "Property": function(node) { + Property: function(node) { verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions); } }; diff --git a/lib/rules/keyword-spacing.js b/lib/rules/keyword-spacing.js index f20ff2b4b90..f771029a581 100644 --- a/lib/rules/keyword-spacing.js +++ b/lib/rules/keyword-spacing.js @@ -75,27 +75,27 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "before": {"type": "boolean"}, - "after": {"type": "boolean"}, - "overrides": { - "type": "object", - "properties": KEYS.reduce(function(retv, key) { + type: "object", + properties: { + before: {type: "boolean"}, + after: {type: "boolean"}, + overrides: { + type: "object", + properties: KEYS.reduce(function(retv, key) { retv[key] = { - "type": "object", - "properties": { - "before": {"type": "boolean"}, - "after": {"type": "boolean"} + type: "object", + properties: { + before: {type: "boolean"}, + after: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false }; return retv; }, {}), - "additionalProperties": false + additionalProperties: false } }, - "additionalProperties": false + additionalProperties: false } ] }, diff --git a/lib/rules/linebreak-style.js b/lib/rules/linebreak-style.js index 7f7378bb40c..d99d7e58579 100644 --- a/lib/rules/linebreak-style.js +++ b/lib/rules/linebreak-style.js @@ -21,7 +21,7 @@ module.exports = { schema: [ { - "enum": ["unix", "windows"] + enum: ["unix", "windows"] } ] }, @@ -53,7 +53,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program": function checkForlinebreakStyle(node) { + Program: function checkForlinebreakStyle(node) { var linebreakStyle = context.options[0] || "unix", expectedLF = linebreakStyle === "unix", expectedLFChars = expectedLF ? "\n" : "\r\n", diff --git a/lib/rules/lines-around-comment.js b/lib/rules/lines-around-comment.js index 6242adf54c7..92fc3252ae9 100644 --- a/lib/rules/lines-around-comment.js +++ b/lib/rules/lines-around-comment.js @@ -75,40 +75,40 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "beforeBlockComment": { - "type": "boolean" + type: "object", + properties: { + beforeBlockComment: { + type: "boolean" }, - "afterBlockComment": { - "type": "boolean" + afterBlockComment: { + type: "boolean" }, - "beforeLineComment": { - "type": "boolean" + beforeLineComment: { + type: "boolean" }, - "afterLineComment": { - "type": "boolean" + afterLineComment: { + type: "boolean" }, - "allowBlockStart": { - "type": "boolean" + allowBlockStart: { + type: "boolean" }, - "allowBlockEnd": { - "type": "boolean" + allowBlockEnd: { + type: "boolean" }, - "allowObjectStart": { - "type": "boolean" + allowObjectStart: { + type: "boolean" }, - "allowObjectEnd": { - "type": "boolean" + allowObjectEnd: { + type: "boolean" }, - "allowArrayStart": { - "type": "boolean" + allowArrayStart: { + type: "boolean" }, - "allowArrayEnd": { - "type": "boolean" + allowArrayEnd: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -323,7 +323,7 @@ module.exports = { return { - "LineComment": function(node) { + LineComment: function(node) { if (options.beforeLineComment || options.afterLineComment) { checkForEmptyLine(node, { after: options.afterLineComment, @@ -332,7 +332,7 @@ module.exports = { } }, - "BlockComment": function(node) { + BlockComment: function(node) { if (options.beforeBlockComment || options.afterBlockComment) { checkForEmptyLine(node, { after: options.afterBlockComment, diff --git a/lib/rules/max-depth.js b/lib/rules/max-depth.js index 37ff0d884d7..317f06c68f3 100644 --- a/lib/rules/max-depth.js +++ b/lib/rules/max-depth.js @@ -19,24 +19,24 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 }, { - "type": "object", - "properties": { - "maximum": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + maximum: { + type: "integer", + minimum: 0 }, - "max": { - "type": "integer", - "minimum": 0 + max: { + type: "integer", + minimum: 0 } }, - "additionalProperties": false + additionalProperties: false } ] } @@ -110,24 +110,24 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program": startFunction, - "FunctionDeclaration": startFunction, - "FunctionExpression": startFunction, - "ArrowFunctionExpression": startFunction, + Program: startFunction, + FunctionDeclaration: startFunction, + FunctionExpression: startFunction, + ArrowFunctionExpression: startFunction, - "IfStatement": function(node) { + IfStatement: function(node) { if (node.parent.type !== "IfStatement") { pushBlock(node); } }, - "SwitchStatement": pushBlock, - "TryStatement": pushBlock, - "DoWhileStatement": pushBlock, - "WhileStatement": pushBlock, - "WithStatement": pushBlock, - "ForStatement": pushBlock, - "ForInStatement": pushBlock, - "ForOfStatement": pushBlock, + SwitchStatement: pushBlock, + TryStatement: pushBlock, + DoWhileStatement: pushBlock, + WhileStatement: pushBlock, + WithStatement: pushBlock, + ForStatement: pushBlock, + ForInStatement: pushBlock, + ForOfStatement: pushBlock, "IfStatement:exit": popBlock, "SwitchStatement:exit": popBlock, diff --git a/lib/rules/max-len.js b/lib/rules/max-len.js index 322c9439955..1ba539a1192 100644 --- a/lib/rules/max-len.js +++ b/lib/rules/max-len.js @@ -10,42 +10,42 @@ //------------------------------------------------------------------------------ var OPTIONS_SCHEMA = { - "type": "object", - "properties": { - "code": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + code: { + type: "integer", + minimum: 0 }, - "comments": { - "type": "integer", - "minimum": 0 + comments: { + type: "integer", + minimum: 0 }, - "tabWidth": { - "type": "integer", - "minimum": 0 + tabWidth: { + type: "integer", + minimum: 0 }, - "ignorePattern": { - "type": "string" + ignorePattern: { + type: "string" }, - "ignoreComments": { - "type": "boolean" + ignoreComments: { + type: "boolean" }, - "ignoreUrls": { - "type": "boolean" + ignoreUrls: { + type: "boolean" }, - "ignoreTrailingComments": { - "type": "boolean" + ignoreTrailingComments: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false }; var OPTIONS_OR_INTEGER_SCHEMA = { - "anyOf": [ + anyOf: [ OPTIONS_SCHEMA, { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 } ] }; @@ -251,7 +251,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program": checkProgramForMaxLength + Program: checkProgramForMaxLength }; } diff --git a/lib/rules/max-nested-callbacks.js b/lib/rules/max-nested-callbacks.js index 52cc2d37660..06554127c63 100644 --- a/lib/rules/max-nested-callbacks.js +++ b/lib/rules/max-nested-callbacks.js @@ -19,24 +19,24 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 }, { - "type": "object", - "properties": { - "maximum": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + maximum: { + type: "integer", + minimum: 0 }, - "max": { - "type": "integer", - "minimum": 0 + max: { + type: "integer", + minimum: 0 } }, - "additionalProperties": false + additionalProperties: false } ] } @@ -101,10 +101,10 @@ module.exports = { //-------------------------------------------------------------------------- return { - "ArrowFunctionExpression": checkFunction, + ArrowFunctionExpression: checkFunction, "ArrowFunctionExpression:exit": popStack, - "FunctionExpression": checkFunction, + FunctionExpression: checkFunction, "FunctionExpression:exit": popStack }; diff --git a/lib/rules/max-params.js b/lib/rules/max-params.js index c24bb4706a1..5d9d64fac10 100644 --- a/lib/rules/max-params.js +++ b/lib/rules/max-params.js @@ -19,24 +19,24 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 }, { - "type": "object", - "properties": { - "maximum": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + maximum: { + type: "integer", + minimum: 0 }, - "max": { - "type": "integer", - "minimum": 0 + max: { + type: "integer", + minimum: 0 } }, - "additionalProperties": false + additionalProperties: false } ] } @@ -74,9 +74,9 @@ module.exports = { } return { - "FunctionDeclaration": checkFunction, - "ArrowFunctionExpression": checkFunction, - "FunctionExpression": checkFunction + FunctionDeclaration: checkFunction, + ArrowFunctionExpression: checkFunction, + FunctionExpression: checkFunction }; } diff --git a/lib/rules/max-statements-per-line.js b/lib/rules/max-statements-per-line.js index 193147a6e88..64058f0d30b 100644 --- a/lib/rules/max-statements-per-line.js +++ b/lib/rules/max-statements-per-line.js @@ -18,13 +18,13 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "max": { - "type": "integer" + type: "object", + properties: { + max: { + type: "integer" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -104,9 +104,9 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program": checkLinesInBody, - "BlockStatement": checkLinesInBody, - "SwitchCase": checkLinesInConsequent + Program: checkLinesInBody, + BlockStatement: checkLinesInBody, + SwitchCase: checkLinesInConsequent }; } diff --git a/lib/rules/max-statements.js b/lib/rules/max-statements.js index 41173cc4561..72904c64bad 100644 --- a/lib/rules/max-statements.js +++ b/lib/rules/max-statements.js @@ -19,35 +19,35 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "type": "integer", - "minimum": 0 + type: "integer", + minimum: 0 }, { - "type": "object", - "properties": { - "maximum": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + maximum: { + type: "integer", + minimum: 0 }, - "max": { - "type": "integer", - "minimum": 0 + max: { + type: "integer", + minimum: 0 } }, - "additionalProperties": false + additionalProperties: false } ] }, { - "type": "object", - "properties": { - "ignoreTopLevelFunctions": { - "type": "boolean" + type: "object", + properties: { + ignoreTopLevelFunctions: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -131,11 +131,11 @@ module.exports = { //-------------------------------------------------------------------------- return { - "FunctionDeclaration": startFunction, - "FunctionExpression": startFunction, - "ArrowFunctionExpression": startFunction, + FunctionDeclaration: startFunction, + FunctionExpression: startFunction, + ArrowFunctionExpression: startFunction, - "BlockStatement": countStatements, + BlockStatement: countStatements, "FunctionDeclaration:exit": endFunction, "FunctionExpression:exit": endFunction, diff --git a/lib/rules/new-cap.js b/lib/rules/new-cap.js index 442f5e6eb08..697b60d0f10 100644 --- a/lib/rules/new-cap.js +++ b/lib/rules/new-cap.js @@ -84,31 +84,31 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "newIsCap": { - "type": "boolean" + type: "object", + properties: { + newIsCap: { + type: "boolean" }, - "capIsNew": { - "type": "boolean" + capIsNew: { + type: "boolean" }, - "newIsCapExceptions": { - "type": "array", - "items": { - "type": "string" + newIsCapExceptions: { + type: "array", + items: { + type: "string" } }, - "capIsNewExceptions": { - "type": "array", - "items": { - "type": "string" + capIsNewExceptions: { + type: "array", + items: { + type: "string" } }, - "properties": { - "type": "boolean" + properties: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, diff --git a/lib/rules/new-parens.js b/lib/rules/new-parens.js index e51dffc8e52..0d7a84e3cc4 100644 --- a/lib/rules/new-parens.js +++ b/lib/rules/new-parens.js @@ -24,7 +24,7 @@ module.exports = { return { - "NewExpression": function(node) { + NewExpression: function(node) { var tokens = context.getTokens(node); var prenticesTokens = tokens.filter(function(token) { return token.value === "(" || token.value === ")"; diff --git a/lib/rules/newline-after-var.js b/lib/rules/newline-after-var.js index 6eb3d4ade2f..fd80c8c5422 100644 --- a/lib/rules/newline-after-var.js +++ b/lib/rules/newline-after-var.js @@ -19,7 +19,7 @@ module.exports = { schema: [ { - "enum": ["never", "always"] + enum: ["never", "always"] } ] }, @@ -170,7 +170,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "VariableDeclaration": checkForBlankLine + VariableDeclaration: checkForBlankLine }; } diff --git a/lib/rules/newline-per-chained-call.js b/lib/rules/newline-per-chained-call.js index f703447db01..80401415aa8 100644 --- a/lib/rules/newline-per-chained-call.js +++ b/lib/rules/newline-per-chained-call.js @@ -19,15 +19,15 @@ module.exports = { }, schema: [{ - "type": "object", - "properties": { - "ignoreChainWithDepth": { - "type": "integer", - "minimum": 1, - "maximum": 10 + type: "object", + properties: { + ignoreChainWithDepth: { + type: "integer", + minimum: 1, + maximum: 10 } }, - "additionalProperties": false + additionalProperties: false }] }, diff --git a/lib/rules/no-alert.js b/lib/rules/no-alert.js index 34c0397b28a..e491dfefc55 100644 --- a/lib/rules/no-alert.js +++ b/lib/rules/no-alert.js @@ -112,11 +112,11 @@ module.exports = { return { - "Program": function() { + Program: function() { globalScope = context.getScope(); }, - "CallExpression": function(node) { + CallExpression: function(node) { var callee = node.callee, identifierName, currentScope = context.getScope(); diff --git a/lib/rules/no-array-constructor.js b/lib/rules/no-array-constructor.js index 417da13f023..389725c62c7 100644 --- a/lib/rules/no-array-constructor.js +++ b/lib/rules/no-array-constructor.js @@ -39,8 +39,8 @@ module.exports = { } return { - "CallExpression": check, - "NewExpression": check + CallExpression: check, + NewExpression: check }; } diff --git a/lib/rules/no-bitwise.js b/lib/rules/no-bitwise.js index 86e7992ecdb..0294998ecc1 100644 --- a/lib/rules/no-bitwise.js +++ b/lib/rules/no-bitwise.js @@ -28,20 +28,20 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "allow": { - "type": "array", - "items": { - "enum": BITWISE_OPERATORS + type: "object", + properties: { + allow: { + type: "array", + items: { + enum: BITWISE_OPERATORS }, - "uniqueItems": true + uniqueItems: true }, - "int32Hint": { - "type": "boolean" + int32Hint: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -100,9 +100,9 @@ module.exports = { } return { - "AssignmentExpression": checkNodeForBitwiseOperator, - "BinaryExpression": checkNodeForBitwiseOperator, - "UnaryExpression": checkNodeForBitwiseOperator + AssignmentExpression: checkNodeForBitwiseOperator, + BinaryExpression: checkNodeForBitwiseOperator, + UnaryExpression: checkNodeForBitwiseOperator }; } diff --git a/lib/rules/no-caller.js b/lib/rules/no-caller.js index ac40939ba26..0405fdaeb90 100644 --- a/lib/rules/no-caller.js +++ b/lib/rules/no-caller.js @@ -24,7 +24,7 @@ module.exports = { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { var objectName = node.object.name, propertyName = node.property.name; diff --git a/lib/rules/no-case-declarations.js b/lib/rules/no-case-declarations.js index 17ef3885d4a..8ef202538ec 100644 --- a/lib/rules/no-case-declarations.js +++ b/lib/rules/no-case-declarations.js @@ -39,7 +39,7 @@ module.exports = { } return { - "SwitchCase": function(node) { + SwitchCase: function(node) { for (var i = 0; i < node.consequent.length; i++) { var statement = node.consequent[i]; diff --git a/lib/rules/no-catch-shadow.js b/lib/rules/no-catch-shadow.js index 2d0d00abe89..4a206833c08 100644 --- a/lib/rules/no-catch-shadow.js +++ b/lib/rules/no-catch-shadow.js @@ -48,7 +48,7 @@ module.exports = { return { - "CatchClause": function(node) { + CatchClause: function(node) { var scope = context.getScope(); // When blockBindings is enabled, CatchClause creates its own scope diff --git a/lib/rules/no-class-assign.js b/lib/rules/no-class-assign.js index fa614f7ee0e..1e4d3243d8b 100644 --- a/lib/rules/no-class-assign.js +++ b/lib/rules/no-class-assign.js @@ -49,8 +49,8 @@ module.exports = { } return { - "ClassDeclaration": checkForClass, - "ClassExpression": checkForClass + ClassDeclaration: checkForClass, + ClassExpression: checkForClass }; } diff --git a/lib/rules/no-cond-assign.js b/lib/rules/no-cond-assign.js index 9c6ae0b49a2..27b99c6b545 100644 --- a/lib/rules/no-cond-assign.js +++ b/lib/rules/no-cond-assign.js @@ -5,10 +5,10 @@ "use strict"; var NODE_DESCRIPTIONS = { - "DoWhileStatement": "a 'do...while' statement", - "ForStatement": "a 'for' statement", - "IfStatement": "an 'if' statement", - "WhileStatement": "a 'while' statement" + DoWhileStatement: "a 'do...while' statement", + ForStatement: "a 'for' statement", + IfStatement: "an 'if' statement", + WhileStatement: "a 'while' statement" }; //------------------------------------------------------------------------------ @@ -25,7 +25,7 @@ module.exports = { schema: [ { - "enum": ["except-parens", "always"] + enum: ["except-parens", "always"] } ] }, @@ -129,15 +129,15 @@ module.exports = { if (prohibitAssign === "always") { return { - "AssignmentExpression": testForConditionalAncestor + AssignmentExpression: testForConditionalAncestor }; } return { - "DoWhileStatement": testForAssign, - "ForStatement": testForAssign, - "IfStatement": testForAssign, - "WhileStatement": testForAssign + DoWhileStatement: testForAssign, + ForStatement: testForAssign, + IfStatement: testForAssign, + WhileStatement: testForAssign }; } diff --git a/lib/rules/no-confusing-arrow.js b/lib/rules/no-confusing-arrow.js index 093d3f16e84..d951a53cf97 100644 --- a/lib/rules/no-confusing-arrow.js +++ b/lib/rules/no-confusing-arrow.js @@ -59,7 +59,7 @@ module.exports = { } return { - "ArrowFunctionExpression": checkArrowFunc + ArrowFunctionExpression: checkArrowFunc }; } }; diff --git a/lib/rules/no-console.js b/lib/rules/no-console.js index 4bd3345e70c..18a897409f6 100644 --- a/lib/rules/no-console.js +++ b/lib/rules/no-console.js @@ -19,18 +19,18 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "allow": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + allow: { + type: "array", + items: { + type: "string" }, - "minItems": 1, - "uniqueItems": true + minItems: 1, + uniqueItems: true } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -39,7 +39,7 @@ module.exports = { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { if (node.object.name === "console") { var blockConsole = true; diff --git a/lib/rules/no-const-assign.js b/lib/rules/no-const-assign.js index e775d81a6d8..344e05a644e 100644 --- a/lib/rules/no-const-assign.js +++ b/lib/rules/no-const-assign.js @@ -39,7 +39,7 @@ module.exports = { } return { - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { if (node.kind === "const") { context.getDeclaredVariables(node).forEach(checkVariable); } diff --git a/lib/rules/no-constant-condition.js b/lib/rules/no-constant-condition.js index 39b7d0ac486..0072491bee5 100644 --- a/lib/rules/no-constant-condition.js +++ b/lib/rules/no-constant-condition.js @@ -107,11 +107,11 @@ module.exports = { //-------------------------------------------------------------------------- return { - "ConditionalExpression": checkConstantCondition, - "IfStatement": checkConstantCondition, - "WhileStatement": checkConstantCondition, - "DoWhileStatement": checkConstantCondition, - "ForStatement": checkConstantCondition + ConditionalExpression: checkConstantCondition, + IfStatement: checkConstantCondition, + WhileStatement: checkConstantCondition, + DoWhileStatement: checkConstantCondition, + ForStatement: checkConstantCondition }; } diff --git a/lib/rules/no-continue.js b/lib/rules/no-continue.js index 343b1f1b990..246df89ebe4 100644 --- a/lib/rules/no-continue.js +++ b/lib/rules/no-continue.js @@ -23,7 +23,7 @@ module.exports = { create: function(context) { return { - "ContinueStatement": function(node) { + ContinueStatement: function(node) { context.report(node, "Unexpected use of continue statement"); } }; diff --git a/lib/rules/no-control-regex.js b/lib/rules/no-control-regex.js index f6c9692f8bd..cf1e8d5c771 100644 --- a/lib/rules/no-control-regex.js +++ b/lib/rules/no-control-regex.js @@ -52,7 +52,7 @@ module.exports = { } return { - "Literal": function(node) { + Literal: function(node) { var computedValue, regex = getRegExp(node); diff --git a/lib/rules/no-debugger.js b/lib/rules/no-debugger.js index 285cc811ab7..552294bd674 100644 --- a/lib/rules/no-debugger.js +++ b/lib/rules/no-debugger.js @@ -23,7 +23,7 @@ module.exports = { create: function(context) { return { - "DebuggerStatement": function(node) { + DebuggerStatement: function(node) { context.report(node, "Unexpected 'debugger' statement."); } }; diff --git a/lib/rules/no-delete-var.js b/lib/rules/no-delete-var.js index a34ffaf5703..c1d717a15ba 100644 --- a/lib/rules/no-delete-var.js +++ b/lib/rules/no-delete-var.js @@ -24,7 +24,7 @@ module.exports = { return { - "UnaryExpression": function(node) { + UnaryExpression: function(node) { if (node.operator === "delete" && node.argument.type === "Identifier") { context.report(node, "Variables should not be deleted."); } diff --git a/lib/rules/no-div-regex.js b/lib/rules/no-div-regex.js index d556da64180..58c44662cb9 100644 --- a/lib/rules/no-div-regex.js +++ b/lib/rules/no-div-regex.js @@ -24,7 +24,7 @@ module.exports = { return { - "Literal": function(node) { + Literal: function(node) { var token = context.getFirstToken(node); if (token.type === "RegularExpression" && token.value[1] === "=") { diff --git a/lib/rules/no-dupe-args.js b/lib/rules/no-dupe-args.js index 583637bec47..e927ce2b3a8 100644 --- a/lib/rules/no-dupe-args.js +++ b/lib/rules/no-dupe-args.js @@ -65,8 +65,8 @@ module.exports = { //-------------------------------------------------------------------------- return { - "FunctionDeclaration": checkParams, - "FunctionExpression": checkParams + FunctionDeclaration: checkParams, + FunctionExpression: checkParams }; } diff --git a/lib/rules/no-dupe-class-members.js b/lib/rules/no-dupe-class-members.js index f1485c758fb..883020bdfe5 100644 --- a/lib/rules/no-dupe-class-members.js +++ b/lib/rules/no-dupe-class-members.js @@ -65,12 +65,12 @@ module.exports = { return { // Initializes the stack of state of member declarations. - "Program": function() { + Program: function() { stack = []; }, // Initializes state of member declarations for the class. - "ClassBody": function() { + ClassBody: function() { stack.push(Object.create(null)); }, @@ -80,7 +80,7 @@ module.exports = { }, // Reports the node if its name has been declared already. - "MethodDefinition": function(node) { + MethodDefinition: function(node) { if (node.computed) { return; } diff --git a/lib/rules/no-dupe-keys.js b/lib/rules/no-dupe-keys.js index 6dc7d71e2ec..26f009b3bfe 100644 --- a/lib/rules/no-dupe-keys.js +++ b/lib/rules/no-dupe-keys.js @@ -24,7 +24,7 @@ module.exports = { return { - "ObjectExpression": function(node) { + ObjectExpression: function(node) { // Object that will be a map of properties--safe because we will // prefix all of the keys. diff --git a/lib/rules/no-duplicate-case.js b/lib/rules/no-duplicate-case.js index 0166ab0229c..1308730a631 100644 --- a/lib/rules/no-duplicate-case.js +++ b/lib/rules/no-duplicate-case.js @@ -24,7 +24,7 @@ module.exports = { create: function(context) { return { - "SwitchStatement": function(node) { + SwitchStatement: function(node) { var mapping = {}; node.cases.forEach(function(switchCase) { diff --git a/lib/rules/no-duplicate-imports.js b/lib/rules/no-duplicate-imports.js index 3c62571a579..44432f48635 100644 --- a/lib/rules/no-duplicate-imports.js +++ b/lib/rules/no-duplicate-imports.js @@ -105,13 +105,13 @@ module.exports = { }, schema: [{ - "type": "object", - "properties": { - "includeExports": { - "type": "boolean" + type: "object", + properties: { + includeExports: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false }] }, @@ -121,7 +121,7 @@ module.exports = { exportsInFile = []; var handlers = { - "ImportDeclaration": handleImports(context, includeExports, importsInFile, exportsInFile) + ImportDeclaration: handleImports(context, includeExports, importsInFile, exportsInFile) }; if (includeExports) { diff --git a/lib/rules/no-else-return.js b/lib/rules/no-else-return.js index d8cf2224dbe..4678d320af9 100644 --- a/lib/rules/no-else-return.js +++ b/lib/rules/no-else-return.js @@ -128,7 +128,7 @@ module.exports = { return { - "IfStatement": function(node) { + IfStatement: function(node) { var parent = context.getAncestors().pop(), consequents, alternate; diff --git a/lib/rules/no-empty-character-class.js b/lib/rules/no-empty-character-class.js index 0e46adad119..e015e0cc067 100644 --- a/lib/rules/no-empty-character-class.js +++ b/lib/rules/no-empty-character-class.js @@ -42,7 +42,7 @@ module.exports = { return { - "Literal": function(node) { + Literal: function(node) { var token = context.getFirstToken(node); if (token.type === "RegularExpression" && !regex.test(token.value)) { diff --git a/lib/rules/no-empty-pattern.js b/lib/rules/no-empty-pattern.js index fa08badac03..afd8b1e393e 100644 --- a/lib/rules/no-empty-pattern.js +++ b/lib/rules/no-empty-pattern.js @@ -21,12 +21,12 @@ module.exports = { create: function(context) { return { - "ObjectPattern": function(node) { + ObjectPattern: function(node) { if (node.properties.length === 0) { context.report(node, "Unexpected empty object pattern."); } }, - "ArrayPattern": function(node) { + ArrayPattern: function(node) { if (node.elements.length === 0) { context.report(node, "Unexpected empty array pattern."); } diff --git a/lib/rules/no-empty.js b/lib/rules/no-empty.js index 4ab4c466708..8f32428304c 100644 --- a/lib/rules/no-empty.js +++ b/lib/rules/no-empty.js @@ -20,13 +20,13 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "allowEmptyCatch": { - "type": "boolean" + type: "object", + properties: { + allowEmptyCatch: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -36,7 +36,7 @@ module.exports = { allowEmptyCatch = options.allowEmptyCatch || false; return { - "BlockStatement": function(node) { + BlockStatement: function(node) { // if the body is not empty, we can just return immediately if (node.body.length !== 0) { @@ -60,7 +60,7 @@ module.exports = { context.report(node, "Empty block statement."); }, - "SwitchStatement": function(node) { + SwitchStatement: function(node) { if (typeof node.cases === "undefined" || node.cases.length === 0) { context.report(node, "Empty switch statement."); diff --git a/lib/rules/no-eq-null.js b/lib/rules/no-eq-null.js index 74495c7ab8f..da039bb9d7d 100644 --- a/lib/rules/no-eq-null.js +++ b/lib/rules/no-eq-null.js @@ -25,7 +25,7 @@ module.exports = { return { - "BinaryExpression": function(node) { + BinaryExpression: function(node) { var badOperator = node.operator === "==" || node.operator === "!="; if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || diff --git a/lib/rules/no-eval.js b/lib/rules/no-eval.js index be1f5624c8a..04db4b96b47 100644 --- a/lib/rules/no-eval.js +++ b/lib/rules/no-eval.js @@ -84,11 +84,11 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "allowIndirect": {"type": "boolean"} + type: "object", + properties: { + allowIndirect: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -247,7 +247,7 @@ module.exports = { } }, - "Program": function(node) { + Program: function(node) { var scope = context.getScope(), features = context.parserOptions.ecmaFeatures || {}, strict = @@ -272,14 +272,14 @@ module.exports = { reportAccessingEvalViaGlobalObject(globalScope); }, - "FunctionDeclaration": enterVarScope, + FunctionDeclaration: enterVarScope, "FunctionDeclaration:exit": exitVarScope, - "FunctionExpression": enterVarScope, + FunctionExpression: enterVarScope, "FunctionExpression:exit": exitVarScope, - "ArrowFunctionExpression": enterVarScope, + ArrowFunctionExpression: enterVarScope, "ArrowFunctionExpression:exit": exitVarScope, - "ThisExpression": function(node) { + ThisExpression: function(node) { if (!isMember(node.parent, "eval")) { return; } diff --git a/lib/rules/no-ex-assign.js b/lib/rules/no-ex-assign.js index 8cd37c9bbb1..bf3afc6cd3f 100644 --- a/lib/rules/no-ex-assign.js +++ b/lib/rules/no-ex-assign.js @@ -38,7 +38,7 @@ module.exports = { } return { - "CatchClause": function(node) { + CatchClause: function(node) { context.getDeclaredVariables(node).forEach(checkVariable); } }; diff --git a/lib/rules/no-extend-native.js b/lib/rules/no-extend-native.js index 6ed08e90108..69d4931ab6e 100644 --- a/lib/rules/no-extend-native.js +++ b/lib/rules/no-extend-native.js @@ -25,17 +25,17 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + exceptions: { + type: "array", + items: { + type: "string" }, - "uniqueItems": true + uniqueItems: true } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -57,7 +57,7 @@ module.exports = { return { // handle the Array.prototype.extra style case - "AssignmentExpression": function(node) { + AssignmentExpression: function(node) { var lhs = node.left, affectsProto; @@ -81,7 +81,7 @@ module.exports = { }, // handle the Object.definePropert[y|ies](Array.prototype) case - "CallExpression": function(node) { + CallExpression: function(node) { var callee = node.callee, subject, diff --git a/lib/rules/no-extra-bind.js b/lib/rules/no-extra-bind.js index 1407eeee3dd..f75e2fcc257 100644 --- a/lib/rules/no-extra-bind.js +++ b/lib/rules/no-extra-bind.js @@ -146,11 +146,11 @@ module.exports = { return { "ArrowFunctionExpression:exit": exitArrowFunction, - "FunctionDeclaration": enterFunction, + FunctionDeclaration: enterFunction, "FunctionDeclaration:exit": exitFunction, - "FunctionExpression": enterFunction, + FunctionExpression: enterFunction, "FunctionExpression:exit": exitFunction, - "ThisExpression": markAsThisFound + ThisExpression: markAsThisFound }; } }; diff --git a/lib/rules/no-extra-boolean-cast.js b/lib/rules/no-extra-boolean-cast.js index 56e7c2b2a9d..f14da0821db 100644 --- a/lib/rules/no-extra-boolean-cast.js +++ b/lib/rules/no-extra-boolean-cast.js @@ -51,7 +51,7 @@ module.exports = { return { - "UnaryExpression": function(node) { + UnaryExpression: function(node) { var ancestors = context.getAncestors(), parent = ancestors.pop(), grandparent = ancestors.pop(); @@ -73,7 +73,7 @@ module.exports = { context.report(node, "Redundant double negation."); } }, - "CallExpression": function(node) { + CallExpression: function(node) { var parent = node.parent; if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") { diff --git a/lib/rules/no-extra-label.js b/lib/rules/no-extra-label.js index 70a52ed16a8..f1a48e3688e 100644 --- a/lib/rules/no-extra-label.js +++ b/lib/rules/no-extra-label.js @@ -119,22 +119,22 @@ module.exports = { } return { - "WhileStatement": enterBreakableStatement, + WhileStatement: enterBreakableStatement, "WhileStatement:exit": exitBreakableStatement, - "DoWhileStatement": enterBreakableStatement, + DoWhileStatement: enterBreakableStatement, "DoWhileStatement:exit": exitBreakableStatement, - "ForStatement": enterBreakableStatement, + ForStatement: enterBreakableStatement, "ForStatement:exit": exitBreakableStatement, - "ForInStatement": enterBreakableStatement, + ForInStatement: enterBreakableStatement, "ForInStatement:exit": exitBreakableStatement, - "ForOfStatement": enterBreakableStatement, + ForOfStatement: enterBreakableStatement, "ForOfStatement:exit": exitBreakableStatement, - "SwitchStatement": enterBreakableStatement, + SwitchStatement: enterBreakableStatement, "SwitchStatement:exit": exitBreakableStatement, - "LabeledStatement": enterLabeledStatement, + LabeledStatement: enterLabeledStatement, "LabeledStatement:exit": exitLabeledStatement, - "BreakStatement": reportIfUnnecessary, - "ContinueStatement": reportIfUnnecessary + BreakStatement: reportIfUnnecessary, + ContinueStatement: reportIfUnnecessary }; } }; diff --git a/lib/rules/no-extra-parens.js b/lib/rules/no-extra-parens.js index b15e450fc46..cf129394ba0 100644 --- a/lib/rules/no-extra-parens.js +++ b/lib/rules/no-extra-parens.js @@ -19,34 +19,34 @@ module.exports = { }, schema: { - "anyOf": [ + anyOf: [ { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["functions"] + enum: ["functions"] } ], - "minItems": 0, - "maxItems": 1 + minItems: 0, + maxItems: 1 }, { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["all"] + enum: ["all"] }, { - "type": "object", - "properties": { - "conditionalAssign": {"type": "boolean"}, - "nestedBinaryExpressions": {"type": "boolean"} + type: "object", + properties: { + conditionalAssign: {type: "boolean"}, + nestedBinaryExpressions: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ], - "minItems": 0, - "maxItems": 2 + minItems: 0, + maxItems: 2 } ] } @@ -359,7 +359,7 @@ module.exports = { } return { - "ArrayExpression": function(node) { + ArrayExpression: function(node) { [].forEach.call(node.elements, function(e) { if (e && hasExcessParens(e) && precedence(e) >= precedence({type: "AssignmentExpression"})) { report(e); @@ -367,7 +367,7 @@ module.exports = { }); }, - "ArrowFunctionExpression": function(node) { + ArrowFunctionExpression: function(node) { if (node.body.type !== "BlockStatement") { if (sourceCode.getFirstToken(node.body).value !== "{" && hasExcessParens(node.body) && precedence(node.body) >= precedence({type: "AssignmentExpression"})) { report(node.body); @@ -382,16 +382,16 @@ module.exports = { } }, - "AssignmentExpression": function(node) { + AssignmentExpression: function(node) { if (hasExcessParens(node.right) && precedence(node.right) >= precedence(node)) { report(node.right); } }, - "BinaryExpression": dryBinaryLogical, - "CallExpression": dryCallNew, + BinaryExpression: dryBinaryLogical, + CallExpression: dryCallNew, - "ConditionalExpression": function(node) { + ConditionalExpression: function(node) { if (hasExcessParens(node.test) && precedence(node.test) >= precedence({type: "LogicalExpression", operator: "||"})) { report(node.test); } @@ -403,13 +403,13 @@ module.exports = { } }, - "DoWhileStatement": function(node) { + DoWhileStatement: function(node) { if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) { report(node.test); } }, - "ExpressionStatement": function(node) { + ExpressionStatement: function(node) { var firstToken, secondToken, firstTokens; if (hasExcessParens(node.expression)) { @@ -433,19 +433,19 @@ module.exports = { } }, - "ForInStatement": function(node) { + ForInStatement: function(node) { if (hasExcessParens(node.right)) { report(node.right); } }, - "ForOfStatement": function(node) { + ForOfStatement: function(node) { if (hasExcessParens(node.right)) { report(node.right); } }, - "ForStatement": function(node) { + ForStatement: function(node) { if (node.init && hasExcessParens(node.init)) { report(node.init); } @@ -459,15 +459,15 @@ module.exports = { } }, - "IfStatement": function(node) { + IfStatement: function(node) { if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) { report(node.test); } }, - "LogicalExpression": dryBinaryLogical, + LogicalExpression: dryBinaryLogical, - "MemberExpression": function(node) { + MemberExpression: function(node) { if ( hasExcessParens(node.object) && precedence(node.object) >= precedence(node) && @@ -496,9 +496,9 @@ module.exports = { } }, - "NewExpression": dryCallNew, + NewExpression: dryCallNew, - "ObjectExpression": function(node) { + ObjectExpression: function(node) { [].forEach.call(node.properties, function(e) { var v = e.value; @@ -508,7 +508,7 @@ module.exports = { }); }, - "ReturnStatement": function(node) { + ReturnStatement: function(node) { var returnToken = sourceCode.getFirstToken(node); if (node.argument && @@ -520,7 +520,7 @@ module.exports = { } }, - "SequenceExpression": function(node) { + SequenceExpression: function(node) { [].forEach.call(node.expressions, function(e) { if (hasExcessParens(e) && precedence(e) >= precedence(node)) { report(e); @@ -528,19 +528,19 @@ module.exports = { }); }, - "SwitchCase": function(node) { + SwitchCase: function(node) { if (node.test && hasExcessParens(node.test)) { report(node.test); } }, - "SwitchStatement": function(node) { + SwitchStatement: function(node) { if (hasDoubleExcessParens(node.discriminant)) { report(node.discriminant); } }, - "ThrowStatement": function(node) { + ThrowStatement: function(node) { var throwToken = sourceCode.getFirstToken(node); if (hasExcessParensNoLineTerminator(throwToken, node.argument)) { @@ -548,10 +548,10 @@ module.exports = { } }, - "UnaryExpression": dryUnaryUpdate, - "UpdateExpression": dryUnaryUpdate, + UnaryExpression: dryUnaryUpdate, + UpdateExpression: dryUnaryUpdate, - "VariableDeclarator": function(node) { + VariableDeclarator: function(node) { if (node.init && hasExcessParens(node.init) && precedence(node.init) >= precedence({type: "AssignmentExpression"}) && @@ -561,19 +561,19 @@ module.exports = { } }, - "WhileStatement": function(node) { + WhileStatement: function(node) { if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) { report(node.test); } }, - "WithStatement": function(node) { + WithStatement: function(node) { if (hasDoubleExcessParens(node.object)) { report(node.object); } }, - "YieldExpression": function(node) { + YieldExpression: function(node) { var yieldToken; if (node.argument) { diff --git a/lib/rules/no-extra-semi.js b/lib/rules/no-extra-semi.js index e844b2c17e7..e451b9e42e3 100644 --- a/lib/rules/no-extra-semi.js +++ b/lib/rules/no-extra-semi.js @@ -63,7 +63,7 @@ module.exports = { * @param {Node} node - A EmptyStatement node to be reported. * @returns {void} */ - "EmptyStatement": function(node) { + EmptyStatement: function(node) { var parent = node.parent, allowedParentTypes = ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"]; @@ -77,7 +77,7 @@ module.exports = { * @param {Node} node - A ClassBody node to check. * @returns {void} */ - "ClassBody": function(node) { + ClassBody: function(node) { checkForPartOfClassBody(context.getFirstToken(node, 1)); // 0 is `{`. }, @@ -86,7 +86,7 @@ module.exports = { * @param {Node} node - A MethodDefinition node of the start point. * @returns {void} */ - "MethodDefinition": function(node) { + MethodDefinition: function(node) { checkForPartOfClassBody(context.getTokenAfter(node)); } }; diff --git a/lib/rules/no-fallthrough.js b/lib/rules/no-fallthrough.js index 8e703255fcd..2edb4972baf 100644 --- a/lib/rules/no-fallthrough.js +++ b/lib/rules/no-fallthrough.js @@ -63,13 +63,13 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "commentPattern": { - "type": "string" + type: "object", + properties: { + commentPattern: { + type: "string" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -93,14 +93,14 @@ module.exports = { } return { - "onCodePathStart": function(codePath) { + onCodePathStart: function(codePath) { currentCodePath = codePath; }, - "onCodePathEnd": function() { + onCodePathEnd: function() { currentCodePath = currentCodePath.upper; }, - "SwitchCase": function(node) { + SwitchCase: function(node) { /* * Checks whether or not there is a fallthrough comment. diff --git a/lib/rules/no-floating-decimal.js b/lib/rules/no-floating-decimal.js index dc3166e3665..56ebd3989a4 100644 --- a/lib/rules/no-floating-decimal.js +++ b/lib/rules/no-floating-decimal.js @@ -23,7 +23,7 @@ module.exports = { create: function(context) { return { - "Literal": function(node) { + Literal: function(node) { if (typeof node.value === "number") { if (node.raw.indexOf(".") === 0) { diff --git a/lib/rules/no-func-assign.js b/lib/rules/no-func-assign.js index afe327effe4..ac3afe55c05 100644 --- a/lib/rules/no-func-assign.js +++ b/lib/rules/no-func-assign.js @@ -59,8 +59,8 @@ module.exports = { } return { - "FunctionDeclaration": checkForFunction, - "FunctionExpression": checkForFunction + FunctionDeclaration: checkForFunction, + FunctionExpression: checkForFunction }; } }; diff --git a/lib/rules/no-implicit-coercion.js b/lib/rules/no-implicit-coercion.js index f5ad6fb4c70..058d9f3572e 100644 --- a/lib/rules/no-implicit-coercion.js +++ b/lib/rules/no-implicit-coercion.js @@ -152,26 +152,26 @@ module.exports = { }, schema: [{ - "type": "object", - "properties": { - "boolean": { - "type": "boolean" + type: "object", + properties: { + boolean: { + type: "boolean" }, - "number": { - "type": "boolean" + number: { + type: "boolean" }, - "string": { - "type": "boolean" + string: { + type: "boolean" }, - "allow": { - "type": "array", - "items": { - "enum": ALLOWABLE_OPERATORS + allow: { + type: "array", + items: { + enum: ALLOWABLE_OPERATORS }, - "uniqueItems": true + uniqueItems: true } }, - "additionalProperties": false + additionalProperties: false }] }, @@ -180,7 +180,7 @@ module.exports = { operatorAllowed = false; return { - "UnaryExpression": function(node) { + UnaryExpression: function(node) { // !!foo operatorAllowed = options.allow.indexOf("!!") >= 0; @@ -239,7 +239,7 @@ module.exports = { } }, - "AssignmentExpression": function(node) { + AssignmentExpression: function(node) { // foo += "" operatorAllowed = options.allow.indexOf("+") >= 0; diff --git a/lib/rules/no-implicit-globals.js b/lib/rules/no-implicit-globals.js index 40444d71165..c2768ea1a09 100644 --- a/lib/rules/no-implicit-globals.js +++ b/lib/rules/no-implicit-globals.js @@ -22,7 +22,7 @@ module.exports = { create: function(context) { return { - "Program": function() { + Program: function() { var scope = context.getScope(); scope.variables.forEach(function(variable) { diff --git a/lib/rules/no-implied-eval.js b/lib/rules/no-implied-eval.js index fe112096f4f..7c1ed2fb6eb 100644 --- a/lib/rules/no-implied-eval.js +++ b/lib/rules/no-implied-eval.js @@ -114,7 +114,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "CallExpression": function(node) { + CallExpression: function(node) { if (isImpliedEvalCallExpression(node)) { // call expressions create a new substack @@ -133,7 +133,7 @@ module.exports = { } }, - "BinaryExpression": function(node) { + BinaryExpression: function(node) { if (node.operator === "+" && hasImpliedEvalParent(node)) { last(impliedEvalAncestorsStack).push(node); } @@ -145,13 +145,13 @@ module.exports = { } }, - "Literal": function(node) { + Literal: function(node) { if (typeof node.value === "string") { checkString(node); } }, - "TemplateLiteral": function(node) { + TemplateLiteral: function(node) { checkString(node); } }; diff --git a/lib/rules/no-inline-comments.js b/lib/rules/no-inline-comments.js index 1afe3f31e77..7835ed30fcc 100644 --- a/lib/rules/no-inline-comments.js +++ b/lib/rules/no-inline-comments.js @@ -55,8 +55,8 @@ module.exports = { return { - "LineComment": testCodeAroundComment, - "BlockComment": testCodeAroundComment + LineComment: testCodeAroundComment, + BlockComment: testCodeAroundComment }; } diff --git a/lib/rules/no-inner-declarations.js b/lib/rules/no-inner-declarations.js index 58e84a9402a..3471ce8cc73 100644 --- a/lib/rules/no-inner-declarations.js +++ b/lib/rules/no-inner-declarations.js @@ -19,7 +19,7 @@ module.exports = { schema: [ { - "enum": ["functions", "both"] + enum: ["functions", "both"] } ] }, @@ -76,8 +76,8 @@ module.exports = { return { - "FunctionDeclaration": check, - "VariableDeclaration": function(node) { + FunctionDeclaration: check, + VariableDeclaration: function(node) { if (context.options[0] === "both" && node.kind === "var") { check(node); } diff --git a/lib/rules/no-invalid-regexp.js b/lib/rules/no-invalid-regexp.js index c28aae0367e..6f8b8673786 100644 --- a/lib/rules/no-invalid-regexp.js +++ b/lib/rules/no-invalid-regexp.js @@ -23,16 +23,16 @@ module.exports = { }, schema: [{ - "type": "object", - "properties": { - "allowConstructorFlags": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + allowConstructorFlags: { + type: "array", + items: { + type: "string" } } }, - "additionalProperties": false + additionalProperties: false }] }, @@ -88,8 +88,8 @@ module.exports = { } return { - "CallExpression": check, - "NewExpression": check + CallExpression: check, + NewExpression: check }; } diff --git a/lib/rules/no-invalid-this.js b/lib/rules/no-invalid-this.js index 65a6078005e..198bfd706ad 100644 --- a/lib/rules/no-invalid-this.js +++ b/lib/rules/no-invalid-this.js @@ -85,7 +85,7 @@ module.exports = { * `this` is invalid only under strict mode. * Modules is always strict mode. */ - "Program": function(node) { + Program: function(node) { var scope = context.getScope(), features = context.parserOptions.ecmaFeatures || {}; @@ -104,13 +104,13 @@ module.exports = { stack.pop(); }, - "FunctionDeclaration": enterFunction, + FunctionDeclaration: enterFunction, "FunctionDeclaration:exit": exitFunction, - "FunctionExpression": enterFunction, + FunctionExpression: enterFunction, "FunctionExpression:exit": exitFunction, // Reports if `this` of the current context is invalid. - "ThisExpression": function(node) { + ThisExpression: function(node) { var current = stack.getCurrent(); if (current && !current.valid) { diff --git a/lib/rules/no-irregular-whitespace.js b/lib/rules/no-irregular-whitespace.js index ff013402254..1dbea8f5a93 100644 --- a/lib/rules/no-irregular-whitespace.js +++ b/lib/rules/no-irregular-whitespace.js @@ -20,13 +20,13 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "skipComments": { - "type": "boolean" + type: "object", + properties: { + skipComments: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -167,7 +167,7 @@ module.exports = { function noop() {} return { - "Program": function(node) { + Program: function(node) { /* * As we can easily fire warnings for all white space issues with @@ -184,10 +184,10 @@ module.exports = { checkForIrregularLineTerminators(node); }, - "Identifier": removeInvalidNodeErrorsInIdentifierOrLiteral, - "Literal": removeInvalidNodeErrorsInIdentifierOrLiteral, - "LineComment": skipComments ? rememberCommentNode : noop, - "BlockComment": skipComments ? rememberCommentNode : noop, + Identifier: removeInvalidNodeErrorsInIdentifierOrLiteral, + Literal: removeInvalidNodeErrorsInIdentifierOrLiteral, + LineComment: skipComments ? rememberCommentNode : noop, + BlockComment: skipComments ? rememberCommentNode : noop, "Program:exit": function() { if (skipComments) { diff --git a/lib/rules/no-iterator.js b/lib/rules/no-iterator.js index 52609a1f4d7..67c1c1bb2a2 100644 --- a/lib/rules/no-iterator.js +++ b/lib/rules/no-iterator.js @@ -24,7 +24,7 @@ module.exports = { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { if (node.property && (node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed) || diff --git a/lib/rules/no-label-var.js b/lib/rules/no-label-var.js index 4e8943dc962..7c6d56f3552 100644 --- a/lib/rules/no-label-var.js +++ b/lib/rules/no-label-var.js @@ -49,7 +49,7 @@ module.exports = { return { - "LabeledStatement": function(node) { + LabeledStatement: function(node) { // Fetch the innermost scope. var scope = context.getScope(); diff --git a/lib/rules/no-labels.js b/lib/rules/no-labels.js index cd98c9d409c..da0cd8e7426 100644 --- a/lib/rules/no-labels.js +++ b/lib/rules/no-labels.js @@ -101,7 +101,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "LabeledStatement": function(node) { + LabeledStatement: function(node) { scopeInfo = { label: node.label.name, kind: getBodyKind(node.body), @@ -120,7 +120,7 @@ module.exports = { scopeInfo = scopeInfo.upper; }, - "BreakStatement": function(node) { + BreakStatement: function(node) { if (node.label && !isAllowed(getKind(node.label.name))) { context.report({ node: node, @@ -129,7 +129,7 @@ module.exports = { } }, - "ContinueStatement": function(node) { + ContinueStatement: function(node) { if (node.label && !isAllowed(getKind(node.label.name))) { context.report({ node: node, diff --git a/lib/rules/no-lone-blocks.js b/lib/rules/no-lone-blocks.js index a8ed63107f5..113cd89b937 100644 --- a/lib/rules/no-lone-blocks.js +++ b/lib/rules/no-lone-blocks.js @@ -79,7 +79,7 @@ module.exports = { // ES6: report blocks without block-level bindings if (context.parserOptions.ecmaVersion >= 6) { ruleDef = { - "BlockStatement": function(node) { + BlockStatement: function(node) { if (isLoneBlock(node)) { loneBlocks.push(node); } diff --git a/lib/rules/no-lonely-if.js b/lib/rules/no-lonely-if.js index d93efb5f294..1efd1acc018 100644 --- a/lib/rules/no-lonely-if.js +++ b/lib/rules/no-lonely-if.js @@ -22,7 +22,7 @@ module.exports = { create: function(context) { return { - "IfStatement": function(node) { + IfStatement: function(node) { var ancestors = context.getAncestors(), parent = ancestors.pop(), grandparent = ancestors.pop(); diff --git a/lib/rules/no-loop-func.js b/lib/rules/no-loop-func.js index abb07d989ef..2b76093cce4 100644 --- a/lib/rules/no-loop-func.js +++ b/lib/rules/no-loop-func.js @@ -190,9 +190,9 @@ module.exports = { } return { - "ArrowFunctionExpression": checkForLoops, - "FunctionExpression": checkForLoops, - "FunctionDeclaration": checkForLoops + ArrowFunctionExpression: checkForLoops, + FunctionExpression: checkForLoops, + FunctionDeclaration: checkForLoops }; } }; diff --git a/lib/rules/no-magic-numbers.js b/lib/rules/no-magic-numbers.js index 95422926306..2e7434c1a58 100644 --- a/lib/rules/no-magic-numbers.js +++ b/lib/rules/no-magic-numbers.js @@ -18,26 +18,26 @@ module.exports = { }, schema: [{ - "type": "object", - "properties": { - "detectObjects": { - "type": "boolean" + type: "object", + properties: { + detectObjects: { + type: "boolean" }, - "enforceConst": { - "type": "boolean" + enforceConst: { + type: "boolean" }, - "ignore": { - "type": "array", - "items": { - "type": "number" + ignore: { + type: "array", + items: { + type: "number" }, - "uniqueItems": true + uniqueItems: true }, - "ignoreArrayIndexes": { - "type": "boolean" + ignoreArrayIndexes: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false }] }, @@ -99,7 +99,7 @@ module.exports = { } return { - "Literal": function(node) { + Literal: function(node) { var parent = node.parent, value = node.value, raw = node.raw, diff --git a/lib/rules/no-mixed-requires.js b/lib/rules/no-mixed-requires.js index 3f3c60fe4a8..b6d365a9dbb 100644 --- a/lib/rules/no-mixed-requires.js +++ b/lib/rules/no-mixed-requires.js @@ -19,21 +19,21 @@ module.exports = { schema: [ { - "oneOf": [ + oneOf: [ { - "type": "boolean" + type: "boolean" }, { - "type": "object", - "properties": { - "grouping": { - "type": "boolean" + type: "object", + properties: { + grouping: { + type: "boolean" }, - "allowCall": { - "type": "boolean" + allowCall: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] } @@ -202,7 +202,7 @@ module.exports = { return { - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { if (isMixed(node.declarations)) { context.report( diff --git a/lib/rules/no-mixed-spaces-and-tabs.js b/lib/rules/no-mixed-spaces-and-tabs.js index 0cf62041764..b3cdd38a600 100644 --- a/lib/rules/no-mixed-spaces-and-tabs.js +++ b/lib/rules/no-mixed-spaces-and-tabs.js @@ -18,7 +18,7 @@ module.exports = { schema: [ { - "enum": ["smart-tabs", true, false] + enum: ["smart-tabs", true, false] } ] }, @@ -73,7 +73,7 @@ module.exports = { return { - "TemplateElement": function(node) { + TemplateElement: function(node) { ignoredLocs.push(node.loc); }, diff --git a/lib/rules/no-multi-spaces.js b/lib/rules/no-multi-spaces.js index 2f495a3cc82..d6c0e4198d1 100644 --- a/lib/rules/no-multi-spaces.js +++ b/lib/rules/no-multi-spaces.js @@ -21,19 +21,19 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "exceptions": { - "type": "object", - "patternProperties": { + type: "object", + properties: { + exceptions: { + type: "object", + patternProperties: { "^([A-Z][a-z]*)+$": { - "type": "boolean" + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -41,7 +41,7 @@ module.exports = { create: function(context) { // the index of the last comment that was checked - var exceptions = { "Property": true }, + var exceptions = { Property: true }, hasExceptions = true, options = context.options[0], lastCommentIndex = 0; @@ -93,7 +93,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program": function() { + Program: function() { var source = context.getSource(), allComments = context.getAllComments(), diff --git a/lib/rules/no-multi-str.js b/lib/rules/no-multi-str.js index 613044c89af..fe7fee4a60a 100644 --- a/lib/rules/no-multi-str.js +++ b/lib/rules/no-multi-str.js @@ -38,7 +38,7 @@ module.exports = { return { - "Literal": function(node) { + Literal: function(node) { var lineBreak = /\n/; if (lineBreak.test(node.raw) && !isJSXElement(node.parent)) { diff --git a/lib/rules/no-multiple-empty-lines.js b/lib/rules/no-multiple-empty-lines.js index 5b099519276..02a41fdbe34 100644 --- a/lib/rules/no-multiple-empty-lines.js +++ b/lib/rules/no-multiple-empty-lines.js @@ -19,23 +19,23 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "max": { - "type": "integer", - "minimum": 0 + type: "object", + properties: { + max: { + type: "integer", + minimum: 0 }, - "maxEOF": { - "type": "integer", - "minimum": 0 + maxEOF: { + type: "integer", + minimum: 0 }, - "maxBOF": { - "type": "integer", - "minimum": 0 + maxBOF: { + type: "integer", + minimum: 0 } }, - "required": ["max"], - "additionalProperties": false + required: ["max"], + additionalProperties: false } ] }, @@ -62,7 +62,7 @@ module.exports = { return { - "TemplateLiteral": function(node) { + TemplateLiteral: function(node) { var start = node.loc.start.line; var end = node.loc.end.line; diff --git a/lib/rules/no-native-reassign.js b/lib/rules/no-native-reassign.js index 0e1787c8d33..7d45e277d50 100644 --- a/lib/rules/no-native-reassign.js +++ b/lib/rules/no-native-reassign.js @@ -19,15 +19,15 @@ module.exports = { schema: [ { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + type: "object", + properties: { + exceptions: { + type: "array", + items: {type: "string"}, + uniqueItems: true } }, - "additionalProperties": false + additionalProperties: false } ] }, @@ -73,7 +73,7 @@ module.exports = { } return { - "Program": function() { + Program: function() { var globalScope = context.getScope(); globalScope.variables.forEach(checkVariable); diff --git a/lib/rules/no-negated-condition.js b/lib/rules/no-negated-condition.js index 1e6c8950a61..5f1037472c5 100644 --- a/lib/rules/no-negated-condition.js +++ b/lib/rules/no-negated-condition.js @@ -63,7 +63,7 @@ module.exports = { } return { - "IfStatement": function(node) { + IfStatement: function(node) { if (!hasElseWithoutCondition(node)) { return; } @@ -72,7 +72,7 @@ module.exports = { context.report(node, "Unexpected negated condition."); } }, - "ConditionalExpression": function(node) { + ConditionalExpression: function(node) { if (isNegatedIf(node)) { context.report(node, "Unexpected negated condition."); } diff --git a/lib/rules/no-negated-in-lhs.js b/lib/rules/no-negated-in-lhs.js index 57241bcfc63..891b75dd2f4 100644 --- a/lib/rules/no-negated-in-lhs.js +++ b/lib/rules/no-negated-in-lhs.js @@ -24,7 +24,7 @@ module.exports = { return { - "BinaryExpression": function(node) { + BinaryExpression: function(node) { if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") { context.report(node, "The 'in' expression's left operand is negated"); } diff --git a/lib/rules/no-nested-ternary.js b/lib/rules/no-nested-ternary.js index f8d745f0a4a..34f9eaaa8db 100644 --- a/lib/rules/no-nested-ternary.js +++ b/lib/rules/no-nested-ternary.js @@ -23,7 +23,7 @@ module.exports = { create: function(context) { return { - "ConditionalExpression": function(node) { + ConditionalExpression: function(node) { if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") { context.report(node, "Do not nest ternary expressions"); diff --git a/lib/rules/no-new-func.js b/lib/rules/no-new-func.js index 4f2b25a1af5..7b01db0cd28 100644 --- a/lib/rules/no-new-func.js +++ b/lib/rules/no-new-func.js @@ -39,8 +39,8 @@ module.exports = { } return { - "NewExpression": validateCallee, - "CallExpression": validateCallee + NewExpression: validateCallee, + CallExpression: validateCallee }; } diff --git a/lib/rules/no-new-object.js b/lib/rules/no-new-object.js index d59b1324e52..4fc2a3bebb0 100644 --- a/lib/rules/no-new-object.js +++ b/lib/rules/no-new-object.js @@ -24,7 +24,7 @@ module.exports = { return { - "NewExpression": function(node) { + NewExpression: function(node) { if (node.callee.name === "Object") { context.report(node, "The object literal notation {} is preferrable."); } diff --git a/lib/rules/no-new-require.js b/lib/rules/no-new-require.js index f1cbccd733a..b39d9c3e373 100644 --- a/lib/rules/no-new-require.js +++ b/lib/rules/no-new-require.js @@ -24,7 +24,7 @@ module.exports = { return { - "NewExpression": function(node) { + NewExpression: function(node) { if (node.callee.type === "Identifier" && node.callee.name === "require") { context.report(node, "Unexpected use of new with require."); } diff --git a/lib/rules/no-new-wrappers.js b/lib/rules/no-new-wrappers.js index 75b56462ed0..eec774fdcad 100644 --- a/lib/rules/no-new-wrappers.js +++ b/lib/rules/no-new-wrappers.js @@ -24,7 +24,7 @@ module.exports = { return { - "NewExpression": function(node) { + NewExpression: function(node) { var wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"]; if (wrapperObjects.indexOf(node.callee.name) > -1) { diff --git a/lib/rules/no-new.js b/lib/rules/no-new.js index c8fbe9aeca2..154bced9bcf 100644 --- a/lib/rules/no-new.js +++ b/lib/rules/no-new.js @@ -25,7 +25,7 @@ module.exports = { return { - "ExpressionStatement": function(node) { + ExpressionStatement: function(node) { if (node.expression.type === "NewExpression") { context.report(node, "Do not use 'new' for side effects."); diff --git a/lib/rules/no-obj-calls.js b/lib/rules/no-obj-calls.js index 717005a8e96..0f58ab93dbd 100644 --- a/lib/rules/no-obj-calls.js +++ b/lib/rules/no-obj-calls.js @@ -23,7 +23,7 @@ module.exports = { create: function(context) { return { - "CallExpression": function(node) { + CallExpression: function(node) { if (node.callee.type === "Identifier") { var name = node.callee.name; diff --git a/lib/rules/no-octal-escape.js b/lib/rules/no-octal-escape.js index 16e58316dda..65be7e397e5 100644 --- a/lib/rules/no-octal-escape.js +++ b/lib/rules/no-octal-escape.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "Literal": function(node) { + Literal: function(node) { if (typeof node.value !== "string") { return; } diff --git a/lib/rules/no-octal.js b/lib/rules/no-octal.js index 5a00c9506ec..34b7b151d88 100644 --- a/lib/rules/no-octal.js +++ b/lib/rules/no-octal.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "Literal": function(node) { + Literal: function(node) { if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) { context.report(node, "Octal literals should not be used."); } diff --git a/lib/rules/no-param-reassign.js b/lib/rules/no-param-reassign.js index c5c44ac60cb..8b4711bea0a 100644 --- a/lib/rules/no-param-reassign.js +++ b/lib/rules/no-param-reassign.js @@ -128,10 +128,10 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "props": {"type": "boolean"} + type: "object", + properties: { + props: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-path-concat.js b/lib/rules/no-path-concat.js index c6d512bc0e7..7b346ecbc20 100644 --- a/lib/rules/no-path-concat.js +++ b/lib/rules/no-path-concat.js @@ -18,7 +18,7 @@ module.exports = function(context) { return { - "BinaryExpression": function(node) { + BinaryExpression: function(node) { var left = node.left, right = node.right; diff --git a/lib/rules/no-plusplus.js b/lib/rules/no-plusplus.js index 42df6a5f2d3..802121581f6 100644 --- a/lib/rules/no-plusplus.js +++ b/lib/rules/no-plusplus.js @@ -21,7 +21,7 @@ module.exports = function(context) { return { - "UpdateExpression": function(node) { + UpdateExpression: function(node) { if (allowInForAfterthought && node.parent.type === "ForStatement") { return; } @@ -34,12 +34,12 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "allowForLoopAfterthoughts": { - "type": "boolean" + type: "object", + properties: { + allowForLoopAfterthoughts: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-process-env.js b/lib/rules/no-process-env.js index 917510cac8a..10b5a7d1d03 100644 --- a/lib/rules/no-process-env.js +++ b/lib/rules/no-process-env.js @@ -12,7 +12,7 @@ module.exports = function(context) { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { var objectName = node.object.name, propertyName = node.property.name; diff --git a/lib/rules/no-process-exit.js b/lib/rules/no-process-exit.js index a1fa3b29dae..2bfa0495540 100644 --- a/lib/rules/no-process-exit.js +++ b/lib/rules/no-process-exit.js @@ -16,7 +16,7 @@ module.exports = function(context) { return { - "CallExpression": function(node) { + CallExpression: function(node) { var callee = node.callee; if (callee.type === "MemberExpression" && callee.object.name === "process" && diff --git a/lib/rules/no-proto.js b/lib/rules/no-proto.js index f91a46afebf..bbc77980830 100644 --- a/lib/rules/no-proto.js +++ b/lib/rules/no-proto.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { if (node.property && (node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed) || diff --git a/lib/rules/no-redeclare.js b/lib/rules/no-redeclare.js index 83a6eed9f03..6a0e1f859ef 100644 --- a/lib/rules/no-redeclare.js +++ b/lib/rules/no-redeclare.js @@ -71,26 +71,26 @@ module.exports = function(context) { if (context.parserOptions.ecmaVersion >= 6) { return { - "Program": checkForGlobal, - "BlockStatement": checkForBlock, - "SwitchStatement": checkForBlock + Program: checkForGlobal, + BlockStatement: checkForBlock, + SwitchStatement: checkForBlock }; } else { return { - "Program": checkForGlobal, - "FunctionDeclaration": checkForBlock, - "FunctionExpression": checkForBlock, - "ArrowFunctionExpression": checkForBlock + Program: checkForGlobal, + FunctionDeclaration: checkForBlock, + FunctionExpression: checkForBlock, + ArrowFunctionExpression: checkForBlock }; } }; module.exports.schema = [ { - "type": "object", - "properties": { - "builtinGlobals": {"type": "boolean"} + type: "object", + properties: { + builtinGlobals: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-regex-spaces.js b/lib/rules/no-regex-spaces.js index 0de9a49f35a..afbe86289c6 100644 --- a/lib/rules/no-regex-spaces.js +++ b/lib/rules/no-regex-spaces.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "Literal": function(node) { + Literal: function(node) { var token = context.getFirstToken(node), nodeType = token.type, nodeValue = token.value, diff --git a/lib/rules/no-restricted-globals.js b/lib/rules/no-restricted-globals.js index 4b4215e4d84..939dae93a24 100644 --- a/lib/rules/no-restricted-globals.js +++ b/lib/rules/no-restricted-globals.js @@ -39,7 +39,7 @@ module.exports = function(context) { } return { - "Program": function() { + Program: function() { var scope = context.getScope(); // Report variables declared elsewhere (ex: variables defined as "global" by eslint) @@ -61,10 +61,10 @@ module.exports = function(context) { }; module.exports.schema = { - "type": "array", - "items": { - "type": "string" + type: "array", + items: { + type: "string" }, - "uniqueItems": true + uniqueItems: true }; diff --git a/lib/rules/no-restricted-imports.js b/lib/rules/no-restricted-imports.js index bae6feef255..40ab28afbd6 100644 --- a/lib/rules/no-restricted-imports.js +++ b/lib/rules/no-restricted-imports.js @@ -17,7 +17,7 @@ module.exports = function(context) { } return { - "ImportDeclaration": function(node) { + ImportDeclaration: function(node) { if (node && node.source && node.source.value) { var value = node.source.value.trim(); @@ -33,9 +33,9 @@ module.exports = function(context) { }; module.exports.schema = { - "type": "array", - "items": { - "type": "string" + type: "array", + items: { + type: "string" }, - "uniqueItems": true + uniqueItems: true }; diff --git a/lib/rules/no-restricted-modules.js b/lib/rules/no-restricted-modules.js index 97097c41b05..ff1ca9aa3f8 100644 --- a/lib/rules/no-restricted-modules.js +++ b/lib/rules/no-restricted-modules.js @@ -58,7 +58,7 @@ module.exports = function(context) { } return { - "CallExpression": function(node) { + CallExpression: function(node) { if (isRequireCall(node)) { var restrictedModuleName = getRestrictedModuleName(node); @@ -73,9 +73,9 @@ module.exports = function(context) { }; module.exports.schema = { - "type": "array", - "items": { - "type": "string" + type: "array", + items: { + type: "string" }, - "uniqueItems": true + uniqueItems: true }; diff --git a/lib/rules/no-restricted-syntax.js b/lib/rules/no-restricted-syntax.js index 214d74b8ace..3c0d7273954 100644 --- a/lib/rules/no-restricted-syntax.js +++ b/lib/rules/no-restricted-syntax.js @@ -30,14 +30,14 @@ module.exports = function(context) { }; module.exports.schema = { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": Object.keys(nodeTypes).map(function(k) { + enum: Object.keys(nodeTypes).map(function(k) { return nodeTypes[k]; }) } ], - "uniqueItems": true, - "minItems": 0 + uniqueItems: true, + minItems: 0 }; diff --git a/lib/rules/no-return-assign.js b/lib/rules/no-return-assign.js index dc02897d410..5819dbd2e34 100644 --- a/lib/rules/no-return-assign.js +++ b/lib/rules/no-return-assign.js @@ -52,12 +52,12 @@ module.exports = function(context) { } return { - "ReturnStatement": function(node) { + ReturnStatement: function(node) { var message = "Return statement should not contain assignment."; checkForAssignInReturn(node.argument, node, message); }, - "ArrowFunctionExpression": function(node) { + ArrowFunctionExpression: function(node) { if (node.body.type !== "BlockStatement") { var message = "Arrow function should not return assignment."; @@ -69,6 +69,6 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["except-parens", "always"] + enum: ["except-parens", "always"] } ]; diff --git a/lib/rules/no-script-url.js b/lib/rules/no-script-url.js index 9526061b24f..4d6032e1298 100644 --- a/lib/rules/no-script-url.js +++ b/lib/rules/no-script-url.js @@ -15,7 +15,7 @@ module.exports = function(context) { return { - "Literal": function(node) { + Literal: function(node) { var value; diff --git a/lib/rules/no-self-assign.js b/lib/rules/no-self-assign.js index 4e7326e1118..4b4a7967d0a 100644 --- a/lib/rules/no-self-assign.js +++ b/lib/rules/no-self-assign.js @@ -112,7 +112,7 @@ module.exports = function(context) { } return { - "AssignmentExpression": function(node) { + AssignmentExpression: function(node) { if (node.operator === "=") { eachSelfAssignment(node.left, node.right, report); } diff --git a/lib/rules/no-self-compare.js b/lib/rules/no-self-compare.js index 9ab99d48f87..3313432b0c4 100644 --- a/lib/rules/no-self-compare.js +++ b/lib/rules/no-self-compare.js @@ -14,7 +14,7 @@ module.exports = function(context) { return { - "BinaryExpression": function(node) { + BinaryExpression: function(node) { var operators = ["===", "==", "!==", "!=", ">", "<", ">=", "<="]; if (operators.indexOf(node.operator) > -1 && diff --git a/lib/rules/no-sequences.js b/lib/rules/no-sequences.js index 032c879f8e5..e6581c077a2 100644 --- a/lib/rules/no-sequences.js +++ b/lib/rules/no-sequences.js @@ -15,11 +15,11 @@ module.exports = function(context) { * Parts of the grammar that are required to have parens. */ var parenthesized = { - "DoWhileStatement": "test", - "IfStatement": "test", - "SwitchStatement": "discriminant", - "WhileStatement": "test", - "WithStatement": "object" + DoWhileStatement: "test", + IfStatement: "test", + SwitchStatement: "discriminant", + WhileStatement: "test", + WithStatement: "object" // Omitting CallExpression - commas are parsed as argument separators // Omitting NewExpression - commas are parsed as argument separators @@ -67,7 +67,7 @@ module.exports = function(context) { } return { - "SequenceExpression": function(node) { + SequenceExpression: function(node) { // Always allow sequences in for statement update if (node.parent.type === "ForStatement" && diff --git a/lib/rules/no-shadow-restricted-names.js b/lib/rules/no-shadow-restricted-names.js index 7d3a712ec01..023be9d4133 100644 --- a/lib/rules/no-shadow-restricted-names.js +++ b/lib/rules/no-shadow-restricted-names.js @@ -25,25 +25,25 @@ module.exports = function(context) { } return { - "VariableDeclarator": function(node) { + VariableDeclarator: function(node) { checkForViolation(node.id); }, - "ArrowFunctionExpression": function(node) { + ArrowFunctionExpression: function(node) { [].map.call(node.params, checkForViolation); }, - "FunctionExpression": function(node) { + FunctionExpression: function(node) { if (node.id) { checkForViolation(node.id); } [].map.call(node.params, checkForViolation); }, - "FunctionDeclaration": function(node) { + FunctionDeclaration: function(node) { if (node.id) { checkForViolation(node.id); [].map.call(node.params, checkForViolation); } }, - "CatchClause": function(node) { + CatchClause: function(node) { checkForViolation(node.param); } }; diff --git a/lib/rules/no-shadow.js b/lib/rules/no-shadow.js index 1ed8a26da32..11f982635f2 100644 --- a/lib/rules/no-shadow.js +++ b/lib/rules/no-shadow.js @@ -162,17 +162,17 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "builtinGlobals": {"type": "boolean"}, - "hoist": {"enum": ["all", "functions", "never"]}, - "allow": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + builtinGlobals: {type: "boolean"}, + hoist: {enum: ["all", "functions", "never"]}, + allow: { + type: "array", + items: { + type: "string" } } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-spaced-func.js b/lib/rules/no-spaced-func.js index 551a3c60971..1ae192beddf 100644 --- a/lib/rules/no-spaced-func.js +++ b/lib/rules/no-spaced-func.js @@ -51,8 +51,8 @@ module.exports = function(context) { } return { - "CallExpression": detectOpenSpaces, - "NewExpression": detectOpenSpaces + CallExpression: detectOpenSpaces, + NewExpression: detectOpenSpaces }; }; diff --git a/lib/rules/no-sparse-arrays.js b/lib/rules/no-sparse-arrays.js index 808ec99bfc1..ba124e2c61f 100644 --- a/lib/rules/no-sparse-arrays.js +++ b/lib/rules/no-sparse-arrays.js @@ -17,7 +17,7 @@ module.exports = function(context) { return { - "ArrayExpression": function(node) { + ArrayExpression: function(node) { var emptySpot = node.elements.indexOf(null) > -1; diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js index 481514b83d4..b2da140b3d2 100644 --- a/lib/rules/no-sync.js +++ b/lib/rules/no-sync.js @@ -15,7 +15,7 @@ module.exports = function(context) { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { var propertyName = node.property.name, syncRegex = /.*Sync$/; diff --git a/lib/rules/no-ternary.js b/lib/rules/no-ternary.js index 79f8576b5fc..f302307192d 100644 --- a/lib/rules/no-ternary.js +++ b/lib/rules/no-ternary.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "ConditionalExpression": function(node) { + ConditionalExpression: function(node) { context.report(node, "Ternary operator used."); } diff --git a/lib/rules/no-this-before-super.js b/lib/rules/no-this-before-super.js index 25a6786cf12..d753781d084 100644 --- a/lib/rules/no-this-before-super.js +++ b/lib/rules/no-this-before-super.js @@ -125,7 +125,7 @@ module.exports = function(context) { * @param {ASTNode} node - The current node. * @returns {void} */ - "onCodePathStart": function(codePath, node) { + onCodePathStart: function(codePath, node) { if (isConstructorFunction(node)) { // Class > ClassBody > MethodDefinition > FunctionExpression @@ -160,7 +160,7 @@ module.exports = function(context) { * @param {ASTNode} node - The current node. * @returns {void} */ - "onCodePathEnd": function(codePath) { + onCodePathEnd: function(codePath) { var isDerivedClass = funcInfo.hasExtends; funcInfo = funcInfo.upper; @@ -194,7 +194,7 @@ module.exports = function(context) { * @param {CodePathSegment} segment - A code path segment to initialize. * @returns {void} */ - "onCodePathSegmentStart": function(segment) { + onCodePathSegmentStart: function(segment) { if (!isInConstructorOfDerivedClass(funcInfo)) { return; } @@ -218,7 +218,7 @@ module.exports = function(context) { * of a loop. * @returns {void} */ - "onCodePathSegmentLoop": function(fromSegment, toSegment) { + onCodePathSegmentLoop: function(fromSegment, toSegment) { if (!isInConstructorOfDerivedClass(funcInfo)) { return; } @@ -248,7 +248,7 @@ module.exports = function(context) { * @param {ASTNode} node - A target node. * @returns {void} */ - "ThisExpression": function(node) { + ThisExpression: function(node) { if (isBeforeCallOfSuper()) { setInvalid(node); } @@ -259,7 +259,7 @@ module.exports = function(context) { * @param {ASTNode} node - A target node. * @returns {void} */ - "Super": function(node) { + Super: function(node) { if (!astUtils.isCallee(node) && isBeforeCallOfSuper()) { setInvalid(node); } diff --git a/lib/rules/no-throw-literal.js b/lib/rules/no-throw-literal.js index ed5a06eddfc..c8951732248 100644 --- a/lib/rules/no-throw-literal.js +++ b/lib/rules/no-throw-literal.js @@ -51,7 +51,7 @@ module.exports = function(context) { return { - "ThrowStatement": function(node) { + ThrowStatement: function(node) { if (!couldBeError(node.argument)) { context.report(node, "Expected an object to be thrown."); } else if (node.argument.type === "Identifier") { diff --git a/lib/rules/no-trailing-spaces.js b/lib/rules/no-trailing-spaces.js index 31308ca083e..17bf214ecf4 100644 --- a/lib/rules/no-trailing-spaces.js +++ b/lib/rules/no-trailing-spaces.js @@ -50,7 +50,7 @@ module.exports = function(context) { return { - "Program": function checkTrailingSpaces(node) { + Program: function checkTrailingSpaces(node) { // Let's hack. Since Espree does not return whitespace nodes, // fetch the source code and do matching via regexps. @@ -112,12 +112,12 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "skipBlankLines": { - "type": "boolean" + type: "object", + properties: { + skipBlankLines: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-undef-init.js b/lib/rules/no-undef-init.js index c031c65b915..a6acd161c2f 100644 --- a/lib/rules/no-undef-init.js +++ b/lib/rules/no-undef-init.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "VariableDeclarator": function(node) { + VariableDeclarator: function(node) { var name = node.id.name, init = node.init && node.init.name; diff --git a/lib/rules/no-undef.js b/lib/rules/no-undef.js index 9e656c17baf..4b8a40fbb15 100644 --- a/lib/rules/no-undef.js +++ b/lib/rules/no-undef.js @@ -50,12 +50,12 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "typeof": { - "type": "boolean" + type: "object", + properties: { + typeof: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-undefined.js b/lib/rules/no-undefined.js index a44eabf1b1f..74f3ed2d426 100644 --- a/lib/rules/no-undefined.js +++ b/lib/rules/no-undefined.js @@ -12,7 +12,7 @@ module.exports = function(context) { return { - "Identifier": function(node) { + Identifier: function(node) { if (node.name === "undefined") { var parent = context.getAncestors().pop(); diff --git a/lib/rules/no-underscore-dangle.js b/lib/rules/no-underscore-dangle.js index 6401e93e378..6abfdd6ce72 100644 --- a/lib/rules/no-underscore-dangle.js +++ b/lib/rules/no-underscore-dangle.js @@ -118,27 +118,27 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "FunctionDeclaration": checkForTrailingUnderscoreInFunctionDeclaration, - "VariableDeclarator": checkForTrailingUnderscoreInVariableExpression, - "MemberExpression": checkForTrailingUnderscoreInMemberExpression + FunctionDeclaration: checkForTrailingUnderscoreInFunctionDeclaration, + VariableDeclarator: checkForTrailingUnderscoreInVariableExpression, + MemberExpression: checkForTrailingUnderscoreInMemberExpression }; }; module.exports.schema = [ { - "type": "object", - "properties": { - "allow": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + allow: { + type: "array", + items: { + type: "string" } }, - "allowAfterThis": { - "type": "boolean" + allowAfterThis: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-unexpected-multiline.js b/lib/rules/no-unexpected-multiline.js index 8794953e97a..4f827e86f2a 100644 --- a/lib/rules/no-unexpected-multiline.js +++ b/lib/rules/no-unexpected-multiline.js @@ -42,21 +42,21 @@ module.exports = function(context) { return { - "MemberExpression": function(node) { + MemberExpression: function(node) { if (!node.computed) { return; } checkForBreakAfter(node.object, PROPERTY_MESSAGE); }, - "TaggedTemplateExpression": function(node) { + TaggedTemplateExpression: function(node) { if (node.tag.loc.end.line === node.quasi.loc.start.line) { return; } context.report(node, node.loc.start, TAGGED_TEMPLATE_MESSAGE); }, - "CallExpression": function(node) { + CallExpression: function(node) { if (node.arguments.length === 0) { return; } diff --git a/lib/rules/no-unneeded-ternary.js b/lib/rules/no-unneeded-ternary.js index 357cc7f0102..16a30b01e0f 100644 --- a/lib/rules/no-unneeded-ternary.js +++ b/lib/rules/no-unneeded-ternary.js @@ -37,7 +37,7 @@ module.exports = function(context) { return { - "ConditionalExpression": function(node) { + ConditionalExpression: function(node) { if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) { context.report(node, node.consequent.loc.start, "Unnecessary use of boolean literals in conditional expression"); } else if (!defaultAssignment && matchesDefaultAssignment(node)) { @@ -49,12 +49,12 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "defaultAssignment": { - "type": "boolean" + type: "object", + properties: { + defaultAssignment: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-unreachable.js b/lib/rules/no-unreachable.js index 680c8f0edd3..cbdb402dcb9 100644 --- a/lib/rules/no-unreachable.js +++ b/lib/rules/no-unreachable.js @@ -47,11 +47,11 @@ module.exports = function(context) { return { // Manages the current code path. - "onCodePathStart": function(codePath) { + onCodePathStart: function(codePath) { currentCodePath = codePath; }, - "onCodePathEnd": function() { + onCodePathEnd: function() { currentCodePath = currentCodePath.upper; }, diff --git a/lib/rules/no-unused-expressions.js b/lib/rules/no-unused-expressions.js index 9588c800a97..019166a2ff5 100644 --- a/lib/rules/no-unused-expressions.js +++ b/lib/rules/no-unused-expressions.js @@ -82,7 +82,7 @@ module.exports = function(context) { } return { - "ExpressionStatement": function(node) { + ExpressionStatement: function(node) { if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) { context.report(node, "Expected an assignment or function call and instead saw an expression."); } @@ -93,15 +93,15 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "allowShortCircuit": { - "type": "boolean" + type: "object", + properties: { + allowShortCircuit: { + type: "boolean" }, - "allowTernary": { - "type": "boolean" + allowTernary: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-unused-labels.js b/lib/rules/no-unused-labels.js index e7da1990389..55c8869d86e 100644 --- a/lib/rules/no-unused-labels.js +++ b/lib/rules/no-unused-labels.js @@ -70,10 +70,10 @@ module.exports = function(context) { } return { - "LabeledStatement": enterLabeledScope, + LabeledStatement: enterLabeledScope, "LabeledStatement:exit": exitLabeledScope, - "BreakStatement": markAsUsed, - "ContinueStatement": markAsUsed + BreakStatement: markAsUsed, + ContinueStatement: markAsUsed }; }; diff --git a/lib/rules/no-unused-vars.js b/lib/rules/no-unused-vars.js index fa889d19751..84db439ba67 100644 --- a/lib/rules/no-unused-vars.js +++ b/lib/rules/no-unused-vars.js @@ -300,30 +300,30 @@ module.exports = function(context) { module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["all", "local"] + enum: ["all", "local"] }, { - "type": "object", - "properties": { - "vars": { - "enum": ["all", "local"] + type: "object", + properties: { + vars: { + enum: ["all", "local"] }, - "varsIgnorePattern": { - "type": "string" + varsIgnorePattern: { + type: "string" }, - "args": { - "enum": ["all", "after-used", "none"] + args: { + enum: ["all", "after-used", "none"] }, - "argsIgnorePattern": { - "type": "string" + argsIgnorePattern: { + type: "string" }, - "caughtErrors": { - "enum": ["all", "none"] + caughtErrors: { + enum: ["all", "none"] }, - "caughtErrorsIgnorePattern": { - "type": "string" + caughtErrorsIgnorePattern: { + type: "string" } } } diff --git a/lib/rules/no-use-before-define.js b/lib/rules/no-use-before-define.js index ea0add2ea0d..a0ce34c2a98 100644 --- a/lib/rules/no-use-before-define.js +++ b/lib/rules/no-use-before-define.js @@ -219,17 +219,17 @@ module.exports = function(context) { module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["nofunc"] + enum: ["nofunc"] }, { - "type": "object", - "properties": { - "functions": {"type": "boolean"}, - "classes": {"type": "boolean"} + type: "object", + properties: { + functions: {type: "boolean"}, + classes: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ] } diff --git a/lib/rules/no-useless-call.js b/lib/rules/no-useless-call.js index 7feb0558fca..808e39624ce 100644 --- a/lib/rules/no-useless-call.js +++ b/lib/rules/no-useless-call.js @@ -73,7 +73,7 @@ function isValidThisArg(expectedThis, thisArg, context) { module.exports = function(context) { return { - "CallExpression": function(node) { + CallExpression: function(node) { if (!isCallOrNonVariadicApply(node)) { return; } diff --git a/lib/rules/no-useless-computed-key.js b/lib/rules/no-useless-computed-key.js index 1242699d694..0894fb7ca41 100644 --- a/lib/rules/no-useless-computed-key.js +++ b/lib/rules/no-useless-computed-key.js @@ -20,7 +20,7 @@ module.exports = { }, create: function(context) { return { - "Property": function(node) { + Property: function(node) { if (!node.computed) { return; } diff --git a/lib/rules/no-useless-constructor.js b/lib/rules/no-useless-constructor.js index f4f036d4048..a2f1dd82575 100644 --- a/lib/rules/no-useless-constructor.js +++ b/lib/rules/no-useless-constructor.js @@ -165,7 +165,7 @@ module.exports = function(context) { } return { - "MethodDefinition": checkForConstructor + MethodDefinition: checkForConstructor }; }; diff --git a/lib/rules/no-useless-escape.js b/lib/rules/no-useless-escape.js index 2b6f9c7e9cc..7a4a26287f2 100644 --- a/lib/rules/no-useless-escape.js +++ b/lib/rules/no-useless-escape.js @@ -113,7 +113,7 @@ module.exports = function(context) { } } return { - "Literal": check + Literal: check }; }; diff --git a/lib/rules/no-var.js b/lib/rules/no-var.js index 36961865318..caa11351b55 100644 --- a/lib/rules/no-var.js +++ b/lib/rules/no-var.js @@ -12,7 +12,7 @@ module.exports = function(context) { return { - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { if (node.kind === "var") { context.report(node, "Unexpected var, use let or const instead."); } diff --git a/lib/rules/no-void.js b/lib/rules/no-void.js index ee7603f3031..9f872fa4cc1 100644 --- a/lib/rules/no-void.js +++ b/lib/rules/no-void.js @@ -15,7 +15,7 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "UnaryExpression": function(node) { + UnaryExpression: function(node) { if (node.operator === "void") { context.report(node, "Expected 'undefined' and instead saw 'void'."); } diff --git a/lib/rules/no-warning-comments.js b/lib/rules/no-warning-comments.js index 02450229d9f..5d4859fcc26 100644 --- a/lib/rules/no-warning-comments.js +++ b/lib/rules/no-warning-comments.js @@ -96,25 +96,25 @@ module.exports = function(context) { warningRegExps = warningTerms.map(convertToRegExp); return { - "BlockComment": checkComment, - "LineComment": checkComment + BlockComment: checkComment, + LineComment: checkComment }; }; module.exports.schema = [ { - "type": "object", - "properties": { - "terms": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + terms: { + type: "array", + items: { + type: "string" } }, - "location": { - "enum": ["start", "anywhere"] + location: { + enum: ["start", "anywhere"] } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/no-with.js b/lib/rules/no-with.js index beec2554db2..894f2278f1f 100644 --- a/lib/rules/no-with.js +++ b/lib/rules/no-with.js @@ -12,7 +12,7 @@ module.exports = function(context) { return { - "WithStatement": function(node) { + WithStatement: function(node) { context.report(node, "Unexpected use of 'with' statement."); } }; diff --git a/lib/rules/object-curly-spacing.js b/lib/rules/object-curly-spacing.js index 680bdc6746b..bd14372d4c7 100644 --- a/lib/rules/object-curly-spacing.js +++ b/lib/rules/object-curly-spacing.js @@ -257,18 +257,18 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "arraysInObjects": { - "type": "boolean" + type: "object", + properties: { + arraysInObjects: { + type: "boolean" }, - "objectsInObjects": { - "type": "boolean" + objectsInObjects: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/object-shorthand.js b/lib/rules/object-shorthand.js index 23bc86129c9..d9f5a0ed0d3 100644 --- a/lib/rules/object-shorthand.js +++ b/lib/rules/object-shorthand.js @@ -45,7 +45,7 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "Property": function(node) { + Property: function(node) { var isConciseProperty = node.method || node.shorthand, type; @@ -92,35 +92,35 @@ module.exports = function(context) { }; module.exports.schema = { - "anyOf": [ + anyOf: [ { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["always", "methods", "properties", "never"] + enum: ["always", "methods", "properties", "never"] } ], - "minItems": 0, - "maxItems": 1 + minItems: 0, + maxItems: 1 }, { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["always", "methods"] + enum: ["always", "methods"] }, { - "type": "object", - "properties": { - "ignoreConstructors": { - "type": "boolean" + type: "object", + properties: { + ignoreConstructors: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ], - "minItems": 0, - "maxItems": 2 + minItems: 0, + maxItems: 2 } ] }; diff --git a/lib/rules/one-var-declaration-per-line.js b/lib/rules/one-var-declaration-per-line.js index 80c0e573aa3..7949d48bc5a 100644 --- a/lib/rules/one-var-declaration-per-line.js +++ b/lib/rules/one-var-declaration-per-line.js @@ -61,13 +61,13 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "VariableDeclaration": checkForNewLine + VariableDeclaration: checkForNewLine }; }; module.exports.schema = [ { - "enum": ["always", "initializations"] + enum: ["always", "initializations"] } ]; diff --git a/lib/rules/one-var.js b/lib/rules/one-var.js index e96f2d10f1f..783b1de6926 100644 --- a/lib/rules/one-var.js +++ b/lib/rules/one-var.js @@ -209,17 +209,17 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "Program": startFunction, - "FunctionDeclaration": startFunction, - "FunctionExpression": startFunction, - "ArrowFunctionExpression": startFunction, - "BlockStatement": startBlock, - "ForStatement": startBlock, - "ForInStatement": startBlock, - "ForOfStatement": startBlock, - "SwitchStatement": startBlock, - - "VariableDeclaration": function(node) { + Program: startFunction, + FunctionDeclaration: startFunction, + FunctionExpression: startFunction, + ArrowFunctionExpression: startFunction, + BlockStatement: startBlock, + ForStatement: startBlock, + ForInStatement: startBlock, + ForOfStatement: startBlock, + SwitchStatement: startBlock, + + VariableDeclaration: function(node) { var parent = node.parent, type, declarations, declarationCounts; @@ -283,36 +283,36 @@ module.exports = function(context) { module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "var": { - "enum": ["always", "never"] + type: "object", + properties: { + var: { + enum: ["always", "never"] }, - "let": { - "enum": ["always", "never"] + let: { + enum: ["always", "never"] }, - "const": { - "enum": ["always", "never"] + const: { + enum: ["always", "never"] } }, - "additionalProperties": false + additionalProperties: false }, { - "type": "object", - "properties": { - "initialized": { - "enum": ["always", "never"] + type: "object", + properties: { + initialized: { + enum: ["always", "never"] }, - "uninitialized": { - "enum": ["always", "never"] + uninitialized: { + enum: ["always", "never"] } }, - "additionalProperties": false + additionalProperties: false } ] } diff --git a/lib/rules/operator-assignment.js b/lib/rules/operator-assignment.js index f44d0b529fa..823de602c18 100644 --- a/lib/rules/operator-assignment.js +++ b/lib/rules/operator-assignment.js @@ -111,13 +111,13 @@ module.exports = function(context) { } return { - "AssignmentExpression": context.options[0] !== "never" ? verify : prohibit + AssignmentExpression: context.options[0] !== "never" ? verify : prohibit }; }; module.exports.schema = [ { - "enum": ["always", "never"] + enum: ["always", "never"] } ]; diff --git a/lib/rules/operator-linebreak.js b/lib/rules/operator-linebreak.js index f0aae97c788..2ed1e216e7c 100644 --- a/lib/rules/operator-linebreak.js +++ b/lib/rules/operator-linebreak.js @@ -110,15 +110,15 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "BinaryExpression": validateBinaryExpression, - "LogicalExpression": validateBinaryExpression, - "AssignmentExpression": validateBinaryExpression, - "VariableDeclarator": function(node) { + BinaryExpression: validateBinaryExpression, + LogicalExpression: validateBinaryExpression, + AssignmentExpression: validateBinaryExpression, + VariableDeclarator: function(node) { if (node.init) { validateNode(node, node.id); } }, - "ConditionalExpression": function(node) { + ConditionalExpression: function(node) { validateNode(node, node.test); validateNode(node, node.consequent); } @@ -127,21 +127,21 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["after", "before", "none", null] + enum: ["after", "before", "none", null] }, { - "type": "object", - "properties": { - "overrides": { - "type": "object", - "properties": { - "anyOf": { - "type": "string", - "enum": ["after", "before", "none", "ignore"] + type: "object", + properties: { + overrides: { + type: "object", + properties: { + anyOf: { + type: "string", + enum: ["after", "before", "none", "ignore"] } } } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/padded-blocks.js b/lib/rules/padded-blocks.js index 7d2eea1e77f..9e1da0deda7 100644 --- a/lib/rules/padded-blocks.js +++ b/lib/rules/padded-blocks.js @@ -192,25 +192,25 @@ module.exports = function(context) { module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "blocks": { - "enum": ["always", "never"] + type: "object", + properties: { + blocks: { + enum: ["always", "never"] }, - "switches": { - "enum": ["always", "never"] + switches: { + enum: ["always", "never"] }, - "classes": { - "enum": ["always", "never"] + classes: { + enum: ["always", "never"] } }, - "additionalProperties": false, - "minProperties": 1 + additionalProperties: false, + minProperties: 1 } ] } diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js index e7d9bc821a7..e37df4c9eac 100644 --- a/lib/rules/prefer-arrow-callback.js +++ b/lib/rules/prefer-arrow-callback.js @@ -233,7 +233,7 @@ module.exports.schema = [ type: "object", properties: { allowNamedFunctions: { - "type": "boolean" + type: "boolean" }, allowUnboundThis: { type: "boolean" diff --git a/lib/rules/prefer-const.js b/lib/rules/prefer-const.js index bc346f9f930..380b0a880d1 100644 --- a/lib/rules/prefer-const.js +++ b/lib/rules/prefer-const.js @@ -234,7 +234,7 @@ module.exports = function(context) { } return { - "Program": function() { + Program: function() { variables = []; }, @@ -248,7 +248,7 @@ module.exports = function(context) { variables = null; }, - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { if (node.kind === "let" && !isInitOfForStatement(node)) { pushAll(variables, context.getDeclaredVariables(node)); } diff --git a/lib/rules/prefer-reflect.js b/lib/rules/prefer-reflect.js index 742e9c169ec..9f48d69e3d2 100644 --- a/lib/rules/prefer-reflect.js +++ b/lib/rules/prefer-reflect.js @@ -10,27 +10,27 @@ module.exports = function(context) { var existingNames = { - "apply": "Function.prototype.apply", - "call": "Function.prototype.call", - "defineProperty": "Object.defineProperty", - "getOwnPropertyDescriptor": "Object.getOwnPropertyDescriptor", - "getPrototypeOf": "Object.getPrototypeOf", - "setPrototypeOf": "Object.setPrototypeOf", - "isExtensible": "Object.isExtensible", - "getOwnPropertyNames": "Object.getOwnPropertyNames", - "preventExtensions": "Object.preventExtensions" + apply: "Function.prototype.apply", + call: "Function.prototype.call", + defineProperty: "Object.defineProperty", + getOwnPropertyDescriptor: "Object.getOwnPropertyDescriptor", + getPrototypeOf: "Object.getPrototypeOf", + setPrototypeOf: "Object.setPrototypeOf", + isExtensible: "Object.isExtensible", + getOwnPropertyNames: "Object.getOwnPropertyNames", + preventExtensions: "Object.preventExtensions" }; var reflectSubsitutes = { - "apply": "Reflect.apply", - "call": "Reflect.apply", - "defineProperty": "Reflect.defineProperty", - "getOwnPropertyDescriptor": "Reflect.getOwnPropertyDescriptor", - "getPrototypeOf": "Reflect.getPrototypeOf", - "setPrototypeOf": "Reflect.setPrototypeOf", - "isExtensible": "Reflect.isExtensible", - "getOwnPropertyNames": "Reflect.getOwnPropertyNames", - "preventExtensions": "Reflect.preventExtensions" + apply: "Reflect.apply", + call: "Reflect.apply", + defineProperty: "Reflect.defineProperty", + getOwnPropertyDescriptor: "Reflect.getOwnPropertyDescriptor", + getPrototypeOf: "Reflect.getPrototypeOf", + setPrototypeOf: "Reflect.setPrototypeOf", + isExtensible: "Reflect.isExtensible", + getOwnPropertyNames: "Reflect.getOwnPropertyNames", + preventExtensions: "Reflect.preventExtensions" }; var exceptions = (context.options[0] || {}).exceptions || []; @@ -50,7 +50,7 @@ module.exports = function(context) { } return { - "CallExpression": function(node) { + CallExpression: function(node) { var methodName = (node.callee.property || {}).name; var isReflectCall = (node.callee.object || {}).name === "Reflect"; var hasReflectSubsitute = reflectSubsitutes.hasOwnProperty(methodName); @@ -60,7 +60,7 @@ module.exports = function(context) { report(node, existingNames[methodName], reflectSubsitutes[methodName]); } }, - "UnaryExpression": function(node) { + UnaryExpression: function(node) { var isDeleteOperator = node.operator === "delete"; var targetsIdentifier = node.argument.type === "Identifier"; var userConfiguredException = exceptions.indexOf("delete") !== -1; @@ -75,12 +75,12 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": { - "enum": [ + type: "object", + properties: { + exceptions: { + type: "array", + items: { + enum: [ "apply", "call", "delete", @@ -93,9 +93,9 @@ module.exports.schema = [ "preventExtensions" ] }, - "uniqueItems": true + uniqueItems: true } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/prefer-spread.js b/lib/rules/prefer-spread.js index a5cb3d2c7f0..c0181c6ef0d 100644 --- a/lib/rules/prefer-spread.js +++ b/lib/rules/prefer-spread.js @@ -72,7 +72,7 @@ function isValidThisArg(expectedThis, thisArg, context) { module.exports = function(context) { return { - "CallExpression": function(node) { + CallExpression: function(node) { if (!isVariadicApplyCalling(node)) { return; } diff --git a/lib/rules/quote-props.js b/lib/rules/quote-props.js index 7aa796e3586..117eca21fdc 100644 --- a/lib/rules/quote-props.js +++ b/lib/rules/quote-props.js @@ -160,7 +160,7 @@ module.exports = function(context) { } return { - "Property": function(node) { + Property: function(node) { if (MODE === "always" || !MODE) { checkOmittedQuotes(node); } @@ -168,7 +168,7 @@ module.exports = function(context) { checkUnnecessaryQuotes(node); } }, - "ObjectExpression": function(node) { + ObjectExpression: function(node) { if (MODE === "consistent") { checkConsistency(node, false); } @@ -181,41 +181,41 @@ module.exports = function(context) { }; module.exports.schema = { - "anyOf": [ + anyOf: [ { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["always", "as-needed", "consistent", "consistent-as-needed"] + enum: ["always", "as-needed", "consistent", "consistent-as-needed"] } ], - "minItems": 0, - "maxItems": 1 + minItems: 0, + maxItems: 1 }, { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["always", "as-needed", "consistent", "consistent-as-needed"] + enum: ["always", "as-needed", "consistent", "consistent-as-needed"] }, { - "type": "object", - "properties": { - "keywords": { - "type": "boolean" + type: "object", + properties: { + keywords: { + type: "boolean" }, - "unnecessary": { - "type": "boolean" + unnecessary: { + type: "boolean" }, - "numbers": { - "type": "boolean" + numbers: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ], - "minItems": 0, - "maxItems": 2 + minItems: 0, + maxItems: 2 } ] }; diff --git a/lib/rules/quotes.js b/lib/rules/quotes.js index d04f0e1c0a5..558aeba16f9 100644 --- a/lib/rules/quotes.js +++ b/lib/rules/quotes.js @@ -16,17 +16,17 @@ var astUtils = require("../ast-utils"); //------------------------------------------------------------------------------ var QUOTE_SETTINGS = { - "double": { + double: { quote: "\"", alternateQuote: "'", description: "doublequote" }, - "single": { + single: { quote: "'", alternateQuote: "\"", description: "singlequote" }, - "backtick": { + backtick: { quote: "`", alternateQuote: "\"", description: "backtick" @@ -173,7 +173,7 @@ module.exports = function(context) { return { - "Literal": function(node) { + Literal: function(node) { var val = node.value, rawVal = node.raw, isValid; @@ -199,7 +199,7 @@ module.exports = function(context) { } }, - "TemplateLiteral": function(node) { + TemplateLiteral: function(node) { // If backticks are expected or it's a tagged template, then this shouldn't throw an errors if (allowTemplateLiterals || quoteOption === "backtick" || node.parent.type === "TaggedTemplateExpression") { @@ -224,24 +224,24 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["single", "double", "backtick"] + enum: ["single", "double", "backtick"] }, { - "anyOf": [ + anyOf: [ { - "enum": ["avoid-escape"] + enum: ["avoid-escape"] }, { - "type": "object", - "properties": { - "avoidEscape": { - "type": "boolean" + type: "object", + properties: { + avoidEscape: { + type: "boolean" }, - "allowTemplateLiterals": { - "type": "boolean" + allowTemplateLiterals: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ] } diff --git a/lib/rules/radix.js b/lib/rules/radix.js index 23a2f71d445..0560c58fb0e 100644 --- a/lib/rules/radix.js +++ b/lib/rules/radix.js @@ -156,6 +156,6 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["always", "as-needed"] + enum: ["always", "as-needed"] } ]; diff --git a/lib/rules/require-jsdoc.js b/lib/rules/require-jsdoc.js index 18cbff3201a..acf75cbcfcf 100644 --- a/lib/rules/require-jsdoc.js +++ b/lib/rules/require-jsdoc.js @@ -9,9 +9,9 @@ var lodash = require("lodash"); module.exports = function(context) { var source = context.getSourceCode(); var DEFAULT_OPTIONS = { - "FunctionDeclaration": true, - "MethodDefinition": false, - "ClassDeclaration": false + FunctionDeclaration: true, + MethodDefinition: false, + ClassDeclaration: false }; var options = lodash.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require || {}); @@ -53,17 +53,17 @@ module.exports = function(context) { } return { - "FunctionDeclaration": function(node) { + FunctionDeclaration: function(node) { if (options.FunctionDeclaration) { checkJsDoc(node); } }, - "FunctionExpression": function(node) { + FunctionExpression: function(node) { if (options.MethodDefinition) { checkClassMethodJsDoc(node); } }, - "ClassDeclaration": function(node) { + ClassDeclaration: function(node) { if (options.ClassDeclaration) { checkJsDoc(node); } @@ -73,24 +73,24 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "require": { - "type": "object", - "properties": { - "ClassDeclaration": { - "type": "boolean" + type: "object", + properties: { + require: { + type: "object", + properties: { + ClassDeclaration: { + type: "boolean" }, - "MethodDefinition": { - "type": "boolean" + MethodDefinition: { + type: "boolean" }, - "FunctionDeclaration": { - "type": "boolean" + FunctionDeclaration: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/require-yield.js b/lib/rules/require-yield.js index 748dafa765c..e27ee63aa09 100644 --- a/lib/rules/require-yield.js +++ b/lib/rules/require-yield.js @@ -44,13 +44,13 @@ module.exports = function(context) { } return { - "FunctionDeclaration": beginChecking, + FunctionDeclaration: beginChecking, "FunctionDeclaration:exit": endChecking, - "FunctionExpression": beginChecking, + FunctionExpression: beginChecking, "FunctionExpression:exit": endChecking, // Increases the count of `yield` keyword. - "YieldExpression": function() { + YieldExpression: function() { /* istanbul ignore else */ if (stack.length > 0) { diff --git a/lib/rules/semi-spacing.js b/lib/rules/semi-spacing.js index 6bfb2ecacf2..436ad41f191 100644 --- a/lib/rules/semi-spacing.js +++ b/lib/rules/semi-spacing.js @@ -175,14 +175,14 @@ module.exports = function(context) { } return { - "VariableDeclaration": checkNode, - "ExpressionStatement": checkNode, - "BreakStatement": checkNode, - "ContinueStatement": checkNode, - "DebuggerStatement": checkNode, - "ReturnStatement": checkNode, - "ThrowStatement": checkNode, - "ForStatement": function(node) { + VariableDeclaration: checkNode, + ExpressionStatement: checkNode, + BreakStatement: checkNode, + ContinueStatement: checkNode, + DebuggerStatement: checkNode, + ReturnStatement: checkNode, + ThrowStatement: checkNode, + ForStatement: function(node) { if (node.init) { checkSemicolonSpacing(context.getTokenAfter(node.init), node); } @@ -196,15 +196,15 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "before": { - "type": "boolean" + type: "object", + properties: { + before: { + type: "boolean" }, - "after": { - "type": "boolean" + after: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/semi.js b/lib/rules/semi.js index 38c6b4e2adf..cb9854b74b1 100644 --- a/lib/rules/semi.js +++ b/lib/rules/semi.js @@ -157,22 +157,22 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "VariableDeclaration": checkForSemicolonForVariableDeclaration, - "ExpressionStatement": checkForSemicolon, - "ReturnStatement": checkForSemicolon, - "ThrowStatement": checkForSemicolon, - "DoWhileStatement": checkForSemicolon, - "DebuggerStatement": checkForSemicolon, - "BreakStatement": checkForSemicolon, - "ContinueStatement": checkForSemicolon, - "ImportDeclaration": checkForSemicolon, - "ExportAllDeclaration": checkForSemicolon, - "ExportNamedDeclaration": function(node) { + VariableDeclaration: checkForSemicolonForVariableDeclaration, + ExpressionStatement: checkForSemicolon, + ReturnStatement: checkForSemicolon, + ThrowStatement: checkForSemicolon, + DoWhileStatement: checkForSemicolon, + DebuggerStatement: checkForSemicolon, + BreakStatement: checkForSemicolon, + ContinueStatement: checkForSemicolon, + ImportDeclaration: checkForSemicolon, + ExportAllDeclaration: checkForSemicolon, + ExportNamedDeclaration: function(node) { if (!node.declaration) { checkForSemicolon(node); } }, - "ExportDefaultDeclaration": function(node) { + ExportDefaultDeclaration: function(node) { if (!/(?:Class|Function)Declaration/.test(node.declaration.type)) { checkForSemicolon(node); } @@ -182,33 +182,33 @@ module.exports = function(context) { }; module.exports.schema = { - "anyOf": [ + anyOf: [ { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["never"] + enum: ["never"] } ], - "minItems": 0, - "maxItems": 1 + minItems: 0, + maxItems: 1 }, { - "type": "array", - "items": [ + type: "array", + items: [ { - "enum": ["always"] + enum: ["always"] }, { - "type": "object", - "properties": { - "omitLastInOneLineBlock": {"type": "boolean"} + type: "object", + properties: { + omitLastInOneLineBlock: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ], - "minItems": 0, - "maxItems": 2 + minItems: 0, + maxItems: 2 } ] }; diff --git a/lib/rules/sort-imports.js b/lib/rules/sort-imports.js index 7bcec410186..29a99b0081b 100644 --- a/lib/rules/sort-imports.js +++ b/lib/rules/sort-imports.js @@ -63,7 +63,7 @@ module.exports = function(context) { } return { - "ImportDeclaration": function(node) { + ImportDeclaration: function(node) { if (previousDeclaration) { var currentLocalMemberName = getFirstLocalMemberName(node), currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node), @@ -142,24 +142,24 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "ignoreCase": { - "type": "boolean" + type: "object", + properties: { + ignoreCase: { + type: "boolean" }, - "memberSyntaxSortOrder": { - "type": "array", - "items": { - "enum": ["none", "all", "multiple", "single"] + memberSyntaxSortOrder: { + type: "array", + items: { + enum: ["none", "all", "multiple", "single"] }, - "uniqueItems": true, - "minItems": 4, - "maxItems": 4 + uniqueItems: true, + minItems: 4, + maxItems: 4 }, - "ignoreMemberSort": { - "type": "boolean" + ignoreMemberSort: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/sort-vars.js b/lib/rules/sort-vars.js index 9aa85c8cbd0..76466a149ff 100644 --- a/lib/rules/sort-vars.js +++ b/lib/rules/sort-vars.js @@ -15,7 +15,7 @@ module.exports = function(context) { ignoreCase = configuration.ignoreCase || false; return { - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { node.declarations.reduce(function(memo, decl) { if (decl.id.type === "ObjectPattern" || decl.id.type === "ArrayPattern") { return memo; @@ -42,12 +42,12 @@ module.exports = function(context) { module.exports.schema = [ { - "type": "object", - "properties": { - "ignoreCase": { - "type": "boolean" + type: "object", + properties: { + ignoreCase: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/space-before-blocks.js b/lib/rules/space-before-blocks.js index e504904734f..e9bdc0207b6 100644 --- a/lib/rules/space-before-blocks.js +++ b/lib/rules/space-before-blocks.js @@ -106,33 +106,33 @@ module.exports = function(context) { } return { - "BlockStatement": checkPrecedingSpace, - "ClassBody": checkPrecedingSpace, - "SwitchStatement": checkSpaceBeforeCaseBlock + BlockStatement: checkPrecedingSpace, + ClassBody: checkPrecedingSpace, + SwitchStatement: checkSpaceBeforeCaseBlock }; }; module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "keywords": { - "enum": ["always", "never"] + type: "object", + properties: { + keywords: { + enum: ["always", "never"] }, - "functions": { - "enum": ["always", "never"] + functions: { + enum: ["always", "never"] }, - "classes": { - "enum": ["always", "never"] + classes: { + enum: ["always", "never"] } }, - "additionalProperties": false + additionalProperties: false } ] } diff --git a/lib/rules/space-before-function-paren.js b/lib/rules/space-before-function-paren.js index 03b8b726fa0..d9092061d8d 100644 --- a/lib/rules/space-before-function-paren.js +++ b/lib/rules/space-before-function-paren.js @@ -102,28 +102,28 @@ module.exports = function(context) { } return { - "FunctionDeclaration": validateSpacingBeforeParentheses, - "FunctionExpression": validateSpacingBeforeParentheses + FunctionDeclaration: validateSpacingBeforeParentheses, + FunctionExpression: validateSpacingBeforeParentheses }; }; module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "anonymous": { - "enum": ["always", "never", "ignore"] + type: "object", + properties: { + anonymous: { + enum: ["always", "never", "ignore"] }, - "named": { - "enum": ["always", "never", "ignore"] + named: { + enum: ["always", "never", "ignore"] } }, - "additionalProperties": false + additionalProperties: false } ] } diff --git a/lib/rules/space-in-parens.js b/lib/rules/space-in-parens.js index c294ad17d09..af1f3353717 100644 --- a/lib/rules/space-in-parens.js +++ b/lib/rules/space-in-parens.js @@ -186,7 +186,7 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "Program": function checkParenSpaces(node) { + Program: function checkParenSpaces(node) { var tokens, prevToken, nextToken; exceptions = getExceptions(); @@ -251,19 +251,19 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": { - "enum": ["{}", "[]", "()", "empty"] + type: "object", + properties: { + exceptions: { + type: "array", + items: { + enum: ["{}", "[]", "()", "empty"] }, - "uniqueItems": true + uniqueItems: true } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/space-infix-ops.js b/lib/rules/space-infix-ops.js index dee07ee31ae..8893be7b1f3 100644 --- a/lib/rules/space-infix-ops.js +++ b/lib/rules/space-infix-ops.js @@ -125,24 +125,24 @@ module.exports = function(context) { } return { - "AssignmentExpression": checkBinary, - "AssignmentPattern": checkBinary, - "BinaryExpression": checkBinary, - "LogicalExpression": checkBinary, - "ConditionalExpression": checkConditional, - "VariableDeclarator": checkVar + AssignmentExpression: checkBinary, + AssignmentPattern: checkBinary, + BinaryExpression: checkBinary, + LogicalExpression: checkBinary, + ConditionalExpression: checkConditional, + VariableDeclarator: checkVar }; }; module.exports.schema = [ { - "type": "object", - "properties": { - "int32Hint": { - "type": "boolean" + type: "object", + properties: { + int32Hint: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/space-unary-ops.js b/lib/rules/space-unary-ops.js index cdca3ab00df..5a43fd89695 100644 --- a/lib/rules/space-unary-ops.js +++ b/lib/rules/space-unary-ops.js @@ -236,31 +236,31 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "UnaryExpression": checkForSpaces, - "UpdateExpression": checkForSpaces, - "NewExpression": checkForSpaces, - "YieldExpression": checkForSpacesAfterYield + UnaryExpression: checkForSpaces, + UpdateExpression: checkForSpaces, + NewExpression: checkForSpaces, + YieldExpression: checkForSpacesAfterYield }; }; module.exports.schema = [ { - "type": "object", - "properties": { - "words": { - "type": "boolean" + type: "object", + properties: { + words: { + type: "boolean" }, - "nonwords": { - "type": "boolean" + nonwords: { + type: "boolean" }, - "overrides": { - "type": "object", - "additionalProperties": { - "type": "boolean" + overrides: { + type: "object", + additionalProperties: { + type: "boolean" } } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/spaced-comment.js b/lib/rules/spaced-comment.js index a5597541927..44ad99786f0 100644 --- a/lib/rules/spaced-comment.js +++ b/lib/rules/spaced-comment.js @@ -235,68 +235,68 @@ module.exports = function(context) { return { - "LineComment": checkCommentForSpace, - "BlockComment": checkCommentForSpace + LineComment: checkCommentForSpace, + BlockComment: checkCommentForSpace }; }; module.exports.schema = [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": { - "type": "string" + type: "object", + properties: { + exceptions: { + type: "array", + items: { + type: "string" } }, - "markers": { - "type": "array", - "items": { - "type": "string" + markers: { + type: "array", + items: { + type: "string" } }, - "line": { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": { - "type": "string" + line: { + type: "object", + properties: { + exceptions: { + type: "array", + items: { + type: "string" } }, - "markers": { - "type": "array", - "items": { - "type": "string" + markers: { + type: "array", + items: { + type: "string" } } }, - "additionalProperties": false + additionalProperties: false }, - "block": { - "type": "object", - "properties": { - "exceptions": { - "type": "array", - "items": { - "type": "string" + block: { + type: "object", + properties: { + exceptions: { + type: "array", + items: { + type: "string" } }, - "markers": { - "type": "array", - "items": { - "type": "string" + markers: { + type: "array", + items: { + type: "string" } } }, - "additionalProperties": false + additionalProperties: false } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/strict.js b/lib/rules/strict.js index a418c28c379..97b840e4e82 100644 --- a/lib/rules/strict.js +++ b/lib/rules/strict.js @@ -163,7 +163,7 @@ module.exports = function(context) { } rule = { - "Program": function(node) { + Program: function(node) { var useStrictDirectives = getUseStrictDirectives(node.body); if (node.sourceType === "module") { @@ -179,16 +179,16 @@ module.exports = function(context) { reportAll(useStrictDirectives, messages[mode]); } }, - "FunctionDeclaration": enterFunction, - "FunctionExpression": enterFunction, - "ArrowFunctionExpression": enterFunction + FunctionDeclaration: enterFunction, + FunctionExpression: enterFunction, + ArrowFunctionExpression: enterFunction }; if (mode === "function") { lodash.assign(rule, { // Inside of class bodies are always strict mode. - "ClassBody": function() { + ClassBody: function() { classScopes.push(true); }, "ClassBody:exit": function() { @@ -206,6 +206,6 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["never", "global", "function", "safe"] + enum: ["never", "global", "function", "safe"] } ]; diff --git a/lib/rules/use-isnan.js b/lib/rules/use-isnan.js index c4579a5284a..dda676b7afb 100644 --- a/lib/rules/use-isnan.js +++ b/lib/rules/use-isnan.js @@ -12,7 +12,7 @@ module.exports = function(context) { return { - "BinaryExpression": function(node) { + BinaryExpression: function(node) { if (/^(?:[<>]|[!=]=)=?$/.test(node.operator) && (node.left.name === "NaN" || node.right.name === "NaN")) { context.report(node, "Use the isNaN function to compare with NaN."); } diff --git a/lib/rules/valid-jsdoc.js b/lib/rules/valid-jsdoc.js index 4593dc46dac..eeaaa0d86af 100644 --- a/lib/rules/valid-jsdoc.js +++ b/lib/rules/valid-jsdoc.js @@ -328,53 +328,53 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "ArrowFunctionExpression": startFunction, - "FunctionExpression": startFunction, - "FunctionDeclaration": startFunction, - "ClassExpression": startFunction, - "ClassDeclaration": startFunction, + ArrowFunctionExpression: startFunction, + FunctionExpression: startFunction, + FunctionDeclaration: startFunction, + ClassExpression: startFunction, + ClassDeclaration: startFunction, "ArrowFunctionExpression:exit": checkJSDoc, "FunctionExpression:exit": checkJSDoc, "FunctionDeclaration:exit": checkJSDoc, "ClassExpression:exit": checkJSDoc, "ClassDeclaration:exit": checkJSDoc, - "ReturnStatement": addReturn + ReturnStatement: addReturn }; }; module.exports.schema = [ { - "type": "object", - "properties": { - "prefer": { - "type": "object", - "additionalProperties": { - "type": "string" + type: "object", + properties: { + prefer: { + type: "object", + additionalProperties: { + type: "string" } }, - "preferType": { - "type": "object", - "additionalProperties": { - "type": "string" + preferType: { + type: "object", + additionalProperties: { + type: "string" } }, - "requireReturn": { - "type": "boolean" + requireReturn: { + type: "boolean" }, - "requireParamDescription": { - "type": "boolean" + requireParamDescription: { + type: "boolean" }, - "requireReturnDescription": { - "type": "boolean" + requireReturnDescription: { + type: "boolean" }, - "matchDescription": { - "type": "string" + matchDescription: { + type: "string" }, - "requireReturnType": { - "type": "boolean" + requireReturnType: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/lib/rules/valid-typeof.js b/lib/rules/valid-typeof.js index d67a46bf3dd..369c6064670 100644 --- a/lib/rules/valid-typeof.js +++ b/lib/rules/valid-typeof.js @@ -19,7 +19,7 @@ module.exports = function(context) { return { - "UnaryExpression": function(node) { + UnaryExpression: function(node) { var parent, sibling; if (node.operator === "typeof") { diff --git a/lib/rules/vars-on-top.js b/lib/rules/vars-on-top.js index c974e56937f..5a7f1ba9139 100644 --- a/lib/rules/vars-on-top.js +++ b/lib/rules/vars-on-top.js @@ -98,7 +98,7 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "VariableDeclaration": function(node) { + VariableDeclaration: function(node) { var ancestors = context.getAncestors(); var parent = ancestors.pop(); var grandParent = ancestors.pop(); diff --git a/lib/rules/wrap-iife.js b/lib/rules/wrap-iife.js index f0888172bad..287bd5eca48 100644 --- a/lib/rules/wrap-iife.js +++ b/lib/rules/wrap-iife.js @@ -29,7 +29,7 @@ module.exports = function(context) { return { - "CallExpression": function(node) { + CallExpression: function(node) { if (node.callee.type === "FunctionExpression") { var callExpressionWrapped = wrapped(node), functionExpressionWrapped = wrapped(node.callee); @@ -49,6 +49,6 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["outside", "inside", "any"] + enum: ["outside", "inside", "any"] } ]; diff --git a/lib/rules/wrap-regex.js b/lib/rules/wrap-regex.js index f2625cc2b98..34cb9950027 100644 --- a/lib/rules/wrap-regex.js +++ b/lib/rules/wrap-regex.js @@ -13,7 +13,7 @@ module.exports = function(context) { return { - "Literal": function(node) { + Literal: function(node) { var token = context.getFirstToken(node), nodeType = token.type, source, diff --git a/lib/rules/yield-star-spacing.js b/lib/rules/yield-star-spacing.js index 9a4188050f9..a34ec1d6cdc 100644 --- a/lib/rules/yield-star-spacing.js +++ b/lib/rules/yield-star-spacing.js @@ -77,24 +77,24 @@ module.exports = function(context) { } return { - "YieldExpression": checkExpression + YieldExpression: checkExpression }; }; module.exports.schema = [ { - "oneOf": [ + oneOf: [ { - "enum": ["before", "after", "both", "neither"] + enum: ["before", "after", "both", "neither"] }, { - "type": "object", - "properties": { - "before": {"type": "boolean"}, - "after": {"type": "boolean"} + type: "object", + properties: { + before: {type: "boolean"}, + after: {type: "boolean"} }, - "additionalProperties": false + additionalProperties: false } ] } diff --git a/lib/rules/yoda.js b/lib/rules/yoda.js index 8b291b4a54f..949a83d73e5 100644 --- a/lib/rules/yoda.js +++ b/lib/rules/yoda.js @@ -195,7 +195,7 @@ module.exports = function(context) { //-------------------------------------------------------------------------- return { - "BinaryExpression": always ? function(node) { + BinaryExpression: always ? function(node) { // Comparisons must always be yoda-style: if ("blue" === color) if ( @@ -228,18 +228,18 @@ module.exports = function(context) { module.exports.schema = [ { - "enum": ["always", "never"] + enum: ["always", "never"] }, { - "type": "object", - "properties": { - "exceptRange": { - "type": "boolean" + type: "object", + properties: { + exceptRange: { + type: "boolean" }, - "onlyEquality": { - "type": "boolean" + onlyEquality: { + type: "boolean" } }, - "additionalProperties": false + additionalProperties: false } ]; diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml index aa1da1846d3..00dc5204511 100644 --- a/packages/eslint-config-eslint/default.yml +++ b/packages/eslint-config-eslint/default.yml @@ -80,6 +80,7 @@ rules: no-with: "error" one-var-declaration-per-line: "error" quotes: ["error", "double"] + quote-props: ["error", "as-needed"] radix: "error" require-jsdoc: "error" semi: "error" diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index e203af6afe6..5c6763230dc 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -191,7 +191,7 @@ describe("CLIEngine", function() { useEslintrc: false, fix: true, rules: { - "semi": 2 + semi: 2 }, ignore: false, cwd: getFixturePath() @@ -200,17 +200,17 @@ describe("CLIEngine", function() { var report = engine.executeOnText("var bar = foo", "passing.js"); assert.deepEqual(report, { - "results": [ + results: [ { - "filePath": getFixturePath("passing.js"), - "messages": [], - "errorCount": 0, - "warningCount": 0, - "output": "var bar = foo;" + filePath: getFixturePath("passing.js"), + messages: [], + errorCount: 0, + warningCount: 0, + output: "var bar = foo;" } ], - "errorCount": 0, - "warningCount": 0 + errorCount: 0, + warningCount: 0 }); }); @@ -229,26 +229,26 @@ describe("CLIEngine", function() { var report = engine.executeOnText("var bar = foo", "passing.js"); assert.deepEqual(report, { - "results": [ + results: [ { - "filePath": getFixturePath("passing.js"), - "messages": [ + filePath: getFixturePath("passing.js"), + messages: [ { - "ruleId": "no-undef", - "severity": 2, - "message": "'foo' is not defined.", - "line": 1, - "column": 11, - "nodeType": "Identifier", - "source": "var bar = foo" + ruleId: "no-undef", + severity: 2, + message: "'foo' is not defined.", + line: 1, + column: 11, + nodeType: "Identifier", + source: "var bar = foo" } ], - "errorCount": 1, - "warningCount": 0 + errorCount: 1, + warningCount: 0 } ], - "errorCount": 1, - "warningCount": 0 + errorCount: 1, + warningCount: 0 }); }); @@ -902,33 +902,33 @@ describe("CLIEngine", function() { report.results.forEach(convertCRLF); assert.deepEqual(report, { - "results": [ + results: [ { - "filePath": fs.realpathSync(path.resolve(fixtureDir, "fixmode/ok.js")), - "messages": [], - "errorCount": 0, - "warningCount": 0 + filePath: fs.realpathSync(path.resolve(fixtureDir, "fixmode/ok.js")), + messages: [], + errorCount: 0, + warningCount: 0 }, { - "filePath": fs.realpathSync(path.resolve(fixtureDir, "fixmode/quotes-semi-eqeqeq.js")), - "messages": [ + filePath: fs.realpathSync(path.resolve(fixtureDir, "fixmode/quotes-semi-eqeqeq.js")), + messages: [ { - "column": 9, - "line": 2, - "message": "Expected '===' and instead saw '=='.", - "nodeType": "BinaryExpression", - "ruleId": "eqeqeq", - "severity": 2, - "source": "if (msg == \"hi\") {" + column: 9, + line: 2, + message: "Expected '===' and instead saw '=='.", + nodeType: "BinaryExpression", + ruleId: "eqeqeq", + severity: 2, + source: "if (msg == \"hi\") {" } ], - "errorCount": 1, - "warningCount": 0, - "output": "var msg = \"hi\";\nif (msg == \"hi\") {\n\n}\n" + errorCount: 1, + warningCount: 0, + output: "var msg = \"hi\";\nif (msg == \"hi\") {\n\n}\n" }, { - "filePath": fs.realpathSync(path.resolve(fixtureDir, "fixmode/quotes.js")), - "messages": [ + filePath: fs.realpathSync(path.resolve(fixtureDir, "fixmode/quotes.js")), + messages: [ { column: 18, line: 1, @@ -939,13 +939,13 @@ describe("CLIEngine", function() { source: "var msg = \"hi\" + foo;" } ], - "errorCount": 1, - "warningCount": 0, - "output": "var msg = \"hi\" + foo;\n" + errorCount: 1, + warningCount: 0, + output: "var msg = \"hi\" + foo;\n" } ], - "errorCount": 2, - "warningCount": 0 + errorCount: 2, + warningCount: 0 }); }); @@ -2077,8 +2077,8 @@ describe("CLIEngine", function() { "eol-last": 0, "no-alert": 1, "no-trailing-spaces": 0, - "strict": 0, - "quotes": 0 + strict: 0, + quotes: 0 } }; @@ -2104,8 +2104,8 @@ describe("CLIEngine", function() { "eol-last": 0, "no-alert": 1, "no-trailing-spaces": 0, - "strict": 0, - "quotes": 0 + strict: 0, + quotes: 0 } }; diff --git a/tests/lib/code-path-analysis/code-path-analyzer.js b/tests/lib/code-path-analysis/code-path-analyzer.js index 824b0453838..773bdbbc9c0 100644 --- a/tests/lib/code-path-analysis/code-path-analyzer.js +++ b/tests/lib/code-path-analysis/code-path-analyzer.js @@ -69,7 +69,7 @@ describe("CodePathAnalyzer", function() { actual = []; eslint.defineRule("test", function() { return { - "onCodePathStart": function(codePath) { + onCodePathStart: function(codePath) { actual.push(codePath); } }; @@ -149,14 +149,14 @@ describe("CodePathAnalyzer", function() { var codePath = null; return { - "onCodePathStart": function(cp) { + onCodePathStart: function(cp) { codePath = cp; }, - "ReturnStatement": function() { + ReturnStatement: function() { assert(codePath.currentSegments.length === 1); assert(codePath.currentSegments[0] instanceof CodePathSegment); }, - "ThrowStatement": function() { + ThrowStatement: function() { assert(codePath.currentSegments.length === 1); assert(codePath.currentSegments[0] instanceof CodePathSegment); } @@ -176,7 +176,7 @@ describe("CodePathAnalyzer", function() { actual = []; eslint.defineRule("test", function() { return { - "onCodePathSegmentStart": function(segment) { + onCodePathSegmentStart: function(segment) { actual.push(segment); } }; @@ -265,7 +265,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathStart": function(cp, node) { + onCodePathStart: function(cp, node) { count += 1; lastCodePathNodeType = node.type; @@ -280,16 +280,16 @@ describe("CodePathAnalyzer", function() { assert(node.type === "ArrowFunctionExpression"); } }, - "Program": function() { + Program: function() { assert(lastCodePathNodeType === "Program"); }, - "FunctionDeclaration": function() { + FunctionDeclaration: function() { assert(lastCodePathNodeType === "FunctionDeclaration"); }, - "FunctionExpression": function() { + FunctionExpression: function() { assert(lastCodePathNodeType === "FunctionExpression"); }, - "ArrowFunctionExpression": function() { + ArrowFunctionExpression: function() { assert(lastCodePathNodeType === "ArrowFunctionExpression"); } }; @@ -310,7 +310,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathEnd": function(cp, node) { + onCodePathEnd: function(cp, node) { count += 1; assert(cp instanceof CodePath); @@ -355,7 +355,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentStart": function(segment, node) { + onCodePathSegmentStart: function(segment, node) { count += 1; lastCodePathNodeType = node.type; @@ -370,16 +370,16 @@ describe("CodePathAnalyzer", function() { assert(node.type === "ArrowFunctionExpression"); } }, - "Program": function() { + Program: function() { assert(lastCodePathNodeType === "Program"); }, - "FunctionDeclaration": function() { + FunctionDeclaration: function() { assert(lastCodePathNodeType === "FunctionDeclaration"); }, - "FunctionExpression": function() { + FunctionExpression: function() { assert(lastCodePathNodeType === "FunctionExpression"); }, - "ArrowFunctionExpression": function() { + ArrowFunctionExpression: function() { assert(lastCodePathNodeType === "ArrowFunctionExpression"); } }; @@ -400,7 +400,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentEnd": function(cp, node) { + onCodePathSegmentEnd: function(cp, node) { count += 1; assert(cp instanceof CodePathSegment); @@ -444,7 +444,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentLoop": function(fromSegment, toSegment, node) { + onCodePathSegmentLoop: function(fromSegment, toSegment, node) { count += 1; assert(fromSegment instanceof CodePathSegment); assert(toSegment instanceof CodePathSegment); @@ -465,7 +465,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentLoop": function(fromSegment, toSegment, node) { + onCodePathSegmentLoop: function(fromSegment, toSegment, node) { count += 1; assert(fromSegment instanceof CodePathSegment); assert(toSegment instanceof CodePathSegment); @@ -486,7 +486,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentLoop": function(fromSegment, toSegment, node) { + onCodePathSegmentLoop: function(fromSegment, toSegment, node) { count += 1; assert(fromSegment instanceof CodePathSegment); assert(toSegment instanceof CodePathSegment); @@ -514,7 +514,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentLoop": function(fromSegment, toSegment, node) { + onCodePathSegmentLoop: function(fromSegment, toSegment, node) { count += 1; assert(fromSegment instanceof CodePathSegment); assert(toSegment instanceof CodePathSegment); @@ -542,7 +542,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathSegmentLoop": function(fromSegment, toSegment, node) { + onCodePathSegmentLoop: function(fromSegment, toSegment, node) { count += 1; assert(fromSegment instanceof CodePathSegment); assert(toSegment instanceof CodePathSegment); @@ -580,7 +580,7 @@ describe("CodePathAnalyzer", function() { eslint.defineRule("test", function() { return { - "onCodePathEnd": function(codePath) { + onCodePathEnd: function(codePath) { actual.push(debug.makeDotArrows(codePath)); } }; diff --git a/tests/lib/code-path-analysis/code-path.js b/tests/lib/code-path-analysis/code-path.js index 9cd59bb0f99..571b25e21dc 100644 --- a/tests/lib/code-path-analysis/code-path.js +++ b/tests/lib/code-path-analysis/code-path.js @@ -28,7 +28,7 @@ function parseCodePaths(code) { eslint.reset(); eslint.defineRule("test", function() { return { - "onCodePathStart": function(codePath) { + onCodePathStart: function(codePath) { retv.push(codePath); } }; diff --git a/tests/lib/config.js b/tests/lib/config.js index 65bd704b759..ea7092ead11 100644 --- a/tests/lib/config.js +++ b/tests/lib/config.js @@ -704,7 +704,7 @@ describe("Config", function() { configHelper = new Config({ useEslintrc: false, configFile: configPath }), expected = { rules: { "no-empty": 1, "comma-dangle": 2, "no-console": 2 }, - env: { "browser": false, "node": true, "es6": true } + env: { browser: false, node: true, es6: true } }, actual = configHelper.getConfig(configPath); @@ -803,7 +803,7 @@ describe("Config", function() { globals: {}, parser: void 0, rules: { - "quotes": [2, "double"] + quotes: [2, "double"] } }; diff --git a/tests/lib/config/config-ops.js b/tests/lib/config/config-ops.js index d979867223d..2e52372b82b 100644 --- a/tests/lib/config/config-ops.js +++ b/tests/lib/config/config-ops.js @@ -287,16 +287,16 @@ describe("ConfigOps", function() { it("should combine configs and override rules options completely", function() { var config = [ - { rules: { "no-mixed-requires": [1, { "event": ["evt", "e"] }] } }, - { rules: { "no-mixed-requires": [1, { "err": ["error", "e"] }] } } + { rules: { "no-mixed-requires": [1, { event: ["evt", "e"] }] } }, + { rules: { "no-mixed-requires": [1, { err: ["error", "e"] }] } } ]; var result = ConfigOps.merge(config[0], config[1]); assert.isArray(result.rules["no-mixed-requires"]); - assert.deepEqual(result.rules["no-mixed-requires"][1], {"err": ["error", "e"]}); - assert.deepEqual(config[0], { rules: { "no-mixed-requires": [1, {"event": ["evt", "e"]}] }}); - assert.deepEqual(config[1], { rules: { "no-mixed-requires": [1, {"err": ["error", "e"]}] }}); + assert.deepEqual(result.rules["no-mixed-requires"][1], {err: ["error", "e"]}); + assert.deepEqual(config[0], { rules: { "no-mixed-requires": [1, {event: ["evt", "e"]}] }}); + assert.deepEqual(config[1], { rules: { "no-mixed-requires": [1, {err: ["error", "e"]}] }}); }); it("should combine configs and override rules options without array or object", function() { @@ -336,11 +336,11 @@ describe("ConfigOps", function() { var config = [ { rules: { - "no-mixed-requires": [1, { "event": ["evt", "e"] }], + "no-mixed-requires": [1, { event: ["evt", "e"] }], "valid-jsdoc": 1, - "semi": 1, - "quotes": [2, { "exception": ["hi"] }], - "smile": [1, ["hi", "bye"]] + semi: 1, + quotes: [2, { exception: ["hi"] }], + smile: [1, ["hi", "bye"]] }, parserOptions: { ecmaFeatures: { blockBindings: true } @@ -350,10 +350,10 @@ describe("ConfigOps", function() { }, { rules: { - "no-mixed-requires": [1, { "err": ["error", "e"] }], + "no-mixed-requires": [1, { err: ["error", "e"] }], "valid-jsdoc": 2, - "test": 1, - "smile": [1, ["xxx", "yyy"]] + test: 1, + smile: [1, ["xxx", "yyy"]] }, parserOptions: { ecmaFeatures: { forOf: true } @@ -367,46 +367,46 @@ describe("ConfigOps", function() { assert.deepEqual(result, { parserOptions: { - "ecmaFeatures": { - "blockBindings": true, - "forOf": true + ecmaFeatures: { + blockBindings: true, + forOf: true } }, - "env": { - "browser": false + env: { + browser: false }, - "globals": { - "foo": true + globals: { + foo: true }, - "rules": { + rules: { "no-mixed-requires": [1, { - "err": [ + err: [ "error", "e" ] } ], - "quotes": [2, + quotes: [2, { - "exception": [ + exception: [ "hi" ] } ], - "semi": 1, - "smile": [1, ["xxx", "yyy"]], - "test": 1, + semi: 1, + smile: [1, ["xxx", "yyy"]], + test: 1, "valid-jsdoc": 2 } }); assert.deepEqual(config[0], { rules: { - "no-mixed-requires": [1, { "event": ["evt", "e"] }], + "no-mixed-requires": [1, { event: ["evt", "e"] }], "valid-jsdoc": 1, - "semi": 1, - "quotes": [2, { "exception": ["hi"] }], - "smile": [1, ["hi", "bye"]] + semi: 1, + quotes: [2, { exception: ["hi"] }], + smile: [1, ["hi", "bye"]] }, parserOptions: { ecmaFeatures: { blockBindings: true } @@ -416,10 +416,10 @@ describe("ConfigOps", function() { }); assert.deepEqual(config[1], { rules: { - "no-mixed-requires": [1, { "err": ["error", "e"] }], + "no-mixed-requires": [1, { err: ["error", "e"] }], "valid-jsdoc": 2, - "test": 1, - "smile": [1, ["xxx", "yyy"]] + test: 1, + smile: [1, ["xxx", "yyy"]] }, parserOptions: { ecmaFeatures: { forOf: true } diff --git a/tests/lib/config/config-validator.js b/tests/lib/config/config-validator.js index 548391312b3..70ec95e4764 100644 --- a/tests/lib/config/config-validator.js +++ b/tests/lib/config/config-validator.js @@ -25,7 +25,7 @@ var assert = require("chai").assert, */ function mockRule(context) { return { - "Program": function(node) { + Program: function(node) { context.report(node, "Expected a validation error."); } }; @@ -33,7 +33,7 @@ function mockRule(context) { mockRule.schema = [ { - "enum": ["first", "second"] + enum: ["first", "second"] } ]; @@ -45,14 +45,14 @@ mockRule.schema = [ */ function mockObjectRule(context) { return { - "Program": function(node) { + Program: function(node) { context.report(node, "Expected a validation error."); } }; } mockObjectRule.schema = { - "enum": ["first", "second"] + enum: ["first", "second"] }; /** @@ -63,7 +63,7 @@ mockObjectRule.schema = { */ function mockNoOptionsRule(context) { return { - "Program": function(node) { + Program: function(node) { context.report(node, "Expected a validation error."); } }; @@ -168,13 +168,13 @@ describe("Validator", function() { }); it("should catch invalid environments", function() { - var fn = validator.validate.bind(null, { env: {"browser": true, "invalid": true } }); + var fn = validator.validate.bind(null, { env: {browser: true, invalid: true } }); assert.throws(fn, "Environment key \"invalid\" is unknown\n"); }); it("should catch disabled invalid environments", function() { - var fn = validator.validate.bind(null, { env: {"browser": true, "invalid": false } }); + var fn = validator.validate.bind(null, { env: {browser: true, invalid: false } }); assert.throws(fn, "Environment key \"invalid\" is unknown\n"); }); @@ -196,7 +196,7 @@ describe("Validator", function() { it("should not modify object schema", function() { eslint.defineRule("mock-object-rule", mockObjectRule); assert.deepEqual(validator.getRuleOptionsSchema("mock-object-rule"), { - "enum": ["first", "second"] + enum: ["first", "second"] }); }); diff --git a/tests/lib/eslint.js b/tests/lib/eslint.js index 55f092bcf92..64bbd5391f4 100644 --- a/tests/lib/eslint.js +++ b/tests/lib/eslint.js @@ -865,7 +865,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{parameter name}}", { "parameter name": "yay!" }); @@ -884,7 +884,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{code}}"); } }; @@ -901,7 +901,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{parameter-name}}", { "parameter-name": "yay!" }); @@ -920,7 +920,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{parameter}}", {}); } }; @@ -937,7 +937,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{parameter}}", {}); } }; @@ -955,7 +955,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{ parameter}}", { parameter: "yay!" }); @@ -974,7 +974,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{parameter }}", { parameter: "yay!" }); @@ -993,7 +993,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{ parameter name }}", { "parameter name": "yay!" }); @@ -1012,7 +1012,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule("test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message {{ parameter-name }}", { "parameter-name": "yay!" }); @@ -1086,7 +1086,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule(code, function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, context.settings.info); } }; @@ -1106,7 +1106,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule(code, function(context) { return { - "Literal": function(node) { + Literal: function(node) { if (Object.getOwnPropertyNames(context.settings).length !== 0) { context.report(node, "Settings should be empty"); } @@ -1604,7 +1604,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule(code, function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message"); } }; @@ -1634,7 +1634,7 @@ describe("eslint", function() { config.rules[item] = 1; newRules[item] = function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, "message"); } }; @@ -1663,7 +1663,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule(code, function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, context.getFilename()); } }; @@ -1682,7 +1682,7 @@ describe("eslint", function() { eslint.reset(); eslint.defineRule(code, function(context) { return { - "Literal": function(node) { + Literal: function(node) { context.report(node, context.getFilename()); } }; @@ -1713,7 +1713,7 @@ describe("eslint", function() { }); it("rules should not change initial config", function() { - var config = { rules: {"strict": 2} }; + var config = { rules: {strict: 2} }; var codeA = "/*eslint strict: 0*/ function bar() { return 2; }"; var codeB = "function foo() { return 1; }"; @@ -1727,7 +1727,7 @@ describe("eslint", function() { }); it("rules should not change initial config", function() { - var config = { rules: {"quotes": [2, "double"]} }; + var config = { rules: {quotes: [2, "double"]} }; var codeA = "/*eslint quotes: 0*/ function bar() { return '2'; }"; var codeB = "function foo() { return '1'; }"; @@ -1741,7 +1741,7 @@ describe("eslint", function() { }); it("rules should not change initial config", function() { - var config = { rules: {"quotes": [2, "double"]} }; + var config = { rules: {quotes: [2, "double"]} }; var codeA = "/*eslint quotes: [0, \"single\"]*/ function bar() { return '2'; }"; var codeB = "function foo() { return '1'; }"; @@ -1755,7 +1755,7 @@ describe("eslint", function() { }); it("rules should not change initial config", function() { - var config = { rules: {"no-unused-vars": [2, {"vars": "all"}]} }; + var config = { rules: {"no-unused-vars": [2, {vars: "all"}]} }; var codeA = "/*eslint no-unused-vars: [0, {\"vars\": \"local\"}]*/ var a = 44;"; var codeB = "var b = 55;"; @@ -1828,7 +1828,7 @@ describe("eslint", function() { eslint.defineRule("test-plugin/test-rule", function(context) { return { - "Literal": function(node) { + Literal: function(node) { if (node.value === "trigger violation") { context.report(node, "Reporting violation."); } @@ -2052,8 +2052,8 @@ describe("eslint", function() { var config = { rules: { "no-alert": 1, - "quotes": [1, "double"], - "semi": [1, "always"], + quotes: [1, "double"], + semi: [1, "always"], "no-console": 1 } }; @@ -2111,7 +2111,7 @@ describe("eslint", function() { var config = { rules: { "no-alert": 1, - "quotes": [1, "single"], + quotes: [1, "single"], "no-console": 1 } }; @@ -2149,8 +2149,8 @@ describe("eslint", function() { ].join("\n"); var config = { rules: { - "semi": [1, "never"], - "quotes": [1, "single"], + semi: [1, "never"], + quotes: [1, "single"], "no-alert": 1, "no-console": 1 } @@ -2387,7 +2387,7 @@ describe("eslint", function() { var code = "/*eslint quotes:[2, \"double\"]*/ alert('test');"; it("should report a violation", function() { - var config = { rules: { "quotes": [2, "single"] } }; + var config = { rules: { quotes: [2, "single"] } }; var messages = eslint.verify(code, config, filename); @@ -2402,7 +2402,7 @@ describe("eslint", function() { var code = "/*eslint quotes:[\"error\", \"double\"]*/ alert('test');"; it("should report a violation", function() { - var config = { rules: { "quotes": [2, "single"] } }; + var config = { rules: { quotes: [2, "single"] } }; var messages = eslint.verify(code, config, filename); @@ -2785,7 +2785,7 @@ describe("eslint", function() { eslint.defineRules({test: function(context) { return { - "Program": function() { + Program: function() { var scope = context.getScope(); var comments = context.getAllComments(); @@ -2875,7 +2875,7 @@ describe("eslint", function() { eslint.defineRules({test: function(context) { return { - "Program": function() { + Program: function() { var scope = context.getScope(); var comments = context.getAllComments(); @@ -3017,7 +3017,7 @@ describe("eslint", function() { it("should report warnings in order by line and column when called", function() { var code = "foo()\n alert('test')"; - var config = { rules: { "no-mixed-spaces-and-tabs": 1, "eol-last": 1, "semi": [1, "always"] } }; + var config = { rules: { "no-mixed-spaces-and-tabs": 1, "eol-last": 1, semi: [1, "always"] } }; var messages = eslint.verify(code, config, filename); @@ -3216,7 +3216,7 @@ describe("eslint", function() { eslint.defineRules({test: function(context) { return { - "Program": function() { + Program: function() { var scope = context.getScope(); var comments = context.getAllComments(); @@ -3281,7 +3281,7 @@ describe("eslint", function() { eslint.defineRules({test: function(context) { return { - "Program": function() { + Program: function() { scope = context.getScope(); ok = true; } @@ -3393,53 +3393,53 @@ describe("eslint", function() { function verify(code, type, expectedNamesList) { eslint.defineRules({test: function(context) { var 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 + 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) { diff --git a/tests/lib/rules/array-bracket-spacing.js b/tests/lib/rules/array-bracket-spacing.js index 017613d27f9..d12ecbd1822 100644 --- a/tests/lib/rules/array-bracket-spacing.js +++ b/tests/lib/rules/array-bracket-spacing.js @@ -42,15 +42,15 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var foo = [ function(){} ];", options: ["always", {objectsInArrays: false}] }, // always - arraysInArrays - { code: "var arr = [[ 1, 2 ], 2, 3, 4 ];", options: ["always", {"arraysInArrays": false}] }, - { code: "var arr = [[ 1, 2 ], [[[ 1 ]]], 3, 4 ];", options: ["always", {"arraysInArrays": false}] }, - { code: "var foo = [ arr[i], arr[j] ];", options: ["always", {"arraysInArrays": false}] }, + { code: "var arr = [[ 1, 2 ], 2, 3, 4 ];", options: ["always", {arraysInArrays: false}] }, + { code: "var arr = [[ 1, 2 ], [[[ 1 ]]], 3, 4 ];", options: ["always", {arraysInArrays: false}] }, + { code: "var foo = [ arr[i], arr[j] ];", options: ["always", {arraysInArrays: false}] }, // always - arraysInArrays, objectsInArrays - { code: "var arr = [[ 1, 2 ], 2, 3, { 'foo': 'bar' }];", options: ["always", {"arraysInArrays": false, objectsInArrays: false}] }, + { code: "var arr = [[ 1, 2 ], 2, 3, { 'foo': 'bar' }];", options: ["always", {arraysInArrays: false, objectsInArrays: false}] }, // always - arraysInArrays, objectsInArrays, singleValue - { code: "var arr = [[ 1, 2 ], [2], 3, { 'foo': 'bar' }];", options: ["always", {"arraysInArrays": false, objectsInArrays: false, singleValue: false}] }, + { code: "var arr = [[ 1, 2 ], [2], 3, { 'foo': 'bar' }];", options: ["always", {arraysInArrays: false, objectsInArrays: false, singleValue: false}] }, // always { code: "obj[ foo ]", options: ["always"] }, @@ -81,8 +81,8 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var [ ,x, ] = z", parserOptions: { ecmaVersion: 6 }, options: ["always"] }, { code: "var [\nx, ...y\n] = z", parserOptions: { ecmaVersion: 6 }, options: ["always"] }, { code: "var [\nx, ...y ] = z", parserOptions: { ecmaVersion: 6 }, options: ["always"] }, - { code: "var [[ x, y ], z ] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["always", {"arraysInArrays": false}] }, - { code: "var [ x, [ y, z ]] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["always", {"arraysInArrays": false}] }, + { code: "var [[ x, y ], z ] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["always", {arraysInArrays: false}] }, + { code: "var [ x, [ y, z ]] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["always", {arraysInArrays: false}] }, { code: "[{ x, y }, z ] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["always", {objectsInArrays: false}] }, { code: "[ x, { y, z }] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["always", {objectsInArrays: false}] }, @@ -115,8 +115,8 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var [,x,] = z", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, { code: "var [\nx, ...y\n] = z", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, { code: "var [\nx, ...y] = z", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, - { code: "var [ [x, y], z] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["never", {"arraysInArrays": true}] }, - { code: "var [x, [y, z] ] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["never", {"arraysInArrays": true}] }, + { code: "var [ [x, y], z] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["never", {arraysInArrays: true}] }, + { code: "var [x, [y, z] ] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["never", {arraysInArrays: true}] }, { code: "[ { x, y }, z] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["never", {objectsInArrays: true}] }, { code: "[x, { y, z } ] = arr;", parserOptions: { ecmaVersion: 6 }, options: ["never", {objectsInArrays: true}] }, @@ -139,15 +139,15 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var foo = [];", options: ["never", {objectsInArrays: true}] }, // never - arraysInArrays - { code: "var arr = [ [1, 2], 2, 3, 4];", options: ["never", {"arraysInArrays": true}] }, - { code: "var foo = [arr[i], arr[j]];", options: ["never", {"arraysInArrays": true}] }, - { code: "var foo = [];", options: ["never", {"arraysInArrays": true}] }, + { code: "var arr = [ [1, 2], 2, 3, 4];", options: ["never", {arraysInArrays: true}] }, + { code: "var foo = [arr[i], arr[j]];", options: ["never", {arraysInArrays: true}] }, + { code: "var foo = [];", options: ["never", {arraysInArrays: true}] }, // never - arraysInArrays, singleValue - { code: "var arr = [ [1, 2], [ [ [ 1 ] ] ], 3, 4];", options: ["never", {"arraysInArrays": true, singleValue: true}] }, + { code: "var arr = [ [1, 2], [ [ [ 1 ] ] ], 3, 4];", options: ["never", {arraysInArrays: true, singleValue: true}] }, // never - arraysInArrays, objectsInArrays - { code: "var arr = [ [1, 2], 2, 3, {'foo': 'bar'} ];", options: ["never", {"arraysInArrays": true, objectsInArrays: true}] }, + { code: "var arr = [ [1, 2], 2, 3, {'foo': 'bar'} ];", options: ["never", {arraysInArrays: true, objectsInArrays: true}] }, // should not warn { code: "var foo = {};", options: ["never"] }, @@ -294,7 +294,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [ [ 1, 2 ], 2, 3, 4 ];", output: "var arr = [[ 1, 2 ], 2, 3, 4 ];", - options: ["always", {"arraysInArrays": false}], + options: ["always", {arraysInArrays: false}], errors: [ { message: "There should be no space after '['", @@ -307,7 +307,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [ 1, 2, 2, [ 3, 4 ] ];", output: "var arr = [ 1, 2, 2, [ 3, 4 ]];", - options: ["always", {"arraysInArrays": false}], + options: ["always", {arraysInArrays: false}], errors: [ { message: "There should be no space before ']'", @@ -320,7 +320,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [[ 1, 2 ], 2, [ 3, 4 ] ];", output: "var arr = [[ 1, 2 ], 2, [ 3, 4 ]];", - options: ["always", {"arraysInArrays": false}], + options: ["always", {arraysInArrays: false}], errors: [ { message: "There should be no space before ']'", @@ -333,7 +333,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [ [ 1, 2 ], 2, [ 3, 4 ]];", output: "var arr = [[ 1, 2 ], 2, [ 3, 4 ]];", - options: ["always", {"arraysInArrays": false}], + options: ["always", {arraysInArrays: false}], errors: [ { message: "There should be no space after '['", @@ -346,7 +346,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];", output: "var arr = [[ 1, 2 ], 2, [ 3, 4 ]];", - options: ["always", {"arraysInArrays": false}], + options: ["always", {arraysInArrays: false}], errors: [ { message: "There should be no space after '['", @@ -457,7 +457,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var [ [ x, y ], z ] = arr;", output: "var [[ x, y ], z ] = arr;", - options: ["always", {"arraysInArrays": false}], + options: ["always", {arraysInArrays: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "There should be no space after '['", @@ -469,7 +469,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "[ { x, y }, z ] = arr;", output: "[{ x, y }, z ] = arr;", - options: ["always", {"objectsInArrays": false}], + options: ["always", {objectsInArrays: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "There should be no space after '['", @@ -481,7 +481,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "[ x, { y, z } ] = arr;", output: "[ x, { y, z }] = arr;", - options: ["always", {"objectsInArrays": false}], + options: ["always", {objectsInArrays: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "There should be no space before ']'", @@ -495,7 +495,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [[1, 2], 2, [3, 4]];", output: "var arr = [ [1, 2], 2, [3, 4] ];", - options: ["never", {"arraysInArrays": true}], + options: ["never", {arraysInArrays: true}], errors: [ { message: "A space is required after '['", @@ -514,7 +514,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [ ];", output: "var arr = [];", - options: ["never", {"arraysInArrays": true}], + options: ["never", {arraysInArrays: true}], errors: [ { message: "There should be no space after '['", @@ -529,7 +529,7 @@ ruleTester.run("array-bracket-spacing", rule, { { code: "var arr = [ ];", output: "var arr = [];", - options: ["never", {"objectsInArrays": true}], + options: ["never", {objectsInArrays: true}], errors: [ { message: "There should be no space after '['", diff --git a/tests/lib/rules/complexity.js b/tests/lib/rules/complexity.js index a2af7246fb7..c19c408f5fa 100644 --- a/tests/lib/rules/complexity.js +++ b/tests/lib/rules/complexity.js @@ -60,7 +60,7 @@ ruleTester.run("complexity", rule, { { code: "var a = (x) => {do {'foo';} while (true)}", options: [2], parserOptions: { ecmaVersion: 6 } }, // object property options - { code: "function b(x) {}", options: [{ "max": 1 }] } + { code: "function b(x) {}", options: [{ max: 1 }] } ], invalid: [ { code: "function a(x) {}", options: [0], errors: [{ message: "Function 'a' has a complexity of 1."}] }, @@ -93,6 +93,6 @@ ruleTester.run("complexity", rule, { }, // object property options - { code: "function a(x) {}", options: [{ "max": 0 }], errors: [{ message: "Function 'a' has a complexity of 1."}] } + { code: "function a(x) {}", options: [{ max: 0 }], errors: [{ message: "Function 'a' has a complexity of 1."}] } ] }); diff --git a/tests/lib/rules/generator-star-spacing.js b/tests/lib/rules/generator-star-spacing.js index c76b6bd3af9..d27e2c6067b 100644 --- a/tests/lib/rules/generator-star-spacing.js +++ b/tests/lib/rules/generator-star-spacing.js @@ -270,204 +270,204 @@ ruleTester.run("generator-star-spacing", rule, { // {"before": true, "after": false} { code: "function foo(){}", - options: [{"before": true, "after": false}] + options: [{before: true, after: false}] }, { code: "function *foo(){}", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "function *foo(arg1, arg2){}", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function *foo(){};", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function *(){};", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = { *foo(){} };", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = {*foo(){} };", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { *foo(){} }", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo {*foo(){} }", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { static *foo(){} }", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 } }, // {"before": false, "after": true} { code: "function foo(){}", - options: [{"before": false, "after": true}] + options: [{before: false, after: true}] }, { code: "function* foo(){}", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "function* foo(arg1, arg2){}", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function* foo(){};", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function* (){};", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = {* foo(){} };", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = { * foo(){} };", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo {* foo(){} }", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { * foo(){} }", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { static* foo(){} }", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 } }, // {"before": true, "after": true} { code: "function foo(){}", - options: [{"before": true, "after": true}] + options: [{before: true, after: true}] }, { code: "function * foo(){}", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "function * foo(arg1, arg2){}", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function * foo(){};", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function * (){};", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = { * foo(){} };", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = {* foo(){} };", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { * foo(){} }", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo {* foo(){} }", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { static * foo(){} }", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 } }, // {"before": false, "after": false} { code: "function foo(){}", - options: [{"before": false, "after": false}] + options: [{before: false, after: false}] }, { code: "function*foo(){}", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "function*foo(arg1, arg2){}", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function*foo(){};", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = function*(){};", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = {*foo(){} };", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "var foo = { *foo(){} };", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo {*foo(){} }", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { *foo(){} }", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } }, { code: "class Foo { static*foo(){} }", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 } } @@ -879,7 +879,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function*foo(){}", output: "function *foo(){}", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -889,7 +889,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function* foo(arg1, arg2){}", output: "function *foo(arg1, arg2){}", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -902,7 +902,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function*foo(){};", output: "var foo = function *foo(){};", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -912,7 +912,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function* (){};", output: "var foo = function *(){};", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -925,7 +925,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = {* foo(){} };", output: "var foo = {*foo(){} };", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space after *.", @@ -935,7 +935,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo {* foo(){} }", output: "class Foo {*foo(){} }", - options: [{"before": true, "after": false}], + options: [{before: true, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space after *.", @@ -947,7 +947,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function*foo(){}", output: "function* foo(){}", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space after *.", @@ -957,7 +957,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function *foo(arg1, arg2){}", output: "function* foo(arg1, arg2){}", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -970,7 +970,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function *foo(){};", output: "var foo = function* foo(){};", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -983,7 +983,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function *(){};", output: "var foo = function* (){};", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -996,7 +996,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = { *foo(){} };", output: "var foo = { * foo(){} };", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space after *.", @@ -1006,7 +1006,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo { *foo(){} }", output: "class Foo { * foo(){} }", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space after *.", @@ -1016,7 +1016,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo { static *foo(){} }", output: "class Foo { static* foo(){} }", - options: [{"before": false, "after": true}], + options: [{before: false, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -1031,7 +1031,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function*foo(){}", output: "function * foo(){}", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -1044,7 +1044,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function*foo(arg1, arg2){}", output: "function * foo(arg1, arg2){}", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -1057,7 +1057,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function*foo(){};", output: "var foo = function * foo(){};", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -1070,7 +1070,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function*(){};", output: "var foo = function * (){};", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -1083,7 +1083,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = {*foo(){} };", output: "var foo = {* foo(){} };", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space after *.", @@ -1093,7 +1093,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo {*foo(){} }", output: "class Foo {* foo(){} }", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space after *.", @@ -1103,7 +1103,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo { static*foo(){} }", output: "class Foo { static * foo(){} }", - options: [{"before": true, "after": true}], + options: [{before: true, after: true}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing space before *.", @@ -1118,7 +1118,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function * foo(){}", output: "function*foo(){}", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -1131,7 +1131,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "function * foo(arg1, arg2){}", output: "function*foo(arg1, arg2){}", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -1144,7 +1144,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function * foo(){};", output: "var foo = function*foo(){};", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -1157,7 +1157,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = function * (){};", output: "var foo = function*(){};", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", @@ -1170,7 +1170,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "var foo = { * foo(){} };", output: "var foo = { *foo(){} };", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space after *.", @@ -1180,7 +1180,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo { * foo(){} }", output: "class Foo { *foo(){} }", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space after *.", @@ -1190,7 +1190,7 @@ ruleTester.run("generator-star-spacing", rule, { { code: "class Foo { static * foo(){} }", output: "class Foo { static*foo(){} }", - options: [{"before": false, "after": false}], + options: [{before: false, after: false}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unexpected space before *.", diff --git a/tests/lib/rules/id-length.js b/tests/lib/rules/id-length.js index 0836f77223d..e2cb3a8b898 100644 --- a/tests/lib/rules/id-length.js +++ b/tests/lib/rules/id-length.js @@ -35,10 +35,10 @@ ruleTester.run("id-length", rule, { "var xyz = new ΣΣ();", "unrelatedExpressionThatNeedsToBeIgnored();", "var obj = { 'a': 1, bc: 2 }; obj.tk = obj.a;", - { code: "var x = Foo(42)", options: [{ "min": 1 }] }, - { code: "var x = Foo(42)", options: [{ "min": 0 }] }, - { code: "foo.$x = Foo(42)", options: [{ "min": 1 }] }, - { code: "var lalala = Foo(42)", options: [{ "max": 6 }] }, + { code: "var x = Foo(42)", options: [{ min: 1 }] }, + { code: "var x = Foo(42)", options: [{ min: 0 }] }, + { code: "foo.$x = Foo(42)", options: [{ min: 1 }] }, + { code: "var lalala = Foo(42)", options: [{ max: 6 }] }, { code: "for (var q, h=0; h < 10; h++) { console.log(h); q++; }", options: [{ exceptions: ["h", "q"] }] }, { code: "(num) => { num * num };", parserOptions: { ecmaVersion: 6 } }, { code: "function foo(num = 0) { }", parserOptions: { ecmaVersion: 6 } }, @@ -52,14 +52,14 @@ ruleTester.run("id-length", rule, { { code: "export var num = 0;", parserOptions: { sourceType: "module" } }, { code: "({ prop: obj.x.y.something }) = {};", parserOptions: { ecmaVersion: 6 } }, { code: "({ prop: obj.longName }) = {};", parserOptions: { ecmaVersion: 6 } }, - { code: "var obj = { a: 1, bc: 2 };", options: [{ "properties": "never" }] }, - { code: "var obj = {}; obj.a = 1; obj.bc = 2;", options: [{ "properties": "never" }] }, - { code: "({ a: obj.x.y.z }) = {};", options: [{ "properties": "never" }], parserOptions: { ecmaVersion: 6 } }, - { code: "({ prop: obj.x }) = {};", options: [{ "properties": "never" }], parserOptions: { ecmaVersion: 6 } }, - { code: "var obj = { aaaaa: 1 };", options: [{ "max": 4, "properties": "never" }] }, - { code: "var obj = {}; obj.aaaaa = 1;", options: [{ "max": 4, "properties": "never" }] }, - { code: "({ a: obj.x.y.z }) = {};", options: [{ "max": 4, "properties": "never" }], parserOptions: { ecmaVersion: 6 } }, - { code: "({ prop: obj.xxxxx }) = {};", options: [{ "max": 4, "properties": "never" }], parserOptions: { ecmaVersion: 6 } } + { code: "var obj = { a: 1, bc: 2 };", options: [{ properties: "never" }] }, + { code: "var obj = {}; obj.a = 1; obj.bc = 2;", options: [{ properties: "never" }] }, + { code: "({ a: obj.x.y.z }) = {};", options: [{ properties: "never" }], parserOptions: { ecmaVersion: 6 } }, + { code: "({ prop: obj.x }) = {};", options: [{ properties: "never" }], parserOptions: { ecmaVersion: 6 } }, + { code: "var obj = { aaaaa: 1 };", options: [{ max: 4, properties: "never" }] }, + { code: "var obj = {}; obj.aaaaa = 1;", options: [{ max: 4, properties: "never" }] }, + { code: "({ a: obj.x.y.z }) = {};", options: [{ max: 4, properties: "never" }], parserOptions: { ecmaVersion: 6 } }, + { code: "({ prop: obj.xxxxx }) = {};", options: [{ max: 4, properties: "never" }], parserOptions: { ecmaVersion: 6 } } ], invalid: [ { code: "var x = 1;", errors: [{ message: "Identifier name 'x' is too short. (< 2)", type: "Identifier" }] }, @@ -71,10 +71,10 @@ 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: [ + { 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: [ + { 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: [ @@ -115,6 +115,6 @@ ruleTester.run("id-length", rule, { { 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" }] } + { code: "var x = 1;", options: [{ properties: "never" }], errors: [{ message: "Identifier name 'x' is too short. (< 2)", type: "Identifier" }] } ] }); diff --git a/tests/lib/rules/indent.js b/tests/lib/rules/indent.js index fb3031e5995..c42846a9915 100644 --- a/tests/lib/rules/indent.js +++ b/tests/lib/rules/indent.js @@ -176,7 +176,7 @@ ruleTester.run("indent", rule, { { code: "// hi", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -186,26 +186,26 @@ ruleTester.run("indent", rule, { "\n" + " files.concat(fileList)\n" + "};\n", - options: [2, {"VariableDeclarator": { "var": 2, "let": 2, "const": 3}}] + options: [2, {VariableDeclarator: { var: 2, let: 2, const: 3}}] }, { code: " ", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: "if(data) {\n" + " console.log('hi');\n" + " b = true;};", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: "foo = () => {\n" + " console.log('hi');\n" + " return true;};", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 1, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 } }, { @@ -213,14 +213,14 @@ ruleTester.run("indent", rule, { "function test(data) {\n" + " console.log('hi');\n" + " return true;};", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: "var test = function(data) {\n" + " console.log('hi');\n" + "};", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -228,14 +228,14 @@ ruleTester.run("indent", rule, { " otherdata.forEach(function(zero) {\n" + " console.log('hi');\n" + " }) });", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: "a = [\n" + " ,3\n" + "]", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -247,7 +247,7 @@ ruleTester.run("indent", rule, { "].forEach(function(method) {\n" + " console.log(method);\n" + "});\n", - options: [2, {"SwitchCase": 1, "VariableDeclarator": 2}] + options: [2, {SwitchCase: 1, VariableDeclarator: 2}] }, { code: @@ -260,7 +260,7 @@ ruleTester.run("indent", rule, { " ]\n" + " }\n" + "});", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -270,7 +270,7 @@ ruleTester.run("indent", rule, { " a: 1\n" + " }\n" + " ];", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -283,7 +283,7 @@ ruleTester.run("indent", rule, { "{\n" + " x: 2\n" + "}];", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -296,7 +296,7 @@ ruleTester.run("indent", rule, { " ].join(',')\n" + " ]\n" + "});", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -309,7 +309,7 @@ ruleTester.run("indent", rule, { " ]\n" + " ]\n" + "};", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -319,7 +319,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " }\n" + ");", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -327,7 +327,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + "});", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -340,7 +340,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " }\n" + " ];", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -352,7 +352,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " }\n" + "];", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -363,7 +363,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + " };", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -372,7 +372,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + " };", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -381,7 +381,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " }),\n" + " b = 2;", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -391,7 +391,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " },\n" + " b = 2;", - options: [2, {"VariableDeclarator": 1, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 1, SwitchCase: 1}] }, { code: @@ -401,7 +401,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " },\n" + " b = 2;", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -410,7 +410,7 @@ ruleTester.run("indent", rule, { " b: 2\n" + " },\n" + " b = 2;", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -418,7 +418,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + "};", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -428,14 +428,14 @@ ruleTester.run("indent", rule, { " console.log(val);\n" + " }\n" + "}", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: "for (var val in obj)\n" + " if (true)\n" + " console.log(val);", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -443,21 +443,21 @@ ruleTester.run("indent", rule, { " if (true)\n" + " if (true)\n" + " console.log(val);", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: "function hi(){ var a = 1;\n" + " y++; x++;\n" + "}", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: "for(;length > index; index++)if(NO_HOLES || index in self){\n" + " x++;\n" + "}", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -468,7 +468,7 @@ ruleTester.run("indent", rule, { " };\n" + " }\n" + "}", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}] + options: [2, {VariableDeclarator: 2, SwitchCase: 1}] }, { code: @@ -766,7 +766,7 @@ ruleTester.run("indent", rule, { " foo: 'bar'\n" + " }\n" + "];\n", - options: [2, {"VariableDeclarator": 2}] + options: [2, {VariableDeclarator: 2}] }, { code: @@ -782,7 +782,7 @@ ruleTester.run("indent", rule, { " foo: 'bar'\n" + " }\n" + ");\n", - options: [2, {"VariableDeclarator": 3}], + options: [2, {VariableDeclarator: 3}], parserOptions: { ecmaVersion: 6 } }, @@ -794,7 +794,7 @@ ruleTester.run("indent", rule, { " b = 2;\n" + "let light = true,\n" + " shadow = false;", - options: [2, { VariableDeclarator: { "const": 3, "let": 2 } }], + options: [2, { VariableDeclarator: { const: 3, let: 2 } }], parserOptions: { ecmaVersion: 6 } }, { @@ -820,7 +820,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + " };\n", - options: [2, { VariableDeclarator: { var: 2, const: 3 }, "SwitchCase": 1}], + options: [2, { VariableDeclarator: { var: 2, const: 3 }, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 } }, { @@ -911,7 +911,7 @@ ruleTester.run("indent", rule, { " a = 5,\n" + " b = 4\n", parserOptions: { ecmaVersion: 6 }, - options: [2, {"VariableDeclarator": { "var": 2, "let": 2, "const": 3}}] + options: [2, {VariableDeclarator: { var: 2, let: 2, const: 3}}] }, { code: @@ -924,7 +924,7 @@ ruleTester.run("indent", rule, { "\n" + "if (YO) console.log(TE)", parserOptions: { ecmaVersion: 6 }, - options: [2, {"VariableDeclarator": { "var": 2, "let": 2, "const": 3}}] + options: [2, {VariableDeclarator: { var: 2, let: 2, const: 3}}] }, { code: @@ -982,7 +982,7 @@ ruleTester.run("indent", rule, { " a(){}\n" + " get b(){}\n" + " };", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 } }, { @@ -995,7 +995,7 @@ ruleTester.run("indent", rule, { " get b(){}\n" + " },\n" + " c = 3;", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 } }, { @@ -1005,7 +1005,7 @@ ruleTester.run("indent", rule, { " a(){}\n" + " get b(){}\n" + "}", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}], + options: [4, {VariableDeclarator: 1, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 } }, { @@ -1015,7 +1015,7 @@ ruleTester.run("indent", rule, { " a(){}\n" + " get b(){}\n" + "}", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}], + options: [4, {VariableDeclarator: 1, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 } }, { @@ -1050,7 +1050,7 @@ ruleTester.run("indent", rule, { " }\n" + " ]\n" + "};\n", - options: [4, {"VariableDeclarator": 0, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 0, SwitchCase: 1}] }, { code: @@ -1060,7 +1060,7 @@ ruleTester.run("indent", rule, { " name: 'compile'\n" + " }\n" + "];\n", - options: [4, {"VariableDeclarator": 0, "SwitchCase": 1}] + options: [4, {VariableDeclarator: 0, SwitchCase: 1}] }, { code: @@ -1758,7 +1758,7 @@ ruleTester.run("indent", rule, { " if (true)\n" + " if (true)\n" + " console.log(val);", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], errors: expectedErrors([ [4, 6, 4, "ExpressionStatement"] ]) @@ -1774,7 +1774,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + "}", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], errors: expectedErrors([ [2, 2, 4, "Property"], [3, 2, 4, "Property"] @@ -1791,7 +1791,7 @@ ruleTester.run("indent", rule, { " a,\n" + " b\n" + "]", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], errors: expectedErrors([ [2, 2, 4, "Identifier"], [3, 2, 4, "Identifier"] @@ -1808,7 +1808,7 @@ ruleTester.run("indent", rule, { " a,\n" + " b\n" + "]", - options: [2, {"VariableDeclarator": { let: 2 }, "SwitchCase": 1}], + options: [2, {VariableDeclarator: { let: 2 }, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 }, errors: expectedErrors([ [2, 2, 4, "Identifier"], @@ -1876,7 +1876,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + " };", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], errors: expectedErrors([ [4, 4, 5, "ObjectExpression"], [5, 6, 7, "Property"], @@ -1897,7 +1897,7 @@ ruleTester.run("indent", rule, { " a: 1,\n" + " b: 2\n" + " };", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], errors: expectedErrors([ [2, 4, 5, "ObjectExpression"], [3, 6, 7, "Property"], @@ -1945,7 +1945,7 @@ ruleTester.run("indent", rule, { " a(){}\n" + " get b(){}\n" + "}", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}], + options: [4, {VariableDeclarator: 1, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 }, errors: expectedErrors([[2, 4, 2, "MethodDefinition"]]) }, @@ -1962,7 +1962,7 @@ ruleTester.run("indent", rule, { " a(){}\n" + " get b(){}\n" + "};", - options: [4, {"VariableDeclarator": 1, "SwitchCase": 1}], + options: [4, {VariableDeclarator: 1, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 }, errors: expectedErrors([[2, 4, 2, "MethodDefinition"], [4, 4, 2, "MethodDefinition"]]) }, @@ -1981,7 +1981,7 @@ ruleTester.run("indent", rule, { " a(){}\n" + " get b(){}\n" + " };", - options: [2, {"VariableDeclarator": 2, "SwitchCase": 1}], + options: [2, {VariableDeclarator: 2, SwitchCase: 1}], parserOptions: { ecmaVersion: 6 }, errors: expectedErrors([[3, 6, 4, "MethodDefinition"]]) }, diff --git a/tests/lib/rules/init-declarations.js b/tests/lib/rules/init-declarations.js index e48c7d9a621..696a73c3962 100644 --- a/tests/lib/rules/init-declarations.js +++ b/tests/lib/rules/init-declarations.js @@ -92,16 +92,16 @@ ruleTester.run("init-declarations", rule, { }, { code: "for(var i = 0; i < 1; i++){}", - options: ["never", { "ignoreForLoopInit": true }] + options: ["never", { ignoreForLoopInit: true }] }, { code: "for (var foo in []) {}", - options: ["never", { "ignoreForLoopInit": true }] + options: ["never", { ignoreForLoopInit: true }] }, { code: "for (var foo of []) {}", parserOptions: { ecmaVersion: 6 }, - options: ["never", { "ignoreForLoopInit": true }] + options: ["never", { ignoreForLoopInit: true }] } ], invalid: [ diff --git a/tests/lib/rules/key-spacing.js b/tests/lib/rules/key-spacing.js index 31313d34404..b4eca277df7 100644 --- a/tests/lib/rules/key-spacing.js +++ b/tests/lib/rules/key-spacing.js @@ -213,7 +213,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { sourceType: "module" }, - options: [{ "align": "value" }] + options: [{ align: "value" }] }, { code: [ "var test = {", @@ -232,7 +232,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }] + options: [{ align: "value" }] }, { code: [ "var obj = {", @@ -242,7 +242,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }] + options: [{ align: "value" }] }, { code: [ "var test = {", @@ -260,7 +260,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }] + options: [{ align: "value" }] }, { code: [ "var obj = {", @@ -270,7 +270,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }] + options: [{ align: "value" }] }, { code: [ "var obj = {", @@ -282,7 +282,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }] + options: [{ align: "value" }] }, { code: [ "var obj = {", @@ -291,7 +291,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }] + options: [{ align: "colon" }] }, { code: [ "var obj = { foo : foo", @@ -299,7 +299,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }] + options: [{ align: "colon" }] }, { code: [ "var obj = {", @@ -309,8 +309,8 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), options: [{ - "align": "value", - "beforeColon": true + align: "value", + beforeColon: true }] }, @@ -432,9 +432,9 @@ ruleTester.run("key-spacing", rule, { "})" ].join("\n"), options: [{ - "multiLine": { - "afterColon": true, - "align": "colon" + multiLine: { + afterColon: true, + align: "colon" } }] }, { @@ -448,14 +448,14 @@ ruleTester.run("key-spacing", rule, { "})" ].join("\n"), options: [{ - "singleLine": { - "afterColon": true, - "beforeColon": false + singleLine: { + afterColon: true, + beforeColon: false }, - "multiLine": { - "afterColon": true, - "beforeColon": true, - "align": "colon" + multiLine: { + afterColon: true, + beforeColon: true, + align: "colon" } }] }, { @@ -469,14 +469,14 @@ ruleTester.run("key-spacing", rule, { "})" ].join("\n"), options: [{ - "multiLine": { - "afterColon": true, - "beforeColon": true, - "align": "colon" + multiLine: { + afterColon: true, + beforeColon: true, + align: "colon" }, - "singleLine": { - "afterColon": true, - "beforeColon": false + singleLine: { + afterColon: true, + beforeColon: false } }] }, { @@ -746,7 +746,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }], + options: [{ align: "value" }], errors: [ { message: "Missing space before value for key 'baz'.", line: 4, column: 10, type: "Literal" } ] @@ -759,7 +759,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }], + options: [{ align: "value" }], errors: [ { message: "Extra space before value for key 'foobar'.", line: 2, column: 14, type: "Literal" } ] @@ -772,7 +772,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }], + options: [{ align: "value" }], errors: [ { message: "Missing space before value for key 'baz'.", line: 4, column: 10, type: "Literal" } ] @@ -785,7 +785,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }], + options: [{ align: "value" }], errors: [ { message: "Extra space before value for key 'foobar'.", line: 2, column: 14, type: "Literal" } ] @@ -800,7 +800,7 @@ ruleTester.run("key-spacing", rule, { "};" ].join("\n"), parserOptions: { ecmaVersion: 6 }, - options: [{ "align": "value" }], + options: [{ align: "value" }], errors: [ { message: "Extra space before value for key 'baz'.", line: 6, column: 13, type: "Literal" } ] @@ -811,7 +811,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Missing space after key 'foo'.", line: 2, column: 5, type: "Identifier" } ] @@ -822,7 +822,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Extra space before value for key 'cats'.", line: 3, column: 12, type: "Identifier" } ] @@ -832,7 +832,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Missing space after key 'foo'.", line: 1, column: 13, type: "Identifier" } ] @@ -842,7 +842,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Extra space after key 'foo'.", line: 1, column: 13, type: "Identifier" } ] @@ -852,7 +852,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Missing space before value for key 'foo'.", line: 1, column: 18, type: "Identifier" } ] @@ -862,7 +862,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Extra space before value for key 'foo'.", line: 1, column: 20, type: "Identifier" } ] @@ -872,7 +872,7 @@ ruleTester.run("key-spacing", rule, { " , cats: cats", "};" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], errors: [ { message: "Extra space before value for key 'cats'.", line: 2, column: 20, type: "Identifier" } ] @@ -895,7 +895,7 @@ ruleTester.run("key-spacing", rule, { " f : 0", "})" ].join("\n"), - options: [{ "align": "colon" }], + options: [{ align: "colon" }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, errors: [ { message: "Missing space after key 'a'.", line: 3, column: 5, type: "Identifier" }, @@ -956,15 +956,15 @@ ruleTester.run("key-spacing", rule, { "})" ].join("\n"), options: [{ - "singleLine": { - "afterColon": false, - "beforeColon": false + singleLine: { + afterColon: false, + beforeColon: false }, - "multiLine": { - "mode": "minimum", - "afterColon": true, - "beforeColon": true, - "align": "value" + multiLine: { + mode: "minimum", + afterColon: true, + beforeColon: true, + align: "value" } }], errors: [ @@ -981,14 +981,14 @@ ruleTester.run("key-spacing", rule, { "})" ].join("\n"), options: [{ - "multiLine": { - "afterColon": true, - "beforeColon": false, - "align": "colon" + multiLine: { + afterColon: true, + beforeColon: false, + align: "colon" }, - "singleLine": { - "afterColon": true, - "beforeColon": true + singleLine: { + afterColon: true, + beforeColon: true } }], errors: [ @@ -1038,9 +1038,9 @@ ruleTester.run("key-spacing", rule, { "})" ].join("\n"), options: [{ - "multiLine": { - "afterColon": true, - "align": "colon" + multiLine: { + afterColon: true, + align: "colon" } }], errors: [ @@ -1052,7 +1052,7 @@ ruleTester.run("key-spacing", rule, { // https://github.com/eslint/eslint/issues/5724 { code: "({ a:b, ...object, c : d })", - options: [{ "align": "colon" }], + options: [{ align: "colon" }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, errors: [ { message: "Missing space before value for key 'a'.", line: 1, column: 6, type: "Identifier" }, diff --git a/tests/lib/rules/max-depth.js b/tests/lib/rules/max-depth.js index 361320e3ac9..7a7389212ff 100644 --- a/tests/lib/rules/max-depth.js +++ b/tests/lib/rules/max-depth.js @@ -26,7 +26,7 @@ ruleTester.run("max-depth", rule, { { code: "function foo() { if (true) { if (false) { if (true) { } } } }" }, // object property options - { code: "function foo() { if (true) { if (false) { if (true) { } } } }", options: [{ "max": 3 }] } + { code: "function foo() { if (true) { if (false) { if (true) { } } } }", options: [{ max: 3 }] } ], invalid: [ { code: "function foo() { if (true) { if (false) { if (true) { } } } }", options: [2], errors: [{ message: "Blocks are nested too deeply (3).", type: "IfStatement"}] }, @@ -38,6 +38,6 @@ ruleTester.run("max-depth", rule, { { code: "function foo() { if (true) { if (false) { if (true) { if (false) { if (true) { } } } } } }", errors: [{ message: "Blocks are nested too deeply (5).", type: "IfStatement"}] }, // object property options - { code: "function foo() { if (true) { if (false) { if (true) { } } } }", options: [{ "max": 2 }], errors: [{ message: "Blocks are nested too deeply (3).", type: "IfStatement"}] } + { code: "function foo() { if (true) { if (false) { if (true) { } } } }", options: [{ max: 2 }], errors: [{ message: "Blocks are nested too deeply (3).", type: "IfStatement"}] } ] }); diff --git a/tests/lib/rules/max-nested-callbacks.js b/tests/lib/rules/max-nested-callbacks.js index 399de687e8a..45d64d4aeae 100644 --- a/tests/lib/rules/max-nested-callbacks.js +++ b/tests/lib/rules/max-nested-callbacks.js @@ -46,7 +46,7 @@ ruleTester.run("max-nested-callbacks", rule, { { code: nestFunctions(10)}, // object property options - { code: "foo(function() { bar(thing, function(data) {}); });", options: [{ "max": 3 }] } + { code: "foo(function() { bar(thing, function(data) {}); });", options: [{ max: 3 }] } ], invalid: [ { @@ -79,7 +79,7 @@ ruleTester.run("max-nested-callbacks", rule, { // object property options { code: "foo(function() { bar(thing, function(data) { baz(function() {}); }); });", - options: [{ "max": 2 }], + options: [{ max: 2 }], errors: [{ message: "Too many nested callbacks (3). Maximum allowed is 2.", type: "FunctionExpression"}] } ] diff --git a/tests/lib/rules/max-params.js b/tests/lib/rules/max-params.js index 929d045d81b..5c668087aca 100644 --- a/tests/lib/rules/max-params.js +++ b/tests/lib/rules/max-params.js @@ -26,7 +26,7 @@ ruleTester.run("max-params", rule, { { code: "var test = function test(a, b, c) {};", options: [3] }, // object property options - { code: "var test = function(a, b, c) {};", options: [{ "max": 3 }] } + { code: "var test = function(a, b, c) {};", options: [{ max: 3 }] } ], invalid: [ { code: "function test(a, b, c) {}", options: [2], errors: [{ message: "This function has too many parameters (3). Maximum allowed is 2.", type: "FunctionDeclaration"}] }, @@ -37,6 +37,6 @@ ruleTester.run("max-params", rule, { { code: "var test = function test(a, b, c) {};", options: [1], errors: [{ message: "This function has too many parameters (3). Maximum allowed is 1.", type: "FunctionExpression"}] }, // object property options - { code: "function test(a, b, c) {}", options: [{ "max": 2 }], errors: [{ message: "This function has too many parameters (3). Maximum allowed is 2.", type: "FunctionDeclaration"}] } + { code: "function test(a, b, c) {}", options: [{ max: 2 }], errors: [{ message: "This function has too many parameters (3). Maximum allowed is 2.", type: "FunctionDeclaration"}] } ] }); diff --git a/tests/lib/rules/max-statements-per-line.js b/tests/lib/rules/max-statements-per-line.js index add543ec781..8696b25c18d 100644 --- a/tests/lib/rules/max-statements-per-line.js +++ b/tests/lib/rules/max-statements-per-line.js @@ -20,92 +20,92 @@ var ruleTester = new RuleTester(); ruleTester.run("max-statements-per-line", rule, { valid: [ - { code: "", options: [{ "max": 0 }] }, - { code: "{ }", options: [{ "max": 1 }] }, + { code: "", options: [{ max: 0 }] }, + { code: "{ }", options: [{ max: 1 }] }, { code: "var bar = 1;" }, - { code: "var bar = 1;", options: [{ "max": 1 }] }, - { code: "if (condition) var bar = 1;", options: [{ "max": 1 }] }, - { code: "if (condition) { }", options: [{ "max": 1 }] }, - { code: "if (condition) { } else { }", options: [{ "max": 1 }] }, - { code: "if (condition) {\nvar bar = 1;\n} else {\nvar bar = 1;\n}", options: [{ "max": 1 }] }, - { code: "for (var i = 0; i < length; ++i) { }", options: [{ "max": 1 }] }, - { code: "for (var i = 0; i < length; ++i) {\nvar bar = 1;\n}", options: [{ "max": 1 }] }, - { code: "switch (discriminant) { default: }", options: [{ "max": 1 }] }, - { code: "switch (discriminant) {\ndefault: break;\n}", options: [{ "max": 1 }] }, - { code: "function foo() { }", options: [{ "max": 1 }] }, - { code: "function foo() {\nif (condition) var bar = 1;\n}", options: [{ "max": 1 }] }, - { code: "function foo() {\nif (condition) {\nvar bar = 1;\n}\n}", options: [{ "max": 1 }] }, - { code: "(function() { })();", options: [{ "max": 1 }] }, - { code: "(function() {\nvar bar = 1;\n})();", options: [{ "max": 1 }] }, - { code: "var foo = function foo() { };", options: [{ "max": 1 }] }, - { code: "var foo = function foo() {\nvar bar = 1;\n};", options: [{ "max": 1 }] }, - { code: "var foo = { prop: () => { } };", options: [{ "max": 1 }], parserOptions: { ecmaVersion: 6 } }, - { code: "var bar = 1; var baz = 2;", options: [{ "max": 2 }] }, - { code: "if (condition) { var bar = 1; }", options: [{ "max": 2 }] }, - { code: "if (condition) {\nvar bar = 1; var baz = 2;\n} else {\nvar bar = 1; var baz = 2;\n}", options: [{ "max": 2 }] }, - { code: "for (var i = 0; i < length; ++i) { var bar = 1; }", options: [{ "max": 2 }] }, - { code: "for (var i = 0; i < length; ++i) {\nvar bar = 1; var baz = 2;\n}", options: [{ "max": 2 }] }, - { code: "switch (discriminant) { default: break; }", options: [{ "max": 2 }] }, - { code: "switch (discriminant) {\ncase 'test': var bar = 1; break;\ndefault: var bar = 1; break;\n}", options: [{ "max": 2 }] }, - { code: "function foo() { var bar = 1; }", options: [{ "max": 2 }] }, - { code: "function foo() {\nvar bar = 1; var baz = 2;\n}", options: [{ "max": 2 }] }, - { code: "function foo() {\nif (condition) { var bar = 1; }\n}", options: [{ "max": 2 }] }, - { code: "function foo() {\nif (condition) {\nvar bar = 1; var baz = 2;\n}\n}", options: [{ "max": 2 }] }, - { code: "(function() { var bar = 1; })();", options: [{ "max": 2 }] }, - { code: "(function() {\nvar bar = 1; var baz = 2;\n})();", options: [{ "max": 2 }] }, - { code: "var foo = function foo() { var bar = 1; };", options: [{ "max": 2 }] }, - { code: "var foo = function foo() {\nvar bar = 1; var baz = 2;\n};", options: [{ "max": 2 }] }, - { code: "var foo = { prop: () => { var bar = 1; } };", options: [{ "max": 2 }], parserOptions: { ecmaVersion: 6 } }, - { code: "var bar = 1; var baz = 2; var qux = 3;", options: [{ "max": 3 }] }, - { code: "if (condition) { var bar = 1; var baz = 2; }", options: [{ "max": 3 }] }, - { code: "if (condition) { var bar = 1; } else { var bar = 1; }", options: [{ "max": 3 }] }, - { code: "switch (discriminant) { case 'test1': ; case 'test2': ; }", options: [{ "max": 3 }] }, - { code: "let bar = bar => { ; }, baz = baz => { ; };", options: [{ "max": 3 }], parserOptions: { ecmaVersion: 6 } }, - { code: "function foo({[bar => { ; }]: baz = qux => { ; }}) { }", options: [{ "max": 3 }], parserOptions: { ecmaVersion: 6 } }, - { code: "bar => { ; }, baz => { ; }, qux => { ; };", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 } }, - { code: "[bar => { ; }, baz => { ; }, qux => { ; }];", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 } }, - { code: "foo(bar => { ; }, baz => { ; }, qux => { ; });", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 } }, - { code: "({ bar: bar => { ; }, baz: baz => { ; }, qux: qux => { ; }});", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 } }, - { code: "(bar => { ; }) ? (baz => { ; }) : (qux => { ; });", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 } } + { code: "var bar = 1;", options: [{ max: 1 }] }, + { code: "if (condition) var bar = 1;", options: [{ max: 1 }] }, + { code: "if (condition) { }", options: [{ max: 1 }] }, + { code: "if (condition) { } else { }", options: [{ max: 1 }] }, + { code: "if (condition) {\nvar bar = 1;\n} else {\nvar bar = 1;\n}", options: [{ max: 1 }] }, + { code: "for (var i = 0; i < length; ++i) { }", options: [{ max: 1 }] }, + { code: "for (var i = 0; i < length; ++i) {\nvar bar = 1;\n}", options: [{ max: 1 }] }, + { code: "switch (discriminant) { default: }", options: [{ max: 1 }] }, + { code: "switch (discriminant) {\ndefault: break;\n}", options: [{ max: 1 }] }, + { code: "function foo() { }", options: [{ max: 1 }] }, + { code: "function foo() {\nif (condition) var bar = 1;\n}", options: [{ max: 1 }] }, + { code: "function foo() {\nif (condition) {\nvar bar = 1;\n}\n}", options: [{ max: 1 }] }, + { code: "(function() { })();", options: [{ max: 1 }] }, + { code: "(function() {\nvar bar = 1;\n})();", options: [{ max: 1 }] }, + { code: "var foo = function foo() { };", options: [{ max: 1 }] }, + { code: "var foo = function foo() {\nvar bar = 1;\n};", options: [{ max: 1 }] }, + { code: "var foo = { prop: () => { } };", options: [{ max: 1 }], parserOptions: { ecmaVersion: 6 } }, + { code: "var bar = 1; var baz = 2;", options: [{ max: 2 }] }, + { code: "if (condition) { var bar = 1; }", options: [{ max: 2 }] }, + { code: "if (condition) {\nvar bar = 1; var baz = 2;\n} else {\nvar bar = 1; var baz = 2;\n}", options: [{ max: 2 }] }, + { code: "for (var i = 0; i < length; ++i) { var bar = 1; }", options: [{ max: 2 }] }, + { code: "for (var i = 0; i < length; ++i) {\nvar bar = 1; var baz = 2;\n}", options: [{ max: 2 }] }, + { code: "switch (discriminant) { default: break; }", options: [{ max: 2 }] }, + { code: "switch (discriminant) {\ncase 'test': var bar = 1; break;\ndefault: var bar = 1; break;\n}", options: [{ max: 2 }] }, + { code: "function foo() { var bar = 1; }", options: [{ max: 2 }] }, + { code: "function foo() {\nvar bar = 1; var baz = 2;\n}", options: [{ max: 2 }] }, + { code: "function foo() {\nif (condition) { var bar = 1; }\n}", options: [{ max: 2 }] }, + { code: "function foo() {\nif (condition) {\nvar bar = 1; var baz = 2;\n}\n}", options: [{ max: 2 }] }, + { code: "(function() { var bar = 1; })();", options: [{ max: 2 }] }, + { code: "(function() {\nvar bar = 1; var baz = 2;\n})();", options: [{ max: 2 }] }, + { code: "var foo = function foo() { var bar = 1; };", options: [{ max: 2 }] }, + { code: "var foo = function foo() {\nvar bar = 1; var baz = 2;\n};", options: [{ max: 2 }] }, + { code: "var foo = { prop: () => { var bar = 1; } };", options: [{ max: 2 }], parserOptions: { ecmaVersion: 6 } }, + { code: "var bar = 1; var baz = 2; var qux = 3;", options: [{ max: 3 }] }, + { code: "if (condition) { var bar = 1; var baz = 2; }", options: [{ max: 3 }] }, + { code: "if (condition) { var bar = 1; } else { var bar = 1; }", options: [{ max: 3 }] }, + { code: "switch (discriminant) { case 'test1': ; case 'test2': ; }", options: [{ max: 3 }] }, + { code: "let bar = bar => { ; }, baz = baz => { ; };", options: [{ max: 3 }], parserOptions: { ecmaVersion: 6 } }, + { code: "function foo({[bar => { ; }]: baz = qux => { ; }}) { }", options: [{ max: 3 }], parserOptions: { ecmaVersion: 6 } }, + { code: "bar => { ; }, baz => { ; }, qux => { ; };", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 } }, + { code: "[bar => { ; }, baz => { ; }, qux => { ; }];", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 } }, + { code: "foo(bar => { ; }, baz => { ; }, qux => { ; });", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 } }, + { code: "({ bar: bar => { ; }, baz: baz => { ; }, qux: qux => { ; }});", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 } }, + { code: "(bar => { ; }) ? (baz => { ; }) : (qux => { ; });", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 } } ], invalid: [ - { code: "{ }", options: [{ "max": 0 }], errors: [{ message: "This line has too many statements. Maximum allowed is 0." }] }, - { code: "var bar = 1;", options: [{ "max": 0 }], errors: [{ message: "This line has too many statements. Maximum allowed is 0." }] }, + { code: "{ }", options: [{ max: 0 }], errors: [{ message: "This line has too many statements. Maximum allowed is 0." }] }, + { code: "var bar = 1;", options: [{ max: 0 }], errors: [{ message: "This line has too many statements. Maximum allowed is 0." }] }, { code: "var bar = 1; var baz = 2;", errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "var bar = 1; var baz = 2;", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "if (condition) var bar = 1; if (condition) var baz = 2;", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "if (condition) { } if (condition) { }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "if (condition) { var bar = 1; } else { }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "if (condition) { } else { var bar = 1; }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "if (condition) { var bar = 1; } else { var bar = 1; }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "for (var i = 0; i < length; ++i) { var bar = 1; }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "switch (discriminant) { default: break; }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "function foo() { var bar = 1; }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "function foo() { if (condition) var bar = 1; }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "function foo() { if (condition) { var bar = 1; } }", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "(function() { var bar = 1; })();", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "var foo = function foo() { var bar = 1; };", options: [{ "max": 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "var foo = { prop: () => { var bar = 1; } };", options: [{ "max": 1 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, - { code: "var bar = 1; var baz = 2; var qux = 3;", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "if (condition) { var bar = 1; var baz = 2; }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "if (condition) { var bar = 1; } else { var bar = 1; }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "if (condition) { var bar = 1; var baz = 2; } else { var bar = 1; var baz = 2; }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "for (var i = 0; i < length; ++i) { var bar = 1; var baz = 2; }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "switch (discriminant) { case 'test': break; default: break; }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "function foo() { var bar = 1; var baz = 2; }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "function foo() { if (condition) { var bar = 1; } }", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "(function() { var bar = 1; var baz = 2; })();", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "var foo = function foo() { var bar = 1; var baz = 2; };", options: [{ "max": 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "var foo = { prop: () => { var bar = 1; var baz = 2; } };", options: [{ "max": 2 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, - { code: "var bar = 1; var baz = 2; var qux = 3; var waldo = 4;", options: [{ "max": 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, - { code: "if (condition) { var bar = 1; var baz = 2; var qux = 3; }", options: [{ "max": 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, - { code: "if (condition) { var bar = 1; var baz = 2; } else { var bar = 1; var baz = 2; }", options: [{ "max": 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, - { code: "switch (discriminant) { case 'test': var bar = 1; break; default: var bar = 1; break; }", options: [{ "max": 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, - { code: "let bar = bar => { ; }, baz = baz => { ; }, qux = qux => { ; };", options: [{ "max": 3 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, - { code: "(bar => { ; }) ? (baz => { ; }) : (qux => { ; });", options: [{ "max": 3 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, - { code: "bar => { ; }, baz => { ; }, qux => { ; }, quux => { ; };", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] }, - { code: "[bar => { ; }, baz => { ; }, qux => { ; }, quux => { ; }];", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] }, - { code: "foo(bar => { ; }, baz => { ; }, qux => { ; }, quux => { ; });", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] }, - { code: "({ bar: bar => { ; }, baz: baz => { ; }, qux: qux => { ; }, quux: quux => { ; }});", options: [{ "max": 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] } + { code: "var bar = 1; var baz = 2;", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "if (condition) var bar = 1; if (condition) var baz = 2;", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "if (condition) { } if (condition) { }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "if (condition) { var bar = 1; } else { }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "if (condition) { } else { var bar = 1; }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "if (condition) { var bar = 1; } else { var bar = 1; }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "for (var i = 0; i < length; ++i) { var bar = 1; }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "switch (discriminant) { default: break; }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "function foo() { var bar = 1; }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "function foo() { if (condition) var bar = 1; }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "function foo() { if (condition) { var bar = 1; } }", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "(function() { var bar = 1; })();", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "var foo = function foo() { var bar = 1; };", options: [{ max: 1 }], errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "var foo = { prop: () => { var bar = 1; } };", options: [{ max: 1 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 1." }] }, + { code: "var bar = 1; var baz = 2; var qux = 3;", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "if (condition) { var bar = 1; var baz = 2; }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "if (condition) { var bar = 1; } else { var bar = 1; }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "if (condition) { var bar = 1; var baz = 2; } else { var bar = 1; var baz = 2; }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "for (var i = 0; i < length; ++i) { var bar = 1; var baz = 2; }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "switch (discriminant) { case 'test': break; default: break; }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "function foo() { var bar = 1; var baz = 2; }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "function foo() { if (condition) { var bar = 1; } }", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "(function() { var bar = 1; var baz = 2; })();", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "var foo = function foo() { var bar = 1; var baz = 2; };", options: [{ max: 2 }], errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "var foo = { prop: () => { var bar = 1; var baz = 2; } };", options: [{ max: 2 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 2." }] }, + { code: "var bar = 1; var baz = 2; var qux = 3; var waldo = 4;", options: [{ max: 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, + { code: "if (condition) { var bar = 1; var baz = 2; var qux = 3; }", options: [{ max: 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, + { code: "if (condition) { var bar = 1; var baz = 2; } else { var bar = 1; var baz = 2; }", options: [{ max: 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, + { code: "switch (discriminant) { case 'test': var bar = 1; break; default: var bar = 1; break; }", options: [{ max: 3 }], errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, + { code: "let bar = bar => { ; }, baz = baz => { ; }, qux = qux => { ; };", options: [{ max: 3 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, + { code: "(bar => { ; }) ? (baz => { ; }) : (qux => { ; });", options: [{ max: 3 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 3." }] }, + { code: "bar => { ; }, baz => { ; }, qux => { ; }, quux => { ; };", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] }, + { code: "[bar => { ; }, baz => { ; }, qux => { ; }, quux => { ; }];", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] }, + { code: "foo(bar => { ; }, baz => { ; }, qux => { ; }, quux => { ; });", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] }, + { code: "({ bar: bar => { ; }, baz: baz => { ; }, qux: qux => { ; }, quux: quux => { ; }});", options: [{ max: 4 }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "This line has too many statements. Maximum allowed is 4." }] } ] }); diff --git a/tests/lib/rules/max-statements.js b/tests/lib/rules/max-statements.js index da0fa530ebe..c6202326c0d 100644 --- a/tests/lib/rules/max-statements.js +++ b/tests/lib/rules/max-statements.js @@ -31,7 +31,7 @@ ruleTester.run("max-statements", rule, { { code: "define(['foo', 'qux'], function(foo, qux) { var bar = 1; var baz = 2; })", options: [1, {ignoreTopLevelFunctions: true}] }, // object property options - { code: "var foo = { thing: function() { var bar = 1; var baz = 2; } }", options: [{ "max": 2 }] } + { code: "var foo = { thing: function() { var bar = 1; var baz = 2; } }", options: [{ max: 2 }] } ], invalid: [ { code: "function foo() { var bar = 1; var baz = 2; var qux = 3; }", options: [2], errors: [{ message: "This function has too many statements (3). Maximum allowed is 2."}] }, @@ -48,6 +48,6 @@ ruleTester.run("max-statements", rule, { { code: "function foo() { var a; var b; var c; var x; var y; var z; bar(); baz(); qux(); quxx(); foo(); }", errors: [{ message: "This function has too many statements (11). Maximum allowed is 10."}] }, // object property options - { code: "function foo() { var bar = 1; var baz = 2; var qux = 3; }", options: [{ "max": 2 }], errors: [{ message: "This function has too many statements (3). Maximum allowed is 2."}] } + { code: "function foo() { var bar = 1; var baz = 2; var qux = 3; }", options: [{ max: 2 }], errors: [{ message: "This function has too many statements (3). Maximum allowed is 2."}] } ] }); diff --git a/tests/lib/rules/new-cap.js b/tests/lib/rules/new-cap.js index db7223d7a00..93debbe21d3 100644 --- a/tests/lib/rules/new-cap.js +++ b/tests/lib/rules/new-cap.js @@ -45,13 +45,13 @@ ruleTester.run("new-cap", rule, { "var x = Symbol('symbol')", "var x = _();", "var x = $();", - { code: "var x = Foo(42)", options: [{"capIsNew": false}] }, - { code: "var x = bar.Foo(42)", options: [{"capIsNew": false}] }, - { code: "var x = Foo.bar(42)", options: [{"capIsNew": false}] }, + { code: "var x = Foo(42)", options: [{capIsNew: false}] }, + { code: "var x = bar.Foo(42)", options: [{capIsNew: false}] }, + { code: "var x = Foo.bar(42)", options: [{capIsNew: false}] }, "var x = bar[Foo](42)", - {code: "var x = bar['Foo'](42)", options: [{"capIsNew": false}] }, + {code: "var x = bar['Foo'](42)", options: [{capIsNew: false}] }, "var x = Foo.bar(42)", - { code: "var x = new foo(42)", options: [{"newIsCap": false}] }, + { code: "var x = new foo(42)", options: [{newIsCap: false}] }, "var o = { 1: function() {} }; o[1]();", "var o = { 1: function() {} }; new o[1]();", { code: "var x = Foo(42);", options: [{ capIsNew: true, capIsNewExceptions: ["Foo"] }] }, diff --git a/tests/lib/rules/no-eval.js b/tests/lib/rules/no-eval.js index ea2a67e9c02..d2c2a5b1a82 100644 --- a/tests/lib/rules/no-eval.js +++ b/tests/lib/rules/no-eval.js @@ -28,13 +28,13 @@ ruleTester.run("no-eval", rule, { // User-defined eval methods. "window.eval('foo')", - { code: "window.eval('foo')", env: {"node": true} }, - { code: "window.noeval('foo')", env: {"browser": true} }, - { code: "function foo() { var eval = 'foo'; window[eval]('foo') }", env: {"browser": true} }, + { code: "window.eval('foo')", env: {node: true} }, + { code: "window.noeval('foo')", env: {browser: true} }, + { code: "function foo() { var eval = 'foo'; window[eval]('foo') }", env: {browser: true} }, "global.eval('foo')", - { code: "global.eval('foo')", env: {"browser": true} }, - { code: "global.noeval('foo')", env: {"node": true} }, - { code: "function foo() { var eval = 'foo'; global[eval]('foo') }", env: {"node": true} }, + { code: "global.eval('foo')", env: {browser: true} }, + { code: "global.noeval('foo')", env: {node: true} }, + { code: "function foo() { var eval = 'foo'; global[eval]('foo') }", env: {node: true} }, "this.noeval('foo');", "function foo() { 'use strict'; this.eval('foo'); }", { code: "function foo() { this.eval('foo'); }", parserOptions: { sourceType: "module" } }, @@ -45,19 +45,19 @@ ruleTester.run("no-eval", rule, { { code: "class A { static foo() { this.eval(); } }", parserOptions: { ecmaVersion: 6 } }, // Allows indirect eval - { code: "(0, eval)('foo')", options: [{"allowIndirect": true}] }, - { code: "(0, window.eval)('foo')", env: {"browser": true}, options: [{"allowIndirect": true}] }, - { code: "(0, window['eval'])('foo')", env: {"browser": true}, options: [{"allowIndirect": true}] }, - { code: "var EVAL = eval; EVAL('foo')", options: [{"allowIndirect": true}] }, - { code: "var EVAL = this.eval; EVAL('foo')", options: [{"allowIndirect": true}] }, - { code: "(function(exe){ exe('foo') })(eval);", options: [{"allowIndirect": true}] }, - { code: "window.eval('foo')", env: {"browser": true}, options: [{"allowIndirect": true}] }, - { code: "window.window.eval('foo')", env: {"browser": true}, options: [{"allowIndirect": true}] }, - { code: "window.window['eval']('foo')", env: {"browser": true}, options: [{"allowIndirect": true}] }, - { code: "global.eval('foo')", env: {"node": true}, options: [{"allowIndirect": true}] }, - { code: "global.global.eval('foo')", env: {"node": true}, options: [{"allowIndirect": true}] }, - { code: "this.eval('foo')", options: [{"allowIndirect": true}] }, - { code: "function foo() { this.eval('foo') }", options: [{"allowIndirect": true}] } + { code: "(0, eval)('foo')", options: [{allowIndirect: true}] }, + { code: "(0, window.eval)('foo')", env: {browser: true}, options: [{allowIndirect: true}] }, + { code: "(0, window['eval'])('foo')", env: {browser: true}, options: [{allowIndirect: true}] }, + { code: "var EVAL = eval; EVAL('foo')", options: [{allowIndirect: true}] }, + { code: "var EVAL = this.eval; EVAL('foo')", options: [{allowIndirect: true}] }, + { code: "(function(exe){ exe('foo') })(eval);", options: [{allowIndirect: true}] }, + { code: "window.eval('foo')", env: {browser: true}, options: [{allowIndirect: true}] }, + { code: "window.window.eval('foo')", env: {browser: true}, options: [{allowIndirect: true}] }, + { code: "window.window['eval']('foo')", env: {browser: true}, options: [{allowIndirect: true}] }, + { code: "global.eval('foo')", env: {node: true}, options: [{allowIndirect: true}] }, + { code: "global.global.eval('foo')", env: {node: true}, options: [{allowIndirect: true}] }, + { code: "this.eval('foo')", options: [{allowIndirect: true}] }, + { code: "function foo() { this.eval('foo') }", options: [{allowIndirect: true}] } ], invalid: [ @@ -66,23 +66,23 @@ ruleTester.run("no-eval", rule, { { code: "eval(foo)", errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, { code: "eval('foo')", errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, { code: "function foo(eval) { eval('foo') }", errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "eval(foo)", options: [{"allowIndirect": true}], errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "eval('foo')", options: [{"allowIndirect": true}], errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "function foo(eval) { eval('foo') }", options: [{"allowIndirect": true}], errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "eval(foo)", options: [{allowIndirect: true}], errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "eval('foo')", options: [{allowIndirect: true}], errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "function foo(eval) { eval('foo') }", options: [{allowIndirect: true}], errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, // Indirect eval { code: "(0, eval)('foo')", errors: [{ message: "eval can be harmful.", type: "Identifier"}] }, - { code: "(0, window.eval)('foo')", env: {"browser": true}, errors: [{ message: "eval can be harmful.", type: "MemberExpression"}] }, - { code: "(0, window['eval'])('foo')", env: {"browser": true}, errors: [{ message: "eval can be harmful.", type: "MemberExpression"}] }, + { code: "(0, window.eval)('foo')", env: {browser: true}, errors: [{ message: "eval can be harmful.", type: "MemberExpression"}] }, + { code: "(0, window['eval'])('foo')", env: {browser: true}, errors: [{ message: "eval can be harmful.", type: "MemberExpression"}] }, { code: "var EVAL = eval; EVAL('foo')", errors: [{ message: "eval can be harmful.", type: "Identifier"}] }, { code: "var EVAL = this.eval; EVAL('foo')", errors: [{ message: "eval can be harmful.", type: "MemberExpression"}] }, { code: "(function(exe){ exe('foo') })(eval);", errors: [{ message: "eval can be harmful.", type: "Identifier"}] }, - { code: "window.eval('foo')", env: {"browser": true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "window.window.eval('foo')", env: {"browser": true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "window.window['eval']('foo')", env: {"browser": true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "global.eval('foo')", env: {"node": true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "global.global.eval('foo')", env: {"node": true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, - { code: "global.global[`eval`]('foo')", env: {"node": true}, parserOptions: { ecmaVersion: 6 }, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "window.eval('foo')", env: {browser: true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "window.window.eval('foo')", env: {browser: true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "window.window['eval']('foo')", env: {browser: true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "global.eval('foo')", env: {node: true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "global.global.eval('foo')", env: {node: true}, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, + { code: "global.global[`eval`]('foo')", env: {node: true}, parserOptions: { ecmaVersion: 6 }, errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, { code: "this.eval('foo')", errors: [{ message: "eval can be harmful.", type: "CallExpression"}] }, { code: "function foo() { this.eval('foo') }", errors: [{ message: "eval can be harmful.", type: "CallExpression"}] } ] diff --git a/tests/lib/rules/no-multi-spaces.js b/tests/lib/rules/no-multi-spaces.js index d83f13702a5..ca929839797 100644 --- a/tests/lib/rules/no-multi-spaces.js +++ b/tests/lib/rules/no-multi-spaces.js @@ -73,7 +73,7 @@ ruleTester.run("no-multi-spaces", rule, { "({ a: b })", { code: "var answer = 6 * 7;", - options: [{ exceptions: { "VariableDeclaration": true, "BinaryExpression": true } }] + options: [{ exceptions: { VariableDeclaration: true, BinaryExpression: true } }] } ], @@ -350,7 +350,7 @@ ruleTester.run("no-multi-spaces", rule, { { code: "({ a: b })", output: "({ a: b })", - options: [{ exceptions: { "Property": false } }], + options: [{ exceptions: { Property: false } }], errors: [{ message: "Multiple spaces found before 'b'.", type: "Identifier" diff --git a/tests/lib/rules/no-multiple-empty-lines.js b/tests/lib/rules/no-multiple-empty-lines.js index 37c8748e76c..cd1ab7800f7 100644 --- a/tests/lib/rules/no-multiple-empty-lines.js +++ b/tests/lib/rules/no-multiple-empty-lines.js @@ -106,7 +106,7 @@ ruleTester.run("no-multiple-empty-lines", rule, { }, { code: "// valid 9\nvar a = 1;\n\n", - options: [{ "max": 2, "maxEOF": 1 }] + options: [{ max: 2, maxEOF: 1 }] }, { code: "// valid 10\nvar a = 5;\n", @@ -114,7 +114,7 @@ ruleTester.run("no-multiple-empty-lines", rule, { }, { code: "\n// valid 11\nvar a = 1;\n", - options: [{ "max": 2, "maxBOF": 1 }] + options: [{ max: 2, maxBOF: 1 }] }, // template strings diff --git a/tests/lib/rules/no-unused-vars.js b/tests/lib/rules/no-unused-vars.js index ccfca81cf5b..82523756e28 100644 --- a/tests/lib/rules/no-unused-vars.js +++ b/tests/lib/rules/no-unused-vars.js @@ -29,8 +29,8 @@ ruleTester.defineRule("use-every-a", function(context) { context.markVariableAsUsed("a"); } return { - "VariableDeclaration": useA, - "ReturnStatement": useA + VariableDeclaration: useA, + ReturnStatement: useA }; }); @@ -62,12 +62,12 @@ ruleTester.run("no-unused-vars", rule, { "try {} catch(e) {}", "/*global a */ a;", { code: "var a=10; (function() { alert(a); })();", options: [{vars: "all"}] }, - { code: "function g(bar, baz) { return baz; }; g();", options: [{"vars": "all"}] }, - { code: "function g(bar, baz) { return baz; }; g();", options: [{"vars": "all", "args": "after-used"}] }, - { code: "function g(bar, baz) { return bar; }; g();", options: [{"vars": "all", "args": "none"}] }, - { code: "function g(bar, baz) { return 2; }; g();", options: [{"vars": "all", "args": "none"}] }, - { code: "function g(bar, baz) { return bar + baz; }; g();", options: [{"vars": "local", "args": "all"}] }, - { code: "var g = function(bar, baz) { return 2; }; g();", options: [{"vars": "all", "args": "none"}] }, + { code: "function g(bar, baz) { return baz; }; g();", options: [{vars: "all"}] }, + { code: "function g(bar, baz) { return baz; }; g();", options: [{vars: "all", args: "after-used"}] }, + { code: "function g(bar, baz) { return bar; }; g();", options: [{vars: "all", args: "none"}] }, + { code: "function g(bar, baz) { return 2; }; g();", options: [{vars: "all", args: "none"}] }, + { code: "function g(bar, baz) { return bar + baz; }; g();", options: [{vars: "local", args: "all"}] }, + { code: "var g = function(bar, baz) { return 2; }; g();", options: [{vars: "all", args: "none"}] }, "(function z() { z(); })();", { code: " ", globals: {a: true} }, { code: "var who = \"Paul\";\nmodule.exports = `Hello ${who}!`;", parserOptions: { ecmaVersion: 6 }}, @@ -169,11 +169,11 @@ ruleTester.run("no-unused-vars", rule, { { code: "var min = Math.min", options: ["all"], errors: [{ message: "'min' is defined but never used" }] }, { code: "var min = {min: 1}", options: ["all"], errors: [{ message: "'min' is defined but never used" }] }, { code: "Foo.bar = function(baz) { return 1; };", options: ["all"], errors: [{ message: "'baz' is defined but never used" }] }, - { code: "var min = {min: 1}", options: [{"vars": "all"}], errors: [{ message: "'min' is defined but never used" }] }, - { code: "function gg(baz, bar) { return baz; }; gg();", options: [{"vars": "all"}], errors: [{ message: "'bar' is defined but never used" }] }, - { code: "(function(foo, baz, bar) { return baz; })();", options: [{"vars": "all", "args": "after-used"}], errors: [{ message: "'bar' is defined but never used" }]}, - { code: "(function(foo, baz, bar) { return baz; })();", options: [{"vars": "all", "args": "all"}], errors: [{ message: "'foo' is defined but never used" }, { message: "'bar' is defined but never used" }]}, - { code: "(function z(foo) { var bar = 33; })();", options: [{"vars": "all", "args": "all"}], errors: [{ message: "'foo' is defined but never used" }, { message: "'bar' is defined but never used" }]}, + { code: "var min = {min: 1}", options: [{vars: "all"}], errors: [{ message: "'min' is defined but never used" }] }, + { code: "function gg(baz, bar) { return baz; }; gg();", options: [{vars: "all"}], errors: [{ message: "'bar' is defined but never used" }] }, + { code: "(function(foo, baz, bar) { return baz; })();", options: [{vars: "all", args: "after-used"}], errors: [{ message: "'bar' is defined but never used" }]}, + { code: "(function(foo, baz, bar) { return baz; })();", options: [{vars: "all", args: "all"}], errors: [{ message: "'foo' is defined but never used" }, { message: "'bar' is defined but never used" }]}, + { code: "(function z(foo) { var bar = 33; })();", options: [{vars: "all", args: "all"}], errors: [{ message: "'foo' is defined but never used" }, { message: "'bar' is defined but never used" }]}, { code: "(function z(foo) { z(); })();", options: [{}], errors: [{ message: "'foo' is defined but never used" }]}, { code: "function f() { var a = 1; return function(){ f(a = 2); }; }", options: [{}], errors: [{ message: "'f' is defined but never used" }, {message: "'a' is defined but never used"}]}, { code: "import x from \"y\";", parserOptions: { sourceType: "module" }, errors: [{ message: "'x' is defined but never used" }]}, @@ -291,26 +291,26 @@ ruleTester.run("no-unused-vars", rule, { // caughtErrors { code: "try{}catch(err){};", - options: [{"caughtErrors": "all"}], + options: [{caughtErrors: "all"}], errors: [{message: "'err' is defined but never used"}] }, { code: "try{}catch(err){};", - options: [{"caughtErrors": "all", "caughtErrorsIgnorePattern": "^ignore"}], + options: [{caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore"}], errors: [{message: "'err' is defined but never used"}] }, // multiple try catch with one success { code: "try{}catch(ignoreErr){}try{}catch(err){};", - options: [{"caughtErrors": "all", "caughtErrorsIgnorePattern": "^ignore"}], + options: [{caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore"}], errors: [{message: "'err' is defined but never used"}] }, // multiple try catch both fail { code: "try{}catch(error){}try{}catch(err){};", - options: [{"caughtErrors": "all", "caughtErrorsIgnorePattern": "^ignore"}], + options: [{caughtErrors: "all", caughtErrorsIgnorePattern: "^ignore"}], errors: [ {message: "'error' is defined but never used"}, {message: "'err' is defined but never used"} diff --git a/tests/lib/rules/no-warning-comments.js b/tests/lib/rules/no-warning-comments.js index ccccc3b4a18..cd4016b2b8a 100644 --- a/tests/lib/rules/no-warning-comments.js +++ b/tests/lib/rules/no-warning-comments.js @@ -20,43 +20,43 @@ var ruleTester = new RuleTester(); ruleTester.run("no-warning-comments", rule, { valid: [ - { code: "// any comment", options: [{ "terms": ["fixme"] } ] }, - { code: "// any comment", options: [{ "terms": ["fixme", "todo"] } ] }, + { code: "// any comment", options: [{ terms: ["fixme"] } ] }, + { code: "// any comment", options: [{ terms: ["fixme", "todo"] } ] }, { code: "// any comment", args: [1] }, - { code: "// any comment", options: [{ "location": "anywhere" } ] }, - { code: "// any comment with TODO, FIXME or XXX", options: [{ "location": "start" } ] }, + { code: "// any comment", options: [{ location: "anywhere" } ] }, + { code: "// any comment with TODO, FIXME or XXX", options: [{ location: "start" } ] }, { code: "// any comment with TODO, FIXME or XXX", args: [1] }, { code: "// any comment with TODO, FIXME or XXX", args: 1 }, - { code: "/* any block comment */", options: [{ "terms": ["fixme"] } ] }, - { code: "/* any block comment */", options: [{ "terms": ["fixme", "todo"] } ] }, + { code: "/* any block comment */", options: [{ terms: ["fixme"] } ] }, + { code: "/* any block comment */", options: [{ terms: ["fixme", "todo"] } ] }, { code: "/* any block comment */", args: [1] }, - { code: "/* any block comment */", options: [{ "location": "anywhere" } ] }, - { code: "/* any block comment with TODO, FIXME or XXX */", options: [{ "location": "start" } ] }, + { code: "/* any block comment */", options: [{ location: "anywhere" } ] }, + { code: "/* any block comment with TODO, FIXME or XXX */", options: [{ location: "start" } ] }, { code: "/* any block comment with TODO, FIXME or XXX */", args: [1] }, { code: "/* any block comment with TODO, FIXME or XXX */", args: 1 }, { code: "/* any block comment with (TODO, FIXME's or XXX!) */", args: 1 }, - { code: "// comments containing terms as substrings like TodoMVC", options: [{ "terms": ["todo"], "location": "anywhere" } ] }, - { code: "// special regex characters don't cause problems", options: [{ "terms": ["[aeiou]"], "location": "anywhere" } ] }, + { code: "// comments containing terms as substrings like TodoMVC", options: [{ terms: ["todo"], location: "anywhere" } ] }, + { code: "// special regex characters don't cause problems", options: [{ terms: ["[aeiou]"], location: "anywhere" } ] }, { code: "/*eslint no-warning-comments: [2, { \"terms\": [\"todo\", \"fixme\", \"any other term\"], \"location\": \"anywhere\" }]*/\n\nvar x = 10;\n" }, - { code: "/*eslint no-warning-comments: [2, { \"terms\": [\"todo\", \"fixme\", \"any other term\"], \"location\": \"anywhere\" }]*/\n\nvar x = 10;\n", options: [{ "location": "anywhere" }] } + { code: "/*eslint no-warning-comments: [2, { \"terms\": [\"todo\", \"fixme\", \"any other term\"], \"location\": \"anywhere\" }]*/\n\nvar x = 10;\n", options: [{ location: "anywhere" }] } ], invalid: [ { code: "// fixme", args: [1], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "// any fixme", options: [{ "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "// any fixme", options: [{ "terms": ["fixme"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "// any FIXME", options: [{ "terms": ["fixme"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "// any fIxMe", options: [{ "terms": ["fixme"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "/* any fixme */", options: [{ "terms": ["FIXME"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'FIXME' comment." } ] }, - { code: "/* any FIXME */", options: [{ "terms": ["FIXME"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'FIXME' comment." } ] }, - { code: "/* any fIxMe */", options: [{ "terms": ["FIXME"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'FIXME' comment." } ] }, - { code: "// any fixme or todo", options: [{ "terms": ["fixme", "todo"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." }, { message: "Unexpected 'todo' comment." } ] }, - { code: "/* any fixme or todo */", options: [{ "terms": ["fixme", "todo"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." }, { message: "Unexpected 'todo' comment." } ] }, - { code: "/* any fixme or todo */", options: [{ "location": "anywhere" } ], errors: [ { message: "Unexpected 'todo' comment." }, { message: "Unexpected 'fixme' comment." } ] }, + { code: "// any fixme", options: [{ location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, + { code: "// any fixme", options: [{ terms: ["fixme"], location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, + { code: "// any FIXME", options: [{ terms: ["fixme"], location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, + { code: "// any fIxMe", options: [{ terms: ["fixme"], location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, + { code: "/* any fixme */", options: [{ terms: ["FIXME"], location: "anywhere" } ], errors: [ { message: "Unexpected 'FIXME' comment." } ] }, + { code: "/* any FIXME */", options: [{ terms: ["FIXME"], location: "anywhere" } ], errors: [ { message: "Unexpected 'FIXME' comment." } ] }, + { code: "/* any fIxMe */", options: [{ terms: ["FIXME"], location: "anywhere" } ], errors: [ { message: "Unexpected 'FIXME' comment." } ] }, + { code: "// any fixme or todo", options: [{ terms: ["fixme", "todo"], location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." }, { message: "Unexpected 'todo' comment." } ] }, + { code: "/* any fixme or todo */", options: [{ terms: ["fixme", "todo"], location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." }, { message: "Unexpected 'todo' comment." } ] }, + { code: "/* any fixme or todo */", options: [{ location: "anywhere" } ], errors: [ { message: "Unexpected 'todo' comment." }, { message: "Unexpected 'fixme' comment." } ] }, { code: "/* fixme and todo */", args: [1], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "/* any fixme */", options: [{ "location": "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "/* fixme! */", options: [{ "terms": ["fixme"] } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, - { code: "// regex [litera|$]", options: [{ "terms": ["[litera|$]"], "location": "anywhere" } ], errors: [ { message: "Unexpected '[litera|$]' comment." } ] }, - { code: "/* eslint one-var: 2 */", options: [{ "terms": ["eslint"] } ], errors: [ { message: "Unexpected 'eslint' comment." } ] }, - { code: "/* eslint one-var: 2 */", options: [{ "terms": ["one"], "location": "anywhere" } ], errors: [ { message: "Unexpected 'one' comment." } ] } + { code: "/* any fixme */", options: [{ location: "anywhere" } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, + { code: "/* fixme! */", options: [{ terms: ["fixme"] } ], errors: [ { message: "Unexpected 'fixme' comment." } ] }, + { code: "// regex [litera|$]", options: [{ terms: ["[litera|$]"], location: "anywhere" } ], errors: [ { message: "Unexpected '[litera|$]' comment." } ] }, + { code: "/* eslint one-var: 2 */", options: [{ terms: ["eslint"] } ], errors: [ { message: "Unexpected 'eslint' comment." } ] }, + { code: "/* eslint one-var: 2 */", options: [{ terms: ["one"], location: "anywhere" } ], errors: [ { message: "Unexpected 'one' comment." } ] } ] }); diff --git a/tests/lib/rules/object-curly-spacing.js b/tests/lib/rules/object-curly-spacing.js index 1c78e172f1e..94ec5757169 100644 --- a/tests/lib/rules/object-curly-spacing.js +++ b/tests/lib/rules/object-curly-spacing.js @@ -59,18 +59,18 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var foo = {};", options: ["always"] }, // always - objectsInObjects - { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }};", options: ["always", {"objectsInObjects": false}] }, - { code: "var a = { noop: function () {} };", options: ["always", {"objectsInObjects": false}] }, + { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }};", options: ["always", {objectsInObjects: false}] }, + { code: "var a = { noop: function () {} };", options: ["always", {objectsInObjects: false}] }, // always - arraysInObjects - { code: "var obj = { 'foo': [ 1, 2 ]};", options: ["always", {"arraysInObjects": false}] }, - { code: "var a = { thingInList: list[0] };", options: ["always", {"arraysInObjects": false}] }, + { code: "var obj = { 'foo': [ 1, 2 ]};", options: ["always", {arraysInObjects: false}] }, + { code: "var a = { thingInList: list[0] };", options: ["always", {arraysInObjects: false}] }, // always - arraysInObjects, objectsInObjects - { code: "var obj = { 'qux': [ 1, 2 ], 'foo': { 'bar': 1, 'baz': 2 }};", options: ["always", {"arraysInObjects": false, "objectsInObjects": false}] }, + { code: "var obj = { 'qux': [ 1, 2 ], 'foo': { 'bar': 1, 'baz': 2 }};", options: ["always", {arraysInObjects: false, objectsInObjects: false}] }, // always - arraysInObjects, objectsInObjects (reverse) - { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }, 'qux': [ 1, 2 ]};", options: ["always", {"arraysInObjects": false, "objectsInObjects": false}] }, + { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }, 'qux': [ 1, 2 ]};", options: ["always", {arraysInObjects: false, objectsInObjects: false}] }, // never { code: "var obj = {foo: bar,\nbaz: qux\n};", options: ["never"] }, @@ -120,7 +120,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var foo = {};", options: ["never"] }, // never - objectsInObjects - { code: "var obj = {'foo': {'bar': 1, 'baz': 2} };", options: ["never", {"objectsInObjects": true}]}, + { code: "var obj = {'foo': {'bar': 1, 'baz': 2} };", options: ["never", {objectsInObjects: true}]}, // https://github.com/eslint/eslint/issues/3658 // Empty cases. @@ -346,7 +346,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = { 'foo': [ 1, 2 ] };", output: "var obj = { 'foo': [ 1, 2 ]};", - options: ["always", {"arraysInObjects": false}], + options: ["always", {arraysInObjects: false}], errors: [ { message: "There should be no space before '}'", @@ -357,7 +357,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = { 'foo': [ 1, 2 ] , 'bar': [ 'baz', 'qux' ] };", output: "var obj = { 'foo': [ 1, 2 ] , 'bar': [ 'baz', 'qux' ]};", - options: ["always", {"arraysInObjects": false}], + options: ["always", {arraysInObjects: false}], errors: [ { message: "There should be no space before '}'", @@ -370,7 +370,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 } };", output: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }};", - options: ["always", {"objectsInObjects": false}], + options: ["always", {objectsInObjects: false}], errors: [ { message: "There should be no space before '}'", @@ -383,7 +383,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = { 'foo': [ 1, 2 ] , 'bar': { 'baz': 1, 'qux': 2 } };", output: "var obj = { 'foo': [ 1, 2 ] , 'bar': { 'baz': 1, 'qux': 2 }};", - options: ["always", {"objectsInObjects": false}], + options: ["always", {objectsInObjects: false}], errors: [ { message: "There should be no space before '}'", @@ -462,7 +462,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = {'foo': {'bar': 1, 'baz': 2}};", output: "var obj = {'foo': {'bar': 1, 'baz': 2} };", - options: ["never", {"objectsInObjects": true}], + options: ["never", {objectsInObjects: true}], errors: [ { message: "A space is required before '}'", @@ -475,7 +475,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = {'foo': [1, 2] , 'bar': {'baz': 1, 'qux': 2}};", output: "var obj = {'foo': [1, 2] , 'bar': {'baz': 1, 'qux': 2} };", - options: ["never", {"objectsInObjects": true}], + options: ["never", {objectsInObjects: true}], errors: [ { message: "A space is required before '}'", @@ -732,7 +732,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = {'foo': [1, 2]};", output: "var obj = {'foo': [1, 2] };", - options: ["never", {"arraysInObjects": true}], + options: ["never", {arraysInObjects: true}], errors: [ { message: "A space is required before '}'", @@ -743,7 +743,7 @@ ruleTester.run("object-curly-spacing", rule, { { code: "var obj = {'foo': [1, 2] , 'bar': ['baz', 'qux']};", output: "var obj = {'foo': [1, 2] , 'bar': ['baz', 'qux'] };", - options: ["never", {"arraysInObjects": true}], + options: ["never", {arraysInObjects: true}], errors: [ { message: "A space is required before '}'", diff --git a/tests/lib/rules/object-shorthand.js b/tests/lib/rules/object-shorthand.js index bbaf51f114b..27c450eef8b 100644 --- a/tests/lib/rules/object-shorthand.js +++ b/tests/lib/rules/object-shorthand.js @@ -74,10 +74,10 @@ ruleTester.run("object-shorthand", rule, { { code: "var x = {a: function(){}, b: {c: d}}", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, // ignoreConstructors - { code: "var x = {ConstructorFunction: function(){}, a: b}", parserOptions: { ecmaVersion: 6 }, options: ["always", { "ignoreConstructors": true }] }, - { code: "var x = {notConstructorFunction(){}, b: c}", parserOptions: { ecmaVersion: 6 }, options: ["always", { "ignoreConstructors": true }] }, - { code: "var x = {ConstructorFunction: function(){}, a: b}", parserOptions: { ecmaVersion: 6 }, options: ["methods", { "ignoreConstructors": true }] }, - { code: "var x = {notConstructorFunction(){}, b: c}", parserOptions: { ecmaVersion: 6 }, options: ["methods", { "ignoreConstructors": true }] }, + { code: "var x = {ConstructorFunction: function(){}, a: b}", parserOptions: { ecmaVersion: 6 }, options: ["always", { ignoreConstructors: true }] }, + { code: "var x = {notConstructorFunction(){}, b: c}", parserOptions: { ecmaVersion: 6 }, options: ["always", { ignoreConstructors: true }] }, + { code: "var x = {ConstructorFunction: function(){}, a: b}", parserOptions: { ecmaVersion: 6 }, options: ["methods", { ignoreConstructors: true }] }, + { code: "var x = {notConstructorFunction(){}, b: c}", parserOptions: { ecmaVersion: 6 }, options: ["methods", { ignoreConstructors: true }] }, { code: "var x = {ConstructorFunction: function(){}, a: b}", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, { code: "var x = {notConstructorFunction: function(){}, b: c}", parserOptions: { ecmaVersion: 6 }, options: ["never"] }, diff --git a/tests/lib/rules/one-var.js b/tests/lib/rules/one-var.js index 04a18c73fe8..f9d7944ee3b 100644 --- a/tests/lib/rules/one-var.js +++ b/tests/lib/rules/one-var.js @@ -400,7 +400,7 @@ ruleTester.run("one-var", rule, { }, { code: "var i = [0], j;", - options: [ { "initialized": "never" } ], + options: [ { initialized: "never" } ], errors: [ { message: "Split initialized 'var' declarations into multiple statements.", type: "VariableDeclaration" @@ -408,7 +408,7 @@ ruleTester.run("one-var", rule, { }, { code: "var i = [0], j;", - options: [ { "uninitialized": "never" } ], + options: [ { uninitialized: "never" } ], errors: [ { message: "Split uninitialized 'var' declarations into multiple statements.", type: "VariableDeclaration" diff --git a/tests/lib/rules/padded-blocks.js b/tests/lib/rules/padded-blocks.js index 48305921355..9dfae7d6e2e 100644 --- a/tests/lib/rules/padded-blocks.js +++ b/tests/lib/rules/padded-blocks.js @@ -32,28 +32,28 @@ ruleTester.run("padded-blocks", rule, { {code: "{//comment\n\na();\n\n}" }, {code: "{\n\na();\n\n/* comment */ }" }, {code: "{\n\na();\n\n/* comment */ }", options: ["always"]}, - {code: "{\n\na();\n\n/* comment */ }", options: [{"blocks": "always"}]}, + {code: "{\n\na();\n\n/* comment */ }", options: [{blocks: "always"}]}, // Ignore switches by default {code: "switch (a) {\n\ncase 0: foo();\ncase 1: bar();\n\n}", options: ["always"]}, {code: "switch (a) {\n\ncase 0: foo();\ncase 1: bar();\n\n}", options: ["never"]}, // Ignore block statements if not configured - {code: "{\na();\n}", options: [{"switches": "always"}]}, - {code: "{\n\na();\n\n}", options: [{"switches": "never"}]}, + {code: "{\na();\n}", options: [{switches: "always"}]}, + {code: "{\n\na();\n\n}", options: [{switches: "never"}]}, - {code: "switch (a) {}", options: [{"switches": "always"}]}, - {code: "switch (a) {\n\ncase 0: foo();\ncase 1: bar();\n\n}", options: [{"switches": "always"}]}, - {code: "switch (a) {\n\n//comment\ncase 0: foo();//comment\n\n}", options: [{"switches": "always"}]}, - {code: "switch (a) {//coment\n\ncase 0: foo();\ncase 1: bar();\n\n/* comment */}", options: [{"switches": "always"}]}, + {code: "switch (a) {}", options: [{switches: "always"}]}, + {code: "switch (a) {\n\ncase 0: foo();\ncase 1: bar();\n\n}", options: [{switches: "always"}]}, + {code: "switch (a) {\n\n//comment\ncase 0: foo();//comment\n\n}", options: [{switches: "always"}]}, + {code: "switch (a) {//coment\n\ncase 0: foo();\ncase 1: bar();\n\n/* comment */}", options: [{switches: "always"}]}, // Ignore classes by default {code: "class A{\nfoo(){}\n}", parserOptions: { ecmaVersion: 6 }}, {code: "class A{\n\nfoo(){}\n\n}", parserOptions: { ecmaVersion: 6 }}, - {code: "class A{}", parserOptions: { ecmaVersion: 6 }, options: [{"classes": "always"}]}, - {code: "class A{\n\n}", parserOptions: { ecmaVersion: 6 }, options: [{"classes": "always"}]}, - {code: "class A{\n\nfoo(){}\n\n}", parserOptions: { ecmaVersion: 6 }, options: [{"classes": "always"}]}, + {code: "class A{}", parserOptions: { ecmaVersion: 6 }, options: [{classes: "always"}]}, + {code: "class A{\n\n}", parserOptions: { ecmaVersion: 6 }, options: [{classes: "always"}]}, + {code: "class A{\n\nfoo(){}\n\n}", parserOptions: { ecmaVersion: 6 }, options: [{classes: "always"}]}, {code: "{\na();\n}", options: ["never"]}, {code: "{\na();}", options: ["never"]}, @@ -69,9 +69,9 @@ ruleTester.run("padded-blocks", rule, { {code: "{\n// comment\ndebugger;\n// comment\n}", options: ["never"] }, {code: "{\n\n// comment\nif (\n// comment\n a) {}\n\n }", options: ["always"] }, {code: "{\n// comment\nif (\n// comment\n a) {}\n }", options: ["never"] }, - {code: "{\n// comment\nif (\n// comment\n a) {}\n }", options: [{"blocks": "never"}] }, - {code: "switch (a) {\ncase 0: foo();\n}", options: [{"switches": "never"}]}, - {code: "class A{\nfoo(){}\n}", parserOptions: { ecmaVersion: 6 }, options: [{"classes": "never"}]} + {code: "{\n// comment\nif (\n// comment\n a) {}\n }", options: [{blocks: "never"}] }, + {code: "switch (a) {\ncase 0: foo();\n}", options: [{switches: "never"}]}, + {code: "class A{\nfoo(){}\n}", parserOptions: { ecmaVersion: 6 }, options: [{classes: "never"}]} ], invalid: [ { @@ -163,7 +163,7 @@ ruleTester.run("padded-blocks", rule, { }, { code: "{a();\n}", - options: [{"blocks": "always"}], + options: [{blocks: "always"}], errors: [ { message: ALWAYS_MESSAGE, @@ -177,7 +177,7 @@ ruleTester.run("padded-blocks", rule, { }, { code: "switch (a) {\ncase 0: foo();\ncase 1: bar();\n}", - options: [{"switches": "always"}], + options: [{switches: "always"}], errors: [ { message: ALWAYS_MESSAGE, @@ -193,7 +193,7 @@ ruleTester.run("padded-blocks", rule, { }, { code: "switch (a) {\n//comment\ncase 0: foo();//comment\n}", - options: [{"switches": "always"}], + options: [{switches: "always"}], errors: [ { message: ALWAYS_MESSAGE, @@ -210,7 +210,7 @@ ruleTester.run("padded-blocks", rule, { { code: "class A {\nconstructor(){}\n}", parserOptions: { ecmaVersion: 6 }, - options: [{"classes": "always"}], + options: [{classes: "always"}], errors: [ { message: ALWAYS_MESSAGE, @@ -319,7 +319,7 @@ ruleTester.run("padded-blocks", rule, { }, { code: "{\n\n// comment\nif (\n// comment\n a) {}\n}", - options: [{"blocks": "never"}], + options: [{blocks: "never"}], errors: [ { message: NEVER_MESSAGE, @@ -330,7 +330,7 @@ ruleTester.run("padded-blocks", rule, { }, { code: "switch (a) {\n\ncase 0: foo();\n}", - options: [{"switches": "never"}], + options: [{switches: "never"}], errors: [ { message: NEVER_MESSAGE, @@ -341,7 +341,7 @@ ruleTester.run("padded-blocks", rule, { }, { code: "switch (a) {\ncase 0: foo();\n\n }", - options: [{"switches": "never"}], + options: [{switches: "never"}], errors: [ { message: NEVER_MESSAGE, @@ -353,7 +353,7 @@ ruleTester.run("padded-blocks", rule, { { code: "class A {\n\nconstructor(){\n\nfoo();\n\n}\n\n}", parserOptions: { ecmaVersion: 6 }, - options: [{"classes": "never"}], + options: [{classes: "never"}], errors: [ { message: NEVER_MESSAGE, @@ -368,7 +368,7 @@ ruleTester.run("padded-blocks", rule, { { code: "class A {\n\nconstructor(){\n\nfoo();\n\n}\n\n}", parserOptions: { ecmaVersion: 6 }, - options: [{"blocks": "never", "classes": "never"}], + options: [{blocks: "never", classes: "never"}], errors: [ { message: NEVER_MESSAGE, diff --git a/tests/lib/rules/quote-props.js b/tests/lib/rules/quote-props.js index ac7f0b753ae..76187003666 100644 --- a/tests/lib/rules/quote-props.js +++ b/tests/lib/rules/quote-props.js @@ -61,10 +61,10 @@ ruleTester.run("quote-props", rule, { { code: "({ '@': 0, 'B': 0 })", options: ["consistent-as-needed"] }, { code: "({ 'while': 0, 'B': 0 })", options: ["consistent-as-needed", {keywords: true}] }, { code: "({ '@': 0, 'B': 0 })", options: ["consistent-as-needed", {keywords: true}] }, - { code: "({ '@': 1, [x]: 0 });", env: {"es6": true}, options: ["consistent-as-needed"]}, - { code: "({ '@': 1, x });", env: {"es6": true}, options: ["consistent-as-needed"]}, - { code: "({ a: 1, [x]: 0 });", env: {"es6": true}, options: ["consistent-as-needed"]}, - { code: "({ a: 1, x });", env: {"es6": true}, options: ["consistent-as-needed"]}, + { code: "({ '@': 1, [x]: 0 });", env: {es6: true}, options: ["consistent-as-needed"]}, + { code: "({ '@': 1, x });", env: {es6: true}, options: ["consistent-as-needed"]}, + { code: "({ a: 1, [x]: 0 });", env: {es6: true}, options: ["consistent-as-needed"]}, + { code: "({ a: 1, x });", env: {es6: true}, options: ["consistent-as-needed"]}, { code: "({ a: 0, 'if': 0 })", options: ["as-needed", {keywords: true}] }, { code: "({ a: 0, 'while': 0 })", options: ["as-needed", {keywords: true}] }, { code: "({ a: 0, 'volatile': 0 })", options: ["as-needed", {keywords: true}] }, @@ -136,14 +136,14 @@ ruleTester.run("quote-props", rule, { }] }, { code: "({ 'a': 0, [x]: 0 })", - env: {"es6": true}, + env: {es6: true}, options: ["consistent-as-needed"], errors: [{ message: "Properties shouldn't be quoted as all quotes are redundant.", type: "ObjectExpression" }] }, { code: "({ 'a': 0, x })", - env: {"es6": true}, + env: {es6: true}, options: ["consistent-as-needed"], errors: [{ message: "Properties shouldn't be quoted as all quotes are redundant.", type: "ObjectExpression" diff --git a/tests/lib/rules/require-jsdoc.js b/tests/lib/rules/require-jsdoc.js index fc797306468..e2c80e880fc 100644 --- a/tests/lib/rules/require-jsdoc.js +++ b/tests/lib/rules/require-jsdoc.js @@ -46,20 +46,20 @@ ruleTester.run("require-jsdoc", rule, { { code: "function myFunction() {}", options: [{ - "require": { - "FunctionDeclaration": false, - "MethodDefinition": true, - "ClassDeclaration": true + require: { + FunctionDeclaration: false, + MethodDefinition: true, + ClassDeclaration: true } }] }, { code: "var myFunction = function() {}", options: [{ - "require": { - "FunctionDeclaration": false, - "MethodDefinition": true, - "ClassDeclaration": true + require: { + FunctionDeclaration: false, + MethodDefinition: true, + ClassDeclaration: true } }] }, @@ -79,9 +79,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6 }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }] }, @@ -101,9 +101,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6 }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }] }, @@ -123,9 +123,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6, sourceType: "module" }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }] }, @@ -145,9 +145,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6, sourceType: "module" }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }] }, @@ -160,9 +160,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6 }, options: [{ - "require": { - "MethodDefinition": false, - "ClassDeclaration": false + require: { + MethodDefinition: false, + ClassDeclaration: false } }] } @@ -188,9 +188,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6 }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }], errors: [{ @@ -211,9 +211,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6 }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }], errors: [{ @@ -234,9 +234,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { ecmaVersion: 6 }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }], errors: [{ @@ -257,9 +257,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { sourceType: "module" }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }], errors: [{ @@ -280,9 +280,9 @@ ruleTester.run("require-jsdoc", rule, { "}", parserOptions: { sourceType: "module" }, options: [{ - "require": { - "MethodDefinition": true, - "ClassDeclaration": true + require: { + MethodDefinition: true, + ClassDeclaration: true } }], errors: [{ diff --git a/tests/lib/rules/semi.js b/tests/lib/rules/semi.js index 4b58332a0bd..999627fc6ed 100644 --- a/tests/lib/rules/semi.js +++ b/tests/lib/rules/semi.js @@ -45,8 +45,8 @@ ruleTester.run("semi", rule, { { code: "do{}while(true)", options: ["never"] }, { code: "do{}while(true);", options: ["always"] }, - { code: "if (foo) { bar() }", options: ["always", { "omitLastInOneLineBlock": true}] }, - { code: "if (foo) { bar(); baz() }", options: ["always", { "omitLastInOneLineBlock": true}] }, + { code: "if (foo) { bar() }", options: ["always", { omitLastInOneLineBlock: true}] }, + { code: "if (foo) { bar(); baz() }", options: ["always", { omitLastInOneLineBlock: true}] }, // method definitions don't have a semicolon. @@ -135,10 +135,10 @@ ruleTester.run("semi", rule, { { code: "import theDefault, { named1, named2 } from 'src/mylib';", output: "import theDefault, { named1, named2 } from 'src/mylib'", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ImportDeclaration"}] }, { code: "do{}while(true);", output: "do{}while(true)", options: ["never"], errors: [{ message: "Extra semicolon.", type: "DoWhileStatement", line: 1}] }, - { code: "if (foo) { bar()\n }", options: ["always", { "omitLastInOneLineBlock": true}], errors: [{ message: "Missing semicolon."}] }, - { code: "if (foo) {\n bar() }", options: ["always", { "omitLastInOneLineBlock": true}], errors: [{ message: "Missing semicolon."}] }, - { code: "if (foo) {\n bar(); baz() }", options: ["always", { "omitLastInOneLineBlock": true}], errors: [{ message: "Missing semicolon."}] }, - { code: "if (foo) { bar(); }", options: ["always", { "omitLastInOneLineBlock": true}], errors: [{ message: "Extra semicolon."}] }, + { code: "if (foo) { bar()\n }", options: ["always", { omitLastInOneLineBlock: true}], errors: [{ message: "Missing semicolon."}] }, + { code: "if (foo) {\n bar() }", options: ["always", { omitLastInOneLineBlock: true}], errors: [{ message: "Missing semicolon."}] }, + { code: "if (foo) {\n bar(); baz() }", options: ["always", { omitLastInOneLineBlock: true}], errors: [{ message: "Missing semicolon."}] }, + { code: "if (foo) { bar(); }", options: ["always", { omitLastInOneLineBlock: true}], errors: [{ message: "Extra semicolon."}] }, // exports, "always" diff --git a/tests/lib/rules/space-unary-ops.js b/tests/lib/rules/space-unary-ops.js index 435def39599..2123ec7659d 100644 --- a/tests/lib/rules/space-unary-ops.js +++ b/tests/lib/rules/space-unary-ops.js @@ -22,107 +22,107 @@ ruleTester.run("space-unary-ops", rule, { valid: [ { code: "++this.a", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "--this.a", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "this.a++", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "this.a--", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "delete foo.bar", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "delete foo[\"bar\"]", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "new Foo", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "new Foo()", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "new [foo][0]", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "new[foo][0]", - options: [{ "words": false }] + options: [{ words: false }] }, { code: "typeof foo", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "typeof{foo:true}", - options: [{ "words": false }] + options: [{ words: false }] }, { code: "typeof {foo:true}", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "typeof!foo", - options: [{ "words": false }] + options: [{ words: false }] }, { code: "void 0", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "(void 0)", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "(void (0))", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "void foo", - options: [{ "words": true }] + options: [{ words: true }] }, { code: "-1", - options: [{ "nonwords": false }] + options: [{ nonwords: false }] }, { code: "!foo", - options: [{ "nonwords": false }] + options: [{ nonwords: false }] }, { code: "!!foo", - options: [{ "nonwords": false }] + options: [{ nonwords: false }] }, { code: "foo++", - options: [{ "nonwords": false }] + options: [{ nonwords: false }] }, { code: "foo ++", - options: [{ "nonwords": true }] + options: [{ nonwords: true }] }, { code: "++foo", - options: [{ "nonwords": false }] + options: [{ nonwords: false }] }, { code: "++ foo", - options: [{ "nonwords": true }] + options: [{ nonwords: true }] }, { code: "function *foo () { yield (0) }", @@ -158,44 +158,44 @@ ruleTester.run("space-unary-ops", rule, { }, { code: "foo++", - options: [{ "nonwords": true, "overrides": {"++": false} }] + options: [{ nonwords: true, overrides: {"++": false} }] }, { code: "foo++", - options: [{ "nonwords": false, "overrides": {"++": false} }] + options: [{ nonwords: false, overrides: {"++": false} }] }, { code: "++foo", - options: [{ "nonwords": true, "overrides": {"++": false} }] + options: [{ nonwords: true, overrides: {"++": false} }] }, { code: "++foo", - options: [{ "nonwords": false, "overrides": {"++": false} }] + options: [{ nonwords: false, overrides: {"++": false} }] }, { code: "!foo", - options: [{ "nonwords": true, "overrides": {"!": false} }] + options: [{ nonwords: true, overrides: {"!": false} }] }, { code: "!foo", - options: [{ "nonwords": false, "overrides": {"!": false} }] + options: [{ nonwords: false, overrides: {"!": false} }] }, { code: "new foo", - options: [{ "words": true, "overrides": {"new": false} }] + options: [{ words: true, overrides: {new: false} }] }, { code: "new foo", - options: [{ "words": false, "overrides": {"new": false} }] + options: [{ words: false, overrides: {new: false} }] }, { code: "function *foo () { yield (0) }", - options: [{ "words": true, "overrides": {"yield": false} }], + options: [{ words: true, overrides: {yield: false} }], parserOptions: { ecmaVersion: 6 } }, { code: "function *foo () { yield (0) }", - options: [{ "words": false, "overrides": {"yield": false} }], + options: [{ words: false, overrides: {yield: false} }], parserOptions: { ecmaVersion: 6 } } ], @@ -204,7 +204,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "delete(foo.bar)", output: "delete (foo.bar)", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'delete' must be followed by whitespace.", type: "UnaryExpression" @@ -213,7 +213,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "delete(foo[\"bar\"]);", output: "delete (foo[\"bar\"]);", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'delete' must be followed by whitespace.", type: "UnaryExpression" @@ -222,7 +222,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "new(Foo)", output: "new (Foo)", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'new' must be followed by whitespace.", type: "NewExpression" @@ -231,7 +231,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "new(Foo())", output: "new (Foo())", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'new' must be followed by whitespace.", type: "NewExpression" @@ -241,7 +241,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "typeof(foo)", output: "typeof (foo)", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'typeof' must be followed by whitespace.", type: "UnaryExpression" @@ -250,7 +250,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "typeof{foo:true}", output: "typeof {foo:true}", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'typeof' must be followed by whitespace.", type: "UnaryExpression" @@ -259,7 +259,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "typeof {foo:true}", output: "typeof{foo:true}", - options: [{ "words": false }], + options: [{ words: false }], errors: [{ message: "Unexpected space after unary word operator 'typeof'.", type: "UnaryExpression" @@ -268,7 +268,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "typeof!foo", output: "typeof !foo", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'typeof' must be followed by whitespace.", type: "UnaryExpression" @@ -278,7 +278,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "void(0);", output: "void (0);", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'void' must be followed by whitespace.", type: "UnaryExpression" @@ -287,7 +287,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "void(foo);", output: "void (foo);", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'void' must be followed by whitespace.", type: "UnaryExpression" @@ -296,7 +296,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "void{a:0};", output: "void {a:0};", - options: [{ "words": true }], + options: [{ words: true }], errors: [{ message: "Unary word operator 'void' must be followed by whitespace.", type: "UnaryExpression" @@ -306,7 +306,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "! foo", output: "!foo", - options: [{ "nonwords": false }], + options: [{ nonwords: false }], errors: [{ message: "Unexpected space after unary operator '!'." }] @@ -314,7 +314,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "!foo", output: "! foo", - options: [{ "nonwords": true }], + options: [{ nonwords: true }], errors: [{ message: "Unary operator '!' must be followed by whitespace." }] @@ -323,7 +323,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "!! foo", output: "!!foo", - options: [{ "nonwords": false }], + options: [{ nonwords: false }], errors: [{ message: "Unexpected space after unary operator '!'.", type: "UnaryExpression", @@ -334,7 +334,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "!!foo", output: "!! foo", - options: [{ "nonwords": true }], + options: [{ nonwords: true }], errors: [{ message: "Unary operator '!' must be followed by whitespace.", type: "UnaryExpression", @@ -346,7 +346,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "- 1", output: "-1", - options: [{ "nonwords": false }], + options: [{ nonwords: false }], errors: [{ message: "Unexpected space after unary operator '-'.", type: "UnaryExpression" @@ -355,7 +355,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "-1", output: "- 1", - options: [{ "nonwords": true }], + options: [{ nonwords: true }], errors: [{ message: "Unary operator '-' must be followed by whitespace.", type: "UnaryExpression" @@ -365,7 +365,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "foo++", output: "foo ++", - options: [{ "nonwords": true }], + options: [{ nonwords: true }], errors: [{ message: "Space is required before unary expressions '++'." }] @@ -373,7 +373,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "foo ++", output: "foo++", - options: [{ "nonwords": false }], + options: [{ nonwords: false }], errors: [{ message: "Unexpected space before unary operator '++'." }] @@ -381,7 +381,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "++ foo", output: "++foo", - options: [{ "nonwords": false }], + options: [{ nonwords: false }], errors: [{ message: "Unexpected space after unary operator '++'." }] @@ -389,7 +389,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "++foo", output: "++ foo", - options: [{ "nonwords": true }], + options: [{ nonwords: true }], errors: [{ message: "Unary operator '++' must be followed by whitespace." }] @@ -419,7 +419,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "foo++", output: "foo ++", - options: [{ "nonwords": true, "overrides": {"++": true} }], + options: [{ nonwords: true, overrides: {"++": true} }], errors: [{ message: "Space is required before unary expressions '++'." }] @@ -427,7 +427,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "foo++", output: "foo ++", - options: [{ "nonwords": false, "overrides": {"++": true} }], + options: [{ nonwords: false, overrides: {"++": true} }], errors: [{ message: "Space is required before unary expressions '++'." }] @@ -435,7 +435,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "++foo", output: "++ foo", - options: [{ "nonwords": true, "overrides": {"++": true} }], + options: [{ nonwords: true, overrides: {"++": true} }], errors: [{ message: "Unary operator '++' must be followed by whitespace." }] @@ -443,7 +443,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "++foo", output: "++ foo", - options: [{ "nonwords": false, "overrides": {"++": true} }], + options: [{ nonwords: false, overrides: {"++": true} }], errors: [{ message: "Unary operator '++' must be followed by whitespace." }] @@ -451,7 +451,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "!foo", output: "! foo", - options: [{ "nonwords": true, "overrides": {"!": true} }], + options: [{ nonwords: true, overrides: {"!": true} }], errors: [{ message: "Unary operator '!' must be followed by whitespace." }] @@ -459,7 +459,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "!foo", output: "! foo", - options: [{ "nonwords": false, "overrides": {"!": true} }], + options: [{ nonwords: false, overrides: {"!": true} }], errors: [{ message: "Unary operator '!' must be followed by whitespace." }] @@ -467,7 +467,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "new(Foo)", output: "new (Foo)", - options: [{ "words": true, "overrides": {"new": true} }], + options: [{ words: true, overrides: {new: true} }], errors: [{ message: "Unary word operator 'new' must be followed by whitespace." }] @@ -475,7 +475,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "new(Foo)", output: "new (Foo)", - options: [{ "words": false, "overrides": {"new": true} }], + options: [{ words: false, overrides: {new: true} }], errors: [{ message: "Unary word operator 'new' must be followed by whitespace." }] @@ -483,7 +483,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "function *foo() { yield(0) }", output: "function *foo() { yield (0) }", - options: [{ "words": true, "overrides": {"yield": true} }], + options: [{ words: true, overrides: {yield: true} }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unary word operator 'yield' must be followed by whitespace.", @@ -495,7 +495,7 @@ ruleTester.run("space-unary-ops", rule, { { code: "function *foo() { yield(0) }", output: "function *foo() { yield (0) }", - options: [{ "words": false, "overrides": {"yield": true} }], + options: [{ words: false, overrides: {yield: true} }], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Unary word operator 'yield' must be followed by whitespace.", diff --git a/tests/lib/rules/valid-jsdoc.js b/tests/lib/rules/valid-jsdoc.js index bd9b2bf18fd..288686d87cc 100644 --- a/tests/lib/rules/valid-jsdoc.js +++ b/tests/lib/rules/valid-jsdoc.js @@ -157,12 +157,12 @@ ruleTester.run("valid-jsdoc", rule, { { code: "/**\n* Start with caps and end with period.\n* @return {void} */\nfunction foo(){}", options: [{ - "matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$" + matchDescription: "^[A-Z][A-Za-z0-9\\s]*[.]$" }] }, { code: "/** Foo \n@return {void} Foo\n */\nfunction foo(){}", - options: [{ prefer: { "return": "return" }}] + options: [{ prefer: { return: "return" }}] }, { code: "/** Foo \n@return Foo\n */\nfunction foo(){}", @@ -277,8 +277,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "Astnode": "ASTNode" + String: "string", + Astnode: "ASTNode" } }] }, @@ -292,8 +292,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "Astnode": "ASTNode" + String: "string", + Astnode: "ASTNode" } }] }, @@ -307,8 +307,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "astnode": "ASTNode" + String: "string", + astnode: "ASTNode" } }] }, @@ -322,7 +322,7 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "test": "Test" + test: "Test" } }] }, @@ -336,8 +336,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "astnode": "ASTNode" + String: "string", + astnode: "ASTNode" } }] }, @@ -349,7 +349,7 @@ ruleTester.run("valid-jsdoc", rule, { " */\n" + "function foo() {}", options: [{ - "requireReturn": false + requireReturn: false }] }, { @@ -361,7 +361,7 @@ ruleTester.run("valid-jsdoc", rule, { " */\n" + "function foo() {}", options: [{ - "requireReturn": false + requireReturn: false }] }, { @@ -372,7 +372,7 @@ ruleTester.run("valid-jsdoc", rule, { " */\n" + "function foo() {}", options: [{ - "requireReturn": false + requireReturn: false }] }, { @@ -383,7 +383,7 @@ ruleTester.run("valid-jsdoc", rule, { " */\n" + "function foo() {}", options: [{ - "requireReturn": false + requireReturn: false }] }, { @@ -396,7 +396,7 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string" + String: "string" } }] }, @@ -410,7 +410,7 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string" + String: "string" } }] }, @@ -424,8 +424,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "Number": "number", - "String": "string" + Number: "number", + String: "string" } }] }, @@ -439,8 +439,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "Number": "number", - "String": "string" + Number: "number", + String: "string" } }] }, @@ -454,8 +454,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "Number": "number", - "String": "string" + Number: "number", + String: "string" } }] }, @@ -534,7 +534,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/** Foo \n@return {void} Foo\n */\nfunction foo(){}", - options: [{ prefer: { "return": "returns" }}], + options: [{ prefer: { return: "returns" }}], errors: [{ message: "Use @returns instead.", type: "Block" @@ -542,7 +542,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/** Foo \n@argument {int} bar baz\n */\nfunction foo(bar){}", - options: [{ prefer: { "argument": "arg" }}], + options: [{ prefer: { argument: "arg" }}], errors: [{ message: "Use @arg instead.", type: "Block" @@ -553,7 +553,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/** Foo \n */\nfunction foo(){}", - options: [{ prefer: { "returns": "return" }}], + options: [{ prefer: { returns: "return" }}], errors: [{ message: "Missing JSDoc @return for function.", type: "Block" @@ -561,7 +561,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/** Foo \n@return {void} Foo\n */\nfoo.bar = () => {}", - options: [{ prefer: { "return": "returns" }}], + options: [{ prefer: { return: "returns" }}], parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Use @returns instead.", @@ -646,7 +646,7 @@ ruleTester.run("valid-jsdoc", rule, { "};", options: [{ requireReturn: true, - "matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$" + matchDescription: "^[A-Z][A-Za-z0-9\\s]*[.]$" }], errors: [ { @@ -753,7 +753,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/**\n * Does something. \n* @param {string} a - this is a \n* @return {Array} The result of doing it \n*/\n export function doSomething(a) { }", - options: [{"prefer": { "return": "returns" }}], + options: [{prefer: { return: "returns" }}], parserOptions: { sourceType: "module" }, errors: [{ message: "Use @returns instead.", @@ -762,7 +762,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/**\n * Does something. \n* @param {string} a - this is a \n* @return {Array} The result of doing it \n*/\n export default function doSomething(a) { }", - options: [{"prefer": { "return": "returns" }}], + options: [{prefer: { return: "returns" }}], parserOptions: { sourceType: "module" }, errors: [{ message: "Use @returns instead.", @@ -812,7 +812,7 @@ ruleTester.run("valid-jsdoc", rule, { { code: "/**\n* Start with caps and end with period\n* @return {void} */\nfunction foo(){}", options: [{ - "matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$" + matchDescription: "^[A-Z][A-Za-z0-9\\s]*[.]$" }], errors: [{ message: "JSDoc description does not satisfy the regex pattern.", @@ -821,7 +821,7 @@ ruleTester.run("valid-jsdoc", rule, { }, { code: "/** Foo \n@return Foo\n */\nfunction foo(){}", - options: [{ prefer: { "return": "return" }}], + options: [{ prefer: { return: "return" }}], errors: [{ message: "Missing JSDoc return type.", type: "Block" @@ -830,7 +830,7 @@ ruleTester.run("valid-jsdoc", rule, { { code: "/** Foo \n@return sdf\n */\nfunction foo(){}", options: [{ - prefer: { "return": "return" }, + prefer: { return: "return" }, requireReturn: false }], errors: [{ @@ -856,7 +856,7 @@ ruleTester.run("valid-jsdoc", rule, { "}", options: [{ requireReturn: false, - "matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$" + matchDescription: "^[A-Z][A-Za-z0-9\\s]*[.]$" }], errors: [ { @@ -888,7 +888,7 @@ ruleTester.run("valid-jsdoc", rule, { "};", options: [{ requireReturn: true, - "matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$" + matchDescription: "^[A-Z][A-Za-z0-9\\s]*[.]$" }], errors: [ { @@ -978,8 +978,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "Astnode": "ASTNode" + String: "string", + Astnode: "ASTNode" } }], errors: [ @@ -1003,8 +1003,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "Astnode": "ASTNode" + String: "string", + Astnode: "ASTNode" } }], errors: [ @@ -1028,7 +1028,7 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "test": "Test" + test: "Test" } }], errors: [ @@ -1048,8 +1048,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "String": "string", - "astnode": "ASTNode" + String: "string", + astnode: "ASTNode" } }], errors: [ @@ -1069,8 +1069,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "Number": "number", - "String": "string" + Number: "number", + String: "string" } }], errors: [ @@ -1098,8 +1098,8 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "Number": "number", - "String": "string" + Number: "number", + String: "string" } }], errors: [ @@ -1131,9 +1131,9 @@ ruleTester.run("valid-jsdoc", rule, { "function foo(hi){}", options: [{ preferType: { - "Number": "number", - "String": "string", - "object": "Object" + Number: "number", + String: "string", + object: "Object" } }], errors: [ diff --git a/tests/lib/testers/rule-tester.js b/tests/lib/testers/rule-tester.js index 0470dfa8dd4..94dc5012288 100644 --- a/tests/lib/testers/rule-tester.js +++ b/tests/lib/testers/rule-tester.js @@ -370,7 +370,7 @@ describe("RuleTester", function() { ruleTester.run("no-test-settings", require("../../fixtures/testers/rule-tester/no-test-settings"), { valid: [ { - code: "var test = 'bar'", settings: { "test": 1 } + code: "var test = 'bar'", settings: { test: 1 } } ], invalid: [