From 251d655cac4e21749177b47a1f28178e0e76aff7 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 26 Aug 2016 23:02:28 -0700 Subject: [PATCH] tools: update ESLint to 3.4.0 PR-URL: https://github.com/nodejs/node/pull/8296 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Roman Reiss --- tools/eslint/README.md | 3 +- tools/eslint/bin/eslint.js | 77 +++++++ tools/eslint/conf/eslint.json | 2 + tools/eslint/lib/ast-utils.js | 36 ++-- tools/eslint/lib/cli-engine.js | 32 +-- tools/eslint/lib/cli.js | 2 +- .../code-path-analysis/code-path-analyzer.js | 6 +- .../code-path-analysis/code-path-segment.js | 2 +- .../lib/code-path-analysis/code-path-state.js | 100 +++++----- .../lib/code-path-analysis/code-path.js | 6 +- .../lib/code-path-analysis/debug-helpers.js | 2 +- .../lib/code-path-analysis/fork-context.js | 14 +- tools/eslint/lib/config.js | 2 +- tools/eslint/lib/config/autoconfig.js | 22 +- tools/eslint/lib/config/config-file.js | 22 +- tools/eslint/lib/config/config-initializer.js | 22 +- tools/eslint/lib/config/config-ops.js | 16 +- tools/eslint/lib/config/config-rule.js | 14 +- tools/eslint/lib/config/config-validator.js | 6 +- tools/eslint/lib/config/plugins.js | 52 ++--- tools/eslint/lib/eslint.js | 56 ++++-- tools/eslint/lib/formatters/html.js | 8 +- tools/eslint/lib/formatters/stylish.js | 2 +- tools/eslint/lib/formatters/table.js | 4 +- tools/eslint/lib/ignored-paths.js | 59 +++--- .../internal-no-invalid-meta.js | 8 +- tools/eslint/lib/logging.js | 4 +- tools/eslint/lib/rule-context.js | 4 +- tools/eslint/lib/rules.js | 32 +-- tools/eslint/lib/rules/accessor-pairs.js | 4 +- .../eslint/lib/rules/array-bracket-spacing.js | 20 +- .../eslint/lib/rules/array-callback-return.js | 14 +- tools/eslint/lib/rules/arrow-body-style.js | 8 +- tools/eslint/lib/rules/arrow-parens.js | 20 +- tools/eslint/lib/rules/arrow-spacing.js | 14 +- tools/eslint/lib/rules/block-scoped-var.js | 4 +- tools/eslint/lib/rules/block-spacing.js | 10 +- tools/eslint/lib/rules/brace-style.js | 2 +- tools/eslint/lib/rules/callback-return.js | 4 +- tools/eslint/lib/rules/camelcase.js | 4 +- .../lib/rules/class-methods-use-this.js | 80 ++++++++ tools/eslint/lib/rules/comma-dangle.js | 6 +- tools/eslint/lib/rules/comma-spacing.js | 8 +- tools/eslint/lib/rules/comma-style.js | 2 +- tools/eslint/lib/rules/complexity.js | 4 +- .../lib/rules/computed-property-spacing.js | 18 +- tools/eslint/lib/rules/consistent-return.js | 18 +- tools/eslint/lib/rules/consistent-this.js | 10 +- tools/eslint/lib/rules/constructor-super.js | 28 +-- tools/eslint/lib/rules/curly.js | 26 +-- tools/eslint/lib/rules/default-case.js | 4 +- tools/eslint/lib/rules/dot-location.js | 2 +- tools/eslint/lib/rules/dot-notation.js | 4 +- tools/eslint/lib/rules/eol-last.js | 6 +- tools/eslint/lib/rules/eqeqeq.js | 8 +- tools/eslint/lib/rules/func-call-spacing.js | 14 +- tools/eslint/lib/rules/func-names.js | 4 +- tools/eslint/lib/rules/func-style.js | 12 +- .../lib/rules/generator-star-spacing.js | 8 +- tools/eslint/lib/rules/global-require.js | 4 +- tools/eslint/lib/rules/guard-for-in.js | 4 +- tools/eslint/lib/rules/handle-callback-err.js | 2 +- tools/eslint/lib/rules/id-blacklist.js | 4 +- tools/eslint/lib/rules/id-length.js | 10 +- tools/eslint/lib/rules/id-match.js | 6 +- tools/eslint/lib/rules/indent.js | 47 +++-- tools/eslint/lib/rules/init-declarations.js | 4 +- tools/eslint/lib/rules/jsx-quotes.js | 10 +- tools/eslint/lib/rules/key-spacing.js | 8 +- tools/eslint/lib/rules/keyword-spacing.js | 10 +- tools/eslint/lib/rules/linebreak-style.js | 4 +- .../eslint/lib/rules/lines-around-comment.js | 14 +- tools/eslint/lib/rules/max-depth.js | 4 +- tools/eslint/lib/rules/max-len.js | 2 +- tools/eslint/lib/rules/max-lines.js | 6 +- .../eslint/lib/rules/max-nested-callbacks.js | 2 +- tools/eslint/lib/rules/max-params.js | 2 +- .../lib/rules/max-statements-per-line.js | 6 +- tools/eslint/lib/rules/max-statements.js | 8 +- tools/eslint/lib/rules/multiline-ternary.js | 39 +++- tools/eslint/lib/rules/new-cap.js | 2 +- tools/eslint/lib/rules/new-parens.js | 4 +- tools/eslint/lib/rules/newline-after-var.js | 2 +- .../eslint/lib/rules/newline-before-return.js | 6 +- .../lib/rules/newline-per-chained-call.js | 4 +- tools/eslint/lib/rules/no-alert.js | 6 +- .../eslint/lib/rules/no-array-constructor.js | 2 +- tools/eslint/lib/rules/no-bitwise.js | 2 +- tools/eslint/lib/rules/no-caller.js | 4 +- .../eslint/lib/rules/no-case-declarations.js | 6 +- tools/eslint/lib/rules/no-catch-shadow.js | 4 +- tools/eslint/lib/rules/no-class-assign.js | 2 +- tools/eslint/lib/rules/no-cond-assign.js | 8 +- tools/eslint/lib/rules/no-confusing-arrow.js | 2 +- tools/eslint/lib/rules/no-console.js | 4 +- tools/eslint/lib/rules/no-const-assign.js | 4 +- .../eslint/lib/rules/no-constant-condition.js | 2 +- tools/eslint/lib/rules/no-continue.js | 4 +- tools/eslint/lib/rules/no-control-regex.js | 4 +- tools/eslint/lib/rules/no-debugger.js | 4 +- tools/eslint/lib/rules/no-delete-var.js | 4 +- tools/eslint/lib/rules/no-div-regex.js | 4 +- tools/eslint/lib/rules/no-dupe-args.js | 4 +- .../eslint/lib/rules/no-dupe-class-members.js | 12 +- tools/eslint/lib/rules/no-duplicate-case.js | 4 +- .../eslint/lib/rules/no-duplicate-imports.js | 4 +- tools/eslint/lib/rules/no-else-return.js | 4 +- .../lib/rules/no-empty-character-class.js | 4 +- tools/eslint/lib/rules/no-empty-function.js | 4 +- tools/eslint/lib/rules/no-empty-pattern.js | 6 +- tools/eslint/lib/rules/no-empty.js | 6 +- tools/eslint/lib/rules/no-eq-null.js | 4 +- tools/eslint/lib/rules/no-eval.js | 22 +- tools/eslint/lib/rules/no-ex-assign.js | 4 +- tools/eslint/lib/rules/no-extend-native.js | 6 +- tools/eslint/lib/rules/no-extra-bind.js | 2 +- .../eslint/lib/rules/no-extra-boolean-cast.js | 6 +- tools/eslint/lib/rules/no-extra-label.js | 2 +- tools/eslint/lib/rules/no-extra-parens.js | 101 +++++++--- tools/eslint/lib/rules/no-extra-semi.js | 10 +- tools/eslint/lib/rules/no-fallthrough.js | 12 +- tools/eslint/lib/rules/no-floating-decimal.js | 4 +- tools/eslint/lib/rules/no-func-assign.js | 2 +- tools/eslint/lib/rules/no-global-assign.js | 4 +- .../eslint/lib/rules/no-implicit-coercion.js | 8 +- tools/eslint/lib/rules/no-implicit-globals.js | 4 +- tools/eslint/lib/rules/no-implied-eval.js | 14 +- tools/eslint/lib/rules/no-inline-comments.js | 2 +- .../eslint/lib/rules/no-inner-declarations.js | 4 +- tools/eslint/lib/rules/no-invalid-regexp.js | 2 +- tools/eslint/lib/rules/no-invalid-this.js | 12 +- .../lib/rules/no-irregular-whitespace.js | 2 +- tools/eslint/lib/rules/no-iterator.js | 4 +- tools/eslint/lib/rules/no-label-var.js | 4 +- tools/eslint/lib/rules/no-labels.js | 16 +- tools/eslint/lib/rules/no-lone-blocks.js | 8 +- tools/eslint/lib/rules/no-lonely-if.js | 4 +- tools/eslint/lib/rules/no-loop-func.js | 2 +- tools/eslint/lib/rules/no-magic-numbers.js | 8 +- tools/eslint/lib/rules/no-mixed-operators.js | 10 +- tools/eslint/lib/rules/no-mixed-requires.js | 4 +- .../lib/rules/no-mixed-spaces-and-tabs.js | 8 +- tools/eslint/lib/rules/no-multi-spaces.js | 4 +- tools/eslint/lib/rules/no-multi-str.js | 4 +- .../lib/rules/no-multiple-empty-lines.js | 16 +- tools/eslint/lib/rules/no-native-reassign.js | 4 +- .../eslint/lib/rules/no-negated-condition.js | 6 +- tools/eslint/lib/rules/no-negated-in-lhs.js | 4 +- tools/eslint/lib/rules/no-nested-ternary.js | 4 +- tools/eslint/lib/rules/no-new-func.js | 2 +- tools/eslint/lib/rules/no-new-object.js | 4 +- tools/eslint/lib/rules/no-new-require.js | 4 +- tools/eslint/lib/rules/no-new-symbol.js | 4 +- tools/eslint/lib/rules/no-new-wrappers.js | 4 +- tools/eslint/lib/rules/no-new.js | 4 +- tools/eslint/lib/rules/no-obj-calls.js | 6 +- tools/eslint/lib/rules/no-octal-escape.js | 6 +- tools/eslint/lib/rules/no-octal.js | 4 +- tools/eslint/lib/rules/no-param-reassign.js | 2 +- tools/eslint/lib/rules/no-path-concat.js | 4 +- tools/eslint/lib/rules/no-plusplus.js | 4 +- tools/eslint/lib/rules/no-process-env.js | 4 +- tools/eslint/lib/rules/no-process-exit.js | 4 +- tools/eslint/lib/rules/no-proto.js | 4 +- .../eslint/lib/rules/no-prototype-builtins.js | 4 +- tools/eslint/lib/rules/no-redeclare.js | 2 +- tools/eslint/lib/rules/no-regex-spaces.js | 2 +- .../eslint/lib/rules/no-restricted-globals.js | 4 +- .../eslint/lib/rules/no-restricted-imports.js | 4 +- .../eslint/lib/rules/no-restricted-modules.js | 4 +- .../eslint/lib/rules/no-restricted-syntax.js | 2 +- tools/eslint/lib/rules/no-return-assign.js | 4 +- tools/eslint/lib/rules/no-script-url.js | 4 +- tools/eslint/lib/rules/no-self-assign.js | 6 +- tools/eslint/lib/rules/no-self-compare.js | 4 +- tools/eslint/lib/rules/no-sequences.js | 4 +- .../lib/rules/no-shadow-restricted-names.js | 12 +- tools/eslint/lib/rules/no-shadow.js | 4 +- tools/eslint/lib/rules/no-spaced-func.js | 6 +- tools/eslint/lib/rules/no-sparse-arrays.js | 4 +- tools/eslint/lib/rules/no-sync.js | 4 +- tools/eslint/lib/rules/no-tabs.js | 2 +- .../lib/rules/no-template-curly-in-string.js | 8 +- tools/eslint/lib/rules/no-ternary.js | 4 +- .../eslint/lib/rules/no-this-before-super.js | 22 +- tools/eslint/lib/rules/no-throw-literal.js | 4 +- tools/eslint/lib/rules/no-trailing-spaces.js | 7 +- tools/eslint/lib/rules/no-undef-init.js | 6 +- tools/eslint/lib/rules/no-undef.js | 4 +- tools/eslint/lib/rules/no-undefined.js | 4 +- .../eslint/lib/rules/no-underscore-dangle.js | 2 +- .../lib/rules/no-unexpected-multiline.js | 8 +- .../lib/rules/no-unmodified-loop-condition.js | 14 +- tools/eslint/lib/rules/no-unneeded-ternary.js | 4 +- tools/eslint/lib/rules/no-unreachable.js | 10 +- tools/eslint/lib/rules/no-unsafe-finally.js | 4 +- tools/eslint/lib/rules/no-unsafe-negation.js | 2 +- .../eslint/lib/rules/no-unused-expressions.js | 4 +- tools/eslint/lib/rules/no-unused-labels.js | 2 +- tools/eslint/lib/rules/no-unused-vars.js | 6 +- .../eslint/lib/rules/no-use-before-define.js | 6 +- tools/eslint/lib/rules/no-useless-call.js | 4 +- .../lib/rules/no-useless-computed-key.js | 4 +- tools/eslint/lib/rules/no-useless-concat.js | 4 +- .../lib/rules/no-useless-constructor.js | 4 +- tools/eslint/lib/rules/no-useless-escape.js | 4 +- tools/eslint/lib/rules/no-useless-rename.js | 10 +- tools/eslint/lib/rules/no-var.js | 8 +- tools/eslint/lib/rules/no-void.js | 4 +- tools/eslint/lib/rules/no-warning-comments.js | 2 +- .../rules/no-whitespace-before-property.js | 8 +- tools/eslint/lib/rules/no-with.js | 4 +- .../eslint/lib/rules/object-curly-newline.js | 20 +- .../eslint/lib/rules/object-curly-spacing.js | 46 ++++- .../lib/rules/object-property-newline.js | 6 +- tools/eslint/lib/rules/object-shorthand.js | 30 +-- .../lib/rules/one-var-declaration-per-line.js | 4 +- tools/eslint/lib/rules/one-var.js | 4 +- tools/eslint/lib/rules/operator-assignment.js | 2 +- tools/eslint/lib/rules/operator-linebreak.js | 6 +- tools/eslint/lib/rules/padded-blocks.js | 18 +- .../eslint/lib/rules/prefer-arrow-callback.js | 12 +- tools/eslint/lib/rules/prefer-const.js | 19 +- tools/eslint/lib/rules/prefer-reflect.js | 10 +- tools/eslint/lib/rules/prefer-rest-params.js | 2 +- tools/eslint/lib/rules/prefer-spread.js | 4 +- tools/eslint/lib/rules/prefer-template.js | 4 +- tools/eslint/lib/rules/quote-props.js | 6 +- tools/eslint/lib/rules/quotes.js | 14 +- tools/eslint/lib/rules/radix.js | 12 +- tools/eslint/lib/rules/require-jsdoc.js | 8 +- tools/eslint/lib/rules/require-yield.js | 4 +- tools/eslint/lib/rules/rest-spread-spacing.js | 14 +- tools/eslint/lib/rules/semi-spacing.js | 20 +- tools/eslint/lib/rules/semi.js | 14 +- tools/eslint/lib/rules/sort-imports.js | 8 +- tools/eslint/lib/rules/sort-keys.js | 8 +- tools/eslint/lib/rules/sort-vars.js | 4 +- tools/eslint/lib/rules/space-before-blocks.js | 10 +- .../lib/rules/space-before-function-paren.js | 10 +- tools/eslint/lib/rules/space-in-parens.js | 22 +- tools/eslint/lib/rules/space-infix-ops.js | 4 +- tools/eslint/lib/rules/space-unary-ops.js | 26 +-- tools/eslint/lib/rules/spaced-comment.js | 14 +- tools/eslint/lib/rules/strict.js | 8 +- tools/eslint/lib/rules/symbol-description.js | 66 ++++++ .../lib/rules/template-curly-spacing.js | 8 +- tools/eslint/lib/rules/unicode-bom.js | 10 +- tools/eslint/lib/rules/use-isnan.js | 4 +- tools/eslint/lib/rules/valid-jsdoc.js | 10 +- tools/eslint/lib/rules/valid-typeof.js | 24 ++- tools/eslint/lib/rules/vars-on-top.js | 4 +- tools/eslint/lib/rules/wrap-iife.js | 4 +- tools/eslint/lib/rules/wrap-regex.js | 4 +- tools/eslint/lib/rules/yield-star-spacing.js | 8 +- tools/eslint/lib/rules/yoda.js | 2 +- .../lib/testers/event-generator-tester.js | 2 +- tools/eslint/lib/testers/rule-tester.js | 10 +- tools/eslint/lib/timing.js | 4 +- tools/eslint/lib/util/glob-util.js | 14 +- tools/eslint/lib/util/glob.js | 63 ++++++ tools/eslint/lib/util/module-resolver.js | 2 +- tools/eslint/lib/util/npm-util.js | 8 +- tools/eslint/lib/util/path-util.js | 4 +- tools/eslint/lib/util/rule-fixer.js | 24 +-- tools/eslint/lib/util/source-code-fixer.js | 4 +- tools/eslint/lib/util/source-code-util.js | 2 +- tools/eslint/lib/util/source-code.js | 18 +- tools/eslint/messages/plugin-missing.txt | 6 +- .../bluebird/js/browser/bluebird.core.js | 117 ++++++++--- .../bluebird/js/browser/bluebird.core.min.js | 6 +- .../bluebird/js/browser/bluebird.js | 126 +++++++++--- .../bluebird/js/browser/bluebird.min.js | 8 +- .../eslint/node_modules/bluebird/package.json | 20 +- .../node_modules/cli-width/package.json | 2 +- .../node_modules/doctrine/lib/doctrine.js | 6 +- .../eslint/node_modules/doctrine/lib/typed.js | 36 +++- .../doctrine/node_modules/esutils/LICENSE.BSD | 19 -- .../doctrine/node_modules/esutils/README.md | 169 ---------------- .../doctrine/node_modules/esutils/lib/ast.js | 144 -------------- .../doctrine/node_modules/esutils/lib/code.js | 101 ---------- .../node_modules/esutils/lib/keyword.js | 137 ------------- .../node_modules/esutils/lib/utils.js | 33 --- .../node_modules/esutils/package.json | 101 ---------- .../eslint/node_modules/doctrine/package.json | 37 ++-- tools/eslint/node_modules/esprima/esprima.js | 5 +- .../eslint/node_modules/esprima/package.json | 22 +- .../eslint/node_modules/esutils/package.json | 1 + .../node_modules/file-entry-cache/cache.js | 46 ++++- .../file-entry-cache/changelog.md | 5 + .../file-entry-cache/package.json | 34 ++-- tools/eslint/node_modules/glob/glob.js | 4 + tools/eslint/node_modules/glob/package.json | 22 +- .../node_modules/graceful-fs/package.json | 18 +- .../node_modules/graceful-fs/polyfills.js | 8 +- tools/eslint/node_modules/ignore/README.md | 188 ++++++++++++++++++ tools/eslint/node_modules/ignore/ignore.js | 112 +++++++---- tools/eslint/node_modules/ignore/package.json | 38 ++-- .../eslint/node_modules/jsonify/package.json | 2 +- .../eslint/node_modules/string-width/index.js | 5 + .../node_modules/string-width/package.json | 29 +-- .../node_modules/string-width/readme.md | 7 +- tools/eslint/package.json | 20 +- 303 files changed, 2227 insertions(+), 2058 deletions(-) create mode 100755 tools/eslint/bin/eslint.js create mode 100644 tools/eslint/lib/rules/class-methods-use-this.js create mode 100644 tools/eslint/lib/rules/symbol-description.js create mode 100644 tools/eslint/lib/util/glob.js delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/LICENSE.BSD delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/README.md delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/lib/ast.js delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/lib/code.js delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/lib/keyword.js delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/lib/utils.js delete mode 100644 tools/eslint/node_modules/doctrine/node_modules/esutils/package.json create mode 100755 tools/eslint/node_modules/ignore/README.md diff --git a/tools/eslint/README.md b/tools/eslint/README.md index 8ba9eaf0b5f1bd..e012e8d1f10f9b 100644 --- a/tools/eslint/README.md +++ b/tools/eslint/README.md @@ -155,13 +155,14 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat * Minor release (might break your lint build) * A bug fix in a rule that results in ESLint reporting more errors. * A new rule is created. - * A new option to an existing rule is created. + * A new option to an existing rule that does not result in ESLint reporting more errors by default. * An existing rule is deprecated. * A new CLI capability is created. * New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.). * A new formatter is created. * Major release (likely to break your lint build) * `eslint:recommended` is updated. + * A new option to an existing rule that results in ESLint reporting more errors by default. * An existing rule is removed. * An existing formatter is removed. * Part of the public API is removed or changed in an incompatible way. diff --git a/tools/eslint/bin/eslint.js b/tools/eslint/bin/eslint.js new file mode 100755 index 00000000000000..8bc431339f0f8e --- /dev/null +++ b/tools/eslint/bin/eslint.js @@ -0,0 +1,77 @@ +#!/usr/bin/env node + +/** + * @fileoverview Main CLI that is run via the eslint command. + * @author Nicholas C. Zakas + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +var useStdIn = (process.argv.indexOf("--stdin") > -1), + init = (process.argv.indexOf("--init") > -1), + debug = (process.argv.indexOf("--debug") > -1); + +// must do this initialization *before* other requires in order to work +if (debug) { + require("debug").enable("eslint:*,-eslint:code-path"); +} + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// now we can safely include the other modules that use debug +var concat = require("concat-stream"), + cli = require("../lib/cli"), + path = require("path"), + fs = require("fs"); + +//------------------------------------------------------------------------------ +// Execution +//------------------------------------------------------------------------------ + +process.on("uncaughtException", function(err){ + // lazy load + var lodash = require("lodash"); + + if (typeof err.messageTemplate === "string" && err.messageTemplate.length > 0) { + var template = lodash.template(fs.readFileSync(path.resolve(__dirname, "../messages/" + err.messageTemplate + ".txt"), "utf-8")); + + console.log("\nOops! Something went wrong! :("); + console.log("\n" + template(err.messageData || {})); + } else { + console.log(err.message); + console.log(err.stack); + } + + process.exit(1); +}); + +if (useStdIn) { + process.stdin.pipe(concat({ encoding: "string" }, function(text) { + try { + process.exitCode = cli.execute(process.argv, text); + } catch (ex) { + console.error(ex.message); + console.error(ex.stack); + process.exitCode = 1; + } + })); +} else if (init) { + var configInit = require("../lib/config/config-initializer"); + configInit.initializeConfig(function(err) { + if (err) { + process.exitCode = 1; + console.error(err.message); + console.error(err.stack); + } else { + process.exitCode = 0; + } + }); +} else { + process.exitCode = cli.execute(process.argv); +} diff --git a/tools/eslint/conf/eslint.json b/tools/eslint/conf/eslint.json index 3d7779ea065d01..5d0b947c5a9c4b 100755 --- a/tools/eslint/conf/eslint.json +++ b/tools/eslint/conf/eslint.json @@ -140,6 +140,7 @@ "brace-style": "off", "callback-return": "off", "camelcase": "off", + "class-methods-use-this": "off", "comma-dangle": "off", "comma-spacing": "off", "comma-style": "off", @@ -217,6 +218,7 @@ "space-unary-ops": "off", "spaced-comment": "off", "strict": "off", + "symbol-description": "off", "template-curly-spacing": "off", "unicode-bom": "off", "use-isnan": "error", diff --git a/tools/eslint/lib/ast-utils.js b/tools/eslint/lib/ast-utils.js index 9fcab25b4af43b..f0b6fc48ce6732 100644 --- a/tools/eslint/lib/ast-utils.js +++ b/tools/eslint/lib/ast-utils.js @@ -210,23 +210,23 @@ module.exports = { * @returns {boolean} Whether or not the tokens are on the same line. * @public */ - isTokenOnSameLine: function(left, right) { + isTokenOnSameLine(left, right) { return left.loc.end.line === right.loc.start.line; }, - isNullOrUndefined: isNullOrUndefined, - isCallee: isCallee, - isES5Constructor: isES5Constructor, - getUpperFunction: getUpperFunction, - isArrayFromMethod: isArrayFromMethod, - isParenthesised: isParenthesised, + isNullOrUndefined, + isCallee, + isES5Constructor, + getUpperFunction, + isArrayFromMethod, + isParenthesised, /** * Checks whether or not a given node is a string literal. * @param {ASTNode} node - A node to check. * @returns {boolean} `true` if the node is a string literal. */ - isStringLiteral: function(node) { + isStringLiteral(node) { return ( (node.type === "Literal" && typeof node.value === "string") || node.type === "TemplateLiteral" @@ -247,7 +247,7 @@ module.exports = { * @param {ASTNode} node - A node to check. * @returns {boolean} `true` if the node is breakable. */ - isBreakableStatement: function(node) { + isBreakableStatement(node) { return breakableTypePattern.test(node.type); }, @@ -257,7 +257,7 @@ module.exports = { * @param {ASTNode} node - A node to get. * @returns {string|null} The label or `null`. */ - getLabel: function(node) { + getLabel(node) { if (node.parent.type === "LabeledStatement") { return node.parent.label.name; } @@ -270,7 +270,7 @@ module.exports = { * @returns {Reference[]} An array of only references which are non initializer and writable. * @public */ - getModifyingReferences: function(references) { + getModifyingReferences(references) { return references.filter(isModifyingReference); }, @@ -281,7 +281,7 @@ module.exports = { * @returns {boolean} True if the text is surrounded by the character, false if not. * @private */ - isSurroundedBy: function(val, character) { + isSurroundedBy(val, character) { return val[0] === character && val[val.length - 1] === character; }, @@ -290,7 +290,7 @@ module.exports = { * @param {LineComment|BlockComment} node The node to be checked * @returns {boolean} `true` if the node is an ESLint directive comment */ - isDirectiveComment: function(node) { + isDirectiveComment(node) { const comment = node.value.trim(); return ( @@ -323,7 +323,7 @@ module.exports = { * @param {string} name - A variable name to find. * @returns {escope.Variable|null} A found variable or `null`. */ - getVariableByName: function(initScope, name) { + getVariableByName(initScope, name) { let scope = initScope; while (scope) { @@ -360,7 +360,7 @@ module.exports = { * @param {SourceCode} sourceCode - A SourceCode instance to get comments. * @returns {boolean} The function node is the default `this` binding. */ - isDefaultThisBinding: function(node, sourceCode) { + isDefaultThisBinding(node, sourceCode) { if (isES5Constructor(node) || hasJSDocThisTag(node, sourceCode)) { return false; } @@ -496,7 +496,7 @@ module.exports = { * @returns {int} precedence level * @private */ - getPrecedence: function(node) { + getPrecedence(node) { switch (node.type) { case "SequenceExpression": return 0; @@ -594,7 +594,7 @@ module.exports = { * @param {ASTNode|null} node - A node to check. * @returns {boolean} `true` if the node is a loop node. */ - isLoop: function(node) { + isLoop(node) { return Boolean(node && anyLoopPattern.test(node.type)); }, @@ -609,7 +609,7 @@ module.exports = { * @param {ASTNode|null} node - A node to check. * @returns {boolean} `true` if the node is a function node. */ - isFunction: function(node) { + isFunction(node) { return Boolean(node && anyFunctionPattern.test(node.type)); }, diff --git a/tools/eslint/lib/cli-engine.js b/tools/eslint/lib/cli-engine.js index 110a844512a20c..cca21096c08e8c 100644 --- a/tools/eslint/lib/cli-engine.js +++ b/tools/eslint/lib/cli-engine.js @@ -241,8 +241,8 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) { parsedBlocks.forEach(function(block) { unprocessedMessages.push(eslint.verify(block, config, { - filename: filename, - allowInlineConfig: allowInlineConfig + filename, + allowInlineConfig })); }); @@ -254,14 +254,14 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) { if (fix) { fixedResult = multipassFix(text, config, { - filename: filename, - allowInlineConfig: allowInlineConfig + filename, + allowInlineConfig }); messages = fixedResult.messages; } else { messages = eslint.verify(text, config, { - filename: filename, - allowInlineConfig: allowInlineConfig + filename, + allowInlineConfig }); } } @@ -270,7 +270,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) { const result = { filePath: filename, - messages: messages, + messages, errorCount: stats.errorCount, warningCount: stats.warningCount }; @@ -329,7 +329,7 @@ function createIgnoreResult(filePath, baseDir) { { fatal: false, severity: 1, - message: message + message } ], errorCount: 0, @@ -559,7 +559,7 @@ CLIEngine.prototype = { * @param {Object} pluginobject Plugin configuration object. * @returns {void} */ - addPlugin: function(name, pluginobject) { + addPlugin(name, pluginobject) { Plugins.define(name, pluginobject); }, @@ -569,7 +569,7 @@ CLIEngine.prototype = { * @param {string[]} patterns The file patterns passed on the command line. * @returns {string[]} The equivalent glob patterns. */ - resolveFileGlobPatterns: function(patterns) { + resolveFileGlobPatterns(patterns) { return globUtil.resolveFileGlobPatterns(patterns, this.options); }, @@ -578,7 +578,7 @@ CLIEngine.prototype = { * @param {string[]} patterns An array of file and directory names. * @returns {Object} The results for all files that were linted. */ - executeOnFiles: function(patterns) { + executeOnFiles(patterns) { const results = [], options = this.options, fileCache = this._fileCache, @@ -716,7 +716,7 @@ CLIEngine.prototype = { debug("Linting complete in: " + (Date.now() - startTime) + "ms"); return { - results: results, + results, errorCount: stats.errorCount, warningCount: stats.warningCount }; @@ -729,7 +729,7 @@ CLIEngine.prototype = { * @param {boolean} warnIgnored Always warn when a file is ignored * @returns {Object} The results for the linting. */ - executeOnText: function(text, filename, warnIgnored) { + executeOnText(text, filename, warnIgnored) { const results = [], options = this.options, @@ -752,7 +752,7 @@ CLIEngine.prototype = { const stats = calculateStatsPerRun(results); return { - results: results, + results, errorCount: stats.errorCount, warningCount: stats.warningCount }; @@ -765,7 +765,7 @@ CLIEngine.prototype = { * @param {string} filePath The path of the file to retrieve a config object for. * @returns {Object} A configuration object for the file. */ - getConfigForFile: function(filePath) { + getConfigForFile(filePath) { const configHelper = new Config(this.options); return configHelper.getConfig(filePath); @@ -776,7 +776,7 @@ CLIEngine.prototype = { * @param {string} filePath The path of the file to check. * @returns {boolean} Whether or not the given path is ignored. */ - isPathIgnored: function(filePath) { + isPathIgnored(filePath) { const resolvedPath = path.resolve(this.options.cwd, filePath); const ignoredPaths = new IgnoredPaths(this.options); diff --git a/tools/eslint/lib/cli.js b/tools/eslint/lib/cli.js index 3a51d2acf38ab8..593c354bc08ba6 100644 --- a/tools/eslint/lib/cli.js +++ b/tools/eslint/lib/cli.js @@ -120,7 +120,7 @@ const cli = { * @param {string} [text] The text to lint (used for TTY). * @returns {int} The exit code for the operation. */ - execute: function(args, text) { + execute(args, text) { let currentOptions; diff --git a/tools/eslint/lib/code-path-analysis/code-path-analyzer.js b/tools/eslint/lib/code-path-analysis/code-path-analyzer.js index 2c596c47f02d2c..1d3b632c625cdb 100644 --- a/tools/eslint/lib/code-path-analysis/code-path-analyzer.js +++ b/tools/eslint/lib/code-path-analysis/code-path-analyzer.js @@ -592,7 +592,7 @@ CodePathAnalyzer.prototype = { * @param {ASTNode} node - A node which is entering. * @returns {void} */ - enterNode: function(node) { + enterNode(node) { this.currentNode = node; // Updates the code path due to node's position in its parent node. @@ -617,7 +617,7 @@ CodePathAnalyzer.prototype = { * @param {ASTNode} node - A node which is leaving. * @returns {void} */ - leaveNode: function(node) { + leaveNode(node) { this.currentNode = node; // Updates the code path. @@ -641,7 +641,7 @@ CodePathAnalyzer.prototype = { * @param {CodePathSegment} toSegment - A segment of next. * @returns {void} */ - onLooped: function(fromSegment, toSegment) { + onLooped(fromSegment, toSegment) { if (fromSegment.reachable && toSegment.reachable) { debug.dump("onCodePathSegmentLoop " + fromSegment.id + " -> " + toSegment.id); this.emitter.emit( diff --git a/tools/eslint/lib/code-path-analysis/code-path-segment.js b/tools/eslint/lib/code-path-analysis/code-path-segment.js index 53e39175a7c78b..b3966c415b0aac 100644 --- a/tools/eslint/lib/code-path-analysis/code-path-segment.js +++ b/tools/eslint/lib/code-path-analysis/code-path-segment.js @@ -138,7 +138,7 @@ CodePathSegment.prototype = { * @param {CodePathSegment} segment - A previous segment to check. * @returns {boolean} `true` if the segment is coming from the end of a loop. */ - isLoopedPrevSegment: function(segment) { + isLoopedPrevSegment(segment) { return this.internal.loopedPrevSegments.indexOf(segment) !== -1; } }; diff --git a/tools/eslint/lib/code-path-analysis/code-path-state.js b/tools/eslint/lib/code-path-analysis/code-path-state.js index bfa93ac6073d92..392e3898f6932c 100644 --- a/tools/eslint/lib/code-path-analysis/code-path-state.js +++ b/tools/eslint/lib/code-path-analysis/code-path-state.js @@ -278,7 +278,7 @@ CodePathState.prototype = { * "finally" block. * @returns {ForkContext} The created context. */ - pushForkContext: function(forkLeavingPath) { + pushForkContext(forkLeavingPath) { this.forkContext = ForkContext.newEmpty( this.forkContext, forkLeavingPath @@ -291,7 +291,7 @@ CodePathState.prototype = { * Pops and merges the last forking context. * @returns {ForkContext} The last context. */ - popForkContext: function() { + popForkContext() { const lastContext = this.forkContext; this.forkContext = lastContext.upper; @@ -304,7 +304,7 @@ CodePathState.prototype = { * Creates a new path. * @returns {void} */ - forkPath: function() { + forkPath() { this.forkContext.add(this.parentForkContext.makeNext(-1, -1)); }, @@ -314,7 +314,7 @@ CodePathState.prototype = { * * @returns {void} */ - forkBypassPath: function() { + forkBypassPath() { this.forkContext.add(this.parentForkContext.head); }, @@ -353,11 +353,11 @@ CodePathState.prototype = { * paths between `true` and `false`. * @returns {void} */ - pushChoiceContext: function(kind, isForkingAsResult) { + pushChoiceContext(kind, isForkingAsResult) { this.choiceContext = { upper: this.choiceContext, - kind: kind, - isForkingAsResult: isForkingAsResult, + kind, + isForkingAsResult, trueForkContext: ForkContext.newEmpty(this.forkContext), falseForkContext: ForkContext.newEmpty(this.forkContext), processed: false @@ -369,7 +369,7 @@ CodePathState.prototype = { * * @returns {ChoiceContext} The popped context. */ - popChoiceContext: function() { + popChoiceContext() { const context = this.choiceContext; this.choiceContext = context.upper; @@ -457,7 +457,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeLogicalRight: function() { + makeLogicalRight() { const context = this.choiceContext; const forkContext = this.forkContext; @@ -501,7 +501,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeIfConsequent: function() { + makeIfConsequent() { const context = this.choiceContext; const forkContext = this.forkContext; @@ -528,7 +528,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeIfAlternate: function() { + makeIfAlternate() { const context = this.choiceContext; const forkContext = this.forkContext; @@ -558,10 +558,10 @@ CodePathState.prototype = { * @param {string|null} label - The label text. * @returns {void} */ - pushSwitchContext: function(hasCase, label) { + pushSwitchContext(hasCase, label) { this.switchContext = { upper: this.switchContext, - hasCase: hasCase, + hasCase, defaultSegments: null, defaultBodySegments: null, foundDefault: false, @@ -582,7 +582,7 @@ CodePathState.prototype = { * * @returns {void} */ - popSwitchContext: function() { + popSwitchContext() { const context = this.switchContext; this.switchContext = context.upper; @@ -658,7 +658,7 @@ CodePathState.prototype = { * @param {boolean} isDefault - `true` if the body is the default case. * @returns {void} */ - makeSwitchCaseBody: function(isEmpty, isDefault) { + makeSwitchCaseBody(isEmpty, isDefault) { const context = this.switchContext; if (!context.hasCase) { @@ -709,11 +709,11 @@ CodePathState.prototype = { * `finally` block. * @returns {void} */ - pushTryContext: function(hasFinalizer) { + pushTryContext(hasFinalizer) { this.tryContext = { upper: this.tryContext, position: "try", - hasFinalizer: hasFinalizer, + hasFinalizer, returnedForkContext: hasFinalizer ? ForkContext.newEmpty(this.forkContext) @@ -730,7 +730,7 @@ CodePathState.prototype = { * * @returns {void} */ - popTryContext: function() { + popTryContext() { const context = this.tryContext; this.tryContext = context.upper; @@ -784,7 +784,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeCatchBlock: function() { + makeCatchBlock() { const context = this.tryContext; const forkContext = this.forkContext; const thrown = context.thrownForkContext; @@ -813,7 +813,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeFinallyBlock: function() { + makeFinallyBlock() { const context = this.tryContext; let forkContext = this.forkContext; const returned = context.returnedForkContext; @@ -871,7 +871,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeFirstThrowablePathInTryBlock: function() { + makeFirstThrowablePathInTryBlock() { const forkContext = this.forkContext; if (!forkContext.reachable) { @@ -904,7 +904,7 @@ CodePathState.prototype = { * @param {string|null} label - A label of the node which was triggered. * @returns {void} */ - pushLoopContext: function(type, label) { + pushLoopContext(type, label) { const forkContext = this.forkContext; const breakContext = this.pushBreakContext(true, label); @@ -913,8 +913,8 @@ CodePathState.prototype = { this.pushChoiceContext("loop", false); this.loopContext = { upper: this.loopContext, - type: type, - label: label, + type, + label, test: void 0, continueDestSegments: null, brokenForkContext: breakContext.brokenForkContext @@ -925,8 +925,8 @@ CodePathState.prototype = { this.pushChoiceContext("loop", false); this.loopContext = { upper: this.loopContext, - type: type, - label: label, + type, + label, test: void 0, entrySegments: null, continueForkContext: ForkContext.newEmpty(forkContext), @@ -938,8 +938,8 @@ CodePathState.prototype = { this.pushChoiceContext("loop", false); this.loopContext = { upper: this.loopContext, - type: type, - label: label, + type, + label, test: void 0, endOfInitSegments: null, testSegments: null, @@ -955,8 +955,8 @@ CodePathState.prototype = { case "ForOfStatement": this.loopContext = { upper: this.loopContext, - type: type, - label: label, + type, + label, prevSegments: null, leftSegments: null, endOfLeftSegments: null, @@ -976,7 +976,7 @@ CodePathState.prototype = { * * @returns {void} */ - popLoopContext: function() { + popLoopContext() { const context = this.loopContext; this.loopContext = context.upper; @@ -1047,7 +1047,7 @@ CodePathState.prototype = { * @param {boolean|undefined} test - The test value (only when constant). * @returns {void} */ - makeWhileTest: function(test) { + makeWhileTest(test) { const context = this.loopContext; const forkContext = this.forkContext; const testSegments = forkContext.makeNext(0, -1); @@ -1063,7 +1063,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeWhileBody: function() { + makeWhileBody() { const context = this.loopContext; const choiceContext = this.choiceContext; const forkContext = this.forkContext; @@ -1085,7 +1085,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeDoWhileBody: function() { + makeDoWhileBody() { const context = this.loopContext; const forkContext = this.forkContext; const bodySegments = forkContext.makeNext(-1, -1); @@ -1101,7 +1101,7 @@ CodePathState.prototype = { * @param {boolean|undefined} test - The test value (only when constant). * @returns {void} */ - makeDoWhileTest: function(test) { + makeDoWhileTest(test) { const context = this.loopContext; const forkContext = this.forkContext; @@ -1122,7 +1122,7 @@ CodePathState.prototype = { * @param {boolean|undefined} test - The test value (only when constant). * @returns {void} */ - makeForTest: function(test) { + makeForTest(test) { const context = this.loopContext; const forkContext = this.forkContext; const endOfInitSegments = forkContext.head; @@ -1140,7 +1140,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeForUpdate: function() { + makeForUpdate() { const context = this.loopContext; const choiceContext = this.choiceContext; const forkContext = this.forkContext; @@ -1167,7 +1167,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeForBody: function() { + makeForBody() { const context = this.loopContext; const choiceContext = this.choiceContext; const forkContext = this.forkContext; @@ -1219,7 +1219,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeForInOfLeft: function() { + makeForInOfLeft() { const context = this.loopContext; const forkContext = this.forkContext; const leftSegments = forkContext.makeDisconnected(-1, -1); @@ -1236,7 +1236,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeForInOfRight: function() { + makeForInOfRight() { const context = this.loopContext; const forkContext = this.forkContext; const temp = ForkContext.newEmpty(forkContext); @@ -1255,7 +1255,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeForInOfBody: function() { + makeForInOfBody() { const context = this.loopContext; const forkContext = this.forkContext; const temp = ForkContext.newEmpty(forkContext); @@ -1283,11 +1283,11 @@ CodePathState.prototype = { * @param {string|null} label - The label of this context. * @returns {Object} The new context. */ - pushBreakContext: function(breakable, label) { + pushBreakContext(breakable, label) { this.breakContext = { upper: this.breakContext, - breakable: breakable, - label: label, + breakable, + label, brokenForkContext: ForkContext.newEmpty(this.forkContext) }; return this.breakContext; @@ -1298,7 +1298,7 @@ CodePathState.prototype = { * * @returns {Object} The removed context. */ - popBreakContext: function() { + popBreakContext() { const context = this.breakContext; const forkContext = this.forkContext; @@ -1326,7 +1326,7 @@ CodePathState.prototype = { * @param {string} label - A label of the break statement. * @returns {void} */ - makeBreak: function(label) { + makeBreak(label) { const forkContext = this.forkContext; if (!forkContext.reachable) { @@ -1352,7 +1352,7 @@ CodePathState.prototype = { * @param {string} label - A label of the continue statement. * @returns {void} */ - makeContinue: function(label) { + makeContinue(label) { const forkContext = this.forkContext; if (!forkContext.reachable) { @@ -1387,7 +1387,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeReturn: function() { + makeReturn() { const forkContext = this.forkContext; if (forkContext.reachable) { @@ -1404,7 +1404,7 @@ CodePathState.prototype = { * * @returns {void} */ - makeThrow: function() { + makeThrow() { const forkContext = this.forkContext; if (forkContext.reachable) { @@ -1417,7 +1417,7 @@ CodePathState.prototype = { * Makes the final path. * @returns {void} */ - makeFinal: function() { + makeFinal() { const segments = this.currentSegments; if (segments.length > 0 && segments[0].reachable) { diff --git a/tools/eslint/lib/code-path-analysis/code-path.js b/tools/eslint/lib/code-path-analysis/code-path.js index cdafc89bbcb43e..1e7b76e5ab1dc7 100644 --- a/tools/eslint/lib/code-path-analysis/code-path.js +++ b/tools/eslint/lib/code-path-analysis/code-path.js @@ -123,7 +123,7 @@ CodePath.prototype = { * @param {Function} callback - A callback function. * @returns {void} */ - traverseSegments: function(options, callback) { + traverseSegments(options, callback) { if (typeof options === "function") { callback = options; options = null; @@ -142,14 +142,14 @@ CodePath.prototype = { let skippedSegment = null; let broken = false; const controller = { - skip: function() { + skip() { if (stack.length <= 1) { broken = true; } else { skippedSegment = stack[stack.length - 2][0]; } }, - break: function() { + break() { broken = true; } }; diff --git a/tools/eslint/lib/code-path-analysis/debug-helpers.js b/tools/eslint/lib/code-path-analysis/debug-helpers.js index 6c096867bffdf6..ac163268b62a65 100644 --- a/tools/eslint/lib/code-path-analysis/debug-helpers.js +++ b/tools/eslint/lib/code-path-analysis/debug-helpers.js @@ -143,7 +143,7 @@ module.exports = { * @param {Object} traceMap - Optional. A map to check whether or not segments had been done. * @returns {string} A DOT code of the code path. */ - makeDotArrows: function(codePath, traceMap) { + makeDotArrows(codePath, traceMap) { const stack = [[codePath.initialSegment, 0]]; const done = traceMap || Object.create(null); let lastId = codePath.initialSegment.id; diff --git a/tools/eslint/lib/code-path-analysis/fork-context.js b/tools/eslint/lib/code-path-analysis/fork-context.js index d728f11cbe1240..f47249b99848e5 100644 --- a/tools/eslint/lib/code-path-analysis/fork-context.js +++ b/tools/eslint/lib/code-path-analysis/fork-context.js @@ -150,7 +150,7 @@ ForkContext.prototype = { * @param {number} end - The last index of previous segments. * @returns {CodePathSegment[]} New segments. */ - makeNext: function(begin, end) { + makeNext(begin, end) { return makeSegments(this, begin, end, CodePathSegment.newNext); }, @@ -162,7 +162,7 @@ ForkContext.prototype = { * @param {number} end - The last index of previous segments. * @returns {CodePathSegment[]} New segments. */ - makeUnreachable: function(begin, end) { + makeUnreachable(begin, end) { return makeSegments(this, begin, end, CodePathSegment.newUnreachable); }, @@ -175,7 +175,7 @@ ForkContext.prototype = { * @param {number} end - The last index of previous segments. * @returns {CodePathSegment[]} New segments. */ - makeDisconnected: function(begin, end) { + makeDisconnected(begin, end) { return makeSegments(this, begin, end, CodePathSegment.newDisconnected); }, @@ -186,7 +186,7 @@ ForkContext.prototype = { * @param {CodePathSegment[]} segments - Segments to add. * @returns {void} */ - add: function(segments) { + add(segments) { assert(segments.length >= this.count, segments.length + " >= " + this.count); this.segmentsList.push(mergeExtraSegments(this, segments)); @@ -199,7 +199,7 @@ ForkContext.prototype = { * @param {CodePathSegment[]} segments - Segments to add. * @returns {void} */ - replaceHead: function(segments) { + replaceHead(segments) { assert(segments.length >= this.count, segments.length + " >= " + this.count); this.segmentsList.splice(-1, 1, mergeExtraSegments(this, segments)); @@ -211,7 +211,7 @@ ForkContext.prototype = { * @param {ForkContext} context - A fork context to add. * @returns {void} */ - addAll: function(context) { + addAll(context) { assert(context.count === this.count); const source = context.segmentsList; @@ -226,7 +226,7 @@ ForkContext.prototype = { * * @returns {void} */ - clear: function() { + clear() { this.segmentsList = []; } }; diff --git a/tools/eslint/lib/config.js b/tools/eslint/lib/config.js index 88c96ec3d40fcc..f3a03750cc3d2b 100644 --- a/tools/eslint/lib/config.js +++ b/tools/eslint/lib/config.js @@ -163,7 +163,7 @@ function getLocalConfig(thisConfig, directory) { noConfigError.messageTemplate = "no-config-found"; noConfigError.messageData = { - directory: directory, + directory, filesExamined: localConfigFiles }; diff --git a/tools/eslint/lib/config/autoconfig.js b/tools/eslint/lib/config/autoconfig.js index d8f29d5a0d49e5..5f558bb177bc14 100644 --- a/tools/eslint/lib/config/autoconfig.js +++ b/tools/eslint/lib/config/autoconfig.js @@ -52,7 +52,7 @@ function makeRegistryItems(rulesConfig) { return Object.keys(rulesConfig).reduce(function(accumulator, ruleId) { accumulator[ruleId] = rulesConfig[ruleId].map(function(config) { return { - config: config, + config, specificity: config.length || 1, errorCount: void 0 }; @@ -87,7 +87,7 @@ Registry.prototype = { * * @returns {void} */ - populateFromCoreRules: function() { + populateFromCoreRules() { const rulesConfig = configRule.createCoreRuleConfigs(); this.rules = makeRegistryItems(rulesConfig); @@ -107,7 +107,7 @@ Registry.prototype = { * @param {Object} registry The autoconfig registry * @returns {Object[]} "rules" configurations to use for linting */ - buildRuleSets: function() { + buildRuleSets() { let idx = 0; const ruleIds = Object.keys(this.rules), ruleSets = []; @@ -168,7 +168,7 @@ Registry.prototype = { * * @returns {void} */ - stripFailingConfigs: function() { + stripFailingConfigs() { const ruleIds = Object.keys(this.rules), newRegistry = new Registry(); @@ -193,7 +193,7 @@ Registry.prototype = { * * @returns {void} */ - stripExtraConfigs: function() { + stripExtraConfigs() { const ruleIds = Object.keys(this.rules), newRegistry = new Registry(); @@ -214,7 +214,7 @@ Registry.prototype = { * * @returns {Registry} A registry of failing rules. */ - getFailingRulesRegistry: function() { + getFailingRulesRegistry() { const ruleIds = Object.keys(this.rules), failingRegistry = new Registry(); @@ -237,7 +237,7 @@ Registry.prototype = { * * @returns {Object} An eslint config with rules section populated */ - createConfig: function() { + createConfig() { const ruleIds = Object.keys(this.rules), config = {rules: {}}; @@ -256,7 +256,7 @@ Registry.prototype = { * @param {number} specificity Only keep configs with this specificity * @returns {Registry} A registry of rules */ - filterBySpecificity: function(specificity) { + filterBySpecificity(specificity) { const ruleIds = Object.keys(this.rules), newRegistry = new Registry(); @@ -278,7 +278,7 @@ Registry.prototype = { * @param {progressCallback} [cb] Optional callback for reporting execution status * @returns {Registry} New registry with errorCount populated */ - lintSourceCode: function(sourceCodes, config, cb) { + lintSourceCode(sourceCodes, config, cb) { let ruleSetIdx, lintedRegistry; @@ -361,6 +361,6 @@ function extendFromRecommended(config) { //------------------------------------------------------------------------------ module.exports = { - Registry: Registry, - extendFromRecommended: extendFromRecommended + Registry, + extendFromRecommended }; diff --git a/tools/eslint/lib/config/config-file.js b/tools/eslint/lib/config/config-file.js index ca46575120348e..67c5970de02995 100644 --- a/tools/eslint/lib/config/config-file.js +++ b/tools/eslint/lib/config/config-file.js @@ -471,12 +471,12 @@ function resolve(filePath, relativeTo) { normalizedPackageName = normalizePackageName(packagePath, "eslint-plugin"); debug("Attempting to resolve " + normalizedPackageName); filePath = resolver.resolve(normalizedPackageName, getLookupPath(relativeTo)); - return { filePath: filePath, configName: configName }; + return { filePath, configName }; } else { normalizedPackageName = normalizePackageName(filePath, "eslint-config"); debug("Attempting to resolve " + normalizedPackageName); filePath = resolver.resolve(normalizedPackageName, getLookupPath(relativeTo)); - return { filePath: filePath }; + return { filePath }; } } @@ -546,14 +546,14 @@ function load(filePath, applyEnvironments, relativeTo) { module.exports = { - getBaseDir: getBaseDir, - getLookupPath: getLookupPath, - load: load, - resolve: resolve, - write: write, - applyExtends: applyExtends, - normalizePackageName: normalizePackageName, - CONFIG_FILES: CONFIG_FILES, + getBaseDir, + getLookupPath, + load, + resolve, + write, + applyExtends, + normalizePackageName, + CONFIG_FILES, /** * Retrieves the configuration filename for a given directory. It loops over all @@ -562,7 +562,7 @@ module.exports = { * @returns {?string} The filename of the configuration file for the directory * or null if there is no configuration file in the directory. */ - getFilenameForDirectory: function(directory) { + getFilenameForDirectory(directory) { for (let i = 0, len = CONFIG_FILES.length; i < len; i++) { const filename = path.join(directory, CONFIG_FILES[i]); diff --git a/tools/eslint/lib/config/config-initializer.js b/tools/eslint/lib/config/config-initializer.js index 36b641147e2265..202c3bfcd0add7 100644 --- a/tools/eslint/lib/config/config-initializer.js +++ b/tools/eslint/lib/config/config-initializer.js @@ -305,8 +305,8 @@ function promptUser(callback) { type: "list", name: "styleguide", message: "Which style guide do you want to follow?", - choices: [{name: "Google", value: "google"}, {name: "AirBnB", value: "airbnb"}, {name: "Standard", value: "standard"}], - when: function(answers) { + choices: [{name: "Google", value: "google"}, {name: "Airbnb", value: "airbnb"}, {name: "Standard", value: "standard"}], + when(answers) { answers.packageJsonExists = npmUtil.checkPackageJson(); return answers.source === "guide" && answers.packageJsonExists; } @@ -315,10 +315,10 @@ function promptUser(callback) { type: "input", name: "patterns", message: "Which file(s), path(s), or glob(s) should be examined?", - when: function(answers) { + when(answers) { return (answers.source === "auto"); }, - validate: function(input) { + validate(input) { if (input.trim().length === 0 && input.trim() !== ",") { return "You must tell us what code to examine. Try again."; } @@ -331,7 +331,7 @@ function promptUser(callback) { message: "What format do you want your config file to be in?", default: "JavaScript", choices: ["JavaScript", "YAML", "JSON"], - when: function(answers) { + when(answers) { return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto"); } } @@ -367,7 +367,7 @@ function promptUser(callback) { name: "modules", message: "Are you using ES6 modules?", default: false, - when: function(answers) { + when(answers) { return answers.es6 === true; } }, @@ -383,7 +383,7 @@ function promptUser(callback) { name: "commonjs", message: "Do you use CommonJS?", default: false, - when: function(answers) { + when(answers) { return answers.env.some(function(env) { return env === "browser"; }); @@ -400,7 +400,7 @@ function promptUser(callback) { name: "react", message: "Do you use React", default: false, - when: function(answers) { + when(answers) { return answers.jsx; } } @@ -479,9 +479,9 @@ function promptUser(callback) { //------------------------------------------------------------------------------ const init = { - getConfigForStyleGuide: getConfigForStyleGuide, - processAnswers: processAnswers, - initializeConfig: /* istanbul ignore next */ function(callback) { + getConfigForStyleGuide, + processAnswers, + /* istanbul ignore next */initializeConfig(callback) { promptUser(callback); } }; diff --git a/tools/eslint/lib/config/config-ops.js b/tools/eslint/lib/config/config-ops.js index 7a52f983f98f91..d0e791b54854ff 100644 --- a/tools/eslint/lib/config/config-ops.js +++ b/tools/eslint/lib/config/config-ops.js @@ -34,7 +34,7 @@ module.exports = { * Creates an empty configuration object suitable for merging as a base. * @returns {Object} A configuration object. */ - createEmptyConfig: function() { + createEmptyConfig() { return { globals: {}, env: {}, @@ -49,7 +49,7 @@ module.exports = { * @returns {Object} A configuration object with the appropriate rules and globals * set. */ - createEnvironmentConfig: function(env) { + createEnvironmentConfig(env) { const envConfig = this.createEmptyConfig(); @@ -84,7 +84,7 @@ module.exports = { * @param {Object} config The configuration information. * @returns {Object} The updated configuration information. */ - applyEnvironments: function(config) { + applyEnvironments(config) { if (config.env && typeof config.env === "object") { debug("Apply environment settings to config"); return this.merge(this.createEnvironmentConfig(config.env), config); @@ -196,7 +196,7 @@ module.exports = { * @param {Object} config The config object to normalize. * @returns {void} */ - normalize: function(config) { + normalize(config) { if (config.rules) { Object.keys(config.rules).forEach(function(ruleId) { @@ -218,7 +218,7 @@ module.exports = { * @param {Object} config The config object to normalize. * @returns {void} */ - normalizeToStrings: function(config) { + normalizeToStrings(config) { if (config.rules) { Object.keys(config.rules).forEach(function(ruleId) { @@ -238,7 +238,7 @@ module.exports = { * @param {int|string|Array} ruleConfig The configuration for an individual rule. * @returns {boolean} True if the rule represents an error, false if not. */ - isErrorSeverity: function(ruleConfig) { + isErrorSeverity(ruleConfig) { let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; @@ -254,7 +254,7 @@ module.exports = { * @param {number|string|Array} ruleConfig - The configuration for an individual rule. * @returns {boolean} `true` if the configuration has valid severity. */ - isValidSeverity: function(ruleConfig) { + isValidSeverity(ruleConfig) { let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; if (typeof severity === "string") { @@ -268,7 +268,7 @@ module.exports = { * @param {Object} config - The configuration for rules. * @returns {boolean} `true` if the configuration has valid severity. */ - isEverySeverityValid: function(config) { + isEverySeverityValid(config) { return Object.keys(config).every(function(ruleId) { return this.isValidSeverity(config[ruleId]); }, this); diff --git a/tools/eslint/lib/config/config-rule.js b/tools/eslint/lib/config/config-rule.js index ea8162d42db38e..eb5c23fe8c840a 100644 --- a/tools/eslint/lib/config/config-rule.js +++ b/tools/eslint/lib/config/config-rule.js @@ -202,7 +202,7 @@ RuleConfigSet.prototype = { * @param {number} [severity=2] The level of severity for the rule (0, 1, 2) * @returns {void} */ - addErrorSeverity: function(severity) { + addErrorSeverity(severity) { severity = severity || 2; this.ruleConfigs = this.ruleConfigs.map(function(config) { @@ -219,7 +219,7 @@ RuleConfigSet.prototype = { * @param {string[]} enums Array of valid rule options (e.g. ["always", "never"]) * @returns {void} */ - addEnums: function(enums) { + addEnums(enums) { this.ruleConfigs = this.ruleConfigs.concat(combineArrays(this.ruleConfigs, enums)); }, @@ -228,10 +228,10 @@ RuleConfigSet.prototype = { * @param {Object} obj Schema item with type === "object" * @returns {void} */ - addObject: function(obj) { + addObject(obj) { const objectConfigSet = { objectConfigs: [], - add: function(property, values) { + add(property, values) { for (let idx = 0; idx < values.length; idx++) { const optionObj = {}; @@ -240,7 +240,7 @@ RuleConfigSet.prototype = { } }, - combine: function() { + combine() { this.objectConfigs = groupByProperty(this.objectConfigs).reduce(function(accumulator, objArr) { return combinePropertyObjects(accumulator, objArr); }, []); @@ -317,6 +317,6 @@ function createCoreRuleConfigs() { //------------------------------------------------------------------------------ module.exports = { - generateConfigsFromSchema: generateConfigsFromSchema, - createCoreRuleConfigs: createCoreRuleConfigs + generateConfigsFromSchema, + createCoreRuleConfigs }; diff --git a/tools/eslint/lib/config/config-validator.js b/tools/eslint/lib/config/config-validator.js index 8bd1e28d82de65..ef285eae4e6032 100644 --- a/tools/eslint/lib/config/config-validator.js +++ b/tools/eslint/lib/config/config-validator.js @@ -171,7 +171,7 @@ function validate(config, source) { //------------------------------------------------------------------------------ module.exports = { - getRuleOptionsSchema: getRuleOptionsSchema, - validate: validate, - validateRuleOptions: validateRuleOptions + getRuleOptionsSchema, + validate, + validateRuleOptions }; diff --git a/tools/eslint/lib/config/plugins.js b/tools/eslint/lib/config/plugins.js index 9b813f3c148546..73c8a7daf26b77 100644 --- a/tools/eslint/lib/config/plugins.js +++ b/tools/eslint/lib/config/plugins.js @@ -9,7 +9,7 @@ //------------------------------------------------------------------------------ const Environments = require("./environments"), - rules = require("../rules"); + Rules = require("../rules"); const debug = require("debug")("eslint:plugins"); @@ -55,9 +55,9 @@ function removeNamespace(pluginName) { module.exports = { - removePrefix: removePrefix, - getNamespace: getNamespace, - removeNamespace: removeNamespace, + removePrefix, + getNamespace, + removeNamespace, /** * Defines a plugin with a given name rather than loading from disk. @@ -65,18 +65,22 @@ module.exports = { * @param {Object} plugin The plugin object. * @returns {void} */ - define: function(pluginName, plugin) { - const pluginNameWithoutNamespace = removeNamespace(pluginName), - pluginNameWithoutPrefix = removePrefix(pluginNameWithoutNamespace); - - plugins[pluginNameWithoutPrefix] = plugin; + define(pluginName, plugin) { + const pluginNamespace = getNamespace(pluginName), + pluginNameWithoutNamespace = removeNamespace(pluginName), + pluginNameWithoutPrefix = removePrefix(pluginNameWithoutNamespace), + shortName = pluginNamespace + pluginNameWithoutPrefix; // load up environments and rules - Environments.importPlugin(plugin, pluginNameWithoutPrefix); + plugins[shortName] = plugin; + Environments.importPlugin(plugin, shortName); + Rules.importPlugin(plugin, shortName); - if (plugin.rules) { - rules.import(plugin.rules, pluginNameWithoutPrefix); - } + // load up environments and rules for the name that '@scope/' was omitted + // 3 lines below will be removed by 4.0.0 + plugins[pluginNameWithoutPrefix] = plugin; + Environments.importPlugin(plugin, pluginNameWithoutPrefix); + Rules.importPlugin(plugin, pluginNameWithoutPrefix); }, /** @@ -84,7 +88,7 @@ module.exports = { * @param {string} pluginName The name of the plugin to retrieve. * @returns {Object} The plugin or null if not loaded. */ - get: function(pluginName) { + get(pluginName) { return plugins[pluginName] || null; }, @@ -92,7 +96,7 @@ module.exports = { * Returns all plugins that are loaded. * @returns {Object} The plugins cache. */ - getAll: function() { + getAll() { return plugins; }, @@ -102,21 +106,23 @@ module.exports = { * @returns {void} * @throws {Error} If the plugin cannot be loaded. */ - load: function(pluginName) { + load(pluginName) { const pluginNamespace = getNamespace(pluginName), pluginNameWithoutNamespace = removeNamespace(pluginName), - pluginNameWithoutPrefix = removePrefix(pluginNameWithoutNamespace); + pluginNameWithoutPrefix = removePrefix(pluginNameWithoutNamespace), + shortName = pluginNamespace + pluginNameWithoutPrefix, + longName = pluginNamespace + PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix; let plugin = null; - if (!plugins[pluginNameWithoutPrefix]) { + if (!plugins[shortName]) { try { - plugin = require(pluginNamespace + PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix); + plugin = require(longName); } catch (err) { - debug("Failed to load plugin eslint-plugin-" + pluginNameWithoutPrefix + ". Proceeding without it."); + debug("Failed to load plugin " + longName + "."); err.message = "Failed to load plugin " + pluginName + ": " + err.message; err.messageTemplate = "plugin-missing"; err.messageData = { - pluginName: pluginNameWithoutPrefix + pluginName: longName }; throw err; } @@ -131,7 +137,7 @@ module.exports = { * @returns {void} * @throws {Error} If a plugin cannot be loaded. */ - loadAll: function(pluginNames) { + loadAll(pluginNames) { pluginNames.forEach(this.load, this); }, @@ -139,7 +145,7 @@ module.exports = { * Resets plugin information. Use for tests only. * @returns {void} */ - testReset: function() { + testReset() { plugins = Object.create(null); } }; diff --git a/tools/eslint/lib/eslint.js b/tools/eslint/lib/eslint.js index 87d02cc36eb8c3..81483e1a261cb3 100755 --- a/tools/eslint/lib/eslint.js +++ b/tools/eslint/lib/eslint.js @@ -59,7 +59,7 @@ function parseBooleanConfig(string, comment) { items[name] = { value: (value === "true"), - comment: comment + comment }; }); @@ -240,14 +240,14 @@ function disableReporting(reportingConfig, start, rulesToDisable) { if (rulesToDisable.length) { rulesToDisable.forEach(function(rule) { reportingConfig.push({ - start: start, + start, end: null, - rule: rule + rule }); }); } else { reportingConfig.push({ - start: start, + start, end: null, rule: null }); @@ -406,6 +406,28 @@ function isDisabledByReportingConfig(reportingConfig, ruleId, location) { return false; } +/** + * Normalize ECMAScript version from the initial config + * @param {number} ecmaVersion ECMAScript version from the initial config + * @param {boolean} isModule Whether the source type is module or not + * @returns {number} normalized ECMAScript version + */ +function normalizeEcmaVersion(ecmaVersion, isModule) { + + // Need at least ES6 for modules + if (isModule && (!ecmaVersion || ecmaVersion < 6)) { + ecmaVersion = 6; + } + + // Calculate ECMAScript edition number from official year version starting with + // ES2015, which corresponds with ES6 (or a difference of 2009). + if (ecmaVersion >= 2015) { + ecmaVersion -= 2009; + } + + return ecmaVersion; +} + /** * Process initial config to make it safe to extend by file comment config * @param {Object} config Initial config @@ -453,21 +475,19 @@ function prepareConfig(config) { settings: ConfigOps.merge({}, config.settings || {}), parserOptions: ConfigOps.merge(parserOptions, config.parserOptions || {}) }; + const isModule = preparedConfig.parserOptions.sourceType === "module"; - if (preparedConfig.parserOptions.sourceType === "module") { + if (isModule) { if (!preparedConfig.parserOptions.ecmaFeatures) { preparedConfig.parserOptions.ecmaFeatures = {}; } // can't have global return inside of modules preparedConfig.parserOptions.ecmaFeatures.globalReturn = false; - - // also need at least ES6 for modules - if (!preparedConfig.parserOptions.ecmaVersion || preparedConfig.parserOptions.ecmaVersion < 6) { - preparedConfig.parserOptions.ecmaVersion = 6; - } } + preparedConfig.parserOptions.ecmaVersion = normalizeEcmaVersion(preparedConfig.parserOptions.ecmaVersion, isModule); + return preparedConfig; } @@ -485,7 +505,7 @@ function createStubRule(message) { */ function createRuleModule(context) { return { - Program: function(node) { + Program(node) { context.report(node, message); } }; @@ -632,7 +652,7 @@ module.exports = (function() { ruleId: null, fatal: true, severity: 2, - source: source, + source, message: "Parsing error: " + message, line: ex.lineNumber, @@ -841,7 +861,7 @@ module.exports = (function() { ignoreEval: true, nodejsScope: ecmaFeatures.globalReturn, impliedStrict: ecmaFeatures.impliedStrict, - ecmaVersion: ecmaVersion, + ecmaVersion, sourceType: currentConfig.parserOptions.sourceType || "script", fallback: Traverser.getKeys }); @@ -890,11 +910,11 @@ module.exports = (function() { * and react accordingly. */ traverser.traverse(ast, { - enter: function(node, parent) { + enter(node, parent) { node.parent = parent; eventGenerator.enterNode(node); }, - leave: function(node) { + leave(node) { eventGenerator.leaveNode(node); } }); @@ -965,9 +985,9 @@ module.exports = (function() { } const problem = { - ruleId: ruleId, - severity: severity, - message: message, + ruleId, + severity, + message, line: location.line, column: location.column + 1, // switch to 1-base instead of 0-base nodeType: node && node.type, diff --git a/tools/eslint/lib/formatters/html.js b/tools/eslint/lib/formatters/html.js index 95437b95e2dc19..a5c324bee31cc7 100644 --- a/tools/eslint/lib/formatters/html.js +++ b/tools/eslint/lib/formatters/html.js @@ -75,9 +75,9 @@ function renderMessages(messages, parentIndex) { const columnNumber = message.column || 0; return messageTemplate({ - parentIndex: parentIndex, - lineNumber: lineNumber, - columnNumber: columnNumber, + parentIndex, + lineNumber, + columnNumber, severityNumber: message.severity, severityName: message.severity === 1 ? "Warning" : "Error", message: message.message, @@ -93,7 +93,7 @@ function renderMessages(messages, parentIndex) { function renderResults(results) { return lodash.map(results, function(result, index) { return resultTemplate({ - index: index, + index, color: renderColor(result.errorCount, result.warningCount), filePath: result.filePath, summary: renderSummary(result.errorCount, result.warningCount) diff --git a/tools/eslint/lib/formatters/stylish.js b/tools/eslint/lib/formatters/stylish.js index cb73777c2e55f1..ee70bf5d74db09 100644 --- a/tools/eslint/lib/formatters/stylish.js +++ b/tools/eslint/lib/formatters/stylish.js @@ -67,7 +67,7 @@ module.exports = function(results) { }), { align: ["", "r", "l"], - stringLength: function(str) { + stringLength(str) { return chalk.stripColor(str).length; } } diff --git a/tools/eslint/lib/formatters/table.js b/tools/eslint/lib/formatters/table.js index 7e793f80fbdfb4..4fc5ad3953414f 100644 --- a/tools/eslint/lib/formatters/table.js +++ b/tools/eslint/lib/formatters/table.js @@ -78,7 +78,7 @@ function drawTable(messages) { wrapWord: true } }, - drawHorizontalLine: function(index) { + drawHorizontalLine(index) { return index === 1; } }); @@ -143,7 +143,7 @@ module.exports = function(report) { wrapWord: true } }, - drawHorizontalLine: function() { + drawHorizontalLine() { return true; } }); diff --git a/tools/eslint/lib/ignored-paths.js b/tools/eslint/lib/ignored-paths.js index ab63fcee059dd8..4e0953885c6ddb 100644 --- a/tools/eslint/lib/ignored-paths.js +++ b/tools/eslint/lib/ignored-paths.js @@ -23,9 +23,15 @@ const debug = require("debug")("eslint:ignored-paths"); //------------------------------------------------------------------------------ const ESLINT_IGNORE_FILENAME = ".eslintignore"; + +/** + * Adds `"*"` at the end of `"node_modules/"`, + * so that subtle directories could be re-included by .gitignore patterns + * such as `"!node_modules/should_not_ignored"` + */ const DEFAULT_IGNORE_DIRS = [ - "node_modules/", - "bower_components/" + "/node_modules/*", + "/bower_components/*" ]; const DEFAULT_OPTIONS = { dotfiles: false, @@ -40,7 +46,7 @@ const DEFAULT_OPTIONS = { /** * Find an ignore file in the current directory. - * @param {stirng} cwd Current working directory + * @param {string} cwd Current working directory * @returns {string} Path of ignore file or an empty string. */ function findIgnoreFile(cwd) { @@ -96,9 +102,7 @@ function IgnoredPaths(options) { return ig.add(fs.readFileSync(filepath, "utf8")); } - this.defaultPatterns = DEFAULT_IGNORE_DIRS.map(function(dir) { - return "/" + dir + "*"; - }).concat(options.patterns || []); + this.defaultPatterns = [].concat(DEFAULT_IGNORE_DIRS, options.patterns || []); this.baseDir = options.cwd; this.ig = { @@ -191,34 +195,37 @@ IgnoredPaths.prototype.contains = function(filepath, category) { /** * Returns a list of dir patterns for glob to ignore - * @returns {string[]} list of glob ignore patterns + * @returns {function()} method to check whether a folder should be ignored by glob. */ -IgnoredPaths.prototype.getIgnoredFoldersGlobPatterns = function() { - let dirs = DEFAULT_IGNORE_DIRS; +IgnoredPaths.prototype.getIgnoredFoldersGlobChecker = function() { - if (this.options.ignore) { + const ig = ignore().add(DEFAULT_IGNORE_DIRS); - /* eslint-disable no-underscore-dangle */ + if (this.options.ignore) { + ig.add(this.ig.custom); + } - const patterns = this.ig.custom._rules.filter(function(rule) { - return rule.negative; - }).map(function(rule) { - return rule.origin; - }); + const filter = ig.createFilter(); - /* eslint-enable no-underscore-dangle */ + /** + * TODO + * 1. + * Actually, it should be `this.options.baseDir`, which is the base dir of `ignore-path`, + * as well as Line 177. + * But doing this leads to a breaking change and fails tests. + * Related to #6759 + */ + const base = this.options.cwd; - dirs = dirs.filter(function(dir) { - return patterns.every(function(p) { - return (p.indexOf("!" + dir) !== 0 && p.indexOf("!/" + dir) !== 0); - }); - }); - } + return function(absolutePath) { + const relative = pathUtil.getRelativePath(absolutePath, base); + if (!relative) { + return false; + } - return dirs.map(function(dir) { - return dir + "**"; - }); + return !filter(relative); + }; }; module.exports = IgnoredPaths; diff --git a/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js b/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js index dea9b79e04cfbf..783a1109e76571 100644 --- a/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js +++ b/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js @@ -176,12 +176,12 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let exportsNode; let ruleIsFixable = false; return { - AssignmentExpression: function(node) { + AssignmentExpression(node) { if (node.left && node.right && node.left.type === "MemberExpression" && @@ -192,7 +192,7 @@ module.exports = { } }, - CallExpression: function(node) { + CallExpression(node) { // If the rule has a call for `context.report` and a property `fix` // is being passed in, then we consider that the rule is fixable. @@ -214,7 +214,7 @@ module.exports = { } }, - "Program:exit": function() { + "Program:exit"() { if (!isCorrectExportsFormat(exportsNode)) { context.report(exportsNode, "Rule does not export an Object. Make sure the rule follows the new rule format."); return; diff --git a/tools/eslint/lib/logging.js b/tools/eslint/lib/logging.js index 3a60879c617923..e1f8338769e938 100644 --- a/tools/eslint/lib/logging.js +++ b/tools/eslint/lib/logging.js @@ -14,7 +14,7 @@ module.exports = { * Cover for console.log * @returns {void} */ - info: function() { + info() { console.log.apply(console, Array.prototype.slice.call(arguments)); }, @@ -22,7 +22,7 @@ module.exports = { * Cover for console.error * @returns {void} */ - error: function() { + error() { console.error.apply(console, Array.prototype.slice.call(arguments)); } }; diff --git a/tools/eslint/lib/rule-context.js b/tools/eslint/lib/rule-context.js index c400fc254ff236..ded5dab962d70c 100644 --- a/tools/eslint/lib/rule-context.js +++ b/tools/eslint/lib/rule-context.js @@ -96,7 +96,7 @@ RuleContext.prototype = { * Passthrough to eslint.getSourceCode(). * @returns {SourceCode} The SourceCode object for the code. */ - getSourceCode: function() { + getSourceCode() { return this.eslint.getSourceCode(); }, @@ -110,7 +110,7 @@ RuleContext.prototype = { * with symbols being replaced by this object's values. * @returns {void} */ - report: function(nodeOrDescriptor, location, message, opts) { + report(nodeOrDescriptor, location, message, opts) { // check to see if it's a new style call if (arguments.length === 1) { diff --git a/tools/eslint/lib/rules.js b/tools/eslint/lib/rules.js index 19ac9f469edb12..ee8695f48d9f34 100644 --- a/tools/eslint/lib/rules.js +++ b/tools/eslint/lib/rules.js @@ -47,17 +47,19 @@ function load(rulesDir, cwd) { /** * Registers all given rules of a plugin. - * @param {Object} pluginRules A key/value map of rule definitions. + * @param {Object} plugin The plugin object to import. * @param {string} pluginName The name of the plugin without prefix (`eslint-plugin-`). * @returns {void} */ -function importPlugin(pluginRules, pluginName) { - Object.keys(pluginRules).forEach(function(ruleId) { - const qualifiedRuleId = pluginName + "/" + ruleId, - rule = pluginRules[ruleId]; - - define(qualifiedRuleId, rule); - }); +function importPlugin(plugin, pluginName) { + if (plugin.rules) { + Object.keys(plugin.rules).forEach(function(ruleId) { + const qualifiedRuleId = pluginName + "/" + ruleId, + rule = plugin.rules[ruleId]; + + define(qualifiedRuleId, rule); + }); + } } /** @@ -65,7 +67,7 @@ function importPlugin(pluginRules, pluginName) { * @param {string} ruleId Rule id (file name). * @returns {Function} Rule handler. */ -function get(ruleId) { +function getHandler(ruleId) { if (typeof rules[ruleId] === "string") { return require(rules[ruleId]); } else { @@ -83,17 +85,17 @@ function testClear() { } module.exports = { - define: define, - load: load, - import: importPlugin, - get: get, - testClear: testClear, + define, + load, + importPlugin, + get: getHandler, + testClear, /** * Resets rules to its starting state. Use for tests only. * @returns {void} */ - testReset: function() { + testReset() { testClear(); load(); } diff --git a/tools/eslint/lib/rules/accessor-pairs.js b/tools/eslint/lib/rules/accessor-pairs.js index abd69668fcb2d4..7e8870edc8c8e1 100644 --- a/tools/eslint/lib/rules/accessor-pairs.js +++ b/tools/eslint/lib/rules/accessor-pairs.js @@ -90,7 +90,7 @@ module.exports = { additionalProperties: false }] }, - create: function(context) { + create(context) { const config = context.options[0] || {}; const checkGetWithoutSet = config.getWithoutSet === true; const checkSetWithoutGet = config.setWithoutGet !== false; @@ -146,7 +146,7 @@ module.exports = { } return { - ObjectExpression: function(node) { + ObjectExpression(node) { if (checkSetWithoutGet || checkGetWithoutSet) { checkLonelySetGet(node); } diff --git a/tools/eslint/lib/rules/array-bracket-spacing.js b/tools/eslint/lib/rules/array-bracket-spacing.js index 04376953f1e6fe..2b93a92806ddf8 100644 --- a/tools/eslint/lib/rules/array-bracket-spacing.js +++ b/tools/eslint/lib/rules/array-bracket-spacing.js @@ -39,7 +39,7 @@ module.exports = { } ] }, - create: function(context) { + create(context) { const spaced = context.options[0] === "always", sourceCode = context.getSourceCode(); @@ -55,7 +55,7 @@ module.exports = { } const options = { - spaced: spaced, + spaced, singleElementException: isOptionSet("singleValue"), objectsInArraysException: isOptionSet("objectsInArrays"), arraysInArraysException: isOptionSet("arraysInArrays") @@ -73,10 +73,10 @@ module.exports = { */ function reportNoBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "There should be no space after '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { const nextToken = sourceCode.getTokenAfter(token); return fixer.removeRange([token.range[1], nextToken.range[0]]); @@ -92,10 +92,10 @@ module.exports = { */ function reportNoEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "There should be no space before '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { const previousToken = sourceCode.getTokenBefore(token); return fixer.removeRange([previousToken.range[1], token.range[0]]); @@ -111,10 +111,10 @@ module.exports = { */ function reportRequiredBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "A space is required after '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(token, " "); } }); @@ -128,10 +128,10 @@ module.exports = { */ function reportRequiredEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "A space is required before '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(token, " "); } }); diff --git a/tools/eslint/lib/rules/array-callback-return.js b/tools/eslint/lib/rules/array-callback-return.js index 4ea95299660993..d85ba0422df12e 100644 --- a/tools/eslint/lib/rules/array-callback-return.js +++ b/tools/eslint/lib/rules/array-callback-return.js @@ -142,7 +142,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let funcInfo = { upper: null, codePath: null, @@ -165,7 +165,7 @@ module.exports = { funcInfo.codePath.currentSegments.some(isReachable) ) { context.report({ - node: node, + node, loc: getLocation(node, context.getSourceCode()).loc.start, message: funcInfo.hasReturn ? "Expected to return a value at the end of this function." @@ -177,10 +177,10 @@ module.exports = { return { // Stacks this function's information. - onCodePathStart: function(codePath, node) { + onCodePathStart(codePath, node) { funcInfo = { upper: funcInfo, - codePath: codePath, + codePath, hasReturn: false, shouldCheck: TARGET_NODE_TYPE.test(node.type) && @@ -190,18 +190,18 @@ module.exports = { }, // Pops this function's information. - onCodePathEnd: function() { + onCodePathEnd() { funcInfo = funcInfo.upper; }, // Checks the return statement is valid. - ReturnStatement: function(node) { + ReturnStatement(node) { if (funcInfo.shouldCheck) { funcInfo.hasReturn = true; if (!node.argument) { context.report({ - node: node, + node, message: "Expected a return value." }); } diff --git a/tools/eslint/lib/rules/arrow-body-style.js b/tools/eslint/lib/rules/arrow-body-style.js index 521c101658ecfc..038aeeb5af2550 100644 --- a/tools/eslint/lib/rules/arrow-body-style.js +++ b/tools/eslint/lib/rules/arrow-body-style.js @@ -49,7 +49,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const options = context.options; const always = options[0] === "always"; const asNeeded = !options[0] || options[0] === "as-needed"; @@ -67,7 +67,7 @@ module.exports = { if (arrowBody.type === "BlockStatement") { if (never) { context.report({ - node: node, + node, loc: arrowBody.loc.start, message: "Unexpected block statement surrounding arrow body." }); @@ -85,7 +85,7 @@ module.exports = { if (asNeeded && blockBody[0].type === "ReturnStatement") { context.report({ - node: node, + node, loc: arrowBody.loc.start, message: "Unexpected block statement surrounding arrow body." }); @@ -94,7 +94,7 @@ module.exports = { } else { if (always || (asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression")) { context.report({ - node: node, + node, loc: arrowBody.loc.start, message: "Expected block statement surrounding arrow body." }); diff --git a/tools/eslint/lib/rules/arrow-parens.js b/tools/eslint/lib/rules/arrow-parens.js index 60b683168ebcde..46b79ecf81dc5d 100644 --- a/tools/eslint/lib/rules/arrow-parens.js +++ b/tools/eslint/lib/rules/arrow-parens.js @@ -34,7 +34,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const message = "Expected parentheses around arrow function argument."; const asNeededMessage = "Unexpected parentheses around single function argument."; const asNeeded = context.options[0] === "as-needed"; @@ -62,9 +62,9 @@ module.exports = { ) { if (token.type === "Punctuator" && token.value === "(") { context.report({ - node: node, + node, message: requireForBlockBodyMessage, - fix: function(fixer) { + fix(fixer) { const paramToken = context.getTokenAfter(token); const closingParenToken = context.getTokenAfter(paramToken); @@ -84,9 +84,9 @@ module.exports = { ) { if (token.type !== "Punctuator" || token.value !== "(") { context.report({ - node: node, + node, message: requireForBlockBodyNoParensMessage, - fix: function(fixer) { + fix(fixer) { return fixer.replaceText(token, "(" + token.value + ")"); } }); @@ -98,9 +98,9 @@ module.exports = { if (asNeeded && node.params.length === 1 && node.params[0].type === "Identifier") { if (token.type === "Punctuator" && token.value === "(") { context.report({ - node: node, + node, message: asNeededMessage, - fix: function(fixer) { + fix(fixer) { const paramToken = context.getTokenAfter(token); const closingParenToken = context.getTokenAfter(paramToken); @@ -120,9 +120,9 @@ module.exports = { // (x) => x if (after.value !== ")") { context.report({ - node: node, - message: message, - fix: function(fixer) { + node, + message, + fix(fixer) { return fixer.replaceText(token, "(" + token.value + ")"); } }); diff --git a/tools/eslint/lib/rules/arrow-spacing.js b/tools/eslint/lib/rules/arrow-spacing.js index 570dfe5d6903b1..fb2fbbfa356c5c 100644 --- a/tools/eslint/lib/rules/arrow-spacing.js +++ b/tools/eslint/lib/rules/arrow-spacing.js @@ -34,7 +34,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // merge rules with default const rule = { before: true, after: true }, @@ -60,7 +60,7 @@ module.exports = { } const after = sourceCode.getTokenAfter(t); - return { before: before, arrow: t, after: after }; + return { before, arrow: t, after }; } /** @@ -72,7 +72,7 @@ module.exports = { const before = tokens.arrow.range[0] - tokens.before.range[1]; const after = tokens.after.range[0] - tokens.arrow.range[1]; - return { before: before, after: after }; + return { before, after }; } /** @@ -93,7 +93,7 @@ module.exports = { context.report({ node: tokens.before, message: "Missing space before =>.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(tokens.arrow, " "); } }); @@ -105,7 +105,7 @@ module.exports = { context.report({ node: tokens.before, message: "Unexpected space before =>.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]); } }); @@ -119,7 +119,7 @@ module.exports = { context.report({ node: tokens.after, message: "Missing space after =>.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(tokens.arrow, " "); } }); @@ -131,7 +131,7 @@ module.exports = { context.report({ node: tokens.after, message: "Unexpected space after =>.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]); } }); diff --git a/tools/eslint/lib/rules/block-scoped-var.js b/tools/eslint/lib/rules/block-scoped-var.js index c8b0d0c765e46d..0f4705a1f140d9 100644 --- a/tools/eslint/lib/rules/block-scoped-var.js +++ b/tools/eslint/lib/rules/block-scoped-var.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let stack = []; /** @@ -92,7 +92,7 @@ module.exports = { } return { - Program: function(node) { + Program(node) { stack = [node.range]; }, diff --git a/tools/eslint/lib/rules/block-spacing.js b/tools/eslint/lib/rules/block-spacing.js index f50e432179f084..802eb15aa0f8b1 100644 --- a/tools/eslint/lib/rules/block-spacing.js +++ b/tools/eslint/lib/rules/block-spacing.js @@ -26,7 +26,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const always = (context.options[0] !== "never"), message = always ? "Requires a space" : "Unexpected space(s)", sourceCode = context.getSourceCode(); @@ -95,10 +95,10 @@ module.exports = { // Check. if (!isValid(openBrace, firstToken)) { context.report({ - node: node, + node, loc: openBrace.loc.start, message: message + " after '{'.", - fix: function(fixer) { + fix(fixer) { if (always) { return fixer.insertTextBefore(firstToken, " "); } @@ -109,10 +109,10 @@ module.exports = { } if (!isValid(lastToken, closeBrace)) { context.report({ - node: node, + node, loc: closeBrace.loc.start, message: message + " before '}'.", - fix: function(fixer) { + fix(fixer) { if (always) { return fixer.insertTextAfter(lastToken, " "); } diff --git a/tools/eslint/lib/rules/brace-style.js b/tools/eslint/lib/rules/brace-style.js index 256f4c0349ce1d..6bd8a8f4c87edb 100644 --- a/tools/eslint/lib/rules/brace-style.js +++ b/tools/eslint/lib/rules/brace-style.js @@ -33,7 +33,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const style = context.options[0] || "1tbs", params = context.options[1] || {}, sourceCode = context.getSourceCode(); diff --git a/tools/eslint/lib/rules/callback-return.js b/tools/eslint/lib/rules/callback-return.js index 699eaa7ea69989..242ef666d2ac6e 100644 --- a/tools/eslint/lib/rules/callback-return.js +++ b/tools/eslint/lib/rules/callback-return.js @@ -22,7 +22,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const callbacks = context.options[0] || ["callback", "cb", "next"], sourceCode = context.getSourceCode(); @@ -110,7 +110,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - CallExpression: function(node) { + CallExpression(node) { // if we're not a callback we can return if (!isCallback(node)) { diff --git a/tools/eslint/lib/rules/camelcase.js b/tools/eslint/lib/rules/camelcase.js index e3f8a10770bdf3..1b22c25e675ca3 100644 --- a/tools/eslint/lib/rules/camelcase.js +++ b/tools/eslint/lib/rules/camelcase.js @@ -30,7 +30,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -73,7 +73,7 @@ module.exports = { return { - Identifier: function(node) { + Identifier(node) { /* * Leading and trailing underscores are commonly used to flag diff --git a/tools/eslint/lib/rules/class-methods-use-this.js b/tools/eslint/lib/rules/class-methods-use-this.js new file mode 100644 index 00000000000000..edf5278353384e --- /dev/null +++ b/tools/eslint/lib/rules/class-methods-use-this.js @@ -0,0 +1,80 @@ +/** + * @fileoverview Rule to enforce that all class methods use 'this'. + * @author Patrick Williams + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "enforce that class methods utilize `this`", + category: "Best Practices", + recommended: false + }, + schema: [] + }, + create(context) { + const stack = []; + + /** + * Initializes the current context to false and pushes it onto the stack. + * These booleans represent whether 'this' has been used in the context. + * @returns {void} + * @private + */ + function enterFunction() { + stack.push(false); + } + + /** + * Check if the node is an instance method + * @param {ASTNode} node - node to check + * @returns {boolean} True if its an instance method + * @private + */ + function isInstanceMethod(node) { + return !node.static && node.kind !== "constructor" && node.type === "MethodDefinition"; + } + + /** + * Checks if we are leaving a function that is a method, and reports if 'this' has not been used. + * Static methods and the constructor are exempt. + * Then pops the context off the stack. + * @param {ASTNode} node - A function node that was entered. + * @returns {void} + * @private + */ + function exitFunction(node) { + const methodUsesThis = stack.pop(); + + if (isInstanceMethod(node.parent) && !methodUsesThis) { + context.report(node, "Expected 'this' to be used by class method '" + node.parent.key.name + "'."); + } + } + + /** + * Mark the current context as having used 'this'. + * @returns {void} + * @private + */ + function markThisUsed() { + if (stack.length) { + stack[stack.length - 1] = true; + } + } + + return { + FunctionDeclaration: enterFunction, + "FunctionDeclaration:exit": exitFunction, + FunctionExpression: enterFunction, + "FunctionExpression:exit": exitFunction, + ThisExpression: markThisUsed, + Super: markThisUsed + }; + } +}; diff --git a/tools/eslint/lib/rules/comma-dangle.js b/tools/eslint/lib/rules/comma-dangle.js index 719ae124c6a549..621bc2f63ea7ff 100644 --- a/tools/eslint/lib/rules/comma-dangle.js +++ b/tools/eslint/lib/rules/comma-dangle.js @@ -44,7 +44,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const mode = context.options[0]; const UNEXPECTED_MESSAGE = "Unexpected trailing comma."; const MISSING_MESSAGE = "Missing trailing comma."; @@ -112,7 +112,7 @@ module.exports = { node: lastItem, loc: trailingToken.loc.start, message: UNEXPECTED_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.remove(trailingToken); } }); @@ -157,7 +157,7 @@ module.exports = { node: lastItem, loc: lastItem.loc.end, message: MISSING_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(penultimateToken, ","); } }); diff --git a/tools/eslint/lib/rules/comma-spacing.js b/tools/eslint/lib/rules/comma-spacing.js index c8d01847dfde9f..4c1ac288859fd4 100644 --- a/tools/eslint/lib/rules/comma-spacing.js +++ b/tools/eslint/lib/rules/comma-spacing.js @@ -36,7 +36,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const tokensAndComments = sourceCode.tokensAndComments; @@ -73,8 +73,8 @@ module.exports = { */ function report(node, dir, otherNode) { context.report({ - node: node, - fix: function(fixer) { + node, + fix(fixer) { if (options[dir]) { if (dir === "before") { return fixer.insertTextBefore(node, " "); @@ -160,7 +160,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program:exit": function() { + "Program:exit"() { tokensAndComments.forEach(function(token, i) { if (!isComma(token)) { diff --git a/tools/eslint/lib/rules/comma-style.js b/tools/eslint/lib/rules/comma-style.js index 9a7c4613d01acb..1ce226b39f8125 100644 --- a/tools/eslint/lib/rules/comma-style.js +++ b/tools/eslint/lib/rules/comma-style.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const style = context.options[0] || "last", sourceCode = context.getSourceCode(); let exceptions = {}; diff --git a/tools/eslint/lib/rules/complexity.js b/tools/eslint/lib/rules/complexity.js index 10f8655dcce2c9..0d837e74d3b650 100644 --- a/tools/eslint/lib/rules/complexity.js +++ b/tools/eslint/lib/rules/complexity.js @@ -44,7 +44,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const option = context.options[0]; let THRESHOLD = 20; @@ -91,7 +91,7 @@ module.exports = { } if (complexity > THRESHOLD) { - context.report(node, "Function '{{name}}' has a complexity of {{complexity}}.", { name: name, complexity: complexity }); + context.report(node, "Function '{{name}}' has a complexity of {{complexity}}.", { name, complexity }); } } diff --git a/tools/eslint/lib/rules/computed-property-spacing.js b/tools/eslint/lib/rules/computed-property-spacing.js index d2861554310d8b..fea3f7387d63e8 100644 --- a/tools/eslint/lib/rules/computed-property-spacing.js +++ b/tools/eslint/lib/rules/computed-property-spacing.js @@ -27,7 +27,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never" @@ -44,10 +44,10 @@ module.exports = { */ function reportNoBeginningSpace(node, token, tokenAfter) { context.report({ - node: node, + node, loc: token.loc.start, message: "There should be no space after '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([token.range[1], tokenAfter.range[0]]); } }); @@ -62,10 +62,10 @@ module.exports = { */ function reportNoEndingSpace(node, token, tokenBefore) { context.report({ - node: node, + node, loc: token.loc.start, message: "There should be no space before '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([tokenBefore.range[1], token.range[0]]); } }); @@ -79,10 +79,10 @@ module.exports = { */ function reportRequiredBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "A space is required after '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(token, " "); } }); @@ -96,10 +96,10 @@ module.exports = { */ function reportRequiredEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "A space is required before '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(token, " "); } }); diff --git a/tools/eslint/lib/rules/consistent-return.js b/tools/eslint/lib/rules/consistent-return.js index 42fd91e3fbed02..5e09e0dddf7408 100644 --- a/tools/eslint/lib/rules/consistent-return.js +++ b/tools/eslint/lib/rules/consistent-return.js @@ -56,7 +56,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const treatUndefinedAsUnspecified = options.treatUndefinedAsUnspecified === true; let funcInfo = null; @@ -110,31 +110,31 @@ module.exports = { // Reports. context.report({ - node: node, - loc: loc, + node, + loc, message: "Expected to return a value at the end of this {{type}}.", - data: {type: type} + data: {type} }); } return { // Initializes/Disposes state of each code path. - onCodePathStart: function(codePath) { + onCodePathStart(codePath) { funcInfo = { upper: funcInfo, - codePath: codePath, + codePath, hasReturn: false, hasReturnValue: false, message: "" }; }, - onCodePathEnd: function() { + onCodePathEnd() { funcInfo = funcInfo.upper; }, // Reports a given return statement if it's inconsistent. - ReturnStatement: function(node) { + ReturnStatement(node) { const argument = node.argument; let hasReturnValue = Boolean(argument); @@ -147,7 +147,7 @@ module.exports = { funcInfo.hasReturnValue = hasReturnValue; funcInfo.message = "Expected " + (hasReturnValue ? "a" : "no") + " return value."; } else if (funcInfo.hasReturnValue !== hasReturnValue) { - context.report({node: node, message: funcInfo.message}); + context.report({node, message: funcInfo.message}); } }, diff --git a/tools/eslint/lib/rules/consistent-this.js b/tools/eslint/lib/rules/consistent-this.js index c61f9da6cb939a..2a068ed1fc2add 100644 --- a/tools/eslint/lib/rules/consistent-this.js +++ b/tools/eslint/lib/rules/consistent-this.js @@ -26,7 +26,7 @@ module.exports = { } }, - create: function(context) { + create(context) { let aliases = []; if (context.options.length === 0) { @@ -45,7 +45,7 @@ module.exports = { function reportBadAssignment(node, alias) { context.report(node, "Designated alias '{{alias}}' is not assigned to 'this'.", - { alias: alias }); + { alias }); } /** @@ -65,7 +65,7 @@ module.exports = { } } else if (isThis) { context.report(node, - "Unexpected alias '{{name}}' for 'this'.", { name: name }); + "Unexpected alias '{{name}}' for 'this'.", { name }); } } @@ -127,7 +127,7 @@ module.exports = { "FunctionExpression:exit": ensureWasAssigned, "FunctionDeclaration:exit": ensureWasAssigned, - VariableDeclarator: function(node) { + VariableDeclarator(node) { const id = node.id; const isDestructuring = id.type === "ArrayPattern" || id.type === "ObjectPattern"; @@ -137,7 +137,7 @@ module.exports = { } }, - AssignmentExpression: function(node) { + AssignmentExpression(node) { if (node.left.type === "Identifier") { checkAssignment(node, node.left.name, node.right); } diff --git a/tools/eslint/lib/rules/constructor-super.js b/tools/eslint/lib/rules/constructor-super.js index 68bbc5ec18d87a..49271cee5899be 100644 --- a/tools/eslint/lib/rules/constructor-super.js +++ b/tools/eslint/lib/rules/constructor-super.js @@ -101,7 +101,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /* * {{hasExtends: boolean, scope: Scope, codePath: CodePath}[]} @@ -160,7 +160,7 @@ module.exports = { * @param {ASTNode} node - The current node. * @returns {void} */ - onCodePathStart: function(codePath, node) { + onCodePathStart(codePath, node) { if (isConstructorFunction(node)) { // Class > ClassBody > MethodDefinition > FunctionExpression @@ -172,7 +172,7 @@ module.exports = { isConstructor: true, hasExtends: Boolean(superClass), superIsConstructor: isPossibleConstructor(superClass), - codePath: codePath + codePath }; } else { funcInfo = { @@ -180,7 +180,7 @@ module.exports = { isConstructor: false, hasExtends: false, superIsConstructor: false, - codePath: codePath + codePath }; } }, @@ -192,7 +192,7 @@ module.exports = { * @param {ASTNode} node - The current node. * @returns {void} */ - onCodePathEnd: function(codePath, node) { + onCodePathEnd(codePath, node) { const hasExtends = funcInfo.hasExtends; // Pop. @@ -222,7 +222,7 @@ module.exports = { * @param {CodePathSegment} segment - A code path segment to initialize. * @returns {void} */ - onCodePathSegmentStart: function(segment) { + onCodePathSegmentStart(segment) { if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) { return; } @@ -252,7 +252,7 @@ module.exports = { * of a loop. * @returns {void} */ - onCodePathSegmentLoop: function(fromSegment, toSegment) { + onCodePathSegmentLoop(fromSegment, toSegment) { if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) { return; } @@ -281,7 +281,7 @@ module.exports = { context.report({ message: "Unexpected duplicate 'super()'.", - node: node + node }); } } @@ -294,7 +294,7 @@ module.exports = { * @param {ASTNode} node - A CallExpression node to check. * @returns {void} */ - "CallExpression:exit": function(node) { + "CallExpression:exit"(node) { if (!(funcInfo && funcInfo.isConstructor)) { return; } @@ -325,12 +325,12 @@ module.exports = { if (duplicate) { context.report({ message: "Unexpected duplicate 'super()'.", - node: node + node }); } else if (!funcInfo.superIsConstructor) { context.report({ message: "Unexpected 'super()' because 'super' is not a constructor.", - node: node + node }); } else { info.validNodes.push(node); @@ -339,7 +339,7 @@ module.exports = { } else if (funcInfo.codePath.currentSegments.some(isReachable)) { context.report({ message: "Unexpected 'super()'.", - node: node + node }); } }, @@ -349,7 +349,7 @@ module.exports = { * @param {ASTNode} node - A ReturnStatement node to check. * @returns {void} */ - ReturnStatement: function(node) { + ReturnStatement(node) { if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) { return; } @@ -377,7 +377,7 @@ module.exports = { * Resets state. * @returns {void} */ - "Program:exit": function() { + "Program:exit"() { segInfoMap = Object.create(null); } }; diff --git a/tools/eslint/lib/rules/curly.js b/tools/eslint/lib/rules/curly.js index 5ca7713763c8ce..b33736e87d9bc7 100644 --- a/tools/eslint/lib/rules/curly.js +++ b/tools/eslint/lib/rules/curly.js @@ -51,7 +51,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const multiOnly = (context.options[0] === "multi"); const multiLine = (context.options[0] === "multi-line"); @@ -144,11 +144,11 @@ module.exports = { */ function reportExpectedBraceError(node, name, suffix) { context.report({ - node: node, + node, loc: (name !== "else" ? node : getElseKeyword(node)).loc.start, message: "Expected { after '{{name}}'{{suffix}}.", data: { - name: name, + name, suffix: (suffix ? " " + suffix : "") } }); @@ -164,11 +164,11 @@ module.exports = { */ function reportUnnecessaryBraceError(node, name, suffix) { context.report({ - node: node, + node, loc: (name !== "else" ? node : getElseKeyword(node)).loc.start, message: "Unnecessary { after '{{name}}'{{suffix}}.", data: { - name: name, + name, suffix: (suffix ? " " + suffix : "") } }); @@ -214,8 +214,8 @@ module.exports = { return { actual: hasBlock, - expected: expected, - check: function() { + expected, + check() { if (this.expected !== null && this.expected !== this.actual) { if (this.expected) { reportExpectedBraceError(node, name, suffix); @@ -272,7 +272,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - IfStatement: function(node) { + IfStatement(node) { if (node.parent.type !== "IfStatement") { prepareIfChecks(node).forEach(function(preparedCheck) { preparedCheck.check(); @@ -280,23 +280,23 @@ module.exports = { } }, - WhileStatement: function(node) { + WhileStatement(node) { prepareCheck(node, node.body, "while", "condition").check(); }, - DoWhileStatement: function(node) { + DoWhileStatement(node) { prepareCheck(node, node.body, "do").check(); }, - ForStatement: function(node) { + ForStatement(node) { prepareCheck(node, node.body, "for", "condition").check(); }, - ForInStatement: function(node) { + ForInStatement(node) { prepareCheck(node, node.body, "for-in").check(); }, - ForOfStatement: function(node) { + ForOfStatement(node) { prepareCheck(node, node.body, "for-of").check(); } }; diff --git a/tools/eslint/lib/rules/default-case.js b/tools/eslint/lib/rules/default-case.js index 8a6135d24b611d..e062798db235ab 100644 --- a/tools/eslint/lib/rules/default-case.js +++ b/tools/eslint/lib/rules/default-case.js @@ -29,7 +29,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const commentPattern = options.commentPattern ? new RegExp(options.commentPattern) : @@ -56,7 +56,7 @@ module.exports = { return { - SwitchStatement: function(node) { + SwitchStatement(node) { if (!node.cases.length) { diff --git a/tools/eslint/lib/rules/dot-location.js b/tools/eslint/lib/rules/dot-location.js index f632ce51907f32..3f2b1e44705be1 100644 --- a/tools/eslint/lib/rules/dot-location.js +++ b/tools/eslint/lib/rules/dot-location.js @@ -26,7 +26,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0]; diff --git a/tools/eslint/lib/rules/dot-notation.js b/tools/eslint/lib/rules/dot-notation.js index 2cbbe07eb15f36..a8a64a280c594c 100644 --- a/tools/eslint/lib/rules/dot-notation.js +++ b/tools/eslint/lib/rules/dot-notation.js @@ -35,7 +35,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const allowKeywords = options.allowKeywords === void 0 || !!options.allowKeywords; @@ -46,7 +46,7 @@ module.exports = { } return { - MemberExpression: function(node) { + MemberExpression(node) { if ( node.computed && node.property.type === "Literal" && diff --git a/tools/eslint/lib/rules/eol-last.js b/tools/eslint/lib/rules/eol-last.js index 15021dd0929e7f..ef15635cb51206 100644 --- a/tools/eslint/lib/rules/eol-last.js +++ b/tools/eslint/lib/rules/eol-last.js @@ -25,7 +25,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Public @@ -46,10 +46,10 @@ module.exports = { // file is not newline-terminated location.line = src.split(/\n/g).length; context.report({ - node: node, + node, loc: location, message: "Newline required at end of file but not found.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfterRange([0, src.length], linebreak); } }); diff --git a/tools/eslint/lib/rules/eqeqeq.js b/tools/eslint/lib/rules/eqeqeq.js index 7bec40ad38aea8..4d61399f207ba7 100644 --- a/tools/eslint/lib/rules/eqeqeq.js +++ b/tools/eslint/lib/rules/eqeqeq.js @@ -50,7 +50,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const config = context.options[0] || "always"; const options = context.options[1] || {}; const sourceCode = context.getSourceCode(); @@ -124,15 +124,15 @@ module.exports = { */ function report(node, message) { context.report({ - node: node, + node, loc: getOperatorLocation(node), - message: message, + message, data: { op: node.operator.charAt(0) } }); } return { - BinaryExpression: function(node) { + BinaryExpression(node) { const isNull = isNullCheck(node); if (node.operator !== "==" && node.operator !== "!=") { diff --git a/tools/eslint/lib/rules/func-call-spacing.js b/tools/eslint/lib/rules/func-call-spacing.js index b0fc0f2ef38cb5..36699ee52ae6a7 100644 --- a/tools/eslint/lib/rules/func-call-spacing.js +++ b/tools/eslint/lib/rules/func-call-spacing.js @@ -53,7 +53,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const never = context.options[0] !== "always"; const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines; @@ -116,28 +116,28 @@ module.exports = { if (never && hasWhitespace) { context.report({ - node: node, + node, loc: lastCalleeToken.loc.start, message: "Unexpected space between function name and paren.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); } }); } else if (!never && !hasWhitespace) { context.report({ - node: node, + node, loc: lastCalleeToken.loc.start, message: "Missing space between function name and paren.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(parenToken, " "); } }); } else if (!never && !allowNewlines && hasNewline) { context.report({ - node: node, + node, loc: lastCalleeToken.loc.start, message: "Unexpected newline between function name and paren.", - fix: function(fixer) { + fix(fixer) { return fixer.replaceTextRange([prevToken.range[1], parenToken.range[0]], " "); } }); diff --git a/tools/eslint/lib/rules/func-names.js b/tools/eslint/lib/rules/func-names.js index a2fe1e972d4fc1..397ef37e91614d 100644 --- a/tools/eslint/lib/rules/func-names.js +++ b/tools/eslint/lib/rules/func-names.js @@ -33,7 +33,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const never = context.options[0] === "never"; /** @@ -54,7 +54,7 @@ module.exports = { } return { - "FunctionExpression:exit": function(node) { + "FunctionExpression:exit"(node) { // Skip recursive functions. const nameVar = context.getDeclaredVariables(node)[0]; diff --git a/tools/eslint/lib/rules/func-style.js b/tools/eslint/lib/rules/func-style.js index 47cb76ee22df81..e0974209c4bb78 100644 --- a/tools/eslint/lib/rules/func-style.js +++ b/tools/eslint/lib/rules/func-style.js @@ -32,7 +32,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const style = context.options[0], allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions === true, @@ -40,29 +40,29 @@ module.exports = { stack = []; const nodesToCheck = { - FunctionDeclaration: function(node) { + FunctionDeclaration(node) { stack.push(false); if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") { context.report(node, "Expected a function expression."); } }, - "FunctionDeclaration:exit": function() { + "FunctionDeclaration:exit"() { stack.pop(); }, - FunctionExpression: function(node) { + FunctionExpression(node) { stack.push(false); if (enforceDeclarations && node.parent.type === "VariableDeclarator") { context.report(node.parent, "Expected a function declaration."); } }, - "FunctionExpression:exit": function() { + "FunctionExpression:exit"() { stack.pop(); }, - ThisExpression: function() { + ThisExpression() { if (stack.length > 0) { stack[stack.length - 1] = true; } diff --git a/tools/eslint/lib/rules/generator-star-spacing.js b/tools/eslint/lib/rules/generator-star-spacing.js index 12576171877c82..017211d46c9dbe 100644 --- a/tools/eslint/lib/rules/generator-star-spacing.js +++ b/tools/eslint/lib/rules/generator-star-spacing.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const mode = (function(option) { if (!option || typeof option === "string") { @@ -90,9 +90,9 @@ module.exports = { const message = type + " space " + side + " *."; context.report({ - node: node, - message: message, - fix: function(fixer) { + node, + message, + fix(fixer) { if (spaceRequired) { if (after) { return fixer.insertTextAfter(node, " "); diff --git a/tools/eslint/lib/rules/global-require.js b/tools/eslint/lib/rules/global-require.js index 6addefc8c815b6..3d6492cfde4671 100644 --- a/tools/eslint/lib/rules/global-require.js +++ b/tools/eslint/lib/rules/global-require.js @@ -59,9 +59,9 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - CallExpression: function(node) { + CallExpression(node) { const currentScope = context.getScope(); if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) { diff --git a/tools/eslint/lib/rules/guard-for-in.js b/tools/eslint/lib/rules/guard-for-in.js index bc25b2c9cb9560..7ccfec90c1c572 100644 --- a/tools/eslint/lib/rules/guard-for-in.js +++ b/tools/eslint/lib/rules/guard-for-in.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ForInStatement: function(node) { + ForInStatement(node) { /* * If the for-in statement has {}, then the real body is the body diff --git a/tools/eslint/lib/rules/handle-callback-err.js b/tools/eslint/lib/rules/handle-callback-err.js index c6f464aa1b8a7e..e8c6d1b3b8f647 100644 --- a/tools/eslint/lib/rules/handle-callback-err.js +++ b/tools/eslint/lib/rules/handle-callback-err.js @@ -24,7 +24,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const errorArgument = context.options[0] || "err"; diff --git a/tools/eslint/lib/rules/id-blacklist.js b/tools/eslint/lib/rules/id-blacklist.js index 2d2b40100a5130..8795cfc6be6964 100644 --- a/tools/eslint/lib/rules/id-blacklist.js +++ b/tools/eslint/lib/rules/id-blacklist.js @@ -27,7 +27,7 @@ module.exports = { } }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- @@ -74,7 +74,7 @@ module.exports = { return { - Identifier: function(node) { + Identifier(node) { const name = node.name, effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent; diff --git a/tools/eslint/lib/rules/id-length.js b/tools/eslint/lib/rules/id-length.js index 3f0d233529fad3..d3a942cd040bed 100644 --- a/tools/eslint/lib/rules/id-length.js +++ b/tools/eslint/lib/rules/id-length.js @@ -44,7 +44,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const minLength = typeof options.min !== "undefined" ? options.min : 2; const maxLength = typeof options.max !== "undefined" ? options.max : Infinity; @@ -66,10 +66,10 @@ module.exports = { parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent) ); }, - AssignmentPattern: function(parent, node) { + AssignmentPattern(parent, node) { return parent.left === node; }, - VariableDeclarator: function(parent, node) { + VariableDeclarator(parent, node) { return parent.id === node; }, Property: properties && function(parent, node) { @@ -86,7 +86,7 @@ module.exports = { }; return { - Identifier: function(node) { + Identifier(node) { const name = node.name; const parent = node.parent; @@ -105,7 +105,7 @@ module.exports = { isShort ? "Identifier name '{{name}}' is too short (< {{min}})." : "Identifier name '{{name}}' is too long (> {{max}}).", - { name: name, min: minLength, max: maxLength } + { name, min: minLength, max: maxLength } ); } } diff --git a/tools/eslint/lib/rules/id-match.js b/tools/eslint/lib/rules/id-match.js index 777dacfbca63fd..961a1859049d24 100644 --- a/tools/eslint/lib/rules/id-match.js +++ b/tools/eslint/lib/rules/id-match.js @@ -32,7 +32,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -77,13 +77,13 @@ module.exports = { function report(node) { context.report(node, "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", { name: node.name, - pattern: pattern + pattern }); } return { - Identifier: function(node) { + Identifier(node) { const name = node.name, parent = node.parent, effectiveParent = (parent.type === "MemberExpression") ? parent.parent : parent; diff --git a/tools/eslint/lib/rules/indent.js b/tools/eslint/lib/rules/indent.js index 287e8dea376876..f2acda4496c1db 100644 --- a/tools/eslint/lib/rules/indent.js +++ b/tools/eslint/lib/rules/indent.js @@ -80,7 +80,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const MESSAGE = "Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}."; const DEFAULT_VARIABLE_INDENT = 1; @@ -152,10 +152,10 @@ module.exports = { */ function report(node, needed, gotten, loc, isLastNodeCheck) { const msgContext = { - needed: needed, + needed, type: indentType, characters: needed === 1 ? "character" : "characters", - gotten: gotten + gotten }; const indentChar = indentType === "space" ? " " : "\t"; @@ -206,15 +206,15 @@ module.exports = { if (loc) { context.report({ - node: node, - loc: loc, + node, + loc, message: MESSAGE, data: msgContext, fix: getFixerFunction() }); } else { context.report({ - node: node, + node, message: MESSAGE, data: msgContext, fix: getFixerFunction() @@ -268,6 +268,16 @@ module.exports = { ) { report(node, indent, nodeIndent); } + + if (node.type === "IfStatement" && node.alternate) { + const elseToken = sourceCode.getTokenBefore(node.alternate); + + checkNodeIndent(elseToken, indent, excludeCommas); + + if (!isNodeFirstInLine(node.alternate)) { + checkNodeIndent(node.alternate, indent, excludeCommas); + } + } } /** @@ -278,14 +288,7 @@ module.exports = { * @returns {void} */ function checkNodesIndent(nodes, indent, excludeCommas) { - nodes.forEach(function(node) { - if (node.type === "IfStatement" && node.alternate) { - const elseToken = sourceCode.getTokenBefore(node.alternate); - - checkNodeIndent(elseToken, indent, excludeCommas); - } - checkNodeIndent(node, indent, excludeCommas); - }); + nodes.forEach(node => checkNodeIndent(node, indent, excludeCommas)); } /** @@ -784,7 +787,7 @@ module.exports = { } return { - Program: function(node) { + Program(node) { if (node.body.length > 0) { // Root nodes should have no indent @@ -806,27 +809,27 @@ module.exports = { DoWhileStatement: blockLessNodes, - IfStatement: function(node) { + IfStatement(node) { if (node.consequent.type !== "BlockStatement" && node.consequent.loc.start.line > node.loc.start.line) { blockIndentationCheck(node); } }, - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (node.declarations[node.declarations.length - 1].loc.start.line > node.declarations[0].loc.start.line) { checkIndentInVariableDeclarations(node); } }, - ObjectExpression: function(node) { + ObjectExpression(node) { checkIndentInArrayOrObjectBlock(node); }, - ArrayExpression: function(node) { + ArrayExpression(node) { checkIndentInArrayOrObjectBlock(node); }, - MemberExpression: function(node) { + MemberExpression(node) { if (typeof options.MemberExpression === "undefined") { return; } @@ -860,7 +863,7 @@ module.exports = { checkNodesIndent(checkNodes, propertyIndent); }, - SwitchStatement: function(node) { + SwitchStatement(node) { // Switch is not a 'BlockStatement' const switchIndent = getNodeIndent(node); @@ -872,7 +875,7 @@ module.exports = { checkLastNodeLineIndent(node, switchIndent); }, - SwitchCase: function(node) { + SwitchCase(node) { // Skip inline cases if (isSingleLineNode(node)) { diff --git a/tools/eslint/lib/rules/init-declarations.js b/tools/eslint/lib/rules/init-declarations.js index bbcb3a92ffd915..c8ff363c1f8d86 100644 --- a/tools/eslint/lib/rules/init-declarations.js +++ b/tools/eslint/lib/rules/init-declarations.js @@ -85,7 +85,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const MODE_ALWAYS = "always", MODE_NEVER = "never"; @@ -98,7 +98,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "VariableDeclaration:exit": function(node) { + "VariableDeclaration:exit"(node) { const kind = node.kind, declarations = node.declarations; diff --git a/tools/eslint/lib/rules/jsx-quotes.js b/tools/eslint/lib/rules/jsx-quotes.js index 99dfda76a24e51..4a9de7acef6bc6 100644 --- a/tools/eslint/lib/rules/jsx-quotes.js +++ b/tools/eslint/lib/rules/jsx-quotes.js @@ -19,14 +19,14 @@ const QUOTE_SETTINGS = { "prefer-double": { quote: "\"", description: "singlequote", - convert: function(str) { + convert(str) { return str.replace(/'/g, "\""); } }, "prefer-single": { quote: "'", description: "doublequote", - convert: function(str) { + convert(str) { return str.replace(/"/g, "'"); } } @@ -53,7 +53,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const quoteOption = context.options[0] || "prefer-double", setting = QUOTE_SETTINGS[quoteOption]; @@ -68,14 +68,14 @@ module.exports = { } return { - JSXAttribute: function(node) { + JSXAttribute(node) { const attributeValue = node.value; if (attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) { context.report({ node: attributeValue, message: "Unexpected usage of " + setting.description + ".", - fix: function(fixer) { + fix(fixer) { return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw)); } }); diff --git a/tools/eslint/lib/rules/key-spacing.js b/tools/eslint/lib/rules/key-spacing.js index 83741822f4e4fb..0b39f7429a29b8 100644 --- a/tools/eslint/lib/rules/key-spacing.js +++ b/tools/eslint/lib/rules/key-spacing.js @@ -323,7 +323,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { /** * OPTIONS @@ -464,7 +464,7 @@ module.exports = { computed: property.computed ? "computed " : "", key: getKey(property) }, - fix: fix + fix }); } } @@ -616,7 +616,7 @@ module.exports = { if (alignmentOptions) { // Verify vertical alignment return { - ObjectExpression: function(node) { + ObjectExpression(node) { if (isSingleLine(node)) { verifyListSpacing(node.properties.filter(isKeyValueProperty)); } else { @@ -628,7 +628,7 @@ module.exports = { } else { // Obey beforeColon and afterColon in each property as configured return { - Property: function(node) { + Property(node) { verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions); } }; diff --git a/tools/eslint/lib/rules/keyword-spacing.js b/tools/eslint/lib/rules/keyword-spacing.js index 74bf4c5cb40cbe..1f5b133f3794cd 100644 --- a/tools/eslint/lib/rules/keyword-spacing.js +++ b/tools/eslint/lib/rules/keyword-spacing.js @@ -100,7 +100,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); /** @@ -126,7 +126,7 @@ module.exports = { loc: token.loc.start, message: "Expected space(s) before \"{{value}}\".", data: token, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(token, " "); } }); @@ -156,7 +156,7 @@ module.exports = { loc: token.loc.start, message: "Unexpected space(s) before \"{{value}}\".", data: token, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([prevToken.range[1], token.range[0]]); } }); @@ -186,7 +186,7 @@ module.exports = { loc: token.loc.start, message: "Expected space(s) after \"{{value}}\".", data: token, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(token, " "); } }); @@ -216,7 +216,7 @@ module.exports = { loc: token.loc.start, message: "Unexpected space(s) after \"{{value}}\".", data: token, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([token.range[1], nextToken.range[0]]); } }); diff --git a/tools/eslint/lib/rules/linebreak-style.js b/tools/eslint/lib/rules/linebreak-style.js index 80b64e370ad44f..6f1a451cdb47bb 100644 --- a/tools/eslint/lib/rules/linebreak-style.js +++ b/tools/eslint/lib/rules/linebreak-style.js @@ -26,7 +26,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const EXPECTED_LF_MSG = "Expected linebreaks to be 'LF' but found 'CRLF'.", EXPECTED_CRLF_MSG = "Expected linebreaks to be 'CRLF' but found 'LF'."; @@ -75,7 +75,7 @@ module.exports = { const range = [index, index + match[0].length]; context.report({ - node: node, + node, loc: { line: i, column: sourceCode.lines[i - 1].length diff --git a/tools/eslint/lib/rules/lines-around-comment.js b/tools/eslint/lib/rules/lines-around-comment.js index 885d136b313c4f..094fefa74f4646 100644 --- a/tools/eslint/lib/rules/lines-around-comment.js +++ b/tools/eslint/lib/rules/lines-around-comment.js @@ -106,7 +106,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] ? Object.assign({}, context.options[0]) : {}; @@ -316,9 +316,9 @@ module.exports = { const range = [lineStart, lineStart]; context.report({ - node: node, + node, message: "Expected line before comment.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBeforeRange(range, "\n"); } }); @@ -328,9 +328,9 @@ module.exports = { if (!exceptionEndAllowed && after && !lodash.includes(commentAndEmptyLines, nextLineNum) && !(isCommentNodeType(nextTokenOrComment) && astUtils.isTokenOnSameLine(node, nextTokenOrComment))) { context.report({ - node: node, + node, message: "Expected line after comment.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(node, "\n"); } }); @@ -344,7 +344,7 @@ module.exports = { return { - LineComment: function(node) { + LineComment(node) { if (options.beforeLineComment || options.afterLineComment) { checkForEmptyLine(node, { after: options.afterLineComment, @@ -353,7 +353,7 @@ module.exports = { } }, - BlockComment: function(node) { + BlockComment(node) { if (options.beforeBlockComment || options.afterBlockComment) { checkForEmptyLine(node, { after: options.afterBlockComment, diff --git a/tools/eslint/lib/rules/max-depth.js b/tools/eslint/lib/rules/max-depth.js index 383509f8cb03e1..35b7e9ce8946de 100644 --- a/tools/eslint/lib/rules/max-depth.js +++ b/tools/eslint/lib/rules/max-depth.js @@ -43,7 +43,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -115,7 +115,7 @@ module.exports = { FunctionExpression: startFunction, ArrowFunctionExpression: startFunction, - IfStatement: function(node) { + IfStatement(node) { if (node.parent.type !== "IfStatement") { pushBlock(node); } diff --git a/tools/eslint/lib/rules/max-len.js b/tools/eslint/lib/rules/max-len.js index 2b19aedf0ac25e..e5add9be0a8f22 100644 --- a/tools/eslint/lib/rules/max-len.js +++ b/tools/eslint/lib/rules/max-len.js @@ -69,7 +69,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { /* * Inspired by http://tools.ietf.org/html/rfc3986#appendix-B, however: diff --git a/tools/eslint/lib/rules/max-lines.js b/tools/eslint/lib/rules/max-lines.js index 333167de4b0db4..a54ad9e3538dbc 100644 --- a/tools/eslint/lib/rules/max-lines.js +++ b/tools/eslint/lib/rules/max-lines.js @@ -51,7 +51,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const option = context.options[0]; let max = 300; @@ -113,9 +113,9 @@ module.exports = { } return { - "Program:exit": function() { + "Program:exit"() { let lines = sourceCode.lines.map(function(text, i) { - return { lineNumber: i + 1, text: text }; + return { lineNumber: i + 1, text }; }); if (skipBlankLines) { diff --git a/tools/eslint/lib/rules/max-nested-callbacks.js b/tools/eslint/lib/rules/max-nested-callbacks.js index 37953dc757d795..7e0c3d24738862 100644 --- a/tools/eslint/lib/rules/max-nested-callbacks.js +++ b/tools/eslint/lib/rules/max-nested-callbacks.js @@ -43,7 +43,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Constants diff --git a/tools/eslint/lib/rules/max-params.js b/tools/eslint/lib/rules/max-params.js index f5a40d931c9710..165362556c2780 100644 --- a/tools/eslint/lib/rules/max-params.js +++ b/tools/eslint/lib/rules/max-params.js @@ -43,7 +43,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const option = context.options[0]; let numParams = 3; diff --git a/tools/eslint/lib/rules/max-statements-per-line.js b/tools/eslint/lib/rules/max-statements-per-line.js index a3482fea796e7b..d1991cc6420977 100644 --- a/tools/eslint/lib/rules/max-statements-per-line.js +++ b/tools/eslint/lib/rules/max-statements-per-line.js @@ -30,7 +30,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(), options = context.options[0] || {}, @@ -89,7 +89,7 @@ module.exports = { // Reports if the node violated this rule. if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1) { - context.report({node: node, message: message}); + context.report({node, message}); } } @@ -166,7 +166,7 @@ module.exports = { // Empty blocks should be warned if `{max: 0}` was given. BlockStatement: function reportIfZero(node) { if (maxStatementsPerLine === 0 && node.body.length === 0) { - context.report({node: node, message: message}); + context.report({node, message}); } } }; diff --git a/tools/eslint/lib/rules/max-statements.js b/tools/eslint/lib/rules/max-statements.js index d56e755287c944..b2dc2b4d73fdcb 100644 --- a/tools/eslint/lib/rules/max-statements.js +++ b/tools/eslint/lib/rules/max-statements.js @@ -52,7 +52,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -87,7 +87,7 @@ module.exports = { context.report( node, "This function has too many statements ({{count}}). Maximum allowed is {{max}}.", - { count: count, max: max }); + { count, max }); } } @@ -110,7 +110,7 @@ module.exports = { const count = functionStack.pop(); if (ignoreTopLevelFunctions && functionStack.length === 0) { - topLevelFunctions.push({ node: node, count: count}); + topLevelFunctions.push({ node, count}); } else { reportIfTooManyStatements(node, count, maxStatements); } @@ -141,7 +141,7 @@ module.exports = { "FunctionExpression:exit": endFunction, "ArrowFunctionExpression:exit": endFunction, - "Program:exit": function() { + "Program:exit"() { if (topLevelFunctions.length === 1) { return; } diff --git a/tools/eslint/lib/rules/multiline-ternary.js b/tools/eslint/lib/rules/multiline-ternary.js index e6f680cf5ceae0..de19bd43fd60ed 100644 --- a/tools/eslint/lib/rules/multiline-ternary.js +++ b/tools/eslint/lib/rules/multiline-ternary.js @@ -18,10 +18,15 @@ module.exports = { category: "Stylistic Issues", recommended: false }, - schema: [] + schema: [ + { + enum: ["always", "never"] + } + ] }, - create: function(context) { + create(context) { + const multiline = context.options[0] !== "never"; //-------------------------------------------------------------------------- // Helpers @@ -31,14 +36,16 @@ module.exports = { * Tests whether node is preceded by supplied tokens * @param {ASTNode} node - node to check * @param {ASTNode} parentNode - parent of node to report + * @param {boolean} expected - whether newline was expected or not * @returns {void} * @private */ - function reportError(node, parentNode) { + function reportError(node, parentNode, expected) { context.report({ - node: node, - message: "Expected newline between {{typeOfError}} of ternary expression.", + node, + message: "{{expected}} newline between {{typeOfError}} of ternary expression.", data: { + expected: expected ? "Expected" : "Unexpected", typeOfError: node === parentNode.test ? "test and consequent" : "consequent and alternate" } }); @@ -49,16 +56,26 @@ module.exports = { //-------------------------------------------------------------------------- return { - ConditionalExpression: function(node) { + ConditionalExpression(node) { const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(node.test, node.consequent); const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(node.consequent, node.alternate); - if (areTestAndConsequentOnSameLine) { - reportError(node.test, node); - } + if (!multiline) { + if (!areTestAndConsequentOnSameLine) { + reportError(node.test, node, false); + } + + if (!areConsequentAndAlternateOnSameLine) { + reportError(node.consequent, node, false); + } + } else { + if (areTestAndConsequentOnSameLine) { + reportError(node.test, node, true); + } - if (areConsequentAndAlternateOnSameLine) { - reportError(node.consequent, node); + if (areConsequentAndAlternateOnSameLine) { + reportError(node.consequent, node, true); + } } } }; diff --git a/tools/eslint/lib/rules/new-cap.js b/tools/eslint/lib/rules/new-cap.js index ab158e9c8bdf6d..e40f98447fabb1 100644 --- a/tools/eslint/lib/rules/new-cap.js +++ b/tools/eslint/lib/rules/new-cap.js @@ -117,7 +117,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0] ? Object.assign({}, context.options[0]) : {}; diff --git a/tools/eslint/lib/rules/new-parens.js b/tools/eslint/lib/rules/new-parens.js index 0509229bbb59de..3fc0f9bd4dd599 100644 --- a/tools/eslint/lib/rules/new-parens.js +++ b/tools/eslint/lib/rules/new-parens.js @@ -20,12 +20,12 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - NewExpression: function(node) { + NewExpression(node) { const tokens = sourceCode.getTokens(node); const prenticesTokens = tokens.filter(function(token) { return token.value === "(" || token.value === ")"; diff --git a/tools/eslint/lib/rules/newline-after-var.js b/tools/eslint/lib/rules/newline-after-var.js index 433fa7ebf8bc08..bf837258d94844 100644 --- a/tools/eslint/lib/rules/newline-after-var.js +++ b/tools/eslint/lib/rules/newline-after-var.js @@ -24,7 +24,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const ALWAYS_MESSAGE = "Expected blank line after variable declarations.", NEVER_MESSAGE = "Unexpected blank line after variable declarations."; diff --git a/tools/eslint/lib/rules/newline-before-return.js b/tools/eslint/lib/rules/newline-before-return.js index 4a30a7d08ac0a6..461d7259035d4d 100644 --- a/tools/eslint/lib/rules/newline-before-return.js +++ b/tools/eslint/lib/rules/newline-before-return.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- @@ -137,10 +137,10 @@ module.exports = { //-------------------------------------------------------------------------- return { - ReturnStatement: function(node) { + ReturnStatement(node) { if (!isFirstNode(node) && !hasNewlineBefore(node)) { context.report({ - node: node, + node, message: "Expected newline before return statement." }); } diff --git a/tools/eslint/lib/rules/newline-per-chained-call.js b/tools/eslint/lib/rules/newline-per-chained-call.js index 8959742d349cc1..5b005f6da2fccb 100644 --- a/tools/eslint/lib/rules/newline-per-chained-call.js +++ b/tools/eslint/lib/rules/newline-per-chained-call.js @@ -31,7 +31,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const options = context.options[0] || {}, ignoreChainWithDepth = options.ignoreChainWithDepth || 2; @@ -54,7 +54,7 @@ module.exports = { } return { - "CallExpression:exit": function(node) { + "CallExpression:exit"(node) { if (!node.callee || node.callee.type !== "MemberExpression") { return; } diff --git a/tools/eslint/lib/rules/no-alert.js b/tools/eslint/lib/rules/no-alert.js index 6be98005a79ac9..96b5d64c6c4e6b 100644 --- a/tools/eslint/lib/rules/no-alert.js +++ b/tools/eslint/lib/rules/no-alert.js @@ -97,16 +97,16 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let globalScope; return { - Program: function() { + Program() { globalScope = context.getScope(); }, - CallExpression: function(node) { + CallExpression(node) { const callee = node.callee, currentScope = context.getScope(); diff --git a/tools/eslint/lib/rules/no-array-constructor.js b/tools/eslint/lib/rules/no-array-constructor.js index 389725c62c7305..2c29217d720fcc 100644 --- a/tools/eslint/lib/rules/no-array-constructor.js +++ b/tools/eslint/lib/rules/no-array-constructor.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Disallow construction of dense arrays using the Array constructor diff --git a/tools/eslint/lib/rules/no-bitwise.js b/tools/eslint/lib/rules/no-bitwise.js index a17a8a9b32bc25..2c6456912f70f8 100644 --- a/tools/eslint/lib/rules/no-bitwise.js +++ b/tools/eslint/lib/rules/no-bitwise.js @@ -46,7 +46,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const allowed = options.allow || []; const int32Hint = options.int32Hint === true; diff --git a/tools/eslint/lib/rules/no-caller.js b/tools/eslint/lib/rules/no-caller.js index ff17262bce967a..16c5fa414b0cb8 100644 --- a/tools/eslint/lib/rules/no-caller.js +++ b/tools/eslint/lib/rules/no-caller.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - MemberExpression: function(node) { + MemberExpression(node) { const objectName = node.object.name, propertyName = node.property.name; diff --git a/tools/eslint/lib/rules/no-case-declarations.js b/tools/eslint/lib/rules/no-case-declarations.js index 6a0db0e8699489..e801c6bb6e0db7 100644 --- a/tools/eslint/lib/rules/no-case-declarations.js +++ b/tools/eslint/lib/rules/no-case-declarations.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Checks whether or not a node is a lexical declaration. @@ -39,13 +39,13 @@ module.exports = { } return { - SwitchCase: function(node) { + SwitchCase(node) { for (let i = 0; i < node.consequent.length; i++) { const statement = node.consequent[i]; if (isLexicalDeclaration(statement)) { context.report({ - node: node, + node, message: "Unexpected lexical declaration in case block." }); } diff --git a/tools/eslint/lib/rules/no-catch-shadow.js b/tools/eslint/lib/rules/no-catch-shadow.js index 7573e3d8a3193c..7f2523333239a7 100644 --- a/tools/eslint/lib/rules/no-catch-shadow.js +++ b/tools/eslint/lib/rules/no-catch-shadow.js @@ -26,7 +26,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -48,7 +48,7 @@ module.exports = { return { - CatchClause: function(node) { + CatchClause(node) { let scope = context.getScope(); // When blockBindings is enabled, CatchClause creates its own scope diff --git a/tools/eslint/lib/rules/no-class-assign.js b/tools/eslint/lib/rules/no-class-assign.js index 059c36e56e509f..cbd4b1da81fe42 100644 --- a/tools/eslint/lib/rules/no-class-assign.js +++ b/tools/eslint/lib/rules/no-class-assign.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Finds and reports references that are non initializer and writable. diff --git a/tools/eslint/lib/rules/no-cond-assign.js b/tools/eslint/lib/rules/no-cond-assign.js index 908dc457704c8e..2d66f55a5ba77b 100644 --- a/tools/eslint/lib/rules/no-cond-assign.js +++ b/tools/eslint/lib/rules/no-cond-assign.js @@ -4,6 +4,8 @@ */ "use strict"; +const astUtils = require("../ast-utils"); + const NODE_DESCRIPTIONS = { DoWhileStatement: "a 'do...while' statement", ForStatement: "a 'for' statement", @@ -30,7 +32,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const prohibitAssign = (context.options[0] || "except-parens"); @@ -59,7 +61,7 @@ module.exports = { if (isConditionalTestExpression(currentAncestor)) { return currentAncestor.parent; } - } while ((currentAncestor = currentAncestor.parent)); + } while ((currentAncestor = currentAncestor.parent) && !astUtils.isFunction(currentAncestor)); return null; } @@ -107,7 +109,7 @@ module.exports = { // must match JSHint's error message context.report({ - node: node, + node, loc: node.test.loc.start, message: "Expected a conditional expression and instead saw an assignment." }); diff --git a/tools/eslint/lib/rules/no-confusing-arrow.js b/tools/eslint/lib/rules/no-confusing-arrow.js index c4bd347046148c..5e1b051423d674 100644 --- a/tools/eslint/lib/rules/no-confusing-arrow.js +++ b/tools/eslint/lib/rules/no-confusing-arrow.js @@ -42,7 +42,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const config = context.options[0] || {}; const sourceCode = context.getSourceCode(); diff --git a/tools/eslint/lib/rules/no-console.js b/tools/eslint/lib/rules/no-console.js index 0daff2bb075297..2fe0056637e504 100644 --- a/tools/eslint/lib/rules/no-console.js +++ b/tools/eslint/lib/rules/no-console.js @@ -35,11 +35,11 @@ module.exports = { ] }, - create: function(context) { + create(context) { return { - MemberExpression: function(node) { + MemberExpression(node) { if (node.object.name === "console") { let blockConsole = true; diff --git a/tools/eslint/lib/rules/no-const-assign.js b/tools/eslint/lib/rules/no-const-assign.js index a34d4c1f4b7004..232e9446fd7955 100644 --- a/tools/eslint/lib/rules/no-const-assign.js +++ b/tools/eslint/lib/rules/no-const-assign.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Finds and reports references that are non initializer and writable. @@ -39,7 +39,7 @@ module.exports = { } return { - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (node.kind === "const") { context.getDeclaredVariables(node).forEach(checkVariable); } diff --git a/tools/eslint/lib/rules/no-constant-condition.js b/tools/eslint/lib/rules/no-constant-condition.js index c4bd50785f970d..f78ddbc2e972b0 100644 --- a/tools/eslint/lib/rules/no-constant-condition.js +++ b/tools/eslint/lib/rules/no-constant-condition.js @@ -31,7 +31,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}, checkLoops = options.checkLoops !== false; diff --git a/tools/eslint/lib/rules/no-continue.js b/tools/eslint/lib/rules/no-continue.js index 5e8c059b0efd02..b8956da4b75025 100644 --- a/tools/eslint/lib/rules/no-continue.js +++ b/tools/eslint/lib/rules/no-continue.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ContinueStatement: function(node) { + ContinueStatement(node) { context.report(node, "Unexpected use of continue statement."); } }; diff --git a/tools/eslint/lib/rules/no-control-regex.js b/tools/eslint/lib/rules/no-control-regex.js index 40fa013b4ae1b1..f30cccb2d639d8 100644 --- a/tools/eslint/lib/rules/no-control-regex.js +++ b/tools/eslint/lib/rules/no-control-regex.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Get the regex expression @@ -99,7 +99,7 @@ module.exports = { } return { - Literal: function(node) { + Literal(node) { const regex = getRegExp(node); if (regex) { diff --git a/tools/eslint/lib/rules/no-debugger.js b/tools/eslint/lib/rules/no-debugger.js index 552294bd674224..6356d5269b61f1 100644 --- a/tools/eslint/lib/rules/no-debugger.js +++ b/tools/eslint/lib/rules/no-debugger.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - DebuggerStatement: function(node) { + DebuggerStatement(node) { context.report(node, "Unexpected 'debugger' statement."); } }; diff --git a/tools/eslint/lib/rules/no-delete-var.js b/tools/eslint/lib/rules/no-delete-var.js index c1d717a15ba573..dce202dc834c7e 100644 --- a/tools/eslint/lib/rules/no-delete-var.js +++ b/tools/eslint/lib/rules/no-delete-var.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - UnaryExpression: function(node) { + UnaryExpression(node) { if (node.operator === "delete" && node.argument.type === "Identifier") { context.report(node, "Variables should not be deleted."); } diff --git a/tools/eslint/lib/rules/no-div-regex.js b/tools/eslint/lib/rules/no-div-regex.js index 908b200310500c..c5ffa7ce7e2e7a 100644 --- a/tools/eslint/lib/rules/no-div-regex.js +++ b/tools/eslint/lib/rules/no-div-regex.js @@ -20,12 +20,12 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - Literal: function(node) { + Literal(node) { const token = sourceCode.getFirstToken(node); if (token.type === "RegularExpression" && token.value[1] === "=") { diff --git a/tools/eslint/lib/rules/no-dupe-args.js b/tools/eslint/lib/rules/no-dupe-args.js index 7e13f997a35aae..0d420eb92aaaf9 100644 --- a/tools/eslint/lib/rules/no-dupe-args.js +++ b/tools/eslint/lib/rules/no-dupe-args.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -52,7 +52,7 @@ module.exports = { if (defs.length >= 2) { context.report({ - node: node, + node, message: "Duplicate param '{{name}}'.", data: {name: variable.name} }); diff --git a/tools/eslint/lib/rules/no-dupe-class-members.js b/tools/eslint/lib/rules/no-dupe-class-members.js index f4385c56cbf3f8..d6e240ccbb49c7 100644 --- a/tools/eslint/lib/rules/no-dupe-class-members.js +++ b/tools/eslint/lib/rules/no-dupe-class-members.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let stack = []; /** @@ -65,22 +65,22 @@ module.exports = { return { // Initializes the stack of state of member declarations. - Program: function() { + Program() { stack = []; }, // Initializes state of member declarations for the class. - ClassBody: function() { + ClassBody() { stack.push(Object.create(null)); }, // Disposes the state for the class. - "ClassBody:exit": function() { + "ClassBody:exit"() { stack.pop(); }, // Reports the node if its name has been declared already. - MethodDefinition: function(node) { + MethodDefinition(node) { if (node.computed) { return; } @@ -101,7 +101,7 @@ module.exports = { } if (isDuplicate) { - context.report(node, "Duplicate name '{{name}}'.", {name: name}); + context.report(node, "Duplicate name '{{name}}'.", {name}); } } }; diff --git a/tools/eslint/lib/rules/no-duplicate-case.js b/tools/eslint/lib/rules/no-duplicate-case.js index 66afb731a556f4..5b20fc3d582980 100644 --- a/tools/eslint/lib/rules/no-duplicate-case.js +++ b/tools/eslint/lib/rules/no-duplicate-case.js @@ -21,11 +21,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - SwitchStatement: function(node) { + SwitchStatement(node) { const mapping = {}; node.cases.forEach(function(switchCase) { diff --git a/tools/eslint/lib/rules/no-duplicate-imports.js b/tools/eslint/lib/rules/no-duplicate-imports.js index 204bfeedc0c392..05ca4196d7fe4e 100644 --- a/tools/eslint/lib/rules/no-duplicate-imports.js +++ b/tools/eslint/lib/rules/no-duplicate-imports.js @@ -36,7 +36,7 @@ function getValue(node) { function checkAndReport(context, node, value, array, message) { if (array.indexOf(value) !== -1) { context.report({ - node: node, + node, message: "'{{module}}' " + message, data: {module: value} }); @@ -115,7 +115,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const includeExports = (context.options[0] || {}).includeExports, importsInFile = [], exportsInFile = []; diff --git a/tools/eslint/lib/rules/no-else-return.js b/tools/eslint/lib/rules/no-else-return.js index 6b8b096d022f87..07b596238caf2b 100644 --- a/tools/eslint/lib/rules/no-else-return.js +++ b/tools/eslint/lib/rules/no-else-return.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -127,7 +127,7 @@ module.exports = { return { - IfStatement: function(node) { + IfStatement(node) { const parent = context.getAncestors().pop(); let consequents, alternate; diff --git a/tools/eslint/lib/rules/no-empty-character-class.js b/tools/eslint/lib/rules/no-empty-character-class.js index 47e48a420e0039..723cebc9450f00 100644 --- a/tools/eslint/lib/rules/no-empty-character-class.js +++ b/tools/eslint/lib/rules/no-empty-character-class.js @@ -38,12 +38,12 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - Literal: function(node) { + Literal(node) { const token = sourceCode.getFirstToken(node); if (token.type === "RegularExpression" && !regex.test(token.value)) { diff --git a/tools/eslint/lib/rules/no-empty-function.js b/tools/eslint/lib/rules/no-empty-function.js index 1f02d230cff445..f7cb58c12effc0 100644 --- a/tools/eslint/lib/rules/no-empty-function.js +++ b/tools/eslint/lib/rules/no-empty-function.js @@ -117,7 +117,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const allowed = options.allow || []; @@ -144,7 +144,7 @@ module.exports = { sourceCode.getComments(node.body).trailing.length === 0 ) { context.report({ - node: node, + node, loc: node.body.loc.start, message: "Unexpected empty " + SHOW_KIND[kind] + "." }); diff --git a/tools/eslint/lib/rules/no-empty-pattern.js b/tools/eslint/lib/rules/no-empty-pattern.js index afd8b1e393e36b..77302fc8d73f9d 100644 --- a/tools/eslint/lib/rules/no-empty-pattern.js +++ b/tools/eslint/lib/rules/no-empty-pattern.js @@ -19,14 +19,14 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ObjectPattern: function(node) { + ObjectPattern(node) { if (node.properties.length === 0) { context.report(node, "Unexpected empty object pattern."); } }, - ArrayPattern: function(node) { + ArrayPattern(node) { if (node.elements.length === 0) { context.report(node, "Unexpected empty array pattern."); } diff --git a/tools/eslint/lib/rules/no-empty.js b/tools/eslint/lib/rules/no-empty.js index b3056033a32c78..8514b9cf89d0c8 100644 --- a/tools/eslint/lib/rules/no-empty.js +++ b/tools/eslint/lib/rules/no-empty.js @@ -35,14 +35,14 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}, allowEmptyCatch = options.allowEmptyCatch || false; const sourceCode = context.getSourceCode(); return { - BlockStatement: function(node) { + BlockStatement(node) { // if the body is not empty, we can just return immediately if (node.body.length !== 0) { @@ -66,7 +66,7 @@ module.exports = { context.report(node, "Empty block statement."); }, - SwitchStatement: function(node) { + SwitchStatement(node) { if (typeof node.cases === "undefined" || node.cases.length === 0) { context.report(node, "Empty switch statement."); diff --git a/tools/eslint/lib/rules/no-eq-null.js b/tools/eslint/lib/rules/no-eq-null.js index 57e4a3f4e4dc6a..62215d05f1b0eb 100644 --- a/tools/eslint/lib/rules/no-eq-null.js +++ b/tools/eslint/lib/rules/no-eq-null.js @@ -21,11 +21,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - BinaryExpression: function(node) { + BinaryExpression(node) { const badOperator = node.operator === "==" || node.operator === "!="; if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || diff --git a/tools/eslint/lib/rules/no-eval.js b/tools/eslint/lib/rules/no-eval.js index b3ef724eedd6ca..af87e4289fcc31 100644 --- a/tools/eslint/lib/rules/no-eval.js +++ b/tools/eslint/lib/rules/no-eval.js @@ -93,7 +93,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const allowIndirect = Boolean( context.options[0] && context.options[0].allowIndirect @@ -116,8 +116,8 @@ module.exports = { funcInfo = { upper: funcInfo, - node: node, - strict: strict, + node, + strict, defaultThis: false, initialized: strict }; @@ -157,7 +157,7 @@ module.exports = { } context.report({ - node: node, + node, loc: locationNode.loc.start, message: "eval can be harmful." }); @@ -228,7 +228,7 @@ module.exports = { // Checks only direct calls to eval. It's simple! return { - "CallExpression:exit": function(node) { + "CallExpression:exit"(node) { const callee = node.callee; if (isIdentifier(callee, "eval")) { @@ -239,7 +239,7 @@ module.exports = { } return { - "CallExpression:exit": function(node) { + "CallExpression:exit"(node) { const callee = node.callee; if (isIdentifier(callee, "eval")) { @@ -247,7 +247,7 @@ module.exports = { } }, - Program: function(node) { + Program(node) { const scope = context.getScope(), features = context.parserOptions.ecmaFeatures || {}, strict = @@ -257,14 +257,14 @@ module.exports = { funcInfo = { upper: null, - node: node, - strict: strict, + node, + strict, defaultThis: true, initialized: true }; }, - "Program:exit": function() { + "Program:exit"() { const globalScope = context.getScope(); exitVarScope(); @@ -279,7 +279,7 @@ module.exports = { ArrowFunctionExpression: enterVarScope, "ArrowFunctionExpression:exit": exitVarScope, - ThisExpression: function(node) { + ThisExpression(node) { if (!isMember(node.parent, "eval")) { return; } diff --git a/tools/eslint/lib/rules/no-ex-assign.js b/tools/eslint/lib/rules/no-ex-assign.js index db1c61aa21b9ee..6ffa8408677292 100644 --- a/tools/eslint/lib/rules/no-ex-assign.js +++ b/tools/eslint/lib/rules/no-ex-assign.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Finds and reports references that are non initializer and writable. @@ -38,7 +38,7 @@ module.exports = { } return { - CatchClause: function(node) { + CatchClause(node) { context.getDeclaredVariables(node).forEach(checkVariable); } }; diff --git a/tools/eslint/lib/rules/no-extend-native.js b/tools/eslint/lib/rules/no-extend-native.js index daf4dd7a480b24..fb64d9a15b4e50 100644 --- a/tools/eslint/lib/rules/no-extend-native.js +++ b/tools/eslint/lib/rules/no-extend-native.js @@ -40,7 +40,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0] || {}; const exceptions = config.exceptions || []; @@ -57,7 +57,7 @@ module.exports = { return { // handle the Array.prototype.extra style case - AssignmentExpression: function(node) { + AssignmentExpression(node) { const lhs = node.left; if (lhs.type !== "MemberExpression" || lhs.object.type !== "MemberExpression") { @@ -80,7 +80,7 @@ module.exports = { }, // handle the Object.definePropert[y|ies](Array.prototype) case - CallExpression: function(node) { + CallExpression(node) { const callee = node.callee; diff --git a/tools/eslint/lib/rules/no-extra-bind.js b/tools/eslint/lib/rules/no-extra-bind.js index 8d433b0358aed0..544a12b9f09468 100644 --- a/tools/eslint/lib/rules/no-extra-bind.js +++ b/tools/eslint/lib/rules/no-extra-bind.js @@ -25,7 +25,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let scopeInfo = null; /** diff --git a/tools/eslint/lib/rules/no-extra-boolean-cast.js b/tools/eslint/lib/rules/no-extra-boolean-cast.js index 7f2949390935fe..89a193b2d12435 100644 --- a/tools/eslint/lib/rules/no-extra-boolean-cast.js +++ b/tools/eslint/lib/rules/no-extra-boolean-cast.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { // Node types which have a test which will coerce values to booleans. const BOOLEAN_NODE_TYPES = [ @@ -51,7 +51,7 @@ module.exports = { return { - UnaryExpression: function(node) { + UnaryExpression(node) { const 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(node) { const parent = node.parent; if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") { diff --git a/tools/eslint/lib/rules/no-extra-label.js b/tools/eslint/lib/rules/no-extra-label.js index 12be549403b209..b34e075163472d 100644 --- a/tools/eslint/lib/rules/no-extra-label.js +++ b/tools/eslint/lib/rules/no-extra-label.js @@ -26,7 +26,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let scopeInfo = null; /** diff --git a/tools/eslint/lib/rules/no-extra-parens.js b/tools/eslint/lib/rules/no-extra-parens.js index 060f84ff793206..1d355cf0a313f4 100644 --- a/tools/eslint/lib/rules/no-extra-parens.js +++ b/tools/eslint/lib/rules/no-extra-parens.js @@ -9,6 +9,7 @@ //------------------------------------------------------------------------------ const astUtils = require("../ast-utils.js"); +const esUtils = require("esutils"); module.exports = { meta: { @@ -18,6 +19,8 @@ module.exports = { recommended: false }, + fixable: "code", + schema: { anyOf: [ { @@ -53,7 +56,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const isParenthesised = astUtils.isParenthesised.bind(astUtils, sourceCode); @@ -256,6 +259,41 @@ module.exports = { throw new Error("unreachable"); } + /** + * Determines whether a node should be preceded by an additional space when removing parens + * @param {ASTNode} node node to evaluate; must be surrounded by parentheses + * @returns {boolean} `true` if a space should be inserted before the node + * @private + */ + function requiresLeadingSpace(node) { + const leftParenToken = sourceCode.getTokenBefore(node); + const tokenBeforeLeftParen = sourceCode.getTokenBefore(node, 1); + const firstToken = sourceCode.getFirstToken(node); + + // If there is already whitespace before the previous token, don't add more. + if (!tokenBeforeLeftParen || tokenBeforeLeftParen.end !== leftParenToken.start) { + return false; + } + + // If the parens are preceded by a keyword (e.g. `typeof(0)`), a space should be inserted (`typeof 0`) + const precededByKeyword = tokenBeforeLeftParen.type === "Keyword"; + + // However, a space should not be inserted unless the first character of the token is an identifier part + // e.g. `typeof([])` should be fixed to `typeof[]` + const startsWithIdentifierPart = esUtils.code.isIdentifierPartES6(firstToken.value.charCodeAt(0)); + + // If the parens are preceded by and start with a unary plus/minus (e.g. `+(+foo)`), a space should be inserted (`+ +foo`) + const precededByUnaryPlus = tokenBeforeLeftParen.type === "Punctuator" && tokenBeforeLeftParen.value === "+"; + const precededByUnaryMinus = tokenBeforeLeftParen.type === "Punctuator" && tokenBeforeLeftParen.value === "-"; + + const startsWithUnaryPlus = firstToken.type === "Punctuator" && firstToken.value === "+"; + const startsWithUnaryMinus = firstToken.type === "Punctuator" && firstToken.value === "-"; + + return (precededByKeyword && startsWithIdentifierPart) || + (precededByUnaryPlus && startsWithUnaryPlus) || + (precededByUnaryMinus && startsWithUnaryMinus); + } + /** * Report the node * @param {ASTNode} node node to evaluate @@ -263,9 +301,22 @@ module.exports = { * @private */ function report(node) { - const previousToken = sourceCode.getTokenBefore(node); - - context.report(node, previousToken.loc.start, "Gratuitous parentheses around expression."); + const leftParenToken = sourceCode.getTokenBefore(node); + const rightParenToken = sourceCode.getTokenAfter(node); + + context.report({ + node, + loc: leftParenToken.loc.start, + message: "Gratuitous parentheses around expression.", + fix(fixer) { + const parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]); + + return fixer.replaceTextRange([ + leftParenToken.range[0], + rightParenToken.range[1] + ], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource); + } + }); } /** @@ -329,7 +380,7 @@ module.exports = { } return { - ArrayExpression: function(node) { + ArrayExpression(node) { [].forEach.call(node.elements, function(e) { if (e && hasExcessParens(e) && precedence(e) >= precedence({type: "AssignmentExpression"})) { report(e); @@ -337,7 +388,7 @@ module.exports = { }); }, - ArrowFunctionExpression: function(node) { + ArrowFunctionExpression(node) { if (isReturnAssignException(node)) { return; } @@ -356,7 +407,7 @@ module.exports = { } }, - AssignmentExpression: function(node) { + AssignmentExpression(node) { if (isReturnAssignException(node)) { return; } @@ -369,7 +420,7 @@ module.exports = { BinaryExpression: dryBinaryLogical, CallExpression: dryCallNew, - ConditionalExpression: function(node) { + ConditionalExpression(node) { if (isReturnAssignException(node)) { return; } @@ -387,13 +438,13 @@ module.exports = { } }, - DoWhileStatement: function(node) { + DoWhileStatement(node) { if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) { report(node.test); } }, - ExpressionStatement: function(node) { + ExpressionStatement(node) { if (hasExcessParens(node.expression)) { const firstTokens = sourceCode.getFirstTokens(node.expression, 2); const firstToken = firstTokens[0]; @@ -415,19 +466,19 @@ module.exports = { } }, - ForInStatement: function(node) { + ForInStatement(node) { if (hasExcessParens(node.right)) { report(node.right); } }, - ForOfStatement: function(node) { + ForOfStatement(node) { if (hasExcessParens(node.right)) { report(node.right); } }, - ForStatement: function(node) { + ForStatement(node) { if (node.init && hasExcessParens(node.init)) { report(node.init); } @@ -441,7 +492,7 @@ module.exports = { } }, - IfStatement: function(node) { + IfStatement(node) { if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) { report(node.test); } @@ -449,7 +500,7 @@ module.exports = { LogicalExpression: dryBinaryLogical, - MemberExpression: function(node) { + MemberExpression(node) { if ( hasExcessParens(node.object) && precedence(node.object) >= precedence(node) && @@ -480,7 +531,7 @@ module.exports = { NewExpression: dryCallNew, - ObjectExpression: function(node) { + ObjectExpression(node) { [].forEach.call(node.properties, function(e) { const v = e.value; @@ -490,7 +541,7 @@ module.exports = { }); }, - ReturnStatement: function(node) { + ReturnStatement(node) { const returnToken = sourceCode.getFirstToken(node); if (isReturnAssignException(node)) { @@ -506,7 +557,7 @@ module.exports = { } }, - SequenceExpression: function(node) { + SequenceExpression(node) { [].forEach.call(node.expressions, function(e) { if (hasExcessParens(e) && precedence(e) >= precedence(node)) { report(e); @@ -514,19 +565,19 @@ module.exports = { }); }, - SwitchCase: function(node) { + SwitchCase(node) { if (node.test && hasExcessParens(node.test)) { report(node.test); } }, - SwitchStatement: function(node) { + SwitchStatement(node) { if (hasDoubleExcessParens(node.discriminant)) { report(node.discriminant); } }, - ThrowStatement: function(node) { + ThrowStatement(node) { const throwToken = sourceCode.getFirstToken(node); if (hasExcessParensNoLineTerminator(throwToken, node.argument)) { @@ -537,7 +588,7 @@ module.exports = { UnaryExpression: dryUnaryUpdate, UpdateExpression: dryUnaryUpdate, - VariableDeclarator: function(node) { + VariableDeclarator(node) { if (node.init && hasExcessParens(node.init) && precedence(node.init) >= precedence({type: "AssignmentExpression"}) && @@ -547,19 +598,19 @@ module.exports = { } }, - WhileStatement: function(node) { + WhileStatement(node) { if (hasDoubleExcessParens(node.test) && !isCondAssignException(node)) { report(node.test); } }, - WithStatement: function(node) { + WithStatement(node) { if (hasDoubleExcessParens(node.object)) { report(node.object); } }, - YieldExpression: function(node) { + YieldExpression(node) { if (node.argument) { const yieldToken = sourceCode.getFirstToken(node); diff --git a/tools/eslint/lib/rules/no-extra-semi.js b/tools/eslint/lib/rules/no-extra-semi.js index 485c0d02f7cbc0..f51f16ee6af3f1 100644 --- a/tools/eslint/lib/rules/no-extra-semi.js +++ b/tools/eslint/lib/rules/no-extra-semi.js @@ -21,7 +21,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); /** @@ -33,7 +33,7 @@ module.exports = { context.report({ node: nodeOrToken, message: "Unnecessary semicolon.", - fix: function(fixer) { + fix(fixer) { return fixer.remove(nodeOrToken); } }); @@ -64,7 +64,7 @@ module.exports = { * @param {Node} node - A EmptyStatement node to be reported. * @returns {void} */ - EmptyStatement: function(node) { + EmptyStatement(node) { const parent = node.parent, allowedParentTypes = [ "ForStatement", @@ -87,7 +87,7 @@ module.exports = { * @param {Node} node - A ClassBody node to check. * @returns {void} */ - ClassBody: function(node) { + ClassBody(node) { checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); // 0 is `{`. }, @@ -96,7 +96,7 @@ module.exports = { * @param {Node} node - A MethodDefinition node of the start point. * @returns {void} */ - MethodDefinition: function(node) { + MethodDefinition(node) { checkForPartOfClassBody(sourceCode.getTokenAfter(node)); } }; diff --git a/tools/eslint/lib/rules/no-fallthrough.js b/tools/eslint/lib/rules/no-fallthrough.js index a1194385967689..380a53634be1cb 100644 --- a/tools/eslint/lib/rules/no-fallthrough.js +++ b/tools/eslint/lib/rules/no-fallthrough.js @@ -74,7 +74,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; let currentCodePath = null; const sourceCode = context.getSourceCode(); @@ -93,14 +93,14 @@ module.exports = { } return { - onCodePathStart: function(codePath) { + onCodePathStart(codePath) { currentCodePath = codePath; }, - onCodePathEnd: function() { + onCodePathEnd() { currentCodePath = currentCodePath.upper; }, - SwitchCase: function(node) { + SwitchCase(node) { /* * Checks whether or not there is a fallthrough comment. @@ -110,13 +110,13 @@ module.exports = { context.report({ message: "Expected a 'break' statement before '{{type}}'.", data: {type: node.test ? "case" : "default"}, - node: node + node }); } fallthroughCase = null; }, - "SwitchCase:exit": function(node) { + "SwitchCase:exit"(node) { const nextToken = sourceCode.getTokenAfter(node); /* diff --git a/tools/eslint/lib/rules/no-floating-decimal.js b/tools/eslint/lib/rules/no-floating-decimal.js index 56ebd3989a4eb8..32767fb5131faf 100644 --- a/tools/eslint/lib/rules/no-floating-decimal.js +++ b/tools/eslint/lib/rules/no-floating-decimal.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - Literal: function(node) { + Literal(node) { if (typeof node.value === "number") { if (node.raw.indexOf(".") === 0) { diff --git a/tools/eslint/lib/rules/no-func-assign.js b/tools/eslint/lib/rules/no-func-assign.js index d57062dfc21661..daa6fa52ba7301 100644 --- a/tools/eslint/lib/rules/no-func-assign.js +++ b/tools/eslint/lib/rules/no-func-assign.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Reports a reference if is non initializer and writable. diff --git a/tools/eslint/lib/rules/no-global-assign.js b/tools/eslint/lib/rules/no-global-assign.js index a5d389e7b0fc96..2bc38cb5d70bb6 100644 --- a/tools/eslint/lib/rules/no-global-assign.js +++ b/tools/eslint/lib/rules/no-global-assign.js @@ -32,7 +32,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0]; const exceptions = (config && config.exceptions) || []; @@ -73,7 +73,7 @@ module.exports = { } return { - Program: function() { + Program() { const globalScope = context.getScope(); globalScope.variables.forEach(checkVariable); diff --git a/tools/eslint/lib/rules/no-implicit-coercion.js b/tools/eslint/lib/rules/no-implicit-coercion.js index a27af2b152ad6b..0810781cf58318 100644 --- a/tools/eslint/lib/rules/no-implicit-coercion.js +++ b/tools/eslint/lib/rules/no-implicit-coercion.js @@ -175,12 +175,12 @@ module.exports = { }] }, - create: function(context) { + create(context) { const options = parseOptions(context.options[0]); const sourceCode = context.getSourceCode(); return { - UnaryExpression: function(node) { + UnaryExpression(node) { let operatorAllowed; // !!foo @@ -215,7 +215,7 @@ module.exports = { }, // Use `:exit` to prevent double reporting - "BinaryExpression:exit": function(node) { + "BinaryExpression:exit"(node) { let operatorAllowed; // 1 * foo @@ -241,7 +241,7 @@ module.exports = { } }, - AssignmentExpression: function(node) { + AssignmentExpression(node) { // foo += "" const operatorAllowed = options.allow.indexOf("+") >= 0; diff --git a/tools/eslint/lib/rules/no-implicit-globals.js b/tools/eslint/lib/rules/no-implicit-globals.js index 84968cb071f6a6..ba01bd12c3836b 100644 --- a/tools/eslint/lib/rules/no-implicit-globals.js +++ b/tools/eslint/lib/rules/no-implicit-globals.js @@ -20,9 +20,9 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - Program: function() { + Program() { const scope = context.getScope(); scope.variables.forEach(function(variable) { diff --git a/tools/eslint/lib/rules/no-implied-eval.js b/tools/eslint/lib/rules/no-implied-eval.js index c074098ba9cefd..9b48e896821363 100644 --- a/tools/eslint/lib/rules/no-implied-eval.js +++ b/tools/eslint/lib/rules/no-implied-eval.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const CALLEE_RE = /set(?:Timeout|Interval)|execScript/; /* @@ -114,7 +114,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - CallExpression: function(node) { + CallExpression(node) { if (isImpliedEvalCallExpression(node)) { // call expressions create a new substack @@ -122,7 +122,7 @@ module.exports = { } }, - "CallExpression:exit": function(node) { + "CallExpression:exit"(node) { if (node === last(last(impliedEvalAncestorsStack))) { /* Destroys the entire sub-stack, rather than just using @@ -133,25 +133,25 @@ module.exports = { } }, - BinaryExpression: function(node) { + BinaryExpression(node) { if (node.operator === "+" && hasImpliedEvalParent(node)) { last(impliedEvalAncestorsStack).push(node); } }, - "BinaryExpression:exit": function(node) { + "BinaryExpression:exit"(node) { if (node === last(last(impliedEvalAncestorsStack))) { last(impliedEvalAncestorsStack).pop(); } }, - Literal: function(node) { + Literal(node) { if (typeof node.value === "string") { checkString(node); } }, - TemplateLiteral: function(node) { + TemplateLiteral(node) { checkString(node); } }; diff --git a/tools/eslint/lib/rules/no-inline-comments.js b/tools/eslint/lib/rules/no-inline-comments.js index 8ca0c573c5bec1..d51a59a183c199 100644 --- a/tools/eslint/lib/rules/no-inline-comments.js +++ b/tools/eslint/lib/rules/no-inline-comments.js @@ -21,7 +21,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); /** diff --git a/tools/eslint/lib/rules/no-inner-declarations.js b/tools/eslint/lib/rules/no-inner-declarations.js index 22ef55b21e8fa0..b50ad53410258a 100644 --- a/tools/eslint/lib/rules/no-inner-declarations.js +++ b/tools/eslint/lib/rules/no-inner-declarations.js @@ -24,7 +24,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { /** * Find the nearest Program or Function ancestor node. @@ -77,7 +77,7 @@ module.exports = { return { FunctionDeclaration: check, - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (context.options[0] === "both" && node.kind === "var") { check(node); } diff --git a/tools/eslint/lib/rules/no-invalid-regexp.js b/tools/eslint/lib/rules/no-invalid-regexp.js index 123b80c39b742e..30627abfa735b4 100644 --- a/tools/eslint/lib/rules/no-invalid-regexp.js +++ b/tools/eslint/lib/rules/no-invalid-regexp.js @@ -36,7 +36,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const options = context.options[0]; let allowedFlags = ""; diff --git a/tools/eslint/lib/rules/no-invalid-this.js b/tools/eslint/lib/rules/no-invalid-this.js index 9672c284678ab9..fe2bc3a1baa647 100644 --- a/tools/eslint/lib/rules/no-invalid-this.js +++ b/tools/eslint/lib/rules/no-invalid-this.js @@ -26,7 +26,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const stack = [], sourceCode = context.getSourceCode(); @@ -66,7 +66,7 @@ module.exports = { // `this` can be invalid only under strict mode. stack.push({ init: !context.getScope().isStrict, - node: node, + node, valid: true }); } @@ -85,13 +85,13 @@ module.exports = { * `this` is invalid only under strict mode. * Modules is always strict mode. */ - Program: function(node) { + Program(node) { const scope = context.getScope(), features = context.parserOptions.ecmaFeatures || {}; stack.push({ init: true, - node: node, + node, valid: !( scope.isStrict || node.sourceType === "module" || @@ -100,7 +100,7 @@ module.exports = { }); }, - "Program:exit": function() { + "Program:exit"() { stack.pop(); }, @@ -110,7 +110,7 @@ module.exports = { "FunctionExpression:exit": exitFunction, // Reports if `this` of the current context is invalid. - ThisExpression: function(node) { + ThisExpression(node) { const current = stack.getCurrent(); if (current && !current.valid) { diff --git a/tools/eslint/lib/rules/no-irregular-whitespace.js b/tools/eslint/lib/rules/no-irregular-whitespace.js index a34de284e01843..74a3c10fed1c9d 100644 --- a/tools/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/eslint/lib/rules/no-irregular-whitespace.js @@ -49,7 +49,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // Module store of errors that we have found let errors = []; diff --git a/tools/eslint/lib/rules/no-iterator.js b/tools/eslint/lib/rules/no-iterator.js index 67c1c1bb2a22fc..faa5153335bd76 100644 --- a/tools/eslint/lib/rules/no-iterator.js +++ b/tools/eslint/lib/rules/no-iterator.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - MemberExpression: function(node) { + MemberExpression(node) { if (node.property && (node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed) || diff --git a/tools/eslint/lib/rules/no-label-var.js b/tools/eslint/lib/rules/no-label-var.js index e050f011392f66..450c9a91fca893 100644 --- a/tools/eslint/lib/rules/no-label-var.js +++ b/tools/eslint/lib/rules/no-label-var.js @@ -26,7 +26,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers @@ -49,7 +49,7 @@ module.exports = { return { - LabeledStatement: function(node) { + LabeledStatement(node) { // Fetch the innermost scope. const scope = context.getScope(); diff --git a/tools/eslint/lib/rules/no-labels.js b/tools/eslint/lib/rules/no-labels.js index 90b696829b4ac2..101092a667622b 100644 --- a/tools/eslint/lib/rules/no-labels.js +++ b/tools/eslint/lib/rules/no-labels.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0]; const allowLoop = Boolean(options && options.allowLoop); const allowSwitch = Boolean(options && options.allowSwitch); @@ -99,7 +99,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - LabeledStatement: function(node) { + LabeledStatement(node) { scopeInfo = { label: node.label.name, kind: getBodyKind(node.body), @@ -107,10 +107,10 @@ module.exports = { }; }, - "LabeledStatement:exit": function(node) { + "LabeledStatement:exit"(node) { if (!isAllowed(scopeInfo.kind)) { context.report({ - node: node, + node, message: "Unexpected labeled statement." }); } @@ -118,19 +118,19 @@ module.exports = { scopeInfo = scopeInfo.upper; }, - BreakStatement: function(node) { + BreakStatement(node) { if (node.label && !isAllowed(getKind(node.label.name))) { context.report({ - node: node, + node, message: "Unexpected label in break statement." }); } }, - ContinueStatement: function(node) { + ContinueStatement(node) { if (node.label && !isAllowed(getKind(node.label.name))) { context.report({ - node: node, + node, message: "Unexpected label in continue statement." }); } diff --git a/tools/eslint/lib/rules/no-lone-blocks.js b/tools/eslint/lib/rules/no-lone-blocks.js index ae59e99fae9049..9945147129cd81 100644 --- a/tools/eslint/lib/rules/no-lone-blocks.js +++ b/tools/eslint/lib/rules/no-lone-blocks.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { // A stack of lone blocks to be checked for block-level bindings const loneBlocks = []; @@ -69,7 +69,7 @@ module.exports = { // Default rule definition: report all lone blocks ruleDef = { - BlockStatement: function(node) { + BlockStatement(node) { if (isLoneBlock(node)) { report(node); } @@ -79,12 +79,12 @@ module.exports = { // ES6: report blocks without block-level bindings if (context.parserOptions.ecmaVersion >= 6) { ruleDef = { - BlockStatement: function(node) { + BlockStatement(node) { if (isLoneBlock(node)) { loneBlocks.push(node); } }, - "BlockStatement:exit": function(node) { + "BlockStatement:exit"(node) { if (loneBlocks.length > 0 && loneBlocks[loneBlocks.length - 1] === node) { loneBlocks.pop(); report(node); diff --git a/tools/eslint/lib/rules/no-lonely-if.js b/tools/eslint/lib/rules/no-lonely-if.js index 4764908dfa8e23..3a1f0b9daac047 100644 --- a/tools/eslint/lib/rules/no-lonely-if.js +++ b/tools/eslint/lib/rules/no-lonely-if.js @@ -19,10 +19,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - IfStatement: function(node) { + IfStatement(node) { const ancestors = context.getAncestors(), parent = ancestors.pop(), grandparent = ancestors.pop(); diff --git a/tools/eslint/lib/rules/no-loop-func.js b/tools/eslint/lib/rules/no-loop-func.js index f51a8327c2db36..6db7a95f7c7254 100644 --- a/tools/eslint/lib/rules/no-loop-func.js +++ b/tools/eslint/lib/rules/no-loop-func.js @@ -162,7 +162,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Reports functions which match the following condition: diff --git a/tools/eslint/lib/rules/no-magic-numbers.js b/tools/eslint/lib/rules/no-magic-numbers.js index 92853c1c06b809..548637ea4eca71 100644 --- a/tools/eslint/lib/rules/no-magic-numbers.js +++ b/tools/eslint/lib/rules/no-magic-numbers.js @@ -41,7 +41,7 @@ module.exports = { }] }, - create: function(context) { + create(context) { const config = context.options[0] || {}, detectObjects = !!config.detectObjects, enforceConst = !!config.enforceConst, @@ -99,7 +99,7 @@ module.exports = { } return { - Literal: function(node) { + Literal(node) { let parent = node.parent, value = node.value, raw = node.raw; @@ -127,14 +127,14 @@ module.exports = { if (parent.type === "VariableDeclarator") { if (enforceConst && parent.parent.kind !== "const") { context.report({ - node: node, + node, message: "Number constants declarations must use 'const'." }); } } else if (okTypes.indexOf(parent.type) === -1 || (parent.type === "AssignmentExpression" && parent.operator !== "=")) { context.report({ - node: node, + node, message: "No magic number: " + raw + "." }); } diff --git a/tools/eslint/lib/rules/no-mixed-operators.js b/tools/eslint/lib/rules/no-mixed-operators.js index 2ddf9a18675080..e90290c326f5d0 100644 --- a/tools/eslint/lib/rules/no-mixed-operators.js +++ b/tools/eslint/lib/rules/no-mixed-operators.js @@ -48,8 +48,8 @@ function normalizeOptions(options) { const allowSamePrecedence = (options && options.allowSamePrecedence) !== false; return { - groups: groups, - allowSamePrecedence: allowSamePrecedence + groups, + allowSamePrecedence }; } @@ -101,7 +101,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const options = normalizeOptions(context.options[0]); @@ -179,12 +179,12 @@ module.exports = { context.report({ node: left, loc: getOperatorToken(left).loc.start, - message: message + message }); context.report({ node: right, loc: getOperatorToken(right).loc.start, - message: message + message }); } diff --git a/tools/eslint/lib/rules/no-mixed-requires.js b/tools/eslint/lib/rules/no-mixed-requires.js index 9d25a1f090d6d7..d1199daef31147 100644 --- a/tools/eslint/lib/rules/no-mixed-requires.js +++ b/tools/eslint/lib/rules/no-mixed-requires.js @@ -40,7 +40,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0]; let grouping = false, @@ -202,7 +202,7 @@ module.exports = { return { - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (isMixed(node.declarations)) { context.report( diff --git a/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js b/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js index 41e47141089040..0e2dcb1b8a8672 100644 --- a/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js +++ b/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js @@ -23,7 +23,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); let smartTabs; @@ -74,11 +74,11 @@ module.exports = { return { - TemplateElement: function(node) { + TemplateElement(node) { ignoredLocs.push(node.loc); }, - "Program:exit": function(node) { + "Program:exit"(node) { /* * At least one space followed by a tab @@ -132,7 +132,7 @@ module.exports = { return; } - context.report(node, { line: lineNumber, column: column }, "Mixed spaces and tabs."); + context.report(node, { line: lineNumber, column }, "Mixed spaces and tabs."); } }); } diff --git a/tools/eslint/lib/rules/no-multi-spaces.js b/tools/eslint/lib/rules/no-multi-spaces.js index 608843aff249f4..43e26a4415353e 100644 --- a/tools/eslint/lib/rules/no-multi-spaces.js +++ b/tools/eslint/lib/rules/no-multi-spaces.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // the index of the last comment that was checked const exceptions = { Property: true }, @@ -88,7 +88,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - Program: function() { + Program() { const sourceCode = context.getSourceCode(), source = sourceCode.getText(), diff --git a/tools/eslint/lib/rules/no-multi-str.js b/tools/eslint/lib/rules/no-multi-str.js index 78930ab0b7034f..092226f7cad355 100644 --- a/tools/eslint/lib/rules/no-multi-str.js +++ b/tools/eslint/lib/rules/no-multi-str.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Determines if a given node is part of JSX syntax. @@ -38,7 +38,7 @@ module.exports = { return { - Literal: function(node) { + Literal(node) { const lineBreak = /\n/; if (lineBreak.test(node.raw) && !isJSXElement(node.parent)) { diff --git a/tools/eslint/lib/rules/no-multiple-empty-lines.js b/tools/eslint/lib/rules/no-multiple-empty-lines.js index 7b8c73d0ac4ccc..3b9169fa7ea173 100644 --- a/tools/eslint/lib/rules/no-multiple-empty-lines.js +++ b/tools/eslint/lib/rules/no-multiple-empty-lines.js @@ -42,7 +42,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // Use options.max or 2 as default let max = 2, @@ -66,7 +66,7 @@ module.exports = { return { - TemplateLiteral: function(node) { + TemplateLiteral(node) { let start = node.loc.start.line; const end = node.loc.end.line; @@ -144,10 +144,10 @@ module.exports = { rangeStart = linesRangeStart[firstNonBlankLine - diff]; rangeEnd = linesRangeStart[firstNonBlankLine]; context.report({ - node: node, + node, loc: node.loc.start, message: "Too many blank lines at the beginning of file. Max of " + maxBOF + " allowed.", - fix: fix + fix }); } currentLocation = firstNonBlankLine - 1; @@ -174,10 +174,10 @@ module.exports = { rangeEnd = linesRangeStart[location.line]; context.report({ - node: node, + node, loc: location, message: "More than " + max + " blank " + (max === 1 ? "line" : "lines") + " not allowed.", - fix: fix + fix }); } } else { @@ -188,10 +188,10 @@ module.exports = { rangeStart = linesRangeStart[location.line - diff]; rangeEnd = linesRangeStart[location.line - 1]; context.report({ - node: node, + node, loc: location, message: "Too many blank lines at the end of file. Max of " + maxEOF + " allowed.", - fix: fix + fix }); } } diff --git a/tools/eslint/lib/rules/no-native-reassign.js b/tools/eslint/lib/rules/no-native-reassign.js index 46708e94b4acc8..2b1c41b2d100b0 100644 --- a/tools/eslint/lib/rules/no-native-reassign.js +++ b/tools/eslint/lib/rules/no-native-reassign.js @@ -36,7 +36,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0]; const exceptions = (config && config.exceptions) || []; @@ -77,7 +77,7 @@ module.exports = { } return { - Program: function() { + Program() { const globalScope = context.getScope(); globalScope.variables.forEach(checkVariable); diff --git a/tools/eslint/lib/rules/no-negated-condition.js b/tools/eslint/lib/rules/no-negated-condition.js index 5f1037472c5e07..ea8b1210774f16 100644 --- a/tools/eslint/lib/rules/no-negated-condition.js +++ b/tools/eslint/lib/rules/no-negated-condition.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Determines if a given node is an if-else without a condition on the else @@ -63,7 +63,7 @@ module.exports = { } return { - IfStatement: function(node) { + IfStatement(node) { if (!hasElseWithoutCondition(node)) { return; } @@ -72,7 +72,7 @@ module.exports = { context.report(node, "Unexpected negated condition."); } }, - ConditionalExpression: function(node) { + ConditionalExpression(node) { if (isNegatedIf(node)) { context.report(node, "Unexpected negated condition."); } diff --git a/tools/eslint/lib/rules/no-negated-in-lhs.js b/tools/eslint/lib/rules/no-negated-in-lhs.js index d2c39943722ab6..6631336ea74d9f 100644 --- a/tools/eslint/lib/rules/no-negated-in-lhs.js +++ b/tools/eslint/lib/rules/no-negated-in-lhs.js @@ -23,11 +23,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - BinaryExpression: function(node) { + BinaryExpression(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/tools/eslint/lib/rules/no-nested-ternary.js b/tools/eslint/lib/rules/no-nested-ternary.js index d28ee693cf0631..50265913b02ecf 100644 --- a/tools/eslint/lib/rules/no-nested-ternary.js +++ b/tools/eslint/lib/rules/no-nested-ternary.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ConditionalExpression: function(node) { + ConditionalExpression(node) { if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") { context.report(node, "Do not nest ternary expressions."); diff --git a/tools/eslint/lib/rules/no-new-func.js b/tools/eslint/lib/rules/no-new-func.js index 7b01db0cd28d4b..e78bcc0772a024 100644 --- a/tools/eslint/lib/rules/no-new-func.js +++ b/tools/eslint/lib/rules/no-new-func.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Helpers diff --git a/tools/eslint/lib/rules/no-new-object.js b/tools/eslint/lib/rules/no-new-object.js index 4fc2a3bebb09f6..d11a2ebc615350 100644 --- a/tools/eslint/lib/rules/no-new-object.js +++ b/tools/eslint/lib/rules/no-new-object.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - NewExpression: function(node) { + NewExpression(node) { if (node.callee.name === "Object") { context.report(node, "The object literal notation {} is preferrable."); } diff --git a/tools/eslint/lib/rules/no-new-require.js b/tools/eslint/lib/rules/no-new-require.js index b39d9c3e373e26..eed2028de351fa 100644 --- a/tools/eslint/lib/rules/no-new-require.js +++ b/tools/eslint/lib/rules/no-new-require.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - NewExpression: function(node) { + NewExpression(node) { if (node.callee.type === "Identifier" && node.callee.name === "require") { context.report(node, "Unexpected use of new with require."); } diff --git a/tools/eslint/lib/rules/no-new-symbol.js b/tools/eslint/lib/rules/no-new-symbol.js index e8c87b1b63b120..c65e7c9df90afb 100644 --- a/tools/eslint/lib/rules/no-new-symbol.js +++ b/tools/eslint/lib/rules/no-new-symbol.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - "Program:exit": function() { + "Program:exit"() { const globalScope = context.getScope(); const variable = globalScope.set.get("Symbol"); diff --git a/tools/eslint/lib/rules/no-new-wrappers.js b/tools/eslint/lib/rules/no-new-wrappers.js index cfc80a7f9ad17a..67e69ee0fefe0a 100644 --- a/tools/eslint/lib/rules/no-new-wrappers.js +++ b/tools/eslint/lib/rules/no-new-wrappers.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - NewExpression: function(node) { + NewExpression(node) { const wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"]; if (wrapperObjects.indexOf(node.callee.name) > -1) { diff --git a/tools/eslint/lib/rules/no-new.js b/tools/eslint/lib/rules/no-new.js index 154bced9bcfb29..639ae22685a96b 100644 --- a/tools/eslint/lib/rules/no-new.js +++ b/tools/eslint/lib/rules/no-new.js @@ -21,11 +21,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ExpressionStatement: function(node) { + ExpressionStatement(node) { if (node.expression.type === "NewExpression") { context.report(node, "Do not use 'new' for side effects."); diff --git a/tools/eslint/lib/rules/no-obj-calls.js b/tools/eslint/lib/rules/no-obj-calls.js index fafc31296f36f7..bd9b6ee4f04f76 100644 --- a/tools/eslint/lib/rules/no-obj-calls.js +++ b/tools/eslint/lib/rules/no-obj-calls.js @@ -20,16 +20,16 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - CallExpression: function(node) { + CallExpression(node) { if (node.callee.type === "Identifier") { const name = node.callee.name; if (name === "Math" || name === "JSON") { - context.report(node, "'{{name}}' is not a function.", { name: name }); + context.report(node, "'{{name}}' is not a function.", { name }); } } } diff --git a/tools/eslint/lib/rules/no-octal-escape.js b/tools/eslint/lib/rules/no-octal-escape.js index e4af81db5eed16..25a5b022e92402 100644 --- a/tools/eslint/lib/rules/no-octal-escape.js +++ b/tools/eslint/lib/rules/no-octal-escape.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - Literal: function(node) { + Literal(node) { if (typeof node.value !== "string") { return; } @@ -37,7 +37,7 @@ module.exports = { // \0 is actually not considered an octal if (match[2] !== "0" || typeof match[3] !== "undefined") { context.report(node, "Don't use octal: '\\{{octalDigit}}'. Use '\\u....' instead.", - { octalDigit: octalDigit }); + { octalDigit }); } } } diff --git a/tools/eslint/lib/rules/no-octal.js b/tools/eslint/lib/rules/no-octal.js index 1332dde5e8234f..ebc5e3252d9771 100644 --- a/tools/eslint/lib/rules/no-octal.js +++ b/tools/eslint/lib/rules/no-octal.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - Literal: function(node) { + Literal(node) { if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) { context.report(node, "Octal literals should not be used."); } diff --git a/tools/eslint/lib/rules/no-param-reassign.js b/tools/eslint/lib/rules/no-param-reassign.js index 048e87bbc36eb0..c20f340d7ab43a 100644 --- a/tools/eslint/lib/rules/no-param-reassign.js +++ b/tools/eslint/lib/rules/no-param-reassign.js @@ -29,7 +29,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const props = context.options[0] && Boolean(context.options[0].props); /** diff --git a/tools/eslint/lib/rules/no-path-concat.js b/tools/eslint/lib/rules/no-path-concat.js index 72fba0b9cd87d9..6b27678aedc8f8 100644 --- a/tools/eslint/lib/rules/no-path-concat.js +++ b/tools/eslint/lib/rules/no-path-concat.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const MATCHER = /^__(?:dir|file)name$/; @@ -29,7 +29,7 @@ module.exports = { return { - BinaryExpression: function(node) { + BinaryExpression(node) { const left = node.left, right = node.right; diff --git a/tools/eslint/lib/rules/no-plusplus.js b/tools/eslint/lib/rules/no-plusplus.js index 7b4dd59569b40f..2448dea99a3c36 100644 --- a/tools/eslint/lib/rules/no-plusplus.js +++ b/tools/eslint/lib/rules/no-plusplus.js @@ -31,7 +31,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0]; let allowInForAfterthought = false; @@ -42,7 +42,7 @@ module.exports = { return { - UpdateExpression: function(node) { + UpdateExpression(node) { if (allowInForAfterthought && node.parent.type === "ForStatement") { return; } diff --git a/tools/eslint/lib/rules/no-process-env.js b/tools/eslint/lib/rules/no-process-env.js index 229b95f8d6da56..a2ae1fd408ac44 100644 --- a/tools/eslint/lib/rules/no-process-env.js +++ b/tools/eslint/lib/rules/no-process-env.js @@ -19,11 +19,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - MemberExpression: function(node) { + MemberExpression(node) { const objectName = node.object.name, propertyName = node.property.name; diff --git a/tools/eslint/lib/rules/no-process-exit.js b/tools/eslint/lib/rules/no-process-exit.js index 2ca84b92013463..69023e58e1b109 100644 --- a/tools/eslint/lib/rules/no-process-exit.js +++ b/tools/eslint/lib/rules/no-process-exit.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Public @@ -27,7 +27,7 @@ module.exports = { return { - CallExpression: function(node) { + CallExpression(node) { const callee = node.callee; if (callee.type === "MemberExpression" && callee.object.name === "process" && diff --git a/tools/eslint/lib/rules/no-proto.js b/tools/eslint/lib/rules/no-proto.js index 325f3d1c019b64..03eb88273c4bc2 100644 --- a/tools/eslint/lib/rules/no-proto.js +++ b/tools/eslint/lib/rules/no-proto.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - MemberExpression: function(node) { + MemberExpression(node) { if (node.property && (node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed) || diff --git a/tools/eslint/lib/rules/no-prototype-builtins.js b/tools/eslint/lib/rules/no-prototype-builtins.js index a0ce73fc15f376..e9f46881597333 100644 --- a/tools/eslint/lib/rules/no-prototype-builtins.js +++ b/tools/eslint/lib/rules/no-prototype-builtins.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const DISALLOWED_PROPS = [ "hasOwnProperty", "isPrototypeOf", @@ -42,7 +42,7 @@ module.exports = { message: "Do not access Object.prototype method '{{prop}}' from target object.", loc: node.callee.property.loc.start, data: {prop: propName}, - node: node + node }); } } diff --git a/tools/eslint/lib/rules/no-redeclare.js b/tools/eslint/lib/rules/no-redeclare.js index 8a26b34b428e37..28e560382babd5 100644 --- a/tools/eslint/lib/rules/no-redeclare.js +++ b/tools/eslint/lib/rules/no-redeclare.js @@ -28,7 +28,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = { builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals) }; diff --git a/tools/eslint/lib/rules/no-regex-spaces.js b/tools/eslint/lib/rules/no-regex-spaces.js index dc09e98e05b6e3..86271cf1b7b72f 100644 --- a/tools/eslint/lib/rules/no-regex-spaces.js +++ b/tools/eslint/lib/rules/no-regex-spaces.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); /** diff --git a/tools/eslint/lib/rules/no-restricted-globals.js b/tools/eslint/lib/rules/no-restricted-globals.js index 3617f1a8d7b776..07ff8b532d2307 100644 --- a/tools/eslint/lib/rules/no-restricted-globals.js +++ b/tools/eslint/lib/rules/no-restricted-globals.js @@ -25,7 +25,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const restrictedGlobals = context.options; // if no globals are restricted we don't need to check @@ -56,7 +56,7 @@ module.exports = { } return { - Program: function() { + Program() { const scope = context.getScope(); // Report variables declared elsewhere (ex: variables defined as "global" by eslint) diff --git a/tools/eslint/lib/rules/no-restricted-imports.js b/tools/eslint/lib/rules/no-restricted-imports.js index 3649f027ac2fe7..87f9af2a6477e0 100644 --- a/tools/eslint/lib/rules/no-restricted-imports.js +++ b/tools/eslint/lib/rules/no-restricted-imports.js @@ -25,7 +25,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const restrictedImports = context.options; // if no imports are restricted we don"t need to check @@ -34,7 +34,7 @@ module.exports = { } return { - ImportDeclaration: function(node) { + ImportDeclaration(node) { if (node && node.source && node.source.value) { const value = node.source.value.trim(); diff --git a/tools/eslint/lib/rules/no-restricted-modules.js b/tools/eslint/lib/rules/no-restricted-modules.js index 982ad0110dc956..1a46c40a81dbe2 100644 --- a/tools/eslint/lib/rules/no-restricted-modules.js +++ b/tools/eslint/lib/rules/no-restricted-modules.js @@ -25,7 +25,7 @@ module.exports = { } }, - create: function(context) { + create(context) { // trim restricted module names const restrictedModules = context.options; @@ -75,7 +75,7 @@ module.exports = { } return { - CallExpression: function(node) { + CallExpression(node) { if (isRequireCall(node)) { const restrictedModuleName = getRestrictedModuleName(node); diff --git a/tools/eslint/lib/rules/no-restricted-syntax.js b/tools/eslint/lib/rules/no-restricted-syntax.js index 7c4d2345018402..ab6c36923a69b0 100644 --- a/tools/eslint/lib/rules/no-restricted-syntax.js +++ b/tools/eslint/lib/rules/no-restricted-syntax.js @@ -32,7 +32,7 @@ module.exports = { } }, - create: function(context) { + create(context) { /** * Generates a warning from the provided node, saying that node type is not allowed. diff --git a/tools/eslint/lib/rules/no-return-assign.js b/tools/eslint/lib/rules/no-return-assign.js index d223fff7ad37bd..653d997468ebf8 100644 --- a/tools/eslint/lib/rules/no-return-assign.js +++ b/tools/eslint/lib/rules/no-return-assign.js @@ -42,12 +42,12 @@ module.exports = { ] }, - create: function(context) { + create(context) { const always = (context.options[0] || "except-parens") !== "except-parens"; const sourceCode = context.getSourceCode(); return { - AssignmentExpression: function(node) { + AssignmentExpression(node) { if (!always && isEnclosedInParens(node, sourceCode)) { return; } diff --git a/tools/eslint/lib/rules/no-script-url.js b/tools/eslint/lib/rules/no-script-url.js index 0d767bbd1e6380..fd2f1e8c3e8954 100644 --- a/tools/eslint/lib/rules/no-script-url.js +++ b/tools/eslint/lib/rules/no-script-url.js @@ -22,11 +22,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - Literal: function(node) { + Literal(node) { if (node.value && typeof node.value === "string") { const value = node.value.toLowerCase(); diff --git a/tools/eslint/lib/rules/no-self-assign.js b/tools/eslint/lib/rules/no-self-assign.js index bfc0241664e486..8b9314a3e87659 100644 --- a/tools/eslint/lib/rules/no-self-assign.js +++ b/tools/eslint/lib/rules/no-self-assign.js @@ -180,7 +180,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const options = context.options[0]; const props = Boolean(options && options.props); @@ -193,7 +193,7 @@ module.exports = { */ function report(node) { context.report({ - node: node, + node, message: "'{{name}}' is assigned to itself.", data: { name: sourceCode.getText(node).replace(SPACES, "") @@ -202,7 +202,7 @@ module.exports = { } return { - AssignmentExpression: function(node) { + AssignmentExpression(node) { if (node.operator === "=") { eachSelfAssignment(node.left, node.right, props, report); } diff --git a/tools/eslint/lib/rules/no-self-compare.js b/tools/eslint/lib/rules/no-self-compare.js index db51796217b9f7..17ce77a939d53e 100644 --- a/tools/eslint/lib/rules/no-self-compare.js +++ b/tools/eslint/lib/rules/no-self-compare.js @@ -21,11 +21,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - BinaryExpression: function(node) { + BinaryExpression(node) { const operators = ["===", "==", "!==", "!=", ">", "<", ">=", "<="]; if (operators.indexOf(node.operator) > -1 && diff --git a/tools/eslint/lib/rules/no-sequences.js b/tools/eslint/lib/rules/no-sequences.js index 7971dac0dcb880..49f20ea43ff61a 100644 --- a/tools/eslint/lib/rules/no-sequences.js +++ b/tools/eslint/lib/rules/no-sequences.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); /** @@ -80,7 +80,7 @@ module.exports = { } return { - SequenceExpression: function(node) { + SequenceExpression(node) { // Always allow sequences in for statement update if (node.parent.type === "ForStatement" && diff --git a/tools/eslint/lib/rules/no-shadow-restricted-names.js b/tools/eslint/lib/rules/no-shadow-restricted-names.js index 54dc1e58733c86..e78183b652d941 100644 --- a/tools/eslint/lib/rules/no-shadow-restricted-names.js +++ b/tools/eslint/lib/rules/no-shadow-restricted-names.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"]; @@ -36,25 +36,25 @@ module.exports = { } return { - VariableDeclarator: function(node) { + VariableDeclarator(node) { checkForViolation(node.id); }, - ArrowFunctionExpression: function(node) { + ArrowFunctionExpression(node) { [].map.call(node.params, checkForViolation); }, - FunctionExpression: function(node) { + FunctionExpression(node) { if (node.id) { checkForViolation(node.id); } [].map.call(node.params, checkForViolation); }, - FunctionDeclaration: function(node) { + FunctionDeclaration(node) { if (node.id) { checkForViolation(node.id); [].map.call(node.params, checkForViolation); } }, - CatchClause: function(node) { + CatchClause(node) { checkForViolation(node.param); } }; diff --git a/tools/eslint/lib/rules/no-shadow.js b/tools/eslint/lib/rules/no-shadow.js index 6eca4a41760d4e..a31288749b5de5 100644 --- a/tools/eslint/lib/rules/no-shadow.js +++ b/tools/eslint/lib/rules/no-shadow.js @@ -41,7 +41,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = { builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals), @@ -171,7 +171,7 @@ module.exports = { } return { - "Program:exit": function() { + "Program:exit"() { const globalScope = context.getScope(); const stack = globalScope.childScopes.slice(); diff --git a/tools/eslint/lib/rules/no-spaced-func.js b/tools/eslint/lib/rules/no-spaced-func.js index cf8266bca5bbb4..39a2f7f7ad9be8 100644 --- a/tools/eslint/lib/rules/no-spaced-func.js +++ b/tools/eslint/lib/rules/no-spaced-func.js @@ -25,7 +25,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); @@ -56,10 +56,10 @@ module.exports = { sourceCode.isSpaceBetweenTokens(prevToken, parenToken) ) { context.report({ - node: node, + node, loc: lastCalleeToken.loc.start, message: "Unexpected space between function name and paren.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); } }); diff --git a/tools/eslint/lib/rules/no-sparse-arrays.js b/tools/eslint/lib/rules/no-sparse-arrays.js index 1765c4c5fa052a..31bd6f2bbffb00 100644 --- a/tools/eslint/lib/rules/no-sparse-arrays.js +++ b/tools/eslint/lib/rules/no-sparse-arrays.js @@ -19,7 +19,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- @@ -28,7 +28,7 @@ module.exports = { return { - ArrayExpression: function(node) { + ArrayExpression(node) { const emptySpot = node.elements.indexOf(null) > -1; diff --git a/tools/eslint/lib/rules/no-sync.js b/tools/eslint/lib/rules/no-sync.js index 449f27eba700a1..4e10103ce28b3f 100644 --- a/tools/eslint/lib/rules/no-sync.js +++ b/tools/eslint/lib/rules/no-sync.js @@ -22,11 +22,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - MemberExpression: function(node) { + MemberExpression(node) { const propertyName = node.property.name, syncRegex = /.*Sync$/; diff --git a/tools/eslint/lib/rules/no-tabs.js b/tools/eslint/lib/rules/no-tabs.js index ef873db2bdb0b8..d57ac324c1d58b 100644 --- a/tools/eslint/lib/rules/no-tabs.js +++ b/tools/eslint/lib/rules/no-tabs.js @@ -17,7 +17,7 @@ const regex = /\t/; module.exports = { meta: { docs: { - description: "Disallow tabs in file", + description: "disallow tabs in file", category: "Stylistic Issues", recommended: false }, diff --git a/tools/eslint/lib/rules/no-template-curly-in-string.js b/tools/eslint/lib/rules/no-template-curly-in-string.js index c0227019dc4640..d8f6c31108bb23 100644 --- a/tools/eslint/lib/rules/no-template-curly-in-string.js +++ b/tools/eslint/lib/rules/no-template-curly-in-string.js @@ -11,7 +11,7 @@ module.exports = { meta: { docs: { - description: "Disallow template literal placeholder syntax in regular strings", + description: "disallow template literal placeholder syntax in regular strings", category: "Possible Errors", recommended: false }, @@ -19,14 +19,14 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const regex = /\$\{[^}]+\}/; return { - Literal: function(node) { + Literal(node) { if (typeof node.value === "string" && regex.test(node.value)) { context.report({ - node: node, + node, message: "Unexpected template string expression." }); } diff --git a/tools/eslint/lib/rules/no-ternary.js b/tools/eslint/lib/rules/no-ternary.js index fb986152bbf74b..2408cd9c39a0ea 100644 --- a/tools/eslint/lib/rules/no-ternary.js +++ b/tools/eslint/lib/rules/no-ternary.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ConditionalExpression: function(node) { + ConditionalExpression(node) { context.report(node, "Ternary operator used."); } diff --git a/tools/eslint/lib/rules/no-this-before-super.js b/tools/eslint/lib/rules/no-this-before-super.js index 5f19b1819d67cb..80a769a481a44a 100644 --- a/tools/eslint/lib/rules/no-this-before-super.js +++ b/tools/eslint/lib/rules/no-this-before-super.js @@ -45,7 +45,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /* * Information for each constructor. @@ -136,7 +136,7 @@ module.exports = { * @param {ASTNode} node - The current node. * @returns {void} */ - onCodePathStart: function(codePath, node) { + onCodePathStart(codePath, node) { if (isConstructorFunction(node)) { // Class > ClassBody > MethodDefinition > FunctionExpression @@ -149,14 +149,14 @@ module.exports = { classNode.superClass && !astUtils.isNullOrUndefined(classNode.superClass) ), - codePath: codePath + codePath }; } else { funcInfo = { upper: funcInfo, isConstructor: false, hasExtends: false, - codePath: codePath + codePath }; } }, @@ -171,7 +171,7 @@ module.exports = { * @param {ASTNode} node - The current node. * @returns {void} */ - onCodePathEnd: function(codePath) { + onCodePathEnd(codePath) { const isDerivedClass = funcInfo.hasExtends; funcInfo = funcInfo.upper; @@ -205,7 +205,7 @@ module.exports = { * @param {CodePathSegment} segment - A code path segment to initialize. * @returns {void} */ - onCodePathSegmentStart: function(segment) { + onCodePathSegmentStart(segment) { if (!isInConstructorOfDerivedClass(funcInfo)) { return; } @@ -229,7 +229,7 @@ module.exports = { * of a loop. * @returns {void} */ - onCodePathSegmentLoop: function(fromSegment, toSegment) { + onCodePathSegmentLoop(fromSegment, toSegment) { if (!isInConstructorOfDerivedClass(funcInfo)) { return; } @@ -259,7 +259,7 @@ module.exports = { * @param {ASTNode} node - A target node. * @returns {void} */ - ThisExpression: function(node) { + ThisExpression(node) { if (isBeforeCallOfSuper()) { setInvalid(node); } @@ -270,7 +270,7 @@ module.exports = { * @param {ASTNode} node - A target node. * @returns {void} */ - Super: function(node) { + Super(node) { if (!astUtils.isCallee(node) && isBeforeCallOfSuper()) { setInvalid(node); } @@ -281,7 +281,7 @@ module.exports = { * @param {ASTNode} node - A target node. * @returns {void} */ - "CallExpression:exit": function(node) { + "CallExpression:exit"(node) { if (node.callee.type === "Super" && isBeforeCallOfSuper()) { setSuperCalled(); } @@ -291,7 +291,7 @@ module.exports = { * Resets state. * @returns {void} */ - "Program:exit": function() { + "Program:exit"() { segInfoMap = Object.create(null); } }; diff --git a/tools/eslint/lib/rules/no-throw-literal.js b/tools/eslint/lib/rules/no-throw-literal.js index 69eda1c76545e8..034361c7a620c9 100644 --- a/tools/eslint/lib/rules/no-throw-literal.js +++ b/tools/eslint/lib/rules/no-throw-literal.js @@ -59,11 +59,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - ThrowStatement: function(node) { + ThrowStatement(node) { if (!couldBeError(node.argument)) { context.report(node, "Expected an object to be thrown."); } else if (node.argument.type === "Identifier") { diff --git a/tools/eslint/lib/rules/no-trailing-spaces.js b/tools/eslint/lib/rules/no-trailing-spaces.js index ed7356f193a5b2..572a9f37d8b60d 100644 --- a/tools/eslint/lib/rules/no-trailing-spaces.js +++ b/tools/eslint/lib/rules/no-trailing-spaces.js @@ -31,7 +31,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const BLANK_CLASS = "[ \t\u00a0\u2000-\u200b\u2028\u2029\u3000]", @@ -57,10 +57,10 @@ module.exports = { * plugin. */ context.report({ - node: node, + node, loc: location, message: "Trailing spaces not allowed.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange(fixRange); } }); @@ -114,6 +114,7 @@ module.exports = { // If the line has only whitespace, and skipBlankLines // is true, don't report it if (skipBlankLines && skipMatch.test(lines[i])) { + totalLength += lineLength; continue; } diff --git a/tools/eslint/lib/rules/no-undef-init.js b/tools/eslint/lib/rules/no-undef-init.js index 80a27f6b78ce2a..67efa87085339d 100644 --- a/tools/eslint/lib/rules/no-undef-init.js +++ b/tools/eslint/lib/rules/no-undef-init.js @@ -20,16 +20,16 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - VariableDeclarator: function(node) { + VariableDeclarator(node) { const name = node.id.name, init = node.init && node.init.name; if (init === "undefined" && node.parent.kind !== "const") { - context.report(node, "It's not necessary to initialize '{{name}}' to undefined.", { name: name }); + context.report(node, "It's not necessary to initialize '{{name}}' to undefined.", { name }); } } }; diff --git a/tools/eslint/lib/rules/no-undef.js b/tools/eslint/lib/rules/no-undef.js index 1206747086ef55..2cd2980f840581 100644 --- a/tools/eslint/lib/rules/no-undef.js +++ b/tools/eslint/lib/rules/no-undef.js @@ -44,12 +44,12 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0]; const considerTypeOf = options && options.typeof === true || false; return { - "Program:exit": function(/* node */) { + "Program:exit"(/* node */) { const globalScope = context.getScope(); globalScope.through.forEach(function(ref) { diff --git a/tools/eslint/lib/rules/no-undefined.js b/tools/eslint/lib/rules/no-undefined.js index 7a785b80fb3ff7..2aad3d0d1f4b55 100644 --- a/tools/eslint/lib/rules/no-undefined.js +++ b/tools/eslint/lib/rules/no-undefined.js @@ -19,11 +19,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - Identifier: function(node) { + Identifier(node) { if (node.name === "undefined") { const parent = context.getAncestors().pop(); diff --git a/tools/eslint/lib/rules/no-underscore-dangle.js b/tools/eslint/lib/rules/no-underscore-dangle.js index 01f44309a944df..567e1c8ee13736 100644 --- a/tools/eslint/lib/rules/no-underscore-dangle.js +++ b/tools/eslint/lib/rules/no-underscore-dangle.js @@ -39,7 +39,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const ALLOWED_VARIABLES = options.allow ? options.allow : []; diff --git a/tools/eslint/lib/rules/no-unexpected-multiline.js b/tools/eslint/lib/rules/no-unexpected-multiline.js index 832150e4e7c390..5208813dadada0 100644 --- a/tools/eslint/lib/rules/no-unexpected-multiline.js +++ b/tools/eslint/lib/rules/no-unexpected-multiline.js @@ -18,7 +18,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const FUNCTION_MESSAGE = "Unexpected newline between function and ( of function call."; const PROPERTY_MESSAGE = "Unexpected newline between object and [ of property access."; @@ -55,21 +55,21 @@ module.exports = { return { - MemberExpression: function(node) { + MemberExpression(node) { if (!node.computed) { return; } checkForBreakAfter(node.object, PROPERTY_MESSAGE); }, - TaggedTemplateExpression: function(node) { + TaggedTemplateExpression(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(node) { if (node.arguments.length === 0) { return; } diff --git a/tools/eslint/lib/rules/no-unmodified-loop-condition.js b/tools/eslint/lib/rules/no-unmodified-loop-condition.js index 3f3addf552c2c3..8243611913a1e8 100644 --- a/tools/eslint/lib/rules/no-unmodified-loop-condition.js +++ b/tools/eslint/lib/rules/no-unmodified-loop-condition.js @@ -98,7 +98,7 @@ function isInRange(node, reference) { const isInLoop = { WhileStatement: isInRange, DoWhileStatement: isInRange, - ForStatement: function(node, reference) { + ForStatement(node, reference) { return ( isInRange(node, reference) && !(node.init && isInRange(node.init, reference)) @@ -118,7 +118,7 @@ function hasDynamicExpressions(root) { const traverser = new Traverser(); traverser.traverse(root, { - enter: function(node) { + enter(node) { if (DYNAMIC_PATTERN.test(node.type)) { retv = true; this.break(); @@ -152,8 +152,8 @@ function toLoopCondition(reference) { // This reference is inside of a loop condition. return { - reference: reference, - group: group, + reference, + group, isInLoop: isInLoop[node.type].bind(null, node), modified: false }; @@ -253,7 +253,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let groupMap = null; /** @@ -266,7 +266,7 @@ module.exports = { const node = condition.reference.identifier; context.report({ - node: node, + node, message: "'{{name}}' is not modified in this loop.", data: node }); @@ -346,7 +346,7 @@ module.exports = { } return { - "Program:exit": function() { + "Program:exit"() { const queue = [context.getScope()]; groupMap = new Map(); diff --git a/tools/eslint/lib/rules/no-unneeded-ternary.js b/tools/eslint/lib/rules/no-unneeded-ternary.js index d22d703498ff77..c755f5f4b4fd11 100644 --- a/tools/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/eslint/lib/rules/no-unneeded-ternary.js @@ -30,7 +30,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const defaultAssignment = options.defaultAssignment !== false; @@ -58,7 +58,7 @@ module.exports = { return { - ConditionalExpression: function(node) { + ConditionalExpression(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)) { diff --git a/tools/eslint/lib/rules/no-unreachable.js b/tools/eslint/lib/rules/no-unreachable.js index d52b9f3517bc22..82ef8301a3612e 100644 --- a/tools/eslint/lib/rules/no-unreachable.js +++ b/tools/eslint/lib/rules/no-unreachable.js @@ -110,7 +110,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let currentCodePath = null; const range = new ConsecutiveRange(context.getSourceCode()); @@ -162,11 +162,11 @@ module.exports = { return { // Manages the current code path. - onCodePathStart: function(codePath) { + onCodePathStart(codePath) { currentCodePath = codePath; }, - onCodePathEnd: function() { + onCodePathEnd() { currentCodePath = currentCodePath.upper; }, @@ -190,7 +190,7 @@ module.exports = { ThrowStatement: reportIfUnreachable, TryStatement: reportIfUnreachable, - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (node.kind !== "var" || node.declarations.some(isInitialized)) { reportIfUnreachable(node); } @@ -202,7 +202,7 @@ module.exports = { ExportDefaultDeclaration: reportIfUnreachable, ExportAllDeclaration: reportIfUnreachable, - "Program:exit": function() { + "Program:exit"() { reportIfUnreachable(); } }; diff --git a/tools/eslint/lib/rules/no-unsafe-finally.js b/tools/eslint/lib/rules/no-unsafe-finally.js index 05901abf0433de..6c5b15f5492e4e 100644 --- a/tools/eslint/lib/rules/no-unsafe-finally.js +++ b/tools/eslint/lib/rules/no-unsafe-finally.js @@ -28,7 +28,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Checks if the node is the finalizer of a TryStatement @@ -84,7 +84,7 @@ module.exports = { if (isInFinallyBlock(node, node.label)) { context.report({ message: "Unsafe usage of " + node.type + ".", - node: node, + node, line: node.loc.line, column: node.loc.column }); diff --git a/tools/eslint/lib/rules/no-unsafe-negation.js b/tools/eslint/lib/rules/no-unsafe-negation.js index c3852a24d75e46..4e2378d4d0f7db 100644 --- a/tools/eslint/lib/rules/no-unsafe-negation.js +++ b/tools/eslint/lib/rules/no-unsafe-negation.js @@ -60,7 +60,7 @@ module.exports = { !astUtils.isParenthesised(sourceCode, node.left) ) { context.report({ - node: node, + node, loc: node.left.loc, message: "Unexpected negating the left operand of '{{operator}}' operator.", data: node, diff --git a/tools/eslint/lib/rules/no-unused-expressions.js b/tools/eslint/lib/rules/no-unused-expressions.js index c5e062ad2a45af..b6408956467448 100644 --- a/tools/eslint/lib/rules/no-unused-expressions.js +++ b/tools/eslint/lib/rules/no-unused-expressions.js @@ -32,7 +32,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0] || {}, allowShortCircuit = config.allowShortCircuit || false, allowTernary = config.allowTernary || false; @@ -106,7 +106,7 @@ module.exports = { } return { - ExpressionStatement: function(node) { + ExpressionStatement(node) { if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) { context.report(node, "Expected an assignment or function call and instead saw an expression."); } diff --git a/tools/eslint/lib/rules/no-unused-labels.js b/tools/eslint/lib/rules/no-unused-labels.js index f7d9045b505348..7d3e533c44a566 100644 --- a/tools/eslint/lib/rules/no-unused-labels.js +++ b/tools/eslint/lib/rules/no-unused-labels.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let scopeInfo = null; /** diff --git a/tools/eslint/lib/rules/no-unused-vars.js b/tools/eslint/lib/rules/no-unused-vars.js index 61052f6c1ea40f..d7bc2cbf71b505 100644 --- a/tools/eslint/lib/rules/no-unused-vars.js +++ b/tools/eslint/lib/rules/no-unused-vars.js @@ -58,7 +58,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const MESSAGE = "'{{name}}' is defined but never used."; @@ -550,7 +550,7 @@ module.exports = { return { line: baseLoc.line + lineInComment, - column: column + column }; } @@ -559,7 +559,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - "Program:exit": function(programNode) { + "Program:exit"(programNode) { const unusedVars = collectUnusedVariables(context.getScope(), []); for (let i = 0, l = unusedVars.length; i < l; ++i) { diff --git a/tools/eslint/lib/rules/no-use-before-define.js b/tools/eslint/lib/rules/no-use-before-define.js index edc7926fe947d0..01c899ca3920c4 100644 --- a/tools/eslint/lib/rules/no-use-before-define.js +++ b/tools/eslint/lib/rules/no-use-before-define.js @@ -29,7 +29,7 @@ function parseOptions(options) { classes = options.classes !== false; } - return {functions: functions, classes: classes}; + return {functions, classes}; } /** @@ -164,7 +164,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = parseOptions(context.options[0]); // Defines a function which checks whether or not a reference is allowed according to the option. @@ -227,7 +227,7 @@ module.exports = { } const ruleDefinition = { - "Program:exit": function(node) { + "Program:exit"(node) { const scope = context.getScope(), ecmaFeatures = context.parserOptions.ecmaFeatures || {}; diff --git a/tools/eslint/lib/rules/no-useless-call.js b/tools/eslint/lib/rules/no-useless-call.js index ace10f682a6727..2be665992a08e5 100644 --- a/tools/eslint/lib/rules/no-useless-call.js +++ b/tools/eslint/lib/rules/no-useless-call.js @@ -82,11 +82,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - CallExpression: function(node) { + CallExpression(node) { if (!isCallOrNonVariadicApply(node)) { return; } diff --git a/tools/eslint/lib/rules/no-useless-computed-key.js b/tools/eslint/lib/rules/no-useless-computed-key.js index e90f7aaca8b259..34a8c9dc22f31a 100644 --- a/tools/eslint/lib/rules/no-useless-computed-key.js +++ b/tools/eslint/lib/rules/no-useless-computed-key.js @@ -20,11 +20,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - Property: function(node) { + Property(node) { if (!node.computed) { return; } diff --git a/tools/eslint/lib/rules/no-useless-concat.js b/tools/eslint/lib/rules/no-useless-concat.js index 20d2afeacaa227..d9cf6a2c354b8b 100644 --- a/tools/eslint/lib/rules/no-useless-concat.js +++ b/tools/eslint/lib/rules/no-useless-concat.js @@ -66,11 +66,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - BinaryExpression: function(node) { + BinaryExpression(node) { // check if not concatenation if (node.operator !== "+") { diff --git a/tools/eslint/lib/rules/no-useless-constructor.js b/tools/eslint/lib/rules/no-useless-constructor.js index 323be4f1fa34d2..f790c789f53d0b 100644 --- a/tools/eslint/lib/rules/no-useless-constructor.js +++ b/tools/eslint/lib/rules/no-useless-constructor.js @@ -151,7 +151,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Checks whether a node is a redundant constructor @@ -169,7 +169,7 @@ module.exports = { if (superClass ? isRedundantSuperCall(body, ctorParams) : (body.length === 0)) { context.report({ - node: node, + node, message: "Useless constructor." }); } diff --git a/tools/eslint/lib/rules/no-useless-escape.js b/tools/eslint/lib/rules/no-useless-escape.js index 244249c389c8e3..6113bff1d03be3 100644 --- a/tools/eslint/lib/rules/no-useless-escape.js +++ b/tools/eslint/lib/rules/no-useless-escape.js @@ -68,7 +68,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Checks if the escape character in given slice is unnecessary. @@ -85,7 +85,7 @@ module.exports = { if (escapeNotFound && !isQuoteEscape) { context.report({ - node: node, + node, loc: { line: node.loc.start.line, column: node.loc.start.column + elm.index diff --git a/tools/eslint/lib/rules/no-useless-rename.js b/tools/eslint/lib/rules/no-useless-rename.js index 91cdcc49ffb215..a489a6e51ba0c0 100644 --- a/tools/eslint/lib/rules/no-useless-rename.js +++ b/tools/eslint/lib/rules/no-useless-rename.js @@ -30,7 +30,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}, ignoreDestructuring = options.ignoreDestructuring === true, ignoreImport = options.ignoreImport === true, @@ -52,13 +52,13 @@ module.exports = { const name = initial.type === "Identifier" ? initial.name : initial.value; return context.report({ - node: node, + node, message: "{{type}} {{name}} unnecessarily renamed.", data: { - name: name, - type: type + name, + type }, - fix: function(fixer) { + fix(fixer) { return fixer.replaceTextRange([ initial.range[0], result.range[1] diff --git a/tools/eslint/lib/rules/no-var.js b/tools/eslint/lib/rules/no-var.js index dfef7ceea69014..0e98170e65e7c1 100644 --- a/tools/eslint/lib/rules/no-var.js +++ b/tools/eslint/lib/rules/no-var.js @@ -87,7 +87,7 @@ module.exports = { fixable: "code" }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); /** @@ -139,10 +139,10 @@ module.exports = { const varToken = sourceCode.getFirstToken(node); context.report({ - node: node, + node, message: "Unexpected var, use let or const instead.", - fix: function(fixer) { + fix(fixer) { if (canFix(node)) { return fixer.replaceText(varToken, "let"); } @@ -152,7 +152,7 @@ module.exports = { } return { - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (node.kind === "var") { report(node); } diff --git a/tools/eslint/lib/rules/no-void.js b/tools/eslint/lib/rules/no-void.js index 4adae20b37bc91..16a36fb3a56df1 100644 --- a/tools/eslint/lib/rules/no-void.js +++ b/tools/eslint/lib/rules/no-void.js @@ -19,14 +19,14 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { - UnaryExpression: function(node) { + UnaryExpression(node) { if (node.operator === "void") { context.report(node, "Expected 'undefined' and instead saw 'void'."); } diff --git a/tools/eslint/lib/rules/no-warning-comments.js b/tools/eslint/lib/rules/no-warning-comments.js index d0ae12da61574c..2467841320596c 100644 --- a/tools/eslint/lib/rules/no-warning-comments.js +++ b/tools/eslint/lib/rules/no-warning-comments.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const configuration = context.options[0] || {}, warningTerms = configuration.terms || ["todo", "fixme", "xxx"], diff --git a/tools/eslint/lib/rules/no-whitespace-before-property.js b/tools/eslint/lib/rules/no-whitespace-before-property.js index 2c0ad7a75035da..8751f143f19138 100644 --- a/tools/eslint/lib/rules/no-whitespace-before-property.js +++ b/tools/eslint/lib/rules/no-whitespace-before-property.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- @@ -56,12 +56,12 @@ module.exports = { const replacementText = node.computed ? "" : "."; context.report({ - node: node, + node, message: "Unexpected whitespace before property {{propName}}.", data: { propName: sourceCode.getText(node.property) }, - fix: function(fixer) { + fix(fixer) { return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText); } }); @@ -72,7 +72,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - MemberExpression: function(node) { + MemberExpression(node) { let rightToken; let leftToken; diff --git a/tools/eslint/lib/rules/no-with.js b/tools/eslint/lib/rules/no-with.js index df7528fdfa8487..6d5bfd8e61605e 100644 --- a/tools/eslint/lib/rules/no-with.js +++ b/tools/eslint/lib/rules/no-with.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - WithStatement: function(node) { + WithStatement(node) { context.report(node, "Unexpected use of 'with' statement."); } }; diff --git a/tools/eslint/lib/rules/object-curly-newline.js b/tools/eslint/lib/rules/object-curly-newline.js index 6b94ad311336fc..3ba786a6f1e2c2 100644 --- a/tools/eslint/lib/rules/object-curly-newline.js +++ b/tools/eslint/lib/rules/object-curly-newline.js @@ -61,7 +61,7 @@ function normalizeOptionValue(value) { multiline = true; } - return {multiline: multiline, minProperties: minProperties}; + return {multiline, minProperties}; } /** @@ -113,7 +113,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const normalizedOptions = normalizeOptions(context.options[0]); @@ -154,9 +154,9 @@ module.exports = { if (astUtils.isTokenOnSameLine(openBrace, first)) { context.report({ message: "Expected a line break after this opening brace.", - node: node, + node, loc: openBrace.loc.start, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(openBrace, "\n"); } }); @@ -164,9 +164,9 @@ module.exports = { if (astUtils.isTokenOnSameLine(last, closeBrace)) { context.report({ message: "Expected a line break before this closing brace.", - node: node, + node, loc: closeBrace.loc.start, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(closeBrace, "\n"); } }); @@ -175,9 +175,9 @@ module.exports = { if (!astUtils.isTokenOnSameLine(openBrace, first)) { context.report({ message: "Unexpected line break after this opening brace.", - node: node, + node, loc: openBrace.loc.start, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([ openBrace.range[1], first.range[0] @@ -188,9 +188,9 @@ module.exports = { if (!astUtils.isTokenOnSameLine(last, closeBrace)) { context.report({ message: "Unexpected line break before this closing brace.", - node: node, + node, loc: closeBrace.loc.start, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([ last.range[1], closeBrace.range[0] diff --git a/tools/eslint/lib/rules/object-curly-spacing.js b/tools/eslint/lib/rules/object-curly-spacing.js index 46c678e6e88ed0..0abf3259182b3f 100644 --- a/tools/eslint/lib/rules/object-curly-spacing.js +++ b/tools/eslint/lib/rules/object-curly-spacing.js @@ -39,7 +39,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const spaced = context.options[0] === "always", sourceCode = context.getSourceCode(); @@ -55,7 +55,7 @@ module.exports = { } const options = { - spaced: spaced, + spaced, arraysInObjectsException: isOptionSet("arraysInObjects"), objectsInObjectsException: isOptionSet("objectsInObjects") }; @@ -72,10 +72,10 @@ module.exports = { */ function reportNoBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "There should be no space after '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { const nextToken = context.getSourceCode().getTokenAfter(token); return fixer.removeRange([token.range[1], nextToken.range[0]]); @@ -91,10 +91,10 @@ module.exports = { */ function reportNoEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "There should be no space before '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { const previousToken = context.getSourceCode().getTokenBefore(token); return fixer.removeRange([previousToken.range[1], token.range[0]]); @@ -110,10 +110,10 @@ module.exports = { */ function reportRequiredBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "A space is required after '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(token, " "); } }); @@ -127,10 +127,10 @@ module.exports = { */ function reportRequiredEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: "A space is required before '" + token.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(token, " "); } }); @@ -180,6 +180,30 @@ module.exports = { } } + /** + * Gets '}' token of an object node. + * + * Because the last token of object patterns might be a type annotation, + * this traverses tokens preceded by the last property, then returns the + * first '}' token. + * + * @param {ASTNode} node - The node to get. This node is an + * ObjectExpression or an ObjectPattern. And this node has one or + * more properties. + * @returns {Token} '}' token. + */ + function getClosingBraceOfObject(node) { + const lastProperty = node.properties[node.properties.length - 1]; + let token = sourceCode.getTokenAfter(lastProperty); + + // skip ')' and trailing commas. + while (token.type !== "Punctuator" || token.value !== "}") { + token = sourceCode.getTokenAfter(token); + } + + return token; + } + /** * Reports a given object node if spacing in curly braces is invalid. * @param {ASTNode} node - An ObjectExpression or ObjectPattern node to check. @@ -191,7 +215,7 @@ module.exports = { } const first = sourceCode.getFirstToken(node), - last = sourceCode.getLastToken(node), + last = getClosingBraceOfObject(node), second = sourceCode.getTokenAfter(first), penultimate = sourceCode.getTokenBefore(last); diff --git a/tools/eslint/lib/rules/object-property-newline.js b/tools/eslint/lib/rules/object-property-newline.js index d159f6f7dbe154..f06cb41843e534 100644 --- a/tools/eslint/lib/rules/object-property-newline.js +++ b/tools/eslint/lib/rules/object-property-newline.js @@ -30,7 +30,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const allowSameLine = context.options[0] && Boolean(context.options[0].allowMultiplePropertiesPerLine); const errorMessage = allowSameLine ? "Object properties must go on a new line if they aren't all on the same line." : @@ -39,7 +39,7 @@ module.exports = { const sourceCode = context.getSourceCode(); return { - ObjectExpression: function(node) { + ObjectExpression(node) { if (allowSameLine) { if (node.properties.length > 1) { const firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]); @@ -59,7 +59,7 @@ module.exports = { if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) { context.report({ - node: node, + node, loc: firstTokenOfCurrentProperty.loc.start, message: errorMessage }); diff --git a/tools/eslint/lib/rules/object-shorthand.js b/tools/eslint/lib/rules/object-shorthand.js index 0e5f6e3f10d52e..eb051c22ab44d4 100644 --- a/tools/eslint/lib/rules/object-shorthand.js +++ b/tools/eslint/lib/rules/object-shorthand.js @@ -84,7 +84,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const APPLY = context.options[0] || OPTIONS.always; const APPLY_TO_METHODS = APPLY === OPTIONS.methods || APPLY === OPTIONS.always; const APPLY_TO_PROPS = APPLY === OPTIONS.properties || APPLY === OPTIONS.always; @@ -201,7 +201,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - ObjectExpression: function(node) { + ObjectExpression(node) { if (APPLY_CONSISTENT) { checkConsistency(node, false); } else if (APPLY_CONSISTENT_AS_NEEDED) { @@ -209,7 +209,7 @@ module.exports = { } }, - Property: function(node) { + Property(node) { const isConciseProperty = node.method || node.shorthand; // Ignore destructuring assignment @@ -236,9 +236,9 @@ module.exports = { const type = node.method ? "method" : "property"; context.report({ - node: node, + node, message: "Expected longform " + type + " syntax.", - fix: function(fixer) { + fix(fixer) { if (node.method) { if (node.value.generator) { return fixer.replaceTextRange([node.range[0], node.key.range[1]], node.key.name + ": function*"); @@ -255,9 +255,9 @@ module.exports = { // {'xyz'() {}} should be written as {'xyz': function() {}} if (AVOID_QUOTES && isStringLiteral(node.key)) { context.report({ - node: node, + node, message: "Expected longform method syntax for string literal keys.", - fix: function(fixer) { + fix(fixer) { if (node.computed) { return fixer.insertTextAfterRange([node.key.range[0], node.key.range[1] + 1], ": function"); } @@ -283,9 +283,9 @@ module.exports = { // {[x]: function(){}} should be written as {[x]() {}} if (node.computed) { context.report({ - node: node, + node, message: "Expected method shorthand.", - fix: function(fixer) { + fix(fixer) { if (node.value.generator) { return fixer.replaceTextRange( [node.key.range[0], node.value.range[0] + "function*".length], @@ -301,9 +301,9 @@ module.exports = { // {x: function(){}} should be written as {x() {}} context.report({ - node: node, + node, message: "Expected method shorthand.", - fix: function(fixer) { + fix(fixer) { if (node.value.generator) { return fixer.replaceTextRange( [node.key.range[0], node.value.range[0] + "function*".length], @@ -318,9 +318,9 @@ module.exports = { // {x: x} should be written as {x} context.report({ - node: node, + node, message: "Expected property shorthand.", - fix: function(fixer) { + fix(fixer) { return fixer.replaceText(node, node.value.name); } }); @@ -331,9 +331,9 @@ module.exports = { // {"x": x} should be written as {x} context.report({ - node: node, + node, message: "Expected property shorthand.", - fix: function(fixer) { + fix(fixer) { return fixer.replaceText(node, node.value.name); } }); diff --git a/tools/eslint/lib/rules/one-var-declaration-per-line.js b/tools/eslint/lib/rules/one-var-declaration-per-line.js index fe47b0333f4e18..cc821d2b90c020 100644 --- a/tools/eslint/lib/rules/one-var-declaration-per-line.js +++ b/tools/eslint/lib/rules/one-var-declaration-per-line.js @@ -23,7 +23,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const ERROR_MESSAGE = "Expected variable declaration to be on a new line."; const always = context.options[0] === "always"; @@ -61,7 +61,7 @@ module.exports = { if (prev && prev.loc.end.line === current.loc.start.line) { if (always || prev.init || current.init) { context.report({ - node: node, + node, message: ERROR_MESSAGE, loc: current.loc.start }); diff --git a/tools/eslint/lib/rules/one-var.js b/tools/eslint/lib/rules/one-var.js index 0291c709737c5c..2be304da397401 100644 --- a/tools/eslint/lib/rules/one-var.js +++ b/tools/eslint/lib/rules/one-var.js @@ -55,7 +55,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const MODE_ALWAYS = "always", MODE_NEVER = "never"; @@ -265,7 +265,7 @@ module.exports = { ForOfStatement: startBlock, SwitchStatement: startBlock, - VariableDeclaration: function(node) { + VariableDeclaration(node) { const parent = node.parent; const type = node.kind; diff --git a/tools/eslint/lib/rules/operator-assignment.js b/tools/eslint/lib/rules/operator-assignment.js index 6056b41d36d0f1..5e1dd97b996bc7 100644 --- a/tools/eslint/lib/rules/operator-assignment.js +++ b/tools/eslint/lib/rules/operator-assignment.js @@ -85,7 +85,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { /** * Ensures that an assignment uses the shorthand form where possible. diff --git a/tools/eslint/lib/rules/operator-linebreak.js b/tools/eslint/lib/rules/operator-linebreak.js index 51c68be5ef8d47..c3fdb589815d0a 100644 --- a/tools/eslint/lib/rules/operator-linebreak.js +++ b/tools/eslint/lib/rules/operator-linebreak.js @@ -41,7 +41,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const usedDefaultGlobal = !context.options[0]; const globalStyle = context.options[0] || "after"; @@ -144,12 +144,12 @@ module.exports = { BinaryExpression: validateBinaryExpression, LogicalExpression: validateBinaryExpression, AssignmentExpression: validateBinaryExpression, - VariableDeclarator: function(node) { + VariableDeclarator(node) { if (node.init) { validateNode(node, node.id); } }, - ConditionalExpression: function(node) { + ConditionalExpression(node) { validateNode(node, node.test); validateNode(node, node.consequent); } diff --git a/tools/eslint/lib/rules/padded-blocks.js b/tools/eslint/lib/rules/padded-blocks.js index b79a25c29089e2..a24d421b0f4f23 100644 --- a/tools/eslint/lib/rules/padded-blocks.js +++ b/tools/eslint/lib/rules/padded-blocks.js @@ -46,7 +46,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = {}; const config = context.options[0] || "always"; @@ -162,9 +162,9 @@ module.exports = { if (requirePaddingFor(node)) { if (!blockHasTopPadding) { context.report({ - node: node, + node, loc: { line: openBrace.loc.start.line, column: openBrace.loc.start.column }, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(openBrace, "\n"); }, message: ALWAYS_MESSAGE @@ -172,9 +172,9 @@ module.exports = { } if (!blockHasBottomPadding) { context.report({ - node: node, + node, loc: {line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 }, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(closeBrace, "\n"); }, message: ALWAYS_MESSAGE @@ -185,9 +185,9 @@ module.exports = { const nextToken = sourceCode.getTokenOrCommentAfter(openBrace); context.report({ - node: node, + node, loc: { line: openBrace.loc.start.line, column: openBrace.loc.start.column }, - fix: function(fixer) { + fix(fixer) { return fixer.replaceTextRange([openBrace.end, nextToken.start - nextToken.loc.start.column], "\n"); }, message: NEVER_MESSAGE @@ -198,10 +198,10 @@ module.exports = { const previousToken = sourceCode.getTokenOrCommentBefore(closeBrace); context.report({ - node: node, + node, loc: {line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 }, message: NEVER_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.replaceTextRange([previousToken.end, closeBrace.start - closeBrace.loc.start.column], "\n"); } }); diff --git a/tools/eslint/lib/rules/prefer-arrow-callback.js b/tools/eslint/lib/rules/prefer-arrow-callback.js index 97aab40b2e339f..e4da8e1e97eb5d 100644 --- a/tools/eslint/lib/rules/prefer-arrow-callback.js +++ b/tools/eslint/lib/rules/prefer-arrow-callback.js @@ -143,7 +143,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const allowUnboundThis = options.allowUnboundThis !== false; // default to true @@ -176,12 +176,12 @@ module.exports = { return { // Reset internal state. - Program: function() { + Program() { stack = []; }, // If there are below, it cannot replace with arrow functions merely. - ThisExpression: function() { + ThisExpression() { const info = stack[stack.length - 1]; if (info) { @@ -189,7 +189,7 @@ module.exports = { } }, - Super: function() { + Super() { const info = stack[stack.length - 1]; if (info) { @@ -197,7 +197,7 @@ module.exports = { } }, - MetaProperty: function(node) { + MetaProperty(node) { const info = stack[stack.length - 1]; if (info && checkMetaProperty(node, "new", "target")) { @@ -211,7 +211,7 @@ module.exports = { // Main. FunctionExpression: enterScope, - "FunctionExpression:exit": function(node) { + "FunctionExpression:exit"(node) { const scopeInfo = exitScope(); // Skip named function expressions diff --git a/tools/eslint/lib/rules/prefer-const.js b/tools/eslint/lib/rules/prefer-const.js index 76931bfc1d1714..5255f2745c9384 100644 --- a/tools/eslint/lib/rules/prefer-const.js +++ b/tools/eslint/lib/rules/prefer-const.js @@ -70,9 +70,14 @@ function canBecomeVariableDeclaration(identifier) { * * If the variable should not change to const, this function returns null. * - If the variable is reassigned. - * - If the variable is never initialized and assigned. + * - If the variable is never initialized nor assigned. * - If the variable is initialized in a different scope from the declaration. * - If the unique assignment of the variable cannot change to a declaration. + * e.g. `if (a) b = 1` / `return (b = 1)` + * - If the variable is declared in the global scope and `eslintUsed` is `true`. + * `/*exported foo` directive comment makes such variables. This rule does not + * warn such variables because this rule cannot distinguish whether the + * exported variables are reassigned or not. * * @param {escope.Variable} variable - A variable to get. * @param {boolean} ignoreReadBeforeAssign - @@ -82,7 +87,7 @@ function canBecomeVariableDeclaration(identifier) { * Otherwise, null. */ function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) { - if (variable.eslintUsed) { + if (variable.eslintUsed && variable.scope.type === "global") { return null; } @@ -247,7 +252,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}; const checkingMixedDestructuring = options.destructuring !== "all"; const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true; @@ -261,7 +266,7 @@ module.exports = { */ function report(node) { const reportArgs = { - node: node, + node, message: "'{{name}}' is never reassigned. Use 'const' instead.", data: node }, @@ -345,11 +350,11 @@ module.exports = { } return { - Program: function() { + Program() { variables = []; }, - "Program:exit": function() { + "Program:exit"() { if (checkingMixedDestructuring) { variables.forEach(checkVariable); } else { @@ -360,7 +365,7 @@ module.exports = { variables = null; }, - VariableDeclaration: function(node) { + VariableDeclaration(node) { if (node.kind === "let" && !isInitOfForStatement(node)) { pushAll(variables, context.getDeclaredVariables(node)); } diff --git a/tools/eslint/lib/rules/prefer-reflect.js b/tools/eslint/lib/rules/prefer-reflect.js index 103574428b3cea..64db836d04dd89 100644 --- a/tools/eslint/lib/rules/prefer-reflect.js +++ b/tools/eslint/lib/rules/prefer-reflect.js @@ -44,7 +44,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const existingNames = { apply: "Function.prototype.apply", call: "Function.prototype.call", @@ -80,13 +80,13 @@ module.exports = { */ function report(node, existing, substitute) { context.report(node, "Avoid using {{existing}}, instead use {{substitute}}.", { - existing: existing, - substitute: substitute + existing, + substitute }); } return { - CallExpression: function(node) { + CallExpression(node) { const methodName = (node.callee.property || {}).name; const isReflectCall = (node.callee.object || {}).name === "Reflect"; const hasReflectSubsitute = reflectSubsitutes.hasOwnProperty(methodName); @@ -96,7 +96,7 @@ module.exports = { report(node, existingNames[methodName], reflectSubsitutes[methodName]); } }, - UnaryExpression: function(node) { + UnaryExpression(node) { const isDeleteOperator = node.operator === "delete"; const targetsIdentifier = node.argument.type === "Identifier"; const userConfiguredException = exceptions.indexOf("delete") !== -1; diff --git a/tools/eslint/lib/rules/prefer-rest-params.js b/tools/eslint/lib/rules/prefer-rest-params.js index 7d60b16f622b03..a9db624dcb64aa 100644 --- a/tools/eslint/lib/rules/prefer-rest-params.js +++ b/tools/eslint/lib/rules/prefer-rest-params.js @@ -69,7 +69,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { /** * Reports a given reference. diff --git a/tools/eslint/lib/rules/prefer-spread.js b/tools/eslint/lib/rules/prefer-spread.js index 2ad0dad4dff995..59fe7754a3ca7b 100644 --- a/tools/eslint/lib/rules/prefer-spread.js +++ b/tools/eslint/lib/rules/prefer-spread.js @@ -81,11 +81,11 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - CallExpression: function(node) { + CallExpression(node) { if (!isVariadicApplyCalling(node)) { return; } diff --git a/tools/eslint/lib/rules/prefer-template.js b/tools/eslint/lib/rules/prefer-template.js index fa623b56eeeaa1..48e598752db746 100644 --- a/tools/eslint/lib/rules/prefer-template.js +++ b/tools/eslint/lib/rules/prefer-template.js @@ -65,7 +65,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { let done = Object.create(null); /** @@ -95,7 +95,7 @@ module.exports = { } return { - Program: function() { + Program() { done = Object.create(null); }, diff --git a/tools/eslint/lib/rules/quote-props.js b/tools/eslint/lib/rules/quote-props.js index 26c527402d3213..fc93b00aa7ae6e 100644 --- a/tools/eslint/lib/rules/quote-props.js +++ b/tools/eslint/lib/rules/quote-props.js @@ -64,7 +64,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const MODE = context.options[0], KEYWORDS = context.options[1] && context.options[1].keywords, @@ -208,7 +208,7 @@ module.exports = { } return { - Property: function(node) { + Property(node) { if (MODE === "always" || !MODE) { checkOmittedQuotes(node); } @@ -216,7 +216,7 @@ module.exports = { checkUnnecessaryQuotes(node); } }, - ObjectExpression: function(node) { + ObjectExpression(node) { if (MODE === "consistent") { checkConsistency(node, false); } diff --git a/tools/eslint/lib/rules/quotes.js b/tools/eslint/lib/rules/quotes.js index a6fa7518ffc807..c72565c257bead 100644 --- a/tools/eslint/lib/rules/quotes.js +++ b/tools/eslint/lib/rules/quotes.js @@ -107,7 +107,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const quoteOption = context.options[0], settings = QUOTE_SETTINGS[quoteOption || "double"], @@ -208,7 +208,7 @@ module.exports = { return { - Literal: function(node) { + Literal(node) { const val = node.value, rawVal = node.raw; let isValid; @@ -224,9 +224,9 @@ module.exports = { if (!isValid) { context.report({ - node: node, + node, message: "Strings must use " + settings.description + ".", - fix: function(fixer) { + fix(fixer) { return fixer.replaceText(node, settings.convert(node.raw)); } }); @@ -234,7 +234,7 @@ module.exports = { } }, - TemplateLiteral: function(node) { + TemplateLiteral(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") { @@ -245,9 +245,9 @@ module.exports = { if (shouldWarn) { context.report({ - node: node, + node, message: "Strings must use " + settings.description + ".", - fix: function(fixer) { + fix(fixer) { return fixer.replaceText(node, settings.convert(sourceCode.getText(node))); } }); diff --git a/tools/eslint/lib/rules/radix.js b/tools/eslint/lib/rules/radix.js index aab917ac212586..f36e27d3634b9e 100644 --- a/tools/eslint/lib/rules/radix.js +++ b/tools/eslint/lib/rules/radix.js @@ -91,7 +91,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const mode = context.options[0] || MODE_ALWAYS; /** @@ -107,7 +107,7 @@ module.exports = { switch (args.length) { case 0: context.report({ - node: node, + node, message: "Missing parameters." }); break; @@ -115,7 +115,7 @@ module.exports = { case 1: if (mode === MODE_ALWAYS) { context.report({ - node: node, + node, message: "Missing radix parameter." }); } @@ -124,12 +124,12 @@ module.exports = { default: if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) { context.report({ - node: node, + node, message: "Redundant radix parameter." }); } else if (!isValidRadix(args[1])) { context.report({ - node: node, + node, message: "Invalid radix parameter." }); } @@ -138,7 +138,7 @@ module.exports = { } return { - "Program:exit": function() { + "Program:exit"() { const scope = context.getScope(); let variable; diff --git a/tools/eslint/lib/rules/require-jsdoc.js b/tools/eslint/lib/rules/require-jsdoc.js index d271f839b3ed1a..9300fce1baa42b 100644 --- a/tools/eslint/lib/rules/require-jsdoc.js +++ b/tools/eslint/lib/rules/require-jsdoc.js @@ -37,7 +37,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const source = context.getSourceCode(); const DEFAULT_OPTIONS = { FunctionDeclaration: true, @@ -84,17 +84,17 @@ module.exports = { } return { - FunctionDeclaration: function(node) { + FunctionDeclaration(node) { if (options.FunctionDeclaration) { checkJsDoc(node); } }, - FunctionExpression: function(node) { + FunctionExpression(node) { if (options.MethodDefinition) { checkClassMethodJsDoc(node); } }, - ClassDeclaration: function(node) { + ClassDeclaration(node) { if (options.ClassDeclaration) { checkJsDoc(node); } diff --git a/tools/eslint/lib/rules/require-yield.js b/tools/eslint/lib/rules/require-yield.js index e9d8281f69620e..36b4ea11a585aa 100644 --- a/tools/eslint/lib/rules/require-yield.js +++ b/tools/eslint/lib/rules/require-yield.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const stack = []; /** @@ -61,7 +61,7 @@ module.exports = { "FunctionExpression:exit": endChecking, // Increases the count of `yield` keyword. - YieldExpression: function() { + YieldExpression() { /* istanbul ignore else */ if (stack.length > 0) { diff --git a/tools/eslint/lib/rules/rest-spread-spacing.js b/tools/eslint/lib/rules/rest-spread-spacing.js index c74c1284095952..91770eca74e4d3 100644 --- a/tools/eslint/lib/rules/rest-spread-spacing.js +++ b/tools/eslint/lib/rules/rest-spread-spacing.js @@ -24,7 +24,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(), alwaysSpace = context.options[0] === "always"; @@ -62,31 +62,31 @@ module.exports = { if (alwaysSpace && !hasWhitespace) { context.report({ - node: node, + node, loc: { line: operator.loc.end.line, column: operator.loc.end.column }, message: "Expected whitespace after {{type}} operator.", data: { - type: type + type }, - fix: function(fixer) { + fix(fixer) { return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " "); } }); } else if (!alwaysSpace && hasWhitespace) { context.report({ - node: node, + node, loc: { line: operator.loc.end.line, column: operator.loc.end.column }, message: "Unexpected whitespace after {{type}} operator.", data: { - type: type + type }, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([operator.range[1], nextToken.range[0]]); } }); diff --git a/tools/eslint/lib/rules/semi-spacing.js b/tools/eslint/lib/rules/semi-spacing.js index b7cffbf3355e8f..4fe95fbf20cebd 100644 --- a/tools/eslint/lib/rules/semi-spacing.js +++ b/tools/eslint/lib/rules/semi-spacing.js @@ -37,7 +37,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0], sourceCode = context.getSourceCode(); @@ -134,10 +134,10 @@ module.exports = { if (hasLeadingSpace(token)) { if (!requireSpaceBefore) { context.report({ - node: node, + node, loc: location, message: "Unexpected whitespace before semicolon.", - fix: function(fixer) { + fix(fixer) { const tokenBefore = sourceCode.getTokenBefore(token); return fixer.removeRange([tokenBefore.range[1], token.range[0]]); @@ -147,10 +147,10 @@ module.exports = { } else { if (requireSpaceBefore) { context.report({ - node: node, + node, loc: location, message: "Missing whitespace before semicolon.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(token, " "); } }); @@ -161,10 +161,10 @@ module.exports = { if (hasTrailingSpace(token)) { if (!requireSpaceAfter) { context.report({ - node: node, + node, loc: location, message: "Unexpected whitespace after semicolon.", - fix: function(fixer) { + fix(fixer) { const tokenAfter = sourceCode.getTokenAfter(token); return fixer.removeRange([token.range[1], tokenAfter.range[0]]); @@ -174,10 +174,10 @@ module.exports = { } else { if (requireSpaceAfter) { context.report({ - node: node, + node, loc: location, message: "Missing whitespace after semicolon.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(token, " "); } }); @@ -206,7 +206,7 @@ module.exports = { DebuggerStatement: checkNode, ReturnStatement: checkNode, ThrowStatement: checkNode, - ForStatement: function(node) { + ForStatement(node) { if (node.init) { checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node); } diff --git a/tools/eslint/lib/rules/semi.js b/tools/eslint/lib/rules/semi.js index d495360a7294f9..7fc80ab8dabfd6 100644 --- a/tools/eslint/lib/rules/semi.js +++ b/tools/eslint/lib/rules/semi.js @@ -51,7 +51,7 @@ module.exports = { } }, - create: function(context) { + create(context) { const OPT_OUT_PATTERN = /[\[\(\/\+\-]/; // One of [(/+- const options = context.options[1]; @@ -90,10 +90,10 @@ module.exports = { } context.report({ - node: node, - loc: loc, - message: message, - fix: fix + node, + loc, + message, + fix }); } @@ -208,12 +208,12 @@ module.exports = { ContinueStatement: checkForSemicolon, ImportDeclaration: checkForSemicolon, ExportAllDeclaration: checkForSemicolon, - ExportNamedDeclaration: function(node) { + ExportNamedDeclaration(node) { if (!node.declaration) { checkForSemicolon(node); } }, - ExportDefaultDeclaration: function(node) { + ExportDefaultDeclaration(node) { if (!/(?:Class|Function)Declaration/.test(node.declaration.type)) { checkForSemicolon(node); } diff --git a/tools/eslint/lib/rules/sort-imports.js b/tools/eslint/lib/rules/sort-imports.js index 9a546fbfe445dc..ae3333c2ac16d7 100644 --- a/tools/eslint/lib/rules/sort-imports.js +++ b/tools/eslint/lib/rules/sort-imports.js @@ -42,7 +42,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const configuration = context.options[0] || {}, ignoreCase = configuration.ignoreCase || false, @@ -96,7 +96,7 @@ module.exports = { } return { - ImportDeclaration: function(node) { + ImportDeclaration(node) { if (previousDeclaration) { const currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node), previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration); @@ -114,7 +114,7 @@ module.exports = { if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) { if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) { context.report({ - node: node, + node, message: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.", data: { syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex], @@ -128,7 +128,7 @@ module.exports = { currentLocalMemberName < previousLocalMemberName ) { context.report({ - node: node, + node, message: "Imports should be sorted alphabetically." }); } diff --git a/tools/eslint/lib/rules/sort-keys.js b/tools/eslint/lib/rules/sort-keys.js index 1c8a97b1d0b7f0..b3aeb81d8e0ee0 100644 --- a/tools/eslint/lib/rules/sort-keys.js +++ b/tools/eslint/lib/rules/sort-keys.js @@ -97,7 +97,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // Parse options. const order = context.options[0] || "asc"; @@ -124,6 +124,10 @@ module.exports = { }, Property(node) { + if (node.parent.type === "ObjectPattern") { + return; + } + const prevName = stack.prevName; const thisName = getPropertyName(node); @@ -135,7 +139,7 @@ module.exports = { if (!isValidOrder(prevName, thisName)) { context.report({ - node: node, + node, loc: node.key.loc, message: "Expected object keys to be in {{natual}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'.", data: { diff --git a/tools/eslint/lib/rules/sort-vars.js b/tools/eslint/lib/rules/sort-vars.js index 02711b53ed7c86..1e1cf3c959e663 100644 --- a/tools/eslint/lib/rules/sort-vars.js +++ b/tools/eslint/lib/rules/sort-vars.js @@ -30,13 +30,13 @@ module.exports = { ] }, - create: function(context) { + create(context) { const configuration = context.options[0] || {}, ignoreCase = configuration.ignoreCase || false; return { - VariableDeclaration: function(node) { + VariableDeclaration(node) { node.declarations.reduce(function(memo, decl) { if (decl.id.type === "ObjectPattern" || decl.id.type === "ArrayPattern") { return memo; diff --git a/tools/eslint/lib/rules/space-before-blocks.js b/tools/eslint/lib/rules/space-before-blocks.js index b3dac2ff74bfa2..a70136b1f59bef 100644 --- a/tools/eslint/lib/rules/space-before-blocks.js +++ b/tools/eslint/lib/rules/space-before-blocks.js @@ -47,7 +47,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const config = context.options[0], sourceCode = context.getSourceCode(); let checkFunctions = true, @@ -99,9 +99,9 @@ module.exports = { if (requireSpace) { if (!hasSpace) { context.report({ - node: node, + node, message: "Missing space before opening brace.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(node, " "); } }); @@ -109,9 +109,9 @@ module.exports = { } else { if (hasSpace) { context.report({ - node: node, + node, message: "Unexpected space before opening brace.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([precedingToken.range[1], node.range[0]]); } }); diff --git a/tools/eslint/lib/rules/space-before-function-paren.js b/tools/eslint/lib/rules/space-before-function-paren.js index 7d7183adb89283..04c169a78624cc 100644 --- a/tools/eslint/lib/rules/space-before-function-paren.js +++ b/tools/eslint/lib/rules/space-before-function-paren.js @@ -41,7 +41,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const configuration = context.options[0], sourceCode = context.getSourceCode(); @@ -109,10 +109,10 @@ module.exports = { if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken)) { if ((isNamed && forbidNamedFunctionSpacing) || (!isNamed && forbidAnonymousFunctionSpacing)) { context.report({ - node: node, + node, loc: location, message: "Unexpected space before function parentheses.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); } }); @@ -120,10 +120,10 @@ module.exports = { } else { if ((isNamed && requireNamedFunctionSpacing) || (!isNamed && requireAnonymousFunctionSpacing)) { context.report({ - node: node, + node, loc: location, message: "Missing space before function parentheses.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(leftToken, " "); } }); diff --git a/tools/eslint/lib/rules/space-in-parens.js b/tools/eslint/lib/rules/space-in-parens.js index 7c913d673d8628..c01170b2bc13b4 100644 --- a/tools/eslint/lib/rules/space-in-parens.js +++ b/tools/eslint/lib/rules/space-in-parens.js @@ -40,7 +40,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const MISSING_SPACE_MESSAGE = "There must be a space inside this paren.", REJECTED_SPACE_MESSAGE = "There should be no spaces inside this paren.", @@ -88,8 +88,8 @@ module.exports = { } return { - openers: openers, - closers: closers + openers, + closers }; } @@ -234,19 +234,19 @@ module.exports = { if (token.value === "(" && shouldOpenerHaveSpace(token, nextToken)) { context.report({ - node: node, + node, loc: token.loc.start, message: MISSING_SPACE_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(token, " "); } }); } else if (token.value === "(" && shouldOpenerRejectSpace(token, nextToken)) { context.report({ - node: node, + node, loc: token.loc.start, message: REJECTED_SPACE_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([token.range[1], nextToken.range[0]]); } }); @@ -254,19 +254,19 @@ module.exports = { // context.report(node, token.loc.start, MISSING_SPACE_MESSAGE); context.report({ - node: node, + node, loc: token.loc.start, message: MISSING_SPACE_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(token, " "); } }); } else if (token.value === ")" && shouldCloserRejectSpace(prevToken, token)) { context.report({ - node: node, + node, loc: token.loc.start, message: REJECTED_SPACE_MESSAGE, - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([prevToken.range[1], token.range[0]]); } }); diff --git a/tools/eslint/lib/rules/space-infix-ops.js b/tools/eslint/lib/rules/space-infix-ops.js index 88c12b439d7acb..c99c32880682ef 100644 --- a/tools/eslint/lib/rules/space-infix-ops.js +++ b/tools/eslint/lib/rules/space-infix-ops.js @@ -31,7 +31,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false; const OPERATORS = [ @@ -79,7 +79,7 @@ module.exports = { node: mainNode, loc: culpritToken.loc.start, message: "Infix operators must be spaced.", - fix: function(fixer) { + fix(fixer) { const previousToken = sourceCode.getTokenBefore(culpritToken); const afterToken = sourceCode.getTokenAfter(culpritToken); let fixString = ""; diff --git a/tools/eslint/lib/rules/space-unary-ops.js b/tools/eslint/lib/rules/space-unary-ops.js index c5d66e65af919b..f300f660b96d33 100644 --- a/tools/eslint/lib/rules/space-unary-ops.js +++ b/tools/eslint/lib/rules/space-unary-ops.js @@ -40,7 +40,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options && Array.isArray(context.options) && context.options[0] || { words: true, nonwords: false }; const sourceCode = context.getSourceCode(); @@ -99,9 +99,9 @@ module.exports = { function verifyWordHasSpaces(node, firstToken, secondToken, word) { if (secondToken.range[0] === firstToken.range[1]) { context.report({ - node: node, + node, message: "Unary word operator '" + word + "' must be followed by whitespace.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(firstToken, " "); } }); @@ -120,9 +120,9 @@ module.exports = { if (isArgumentObjectExpression(node)) { if (secondToken.range[0] > firstToken.range[1]) { context.report({ - node: node, + node, message: "Unexpected space after unary word operator '" + word + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); } }); @@ -184,9 +184,9 @@ module.exports = { } if (firstToken.range[1] === secondToken.range[0]) { context.report({ - node: node, + node, message: "Unary operator '" + firstToken.value + "' must be followed by whitespace.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextAfter(firstToken, " "); } }); @@ -194,9 +194,9 @@ module.exports = { } else { if (firstToken.range[1] === secondToken.range[0]) { context.report({ - node: node, + node, message: "Space is required before unary expressions '" + secondToken.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(secondToken, " "); } }); @@ -215,9 +215,9 @@ module.exports = { if (node.prefix) { if (secondToken.range[0] > firstToken.range[1]) { context.report({ - node: node, + node, message: "Unexpected space after unary operator '" + firstToken.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); } }); @@ -225,9 +225,9 @@ module.exports = { } else { if (secondToken.range[0] > firstToken.range[1]) { context.report({ - node: node, + node, message: "Unexpected space before unary operator '" + secondToken.value + "'.", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); } }); diff --git a/tools/eslint/lib/rules/spaced-comment.js b/tools/eslint/lib/rules/spaced-comment.js index 666604df15e6d4..3514e7ba2281f1 100644 --- a/tools/eslint/lib/rules/spaced-comment.js +++ b/tools/eslint/lib/rules/spaced-comment.js @@ -227,7 +227,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // Unless the first option is never, require a space const requireSpace = context.options[0] !== "never"; @@ -268,8 +268,8 @@ module.exports = { commentIdentifier = type === "block" ? "/*" : "//"; context.report({ - node: node, - fix: function(fixer) { + node, + fix(fixer) { const start = node.range[0]; let end = start + 2; @@ -283,7 +283,7 @@ module.exports = { return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : "")); } }, - message: message + message }); } @@ -296,8 +296,8 @@ module.exports = { */ function reportEnd(node, message, match) { context.report({ - node: node, - fix: function(fixer) { + node, + fix(fixer) { if (requireSpace) { return fixer.insertTextAfterRange([node.start, node.end - 2], " "); } else { @@ -307,7 +307,7 @@ module.exports = { return fixer.replaceTextRange([start, end], ""); } }, - message: message + message }); } diff --git a/tools/eslint/lib/rules/strict.js b/tools/eslint/lib/rules/strict.js index 8c9ff05ce6decb..6581ac1bfd07d9 100644 --- a/tools/eslint/lib/rules/strict.js +++ b/tools/eslint/lib/rules/strict.js @@ -91,7 +91,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const ecmaFeatures = context.parserOptions.ecmaFeatures || {}, scopes = [], @@ -207,7 +207,7 @@ module.exports = { } const rule = { - Program: function(node) { + Program(node) { const useStrictDirectives = getUseStrictDirectives(node.body); if (node.sourceType === "module") { @@ -232,10 +232,10 @@ module.exports = { Object.assign(rule, { // Inside of class bodies are always strict mode. - ClassBody: function() { + ClassBody() { classScopes.push(true); }, - "ClassBody:exit": function() { + "ClassBody:exit"() { classScopes.pop(); }, diff --git a/tools/eslint/lib/rules/symbol-description.js b/tools/eslint/lib/rules/symbol-description.js new file mode 100644 index 00000000000000..37ac8be7276656 --- /dev/null +++ b/tools/eslint/lib/rules/symbol-description.js @@ -0,0 +1,66 @@ +/** + * @fileoverview Rule to enforce description with the `Symbol` object + * @author Jarek Rencz + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("../ast-utils"); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + + +module.exports = { + meta: { + docs: { + description: "require symbol descriptions", + category: "ECMAScript 6", + recommended: false + }, + + schema: [] + }, + + create(context) { + + /** + * Reports if node does not conform the rule in case rule is set to + * report missing description + * + * @param {ASTNode} node - A CallExpression node to check. + * @returns {void} + */ + function checkArgument(node) { + if (node.arguments.length === 0) { + context.report({ + node, + message: "Expected Symbol to have a description." + }); + } + } + + return { + "Program:exit"() { + const scope = context.getScope(); + const variable = astUtils.getVariableByName(scope, "Symbol"); + + if (variable && variable.defs.length === 0) { + variable.references.forEach(function(reference) { + const node = reference.identifier; + + if (astUtils.isCallee(node)) { + checkArgument(node.parent); + } + }); + } + } + }; + + } +}; diff --git a/tools/eslint/lib/rules/template-curly-spacing.js b/tools/eslint/lib/rules/template-curly-spacing.js index fb918ea4dbdd2f..7c03488b28a688 100644 --- a/tools/eslint/lib/rules/template-curly-spacing.js +++ b/tools/eslint/lib/rules/template-curly-spacing.js @@ -37,7 +37,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const always = context.options[0] === "always"; const prefix = always ? "Expected" : "Unexpected"; @@ -58,7 +58,7 @@ module.exports = { context.report({ loc: token.loc.start, message: prefix + " space(s) before '}'.", - fix: function(fixer) { + fix(fixer) { if (always) { return fixer.insertTextBefore(token, " "); } @@ -90,7 +90,7 @@ module.exports = { column: token.loc.end.column - 2 }, message: prefix + " space(s) after '${'.", - fix: function(fixer) { + fix(fixer) { if (always) { return fixer.insertTextAfter(token, " "); } @@ -104,7 +104,7 @@ module.exports = { } return { - TemplateElement: function(node) { + TemplateElement(node) { const token = sourceCode.getFirstToken(node); checkSpacingBefore(token); diff --git a/tools/eslint/lib/rules/unicode-bom.js b/tools/eslint/lib/rules/unicode-bom.js index d7f38a2dcbc13a..82692894d4a852 100644 --- a/tools/eslint/lib/rules/unicode-bom.js +++ b/tools/eslint/lib/rules/unicode-bom.js @@ -25,7 +25,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { //-------------------------------------------------------------------------- // Public @@ -41,19 +41,19 @@ module.exports = { if (!sourceCode.hasBOM && (requireBOM === "always")) { context.report({ - node: node, + node, loc: location, message: "Expected Unicode BOM (Byte Order Mark).", - fix: function(fixer) { + fix(fixer) { return fixer.insertTextBefore(node, "\uFEFF"); } }); } else if (sourceCode.hasBOM && (requireBOM === "never")) { context.report({ - node: node, + node, loc: location, message: "Unexpected Unicode BOM (Byte Order Mark).", - fix: function(fixer) { + fix(fixer) { return fixer.removeRange([-1, 0]); } }); diff --git a/tools/eslint/lib/rules/use-isnan.js b/tools/eslint/lib/rules/use-isnan.js index 10f7b71c8bd42b..b4a978b5efe21b 100644 --- a/tools/eslint/lib/rules/use-isnan.js +++ b/tools/eslint/lib/rules/use-isnan.js @@ -20,10 +20,10 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { return { - BinaryExpression: function(node) { + BinaryExpression(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/tools/eslint/lib/rules/valid-jsdoc.js b/tools/eslint/lib/rules/valid-jsdoc.js index d9575fa7ef8228..f43b894a170814 100644 --- a/tools/eslint/lib/rules/valid-jsdoc.js +++ b/tools/eslint/lib/rules/valid-jsdoc.js @@ -59,7 +59,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const options = context.options[0] || {}, prefer = options.prefer || {}, @@ -159,8 +159,8 @@ module.exports = { const expectedType = currentType && preferType[currentType]; return { - currentType: currentType, - expectedType: expectedType + currentType, + expectedType }; } @@ -349,12 +349,12 @@ module.exports = { if (param.type === "Identifier") { if (jsdocParams[i] && (name !== jsdocParams[i])) { context.report(jsdocNode, "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.", { - name: name, + name, jsdocName: jsdocParams[i] }); } else if (!params[name] && !isOverride) { context.report(jsdocNode, "Missing JSDoc for parameter '{{name}}'.", { - name: name + name }); } } diff --git a/tools/eslint/lib/rules/valid-typeof.js b/tools/eslint/lib/rules/valid-typeof.js index 532088b9701aa8..b13e2aefdd08c1 100644 --- a/tools/eslint/lib/rules/valid-typeof.js +++ b/tools/eslint/lib/rules/valid-typeof.js @@ -16,10 +16,20 @@ module.exports = { recommended: true }, - schema: [] + schema: [ + { + type: "object", + properties: { + requireStringLiterals: { + type: "boolean" + } + }, + additionalProperties: false + } + ] }, - create: function(context) { + create(context) { const VALID_TYPES = ["symbol", "undefined", "object", "boolean", "number", "string", "function"], OPERATORS = ["==", "===", "!=", "!=="]; @@ -30,15 +40,19 @@ module.exports = { return { - UnaryExpression: function(node) { + UnaryExpression(node) { if (node.operator === "typeof") { const parent = context.getAncestors().pop(); if (parent.type === "BinaryExpression" && OPERATORS.indexOf(parent.operator) !== -1) { const sibling = parent.left === node ? parent.right : parent.left; - if (sibling.type === "Literal" && VALID_TYPES.indexOf(sibling.value) === -1) { - context.report(sibling, "Invalid typeof comparison value."); + if (sibling.type === "Literal") { + if (VALID_TYPES.indexOf(sibling.value) === -1) { + context.report(sibling, "Invalid typeof comparison value."); + } + } else if (context.options[0] && context.options[0].requireStringLiterals) { + context.report(sibling, "Typeof comparisons should be to string literals."); } } } diff --git a/tools/eslint/lib/rules/vars-on-top.js b/tools/eslint/lib/rules/vars-on-top.js index 43703f144f6988..92ed08e2d4b5de 100644 --- a/tools/eslint/lib/rules/vars-on-top.js +++ b/tools/eslint/lib/rules/vars-on-top.js @@ -20,7 +20,7 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const errorMessage = "All 'var' declarations must be at the top of the function scope."; //-------------------------------------------------------------------------- @@ -124,7 +124,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - VariableDeclaration: function(node) { + VariableDeclaration(node) { const ancestors = context.getAncestors(); let parent = ancestors.pop(); let grandParent = ancestors.pop(); diff --git a/tools/eslint/lib/rules/wrap-iife.js b/tools/eslint/lib/rules/wrap-iife.js index 66275a2e718279..c648af82d2e208 100644 --- a/tools/eslint/lib/rules/wrap-iife.js +++ b/tools/eslint/lib/rules/wrap-iife.js @@ -24,7 +24,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const style = context.options[0] || "outside"; @@ -46,7 +46,7 @@ module.exports = { return { - CallExpression: function(node) { + CallExpression(node) { if (node.callee.type === "FunctionExpression") { const callExpressionWrapped = wrapped(node), functionExpressionWrapped = wrapped(node.callee); diff --git a/tools/eslint/lib/rules/wrap-regex.js b/tools/eslint/lib/rules/wrap-regex.js index a309d9ae1d02e2..71cfa06a75635e 100644 --- a/tools/eslint/lib/rules/wrap-regex.js +++ b/tools/eslint/lib/rules/wrap-regex.js @@ -20,12 +20,12 @@ module.exports = { schema: [] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); return { - Literal: function(node) { + Literal(node) { const token = sourceCode.getFirstToken(node), nodeType = token.type; diff --git a/tools/eslint/lib/rules/yield-star-spacing.js b/tools/eslint/lib/rules/yield-star-spacing.js index 6566fc7d4d5a92..eafe23bab7f88c 100644 --- a/tools/eslint/lib/rules/yield-star-spacing.js +++ b/tools/eslint/lib/rules/yield-star-spacing.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { const sourceCode = context.getSourceCode(); const mode = (function(option) { @@ -71,9 +71,9 @@ module.exports = { const message = type + " space " + side + " *."; context.report({ - node: node, - message: message, - fix: function(fixer) { + node, + message, + fix(fixer) { if (spaceRequired) { if (after) { return fixer.insertTextAfter(node, " "); diff --git a/tools/eslint/lib/rules/yoda.js b/tools/eslint/lib/rules/yoda.js index cb8cee5e6462d5..91df72514efbbc 100644 --- a/tools/eslint/lib/rules/yoda.js +++ b/tools/eslint/lib/rules/yoda.js @@ -144,7 +144,7 @@ module.exports = { ] }, - create: function(context) { + create(context) { // Default to "never" (!always) if no option const always = (context.options[0] === "always"); diff --git a/tools/eslint/lib/testers/event-generator-tester.js b/tools/eslint/lib/testers/event-generator-tester.js index e4179bfb86a012..d85238e9db0471 100644 --- a/tools/eslint/lib/testers/event-generator-tester.js +++ b/tools/eslint/lib/testers/event-generator-tester.js @@ -43,7 +43,7 @@ module.exports = { * @param {Object} instance - An object to check. * @returns {void} */ - testEventGeneratorInterface: function(instance) { + testEventGeneratorInterface(instance) { this.describe("should implement EventGenerator interface", function() { this.it("should have `emitter` property.", function() { assert.equal(typeof instance.emitter, "object"); diff --git a/tools/eslint/lib/testers/rule-tester.js b/tools/eslint/lib/testers/rule-tester.js index ebf4beff79faf3..04e64cf662248e 100644 --- a/tools/eslint/lib/testers/rule-tester.js +++ b/tools/eslint/lib/testers/rule-tester.js @@ -198,7 +198,7 @@ RuleTester.prototype = { * @param {Function} rule The rule definition. * @returns {void} */ - defineRule: function(name, rule) { + defineRule(name, rule) { eslint.defineRule(name, rule); }, @@ -209,7 +209,7 @@ RuleTester.prototype = { * @param {Object} test The collection of tests to run. * @returns {void} */ - run: function(ruleName, rule, test) { + run(ruleName, rule, test) { const testerConfig = this.testerConfig, result = {}; @@ -308,7 +308,7 @@ RuleTester.prototype = { } else { return { meta: rule.meta, - create: function(context) { + create(context) { Object.freeze(context); freezeDeeply(context.options); freezeDeeply(context.settings); @@ -322,8 +322,8 @@ RuleTester.prototype = { return { messages: eslint.verify(code, config, filename, true), - beforeAST: beforeAST, - afterAST: afterAST + beforeAST, + afterAST }; } finally { rules.get = originalGet; diff --git a/tools/eslint/lib/timing.js b/tools/eslint/lib/timing.js index 19fbefb3670fe8..b9394af47cee69 100644 --- a/tools/eslint/lib/timing.js +++ b/tools/eslint/lib/timing.js @@ -136,8 +136,8 @@ module.exports = (function() { } return { - time: time, - enabled: enabled + time, + enabled }; }()); diff --git a/tools/eslint/lib/util/glob-util.js b/tools/eslint/lib/util/glob-util.js index 56b871a1bd84a2..4106ca5240d3f5 100644 --- a/tools/eslint/lib/util/glob-util.js +++ b/tools/eslint/lib/util/glob-util.js @@ -10,7 +10,7 @@ const fs = require("fs"), path = require("path"), - glob = require("glob"), + GlobSync = require("./glob"), shell = require("shelljs"), pathUtil = require("./path-util"), @@ -113,9 +113,9 @@ function listFilesToProcess(globPatterns, options) { const ignoredPaths = new IgnoredPaths(options); const globOptions = { nodir: true, - cwd: cwd, - ignore: ignoredPaths.getIgnoredFoldersGlobPatterns() + cwd }; + const shouldIgnore = ignoredPaths.getIgnoredFoldersGlobChecker(); /** * Executes the linter on a file defined by the `filename`. Skips @@ -151,7 +151,7 @@ function listFilesToProcess(globPatterns, options) { if (added[filename]) { return; } - files.push({filename: filename, ignored: ignored}); + files.push({filename, ignored}); added[filename] = true; } @@ -162,7 +162,7 @@ function listFilesToProcess(globPatterns, options) { if (shell.test("-f", file)) { addFile(fs.realpathSync(file), !shell.test("-d", file)); } else { - glob.sync(pattern, globOptions).forEach(function(globMatch) { + new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(function(globMatch) { addFile(path.resolve(cwd, globMatch), false); }); } @@ -172,6 +172,6 @@ function listFilesToProcess(globPatterns, options) { } module.exports = { - resolveFileGlobPatterns: resolveFileGlobPatterns, - listFilesToProcess: listFilesToProcess + resolveFileGlobPatterns, + listFilesToProcess }; diff --git a/tools/eslint/lib/util/glob.js b/tools/eslint/lib/util/glob.js new file mode 100644 index 00000000000000..915dcff08ef186 --- /dev/null +++ b/tools/eslint/lib/util/glob.js @@ -0,0 +1,63 @@ +/** + * @fileoverview An inherited `glob.GlobSync` to support .gitignore patterns. + * @author Kael Zhang + */ +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const Sync = require("glob").GlobSync, + util = require("util"); + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + +const IGNORE = typeof Symbol === "function" ? Symbol("ignore") : "_shouldIgnore"; + +/** + * Subclass of `glob.GlobSync` + * @param {string} pattern Pattern to be matched. + * @param {Object} options `options` for `glob` + * @param {function()} shouldIgnore Method to check whether a directory should be ignored. + * @constructor + */ +function GlobSync(pattern, options, shouldIgnore) { + + /** + * We don't put this thing to argument `options` to avoid + * further problems, such as `options` validation. + * + * Use `Symbol` as much as possible to avoid confliction. + */ + this[IGNORE] = shouldIgnore; + + Sync.call(this, pattern, options); +} + +util.inherits(GlobSync, Sync); + +/* eslint no-underscore-dangle: ["error", { "allow": ["_readdir", "_mark"] }] */ + +GlobSync.prototype._readdir = function(abs, inGlobStar) { + + /** + * `options.nodir` makes `options.mark` as `true`. + * Mark `abs` first + * to make sure `"node_modules"` will be ignored immediately with ignore pattern `"node_modules/"`. + + * There is a built-in cache about marked `File.Stat` in `glob`, so that we could not worry about the extra invocation of `this._mark()` + */ + const marked = this._mark(abs); + + if (this[IGNORE](marked)) { + return null; + } + + return Sync.prototype._readdir.call(this, abs, inGlobStar); +}; + + +module.exports = GlobSync; diff --git a/tools/eslint/lib/util/module-resolver.js b/tools/eslint/lib/util/module-resolver.js index 3c2ba188793947..d59413c505c123 100644 --- a/tools/eslint/lib/util/module-resolver.js +++ b/tools/eslint/lib/util/module-resolver.js @@ -52,7 +52,7 @@ ModuleResolver.prototype = { * @returns {string} The resolved file path for the module. * @throws {Error} If the module cannot be resolved. */ - resolve: function(name, extraLookupPath) { + resolve(name, extraLookupPath) { /* * First, clone the lookup paths so we're not messing things up for diff --git a/tools/eslint/lib/util/npm-util.js b/tools/eslint/lib/util/npm-util.js index e772107e724a89..a910419403309d 100644 --- a/tools/eslint/lib/util/npm-util.js +++ b/tools/eslint/lib/util/npm-util.js @@ -139,8 +139,8 @@ function checkPackageJson(startDir) { //------------------------------------------------------------------------------ module.exports = { - installSyncSaveDev: installSyncSaveDev, - checkDeps: checkDeps, - checkDevDeps: checkDevDeps, - checkPackageJson: checkPackageJson + installSyncSaveDev, + checkDeps, + checkDevDeps, + checkPackageJson }; diff --git a/tools/eslint/lib/util/path-util.js b/tools/eslint/lib/util/path-util.js index 5cec711a5873e7..4100ff91a05808 100644 --- a/tools/eslint/lib/util/path-util.js +++ b/tools/eslint/lib/util/path-util.js @@ -69,6 +69,6 @@ function getRelativePath(filepath, baseDir) { //------------------------------------------------------------------------------ module.exports = { - convertPathToPosix: convertPathToPosix, - getRelativePath: getRelativePath + convertPathToPosix, + getRelativePath }; diff --git a/tools/eslint/lib/util/rule-fixer.js b/tools/eslint/lib/util/rule-fixer.js index 91f1033e4260af..e6afe85f502f38 100644 --- a/tools/eslint/lib/util/rule-fixer.js +++ b/tools/eslint/lib/util/rule-fixer.js @@ -24,7 +24,7 @@ function insertTextAt(index, text) { return { range: [index, index], - text: text + text }; } @@ -50,7 +50,7 @@ RuleFixer.prototype = { * @param {string} text The text to insert. * @returns {Object} The fix command. */ - insertTextAfter: function(nodeOrToken, text) { + insertTextAfter(nodeOrToken, text) { return this.insertTextAfterRange(nodeOrToken.range, text); }, @@ -62,7 +62,7 @@ RuleFixer.prototype = { * @param {string} text The text to insert. * @returns {Object} The fix command. */ - insertTextAfterRange: function(range, text) { + insertTextAfterRange(range, text) { return insertTextAt(range[1], text); }, @@ -73,7 +73,7 @@ RuleFixer.prototype = { * @param {string} text The text to insert. * @returns {Object} The fix command. */ - insertTextBefore: function(nodeOrToken, text) { + insertTextBefore(nodeOrToken, text) { return this.insertTextBeforeRange(nodeOrToken.range, text); }, @@ -85,7 +85,7 @@ RuleFixer.prototype = { * @param {string} text The text to insert. * @returns {Object} The fix command. */ - insertTextBeforeRange: function(range, text) { + insertTextBeforeRange(range, text) { return insertTextAt(range[0], text); }, @@ -96,7 +96,7 @@ RuleFixer.prototype = { * @param {string} text The text to insert. * @returns {Object} The fix command. */ - replaceText: function(nodeOrToken, text) { + replaceText(nodeOrToken, text) { return this.replaceTextRange(nodeOrToken.range, text); }, @@ -108,10 +108,10 @@ RuleFixer.prototype = { * @param {string} text The text to insert. * @returns {Object} The fix command. */ - replaceTextRange: function(range, text) { + replaceTextRange(range, text) { return { - range: range, - text: text + range, + text }; }, @@ -121,7 +121,7 @@ RuleFixer.prototype = { * @param {ASTNode|Token} nodeOrToken The node or token to remove. * @returns {Object} The fix command. */ - remove: function(nodeOrToken) { + remove(nodeOrToken) { return this.removeRange(nodeOrToken.range); }, @@ -132,9 +132,9 @@ RuleFixer.prototype = { * is end of range. * @returns {Object} The fix command. */ - removeRange: function(range) { + removeRange(range) { return { - range: range, + range, text: "" }; } diff --git a/tools/eslint/lib/util/source-code-fixer.js b/tools/eslint/lib/util/source-code-fixer.js index ebba46716d7a48..064a0a1f902443 100644 --- a/tools/eslint/lib/util/source-code-fixer.js +++ b/tools/eslint/lib/util/source-code-fixer.js @@ -60,7 +60,7 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { debug("No source code to fix"); return { fixed: false, - messages: messages, + messages, output: "" }; } @@ -128,7 +128,7 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { debug("No fixes to apply"); return { fixed: false, - messages: messages, + messages, output: prefix + text }; } diff --git a/tools/eslint/lib/util/source-code-util.js b/tools/eslint/lib/util/source-code-util.js index 6139e093bd9495..c96552f8f6646f 100644 --- a/tools/eslint/lib/util/source-code-util.js +++ b/tools/eslint/lib/util/source-code-util.js @@ -106,5 +106,5 @@ function getSourceCodeOfFiles(patterns, options, cb) { } module.exports = { - getSourceCodeOfFiles: getSourceCodeOfFiles + getSourceCodeOfFiles }; diff --git a/tools/eslint/lib/util/source-code.js b/tools/eslint/lib/util/source-code.js index 557c4504105032..378bdd328fa50a 100644 --- a/tools/eslint/lib/util/source-code.js +++ b/tools/eslint/lib/util/source-code.js @@ -158,7 +158,7 @@ SourceCode.prototype = { * @param {int=} afterCount The number of characters after the node to retrieve. * @returns {string} The text representing the AST node. */ - getText: function(node, beforeCount, afterCount) { + getText(node, beforeCount, afterCount) { if (node) { return this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0), node.range[1] + (afterCount || 0)); @@ -172,7 +172,7 @@ SourceCode.prototype = { * Gets the entire source text split into an array of lines. * @returns {Array} The source text as an array of lines. */ - getLines: function() { + getLines() { return this.lines; }, @@ -180,7 +180,7 @@ SourceCode.prototype = { * Retrieves an array containing all comments in the source code. * @returns {ASTNode[]} An array of comment nodes. */ - getAllComments: function() { + getAllComments() { return this.ast.comments; }, @@ -190,7 +190,7 @@ SourceCode.prototype = { * @returns {Object} The list of comments indexed by their position. * @public */ - getComments: function(node) { + getComments(node) { let leadingComments = node.leadingComments || []; const trailingComments = node.trailingComments || []; @@ -219,7 +219,7 @@ SourceCode.prototype = { * given node or null if not found. * @public */ - getJSDocComment: function(node) { + getJSDocComment(node) { let parent = node.parent; @@ -259,13 +259,13 @@ SourceCode.prototype = { * @param {int} index Range index of the desired node. * @returns {ASTNode} The node if found or null if not found. */ - getNodeByRangeIndex: function(index) { + getNodeByRangeIndex(index) { let result = null, resultParent = null; const traverser = new Traverser(); traverser.traverse(this.ast, { - enter: function(node, parent) { + enter(node, parent) { if (node.range[0] <= index && index < node.range[1]) { result = node; resultParent = parent; @@ -273,7 +273,7 @@ SourceCode.prototype = { this.skip(); } }, - leave: function(node) { + leave(node) { if (node === result) { this.break(); } @@ -292,7 +292,7 @@ SourceCode.prototype = { * @returns {boolean} True if there is only space between tokens, false * if there is anything other than whitespace between tokens. */ - isSpaceBetweenTokens: function(first, second) { + isSpaceBetweenTokens(first, second) { const text = this.text.slice(first.range[1], second.range[0]); return /\s/.test(text.replace(/\/\*.*?\*\//g, "")); diff --git a/tools/eslint/messages/plugin-missing.txt b/tools/eslint/messages/plugin-missing.txt index 56679528c9bc3f..00c7fe78b02ed1 100644 --- a/tools/eslint/messages/plugin-missing.txt +++ b/tools/eslint/messages/plugin-missing.txt @@ -1,9 +1,9 @@ -ESLint couldn't find the plugin "eslint-plugin-<%- pluginName %>". This can happen for a couple different reasons: +ESLint couldn't find the plugin "<%- pluginName %>". This can happen for a couple different reasons: -1. If ESLint is installed globally, then make sure eslint-plugin-<%- pluginName %> is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin. +1. If ESLint is installed globally, then make sure <%- pluginName %> is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin. 2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following: - npm i eslint-plugin-<%- pluginName %>@latest --save-dev + npm i <%- pluginName %>@latest --save-dev If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team. diff --git a/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.js b/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.js index 8bf203e220d65a..a7e535a2704049 100644 --- a/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.js +++ b/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.js @@ -23,7 +23,7 @@ * */ /** - * bluebird build version 3.4.1 + * bluebird build version 3.4.3 * Features enabled: core * Features disabled: race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each */ @@ -290,7 +290,7 @@ Promise.prototype["break"] = Promise.prototype.cancel = function() { var promise = this; var child = promise; - while (promise.isCancellable()) { + while (promise._isCancellable()) { if (!promise._cancelBy(child)) { if (child._isFollowing()) { child._followee().cancel(); @@ -301,7 +301,7 @@ Promise.prototype["break"] = Promise.prototype.cancel = function() { } var parent = promise._cancellationParent; - if (parent == null || !parent.isCancellable()) { + if (parent == null || !parent._isCancellable()) { if (promise._isFollowing()) { promise._followee().cancel(); } else { @@ -310,6 +310,7 @@ Promise.prototype["break"] = Promise.prototype.cancel = function() { break; } else { if (promise._isFollowing()) promise._followee().cancel(); + promise._setWillBeCancelled(); child = promise; promise = parent; } @@ -347,8 +348,7 @@ Promise.prototype._cancelBranched = function() { }; Promise.prototype._cancel = function() { - if (!this.isCancellable()) return; - + if (!this._isCancellable()) return; this._setCancelled(); async.invoke(this._cancelPromises, this, undefined); }; @@ -361,6 +361,10 @@ Promise.prototype._unsetOnCancel = function() { this._onCancelField = undefined; }; +Promise.prototype._isCancellable = function() { + return this.isPending() && !this._isCancelled(); +}; + Promise.prototype.isCancellable = function() { return this.isPending() && !this.isCancelled(); }; @@ -392,7 +396,7 @@ Promise.prototype._invokeOnCancel = function() { }; Promise.prototype._invokeInternalOnCancel = function() { - if (this.isCancellable()) { + if (this._isCancellable()) { this._doInvokeOnCancel(this._onCancel(), true); this._unsetOnCancel(); } @@ -531,6 +535,8 @@ var unhandledRejectionHandled; var possiblyUnhandledRejection; var bluebirdFramePattern = /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/; +var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/; +var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/; var stackFramePattern = null; var formatStack = null; var indentStackFrames = false; @@ -661,14 +667,24 @@ Promise.hasLongStackTraces = function () { var fireDomEvent = (function() { try { - var event = document.createEvent("CustomEvent"); - event.initCustomEvent("testingtheevent", false, true, {}); - util.global.dispatchEvent(event); - return function(name, event) { - var domEvent = document.createEvent("CustomEvent"); - domEvent.initCustomEvent(name.toLowerCase(), false, true, event); - return !util.global.dispatchEvent(domEvent); - }; + if (typeof CustomEvent === "function") { + var event = new CustomEvent("CustomEvent"); + util.global.dispatchEvent(event); + return function(name, event) { + var domEvent = new CustomEvent(name.toLowerCase(), event); + return !util.global.dispatchEvent(domEvent); + }; + } else { + var event = document.createEvent("CustomEvent"); + event.initCustomEvent("testingtheevent", false, true, {}); + util.global.dispatchEvent(event); + return function(name, event) { + var domEvent = document.createEvent("CustomEvent"); + domEvent.initCustomEvent(name.toLowerCase(), false, true, + event); + return !util.global.dispatchEvent(domEvent); + }; + } } catch (e) {} return function() { return false; @@ -825,7 +841,7 @@ function cancellationExecute(executor, resolve, reject) { } function cancellationAttachCancellationCallback(onCancel) { - if (!this.isCancellable()) return this; + if (!this._isCancellable()) return this; var previousOnCancel = this._onCancel(); if (previousOnCancel !== undefined) { @@ -916,8 +932,41 @@ function checkForgottenReturns(returnValue, promiseCreated, name, promise, if ((promise._bitField & 65535) === 0) return; if (name) name = name + " "; + var handlerLine = ""; + var creatorLine = ""; + if (promiseCreated._trace) { + var traceLines = promiseCreated._trace.stack.split("\n"); + var stack = cleanStack(traceLines); + for (var i = stack.length - 1; i >= 0; --i) { + var line = stack[i]; + if (!nodeFramePattern.test(line)) { + var lineMatches = line.match(parseLinePattern); + if (lineMatches) { + handlerLine = "at " + lineMatches[1] + + ":" + lineMatches[2] + ":" + lineMatches[3] + " "; + } + break; + } + } + + if (stack.length > 0) { + var firstUserLine = stack[0]; + for (var i = 0; i < traceLines.length; ++i) { + + if (traceLines[i] === firstUserLine) { + if (i > 0) { + creatorLine = "\n" + traceLines[i - 1]; + } + break; + } + } + + } + } var msg = "a promise was created in a " + name + - "handler but was not returned from it"; + "handler " + handlerLine + "but was not returned from it, " + + "see http://goo.gl/rRqMUw" + + creatorLine; promise._warn(msg, true, promiseCreated); } } @@ -1378,7 +1427,7 @@ return { },{"./errors":9,"./util":21}],8:[function(_dereq_,module,exports){ "use strict"; -module.exports = function(Promise) { +module.exports = function(Promise, tryConvertToPromise) { function returner() { return this.value; } @@ -1388,6 +1437,7 @@ function thrower() { Promise.prototype["return"] = Promise.prototype.thenReturn = function (value) { + value = tryConvertToPromise(value); if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( returner, undefined, undefined, {value: value}, undefined); @@ -1412,11 +1462,13 @@ Promise.prototype.catchThrow = function (reason) { Promise.prototype.catchReturn = function (value) { if (arguments.length <= 1) { + value = tryConvertToPromise(value); if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( undefined, returner, undefined, {value: value}, undefined); } else { var _value = arguments[1]; + _value = tryConvertToPromise(_value); if (_value instanceof Promise) _value.suppressUnhandledRejections(); var handler = function() {return _value;}; return this.caught(value, handler); @@ -1686,7 +1738,7 @@ function finallyHandler(reasonOrValue) { var maybePromise = tryConvertToPromise(ret, promise); if (maybePromise instanceof Promise) { if (this.cancelPromise != null) { - if (maybePromise.isCancelled()) { + if (maybePromise._isCancelled()) { var reason = new CancellationError("late cancellation observer"); promise._attachExtraTrace(reason); @@ -2095,7 +2147,8 @@ Promise.prototype.caught = Promise.prototype["catch"] = function (fn) { if (util.isObject(item)) { catchInstances[j++] = item; } else { - return apiRejection("expecting an object but got " + util.classString(item)); + return apiRejection("expecting an object but got " + + "A catch statement predicate " + util.classString(item)); } } catchInstances.length = j; @@ -2320,6 +2373,10 @@ Promise.prototype._setCancelled = function() { this._fireEvent("promiseCancelled", this); }; +Promise.prototype._setWillBeCancelled = function() { + this._bitField = this._bitField | 8388608; +}; + Promise.prototype._setAsyncGuaranteed = function() { if (async.hasCustomScheduler()) return; this._bitField = this._bitField | 134217728; @@ -2721,12 +2778,12 @@ _dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug); _dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug); _dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug); -_dereq_("./direct_resolve")(Promise); +_dereq_("./direct_resolve")(Promise, tryConvertToPromise); _dereq_("./synchronous_inspection")(Promise); _dereq_("./join")( Promise, PromiseArray, tryConvertToPromise, INTERNAL, debug); Promise.Promise = Promise; -Promise.version = "3.4.0"; +Promise.version = "3.4.3"; util.toFastProperties(Promise); util.toFastProperties(Promise.prototype); @@ -2881,7 +2938,7 @@ PromiseArray.prototype._resolve = function (value) { }; PromiseArray.prototype._cancel = function() { - if (this._isResolved() || !this._promise.isCancellable()) return; + if (this._isResolved() || !this._promise._isCancellable()) return; this._values = null; this._promise._cancel(); }; @@ -3044,7 +3101,8 @@ if (util.isNode && typeof MutationObserver === "undefined") { schedule = util.isRecentNode ? function(fn) { GlobalSetImmediate.call(global, fn); } : function(fn) { ProcessNextTick.call(process, fn); }; -} else if (typeof NativePromise === "function") { +} else if (typeof NativePromise === "function" && + typeof NativePromise.resolve === "function") { var nativePromise = NativePromise.resolve(); schedule = function(fn) { nativePromise.then(fn); @@ -3143,13 +3201,20 @@ var isResolved = PromiseInspection.prototype.isResolved = function () { return (this._bitField & 50331648) !== 0; }; -PromiseInspection.prototype.isCancelled = -Promise.prototype._isCancelled = function() { +PromiseInspection.prototype.isCancelled = function() { + return (this._bitField & 8454144) !== 0; +}; + +Promise.prototype.__isCancelled = function() { return (this._bitField & 65536) === 65536; }; +Promise.prototype._isCancelled = function() { + return this._target().__isCancelled(); +}; + Promise.prototype.isCancelled = function() { - return this._target()._isCancelled(); + return (this._target()._bitField & 8454144) !== 0; }; Promise.prototype.isPending = function() { diff --git a/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.min.js b/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.min.js index 7859c2aee9136a..68be3cdda0fdde 100644 --- a/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.min.js +++ b/tools/eslint/node_modules/bluebird/js/browser/bluebird.core.min.js @@ -23,9 +23,9 @@ * */ /** - * bluebird build version 3.4.1 + * bluebird build version 3.4.3 * Features enabled: core * Features disabled: race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function i(a,s){if(!e[a]){if(!t[a]){var c="function"==typeof _dereq_&&_dereq_;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=e[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return i(n?n:e)},u,u.exports,r,t,e,n)}return e[a].exports}for(var o="function"==typeof _dereq_&&_dereq_,a=0;a0;){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=s},{"./queue":17,"./schedule":18,"./util":21}],2:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(o),u=new t(e);u._propagateFrom(this,1);var p=this._target();if(u._setBoundTo(l),l instanceof t){var f={promiseRejectionQueued:!1,promise:u,target:p,bindingPromise:l};p._then(e,a,void 0,u,f),l._then(s,c,void 0,u,f),u._setOnCancel(l)}else u._resolveCallback(p);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],3:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":15}],4:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),a=o.tryCatch,s=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t.isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n.isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this.isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],7:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,e){return{promise:e}}function i(){return!1}function o(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+H.toString(t));r._attachCancellationCallback(t)})}catch(i){return i}}function a(t){if(!this.isCancellable())return this;var e=this._onCancel();void 0!==e?H.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function s(){return this._onCancelField}function c(t){this._onCancelField=t}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function u(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function f(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function h(){this._trace=new S(this._peekContext())}function _(t,e){if(B(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=w(t);H.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),H.notEnumerableProp(t,"__stackCleaned__",!0)}}}function d(t,e,n,r,i){if(void 0===t&&null!==e&&$){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="a promise was created in a "+n+"handler but was not returned from it";r._warn(o,!0,e)}}function v(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),y(n)}function y(t,n,r){if(rt.warnings){var i,o=new U(t);if(n)r._attachExtraTrace(o);else if(rt.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var a=w(o);o.stack=a.message+"\n"+a.stack.join("\n")}Y("warning",o)||E(o,"",!0)}}function g(t,e){for(var n=0;n=0;--s)if(r[s]===o){a=s;break}for(var s=a;s>=0;--s){var c=r[s];if(e[i]!==c)break;e.pop(),i--}e=r}}function C(t){for(var e=[],n=0;n0&&(e=e.slice(n)),e}function w(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?k(t):[" (No stack trace)"],{message:n,stack:C(e)}}function E(t,e,n){if("undefined"!=typeof console){var r;if(H.isObject(t)){var i=t.stack;r=e+Q(i,t)}else r=e+String(t);"function"==typeof N?N(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function j(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(o){I.throwLater(o)}"unhandledRejection"===t?Y(t,n,r)||i||E(n,"Unhandled rejection "):Y(t,r)}function F(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():H.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+T(e)+">, no stack trace)"}function T(t){var e=41;return t.lengtha||0>s||!n||!r||n!==r||a>=s||(tt=function(t){if(D.test(t))return!0;var e=P(t);return e&&e.fileName===n&&a<=e.line&&e.line<=s?!0:!1})}}function S(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);nt(this,S),e>32&&this.uncycle()}var x,A,N,L=e._getDomain,I=e._async,U=t("./errors").Warning,H=t("./util"),B=H.canAttachTrace,D=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,V=null,Q=null,q=!1,G=!(0==H.env("BLUEBIRD_DEBUG")||!H.env("BLUEBIRD_DEBUG")&&"development"!==H.env("NODE_ENV")),M=!(0==H.env("BLUEBIRD_WARNINGS")||!G&&!H.env("BLUEBIRD_WARNINGS")),W=!(0==H.env("BLUEBIRD_LONG_STACK_TRACES")||!G&&!H.env("BLUEBIRD_LONG_STACK_TRACES")),$=0!=H.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(M||!!H.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),I.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){j("rejectionHandled",x,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),j("unhandledRejection",A,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return y(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var e=L();A="function"==typeof t?null===e?t:e.bind(t):void 0},e.onUnhandledRejectionHandled=function(t){var e=L();x="function"==typeof t?null===e?t:e.bind(t):void 0};var z=function(){};e.longStackTraces=function(){if(I.haveItemsQueued()&&!rt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!rt.longStackTraces&&O()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace;rt.longStackTraces=!0,z=function(){if(I.haveItemsQueued()&&!rt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,n.deactivateLongStackTraces(),I.enableTrampoline(),rt.longStackTraces=!1},e.prototype._captureStackTrace=h,e.prototype._attachExtraTrace=_,n.activateLongStackTraces(),I.disableTrampolineIfNecessary()}},e.hasLongStackTraces=function(){return rt.longStackTraces&&O()};var X=function(){try{var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),H.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!H.global.dispatchEvent(n)}}catch(e){}return function(){return!1}}(),K=function(){return H.isNode?function(){return process.emit.apply(process,arguments)}:H.global?function(t){var e="on"+t.toLowerCase(),n=H.global[e];return n?(n.apply(H.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),J={promiseCreated:r,promiseFulfilled:r,promiseRejected:r,promiseResolved:r,promiseCancelled:r,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:r},Y=function(t){var e=!1;try{e=K.apply(null,arguments)}catch(n){I.throwLater(n),e=!0}var r=!1;try{r=X(t,J[t].apply(null,arguments))}catch(n){I.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&z()),"warnings"in t){var n=t.warnings;rt.warnings=!!n,$=rt.warnings,H.isObject(n)&&"wForgottenReturn"in n&&($=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!rt.cancellation){if(I.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=l,e.prototype._propagateFrom=u,e.prototype._onCancel=s,e.prototype._setOnCancel=c,e.prototype._attachCancellationCallback=a,e.prototype._execute=o,Z=u,rt.cancellation=!0}"monitoring"in t&&(t.monitoring&&!rt.monitoring?(rt.monitoring=!0,e.prototype._fireEvent=Y):!t.monitoring&&rt.monitoring&&(rt.monitoring=!1,e.prototype._fireEvent=i))},e.prototype._fireEvent=i,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var Z=p,tt=function(){return!1},et=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;H.inherits(S,Error),n.CapturedTrace=S,S.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;t>r;++r){var a=e[r].stack,s=n[a];if(void 0!==s&&s!==r){s>0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>s?(c._parent=e[s+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var l=c._length+1,u=r-2;u>=0;--u)e[u]._length=l,l++;return}}}},S.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=w(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(C(i.stack.split("\n"))),i=i._parent;b(r),m(r),H.notEnumerableProp(t,"stack",g(n,r)),H.notEnumerableProp(t,"__stackCleaned__",!0)}};var nt=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():F(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,V=t,Q=e;var n=Error.captureStackTrace;return tt=function(t){return D.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return V=/@/,Q=e,q=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(Q=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?F(e):e.toString()},null):(V=t,Q=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(N=function(t){console.warn(t)},H.isNode&&process.stderr.isTTY?N=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:H.isNode||"string"!=typeof(new Error).stack||(N=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var rt={warnings:M,longStackTraces:!1,cancellation:!1,monitoring:!1};return W&&e.longStackTraces(),{longStackTraces:function(){return rt.longStackTraces},warnings:function(){return rt.warnings},cancellation:function(){return rt.cancellation},monitoring:function(){return rt.monitoring},propagateFromFunction:function(){return Z},boundValueFunction:function(){return f},checkForgottenReturns:d,setBounds:R,warn:y,deprecated:v,CapturedTrace:S,fireDomEvent:X,fireGlobalEvent:K}}},{"./errors":9,"./util":21}],8:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],9:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return u(n,Error),n}function i(t){return this instanceof i?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,a,s=t("./es5"),c=s.freeze,l=t("./util"),u=l.inherits,p=l.notEnumerableProp,f=r("Warning","warning"),h=r("CancellationError","cancellation error"),_=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{o=TypeError,a=RangeError}catch(v){o=r("TypeError","type error"),a=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function a(){return c.call(this,this.promise._target()._settledValue())}function s(t){return o(this,t)?void 0:(p.e=t,p)}function c(t){var r=this.promise,c=this.handler;if(!this.called){this.called=!0;var l=this.isFinallyHandler()?c.call(r._boundValue()):c.call(r._boundValue(),t);if(void 0!==l){r._setReturnedNonUndefined();var f=n(l,r);if(f instanceof e){if(null!=this.cancelPromise){if(f.isCancelled()){var h=new u("late cancellation observer");return r._attachExtraTrace(h),p.e=h,p}f.isPending()&&f._attachCancellationCallback(new i(this))}return f._then(a,s,void 0,this,void 0)}}}return r.isRejected()?(o(this),p.e=t,p):(o(this),t)}var l=t("./util"),u=e.CancellationError,p=l.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,i){return"function"!=typeof t?this.then():this._then(n,i,void 0,new r(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,c,c)},e.prototype.tap=function(t){return this._passThrough(t,1,c)},r}},{"./util":21}],12:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util");o.canEvaluate,o.tryCatch,o.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":21}],13:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var a=t("./util"),s=a.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+a.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var i=s(t).apply(this,arguments),a=r._popContext();return o.checkForgottenReturns(i,a,"Promise.method",r),r._resolveFromSyncValue(i),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+a.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],u=arguments[2];c=a.isArray(l)?s(t).apply(u,l):s(t).call(u,l)}else c=s(t)();var p=r._popContext();return o.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===a.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":21}],14:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&u.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=u.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;e-1>n;++n){var o=arguments[n];if(!h.isObject(o))return p("expecting an object but got "+h.classString(o));r[i++]=o}return r.length=i,t=arguments[n],this.then(void 0,O(r,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(u,u,void 0,this,void 0)},i.prototype.then=function(t,e){if(F.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+h.classString(t);arguments.length>1&&(n+=", "+h.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?p("expecting a function but got "+h.classString(t)):this.all()._then(t,void 0,void 0,C,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new E(this).promise()},i.prototype.error=function(t){return this.caught(h.originatesFromRejection,t)},i.getNewLibraryCopy=e.exports,i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(b);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=S(t)(P(e,n));return r===R&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new E(t).promise()},i.cast=function(t){var e=w(t);return e instanceof i||(e=new i(b),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(b);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new g("expecting a function but got "+h.classString(t));return v.setScheduler(t)},i.prototype._then=function(t,e,n,r,o){var a=void 0!==o,s=a?o:new i(b),l=this._target(),u=l._bitField; -a||(s._propagateFrom(this,3),s._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&u)?this._boundValue():l===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,s));var p=c();if(0!==(50397184&u)){var f,h,_=l._settlePromiseCtx;0!==(33554432&u)?(h=l._rejectionHandler0,f=t):0!==(16777216&u)?(h=l._fulfillmentHandler0,f=e,l._unsetRejectionIsUnhandled()):(_=l._settlePromiseLateCancellationObserver,h=new m("late cancellation observer"),l._attachExtraTrace(h),f=e),v.invoke(_,l,{handler:null===p?f:"function"==typeof f&&p.bind(f),promise:s,receiver:r,value:h})}else l._addCallbacks(t,e,s,r,p);return s},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setAsyncGuaranteed=function(){v.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===f?void 0:void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=f),this._addCallbacks(e,n,r,i,null)},i.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=f),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(t,e,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:i.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:i.bind(e));else{var a=4*o-4;this[a+2]=n,this[a+3]=r,"function"==typeof t&&(this[a+0]=null===i?t:i.bind(t)),"function"==typeof e&&(this[a+1]=null===i?e:i.bind(e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(l(),!1);var n=w(t,this);if(!(n instanceof i))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(l());var o=r._bitField;if(0===(50397184&o)){var a=this._length();a>0&&r._migrateCallback0(this);for(var s=1;a>s;++s)r._migrateCallbackAt(this,s);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var c=new m("late cancellation observer");r._attachExtraTrace(c),this._reject(c)}}},i.prototype._rejectCallback=function(t,e,n){var r=h.ensureErrorObject(t),i=r===t;if(!i&&!n&&F.warnings()){var o="a promise was rejected with a non-error: "+h.classString(t);this._warn(o,!0)}this._attachExtraTrace(r,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)},i.prototype._settlePromiseFromHandler=function(t,e,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;e===C?n&&"number"==typeof n.length?o=S(t).apply(this._boundValue(),n):(o=R,o.e=new g("cannot .spread() a non-array: "+h.classString(n))):o=S(t).call(e,n);var a=r._popContext();i=r._bitField,0===(65536&i)&&(o===k?r._reject(n):o===R?r._rejectCallback(o.e,!1):(F.checkForgottenReturns(o,a,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,r,o){var a=t instanceof i,s=this._bitField,c=0!==(134217728&s);0!==(65536&s)?(a&&t._invokeInternalOnCancel(),r instanceof T&&r.isFinallyHandler()?(r.cancelPromise=t,S(e).call(r,o)===R&&t._reject(R.e)):e===u?t._fulfill(u.call(r)):r instanceof n?r._promiseCancelled(t):a||t instanceof E?t._cancel():r.cancel()):"function"==typeof e?a?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,o,t)):e.call(r,o,t):r instanceof n?r._isResolved()||(0!==(33554432&s)?r._promiseFulfilled(o,t):r._promiseRejected(o,t)):a&&(c&&t._setAsyncGuaranteed(),0!==(33554432&s)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof i?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=l();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():v.settlePromises(this))}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?v.fatalError(t,h.isNode):void((65535&e)>0?v.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){F.deprecated("Promise.defer","new Promise");var t=new i(b);return{promise:t,resolve:o,reject:a}},h.notEnumerableProp(i,"_makeSelfResolutionError",l),t("./method")(i,b,w,p,F),t("./bind")(i,b,w,F),t("./cancel")(i,E,p,F),t("./direct_resolve")(i),t("./synchronous_inspection")(i),t("./join")(i,E,w,b,F),i.Promise=i,i.version="3.4.0",h.toFastProperties(i),h.toFastProperties(i.prototype),s({a:1}),s({b:2}),s({c:3}),s(1),s(function(){}),s(void 0),s(!1),s(new i(b)),F.setBounds(d.firstLineError,h.lastLineError),i}},{"./async":1,"./bind":2,"./cancel":4,"./catch_filter":5,"./context":6,"./debuggability":7,"./direct_resolve":8,"./errors":9,"./es5":10,"./finally":11,"./join":12,"./method":13,"./nodeback":14,"./promise_array":16,"./synchronous_inspection":19,"./thenables":20,"./util":21}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){function a(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(s,o),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function l(t,n){var o=r(this._values,this._promise);if(o instanceof e){o=o._target();var s=o._bitField;if(this._values=o,0===(50397184&s))return this._promise._setAsyncGuaranteed(),o._then(l,this._reject,void 0,this,n);if(0===(33554432&s))return 0!==(16777216&s)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var u=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(u,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(a(n))):void this._iterate(o)},s.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,a=null,s=0;n>s;++s){var c=r(t[s],i);c instanceof e?(c=c._target(),a=c._bitField):a=null,o?null!==a&&c.suppressUnhandledRejections():null!==a?0===(50397184&a)?(c._proxy(this,s),this._values[s]=c):o=0!==(33554432&a)?this._promiseFulfilled(c._value(),s):0!==(16777216&a)?this._promiseRejected(c._reason(),s):this._promiseCancelled(s):o=this._promiseFulfilled(c,s)}o||i._setAsyncGuaranteed()},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype._cancel=function(){!this._isResolved()&&this._promise.isCancellable()&&(this._values=null,this._promise._cancel())},s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;no;++o)n[o+r]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityn;++n)i[n]=t[n];return i[n]=e,i}function l(t,e,n){if(!j.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function u(t,e,n){if(o(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return j.defineProperty(t,e,r),t}function p(t){throw t}function f(t){try{if("function"==typeof t){var e=j.names(t.prototype),n=j.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=x.test(t+"")&&j.names(t).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function h(t){function e(){}e.prototype=t;for(var n=8;n--;)new e;return t}function _(t){return A.test(t)}function d(t,e,n){for(var r=new Array(t),i=0;t>i;++i)r[i]=e+i+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function g(t){try{u(t,"isOperational",!0)}catch(e){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&j.propertyIsWritable(t,"stack")}function C(t){return{}.toString.call(t)}function k(t,e,n){for(var r=j.names(t),i=0;i10||t[0]>0}(),H.isNode&&H.toFastProperties(process);try{throw new Error}catch(B){H.lastLineError=B}e.exports=H},{"./es5":10}]},{},[3])(3)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function i(a,s){if(!e[a]){if(!t[a]){var c="function"==typeof _dereq_&&_dereq_;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=e[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return i(n?n:e)},u,u.exports,r,t,e,n)}return e[a].exports}for(var o="function"==typeof _dereq_&&_dereq_,a=0;a0;){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=s},{"./queue":17,"./schedule":18,"./util":21}],2:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(o),u=new t(e);u._propagateFrom(this,1);var p=this._target();if(u._setBoundTo(l),l instanceof t){var f={promiseRejectionQueued:!1,promise:u,target:p,bindingPromise:l};p._then(e,a,void 0,u,f),l._then(s,c,void 0,u,f),u._setOnCancel(l)}else u._resolveCallback(p);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],3:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":15}],4:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),a=o.tryCatch,s=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],7:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,e){return{promise:e}}function i(){return!1}function o(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+H.toString(t));r._attachCancellationCallback(t)})}catch(i){return i}}function a(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?H.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function s(){return this._onCancelField}function c(t){this._onCancelField=t}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function u(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function f(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function h(){this._trace=new S(this._peekContext())}function _(t,e){if(B(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=w(t);H.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),H.notEnumerableProp(t,"__stackCleaned__",!0)}}}function d(t,e,n,r,i){if(void 0===t&&null!==e&&X){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="",a="";if(e._trace){for(var s=e._trace.stack.split("\n"),c=C(s),l=c.length-1;l>=0;--l){var u=c[l];if(!V.test(u)){var p=u.match(Q);p&&(o="at "+p[1]+":"+p[2]+":"+p[3]+" ");break}}if(c.length>0)for(var f=c[0],l=0;l0&&(a="\n"+s[l-1]);break}}var h="a promise was created in a "+n+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+a;r._warn(h,!0,e)}}function v(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),y(n)}function y(t,n,r){if(ot.warnings){var i,o=new I(t);if(n)r._attachExtraTrace(o);else if(ot.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var a=w(o);o.stack=a.message+"\n"+a.stack.join("\n")}tt("warning",o)||E(o,"",!0)}}function g(t,e){for(var n=0;n=0;--s)if(r[s]===o){a=s;break}for(var s=a;s>=0;--s){var c=r[s];if(e[i]!==c)break;e.pop(),i--}e=r}}function C(t){for(var e=[],n=0;n0&&(e=e.slice(n)),e}function w(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?k(t):[" (No stack trace)"],{message:n,stack:C(e)}}function E(t,e,n){if("undefined"!=typeof console){var r;if(H.isObject(t)){var i=t.stack;r=e+G(i,t)}else r=e+String(t);"function"==typeof N?N(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function j(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(o){U.throwLater(o)}"unhandledRejection"===t?tt(t,n,r)||i||E(n,"Unhandled rejection "):tt(t,r)}function F(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():H.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+T(e)+">, no stack trace)"}function T(t){var e=41;return t.lengtha||0>s||!n||!r||n!==r||a>=s||(nt=function(t){if(D.test(t))return!0;var e=P(t);return e&&e.fileName===n&&a<=e.line&&e.line<=s?!0:!1})}}function S(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);it(this,S),e>32&&this.uncycle()}var x,A,N,L=e._getDomain,U=e._async,I=t("./errors").Warning,H=t("./util"),B=H.canAttachTrace,D=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,V=/\((?:timers\.js):\d+:\d+\)/,Q=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,q=null,G=null,M=!1,W=!(0==H.env("BLUEBIRD_DEBUG")||!H.env("BLUEBIRD_DEBUG")&&"development"!==H.env("NODE_ENV")),$=!(0==H.env("BLUEBIRD_WARNINGS")||!W&&!H.env("BLUEBIRD_WARNINGS")),z=!(0==H.env("BLUEBIRD_LONG_STACK_TRACES")||!W&&!H.env("BLUEBIRD_LONG_STACK_TRACES")),X=0!=H.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&($||!!H.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),U.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){j("rejectionHandled",x,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),j("unhandledRejection",A,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return y(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var e=L();A="function"==typeof t?null===e?t:e.bind(t):void 0},e.onUnhandledRejectionHandled=function(t){var e=L();x="function"==typeof t?null===e?t:e.bind(t):void 0};var K=function(){};e.longStackTraces=function(){if(U.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ot.longStackTraces&&O()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace;ot.longStackTraces=!0,K=function(){if(U.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,n.deactivateLongStackTraces(),U.enableTrampoline(),ot.longStackTraces=!1},e.prototype._captureStackTrace=h,e.prototype._attachExtraTrace=_,n.activateLongStackTraces(),U.disableTrampolineIfNecessary()}},e.hasLongStackTraces=function(){return ot.longStackTraces&&O()};var J=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return H.global.dispatchEvent(t),function(t,e){var n=new CustomEvent(t.toLowerCase(),e);return!H.global.dispatchEvent(n)}}var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),H.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!H.global.dispatchEvent(n)}}catch(e){}return function(){return!1}}(),Y=function(){return H.isNode?function(){return process.emit.apply(process,arguments)}:H.global?function(t){var e="on"+t.toLowerCase(),n=H.global[e];return n?(n.apply(H.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),Z={promiseCreated:r,promiseFulfilled:r,promiseRejected:r,promiseResolved:r,promiseCancelled:r,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:r},tt=function(t){var e=!1;try{e=Y.apply(null,arguments)}catch(n){U.throwLater(n),e=!0}var r=!1;try{r=J(t,Z[t].apply(null,arguments))}catch(n){U.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&K()),"warnings"in t){var n=t.warnings;ot.warnings=!!n,X=ot.warnings,H.isObject(n)&&"wForgottenReturn"in n&&(X=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!ot.cancellation){if(U.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=l,e.prototype._propagateFrom=u,e.prototype._onCancel=s,e.prototype._setOnCancel=c,e.prototype._attachCancellationCallback=a,e.prototype._execute=o,et=u,ot.cancellation=!0}"monitoring"in t&&(t.monitoring&&!ot.monitoring?(ot.monitoring=!0,e.prototype._fireEvent=tt):!t.monitoring&&ot.monitoring&&(ot.monitoring=!1,e.prototype._fireEvent=i))},e.prototype._fireEvent=i,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var et=p,nt=function(){return!1},rt=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;H.inherits(S,Error),n.CapturedTrace=S,S.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;t>r;++r){var a=e[r].stack,s=n[a];if(void 0!==s&&s!==r){s>0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>s?(c._parent=e[s+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var l=c._length+1,u=r-2;u>=0;--u)e[u]._length=l,l++;return}}}},S.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=w(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(C(i.stack.split("\n"))),i=i._parent;b(r),m(r),H.notEnumerableProp(t,"stack",g(n,r)),H.notEnumerableProp(t,"__stackCleaned__",!0)}};var it=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():F(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,q=t,G=e;var n=Error.captureStackTrace;return nt=function(t){return D.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return q=/@/,G=e,M=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(G=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?F(e):e.toString()},null):(q=t,G=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(N=function(t){console.warn(t)},H.isNode&&process.stderr.isTTY?N=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:H.isNode||"string"!=typeof(new Error).stack||(N=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var ot={warnings:$,longStackTraces:!1,cancellation:!1,monitoring:!1};return z&&e.longStackTraces(),{longStackTraces:function(){return ot.longStackTraces},warnings:function(){return ot.warnings},cancellation:function(){return ot.cancellation},monitoring:function(){return ot.monitoring},propagateFromFunction:function(){return et},boundValueFunction:function(){return f},checkForgottenReturns:d,setBounds:R,warn:y,deprecated:v,CapturedTrace:S,fireDomEvent:J,fireGlobalEvent:Y}}},{"./errors":9,"./util":21}],8:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return this.value}function r(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(r){return r=e(r),r instanceof t&&r.suppressUnhandledRejections(),this._then(n,void 0,void 0,{value:r},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(r,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,r,void 0,{reason:t},void 0);var e=arguments[1],n=function(){throw e};return this.caught(t,n)},t.prototype.catchReturn=function(r){if(arguments.length<=1)return r=e(r),r instanceof t&&r.suppressUnhandledRejections(),this._then(void 0,n,void 0,{value:r},void 0);var i=arguments[1];i=e(i),i instanceof t&&i.suppressUnhandledRejections();var o=function(){return i};return this.caught(r,o)}}},{}],9:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return u(n,Error),n}function i(t){return this instanceof i?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,a,s=t("./es5"),c=s.freeze,l=t("./util"),u=l.inherits,p=l.notEnumerableProp,f=r("Warning","warning"),h=r("CancellationError","cancellation error"),_=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{o=TypeError,a=RangeError}catch(v){o=r("TypeError","type error"),a=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function a(){return c.call(this,this.promise._target()._settledValue())}function s(t){return o(this,t)?void 0:(p.e=t,p)}function c(t){var r=this.promise,c=this.handler;if(!this.called){this.called=!0;var l=this.isFinallyHandler()?c.call(r._boundValue()):c.call(r._boundValue(),t);if(void 0!==l){r._setReturnedNonUndefined();var f=n(l,r);if(f instanceof e){if(null!=this.cancelPromise){if(f._isCancelled()){var h=new u("late cancellation observer");return r._attachExtraTrace(h),p.e=h,p}f.isPending()&&f._attachCancellationCallback(new i(this))}return f._then(a,s,void 0,this,void 0)}}}return r.isRejected()?(o(this),p.e=t,p):(o(this),t)}var l=t("./util"),u=e.CancellationError,p=l.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,i){return"function"!=typeof t?this.then():this._then(n,i,void 0,new r(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,c,c)},e.prototype.tap=function(t){return this._passThrough(t,1,c)},r}},{"./util":21}],12:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util");o.canEvaluate,o.tryCatch,o.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":21}],13:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var a=t("./util"),s=a.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+a.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var i=s(t).apply(this,arguments),a=r._popContext();return o.checkForgottenReturns(i,a,"Promise.method",r),r._resolveFromSyncValue(i),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+a.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],u=arguments[2];c=a.isArray(l)?s(t).apply(u,l):s(t).call(u,l)}else c=s(t)();var p=r._popContext();return o.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===a.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":21}],14:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&u.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=u.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;e-1>n;++n){var o=arguments[n];if(!h.isObject(o))return p("expecting an object but got A catch statement predicate "+h.classString(o));r[i++]=o}return r.length=i,t=arguments[n],this.then(void 0,O(r,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(u,u,void 0,this,void 0)},i.prototype.then=function(t,e){if(F.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+h.classString(t);arguments.length>1&&(n+=", "+h.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?p("expecting a function but got "+h.classString(t)):this.all()._then(t,void 0,void 0,C,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new E(this).promise()},i.prototype.error=function(t){return this.caught(h.originatesFromRejection,t)},i.getNewLibraryCopy=e.exports,i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){ +var e=new i(b);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=S(t)(P(e,n));return r===R&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new E(t).promise()},i.cast=function(t){var e=w(t);return e instanceof i||(e=new i(b),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(b);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new g("expecting a function but got "+h.classString(t));return v.setScheduler(t)},i.prototype._then=function(t,e,n,r,o){var a=void 0!==o,s=a?o:new i(b),l=this._target(),u=l._bitField;a||(s._propagateFrom(this,3),s._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&u)?this._boundValue():l===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,s));var p=c();if(0!==(50397184&u)){var f,h,_=l._settlePromiseCtx;0!==(33554432&u)?(h=l._rejectionHandler0,f=t):0!==(16777216&u)?(h=l._fulfillmentHandler0,f=e,l._unsetRejectionIsUnhandled()):(_=l._settlePromiseLateCancellationObserver,h=new m("late cancellation observer"),l._attachExtraTrace(h),f=e),v.invoke(_,l,{handler:null===p?f:"function"==typeof f&&p.bind(f),promise:s,receiver:r,value:h})}else l._addCallbacks(t,e,s,r,p);return s},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},i.prototype._setAsyncGuaranteed=function(){v.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===f?void 0:void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=f),this._addCallbacks(e,n,r,i,null)},i.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=f),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(t,e,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:i.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:i.bind(e));else{var a=4*o-4;this[a+2]=n,this[a+3]=r,"function"==typeof t&&(this[a+0]=null===i?t:i.bind(t)),"function"==typeof e&&(this[a+1]=null===i?e:i.bind(e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(l(),!1);var n=w(t,this);if(!(n instanceof i))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(l());var o=r._bitField;if(0===(50397184&o)){var a=this._length();a>0&&r._migrateCallback0(this);for(var s=1;a>s;++s)r._migrateCallbackAt(this,s);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var c=new m("late cancellation observer");r._attachExtraTrace(c),this._reject(c)}}},i.prototype._rejectCallback=function(t,e,n){var r=h.ensureErrorObject(t),i=r===t;if(!i&&!n&&F.warnings()){var o="a promise was rejected with a non-error: "+h.classString(t);this._warn(o,!0)}this._attachExtraTrace(r,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)},i.prototype._settlePromiseFromHandler=function(t,e,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;e===C?n&&"number"==typeof n.length?o=S(t).apply(this._boundValue(),n):(o=R,o.e=new g("cannot .spread() a non-array: "+h.classString(n))):o=S(t).call(e,n);var a=r._popContext();i=r._bitField,0===(65536&i)&&(o===k?r._reject(n):o===R?r._rejectCallback(o.e,!1):(F.checkForgottenReturns(o,a,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,r,o){var a=t instanceof i,s=this._bitField,c=0!==(134217728&s);0!==(65536&s)?(a&&t._invokeInternalOnCancel(),r instanceof T&&r.isFinallyHandler()?(r.cancelPromise=t,S(e).call(r,o)===R&&t._reject(R.e)):e===u?t._fulfill(u.call(r)):r instanceof n?r._promiseCancelled(t):a||t instanceof E?t._cancel():r.cancel()):"function"==typeof e?a?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,o,t)):e.call(r,o,t):r instanceof n?r._isResolved()||(0!==(33554432&s)?r._promiseFulfilled(o,t):r._promiseRejected(o,t)):a&&(c&&t._setAsyncGuaranteed(),0!==(33554432&s)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof i?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=l();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():v.settlePromises(this))}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?v.fatalError(t,h.isNode):void((65535&e)>0?v.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){F.deprecated("Promise.defer","new Promise");var t=new i(b);return{promise:t,resolve:o,reject:a}},h.notEnumerableProp(i,"_makeSelfResolutionError",l),t("./method")(i,b,w,p,F),t("./bind")(i,b,w,F),t("./cancel")(i,E,p,F),t("./direct_resolve")(i,w),t("./synchronous_inspection")(i),t("./join")(i,E,w,b,F),i.Promise=i,i.version="3.4.3",h.toFastProperties(i),h.toFastProperties(i.prototype),s({a:1}),s({b:2}),s({c:3}),s(1),s(function(){}),s(void 0),s(!1),s(new i(b)),F.setBounds(d.firstLineError,h.lastLineError),i}},{"./async":1,"./bind":2,"./cancel":4,"./catch_filter":5,"./context":6,"./debuggability":7,"./direct_resolve":8,"./errors":9,"./es5":10,"./finally":11,"./join":12,"./method":13,"./nodeback":14,"./promise_array":16,"./synchronous_inspection":19,"./thenables":20,"./util":21}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){function a(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(s,o),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function l(t,n){var o=r(this._values,this._promise);if(o instanceof e){o=o._target();var s=o._bitField;if(this._values=o,0===(50397184&s))return this._promise._setAsyncGuaranteed(),o._then(l,this._reject,void 0,this,n);if(0===(33554432&s))return 0!==(16777216&s)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var u=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(u,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(a(n))):void this._iterate(o)},s.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,a=null,s=0;n>s;++s){var c=r(t[s],i);c instanceof e?(c=c._target(),a=c._bitField):a=null,o?null!==a&&c.suppressUnhandledRejections():null!==a?0===(50397184&a)?(c._proxy(this,s),this._values[s]=c):o=0!==(33554432&a)?this._promiseFulfilled(c._value(),s):0!==(16777216&a)?this._promiseRejected(c._reason(),s):this._promiseCancelled(s):o=this._promiseFulfilled(c,s)}o||i._setAsyncGuaranteed()},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;no;++o)n[o+r]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityn;++n)i[n]=t[n];return i[n]=e,i}function l(t,e,n){if(!j.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function u(t,e,n){if(o(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return j.defineProperty(t,e,r),t}function p(t){throw t}function f(t){try{if("function"==typeof t){var e=j.names(t.prototype),n=j.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=x.test(t+"")&&j.names(t).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function h(t){function e(){}e.prototype=t;for(var n=8;n--;)new e;return t}function _(t){return A.test(t)}function d(t,e,n){for(var r=new Array(t),i=0;t>i;++i)r[i]=e+i+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function g(t){try{u(t,"isOperational",!0)}catch(e){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&j.propertyIsWritable(t,"stack")}function C(t){return{}.toString.call(t)}function k(t,e,n){for(var r=j.names(t),i=0;i10||t[0]>0}(),H.isNode&&H.toFastProperties(process);try{throw new Error}catch(B){H.lastLineError=B}e.exports=H},{"./es5":10}]},{},[3])(3)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file diff --git a/tools/eslint/node_modules/bluebird/js/browser/bluebird.js b/tools/eslint/node_modules/bluebird/js/browser/bluebird.js index 0d9834e6bea358..3ef5ce212b16fe 100644 --- a/tools/eslint/node_modules/bluebird/js/browser/bluebird.js +++ b/tools/eslint/node_modules/bluebird/js/browser/bluebird.js @@ -23,7 +23,7 @@ * */ /** - * bluebird build version 3.4.1 + * bluebird build version 3.4.3 * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each */ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o= 0; --i) { + var line = stack[i]; + if (!nodeFramePattern.test(line)) { + var lineMatches = line.match(parseLinePattern); + if (lineMatches) { + handlerLine = "at " + lineMatches[1] + + ":" + lineMatches[2] + ":" + lineMatches[3] + " "; + } + break; + } + } + + if (stack.length > 0) { + var firstUserLine = stack[0]; + for (var i = 0; i < traceLines.length; ++i) { + + if (traceLines[i] === firstUserLine) { + if (i > 0) { + creatorLine = "\n" + traceLines[i - 1]; + } + break; + } + } + + } + } var msg = "a promise was created in a " + name + - "handler but was not returned from it"; + "handler " + handlerLine + "but was not returned from it, " + + "see http://goo.gl/rRqMUw" + + creatorLine; promise._warn(msg, true, promiseCreated); } } @@ -1525,7 +1574,7 @@ return { },{"./errors":12,"./util":36}],10:[function(_dereq_,module,exports){ "use strict"; -module.exports = function(Promise) { +module.exports = function(Promise, tryConvertToPromise) { function returner() { return this.value; } @@ -1535,6 +1584,7 @@ function thrower() { Promise.prototype["return"] = Promise.prototype.thenReturn = function (value) { + value = tryConvertToPromise(value); if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( returner, undefined, undefined, {value: value}, undefined); @@ -1559,11 +1609,13 @@ Promise.prototype.catchThrow = function (reason) { Promise.prototype.catchReturn = function (value) { if (arguments.length <= 1) { + value = tryConvertToPromise(value); if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( undefined, returner, undefined, {value: value}, undefined); } else { var _value = arguments[1]; + _value = tryConvertToPromise(_value); if (_value instanceof Promise) _value.suppressUnhandledRejections(); var handler = function() {return _value;}; return this.caught(value, handler); @@ -1878,7 +1930,7 @@ function finallyHandler(reasonOrValue) { var maybePromise = tryConvertToPromise(ret, promise); if (maybePromise instanceof Promise) { if (this.cancelPromise != null) { - if (maybePromise.isCancelled()) { + if (maybePromise._isCancelled()) { var reason = new CancellationError("late cancellation observer"); promise._attachExtraTrace(reason); @@ -2104,9 +2156,13 @@ PromiseSpawn.prototype._continue = function (result) { this._yieldedPromise = maybePromise; maybePromise._proxy(this, null); } else if (((bitField & 33554432) !== 0)) { - this._promiseFulfilled(maybePromise._value()); + Promise._async.invoke( + this._promiseFulfilled, this, maybePromise._value() + ); } else if (((bitField & 16777216) !== 0)) { - this._promiseRejected(maybePromise._reason()); + Promise._async.invoke( + this._promiseRejected, this, maybePromise._reason() + ); } else { this._promiseCancelled(); } @@ -2734,7 +2790,8 @@ Promise.prototype.caught = Promise.prototype["catch"] = function (fn) { if (util.isObject(item)) { catchInstances[j++] = item; } else { - return apiRejection("expecting an object but got " + util.classString(item)); + return apiRejection("expecting an object but got " + + "A catch statement predicate " + util.classString(item)); } } catchInstances.length = j; @@ -2959,6 +3016,10 @@ Promise.prototype._setCancelled = function() { this._fireEvent("promiseCancelled", this); }; +Promise.prototype._setWillBeCancelled = function() { + this._bitField = this._bitField | 8388608; +}; + Promise.prototype._setAsyncGuaranteed = function() { if (async.hasCustomScheduler()) return; this._bitField = this._bitField | 134217728; @@ -3360,12 +3421,12 @@ _dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug); _dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug); _dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug); -_dereq_("./direct_resolve")(Promise); +_dereq_("./direct_resolve")(Promise, tryConvertToPromise); _dereq_("./synchronous_inspection")(Promise); _dereq_("./join")( Promise, PromiseArray, tryConvertToPromise, INTERNAL, debug); Promise.Promise = Promise; -Promise.version = "3.4.0"; +Promise.version = "3.4.3"; _dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug); _dereq_('./call_get.js')(Promise); _dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug); @@ -3535,7 +3596,7 @@ PromiseArray.prototype._resolve = function (value) { }; PromiseArray.prototype._cancel = function() { - if (this._isResolved() || !this._promise.isCancellable()) return; + if (this._isResolved() || !this._promise._isCancellable()) return; this._values = null; this._promise._cancel(); }; @@ -4349,7 +4410,8 @@ if (util.isNode && typeof MutationObserver === "undefined") { schedule = util.isRecentNode ? function(fn) { GlobalSetImmediate.call(global, fn); } : function(fn) { ProcessNextTick.call(process, fn); }; -} else if (typeof NativePromise === "function") { +} else if (typeof NativePromise === "function" && + typeof NativePromise.resolve === "function") { var nativePromise = NativePromise.resolve(); schedule = function(fn) { nativePromise.then(fn); @@ -4643,13 +4705,20 @@ var isResolved = PromiseInspection.prototype.isResolved = function () { return (this._bitField & 50331648) !== 0; }; -PromiseInspection.prototype.isCancelled = -Promise.prototype._isCancelled = function() { +PromiseInspection.prototype.isCancelled = function() { + return (this._bitField & 8454144) !== 0; +}; + +Promise.prototype.__isCancelled = function() { return (this._bitField & 65536) === 65536; }; +Promise.prototype._isCancelled = function() { + return this._target().__isCancelled(); +}; + Promise.prototype.isCancelled = function() { - return this._target()._isCancelled(); + return (this._target()._bitField & 8454144) !== 0; }; Promise.prototype.isPending = function() { @@ -4808,6 +4877,7 @@ var delay = Promise.delay = function (ms, value) { if (debug.cancellation()) { ret._setOnCancel(new HandleWrapper(handle)); } + ret._captureStackTrace(); } ret._setAsyncGuaranteed(); return ret; diff --git a/tools/eslint/node_modules/bluebird/js/browser/bluebird.min.js b/tools/eslint/node_modules/bluebird/js/browser/bluebird.min.js index 86146d3ce6da88..0e1256d26d9cc6 100644 --- a/tools/eslint/node_modules/bluebird/js/browser/bluebird.min.js +++ b/tools/eslint/node_modules/bluebird/js/browser/bluebird.min.js @@ -23,9 +23,9 @@ * */ /** - * bluebird build version 3.4.1 + * bluebird build version 3.4.3 * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function i(s,a){if(!e[s]){if(!t[s]){var c="function"==typeof _dereq_&&_dereq_;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=e[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n?n:e)},u,u.exports,r,t,e,n)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s0;){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=a},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},s=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},a=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(o),u=new t(e);u._propagateFrom(this,1);var p=this._target();if(u._setBoundTo(l),l instanceof t){var h={promiseRejectionQueued:!1,promise:u,target:p,bindingPromise:l};p._then(e,s,void 0,u,h),l._then(a,c,void 0,u,h),u._setOnCancel(l)}else u._resolveCallback(p);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}e.exports=function(e){function n(t,n){var r;if(null!=t&&(r=t[n]),"function"!=typeof r){var i="Object "+a.classString(t)+" has no method '"+a.toString(n)+"'";throw new e.TypeError(i)}return r}function r(t){var e=this.pop(),r=n(t,e);return r.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var s,a=t("./util"),c=a.canEvaluate;a.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(r,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,n="number"==typeof t;if(n)e=o;else if(c){var r=s(t);e=null!==r?r:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),s=o.tryCatch,a=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t.isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n.isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this.isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,s=t._peekContext,a=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=s,t.prototype._peekContext=a,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,e){return{promise:e}}function i(){return!1}function o(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+H.toString(t));r._attachCancellationCallback(t)})}catch(i){return i}}function s(t){if(!this.isCancellable())return this;var e=this._onCancel();void 0!==e?H.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function a(){return this._onCancelField}function c(t){this._onCancelField=t}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function u(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function f(){this._trace=new S(this._peekContext())}function _(t,e){if(N(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=j(t);H.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),H.notEnumerableProp(t,"__stackCleaned__",!0)}}}function d(t,e,n,r,i){if(void 0===t&&null!==e&&z){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="a promise was created in a "+n+"handler but was not returned from it";r._warn(o,!0,e)}}function v(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),y(n)}function y(t,n,r){if(rt.warnings){var i,o=new L(t);if(n)r._attachExtraTrace(o);else if(rt.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var s=j(o);o.stack=s.message+"\n"+s.stack.join("\n")}Y("warning",o)||k(o,"",!0)}}function m(t,e){for(var n=0;n=0;--a)if(r[a]===o){s=a;break}for(var a=s;a>=0;--a){var c=r[a];if(e[i]!==c)break;e.pop(),i--}e=r}}function w(t){for(var e=[],n=0;n0&&(e=e.slice(n)),e}function j(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?C(t):[" (No stack trace)"],{message:n,stack:w(e)}}function k(t,e,n){if("undefined"!=typeof console){var r;if(H.isObject(t)){var i=t.stack;r=e+M(i,t)}else r=e+String(t);"function"==typeof D?D(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function E(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(o){I.throwLater(o)}"unhandledRejection"===t?Y(t,n,r)||i||k(n,"Unhandled rejection "):Y(t,r)}function F(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():H.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+x(e)+">, no stack trace)"}function x(t){var e=41;return t.lengths||0>a||!n||!r||n!==r||s>=a||(tt=function(t){if(U.test(t))return!0;var e=P(t);return e&&e.fileName===n&&s<=e.line&&e.line<=a?!0:!1})}}function S(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);nt(this,S),e>32&&this.uncycle()}var O,A,D,V=e._getDomain,I=e._async,L=t("./errors").Warning,H=t("./util"),N=H.canAttachTrace,U=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,B=null,M=null,q=!1,Q=!(0==H.env("BLUEBIRD_DEBUG")||!H.env("BLUEBIRD_DEBUG")&&"development"!==H.env("NODE_ENV")),$=!(0==H.env("BLUEBIRD_WARNINGS")||!Q&&!H.env("BLUEBIRD_WARNINGS")),G=!(0==H.env("BLUEBIRD_LONG_STACK_TRACES")||!Q&&!H.env("BLUEBIRD_LONG_STACK_TRACES")),z=0!=H.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&($||!!H.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),I.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){E("rejectionHandled",O,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),E("unhandledRejection",A,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return y(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var e=V();A="function"==typeof t?null===e?t:e.bind(t):void 0},e.onUnhandledRejectionHandled=function(t){var e=V();O="function"==typeof t?null===e?t:e.bind(t):void 0};var X=function(){};e.longStackTraces=function(){if(I.haveItemsQueued()&&!rt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!rt.longStackTraces&&T()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace;rt.longStackTraces=!0,X=function(){if(I.haveItemsQueued()&&!rt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,n.deactivateLongStackTraces(),I.enableTrampoline(),rt.longStackTraces=!1},e.prototype._captureStackTrace=f,e.prototype._attachExtraTrace=_,n.activateLongStackTraces(),I.disableTrampolineIfNecessary()}},e.hasLongStackTraces=function(){return rt.longStackTraces&&T()};var W=function(){try{var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),H.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!H.global.dispatchEvent(n)}}catch(e){}return function(){return!1}}(),K=function(){return H.isNode?function(){return process.emit.apply(process,arguments)}:H.global?function(t){var e="on"+t.toLowerCase(),n=H.global[e];return n?(n.apply(H.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),J={promiseCreated:r,promiseFulfilled:r,promiseRejected:r,promiseResolved:r,promiseCancelled:r,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:r},Y=function(t){var e=!1;try{e=K.apply(null,arguments)}catch(n){I.throwLater(n),e=!0}var r=!1;try{r=W(t,J[t].apply(null,arguments))}catch(n){I.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&X()),"warnings"in t){var n=t.warnings;rt.warnings=!!n,z=rt.warnings,H.isObject(n)&&"wForgottenReturn"in n&&(z=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!rt.cancellation){if(I.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=l,e.prototype._propagateFrom=u,e.prototype._onCancel=a,e.prototype._setOnCancel=c,e.prototype._attachCancellationCallback=s,e.prototype._execute=o,Z=u,rt.cancellation=!0}"monitoring"in t&&(t.monitoring&&!rt.monitoring?(rt.monitoring=!0,e.prototype._fireEvent=Y):!t.monitoring&&rt.monitoring&&(rt.monitoring=!1,e.prototype._fireEvent=i))},e.prototype._fireEvent=i,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var Z=p,tt=function(){return!1},et=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;H.inherits(S,Error),n.CapturedTrace=S,S.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;t>r;++r){var s=e[r].stack,a=n[s];if(void 0!==a&&a!==r){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>a?(c._parent=e[a+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var l=c._length+1,u=r-2;u>=0;--u)e[u]._length=l,l++;return}}}},S.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=j(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(w(i.stack.split("\n"))),i=i._parent;b(r),g(r),H.notEnumerableProp(t,"stack",m(n,r)),H.notEnumerableProp(t,"__stackCleaned__",!0)}};var nt=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():F(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,B=t,M=e;var n=Error.captureStackTrace;return tt=function(t){return U.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return B=/@/,M=e,q=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(M=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?F(e):e.toString()},null):(B=t,M=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(D=function(t){console.warn(t)},H.isNode&&process.stderr.isTTY?D=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:H.isNode||"string"!=typeof(new Error).stack||(D=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var rt={warnings:$,longStackTraces:!1,cancellation:!1,monitoring:!1};return G&&e.longStackTraces(),{longStackTraces:function(){return rt.longStackTraces},warnings:function(){return rt.warnings},cancellation:function(){return rt.cancellation},monitoring:function(){return rt.monitoring},propagateFromFunction:function(){return Z},boundValueFunction:function(){return h},checkForgottenReturns:d,setBounds:R,warn:y,deprecated:v,CapturedTrace:S,fireDomEvent:W,fireGlobalEvent:K}}},{"./errors":12,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return o(this)}function r(t,n){return i(t,n,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return this.mapSeries(t)._then(n,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,e){return r(t,e)._then(n,void 0,void 0,t,void 0)},t.mapSeries=r}},{}],12:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return u(n,Error),n}function i(t){return this instanceof i?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,s,a=t("./es5"),c=a.freeze,l=t("./util"),u=l.inherits,p=l.notEnumerableProp,h=r("Warning","warning"),f=r("CancellationError","cancellation error"),_=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(v){o=r("TypeError","type error"),s=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),m=0;m1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function s(){return c.call(this,this.promise._target()._settledValue())}function a(t){return o(this,t)?void 0:(p.e=t,p)}function c(t){var r=this.promise,c=this.handler;if(!this.called){this.called=!0;var l=this.isFinallyHandler()?c.call(r._boundValue()):c.call(r._boundValue(),t);if(void 0!==l){r._setReturnedNonUndefined();var h=n(l,r);if(h instanceof e){if(null!=this.cancelPromise){if(h.isCancelled()){var f=new u("late cancellation observer");return r._attachExtraTrace(f),p.e=f,p}h.isPending()&&h._attachCancellationCallback(new i(this))}return h._then(s,a,void 0,this,void 0)}}}return r.isRejected()?(o(this),p.e=t,p):(o(this),t)}var l=t("./util"),u=e.CancellationError,p=l.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,i){return"function"!=typeof t?this.then():this._then(n,i,void 0,new r(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,c,c)},e.prototype.tap=function(t){return this._passThrough(t,1,c)},r}},{"./util":36}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r){for(var o=0;o0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var i=l();this._callback=null===i?e:i.bind(e), -this._preservedValues=r===o?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=n>=1?[]:f,this._init$(void 0,-2)}function c(t,n,i,o){if("function"!=typeof n)return r("expecting a function but got "+u.classString(n));var s=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+u.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+u.classString(i.concurrency)));s=i.concurrency}return s="number"==typeof s&&isFinite(s)&&s>=1?s:0,new a(t,n,s,o).promise()}var l=e._getDomain,u=t("./util"),p=u.tryCatch,h=u.errorObj,f=[];u.inherits(a,n),a.prototype._init=function(){},a.prototype._promiseFulfilled=function(t,n){var r=this._values,o=this.length(),a=this._preservedValues,c=this._limit;if(0>n){if(n=-1*n-1,r[n]=t,c>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(c>=1&&this._inFlight>=c)return r[n]=t,this._queue.push(n),!1;null!==a&&(a[n]=t);var l=this._promise,u=this._callback,f=l._boundValue();l._pushContext();var _=p(u).call(f,t,n,o),d=l._popContext();if(s.checkForgottenReturns(_,d,null!==a?"Promise.filter":"Promise.map",l),_===h)return this._reject(_.e),!0;var v=i(_,this._promise);if(v instanceof e){v=v._target();var y=v._bitField;if(0===(50397184&y))return c>=1&&this._inFlight++,r[n]=v,v._proxy(this,-1*(n+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(v._reason()),!0):(this._cancel(),!0);_=v._value()}r[n]=_}var m=++this._totalResolved;return m>=o?(null!==a?this._filter(r,a):this._resolve(r),!0):!1},a.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(r[i++]=e[o]);r.length=i,this._resolve(r)},a.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return c(this,t,e,null)},e.map=function(t,e,n,r){return c(t,e,n,r)}}},{"./util":36}],19:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var s=t("./util"),a=s.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+s.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var i=a(t).apply(this,arguments),s=r._popContext();return o.checkForgottenReturns(i,s,"Promise.method",r),r._resolveFromSyncValue(i),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+s.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],u=arguments[2];c=s.isArray(l)?a(t).apply(u,l):a(t).call(u,l)}else c=a(t)();var p=r._popContext();return o.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===s.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&u.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=u.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;e-1>n;++n){var o=arguments[n];if(!f.isObject(o))return p("expecting an object but got "+f.classString(o));r[i++]=o}return r.length=i,t=arguments[n],this.then(void 0,P(r,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(u,u,void 0,this,void 0)},i.prototype.then=function(t,e){if(x.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+f.classString(t);arguments.length>1&&(n+=", "+f.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?p("expecting a function but got "+f.classString(t)):this.all()._then(t,void 0,void 0,w,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new k(this).promise()},i.prototype.error=function(t){return this.caught(f.originatesFromRejection,t)},i.getNewLibraryCopy=e.exports,i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(b);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=O(t)(R(e,n));return r===S&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new k(t).promise()},i.cast=function(t){var e=j(t);return e instanceof i||(e=new i(b),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(b);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new m("expecting a function but got "+f.classString(t));return v.setScheduler(t)},i.prototype._then=function(t,e,n,r,o){var s=void 0!==o,a=s?o:new i(b),l=this._target(),u=l._bitField;s||(a._propagateFrom(this,3),a._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&u)?this._boundValue():l===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,a));var p=c();if(0!==(50397184&u)){var h,f,_=l._settlePromiseCtx;0!==(33554432&u)?(f=l._rejectionHandler0,h=t):0!==(16777216&u)?(f=l._fulfillmentHandler0,h=e,l._unsetRejectionIsUnhandled()):(_=l._settlePromiseLateCancellationObserver,f=new g("late cancellation observer"),l._attachExtraTrace(f),h=e),v.invoke(_,l,{handler:null===p?h:"function"==typeof h&&p.bind(h),promise:a,receiver:r,value:f})}else l._addCallbacks(t,e,a,r,p);return a},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setAsyncGuaranteed=function(){v.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===h?void 0:void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=h),this._addCallbacks(e,n,r,i,null)},i.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=h),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(t,e,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:i.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:i.bind(e));else{var s=4*o-4;this[s+2]=n,this[s+3]=r,"function"==typeof t&&(this[s+0]=null===i?t:i.bind(t)),"function"==typeof e&&(this[s+1]=null===i?e:i.bind(e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(l(),!1);var n=j(t,this);if(!(n instanceof i))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(l());var o=r._bitField;if(0===(50397184&o)){var s=this._length();s>0&&r._migrateCallback0(this);for(var a=1;s>a;++a)r._migrateCallbackAt(this,a);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var c=new g("late cancellation observer");r._attachExtraTrace(c),this._reject(c)}}},i.prototype._rejectCallback=function(t,e,n){var r=f.ensureErrorObject(t),i=r===t;if(!i&&!n&&x.warnings()){var o="a promise was rejected with a non-error: "+f.classString(t);this._warn(o,!0)}this._attachExtraTrace(r,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)},i.prototype._settlePromiseFromHandler=function(t,e,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;e===w?n&&"number"==typeof n.length?o=O(t).apply(this._boundValue(),n):(o=S,o.e=new m("cannot .spread() a non-array: "+f.classString(n))):o=O(t).call(e,n);var s=r._popContext();i=r._bitField,0===(65536&i)&&(o===C?r._reject(n):o===S?r._rejectCallback(o.e,!1):(x.checkForgottenReturns(o,s,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,r,o){var s=t instanceof i,a=this._bitField,c=0!==(134217728&a);0!==(65536&a)?(s&&t._invokeInternalOnCancel(),r instanceof T&&r.isFinallyHandler()?(r.cancelPromise=t,O(e).call(r,o)===S&&t._reject(S.e)):e===u?t._fulfill(u.call(r)):r instanceof n?r._promiseCancelled(t):s||t instanceof k?t._cancel():r.cancel()):"function"==typeof e?s?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,o,t)):e.call(r,o,t):r instanceof n?r._isResolved()||(0!==(33554432&a)?r._promiseFulfilled(o,t):r._promiseRejected(o,t)):s&&(c&&t._setAsyncGuaranteed(),0!==(33554432&a)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof i?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=l();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():v.settlePromises(this))}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?v.fatalError(t,f.isNode):void((65535&e)>0?v.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){x.deprecated("Promise.defer","new Promise");var t=new i(b);return{promise:t,resolve:o,reject:s}},f.notEnumerableProp(i,"_makeSelfResolutionError",l),t("./method")(i,b,j,p,x),t("./bind")(i,b,j,x),t("./cancel")(i,k,p,x),t("./direct_resolve")(i),t("./synchronous_inspection")(i),t("./join")(i,k,j,b,x),i.Promise=i,i.version="3.4.0",t("./map.js")(i,k,p,j,b,x),t("./call_get.js")(i),t("./using.js")(i,p,j,F,b,x),t("./timers.js")(i,b,x),t("./generators.js")(i,p,b,j,n,x),t("./nodeify.js")(i),t("./promisify.js")(i,b),t("./props.js")(i,k,j,p),t("./race.js")(i,b,j,p),t("./reduce.js")(i,k,p,j,b,x),t("./settle.js")(i,k,x),t("./some.js")(i,k,p),t("./filter.js")(i,b),t("./each.js")(i,b),t("./any.js")(i),f.toFastProperties(i),f.toFastProperties(i.prototype),a({a:1}),a({b:2}),a({c:3}),a(1),a(function(){}),a(void 0),a(!1),a(new i(b)),x.setBounds(d.firstLineError,f.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){function s(t){switch(t){case-2:return[];case-3:return{}}}function a(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(a,o),a.prototype.length=function(){return this._length},a.prototype.promise=function(){return this._promise},a.prototype._init=function l(t,n){var o=r(this._values,this._promise);if(o instanceof e){o=o._target();var a=o._bitField;if(this._values=o,0===(50397184&a))return this._promise._setAsyncGuaranteed(),o._then(l,this._reject,void 0,this,n);if(0===(33554432&a))return 0!==(16777216&a)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var u=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(u,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(s(n))):void this._iterate(o)},a.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,s=null,a=0;n>a;++a){var c=r(t[a],i);c instanceof e?(c=c._target(),s=c._bitField):s=null,o?null!==s&&c.suppressUnhandledRejections():null!==s?0===(50397184&s)?(c._proxy(this,a),this._values[a]=c):o=0!==(33554432&s)?this._promiseFulfilled(c._value(),a):0!==(16777216&s)?this._promiseRejected(c._reason(),a):this._promiseCancelled(a):o=this._promiseFulfilled(c,a)}o||i._setAsyncGuaranteed()},a.prototype._isResolved=function(){return null===this._values},a.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},a.prototype._cancel=function(){!this._isResolved()&&this._promise.isCancellable()&&(this._values=null,this._promise._cancel())},a.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},a.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},a.prototype._promiseCancelled=function(){return this._cancel(),!0},a.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},a.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;nc;c+=2){var u=s[c],p=s[c+1],_=u+e;if(r===E)t[_]=E(u,h,u,p,e,i);else{var d=r(p,function(){return E(u,h,u,p,e,i)});f.notEnumerableProp(d,"__isPromisified__",!0),t[_]=d}}return f.toFastProperties(t),t}function u(t,e,n){return E(t,e,void 0,t,null,n)}var p,h={},f=t("./util"),_=t("./nodeback"),d=f.withAppended,v=f.maybeWrapAsError,y=f.canEvaluate,m=t("./errors").TypeError,g="Async",b={__isPromisified__:!0},w=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],C=new RegExp("^(?:"+w.join("|")+")$"),j=function(t){return f.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},k=function(t){return t.replace(/([$])/,"\\$")},E=y?p:c;e.promisify=function(t,e){if("function"!=typeof t)throw new m("expecting a function but got "+f.classString(t));if(i(t))return t;e=Object(e);var n=void 0===e.context?h:e.context,o=!!e.multiArgs,s=u(t,n,o);return f.copyDescriptors(t,s,r),s},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new m("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");e=Object(e);var n=!!e.multiArgs,r=e.suffix;"string"!=typeof r&&(r=g);var i=e.filter;"function"!=typeof i&&(i=j);var o=e.promisifier;if("function"!=typeof o&&(o=E),!f.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var s=f.inheritedDataKeys(t),a=0;ao;++o){var s=r[o];e[o]=t[s],e[o+i]=s}}this.constructor$(e),this._isMap=n,this._init$(void 0,-3)}function s(t){var n,s=r(t);return l(s)?(n=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&n._propagateFrom(s,2),n):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var a,c=t("./util"),l=c.isObject,u=t("./es5");"function"==typeof Map&&(a=Map);var p=function(){function t(t,r){this[e]=t,this[e+n]=r,e++}var e=0,n=0;return function(r){n=r.size,e=0;var i=new Array(2*r.size);return r.forEach(t,i),i}}(),h=function(t){for(var e=new a,n=t.length/2|0,r=0;n>r;++r){var i=t[n+r],o=t[r];e.set(i,o)}return e};c.inherits(o,n),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;if(n>=this._length){var r;if(this._isMap)r=h(this._values);else{r={};for(var i=this.length(),o=0,s=this.length();s>o;++o)r[this._values[o+i]]=this._values[o]}return this._resolve(r),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t,e,n,r,i){for(var o=0;i>o;++o)n[o+r]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityh;++h){var _=t[h];(void 0!==_||h in t)&&e.cast(_)._then(u,p,void 0,l,null)}return l}var s=t("./util"),a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r,i){this.constructor$(t);var s=h();this._fn=null===s?n:s.bind(n),void 0!==r&&(r=e.resolve(r),r._attachCancellationCallback(this)),this._initialValue=r,this._currentCancellable=null,this._eachValues=i===o?[]:void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function c(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function l(t,e,n,i){if("function"!=typeof e)return r("expecting a function but got "+f.classString(e));var o=new a(t,e,n,i);return o.promise()}function u(t){this.accum=t,this.array._gotAccum(t);var n=i(this.value,this.array._promise);return n instanceof e?(this.array._currentCancellable=n,n._then(p,void 0,void 0,this,void 0)):p.call(this,n)}function p(t){var n=this.array,r=n._promise,i=_(n._fn);r._pushContext();var o;o=void 0!==n._eachValues?i.call(r._boundValue(),t,this.index,this.length):i.call(r._boundValue(),this.accum,t,this.index,this.length),o instanceof e&&(n._currentCancellable=o);var a=r._popContext();return s.checkForgottenReturns(o,a,void 0!==n._eachValues?"Promise.each":"Promise.reduce",r),o}var h=e._getDomain,f=t("./util"),_=f.tryCatch;f.inherits(a,n),a.prototype._gotAccum=function(t){void 0!==this._eachValues&&t!==o&&this._eachValues.push(t)},a.prototype._eachComplete=function(t){return this._eachValues.push(t),this._eachValues},a.prototype._init=function(){},a.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},a.prototype.shouldCopyValues=function(){return!1},a.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},a.prototype._resultCancelled=function(t){return t===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof e&&this._currentCancellable.cancel(),this._initialValue instanceof e&&this._initialValue.cancel()))},a.prototype._iterate=function(t){this._values=t;var n,r,i=t.length;if(void 0!==this._initialValue?(n=this._initialValue,r=0):(n=e.resolve(t[0]),r=1),this._currentCancellable=n,!n.isRejected())for(;i>r;++r){var o={accum:null,value:t[r],index:r,length:i,array:this};n=n._then(u,void 0,void 0,o,void 0)}void 0!==this._eachValues&&(n=n._then(this._eachComplete,void 0,void 0,this,void 0)),n._then(c,c,void 0,n,this)},e.prototype.reduce=function(t,e){return l(this,t,e,null)},e.reduce=function(t,e,n,r){return l(t,e,n,r)}}},{"./util":36}],29:[function(t,e,n){"use strict";var r,i=t("./util"),o=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},s=i.getNativePromise();if(i.isNode&&"undefined"==typeof MutationObserver){var a=global.setImmediate,c=process.nextTick;r=i.isRecentNode?function(t){a.call(global,t)}:function(t){c.call(process,t)}}else if("function"==typeof s){var l=s.resolve();r=function(t){l.then(t)}}else r="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?"undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:o:function(){var t=document.createElement("div"),e={attributes:!0},n=!1,r=document.createElement("div"),i=new MutationObserver(function(){t.classList.toggle("foo"),n=!1});i.observe(r,e);var o=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(t,e),o()}}();e.exports=r},{"./util":36}],30:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t)}var o=e.PromiseInspection,s=t("./util");s.inherits(i,n),i.prototype._promiseResolved=function(t,e){this._values[t]=e;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(t,e){var n=new o;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},i.prototype._promiseRejected=function(t,e){var n=new o;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new i(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new i(t),o=n.promise();return n.setHowMany(e),n.init(),o}var s=t("./util"),a=t("./errors").RangeError,c=t("./errors").AggregateError,l=s.isArray,u={};s.inherits(i,n),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=l(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(u),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new c,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=t.prototype._isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype.isCancelled=function(){return this._target()._isCancelled()},t.prototype.isPending=function(){return s.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return a.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,r){if(u(t)){if(t instanceof e)return t;var i=o(t);if(i===l){r&&r._pushContext();var c=e.reject(i.e);return r&&r._popContext(),c}if("function"==typeof i){if(s(t)){var c=new e(n);return t._then(c._fulfill,c._reject,void 0,c,null),c}return a(t,i,r)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return l.e=e,l}}function s(t){try{return p.call(t,"_promise0")}catch(e){return!1}}function a(t,r,i){function o(t){a&&(a._resolveCallback(t),a=null)}function s(t){a&&(a._rejectCallback(t,p,!0),a=null)}var a=new e(n),u=a;i&&i._pushContext(),a._captureStackTrace(),i&&i._popContext();var p=!0,h=c.tryCatch(r).call(t,o,s);return p=!1,a&&h===l&&(a._rejectCallback(h.e,!0,!0),a=null),u}var c=t("./util"),l=c.errorObj,u=c.isObject,p={}.hasOwnProperty;return r}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.handle=t}function o(t){return clearTimeout(this.handle),t}function s(t){throw clearTimeout(this.handle),t}var a=t("./util"),c=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var l=function(t){return u(+this).thenReturn(t)},u=e.delay=function(t,o){var s,a;return void 0!==o?(s=e.resolve(o)._then(l,null,null,t,void 0),r.cancellation()&&o instanceof e&&s._setOnCancel(o)):(s=new e(n),a=setTimeout(function(){s._fulfill()},+t),r.cancellation()&&s._setOnCancel(new i(a))),s._setAsyncGuaranteed(),s};e.prototype.delay=function(t){return u(t,this)};var p=function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new c("operation timed out"):new c(e),a.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()};e.prototype.timeout=function(t,e){t=+t;var n,a,c=new i(setTimeout(function(){n.isPending()&&p(n,e,a)},t));return r.cancellation()?(a=this.then(),n=a._then(o,s,void 0,c,void 0),n._setOnCancel(c)):n=this._then(o,s,void 0,c,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t){setTimeout(function(){throw t},0)}function c(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function l(t,n){function i(){if(s>=l)return u._fulfill();var o=c(t[s++]);if(o instanceof e&&o._isDisposable()){try{o=r(o._getDisposer().tryDispose(n),t.promise)}catch(p){return a(p)}if(o instanceof e)return o._then(i,a,null,null,null)}i()}var s=0,l=t.length,u=new e(o);return i(),u}function u(t,e,n){this._data=t,this._promise=e,this._context=n}function p(t,e,n){this.constructor$(t,e,n)}function h(t){return u.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function f(t){this.length=t,this.promise=null,this[t-1]=null}var _=t("./util"),d=t("./errors").TypeError,v=t("./util").inherits,y=_.errorObj,m=_.tryCatch,g={};u.prototype.data=function(){return this._data},u.prototype.promise=function(){return this._promise},u.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():g},u.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==g?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},u.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},v(p,u),p.prototype.doDispose=function(t,e){var n=this.data();return n.call(t,t,e)},f.prototype._resultCancelled=function(){for(var t=this.length,n=0;t>n;++n){var r=this[n];r instanceof e&&r.cancel()}},e.using=function(){var t=arguments.length;if(2>t)return n("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return n("expecting a function but got "+_.classString(i));var o,a=!0;2===t&&Array.isArray(arguments[0])?(o=arguments[0],t=o.length,a=!1):(o=arguments,t--);for(var c=new f(t),p=0;t>p;++p){var d=o[p];if(u.isDisposer(d)){var v=d;d=d.promise(),d._setDisposable(v)}else{var g=r(d);g instanceof e&&(d=g._then(h,null,null,{resources:c,index:p},void 0))}c[p]=d}for(var b=new Array(c.length),p=0;p0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new d}}},{"./errors":12,"./util":36}],36:[function(t,e,n){"use strict";function r(){try{var t=T;return T=null,t.apply(this,arguments)}catch(e){return x.e=e,x}}function i(t){return T=t,r}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}function a(t){return o(t)?new Error(v(t)):t}function c(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;r>n;++n)i[n]=t[n];return i[n]=e,i}function l(t,e,n){if(!E.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function u(t,e,n){if(o(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return E.defineProperty(t,e,r),t}function p(t){throw t}function h(t){try{if("function"==typeof t){var e=E.names(t.prototype),n=E.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=O.test(t+"")&&E.names(t).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function f(t){function e(){}e.prototype=t;for(var n=8;n--;)new e;return t}function _(t){return A.test(t)}function d(t,e,n){for(var r=new Array(t),i=0;t>i;++i)r[i]=e+i+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function m(t){try{u(t,"isOperational",!0)}catch(e){}}function g(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&E.propertyIsWritable(t,"stack")}function w(t){return{}.toString.call(t)}function C(t,e,n){for(var r=E.names(t),i=0;i10||t[0]>0}(),H.isNode&&H.toFastProperties(process);try{throw new Error}catch(N){H.lastLineError=N}e.exports=H},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function i(s,a){if(!e[s]){if(!t[s]){var c="function"==typeof _dereq_&&_dereq_;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=e[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n?n:e)},u,u.exports,r,t,e,n)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s0;){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=a},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},s=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},a=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(o),u=new t(e);u._propagateFrom(this,1);var p=this._target();if(u._setBoundTo(l),l instanceof t){var h={promiseRejectionQueued:!1,promise:u,target:p,bindingPromise:l};p._then(e,s,void 0,u,h),l._then(a,c,void 0,u,h),u._setOnCancel(l)}else u._resolveCallback(p);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}e.exports=function(e){function n(t,n){var r;if(null!=t&&(r=t[n]),"function"!=typeof r){var i="Object "+a.classString(t)+" has no method '"+a.toString(n)+"'";throw new e.TypeError(i)}return r}function r(t){var e=this.pop(),r=n(t,e);return r.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var s,a=t("./util"),c=a.canEvaluate;a.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(r,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,n="number"==typeof t;if(n)e=o;else if(c){var r=s(t);e=null!==r?r:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),s=o.tryCatch,a=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,s=t._peekContext,a=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=s,t.prototype._peekContext=a,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,e){return{promise:e}}function i(){return!1}function o(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+H.toString(t));r._attachCancellationCallback(t)})}catch(i){return i}}function s(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?H.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function a(){return this._onCancelField}function c(t){this._onCancelField=t}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function u(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function f(){this._trace=new S(this._peekContext())}function _(t,e){if(N(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=j(t);H.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),H.notEnumerableProp(t,"__stackCleaned__",!0)}}}function d(t,e,n,r,i){if(void 0===t&&null!==e&&W){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="",s="";if(e._trace){for(var a=e._trace.stack.split("\n"),c=w(a),l=c.length-1;l>=0;--l){var u=c[l];if(!B.test(u)){var p=u.match(M);p&&(o="at "+p[1]+":"+p[2]+":"+p[3]+" ");break}}if(c.length>0)for(var h=c[0],l=0;l0&&(s="\n"+a[l-1]);break}}var f="a promise was created in a "+n+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+s;r._warn(f,!0,e)}}function v(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),y(n)}function y(t,n,r){if(ot.warnings){var i,o=new I(t);if(n)r._attachExtraTrace(o);else if(ot.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var s=j(o);o.stack=s.message+"\n"+s.stack.join("\n")}tt("warning",o)||k(o,"",!0)}}function g(t,e){for(var n=0;n=0;--a)if(r[a]===o){s=a;break}for(var a=s;a>=0;--a){var c=r[a];if(e[i]!==c)break;e.pop(),i--}e=r}}function w(t){for(var e=[],n=0;n0&&(e=e.slice(n)),e}function j(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?C(t):[" (No stack trace)"],{message:n,stack:w(e)}}function k(t,e,n){if("undefined"!=typeof console){var r;if(H.isObject(t)){var i=t.stack;r=e+Q(i,t)}else r=e+String(t);"function"==typeof D?D(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function E(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(o){L.throwLater(o)}"unhandledRejection"===t?tt(t,n,r)||i||k(n,"Unhandled rejection "):tt(t,r)}function F(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():H.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+x(e)+">, no stack trace)"}function x(t){var e=41;return t.lengths||0>a||!n||!r||n!==r||s>=a||(nt=function(t){if(U.test(t))return!0;var e=P(t);return e&&e.fileName===n&&s<=e.line&&e.line<=a?!0:!1})}}function S(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);it(this,S),e>32&&this.uncycle()}var O,A,D,V=e._getDomain,L=e._async,I=t("./errors").Warning,H=t("./util"),N=H.canAttachTrace,U=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,B=/\((?:timers\.js):\d+:\d+\)/,M=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,q=null,Q=null,$=!1,G=!(0==H.env("BLUEBIRD_DEBUG")||!H.env("BLUEBIRD_DEBUG")&&"development"!==H.env("NODE_ENV")),z=!(0==H.env("BLUEBIRD_WARNINGS")||!G&&!H.env("BLUEBIRD_WARNINGS")),X=!(0==H.env("BLUEBIRD_LONG_STACK_TRACES")||!G&&!H.env("BLUEBIRD_LONG_STACK_TRACES")),W=0!=H.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(z||!!H.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),L.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){E("rejectionHandled",O,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),E("unhandledRejection",A,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return y(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var e=V();A="function"==typeof t?null===e?t:e.bind(t):void 0},e.onUnhandledRejectionHandled=function(t){var e=V();O="function"==typeof t?null===e?t:e.bind(t):void 0};var K=function(){};e.longStackTraces=function(){if(L.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ot.longStackTraces&&T()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace;ot.longStackTraces=!0,K=function(){if(L.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,n.deactivateLongStackTraces(),L.enableTrampoline(),ot.longStackTraces=!1},e.prototype._captureStackTrace=f,e.prototype._attachExtraTrace=_,n.activateLongStackTraces(),L.disableTrampolineIfNecessary()}},e.hasLongStackTraces=function(){return ot.longStackTraces&&T()};var J=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return H.global.dispatchEvent(t),function(t,e){var n=new CustomEvent(t.toLowerCase(),e);return!H.global.dispatchEvent(n)}}var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),H.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!H.global.dispatchEvent(n)}}catch(e){}return function(){return!1}}(),Y=function(){return H.isNode?function(){return process.emit.apply(process,arguments)}:H.global?function(t){var e="on"+t.toLowerCase(),n=H.global[e];return n?(n.apply(H.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),Z={promiseCreated:r,promiseFulfilled:r,promiseRejected:r,promiseResolved:r,promiseCancelled:r,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:r},tt=function(t){var e=!1;try{e=Y.apply(null,arguments)}catch(n){L.throwLater(n),e=!0}var r=!1;try{r=J(t,Z[t].apply(null,arguments))}catch(n){L.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&K()),"warnings"in t){var n=t.warnings;ot.warnings=!!n,W=ot.warnings,H.isObject(n)&&"wForgottenReturn"in n&&(W=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!ot.cancellation){if(L.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=l,e.prototype._propagateFrom=u,e.prototype._onCancel=a,e.prototype._setOnCancel=c,e.prototype._attachCancellationCallback=s,e.prototype._execute=o,et=u,ot.cancellation=!0}"monitoring"in t&&(t.monitoring&&!ot.monitoring?(ot.monitoring=!0,e.prototype._fireEvent=tt):!t.monitoring&&ot.monitoring&&(ot.monitoring=!1,e.prototype._fireEvent=i))},e.prototype._fireEvent=i,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var et=p,nt=function(){return!1},rt=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;H.inherits(S,Error),n.CapturedTrace=S,S.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;t>r;++r){var s=e[r].stack,a=n[s];if(void 0!==a&&a!==r){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>a?(c._parent=e[a+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var l=c._length+1,u=r-2;u>=0;--u)e[u]._length=l,l++;return}}}},S.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=j(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(w(i.stack.split("\n"))),i=i._parent;b(r),m(r),H.notEnumerableProp(t,"stack",g(n,r)),H.notEnumerableProp(t,"__stackCleaned__",!0)}};var it=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():F(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,q=t,Q=e;var n=Error.captureStackTrace;return nt=function(t){return U.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return q=/@/,Q=e,$=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(Q=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?F(e):e.toString()},null):(q=t,Q=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(D=function(t){console.warn(t)},H.isNode&&process.stderr.isTTY?D=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:H.isNode||"string"!=typeof(new Error).stack||(D=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var ot={warnings:z,longStackTraces:!1,cancellation:!1,monitoring:!1};return X&&e.longStackTraces(),{longStackTraces:function(){return ot.longStackTraces},warnings:function(){return ot.warnings},cancellation:function(){return ot.cancellation},monitoring:function(){return ot.monitoring},propagateFromFunction:function(){return et},boundValueFunction:function(){return h},checkForgottenReturns:d,setBounds:R,warn:y,deprecated:v,CapturedTrace:S,fireDomEvent:J,fireGlobalEvent:Y}}},{"./errors":12,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return this.value}function r(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(r){return r=e(r),r instanceof t&&r.suppressUnhandledRejections(),this._then(n,void 0,void 0,{value:r},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(r,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,r,void 0,{reason:t},void 0);var e=arguments[1],n=function(){throw e};return this.caught(t,n)},t.prototype.catchReturn=function(r){if(arguments.length<=1)return r=e(r),r instanceof t&&r.suppressUnhandledRejections(),this._then(void 0,n,void 0,{value:r},void 0);var i=arguments[1];i=e(i),i instanceof t&&i.suppressUnhandledRejections();var o=function(){return i};return this.caught(r,o)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return o(this)}function r(t,n){return i(t,n,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return this.mapSeries(t)._then(n,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,e){return r(t,e)._then(n,void 0,void 0,t,void 0)},t.mapSeries=r}},{}],12:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return u(n,Error),n}function i(t){return this instanceof i?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,s,a=t("./es5"),c=a.freeze,l=t("./util"),u=l.inherits,p=l.notEnumerableProp,h=r("Warning","warning"),f=r("CancellationError","cancellation error"),_=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(v){o=r("TypeError","type error"),s=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function s(){return c.call(this,this.promise._target()._settledValue())}function a(t){return o(this,t)?void 0:(p.e=t,p)}function c(t){var r=this.promise,c=this.handler;if(!this.called){this.called=!0;var l=this.isFinallyHandler()?c.call(r._boundValue()):c.call(r._boundValue(),t);if(void 0!==l){r._setReturnedNonUndefined();var h=n(l,r);if(h instanceof e){if(null!=this.cancelPromise){if(h._isCancelled()){var f=new u("late cancellation observer");return r._attachExtraTrace(f),p.e=f,p}h.isPending()&&h._attachCancellationCallback(new i(this))}return h._then(s,a,void 0,this,void 0)}}}return r.isRejected()?(o(this),p.e=t,p):(o(this),t)}var l=t("./util"),u=e.CancellationError,p=l.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,i){return"function"!=typeof t?this.then():this._then(n,i,void 0,new r(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,c,c)},e.prototype.tap=function(t){return this._passThrough(t,1,c)},r}},{"./util":36}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r){for(var o=0;o0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var i=l();this._callback=null===i?e:i.bind(e),this._preservedValues=r===o?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=n>=1?[]:f,this._init$(void 0,-2)}function c(t,n,i,o){if("function"!=typeof n)return r("expecting a function but got "+u.classString(n));var s=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+u.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+u.classString(i.concurrency)));s=i.concurrency}return s="number"==typeof s&&isFinite(s)&&s>=1?s:0,new a(t,n,s,o).promise()}var l=e._getDomain,u=t("./util"),p=u.tryCatch,h=u.errorObj,f=[];u.inherits(a,n),a.prototype._init=function(){},a.prototype._promiseFulfilled=function(t,n){var r=this._values,o=this.length(),a=this._preservedValues,c=this._limit;if(0>n){if(n=-1*n-1,r[n]=t,c>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(c>=1&&this._inFlight>=c)return r[n]=t,this._queue.push(n),!1;null!==a&&(a[n]=t);var l=this._promise,u=this._callback,f=l._boundValue();l._pushContext();var _=p(u).call(f,t,n,o),d=l._popContext();if(s.checkForgottenReturns(_,d,null!==a?"Promise.filter":"Promise.map",l),_===h)return this._reject(_.e),!0;var v=i(_,this._promise);if(v instanceof e){v=v._target();var y=v._bitField;if(0===(50397184&y))return c>=1&&this._inFlight++,r[n]=v,v._proxy(this,-1*(n+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(v._reason()),!0):(this._cancel(),!0);_=v._value()}r[n]=_}var g=++this._totalResolved;return g>=o?(null!==a?this._filter(r,a):this._resolve(r),!0):!1},a.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(r[i++]=e[o]);r.length=i,this._resolve(r)},a.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return c(this,t,e,null)},e.map=function(t,e,n,r){return c(t,e,n,r)}}},{"./util":36}],19:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var s=t("./util"),a=s.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+s.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var i=a(t).apply(this,arguments),s=r._popContext();return o.checkForgottenReturns(i,s,"Promise.method",r),r._resolveFromSyncValue(i),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+s.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],u=arguments[2];c=s.isArray(l)?a(t).apply(u,l):a(t).call(u,l)}else c=a(t)();var p=r._popContext();return o.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===s.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&u.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=u.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;e-1>n;++n){var o=arguments[n];if(!f.isObject(o))return p("expecting an object but got A catch statement predicate "+f.classString(o));r[i++]=o}return r.length=i,t=arguments[n],this.then(void 0,P(r,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(u,u,void 0,this,void 0)},i.prototype.then=function(t,e){if(x.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+f.classString(t);arguments.length>1&&(n+=", "+f.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?p("expecting a function but got "+f.classString(t)):this.all()._then(t,void 0,void 0,w,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new k(this).promise()},i.prototype.error=function(t){return this.caught(f.originatesFromRejection,t)},i.getNewLibraryCopy=e.exports,i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(b);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=O(t)(R(e,n));return r===S&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new k(t).promise()},i.cast=function(t){var e=j(t);return e instanceof i||(e=new i(b),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(b);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new g("expecting a function but got "+f.classString(t));return v.setScheduler(t)},i.prototype._then=function(t,e,n,r,o){var s=void 0!==o,a=s?o:new i(b),l=this._target(),u=l._bitField;s||(a._propagateFrom(this,3),a._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&u)?this._boundValue():l===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,a));var p=c();if(0!==(50397184&u)){var h,f,_=l._settlePromiseCtx;0!==(33554432&u)?(f=l._rejectionHandler0,h=t):0!==(16777216&u)?(f=l._fulfillmentHandler0,h=e,l._unsetRejectionIsUnhandled()):(_=l._settlePromiseLateCancellationObserver,f=new m("late cancellation observer"),l._attachExtraTrace(f),h=e),v.invoke(_,l,{handler:null===p?h:"function"==typeof h&&p.bind(h),promise:a,receiver:r,value:f})}else l._addCallbacks(t,e,a,r,p);return a},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},i.prototype._setAsyncGuaranteed=function(){v.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===h?void 0:void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=h),this._addCallbacks(e,n,r,i,null)},i.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=h),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(t,e,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:i.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:i.bind(e));else{var s=4*o-4;this[s+2]=n,this[s+3]=r,"function"==typeof t&&(this[s+0]=null===i?t:i.bind(t)),"function"==typeof e&&(this[s+1]=null===i?e:i.bind(e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(l(),!1);var n=j(t,this);if(!(n instanceof i))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(l());var o=r._bitField;if(0===(50397184&o)){var s=this._length();s>0&&r._migrateCallback0(this);for(var a=1;s>a;++a)r._migrateCallbackAt(this,a);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var c=new m("late cancellation observer");r._attachExtraTrace(c),this._reject(c)}}},i.prototype._rejectCallback=function(t,e,n){var r=f.ensureErrorObject(t),i=r===t;if(!i&&!n&&x.warnings()){var o="a promise was rejected with a non-error: "+f.classString(t);this._warn(o,!0)}this._attachExtraTrace(r,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)},i.prototype._settlePromiseFromHandler=function(t,e,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;e===w?n&&"number"==typeof n.length?o=O(t).apply(this._boundValue(),n):(o=S,o.e=new g("cannot .spread() a non-array: "+f.classString(n))):o=O(t).call(e,n);var s=r._popContext();i=r._bitField,0===(65536&i)&&(o===C?r._reject(n):o===S?r._rejectCallback(o.e,!1):(x.checkForgottenReturns(o,s,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,r,o){var s=t instanceof i,a=this._bitField,c=0!==(134217728&a);0!==(65536&a)?(s&&t._invokeInternalOnCancel(),r instanceof T&&r.isFinallyHandler()?(r.cancelPromise=t,O(e).call(r,o)===S&&t._reject(S.e)):e===u?t._fulfill(u.call(r)):r instanceof n?r._promiseCancelled(t):s||t instanceof k?t._cancel():r.cancel()):"function"==typeof e?s?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,o,t)):e.call(r,o,t):r instanceof n?r._isResolved()||(0!==(33554432&a)?r._promiseFulfilled(o,t):r._promiseRejected(o,t)):s&&(c&&t._setAsyncGuaranteed(),0!==(33554432&a)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof i?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=l();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():v.settlePromises(this))}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?v.fatalError(t,f.isNode):void((65535&e)>0?v.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){x.deprecated("Promise.defer","new Promise");var t=new i(b);return{promise:t,resolve:o,reject:s}},f.notEnumerableProp(i,"_makeSelfResolutionError",l),t("./method")(i,b,j,p,x),t("./bind")(i,b,j,x),t("./cancel")(i,k,p,x),t("./direct_resolve")(i,j),t("./synchronous_inspection")(i),t("./join")(i,k,j,b,x),i.Promise=i,i.version="3.4.3",t("./map.js")(i,k,p,j,b,x),t("./call_get.js")(i),t("./using.js")(i,p,j,F,b,x),t("./timers.js")(i,b,x),t("./generators.js")(i,p,b,j,n,x),t("./nodeify.js")(i),t("./promisify.js")(i,b),t("./props.js")(i,k,j,p),t("./race.js")(i,b,j,p),t("./reduce.js")(i,k,p,j,b,x),t("./settle.js")(i,k,x),t("./some.js")(i,k,p),t("./filter.js")(i,b),t("./each.js")(i,b),t("./any.js")(i),f.toFastProperties(i),f.toFastProperties(i.prototype),a({a:1}),a({b:2}),a({c:3}),a(1),a(function(){}),a(void 0),a(!1),a(new i(b)),x.setBounds(d.firstLineError,f.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){function s(t){switch(t){case-2:return[];case-3:return{}}}function a(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(a,o),a.prototype.length=function(){return this._length},a.prototype.promise=function(){return this._promise},a.prototype._init=function l(t,n){var o=r(this._values,this._promise);if(o instanceof e){o=o._target();var a=o._bitField;if(this._values=o,0===(50397184&a))return this._promise._setAsyncGuaranteed(),o._then(l,this._reject,void 0,this,n);if(0===(33554432&a))return 0!==(16777216&a)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var u=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(u,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(s(n))):void this._iterate(o)},a.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,s=null,a=0;n>a;++a){var c=r(t[a],i);c instanceof e?(c=c._target(),s=c._bitField):s=null,o?null!==s&&c.suppressUnhandledRejections():null!==s?0===(50397184&s)?(c._proxy(this,a),this._values[a]=c):o=0!==(33554432&s)?this._promiseFulfilled(c._value(),a):0!==(16777216&s)?this._promiseRejected(c._reason(),a):this._promiseCancelled(a):o=this._promiseFulfilled(c,a)}o||i._setAsyncGuaranteed()},a.prototype._isResolved=function(){return null===this._values},a.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},a.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},a.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},a.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},a.prototype._promiseCancelled=function(){return this._cancel(),!0},a.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},a.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;nc;c+=2){var u=s[c],p=s[c+1],_=u+e;if(r===E)t[_]=E(u,h,u,p,e,i);else{var d=r(p,function(){return E(u,h,u,p,e,i)});f.notEnumerableProp(d,"__isPromisified__",!0),t[_]=d}}return f.toFastProperties(t),t}function u(t,e,n){return E(t,e,void 0,t,null,n)}var p,h={},f=t("./util"),_=t("./nodeback"),d=f.withAppended,v=f.maybeWrapAsError,y=f.canEvaluate,g=t("./errors").TypeError,m="Async",b={__isPromisified__:!0},w=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],C=new RegExp("^(?:"+w.join("|")+")$"),j=function(t){return f.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},k=function(t){return t.replace(/([$])/,"\\$")},E=y?p:c;e.promisify=function(t,e){if("function"!=typeof t)throw new g("expecting a function but got "+f.classString(t));if(i(t))return t;e=Object(e);var n=void 0===e.context?h:e.context,o=!!e.multiArgs,s=u(t,n,o);return f.copyDescriptors(t,s,r),s},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");e=Object(e);var n=!!e.multiArgs,r=e.suffix;"string"!=typeof r&&(r=m);var i=e.filter;"function"!=typeof i&&(i=j);var o=e.promisifier;if("function"!=typeof o&&(o=E),!f.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var s=f.inheritedDataKeys(t),a=0;ao;++o){var s=r[o];e[o]=t[s],e[o+i]=s}}this.constructor$(e),this._isMap=n,this._init$(void 0,-3)}function s(t){var n,s=r(t);return l(s)?(n=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&n._propagateFrom(s,2),n):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var a,c=t("./util"),l=c.isObject,u=t("./es5");"function"==typeof Map&&(a=Map);var p=function(){function t(t,r){this[e]=t,this[e+n]=r,e++}var e=0,n=0;return function(r){n=r.size,e=0;var i=new Array(2*r.size);return r.forEach(t,i),i}}(),h=function(t){for(var e=new a,n=t.length/2|0,r=0;n>r;++r){var i=t[n+r],o=t[r];e.set(i,o)}return e};c.inherits(o,n),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;if(n>=this._length){var r;if(this._isMap)r=h(this._values);else{r={};for(var i=this.length(),o=0,s=this.length();s>o;++o)r[this._values[o+i]]=this._values[o]}return this._resolve(r),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t,e,n,r,i){for(var o=0;i>o;++o)n[o+r]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityh;++h){var _=t[h];(void 0!==_||h in t)&&e.cast(_)._then(u,p,void 0,l,null)}return l}var s=t("./util"),a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r,i){this.constructor$(t);var s=h();this._fn=null===s?n:s.bind(n),void 0!==r&&(r=e.resolve(r),r._attachCancellationCallback(this)),this._initialValue=r,this._currentCancellable=null,this._eachValues=i===o?[]:void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function c(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function l(t,e,n,i){if("function"!=typeof e)return r("expecting a function but got "+f.classString(e));var o=new a(t,e,n,i);return o.promise()}function u(t){this.accum=t,this.array._gotAccum(t);var n=i(this.value,this.array._promise);return n instanceof e?(this.array._currentCancellable=n,n._then(p,void 0,void 0,this,void 0)):p.call(this,n)}function p(t){var n=this.array,r=n._promise,i=_(n._fn);r._pushContext();var o;o=void 0!==n._eachValues?i.call(r._boundValue(),t,this.index,this.length):i.call(r._boundValue(),this.accum,t,this.index,this.length),o instanceof e&&(n._currentCancellable=o);var a=r._popContext();return s.checkForgottenReturns(o,a,void 0!==n._eachValues?"Promise.each":"Promise.reduce",r),o}var h=e._getDomain,f=t("./util"),_=f.tryCatch;f.inherits(a,n),a.prototype._gotAccum=function(t){void 0!==this._eachValues&&t!==o&&this._eachValues.push(t)},a.prototype._eachComplete=function(t){return this._eachValues.push(t),this._eachValues},a.prototype._init=function(){},a.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},a.prototype.shouldCopyValues=function(){return!1},a.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},a.prototype._resultCancelled=function(t){return t===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof e&&this._currentCancellable.cancel(),this._initialValue instanceof e&&this._initialValue.cancel()))},a.prototype._iterate=function(t){this._values=t;var n,r,i=t.length;if(void 0!==this._initialValue?(n=this._initialValue,r=0):(n=e.resolve(t[0]),r=1),this._currentCancellable=n,!n.isRejected())for(;i>r;++r){var o={accum:null,value:t[r],index:r,length:i,array:this};n=n._then(u,void 0,void 0,o,void 0)}void 0!==this._eachValues&&(n=n._then(this._eachComplete,void 0,void 0,this,void 0)),n._then(c,c,void 0,n,this)},e.prototype.reduce=function(t,e){return l(this,t,e,null)},e.reduce=function(t,e,n,r){return l(t,e,n,r)}}},{"./util":36}],29:[function(t,e,n){"use strict";var r,i=t("./util"),o=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},s=i.getNativePromise();if(i.isNode&&"undefined"==typeof MutationObserver){var a=global.setImmediate,c=process.nextTick;r=i.isRecentNode?function(t){a.call(global,t)}:function(t){c.call(process,t)}}else if("function"==typeof s&&"function"==typeof s.resolve){var l=s.resolve();r=function(t){l.then(t)}}else r="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?"undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:o:function(){var t=document.createElement("div"),e={attributes:!0},n=!1,r=document.createElement("div"),i=new MutationObserver(function(){t.classList.toggle("foo"),n=!1});i.observe(r,e);var o=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(t,e),o()}}();e.exports=r},{"./util":36}],30:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t)}var o=e.PromiseInspection,s=t("./util");s.inherits(i,n),i.prototype._promiseResolved=function(t,e){this._values[t]=e;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(t,e){var n=new o;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},i.prototype._promiseRejected=function(t,e){var n=new o;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new i(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new i(t),o=n.promise();return n.setHowMany(e),n.init(),o}var s=t("./util"),a=t("./errors").RangeError,c=t("./errors").AggregateError,l=s.isArray,u={};s.inherits(i,n),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=l(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length())); +}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(u),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new c,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!==(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!==(8454144&this._target()._bitField)},t.prototype.isPending=function(){return s.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return a.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,r){if(u(t)){if(t instanceof e)return t;var i=o(t);if(i===l){r&&r._pushContext();var c=e.reject(i.e);return r&&r._popContext(),c}if("function"==typeof i){if(s(t)){var c=new e(n);return t._then(c._fulfill,c._reject,void 0,c,null),c}return a(t,i,r)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return l.e=e,l}}function s(t){try{return p.call(t,"_promise0")}catch(e){return!1}}function a(t,r,i){function o(t){a&&(a._resolveCallback(t),a=null)}function s(t){a&&(a._rejectCallback(t,p,!0),a=null)}var a=new e(n),u=a;i&&i._pushContext(),a._captureStackTrace(),i&&i._popContext();var p=!0,h=c.tryCatch(r).call(t,o,s);return p=!1,a&&h===l&&(a._rejectCallback(h.e,!0,!0),a=null),u}var c=t("./util"),l=c.errorObj,u=c.isObject,p={}.hasOwnProperty;return r}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.handle=t}function o(t){return clearTimeout(this.handle),t}function s(t){throw clearTimeout(this.handle),t}var a=t("./util"),c=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var l=function(t){return u(+this).thenReturn(t)},u=e.delay=function(t,o){var s,a;return void 0!==o?(s=e.resolve(o)._then(l,null,null,t,void 0),r.cancellation()&&o instanceof e&&s._setOnCancel(o)):(s=new e(n),a=setTimeout(function(){s._fulfill()},+t),r.cancellation()&&s._setOnCancel(new i(a)),s._captureStackTrace()),s._setAsyncGuaranteed(),s};e.prototype.delay=function(t){return u(t,this)};var p=function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new c("operation timed out"):new c(e),a.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()};e.prototype.timeout=function(t,e){t=+t;var n,a,c=new i(setTimeout(function(){n.isPending()&&p(n,e,a)},t));return r.cancellation()?(a=this.then(),n=a._then(o,s,void 0,c,void 0),n._setOnCancel(c)):n=this._then(o,s,void 0,c,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t){setTimeout(function(){throw t},0)}function c(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function l(t,n){function i(){if(s>=l)return u._fulfill();var o=c(t[s++]);if(o instanceof e&&o._isDisposable()){try{o=r(o._getDisposer().tryDispose(n),t.promise)}catch(p){return a(p)}if(o instanceof e)return o._then(i,a,null,null,null)}i()}var s=0,l=t.length,u=new e(o);return i(),u}function u(t,e,n){this._data=t,this._promise=e,this._context=n}function p(t,e,n){this.constructor$(t,e,n)}function h(t){return u.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function f(t){this.length=t,this.promise=null,this[t-1]=null}var _=t("./util"),d=t("./errors").TypeError,v=t("./util").inherits,y=_.errorObj,g=_.tryCatch,m={};u.prototype.data=function(){return this._data},u.prototype.promise=function(){return this._promise},u.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():m},u.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==m?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},u.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},v(p,u),p.prototype.doDispose=function(t,e){var n=this.data();return n.call(t,t,e)},f.prototype._resultCancelled=function(){for(var t=this.length,n=0;t>n;++n){var r=this[n];r instanceof e&&r.cancel()}},e.using=function(){var t=arguments.length;if(2>t)return n("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return n("expecting a function but got "+_.classString(i));var o,a=!0;2===t&&Array.isArray(arguments[0])?(o=arguments[0],t=o.length,a=!1):(o=arguments,t--);for(var c=new f(t),p=0;t>p;++p){var d=o[p];if(u.isDisposer(d)){var v=d;d=d.promise(),d._setDisposable(v)}else{var m=r(d);m instanceof e&&(d=m._then(h,null,null,{resources:c,index:p},void 0))}c[p]=d}for(var b=new Array(c.length),p=0;p0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new d}}},{"./errors":12,"./util":36}],36:[function(t,e,n){"use strict";function r(){try{var t=T;return T=null,t.apply(this,arguments)}catch(e){return x.e=e,x}}function i(t){return T=t,r}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}function a(t){return o(t)?new Error(v(t)):t}function c(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;r>n;++n)i[n]=t[n];return i[n]=e,i}function l(t,e,n){if(!E.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function u(t,e,n){if(o(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return E.defineProperty(t,e,r),t}function p(t){throw t}function h(t){try{if("function"==typeof t){var e=E.names(t.prototype),n=E.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=O.test(t+"")&&E.names(t).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function f(t){function e(){}e.prototype=t;for(var n=8;n--;)new e;return t}function _(t){return A.test(t)}function d(t,e,n){for(var r=new Array(t),i=0;t>i;++i)r[i]=e+i+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function g(t){try{u(t,"isOperational",!0)}catch(e){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&E.propertyIsWritable(t,"stack")}function w(t){return{}.toString.call(t)}function C(t,e,n){for(var r=E.names(t),i=0;i10||t[0]>0}(),H.isNode&&H.toFastProperties(process);try{throw new Error}catch(N){H.lastLineError=N}e.exports=H},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file diff --git a/tools/eslint/node_modules/bluebird/package.json b/tools/eslint/node_modules/bluebird/package.json index 56ab6e32b323f5..6b708d51304a3b 100644 --- a/tools/eslint/node_modules/bluebird/package.json +++ b/tools/eslint/node_modules/bluebird/package.json @@ -14,20 +14,20 @@ ] ], "_from": "bluebird@>=3.1.1 <4.0.0", - "_id": "bluebird@3.4.1", + "_id": "bluebird@3.4.3", "_inCache": true, "_installable": true, "_location": "/bluebird", - "_nodeVersion": "5.6.0", + "_nodeVersion": "6.4.0", "_npmOperationalInternal": { "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/bluebird-3.4.1.tgz_1466192624169_0.8191918630618602" + "tmp": "tmp/bluebird-3.4.3.tgz_1472108494164_0.43675709678791463" }, "_npmUser": { "name": "esailija", "email": "petka_antonov@hotmail.com" }, - "_npmVersion": "3.6.0", + "_npmVersion": "3.10.3", "_phantomChildren": {}, "_requested": { "raw": "bluebird@^3.1.1", @@ -41,8 +41,8 @@ "_requiredBy": [ "/table" ], - "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.1.tgz", - "_shasum": "b731ddf48e2dd3bedac2e75e1215a11bcb91fa07", + "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.3.tgz", + "_shasum": "1bdf56bb9336f4206f0f4efb7bedd5b5e9392058", "_shrinkwrap": null, "_spec": "bluebird@^3.1.1", "_where": "/Users/trott/io.js/tools/node_modules/table", @@ -85,15 +85,15 @@ }, "directories": {}, "dist": { - "shasum": "b731ddf48e2dd3bedac2e75e1215a11bcb91fa07", - "tarball": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.1.tgz" + "shasum": "1bdf56bb9336f4206f0f4efb7bedd5b5e9392058", + "tarball": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.3.tgz" }, "files": [ "js/browser", "js/release", "LICENSE" ], - "gitHead": "fa5752d31ed3329631af4eebbcaa26c73b0407b8", + "gitHead": "64326d7ec06dd2839d9704b13969320e3dfb63e0", "homepage": "https://github.com/petkaantonov/bluebird", "keywords": [ "promise", @@ -133,5 +133,5 @@ "prepublish": "npm run generate-browser-core && npm run generate-browser-full", "test": "node tools/test.js" }, - "version": "3.4.1" + "version": "3.4.3" } diff --git a/tools/eslint/node_modules/cli-width/package.json b/tools/eslint/node_modules/cli-width/package.json index 57d073576d08f2..54cd04e1749222 100644 --- a/tools/eslint/node_modules/cli-width/package.json +++ b/tools/eslint/node_modules/cli-width/package.json @@ -65,7 +65,7 @@ "directories": {}, "dist": { "shasum": "b234ca209b29ef66fc518d9b98d5847b00edf00a", - "tarball": "http://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz" + "tarball": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz" }, "gitHead": "c9506fd74bd3863ff327f8f8892601fa4ac2dbb3", "homepage": "https://github.com/knownasilya/cli-width", diff --git a/tools/eslint/node_modules/doctrine/lib/doctrine.js b/tools/eslint/node_modules/doctrine/lib/doctrine.js index 23d6e3909cf503..d9a408170abf4f 100644 --- a/tools/eslint/node_modules/doctrine/lib/doctrine.js +++ b/tools/eslint/node_modules/doctrine/lib/doctrine.js @@ -263,11 +263,11 @@ function scanIdentifier(last) { var identifier; - if (!esutils.code.isIdentifierStart(source.charCodeAt(index))) { + if (!esutils.code.isIdentifierStartES5(source.charCodeAt(index))) { return null; } identifier = advance(); - while (index < last && esutils.code.isIdentifierPart(source.charCodeAt(index))) { + while (index < last && esutils.code.isIdentifierPartES5(source.charCodeAt(index))) { identifier += advance(); } return identifier; @@ -295,7 +295,7 @@ name = advance(); } - if (!esutils.code.isIdentifierStart(source.charCodeAt(index))) { + if (!esutils.code.isIdentifierStartES5(source.charCodeAt(index))) { return null; } diff --git a/tools/eslint/node_modules/doctrine/lib/typed.js b/tools/eslint/node_modules/doctrine/lib/typed.js index 80b342151a295d..a4c282f8fd8428 100644 --- a/tools/eslint/node_modules/doctrine/lib/typed.js +++ b/tools/eslint/node_modules/doctrine/lib/typed.js @@ -41,7 +41,9 @@ OptionalType: 'OptionalType', NullableType: 'NullableType', NameExpression: 'NameExpression', - TypeApplication: 'TypeApplication' + TypeApplication: 'TypeApplication', + StringLiteralType: 'StringLiteralType', + NumericLiteralType: 'NumericLiteralType' }; Token = { @@ -233,7 +235,7 @@ if (index < length) { ch = source.charCodeAt(index); - if (esutils.code.isIdentifierStart(ch)) { + if (esutils.code.isIdentifierStartES5(ch)) { utility.throwError('unexpected token'); } } @@ -253,7 +255,7 @@ if (index < length) { ch = source.charCodeAt(index); - if (esutils.code.isIdentifierStart(ch) || esutils.code.isDecimalDigit(ch)) { + if (esutils.code.isIdentifierStartES5(ch) || esutils.code.isDecimalDigit(ch)) { utility.throwError('unexpected token'); } } @@ -311,7 +313,7 @@ if (index < length) { ch = source.charCodeAt(index); - if (esutils.code.isIdentifierStart(ch)) { + if (esutils.code.isIdentifierStartES5(ch)) { utility.throwError('unexpected token'); } } @@ -462,6 +464,10 @@ token = Token.EQUAL; return token; + case 0x2D: /* '-' */ + token = scanNumber(); + return token; + default: if (esutils.code.isDecimalDigit(ch)) { token = scanNumber(); @@ -888,6 +894,20 @@ return parseTypeName(); + case Token.STRING: + next(); + return { + type: Syntax.StringLiteralType, + value: value + }; + + case Token.NUMBER: + next(); + return { + type: Syntax.NumericLiteralType, + value: value + }; + default: utility.throwError('unexpected token'); } @@ -1220,6 +1240,14 @@ result += '>'; break; + case Syntax.StringLiteralType: + result = '"' + node.value + '"'; + break; + + case Syntax.NumericLiteralType: + result = String(node.value); + break; + default: utility.throwError('Unknown type ' + node.type); } diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/LICENSE.BSD b/tools/eslint/node_modules/doctrine/node_modules/esutils/LICENSE.BSD deleted file mode 100644 index 3e580c355a96e5..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/LICENSE.BSD +++ /dev/null @@ -1,19 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/README.md b/tools/eslint/node_modules/doctrine/node_modules/esutils/README.md deleted file mode 100644 index 494fac5edaad47..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/README.md +++ /dev/null @@ -1,169 +0,0 @@ -### esutils [![Build Status](https://secure.travis-ci.org/Constellation/esutils.svg)](http://travis-ci.org/Constellation/esutils) -esutils ([esutils](http://github.com/Constellation/esutils)) is -utility box for ECMAScript language tools. - -### API - -### ast - -#### ast.isExpression(node) - -Returns true if `node` is an Expression as defined in ECMA262 edition 5.1 section -[11](https://es5.github.io/#x11). - -#### ast.isStatement(node) - -Returns true if `node` is a Statement as defined in ECMA262 edition 5.1 section -[12](https://es5.github.io/#x12). - -#### ast.isIterationStatement(node) - -Returns true if `node` is an IterationStatement as defined in ECMA262 edition -5.1 section [12.6](https://es5.github.io/#x12.6). - -#### ast.isSourceElement(node) - -Returns true if `node` is a SourceElement as defined in ECMA262 edition 5.1 -section [14](https://es5.github.io/#x14). - -#### ast.trailingStatement(node) - -Returns `Statement?` if `node` has trailing `Statement`. -```js -if (cond) - consequent; -``` -When taking this `IfStatement`, returns `consequent;` statement. - -#### ast.isProblematicIfStatement(node) - -Returns true if `node` is a problematic IfStatement. If `node` is a problematic `IfStatement`, `node` cannot be represented as an one on one JavaScript code. -```js -{ - type: 'IfStatement', - consequent: { - type: 'WithStatement', - body: { - type: 'IfStatement', - consequent: {type: 'EmptyStatement'} - } - }, - alternate: {type: 'EmptyStatement'} -} -``` -The above node cannot be represented as a JavaScript code, since the top level `else` alternate belongs to an inner `IfStatement`. - - -### code - -#### code.isDecimalDigit(code) - -Return true if provided code is decimal digit. - -#### code.isHexDigit(code) - -Return true if provided code is hexadecimal digit. - -#### code.isOctalDigit(code) - -Return true if provided code is octal digit. - -#### code.isWhiteSpace(code) - -Return true if provided code is white space. White space characters are formally defined in ECMA262. - -#### code.isLineTerminator(code) - -Return true if provided code is line terminator. Line terminator characters are formally defined in ECMA262. - -#### code.isIdentifierStart(code) - -Return true if provided code can be the first character of ECMA262 Identifier. They are formally defined in ECMA262. - -#### code.isIdentifierPart(code) - -Return true if provided code can be the trailing character of ECMA262 Identifier. They are formally defined in ECMA262. - -### keyword - -#### keyword.isKeywordES5(id, strict) - -Returns `true` if provided identifier string is a Keyword or Future Reserved Word -in ECMA262 edition 5.1. They are formally defined in ECMA262 sections -[7.6.1.1](http://es5.github.io/#x7.6.1.1) and [7.6.1.2](http://es5.github.io/#x7.6.1.2), -respectively. If the `strict` flag is truthy, this function additionally checks whether -`id` is a Keyword or Future Reserved Word under strict mode. - -#### keyword.isKeywordES6(id, strict) - -Returns `true` if provided identifier string is a Keyword or Future Reserved Word -in ECMA262 edition 6. They are formally defined in ECMA262 sections -[11.6.2.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-keywords) and -[11.6.2.2](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-future-reserved-words), -respectively. If the `strict` flag is truthy, this function additionally checks whether -`id` is a Keyword or Future Reserved Word under strict mode. - -#### keyword.isReservedWordES5(id, strict) - -Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 5.1. -They are formally defined in ECMA262 section [7.6.1](http://es5.github.io/#x7.6.1). -If the `strict` flag is truthy, this function additionally checks whether `id` -is a Reserved Word under strict mode. - -#### keyword.isReservedWordES6(id, strict) - -Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 6. -They are formally defined in ECMA262 section [11.6.2](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words). -If the `strict` flag is truthy, this function additionally checks whether `id` -is a Reserved Word under strict mode. - -#### keyword.isRestrictedWord(id) - -Returns `true` if provided identifier string is one of `eval` or `arguments`. -They are restricted in strict mode code throughout ECMA262 edition 5.1 and -in ECMA262 edition 6 section [12.1.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers-static-semantics-early-errors). - -#### keyword.isIdentifierName(id) - -Return true if provided identifier string is an IdentifierName as specified in -ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6). - -#### keyword.isIdentifierES5(id, strict) - -Return true if provided identifier string is an Identifier as specified in -ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6). If the `strict` -flag is truthy, this function additionally checks whether `id` is an Identifier -under strict mode. - -#### keyword.isIdentifierES6(id, strict) - -Return true if provided identifier string is an Identifier as specified in -ECMA262 edition 6 section [12.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers). -If the `strict` flag is truthy, this function additionally checks whether `id` -is an Identifier under strict mode. - -### License - -Copyright (C) 2013 [Yusuke Suzuki](http://github.com/Constellation) - (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/ast.js b/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/ast.js deleted file mode 100644 index 8faadae1ce736d..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/ast.js +++ /dev/null @@ -1,144 +0,0 @@ -/* - Copyright (C) 2013 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function () { - 'use strict'; - - function isExpression(node) { - if (node == null) { return false; } - switch (node.type) { - case 'ArrayExpression': - case 'AssignmentExpression': - case 'BinaryExpression': - case 'CallExpression': - case 'ConditionalExpression': - case 'FunctionExpression': - case 'Identifier': - case 'Literal': - case 'LogicalExpression': - case 'MemberExpression': - case 'NewExpression': - case 'ObjectExpression': - case 'SequenceExpression': - case 'ThisExpression': - case 'UnaryExpression': - case 'UpdateExpression': - return true; - } - return false; - } - - function isIterationStatement(node) { - if (node == null) { return false; } - switch (node.type) { - case 'DoWhileStatement': - case 'ForInStatement': - case 'ForStatement': - case 'WhileStatement': - return true; - } - return false; - } - - function isStatement(node) { - if (node == null) { return false; } - switch (node.type) { - case 'BlockStatement': - case 'BreakStatement': - case 'ContinueStatement': - case 'DebuggerStatement': - case 'DoWhileStatement': - case 'EmptyStatement': - case 'ExpressionStatement': - case 'ForInStatement': - case 'ForStatement': - case 'IfStatement': - case 'LabeledStatement': - case 'ReturnStatement': - case 'SwitchStatement': - case 'ThrowStatement': - case 'TryStatement': - case 'VariableDeclaration': - case 'WhileStatement': - case 'WithStatement': - return true; - } - return false; - } - - function isSourceElement(node) { - return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; - } - - function trailingStatement(node) { - switch (node.type) { - case 'IfStatement': - if (node.alternate != null) { - return node.alternate; - } - return node.consequent; - - case 'LabeledStatement': - case 'ForStatement': - case 'ForInStatement': - case 'WhileStatement': - case 'WithStatement': - return node.body; - } - return null; - } - - function isProblematicIfStatement(node) { - var current; - - if (node.type !== 'IfStatement') { - return false; - } - if (node.alternate == null) { - return false; - } - current = node.consequent; - do { - if (current.type === 'IfStatement') { - if (current.alternate == null) { - return true; - } - } - current = trailingStatement(current); - } while (current); - - return false; - } - - module.exports = { - isExpression: isExpression, - isStatement: isStatement, - isIterationStatement: isIterationStatement, - isSourceElement: isSourceElement, - isProblematicIfStatement: isProblematicIfStatement, - - trailingStatement: trailingStatement - }; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/code.js b/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/code.js deleted file mode 100644 index 730292a3472918..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/code.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2013-2014 Yusuke Suzuki - Copyright (C) 2014 Ivan Nikulin - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function () { - 'use strict'; - - var Regex, NON_ASCII_WHITESPACES; - - // See `tools/generate-identifier-regex.js`. - Regex = { - NonAsciiIdentifierStart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'), - NonAsciiIdentifierPart: new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]') - }; - - function isDecimalDigit(ch) { - return (ch >= 48 && ch <= 57); // 0..9 - } - - function isHexDigit(ch) { - return isDecimalDigit(ch) || // 0..9 - (97 <= ch && ch <= 102) || // a..f - (65 <= ch && ch <= 70); // A..F - } - - function isOctalDigit(ch) { - return (ch >= 48 && ch <= 55); // 0..7 - } - - // 7.2 White Space - - NON_ASCII_WHITESPACES = [ - 0x1680, 0x180E, - 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, - 0x202F, 0x205F, - 0x3000, - 0xFEFF - ]; - - function isWhiteSpace(ch) { - return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || - (ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0); - } - - // 7.3 Line Terminators - - function isLineTerminator(ch) { - return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); - } - - // 7.6 Identifier Names and Identifiers - - function isIdentifierStart(ch) { - return (ch >= 97 && ch <= 122) || // a..z - (ch >= 65 && ch <= 90) || // A..Z - (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) - (ch === 92) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); - } - - function isIdentifierPart(ch) { - return (ch >= 97 && ch <= 122) || // a..z - (ch >= 65 && ch <= 90) || // A..Z - (ch >= 48 && ch <= 57) || // 0..9 - (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) - (ch === 92) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); - } - - module.exports = { - isDecimalDigit: isDecimalDigit, - isHexDigit: isHexDigit, - isOctalDigit: isOctalDigit, - isWhiteSpace: isWhiteSpace, - isLineTerminator: isLineTerminator, - isIdentifierStart: isIdentifierStart, - isIdentifierPart: isIdentifierPart - }; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/keyword.js b/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/keyword.js deleted file mode 100644 index 884be72fbed5f0..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/keyword.js +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2013 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function () { - 'use strict'; - - var code = require('./code'); - - function isStrictModeReservedWordES6(id) { - switch (id) { - case 'implements': - case 'interface': - case 'package': - case 'private': - case 'protected': - case 'public': - case 'static': - case 'let': - return true; - default: - return false; - } - } - - function isKeywordES5(id, strict) { - // yield should not be treated as keyword under non-strict mode. - if (!strict && id === 'yield') { - return false; - } - return isKeywordES6(id, strict); - } - - function isKeywordES6(id, strict) { - if (strict && isStrictModeReservedWordES6(id)) { - return true; - } - - switch (id.length) { - case 2: - return (id === 'if') || (id === 'in') || (id === 'do'); - case 3: - return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); - case 4: - return (id === 'this') || (id === 'else') || (id === 'case') || - (id === 'void') || (id === 'with') || (id === 'enum'); - case 5: - return (id === 'while') || (id === 'break') || (id === 'catch') || - (id === 'throw') || (id === 'const') || (id === 'yield') || - (id === 'class') || (id === 'super'); - case 6: - return (id === 'return') || (id === 'typeof') || (id === 'delete') || - (id === 'switch') || (id === 'export') || (id === 'import'); - case 7: - return (id === 'default') || (id === 'finally') || (id === 'extends'); - case 8: - return (id === 'function') || (id === 'continue') || (id === 'debugger'); - case 10: - return (id === 'instanceof'); - default: - return false; - } - } - - function isReservedWordES5(id, strict) { - return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); - } - - function isReservedWordES6(id, strict) { - return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); - } - - function isRestrictedWord(id) { - return id === 'eval' || id === 'arguments'; - } - - function isIdentifierName(id) { - var i, iz, ch; - - if (id.length === 0) { - return false; - } - - ch = id.charCodeAt(0); - if (!code.isIdentifierStart(ch) || ch === 92) { // \ (backslash) - return false; - } - - for (i = 1, iz = id.length; i < iz; ++i) { - ch = id.charCodeAt(i); - if (!code.isIdentifierPart(ch) || ch === 92) { // \ (backslash) - return false; - } - } - return true; - } - - function isIdentifierES5(id, strict) { - return isIdentifierName(id) && !isReservedWordES5(id, strict); - } - - function isIdentifierES6(id, strict) { - return isIdentifierName(id) && !isReservedWordES6(id, strict); - } - - module.exports = { - isKeywordES5: isKeywordES5, - isKeywordES6: isKeywordES6, - isReservedWordES5: isReservedWordES5, - isReservedWordES6: isReservedWordES6, - isRestrictedWord: isRestrictedWord, - isIdentifierName: isIdentifierName, - isIdentifierES5: isIdentifierES5, - isIdentifierES6: isIdentifierES6 - }; -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/utils.js b/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/utils.js deleted file mode 100644 index ce18faa6bc80fa..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/lib/utils.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2013 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -(function () { - 'use strict'; - - exports.ast = require('./ast'); - exports.code = require('./code'); - exports.keyword = require('./keyword'); -}()); -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/doctrine/node_modules/esutils/package.json b/tools/eslint/node_modules/doctrine/node_modules/esutils/package.json deleted file mode 100644 index a566a75d10e4d5..00000000000000 --- a/tools/eslint/node_modules/doctrine/node_modules/esutils/package.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "esutils@^1.1.6", - "scope": null, - "escapedName": "esutils", - "name": "esutils", - "rawSpec": "^1.1.6", - "spec": ">=1.1.6 <2.0.0", - "type": "range" - }, - "/Users/trott/io.js/tools/node_modules/doctrine" - ] - ], - "_from": "esutils@>=1.1.6 <2.0.0", - "_id": "esutils@1.1.6", - "_inCache": true, - "_installable": true, - "_location": "/doctrine/esutils", - "_npmUser": { - "name": "constellation", - "email": "utatane.tea@gmail.com" - }, - "_npmVersion": "2.0.0-alpha-5", - "_phantomChildren": {}, - "_requested": { - "raw": "esutils@^1.1.6", - "scope": null, - "escapedName": "esutils", - "name": "esutils", - "rawSpec": "^1.1.6", - "spec": ">=1.1.6 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/doctrine" - ], - "_resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", - "_shasum": "c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375", - "_shrinkwrap": null, - "_spec": "esutils@^1.1.6", - "_where": "/Users/trott/io.js/tools/node_modules/doctrine", - "bugs": { - "url": "https://github.com/Constellation/esutils/issues" - }, - "dependencies": {}, - "description": "utility box for ECMAScript language tools", - "devDependencies": { - "chai": "~1.7.2", - "coffee-script": "~1.6.3", - "jshint": "2.1.5", - "mocha": "~1.12.0", - "regenerate": "~0.5.4", - "unicode-6.3.0": "~0.1.1" - }, - "directories": { - "lib": "./lib" - }, - "dist": { - "shasum": "c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375", - "tarball": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "LICENSE.BSD", - "README.md", - "lib" - ], - "gitHead": "a91c5ed6199d1019ef071f610848fcd5103ef153", - "homepage": "https://github.com/Constellation/esutils", - "licenses": [ - { - "type": "BSD", - "url": "http://github.com/Constellation/esutils/raw/master/LICENSE.BSD" - } - ], - "main": "lib/utils.js", - "maintainers": [ - { - "name": "constellation", - "email": "utatane.tea@gmail.com" - } - ], - "name": "esutils", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/Constellation/esutils.git" - }, - "scripts": { - "generate-regex": "node tools/generate-identifier-regex.js", - "lint": "jshint lib/*.js", - "test": "npm run-script lint && npm run-script unit-test", - "unit-test": "mocha --compilers coffee:coffee-script -R spec" - }, - "version": "1.1.6" -} diff --git a/tools/eslint/node_modules/doctrine/package.json b/tools/eslint/node_modules/doctrine/package.json index bd3d0367cd8dc0..09fd0f89d0cc48 100644 --- a/tools/eslint/node_modules/doctrine/package.json +++ b/tools/eslint/node_modules/doctrine/package.json @@ -14,20 +14,20 @@ ] ], "_from": "doctrine@>=1.2.2 <2.0.0", - "_id": "doctrine@1.2.2", + "_id": "doctrine@1.3.0", "_inCache": true, "_installable": true, "_location": "/doctrine", - "_nodeVersion": "4.4.2", + "_nodeVersion": "4.4.7", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/doctrine-1.2.2.tgz_1463692862416_0.07905266736634076" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/doctrine-1.3.0.tgz_1471897078408_0.6770147804636508" }, "_npmUser": { - "name": "nzakas", - "email": "nicholas@nczconsulting.com" + "name": "eslint", + "email": "nicholas+eslint@nczconsulting.com" }, - "_npmVersion": "2.15.0", + "_npmVersion": "2.15.8", "_phantomChildren": {}, "_requested": { "raw": "doctrine@^1.2.2", @@ -41,8 +41,8 @@ "_requiredBy": [ "/eslint" ], - "_resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.2.2.tgz", - "_shasum": "9e9867210149548b95ec51469dae4caad312308e", + "_resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.3.0.tgz", + "_shasum": "13e75682b55518424276f7c173783456ef913d26", "_shrinkwrap": null, "_spec": "doctrine@^1.2.2", "_where": "/Users/trott/io.js/tools/node_modules/eslint", @@ -50,7 +50,7 @@ "url": "https://github.com/eslint/doctrine/issues" }, "dependencies": { - "esutils": "^1.1.6", + "esutils": "^2.0.2", "isarray": "^1.0.0" }, "description": "JSDoc parser", @@ -58,7 +58,7 @@ "coveralls": "^2.11.2", "dateformat": "^1.0.11", "eslint": "^1.10.3", - "eslint-release": "^0.3.0", + "eslint-release": "^0.10.0", "istanbul": "^0.4.1", "linefix": "^0.1.1", "mocha": "^2.3.3", @@ -72,8 +72,8 @@ "lib": "./lib" }, "dist": { - "shasum": "9e9867210149548b95ec51469dae4caad312308e", - "tarball": "https://registry.npmjs.org/doctrine/-/doctrine-1.2.2.tgz" + "shasum": "13e75682b55518424276f7c173783456ef913d26", + "tarball": "https://registry.npmjs.org/doctrine/-/doctrine-1.3.0.tgz" }, "engines": { "node": ">=0.10.0" @@ -85,7 +85,7 @@ "LICENSE.esprima", "README.md" ], - "gitHead": "fedfef2642a3631b22e995a3b833bd937a283ec1", + "gitHead": "b4b2870ccb4e47977fafce8e6055740e4dda28af", "homepage": "https://github.com/eslint/doctrine", "licenses": [ { @@ -99,6 +99,10 @@ "name": "constellation", "email": "utatane.tea@gmail.com" }, + { + "name": "eslint", + "email": "nicholas+eslint@nczconsulting.com" + }, { "name": "nzakas", "email": "nicholas@nczconsulting.com" @@ -109,14 +113,15 @@ "readme": "ERROR: No README data found!", "repository": { "type": "git", - "url": "git+ssh://git@github.com/eslint/doctrine.git" + "url": "git+https://github.com/eslint/doctrine.git" }, "scripts": { "alpharelease": "eslint-prerelease alpha", "betarelease": "eslint-prerelease beta", + "ci-release": "eslint-ci-release", "lint": "eslint lib/", "release": "eslint-release", "test": "npm run lint && node Makefile.js test" }, - "version": "1.2.2" + "version": "1.3.0" } diff --git a/tools/eslint/node_modules/esprima/esprima.js b/tools/eslint/node_modules/esprima/esprima.js index 654e5fd0ddb318..0cb0a9361c9576 100644 --- a/tools/eslint/node_modules/esprima/esprima.js +++ b/tools/eslint/node_modules/esprima/esprima.js @@ -1325,6 +1325,7 @@ try { return new RegExp(pattern, flags); } catch (exception) { + /* istanbul ignore next */ return null; } } @@ -1521,7 +1522,7 @@ return value && (value.length > 1) && (value[0] >= 'a') && (value[0] <= 'z'); } - previous = extra.tokenValues[extra.tokens.length - 1]; + previous = extra.tokenValues[extra.tokenValues.length - 1]; regex = (previous !== null); switch (previous) { @@ -5707,7 +5708,7 @@ } // Sync with *.json manifests. - exports.version = '2.7.2'; + exports.version = '2.7.3'; exports.tokenize = tokenize; diff --git a/tools/eslint/node_modules/esprima/package.json b/tools/eslint/node_modules/esprima/package.json index 748bc15cfefa7f..ddee8dbee8224e 100644 --- a/tools/eslint/node_modules/esprima/package.json +++ b/tools/eslint/node_modules/esprima/package.json @@ -14,20 +14,20 @@ ] ], "_from": "esprima@>=2.6.0 <3.0.0", - "_id": "esprima@2.7.2", + "_id": "esprima@2.7.3", "_inCache": true, "_installable": true, "_location": "/esprima", - "_nodeVersion": "4.2.2", + "_nodeVersion": "6.1.0", "_npmOperationalInternal": { - "host": "packages-9-west.internal.npmjs.com", - "tmp": "tmp/esprima-2.7.2.tgz_1454477276067_0.014412595424801111" + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/esprima-2.7.3.tgz_1472013602345_0.010668299393728375" }, "_npmUser": { "name": "ariya", "email": "ariya.hidayat@gmail.com" }, - "_npmVersion": "2.14.7", + "_npmVersion": "3.8.6", "_phantomChildren": {}, "_requested": { "raw": "esprima@^2.6.0", @@ -41,8 +41,8 @@ "_requiredBy": [ "/js-yaml" ], - "_resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.2.tgz", - "_shasum": "f43be543609984eae44c933ac63352a6af35f339", + "_resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "_shasum": "96e3b70d5779f6ad49cd032673d1c312767ba581", "_shrinkwrap": null, "_spec": "esprima@^2.6.0", "_where": "/Users/trott/io.js/tools/node_modules/js-yaml", @@ -85,8 +85,8 @@ }, "directories": {}, "dist": { - "shasum": "f43be543609984eae44c933ac63352a6af35f339", - "tarball": "https://registry.npmjs.org/esprima/-/esprima-2.7.2.tgz" + "shasum": "96e3b70d5779f6ad49cd032673d1c312767ba581", + "tarball": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz" }, "engines": { "node": ">=0.10.0" @@ -96,7 +96,7 @@ "unit-tests.js", "esprima.js" ], - "gitHead": "eb05a03b18b8433ab1ebeabea635a949219cd75e", + "gitHead": "abaaf7f12040f0b31fac6fee342ffec8feab15d0", "homepage": "http://esprima.org", "keywords": [ "ast", @@ -150,5 +150,5 @@ "travis": "npm test", "unit-tests": "node test/unit-tests.js" }, - "version": "2.7.2" + "version": "2.7.3" } diff --git a/tools/eslint/node_modules/esutils/package.json b/tools/eslint/node_modules/esutils/package.json index 39034dcb3cca18..ee940c57f21107 100644 --- a/tools/eslint/node_modules/esutils/package.json +++ b/tools/eslint/node_modules/esutils/package.json @@ -35,6 +35,7 @@ "type": "range" }, "_requiredBy": [ + "/doctrine", "/eslint" ], "_resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", diff --git a/tools/eslint/node_modules/file-entry-cache/cache.js b/tools/eslint/node_modules/file-entry-cache/cache.js index 5823b332c5cbea..c37d679f63ce58 100644 --- a/tools/eslint/node_modules/file-entry-cache/cache.js +++ b/tools/eslint/node_modules/file-entry-cache/cache.js @@ -14,6 +14,22 @@ module.exports = { var assign = require( 'object-assign' ); var normalizedEntries = { }; + var removeNotFoundFiles = function removeNotFoundFiles() { + const cachedEntries = cache.keys(); + // remove not found entries + cachedEntries.forEach( function remover( fPath ) { + try { + fs.statSync( fPath ); + } catch (err) { + if ( err.code === 'ENOENT' ) { + cache.removeKey( fPath ); + } + } + } ); + }; + + removeNotFoundFiles(); + return { /** * the flat cache storage used to persist the metadata of the `files @@ -161,12 +177,12 @@ module.exports = { }, /** * Sync the files and persist them to the cache - * @param [noPrune=false] {Boolean} whether to remove non visited/saved entries * @method reconcile */ - reconcile: function ( noPrune ) { - var entries = normalizedEntries; + reconcile: function () { + removeNotFoundFiles(); + var entries = normalizedEntries; var keys = Object.keys( entries ); if ( keys.length === 0 ) { @@ -175,17 +191,25 @@ module.exports = { keys.forEach( function ( entryName ) { var cacheEntry = entries[ entryName ]; - var stat = fs.statSync( cacheEntry.key ); - var meta = assign( cacheEntry.meta, { - size: stat.size, - mtime: stat.mtime.getTime() - } ); - - cache.setKey( entryName, meta ); + try { + var stat = fs.statSync( cacheEntry.key ); + var meta = assign( cacheEntry.meta, { + size: stat.size, + mtime: stat.mtime.getTime() + } ); + + cache.setKey( entryName, meta ); + } catch (err) { + // if the file does not exists we don't save it + // other errors are just thrown + if ( err.code !== 'ENOENT' ) { + throw err; + } + } } ); - cache.save( noPrune ); + cache.save( true ); } }; } diff --git a/tools/eslint/node_modules/file-entry-cache/changelog.md b/tools/eslint/node_modules/file-entry-cache/changelog.md index 57eec48aada74d..4cf9fdac65a09d 100644 --- a/tools/eslint/node_modules/file-entry-cache/changelog.md +++ b/tools/eslint/node_modules/file-entry-cache/changelog.md @@ -1,5 +1,10 @@ # file-entry-cache - Changelog +## v2.0.0 +- **Features** + - do not persist and prune removed files from cache. Relates to [#2](https://github.com/royriojas/file-entry-cache/issues/2) - [408374d]( https://github.com/royriojas/file-entry-cache/commit/408374d ), [Roy Riojas](https://github.com/Roy Riojas), 16/08/2016 15:47:58 + + ## v1.3.1 - **Build Scripts Changes** - remove older node version - [0a26ac4]( https://github.com/royriojas/file-entry-cache/commit/0a26ac4 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 06:09:17 diff --git a/tools/eslint/node_modules/file-entry-cache/package.json b/tools/eslint/node_modules/file-entry-cache/package.json index dc15546159c139..aa6f30003e5a85 100644 --- a/tools/eslint/node_modules/file-entry-cache/package.json +++ b/tools/eslint/node_modules/file-entry-cache/package.json @@ -2,26 +2,26 @@ "_args": [ [ { - "raw": "file-entry-cache@^1.3.1", + "raw": "file-entry-cache@^2.0.0", "scope": null, "escapedName": "file-entry-cache", "name": "file-entry-cache", - "rawSpec": "^1.3.1", - "spec": ">=1.3.1 <2.0.0", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", "type": "range" }, "/Users/trott/io.js/tools/node_modules/eslint" ] ], - "_from": "file-entry-cache@>=1.3.1 <2.0.0", - "_id": "file-entry-cache@1.3.1", + "_from": "file-entry-cache@>=2.0.0 <3.0.0", + "_id": "file-entry-cache@2.0.0", "_inCache": true, "_installable": true, "_location": "/file-entry-cache", "_nodeVersion": "6.3.0", "_npmOperationalInternal": { "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/file-entry-cache-1.3.1.tgz_1470049850988_0.09572241548448801" + "tmp": "tmp/file-entry-cache-2.0.0.tgz_1471380536263_0.40089720860123634" }, "_npmUser": { "name": "royriojas", @@ -30,21 +30,21 @@ "_npmVersion": "3.10.3", "_phantomChildren": {}, "_requested": { - "raw": "file-entry-cache@^1.3.1", + "raw": "file-entry-cache@^2.0.0", "scope": null, "escapedName": "file-entry-cache", "name": "file-entry-cache", - "rawSpec": "^1.3.1", - "spec": ">=1.3.1 <2.0.0", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", "type": "range" }, "_requiredBy": [ "/eslint" ], - "_resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-1.3.1.tgz", - "_shasum": "44c61ea607ae4be9c1402f41f44270cbfe334ff8", + "_resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "_shasum": "c392990c3e684783d838b8c84a45d8a048458361", "_shrinkwrap": null, - "_spec": "file-entry-cache@^1.3.1", + "_spec": "file-entry-cache@^2.0.0", "_where": "/Users/trott/io.js/tools/node_modules/eslint", "author": { "name": "Roy Riojas", @@ -90,8 +90,8 @@ }, "directories": {}, "dist": { - "shasum": "44c61ea607ae4be9c1402f41f44270cbfe334ff8", - "tarball": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-1.3.1.tgz" + "shasum": "c392990c3e684783d838b8c84a45d8a048458361", + "tarball": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz" }, "engines": { "node": ">=0.10.0" @@ -99,7 +99,7 @@ "files": [ "cache.js" ], - "gitHead": "037bc03eb9c2e759a66da95cd5432499a74f754a", + "gitHead": "8c015253938e1756104b524c09ea48798e788aa0", "homepage": "https://github.com/royriojas/file-entry-cache#readme", "keywords": [ "file cache", @@ -144,9 +144,9 @@ "lint": "npm run beautify && npm run eslint", "post-v": "npm run do-changelog && git push --no-verify && git push --tags --no-verify", "pre-v": "npm run test", - "test": "npm run verify && mocha -R spec test/specs", + "test": "npm run verify --silent && mocha -R spec test/specs", "verify": "npm run beautify-check && npm run eslint", "watch": "watch-run -i -p 'test/specs/**/*.js' istanbul cover test/runner.js html text-summary" }, - "version": "1.3.1" + "version": "2.0.0" } diff --git a/tools/eslint/node_modules/glob/glob.js b/tools/eslint/node_modules/glob/glob.js index 02d15b755dd84e..9eca910bb05ec6 100644 --- a/tools/eslint/node_modules/glob/glob.js +++ b/tools/eslint/node_modules/glob/glob.js @@ -100,6 +100,10 @@ glob.hasMagic = function (pattern, options_) { var g = new Glob(pattern, options) var set = g.minimatch.set + + if (!pattern) + return false + if (set.length > 1) return true diff --git a/tools/eslint/node_modules/glob/package.json b/tools/eslint/node_modules/glob/package.json index 879ae782919339..761e829355d642 100644 --- a/tools/eslint/node_modules/glob/package.json +++ b/tools/eslint/node_modules/glob/package.json @@ -14,20 +14,20 @@ ] ], "_from": "glob@>=7.0.3 <8.0.0", - "_id": "glob@7.0.5", + "_id": "glob@7.0.6", "_inCache": true, "_installable": true, "_location": "/glob", - "_nodeVersion": "4.4.4", + "_nodeVersion": "4.5.0", "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/glob-7.0.5.tgz_1466471133629_0.7749870484694839" + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/glob-7.0.6.tgz_1472074762911_0.47247025789693" }, "_npmUser": { "name": "isaacs", "email": "i@izs.me" }, - "_npmVersion": "3.9.1", + "_npmVersion": "3.10.7", "_phantomChildren": {}, "_requested": { "raw": "glob@^7.0.3", @@ -43,8 +43,8 @@ "/globby", "/rimraf" ], - "_resolved": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz", - "_shasum": "b4202a69099bbb4d292a7c1b95b6682b67ebdc95", + "_resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", + "_shasum": "211bafaf49e525b8cd93260d14ab136152b3f57a", "_shrinkwrap": null, "_spec": "glob@^7.0.3", "_where": "/Users/trott/io.js/tools/node_modules/eslint", @@ -73,8 +73,8 @@ }, "directories": {}, "dist": { - "shasum": "b4202a69099bbb4d292a7c1b95b6682b67ebdc95", - "tarball": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz" + "shasum": "211bafaf49e525b8cd93260d14ab136152b3f57a", + "tarball": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz" }, "engines": { "node": "*" @@ -84,7 +84,7 @@ "sync.js", "common.js" ], - "gitHead": "1319866c764e1a1bb39114dcbc2c1d518bb9b476", + "gitHead": "98327d8def195b1ba200217952df8ea829426038", "homepage": "https://github.com/isaacs/node-glob#readme", "license": "ISC", "main": "glob.js", @@ -110,5 +110,5 @@ "test": "tap test/*.js --cov", "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js" }, - "version": "7.0.5" + "version": "7.0.6" } diff --git a/tools/eslint/node_modules/graceful-fs/package.json b/tools/eslint/node_modules/graceful-fs/package.json index 417c5b3b1c4004..6e4bc3283b51a9 100644 --- a/tools/eslint/node_modules/graceful-fs/package.json +++ b/tools/eslint/node_modules/graceful-fs/package.json @@ -14,20 +14,20 @@ ] ], "_from": "graceful-fs@>=4.1.2 <5.0.0", - "_id": "graceful-fs@4.1.5", + "_id": "graceful-fs@4.1.6", "_inCache": true, "_installable": true, "_location": "/graceful-fs", "_nodeVersion": "4.4.4", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/graceful-fs-4.1.5.tgz_1469558843062_0.986795610981062" + "tmp": "tmp/graceful-fs-4.1.6.tgz_1471616320359_0.39477095939219" }, "_npmUser": { "name": "isaacs", "email": "i@izs.me" }, - "_npmVersion": "3.10.6", + "_npmVersion": "3.10.7", "_phantomChildren": {}, "_requested": { "raw": "graceful-fs@^4.1.2", @@ -41,8 +41,8 @@ "_requiredBy": [ "/flat-cache" ], - "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.5.tgz", - "_shasum": "f4745e8caed5e0dd2ef21bb5e2d229a32e8093c0", + "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.6.tgz", + "_shasum": "514c38772b31bee2e08bedc21a0aeb3abf54c19e", "_shrinkwrap": null, "_spec": "graceful-fs@^4.1.2", "_where": "/Users/trott/io.js/tools/node_modules/flat-cache", @@ -60,8 +60,8 @@ "test": "test" }, "dist": { - "shasum": "f4745e8caed5e0dd2ef21bb5e2d229a32e8093c0", - "tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.5.tgz" + "shasum": "514c38772b31bee2e08bedc21a0aeb3abf54c19e", + "tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.6.tgz" }, "engines": { "node": ">=0.4.0" @@ -72,7 +72,7 @@ "legacy-streams.js", "polyfills.js" ], - "gitHead": "d170f3f2ceb56adb4d6bd50df4b535bed54120c0", + "gitHead": "cfe3ba80e37af542f02e445c89aa59482aa32a63", "homepage": "https://github.com/isaacs/node-graceful-fs#readme", "keywords": [ "fs", @@ -108,5 +108,5 @@ "scripts": { "test": "node test.js | tap -" }, - "version": "4.1.5" + "version": "4.1.6" } diff --git a/tools/eslint/node_modules/graceful-fs/polyfills.js b/tools/eslint/node_modules/graceful-fs/polyfills.js index 1cc74c8236b7df..2798050604be2f 100644 --- a/tools/eslint/node_modules/graceful-fs/polyfills.js +++ b/tools/eslint/node_modules/graceful-fs/polyfills.js @@ -206,9 +206,9 @@ function patchLutimes (fs) { function chmodFix (orig) { if (!orig) return orig return function (target, mode, cb) { - return orig.call(fs, target, mode, function (er, res) { + return orig.call(fs, target, mode, function (er) { if (chownErOk(er)) er = null - if (cb) cb(er, res) + if (cb) cb.apply(this, arguments) }) } } @@ -228,9 +228,9 @@ function chmodFixSync (orig) { function chownFix (orig) { if (!orig) return orig return function (target, uid, gid, cb) { - return orig.call(fs, target, uid, gid, function (er, res) { + return orig.call(fs, target, uid, gid, function (er) { if (chownErOk(er)) er = null - if (cb) cb(er, res) + if (cb) cb.apply(this, arguments) }) } } diff --git a/tools/eslint/node_modules/ignore/README.md b/tools/eslint/node_modules/ignore/README.md new file mode 100755 index 00000000000000..96c70b60a58b6e --- /dev/null +++ b/tools/eslint/node_modules/ignore/README.md @@ -0,0 +1,188 @@ +[![Build Status](https://travis-ci.org/kaelzhang/node-ignore.svg?branch=master)](https://travis-ci.org/kaelzhang/node-ignore) +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/kaelzhang/node-ignore?branch=master&svg=true)](https://ci.appveyor.com/project/kaelzhang/node-ignore) +[![npm module downloads per month](http://img.shields.io/npm/dm/ignore.svg)](https://www.npmjs.org/package/ignore) + +# ignore + +`ignore` is a manager and filter which implemented in pure JavaScript according to the .gitignore [spec](http://git-scm.com/docs/gitignore). + +Pay attention that [`minimatch`](https://www.npmjs.org/package/minimatch) does not work in the gitignore way. To filter filenames according to .gitignore file, I recommend this module. + +##### Tested on + +- Linux + Node: `0.8` - `5.x` +- Windows + Node: `0.10` - `5.x`, node < `0.10` is not tested due to the lack of support of appveyor. + +## Table Of Main Contents + +- [Usage](#usage) +- [Guide for 2.x -> 3.x](#upgrade-2x---3x) +- [Contributing](#contributing) + +## Usage + +```js +const ignore = require('ignore') +let ig = ignore().add(['.abc/*', '!.abc/d/']) +``` + +### Filter the given paths + +```js +let paths = [ + '.abc/a.js', // filtered out + '.abc/d/e.js' // included +] + +ig.filter(paths) // ['.abc/d/e.js'] +``` + +### As the filter function + +```js +paths.filter(ig.createFilter()); // ['.abc/d/e.js'] +``` + +### Win32 paths will be handled + +```js +ig.filter(['.abc\\a.js', '.abc\\d\\e.js']) +// if the code above runs on windows, the result will be +// ['.abc\\d\\e.js'] +``` + +## Why another ignore? + +1. `ignore` is a standalone module, and is much simpler so that it could easy work with other programs, unlike [isaacs](https://npmjs.org/~isaacs)'s [fstream-ignore](https://npmjs.org/package/fstream-ignore) which must work with the modules of the fstream family. + +2. `ignore` only contains utility methods to filter paths according to the specified ignore rules, so + - `ignore` never try to find out ignore rules by traversing directories or fetching from git configurations. + - `ignore` don't cares about sub-modules of git projects. + +3. Exactly according to [gitignore man page](http://git-scm.com/docs/gitignore), fixes some known matching issues of fstream-ignore, such as: + - '`/*.js`' should only match '`a.js`', but not '`abc/a.js`'. + - '`**/foo`' should match '`foo`' anywhere. + - prevent re-including a file if a parent directory of that file is excluded. + - handle trailing whitespaces: + - `'a '`(one space) should not match `'a '`(two spaces). + - `'a \ '` matches `'a '` + +## Methods + +### .add(pattern) +### .add(patterns) + +- pattern `String|Ignore` An ignore pattern string, or the `Ignore` instance +- patterns `Array.` Array of ignore patterns. + +Adds a rule or several rules to the current manager. + +Returns `this` + +Notice that a line starting with `'#'`(hash) is treated as a comment. Put a backslash (`'\'`) in front of the first hash for patterns that begin with a hash, if you want to ignore a file with a hash at the beginning of the filename. + +```js +ignore().add('#abc').filter(['#abc']) // ['#abc'] +ignore().add('\#abc').filter(['#abc']) // [] +``` + +`pattern` could either be a line of ignore pattern or a string of multiple ignore patterns, which means we could just `ignore().add()` the content of a ignore file: + +```js +ignore().add(fs.readFileSync(filenameOfGitignore).toString()).filter(filenames) +``` + +`pattern` could also be an `ignore` instance, so that we could easily inherit the rules of another `Ignore` instance. + +### .addIgnoreFile(path) + +REMOVED in `3.x` for now. + +To upgrade `ignore@2.x` up to `3.x`, use + +```js +const fs = require('fs') + +if (fs.existsSync(filename)) { + ignore().add(fs.readFileSync(filename).toString()) +} +``` + +instead. + + +### .filter(paths) + +Filters the given array of pathnames, and returns the filtered array. + +- paths `Array.` The array of paths to be filtered. + +*NOTICE* that each `path` here should be a relative path to the root of your repository. Suppose the dir structure is: + +``` +/path/to/your/repo + |-- a + | |-- a.js + | + |-- .b + | + |-- .c + |-- .DS_store +``` + +Then the `paths` might be like this: + +```js +[ + 'a/a.js' + '.b', + '.c/.DS_store' +] +``` + +Usually, you could use [`glob`](http://npmjs.org/package/glob) with `option.mark = true` to fetch the structure of the current directory: + +```js +const glob = require('glob') + +glob('**', { + // Adds a / character to directory matches. + mark: true +}, (err, files) => { + if (err) { + return console.error(err) + } + + let filtered = ignore().add(patterns).filter(files) + console.log(filtered) +}) +``` + +### .createFilter() + +Creates a filter function which could filter an array of paths with `Array.prototype.filter`. + +Returns `function(path)` the filter function. + +**** + +## Upgrade 2.x -> 3.x + +- All `options` of 2.x are unnecessary and removed, so just remove them. +- `ignore()` instance is no longer an [`EventEmitter`](nodejs.org/api/events.html), and all events are unnecessary and removed. +- `.addIgnoreFile()` is removed, see the [.addIgnoreFile](#addignorefilepath) section for details. + +**** + +## Contributing + +The code of `node-ignore` is based on es6 and babel, but babel and its preset is not included in the `dependencies` field of package.json, so that the installation process of test cases will not fail in older versions of node. + +So use `bash install.sh` to install dependencies and `bash test.sh` to run test cases in your local machine. + +#### Collaborators + +- [SamyPesse](https://github.com/SamyPesse) *Samy Pessé* +- [azproduction](https://github.com/azproduction) *Mikhail Davydov* +- [TrySound](https://github.com/TrySound) *Bogdan Chadkin* +- [JanMattner](https://github.com/JanMattner) *Jan Mattner* diff --git a/tools/eslint/node_modules/ignore/ignore.js b/tools/eslint/node_modules/ignore/ignore.js index b69f68ebdde9e2..c9e16fddb8a324 100644 --- a/tools/eslint/node_modules/ignore/ignore.js +++ b/tools/eslint/node_modules/ignore/ignore.js @@ -106,13 +106,12 @@ var IgnoreBase = function () { }, { key: '_createRule', value: function _createRule(pattern) { - var rule_object = { - origin: pattern - }; + var origin = pattern; + var negative = false; // > An optional prefix "!" which negates the pattern; if (pattern.indexOf('!') === 0) { - rule_object.negative = true; + negative = true; pattern = pattern.substr(1); } @@ -122,10 +121,14 @@ var IgnoreBase = function () { // > Put a backslash ("\") in front of the first hash for patterns that begin with a hash. .replace(REGEX_LEADING_EXCAPED_HASH, '#'); - rule_object.pattern = pattern; - rule_object.regex = regex(pattern); + var regex = make_regex(pattern, negative); - return rule_object; + return { + origin: origin, + pattern: pattern, + negative: negative, + regex: regex + }; } }, { key: '_filter', @@ -197,7 +200,7 @@ var IgnoreBase = function () { // '`foo/`' should not continue with the '`..`' -var REPLACERS = [ +var DEFAULT_REPLACER_PREFIX = [ // > Trailing spaces are ignored unless they are quoted with backslash ("\") [ @@ -209,7 +212,7 @@ var REPLACERS = [ }], // replace (\ ) with ' ' -[/\\\s/g, function (match) { +[/\\\s/g, function () { return ' '; }], @@ -259,36 +262,14 @@ var REPLACERS = [ // just remove it function () { return '^(?:.*\\/)?'; -}], - -// 'f' -// matches -// - /f(end) -// - /f/ -// - (start)f(end) -// - (start)f/ -// doesn't match -// - oof -// - foo -// pseudo: -// -> (^|/)f(/|$) - -// ending -[ -// 'js' will not match 'js.' -// 'ab' will not match 'abc' -/(?:[^*\/])$/, function (match) { - // 'js*' will not match 'a.js' - // 'js/' will not match 'a.js' - // 'js' will match 'a.js' and 'a.js/' - return match + '(?=$|\\/)'; -}], +}]]; +var DEFAULT_REPLACER_SUFFIX = [ // starting [ // there will be no leading '/' (which has been replaced by section "leading slash") // If starts with '**', adding a '^' to the regular expression also works -/^(?=[^\^])/, function (match) { +/^(?=[^\^])/, function () { return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern // Actually, if there is only a trailing slash, git also treats it as a shell glob pattern @@ -305,9 +286,9 @@ function () { // Zero, one or several directories // should not use '*', or it will be replaced by the next replacer -function (m, index, str) { - // Check if it is not the last `'/**'` +// Check if it is not the last `'/**'` +function (match, index, str) { return index + 6 < str.length // case: /**/ @@ -330,19 +311,21 @@ function (m, index, str) { // 'abc.*/' -> go // 'abc.*' -> skip this rule -/(^|[^\\]+)\\\*(?=.+)/g, function (match, p1) { - // '*.js' matches '.js' - // '*.js' doesn't match 'abc' +/(^|[^\\]+)\\\*(?=.+)/g, + +// '*.js' matches '.js' +// '*.js' doesn't match 'abc' +function (match, p1) { return p1 + '[^\\/]*'; }], // trailing wildcard -[/(\\\/)?\\\*$/, function (m, p1) { +[/(\\\/)?\\\*$/, function (match, p1) { return p1 === '\\/' // 'a/*' does not match 'a/' // 'a/*' matches 'a/a' // 'a/' - ? '\\/[^/]+' + ? '\\/[^/]+(?=$|\\/$)' // or it will match everything after : ''; @@ -352,17 +335,60 @@ function (m, index, str) { return '\\'; }]]; +var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [ + +// 'f' +// matches +// - /f(end) +// - /f/ +// - (start)f(end) +// - (start)f/ +// doesn't match +// - oof +// - foo +// pseudo: +// -> (^|/)f(/|$) + +// ending +[ +// 'js' will not match 'js.' +// 'ab' will not match 'abc' +/(?:[^*\/])$/, + +// 'js*' will not match 'a.js' +// 'js/' will not match 'a.js' +// 'js' will match 'a.js' and 'a.js/' +function (match) { + return match + '(?=$|\\/)'; +}]], DEFAULT_REPLACER_SUFFIX); + +var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [ + +// #24 +// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore) +// A negative pattern without a trailing wildcard should not +// re-include the things inside that directory. + +// eg: +// ['node_modules/*', '!node_modules'] +// should ignore `node_modules/a.js` +[/(?:[^*\/])$/, function (match) { + return match + '(?=$|\\/$)'; +}]], DEFAULT_REPLACER_SUFFIX); + // A simple cache, because an ignore rule only has only one certain meaning var cache = {}; // @param {pattern} -function regex(pattern) { +function make_regex(pattern, negative) { var r = cache[pattern]; if (r) { return r; } - var source = REPLACERS.reduce(function (prev, current) { + var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS; + + var source = replacers.reduce(function (prev, current) { return prev.replace(current[0], current[1].bind(pattern)); }, pattern); diff --git a/tools/eslint/node_modules/ignore/package.json b/tools/eslint/node_modules/ignore/package.json index a1198d589b587c..68745c23eb376b 100644 --- a/tools/eslint/node_modules/ignore/package.json +++ b/tools/eslint/node_modules/ignore/package.json @@ -2,49 +2,49 @@ "_args": [ [ { - "raw": "ignore@^3.1.2", + "raw": "ignore@^3.1.5", "scope": null, "escapedName": "ignore", "name": "ignore", - "rawSpec": "^3.1.2", - "spec": ">=3.1.2 <4.0.0", + "rawSpec": "^3.1.5", + "spec": ">=3.1.5 <4.0.0", "type": "range" }, "/Users/trott/io.js/tools/node_modules/eslint" ] ], - "_from": "ignore@>=3.1.2 <4.0.0", - "_id": "ignore@3.1.3", + "_from": "ignore@>=3.1.5 <4.0.0", + "_id": "ignore@3.1.5", "_inCache": true, "_installable": true, "_location": "/ignore", - "_nodeVersion": "6.2.1", + "_nodeVersion": "6.3.0", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/ignore-3.1.3.tgz_1466563368081_0.9863177102524787" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/ignore-3.1.5.tgz_1471234764185_0.0016845394857227802" }, "_npmUser": { "name": "kael", "email": "i@kael.me" }, - "_npmVersion": "3.9.3", + "_npmVersion": "3.10.3", "_phantomChildren": {}, "_requested": { - "raw": "ignore@^3.1.2", + "raw": "ignore@^3.1.5", "scope": null, "escapedName": "ignore", "name": "ignore", - "rawSpec": "^3.1.2", - "spec": ">=3.1.2 <4.0.0", + "rawSpec": "^3.1.5", + "spec": ">=3.1.5 <4.0.0", "type": "range" }, "_requiredBy": [ "/eslint" ], - "_resolved": "https://registry.npmjs.org/ignore/-/ignore-3.1.3.tgz", - "_shasum": "9e890c0652519115ae9427da47516bd54d1d6999", + "_resolved": "https://registry.npmjs.org/ignore/-/ignore-3.1.5.tgz", + "_shasum": "54ba1eb92ef9fff8d49e5a1fb23961cdba77eb7a", "_shrinkwrap": null, - "_spec": "ignore@^3.1.2", + "_spec": "ignore@^3.1.5", "_where": "/Users/trott/io.js/tools/node_modules/eslint", "author": { "name": "kael" @@ -60,14 +60,14 @@ }, "directories": {}, "dist": { - "shasum": "9e890c0652519115ae9427da47516bd54d1d6999", - "tarball": "https://registry.npmjs.org/ignore/-/ignore-3.1.3.tgz" + "shasum": "54ba1eb92ef9fff8d49e5a1fb23961cdba77eb7a", + "tarball": "https://registry.npmjs.org/ignore/-/ignore-3.1.5.tgz" }, "files": [ "ignore.js", "LICENSE-MIT" ], - "gitHead": "05adc3e323d72b76cf1e3be7e9e8e38f43d3a544", + "gitHead": "316d0704f4ad631df14e1be5b993c64f4466b2c1", "homepage": "https://github.com/kaelzhang/node-ignore#readme", "keywords": [ "ignore", @@ -102,5 +102,5 @@ "scripts": { "test": "mocha --reporter spec ./test/ignore.js" }, - "version": "3.1.3" + "version": "3.1.5" } diff --git a/tools/eslint/node_modules/jsonify/package.json b/tools/eslint/node_modules/jsonify/package.json index 3c1a4c2782fa56..3bf2f395effcc3 100644 --- a/tools/eslint/node_modules/jsonify/package.json +++ b/tools/eslint/node_modules/jsonify/package.json @@ -59,7 +59,7 @@ }, "dist": { "shasum": "2c74b6ee41d93ca51b7b5aaee8f503631d252a73", - "tarball": "http://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz" + "tarball": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz" }, "engines": { "node": "*" diff --git a/tools/eslint/node_modules/string-width/index.js b/tools/eslint/node_modules/string-width/index.js index aa2f839b6dd2ce..b9bec62440a468 100644 --- a/tools/eslint/node_modules/string-width/index.js +++ b/tools/eslint/node_modules/string-width/index.js @@ -16,6 +16,11 @@ module.exports = function (str) { for (var i = 0; i < str.length; i++) { var code = codePointAt(str, i); + // ignore control characters + if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) { + continue; + } + // surrogates if (code >= 0x10000) { i++; diff --git a/tools/eslint/node_modules/string-width/package.json b/tools/eslint/node_modules/string-width/package.json index 9a200671bcd90d..cb8d773631c18f 100644 --- a/tools/eslint/node_modules/string-width/package.json +++ b/tools/eslint/node_modules/string-width/package.json @@ -14,16 +14,20 @@ ] ], "_from": "string-width@>=1.0.1 <2.0.0", - "_id": "string-width@1.0.1", + "_id": "string-width@1.0.2", "_inCache": true, "_installable": true, "_location": "/string-width", - "_nodeVersion": "0.12.5", + "_nodeVersion": "4.4.5", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/string-width-1.0.2.tgz_1471188233009_0.6573935742489994" + }, "_npmUser": { "name": "sindresorhus", "email": "sindresorhus@gmail.com" }, - "_npmVersion": "2.11.2", + "_npmVersion": "2.15.5", "_phantomChildren": {}, "_requested": { "raw": "string-width@^1.0.1", @@ -38,8 +42,8 @@ "/inquirer", "/table" ], - "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.1.tgz", - "_shasum": "c92129b6f1d7f52acf9af424a26e3864a05ceb0a", + "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "_shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", "_shrinkwrap": null, "_spec": "string-width@^1.0.1", "_where": "/Users/trott/io.js/tools/node_modules/inquirer", @@ -58,12 +62,13 @@ }, "description": "Get the visual width of a string - the number of columns required to display it", "devDependencies": { - "ava": "0.0.4" + "ava": "*", + "xo": "*" }, "directories": {}, "dist": { - "shasum": "c92129b6f1d7f52acf9af424a26e3864a05ceb0a", - "tarball": "http://registry.npmjs.org/string-width/-/string-width-1.0.1.tgz" + "shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", + "tarball": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz" }, "engines": { "node": ">=0.10.0" @@ -71,8 +76,8 @@ "files": [ "index.js" ], - "gitHead": "f279cfd14835f0a3c8df69ba18e9a3960156e135", - "homepage": "https://github.com/sindresorhus/string-width", + "gitHead": "282cf3d53918a92cc3ee0778dcf938039bcbc47b", + "homepage": "https://github.com/sindresorhus/string-width#readme", "keywords": [ "string", "str", @@ -114,7 +119,7 @@ "url": "git+https://github.com/sindresorhus/string-width.git" }, "scripts": { - "test": "node test.js" + "test": "xo && ava" }, - "version": "1.0.1" + "version": "1.0.2" } diff --git a/tools/eslint/node_modules/string-width/readme.md b/tools/eslint/node_modules/string-width/readme.md index a7737a986c5736..1ab42c93580ecb 100644 --- a/tools/eslint/node_modules/string-width/readme.md +++ b/tools/eslint/node_modules/string-width/readme.md @@ -2,7 +2,7 @@ > Get the visual width of a string - the number of columns required to display it -Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. +Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. Useful to be able to measure the actual width of command-line output. @@ -17,7 +17,7 @@ $ npm install --save string-width ## Usage ```js -var stringWidth = require('string-width'); +const stringWidth = require('string-width'); stringWidth('古'); //=> 2 @@ -34,8 +34,9 @@ stringWidth('a'); - [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module - [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string +- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/tools/eslint/package.json b/tools/eslint/package.json index 00417309654145..9beea6849e01e1 100644 --- a/tools/eslint/package.json +++ b/tools/eslint/package.json @@ -14,14 +14,14 @@ ] ], "_from": "eslint@latest", - "_id": "eslint@3.3.0", + "_id": "eslint@3.4.0", "_inCache": true, "_installable": true, "_location": "/eslint", "_nodeVersion": "4.4.7", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/eslint-3.3.0.tgz_1471027082338_0.7748861608561128" + "tmp": "tmp/eslint-3.4.0.tgz_1472234173647_0.17217218782752752" }, "_npmUser": { "name": "eslint", @@ -41,8 +41,8 @@ "_requiredBy": [ "#USER" ], - "_resolved": "https://registry.npmjs.org/eslint/-/eslint-3.3.0.tgz", - "_shasum": "9524700cf94f90f0447f34152e68e99d39034f57", + "_resolved": "https://registry.npmjs.org/eslint/-/eslint-3.4.0.tgz", + "_shasum": "af5984007bd3f1fb1b3b6b01a0a22eda0ec7a9f4", "_shrinkwrap": null, "_spec": "eslint", "_where": "/Users/trott/io.js/tools", @@ -65,10 +65,10 @@ "espree": "^3.1.6", "estraverse": "^4.2.0", "esutils": "^2.0.2", - "file-entry-cache": "^1.3.1", + "file-entry-cache": "^2.0.0", "glob": "^7.0.3", "globals": "^9.2.0", - "ignore": "^3.1.2", + "ignore": "^3.1.5", "imurmurhash": "^0.1.4", "inquirer": "^0.12.0", "is-my-json-valid": "^2.10.0", @@ -133,8 +133,8 @@ }, "directories": {}, "dist": { - "shasum": "9524700cf94f90f0447f34152e68e99d39034f57", - "tarball": "https://registry.npmjs.org/eslint/-/eslint-3.3.0.tgz" + "shasum": "af5984007bd3f1fb1b3b6b01a0a22eda0ec7a9f4", + "tarball": "https://registry.npmjs.org/eslint/-/eslint-3.4.0.tgz" }, "engines": { "node": ">=4" @@ -147,7 +147,7 @@ "lib", "messages" ], - "gitHead": "c66bcfec9fe0d166a5ed7b9910eb8cc802ff94d7", + "gitHead": "faab36e519ce8caf428da4567766e699464a2316", "homepage": "http://eslint.org", "keywords": [ "ast", @@ -194,5 +194,5 @@ "release": "node Makefile.js release", "test": "node Makefile.js test" }, - "version": "3.3.0" + "version": "3.4.0" }