From ef53149203c660101fa4d4cb9437416ce9e6e315 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 10 Jul 2017 11:14:37 -0700 Subject: [PATCH] tools: update ESLint to 4.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ESLint 4.2.0 contains a fix for a bug that is blocking us from moving to the non-legacy stricter indentation linting. Update to 4.2.0 to remove the blocking issue. PR-URL: https://github.com/nodejs/node/pull/14155 Ref: https://github.com/eslint/eslint/issues/8882 Ref: https://github.com/eslint/eslint/pull/8885 Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Gibson Fahnestock Reviewed-By: Refael Ackermann --- tools/eslint/conf/eslint-recommended.js | 1 + tools/eslint/lib/cli-engine.js | 7 +- tools/eslint/lib/cli.js | 13 +- tools/eslint/lib/config/config-validator.js | 33 +- tools/eslint/lib/linter.js | 9 +- tools/eslint/lib/rules/arrow-parens.js | 5 +- tools/eslint/lib/rules/comma-dangle.js | 80 +- tools/eslint/lib/rules/dot-notation.js | 9 + tools/eslint/lib/rules/getter-return.js | 151 + tools/eslint/lib/rules/indent.js | 114 +- tools/eslint/lib/rules/multiline-ternary.js | 10 +- tools/eslint/lib/rules/no-debugger.js | 7 +- tools/eslint/lib/rules/no-extra-parens.js | 31 +- tools/eslint/lib/rules/no-regex-spaces.js | 4 +- tools/eslint/lib/rules/no-sync.js | 18 +- tools/eslint/lib/testers/rule-tester.js | 19 +- tools/eslint/lib/util/ajv.js | 29 + tools/eslint/lib/util/source-code-fixer.js | 66 +- tools/eslint/node_modules/.bin/acorn | 1 - tools/eslint/node_modules/.bin/esparse | 1 - tools/eslint/node_modules/.bin/esvalidate | 1 - tools/eslint/node_modules/.bin/js-yaml | 1 - tools/eslint/node_modules/.bin/mkdirp | 1 - tools/eslint/node_modules/.bin/rimraf | 1 - .../acorn-jsx/node_modules/.bin/acorn | 1 - tools/eslint/node_modules/acorn/AUTHORS | 4 + tools/eslint/node_modules/acorn/LICENSE | 2 +- tools/eslint/node_modules/acorn/README.md | 49 +- tools/eslint/node_modules/acorn/bin/acorn | 66 +- .../node_modules/acorn/dist/acorn.es.js | 3283 +++--- tools/eslint/node_modules/acorn/dist/acorn.js | 3293 +++--- .../node_modules/acorn/dist/acorn_loose.es.js | 1298 +-- .../node_modules/acorn/dist/acorn_loose.js | 1302 +-- .../eslint/node_modules/acorn/dist/walk.es.js | 453 +- tools/eslint/node_modules/acorn/dist/walk.js | 461 +- tools/eslint/node_modules/acorn/package.json | 34 +- tools/eslint/node_modules/acorn/src/.eslintrc | 33 - .../node_modules/acorn/src/bin/.eslintrc | 6 - .../node_modules/acorn/src/bin/acorn.js | 62 - .../node_modules/acorn/src/expression.js | 830 -- .../node_modules/acorn/src/identifier.js | 85 - tools/eslint/node_modules/acorn/src/index.js | 78 - .../eslint/node_modules/acorn/src/location.js | 26 - .../eslint/node_modules/acorn/src/locutil.js | 42 - .../acorn/src/loose/expression.js | 562 - .../node_modules/acorn/src/loose/index.js | 49 - .../node_modules/acorn/src/loose/parseutil.js | 1 - .../node_modules/acorn/src/loose/state.js | 161 - .../node_modules/acorn/src/loose/statement.js | 448 - .../node_modules/acorn/src/loose/tokenize.js | 111 - tools/eslint/node_modules/acorn/src/lval.js | 236 - tools/eslint/node_modules/acorn/src/node.js | 50 - .../eslint/node_modules/acorn/src/options.js | 127 - .../node_modules/acorn/src/parseutil.js | 128 - tools/eslint/node_modules/acorn/src/scope.js | 75 - tools/eslint/node_modules/acorn/src/state.js | 115 - .../node_modules/acorn/src/statement.js | 765 -- .../node_modules/acorn/src/tokencontext.js | 139 - .../eslint/node_modules/acorn/src/tokenize.js | 687 -- .../node_modules/acorn/src/tokentype.js | 147 - tools/eslint/node_modules/acorn/src/util.js | 11 - .../node_modules/acorn/src/walk/index.js | 342 - .../node_modules/acorn/src/whitespace.js | 13 - .../eslint/node_modules/ajv/.tonic_example.js | 2 +- tools/eslint/node_modules/ajv/README.md | 269 +- .../node_modules/ajv/dist/ajv.bundle.js | 3665 +++--- tools/eslint/node_modules/ajv/dist/ajv.min.js | 7 +- .../node_modules/ajv/dist/ajv.min.js.map | 2 +- .../node_modules/ajv/dist/nodent.min.js | 8 +- .../node_modules/ajv/dist/regenerator.min.js | 32 +- tools/eslint/node_modules/ajv/lib/$data.js | 49 + tools/eslint/node_modules/ajv/lib/ajv.d.ts | 84 +- tools/eslint/node_modules/ajv/lib/ajv.js | 677 +- .../node_modules/ajv/lib/compile/_rules.js | 3 + .../node_modules/ajv/lib/compile/async.js | 90 + .../node_modules/ajv/lib/compile/equal.js | 44 +- .../ajv/lib/compile/error_classes.js | 34 + .../node_modules/ajv/lib/compile/formats.js | 79 +- .../node_modules/ajv/lib/compile/index.js | 59 +- .../node_modules/ajv/lib/compile/resolve.js | 104 +- .../node_modules/ajv/lib/compile/rules.js | 34 +- .../node_modules/ajv/lib/compile/util.js | 28 +- .../node_modules/ajv/lib/dot/_limit.jst | 79 +- .../eslint/node_modules/ajv/lib/dot/anyOf.jst | 2 +- .../eslint/node_modules/ajv/lib/dot/const.jst | 11 + .../node_modules/ajv/lib/dot/contains.jst | 57 + .../node_modules/ajv/lib/dot/custom.jst | 23 +- .../node_modules/ajv/lib/dot/definitions.def | 25 +- .../node_modules/ajv/lib/dot/dependencies.jst | 37 +- .../node_modules/ajv/lib/dot/errors.def | 23 +- .../node_modules/ajv/lib/dot/format.jst | 40 +- .../eslint/node_modules/ajv/lib/dot/items.jst | 1 - .../node_modules/ajv/lib/dot/missing.def | 19 +- .../eslint/node_modules/ajv/lib/dot/oneOf.jst | 2 +- .../node_modules/ajv/lib/dot/properties.jst | 80 +- .../ajv/lib/dot/propertyNames.jst | 54 + tools/eslint/node_modules/ajv/lib/dot/ref.jst | 21 +- .../node_modules/ajv/lib/dot/required.jst | 20 +- .../node_modules/ajv/lib/dot/validate.jst | 184 +- .../node_modules/ajv/lib/dotjs/_limit.js | 65 +- .../node_modules/ajv/lib/dotjs/_limitItems.js | 4 +- .../ajv/lib/dotjs/_limitLength.js | 4 +- .../ajv/lib/dotjs/_limitProperties.js | 4 +- .../node_modules/ajv/lib/dotjs/allOf.js | 2 +- .../node_modules/ajv/lib/dotjs/anyOf.js | 14 +- .../node_modules/ajv/lib/dotjs/const.js | 55 + .../node_modules/ajv/lib/dotjs/contains.js | 81 + .../node_modules/ajv/lib/dotjs/custom.js | 24 +- .../ajv/lib/dotjs/dependencies.js | 190 +- .../eslint/node_modules/ajv/lib/dotjs/enum.js | 4 +- .../node_modules/ajv/lib/dotjs/format.js | 35 +- .../node_modules/ajv/lib/dotjs/items.js | 8 +- .../node_modules/ajv/lib/dotjs/multipleOf.js | 6 +- .../eslint/node_modules/ajv/lib/dotjs/not.js | 2 +- .../node_modules/ajv/lib/dotjs/oneOf.js | 16 +- .../node_modules/ajv/lib/dotjs/pattern.js | 4 +- .../node_modules/ajv/lib/dotjs/properties.js | 121 +- .../ajv/lib/dotjs/propertyNames.js | 81 + .../eslint/node_modules/ajv/lib/dotjs/ref.js | 26 +- .../node_modules/ajv/lib/dotjs/required.js | 49 +- .../node_modules/ajv/lib/dotjs/uniqueItems.js | 4 +- .../node_modules/ajv/lib/dotjs/validate.js | 391 +- tools/eslint/node_modules/ajv/lib/keyword.js | 9 +- .../node_modules/ajv/lib/patternGroups.js | 36 + .../node_modules/ajv/lib/refs/$data.json | 17 + .../ajv/lib/refs/json-schema-draft-06.json | 150 + .../ajv/lib/refs/json-schema-v5.json | 84 +- tools/eslint/node_modules/ajv/package.json | 47 +- .../eslint/node_modules/ajv/scripts/bundle.js | 19 +- .../node_modules/ajv/scripts/compile-dots.js | 4 +- tools/eslint/node_modules/bail/history.md | 12 - tools/eslint/node_modules/bail/index.js | 25 - tools/eslint/node_modules/bail/package.json | 46 +- tools/eslint/node_modules/bail/readme.md | 8 +- tools/eslint/node_modules/chalk/package.json | 1 - .../character-entities-legacy/package.json | 3 +- tools/eslint/node_modules/co/package.json | 3 +- .../collapse-white-space/package.json | 10 +- .../eslint/node_modules/color-convert/LICENSE | 21 + .../node_modules/color-convert/README.md | 68 + .../node_modules/color-convert/conversions.js | 861 ++ .../node_modules/color-convert/index.js | 78 + .../node_modules/color-convert/package.json | 81 + .../node_modules/color-convert/route.js | 98 + tools/eslint/node_modules/color-name/LICENSE | 8 + .../eslint/node_modules/color-name/README.md | 11 + tools/eslint/node_modules/color-name/index.js | 150 + .../node_modules/color-name/package.json | 56 + .../escape-string-regexp/package.json | 3 +- .../eslint-plugin-markdown/package.json | 14 +- tools/eslint/node_modules/esprima/README.md | 8 +- .../node_modules/esprima/bin/esparse.js | 0 .../node_modules/esprima/bin/esvalidate.js | 2 +- .../node_modules/esprima/dist/esprima.js | 9969 +++++++++-------- .../eslint/node_modules/esprima/package.json | 45 +- tools/eslint/node_modules/extend/package.json | 4 +- .../fast-deep-equal/.eslintrc.yml | 25 + .../LICENSE.md => fast-deep-equal/LICENSE} | 12 +- .../node_modules/fast-deep-equal/README.md | 55 + .../node_modules/fast-deep-equal/index.js | 43 + .../node_modules/fast-deep-equal/package.json | 78 + .../node_modules/generate-function/README.md | 72 - .../node_modules/generate-function/example.js | 27 - .../node_modules/generate-function/index.js | 61 - .../generate-function/package.json | 56 - .../generate-object-property/README.md | 19 - .../generate-object-property/index.js | 12 - .../generate-object-property/package.json | 53 - tools/eslint/node_modules/has-flag/index.js | 10 + .../{is-property/LICENSE => has-flag/license} | 3 +- .../eslint/node_modules/has-flag/package.json | 93 + tools/eslint/node_modules/has-flag/readme.md | 67 + tools/eslint/node_modules/has/package.json | 4 +- tools/eslint/node_modules/inquirer/README.md | 17 + .../node_modules/inquirer/lib/prompts/list.js | 7 +- .../node_modules/inquirer/lib/ui/baseUI.js | 6 +- .../inquirer/lib/utils/paginator.js | 2 +- .../inquirer/node_modules/ansi-regex/index.js | 10 + .../inquirer/node_modules/ansi-regex/license | 9 + .../node_modules/ansi-regex/package.json | 85 + .../node_modules/ansi-regex/readme.md | 46 + .../node_modules/ansi-styles/index.js | 143 + .../node_modules/ansi-styles/license} | 4 +- .../node_modules/ansi-styles/package.json | 103 + .../node_modules/ansi-styles/readme.md | 135 + .../inquirer/node_modules/chalk/index.js | 214 + .../inquirer/node_modules/chalk/license | 9 + .../inquirer/node_modules/chalk/package.json | 94 + .../inquirer/node_modules/chalk/readme.md | 302 + .../inquirer/node_modules/chalk/templates.js | 175 + .../inquirer/node_modules/strip-ansi/index.js | 4 + .../inquirer/node_modules/strip-ansi/license | 9 + .../node_modules/strip-ansi/package.json | 84 + .../node_modules/strip-ansi/readme.md | 39 + .../node_modules/supports-color/browser.js | 2 + .../node_modules/supports-color/index.js | 115 + .../node_modules/supports-color/license | 9 + .../node_modules/supports-color/package.json | 85 + .../node_modules/supports-color/readme.md | 66 + .../eslint/node_modules/inquirer/package.json | 28 +- .../node_modules/is-alphabetical/package.json | 5 +- .../is-alphanumerical/package.json | 3 +- .../node_modules/is-buffer/package.json | 4 +- .../node_modules/is-decimal/package.json | 5 +- .../node_modules/is-hexadecimal/package.json | 3 +- .../node_modules/is-my-json-valid/README.md | 200 - .../node_modules/is-my-json-valid/example.js | 18 - .../node_modules/is-my-json-valid/formats.js | 14 - .../node_modules/is-my-json-valid/index.js | 590 - .../is-my-json-valid/package.json | 61 - .../node_modules/is-my-json-valid/require.js | 12 - .../node_modules/is-plain-obj/package.json | 4 +- .../eslint/node_modules/is-property/README.md | 28 - .../node_modules/is-property/is-property.js | 5 - .../node_modules/is-property/package.json | 63 - .../is-whitespace-character/package.json | 4 +- .../is-word-character/package.json | 4 +- .../node_modules/js-tokens/package.json | 16 +- tools/eslint/node_modules/js-tokens/readme.md | 4 +- tools/eslint/node_modules/js-yaml/README.md | 9 +- .../node_modules/js-yaml/dist/js-yaml.js | 32 +- .../node_modules/js-yaml/dist/js-yaml.min.js | 2 +- .../js-yaml/lib/js-yaml/dumper.js | 5 +- .../js-yaml/lib/js-yaml/loader.js | 25 +- .../eslint/node_modules/js-yaml/package.json | 14 +- .../json-schema-traverse/.eslintrc.yml | 27 + .../node_modules/json-schema-traverse/LICENSE | 21 + .../json-schema-traverse/README.md | 69 + .../json-schema-traverse/index.js | 81 + .../json-schema-traverse/package.json | 70 + .../json-stable-stringify/package.json | 3 +- .../eslint/node_modules/jsonpointer/README.md | 39 - .../node_modules/jsonpointer/jsonpointer.js | 93 - .../node_modules/jsonpointer/package.json | 72 - .../markdown-escapes/package.json | 4 +- .../node_modules/parse-entities/package.json | 3 +- .../node_modules/readable-stream/README.md | 4 +- .../readable-stream/lib/_stream_readable.js | 5 +- .../readable-stream/lib/_stream_writable.js | 5 +- .../node_modules/readable-stream/package.json | 14 +- .../node_modules/remark-parse/package.json | 50 +- .../node_modules/repeat-string/package.json | 3 +- tools/eslint/node_modules/replace-ext/LICENSE | 0 .../node_modules/replace-ext/package.json | 4 +- .../node_modules/safe-buffer/package.json | 10 +- .../node_modules/state-toggle/package.json | 4 +- .../node_modules/string-width/package.json | 10 +- .../node_modules/string_decoder/package.json | 10 +- .../node_modules/strip-ansi/package.json | 3 +- .../table/node_modules/ajv/.tonic_example.js | 20 + .../node_modules/ajv}/LICENSE | 11 +- .../table/node_modules/ajv/README.md | 1213 ++ .../table/node_modules/ajv/dist/ajv.bundle.js | 8023 +++++++++++++ .../table/node_modules/ajv/dist/ajv.min.js | 6 + .../node_modules/ajv/dist/ajv.min.js.map | 1 + .../table/node_modules/ajv/dist/nodent.min.js | 8 + .../node_modules/ajv/dist/regenerator.min.js | 32 + .../table/node_modules/ajv/lib/ajv.d.ts | 284 + .../table/node_modules/ajv/lib/ajv.js | 420 + .../{ => table/node_modules}/ajv/lib/async.js | 0 .../table/node_modules/ajv/lib/cache.js | 26 + .../node_modules/ajv/lib/compile/_rules.js | 28 + .../node_modules/ajv/lib/compile/equal.js | 45 + .../node_modules/ajv/lib/compile/formats.js | 164 + .../node_modules/ajv/lib/compile/index.js | 390 + .../node_modules/ajv/lib/compile/resolve.js | 267 + .../node_modules/ajv/lib/compile/rules.js | 40 + .../ajv/lib/compile/schema_obj.js | 9 + .../ajv/lib/compile/ucs2length.js | 20 + .../node_modules/ajv/lib/compile/util.js | 257 + .../ajv/lib/compile/validation_error.js | 0 .../table/node_modules/ajv/lib/dot/_limit.jst | 49 + .../node_modules/ajv/lib/dot/_limitItems.jst | 10 + .../node_modules/ajv/lib/dot/_limitLength.jst | 10 + .../ajv/lib/dot/_limitProperties.jst | 10 + .../table/node_modules/ajv/lib/dot/allOf.jst | 34 + .../table/node_modules/ajv/lib/dot/anyOf.jst | 48 + .../table/node_modules/ajv/lib/dot/coerce.def | 61 + .../table/node_modules/ajv/lib/dot/custom.jst | 184 + .../node_modules/ajv/lib/dot/defaults.def | 32 + .../node_modules/ajv/lib/dot/definitions.def | 182 + .../node_modules/ajv/lib/dot/dependencies.jst | 69 + .../table/node_modules/ajv/lib/dot/enum.jst | 30 + .../table/node_modules/ajv/lib/dot/errors.def | 185 + .../table/node_modules/ajv/lib/dot/format.jst | 100 + .../table/node_modules/ajv/lib/dot/items.jst | 101 + .../node_modules/ajv/lib/dot/missing.def | 34 + .../node_modules/ajv/lib/dot/multipleOf.jst | 20 + .../table/node_modules/ajv/lib/dot/not.jst | 43 + .../table/node_modules/ajv/lib/dot/oneOf.jst | 44 + .../node_modules/ajv/lib/dot/pattern.jst | 14 + .../node_modules/ajv/lib/dot/properties.jst | 319 + .../table/node_modules/ajv/lib/dot/ref.jst | 86 + .../node_modules/ajv/lib/dot/required.jst | 96 + .../node_modules/ajv/lib/dot/uniqueItems.jst | 38 + .../ajv/lib/dot/v5/_formatLimit.jst | 0 .../node_modules}/ajv/lib/dot/v5/constant.jst | 0 .../ajv/lib/dot/v5/patternRequired.jst | 0 .../node_modules}/ajv/lib/dot/v5/switch.jst | 0 .../node_modules/ajv/lib/dot/validate.jst | 210 + .../node_modules/ajv/lib/dotjs/README.md | 3 + .../ajv/lib/dotjs/_formatLimit.js | 0 .../node_modules/ajv/lib/dotjs/_limit.js | 124 + .../node_modules/ajv/lib/dotjs/_limitItems.js | 76 + .../ajv/lib/dotjs/_limitLength.js | 81 + .../ajv/lib/dotjs/_limitProperties.js | 76 + .../table/node_modules/ajv/lib/dotjs/allOf.js | 43 + .../table/node_modules/ajv/lib/dotjs/anyOf.js | 65 + .../node_modules}/ajv/lib/dotjs/constant.js | 0 .../node_modules/ajv/lib/dotjs/custom.js | 220 + .../ajv/lib/dotjs/dependencies.js | 147 + .../table/node_modules/ajv/lib/dotjs/enum.js | 65 + .../node_modules/ajv/lib/dotjs/format.js | 138 + .../table/node_modules/ajv/lib/dotjs/items.js | 144 + .../node_modules/ajv/lib/dotjs/multipleOf.js | 76 + .../table/node_modules/ajv/lib/dotjs/not.js | 83 + .../table/node_modules/ajv/lib/dotjs/oneOf.js | 76 + .../node_modules/ajv/lib/dotjs/pattern.js | 74 + .../ajv/lib/dotjs/patternRequired.js | 0 .../node_modules/ajv/lib/dotjs/properties.js | 445 + .../table/node_modules/ajv/lib/dotjs/ref.js | 119 + .../node_modules/ajv/lib/dotjs/required.js | 249 + .../node_modules}/ajv/lib/dotjs/switch.js | 0 .../node_modules/ajv/lib/dotjs/uniqueItems.js | 71 + .../node_modules/ajv/lib/dotjs/validate.js | 375 + .../table/node_modules/ajv/lib/keyword.js | 129 + .../ajv/lib/refs/json-schema-draft-04.json} | 0 .../ajv/lib/refs/json-schema-v5.json | 328 + .../{ => table/node_modules}/ajv/lib/v5.js | 0 .../table/node_modules/ajv/package.json | 131 + .../node_modules/ajv/scripts/.eslintrc.yml | 3 + .../table/node_modules/ajv/scripts/bundle.js | 54 + .../node_modules/ajv/scripts/compile-dots.js | 73 + .../table/node_modules/ajv/scripts/info | 10 + .../node_modules/ajv/scripts/prepare-tests | 9 + .../node_modules/ajv/scripts/travis-gh-pages | 23 + tools/eslint/node_modules/table/package.json | 5 +- tools/eslint/node_modules/trough/history.md | 6 - tools/eslint/node_modules/trough/index.js | 63 +- tools/eslint/node_modules/trough/package.json | 56 +- tools/eslint/node_modules/trough/readme.md | 100 +- .../eslint/node_modules/unherit/package.json | 3 +- .../eslint/node_modules/unified/package.json | 80 +- .../package.json | 4 +- tools/eslint/node_modules/vfile/package.json | 93 +- .../node_modules/x-is-function/package.json | 4 +- .../node_modules/x-is-string/package.json | 4 +- tools/eslint/node_modules/xtend/package.json | 17 +- tools/eslint/package-lock.json | 560 +- tools/eslint/package.json | 16 +- 350 files changed, 36664 insertions(+), 20632 deletions(-) create mode 100644 tools/eslint/lib/rules/getter-return.js create mode 100644 tools/eslint/lib/util/ajv.js delete mode 120000 tools/eslint/node_modules/.bin/acorn delete mode 120000 tools/eslint/node_modules/.bin/esparse delete mode 120000 tools/eslint/node_modules/.bin/esvalidate delete mode 120000 tools/eslint/node_modules/.bin/js-yaml delete mode 120000 tools/eslint/node_modules/.bin/mkdirp delete mode 120000 tools/eslint/node_modules/.bin/rimraf delete mode 120000 tools/eslint/node_modules/acorn-jsx/node_modules/.bin/acorn mode change 100755 => 100644 tools/eslint/node_modules/acorn/bin/acorn delete mode 100644 tools/eslint/node_modules/acorn/src/.eslintrc delete mode 100644 tools/eslint/node_modules/acorn/src/bin/.eslintrc delete mode 100644 tools/eslint/node_modules/acorn/src/bin/acorn.js delete mode 100644 tools/eslint/node_modules/acorn/src/expression.js delete mode 100644 tools/eslint/node_modules/acorn/src/identifier.js delete mode 100644 tools/eslint/node_modules/acorn/src/index.js delete mode 100644 tools/eslint/node_modules/acorn/src/location.js delete mode 100644 tools/eslint/node_modules/acorn/src/locutil.js delete mode 100644 tools/eslint/node_modules/acorn/src/loose/expression.js delete mode 100644 tools/eslint/node_modules/acorn/src/loose/index.js delete mode 100644 tools/eslint/node_modules/acorn/src/loose/parseutil.js delete mode 100644 tools/eslint/node_modules/acorn/src/loose/state.js delete mode 100644 tools/eslint/node_modules/acorn/src/loose/statement.js delete mode 100644 tools/eslint/node_modules/acorn/src/loose/tokenize.js delete mode 100644 tools/eslint/node_modules/acorn/src/lval.js delete mode 100644 tools/eslint/node_modules/acorn/src/node.js delete mode 100644 tools/eslint/node_modules/acorn/src/options.js delete mode 100644 tools/eslint/node_modules/acorn/src/parseutil.js delete mode 100644 tools/eslint/node_modules/acorn/src/scope.js delete mode 100644 tools/eslint/node_modules/acorn/src/state.js delete mode 100644 tools/eslint/node_modules/acorn/src/statement.js delete mode 100644 tools/eslint/node_modules/acorn/src/tokencontext.js delete mode 100644 tools/eslint/node_modules/acorn/src/tokenize.js delete mode 100644 tools/eslint/node_modules/acorn/src/tokentype.js delete mode 100644 tools/eslint/node_modules/acorn/src/util.js delete mode 100644 tools/eslint/node_modules/acorn/src/walk/index.js delete mode 100644 tools/eslint/node_modules/acorn/src/whitespace.js create mode 100644 tools/eslint/node_modules/ajv/lib/$data.js create mode 100644 tools/eslint/node_modules/ajv/lib/compile/async.js create mode 100644 tools/eslint/node_modules/ajv/lib/compile/error_classes.js create mode 100644 tools/eslint/node_modules/ajv/lib/dot/const.jst create mode 100644 tools/eslint/node_modules/ajv/lib/dot/contains.jst create mode 100644 tools/eslint/node_modules/ajv/lib/dot/propertyNames.jst create mode 100644 tools/eslint/node_modules/ajv/lib/dotjs/const.js create mode 100644 tools/eslint/node_modules/ajv/lib/dotjs/contains.js create mode 100644 tools/eslint/node_modules/ajv/lib/dotjs/propertyNames.js create mode 100644 tools/eslint/node_modules/ajv/lib/patternGroups.js create mode 100644 tools/eslint/node_modules/ajv/lib/refs/$data.json create mode 100644 tools/eslint/node_modules/ajv/lib/refs/json-schema-draft-06.json delete mode 100644 tools/eslint/node_modules/bail/history.md create mode 100644 tools/eslint/node_modules/color-convert/LICENSE create mode 100644 tools/eslint/node_modules/color-convert/README.md create mode 100644 tools/eslint/node_modules/color-convert/conversions.js create mode 100644 tools/eslint/node_modules/color-convert/index.js create mode 100644 tools/eslint/node_modules/color-convert/package.json create mode 100644 tools/eslint/node_modules/color-convert/route.js create mode 100644 tools/eslint/node_modules/color-name/LICENSE create mode 100644 tools/eslint/node_modules/color-name/README.md create mode 100644 tools/eslint/node_modules/color-name/index.js create mode 100644 tools/eslint/node_modules/color-name/package.json mode change 100755 => 100644 tools/eslint/node_modules/esprima/bin/esparse.js mode change 100755 => 100644 tools/eslint/node_modules/esprima/bin/esvalidate.js create mode 100644 tools/eslint/node_modules/fast-deep-equal/.eslintrc.yml rename tools/eslint/node_modules/{jsonpointer/LICENSE.md => fast-deep-equal/LICENSE} (81%) create mode 100644 tools/eslint/node_modules/fast-deep-equal/README.md create mode 100644 tools/eslint/node_modules/fast-deep-equal/index.js create mode 100644 tools/eslint/node_modules/fast-deep-equal/package.json delete mode 100644 tools/eslint/node_modules/generate-function/README.md delete mode 100644 tools/eslint/node_modules/generate-function/example.js delete mode 100644 tools/eslint/node_modules/generate-function/index.js delete mode 100644 tools/eslint/node_modules/generate-function/package.json delete mode 100644 tools/eslint/node_modules/generate-object-property/README.md delete mode 100644 tools/eslint/node_modules/generate-object-property/index.js delete mode 100644 tools/eslint/node_modules/generate-object-property/package.json create mode 100644 tools/eslint/node_modules/has-flag/index.js rename tools/eslint/node_modules/{is-property/LICENSE => has-flag/license} (93%) create mode 100644 tools/eslint/node_modules/has-flag/package.json create mode 100644 tools/eslint/node_modules/has-flag/readme.md create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-regex/index.js create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-regex/license create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-regex/package.json create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-regex/readme.md create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-styles/index.js rename tools/eslint/node_modules/{generate-object-property/LICENSE => inquirer/node_modules/ansi-styles/license} (92%) create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-styles/package.json create mode 100644 tools/eslint/node_modules/inquirer/node_modules/ansi-styles/readme.md create mode 100644 tools/eslint/node_modules/inquirer/node_modules/chalk/index.js create mode 100644 tools/eslint/node_modules/inquirer/node_modules/chalk/license create mode 100644 tools/eslint/node_modules/inquirer/node_modules/chalk/package.json create mode 100644 tools/eslint/node_modules/inquirer/node_modules/chalk/readme.md create mode 100644 tools/eslint/node_modules/inquirer/node_modules/chalk/templates.js create mode 100644 tools/eslint/node_modules/inquirer/node_modules/strip-ansi/index.js create mode 100644 tools/eslint/node_modules/inquirer/node_modules/strip-ansi/license create mode 100644 tools/eslint/node_modules/inquirer/node_modules/strip-ansi/package.json create mode 100644 tools/eslint/node_modules/inquirer/node_modules/strip-ansi/readme.md create mode 100644 tools/eslint/node_modules/inquirer/node_modules/supports-color/browser.js create mode 100644 tools/eslint/node_modules/inquirer/node_modules/supports-color/index.js create mode 100644 tools/eslint/node_modules/inquirer/node_modules/supports-color/license create mode 100644 tools/eslint/node_modules/inquirer/node_modules/supports-color/package.json create mode 100644 tools/eslint/node_modules/inquirer/node_modules/supports-color/readme.md delete mode 100644 tools/eslint/node_modules/is-my-json-valid/README.md delete mode 100644 tools/eslint/node_modules/is-my-json-valid/example.js delete mode 100644 tools/eslint/node_modules/is-my-json-valid/formats.js delete mode 100644 tools/eslint/node_modules/is-my-json-valid/index.js delete mode 100644 tools/eslint/node_modules/is-my-json-valid/package.json delete mode 100644 tools/eslint/node_modules/is-my-json-valid/require.js delete mode 100644 tools/eslint/node_modules/is-property/README.md delete mode 100644 tools/eslint/node_modules/is-property/is-property.js delete mode 100644 tools/eslint/node_modules/is-property/package.json create mode 100644 tools/eslint/node_modules/json-schema-traverse/.eslintrc.yml create mode 100644 tools/eslint/node_modules/json-schema-traverse/LICENSE create mode 100644 tools/eslint/node_modules/json-schema-traverse/README.md create mode 100644 tools/eslint/node_modules/json-schema-traverse/index.js create mode 100644 tools/eslint/node_modules/json-schema-traverse/package.json delete mode 100644 tools/eslint/node_modules/jsonpointer/README.md delete mode 100644 tools/eslint/node_modules/jsonpointer/jsonpointer.js delete mode 100644 tools/eslint/node_modules/jsonpointer/package.json mode change 100644 => 100755 tools/eslint/node_modules/replace-ext/LICENSE create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/.tonic_example.js rename tools/eslint/node_modules/{is-my-json-valid => table/node_modules/ajv}/LICENSE (88%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/README.md create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/dist/ajv.bundle.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/dist/ajv.min.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/dist/ajv.min.js.map create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/dist/nodent.min.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/dist/regenerator.min.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/ajv.d.ts create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/ajv.js rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/async.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/cache.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/_rules.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/equal.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/formats.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/index.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/resolve.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/rules.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/schema_obj.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/ucs2length.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/compile/util.js rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/compile/validation_error.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/_limit.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/_limitItems.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/_limitLength.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/_limitProperties.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/allOf.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/anyOf.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/coerce.def create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/custom.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/defaults.def create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/definitions.def create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/dependencies.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/enum.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/errors.def create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/format.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/items.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/missing.def create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/multipleOf.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/not.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/oneOf.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/pattern.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/properties.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/ref.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/required.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/uniqueItems.jst rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dot/v5/_formatLimit.jst (100%) rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dot/v5/constant.jst (100%) rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dot/v5/patternRequired.jst (100%) rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dot/v5/switch.jst (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dot/validate.jst create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/README.md rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dotjs/_formatLimit.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/_limit.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/_limitItems.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/_limitLength.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/_limitProperties.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/allOf.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/anyOf.js rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dotjs/constant.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/custom.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/dependencies.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/enum.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/format.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/items.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/multipleOf.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/not.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/oneOf.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/pattern.js rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dotjs/patternRequired.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/properties.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/ref.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/required.js rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/dotjs/switch.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/uniqueItems.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/dotjs/validate.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/keyword.js rename tools/eslint/{conf/json-schema-schema.json => node_modules/table/node_modules/ajv/lib/refs/json-schema-draft-04.json} (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/lib/refs/json-schema-v5.json rename tools/eslint/node_modules/{ => table/node_modules}/ajv/lib/v5.js (100%) create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/package.json create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/scripts/.eslintrc.yml create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/scripts/bundle.js create mode 100644 tools/eslint/node_modules/table/node_modules/ajv/scripts/compile-dots.js create mode 100755 tools/eslint/node_modules/table/node_modules/ajv/scripts/info create mode 100755 tools/eslint/node_modules/table/node_modules/ajv/scripts/prepare-tests create mode 100755 tools/eslint/node_modules/table/node_modules/ajv/scripts/travis-gh-pages delete mode 100644 tools/eslint/node_modules/trough/history.md diff --git a/tools/eslint/conf/eslint-recommended.js b/tools/eslint/conf/eslint-recommended.js index 0d8d19e447d42c..1a2e2f8e7ff976 100755 --- a/tools/eslint/conf/eslint-recommended.js +++ b/tools/eslint/conf/eslint-recommended.js @@ -48,6 +48,7 @@ module.exports = { "func-names": "off", "func-style": "off", "generator-star-spacing": "off", + "getter-return": "off", "global-require": "off", "guard-for-in": "off", "handle-callback-err": "off", diff --git a/tools/eslint/lib/cli-engine.js b/tools/eslint/lib/cli-engine.js index 8d5ab065fe5b7c..1abc1fd2c6bc84 100644 --- a/tools/eslint/lib/cli-engine.js +++ b/tools/eslint/lib/cli-engine.js @@ -45,7 +45,7 @@ const debug = require("debug")("eslint:cli-engine"); * @property {string} cwd The value to use for the current working directory. * @property {string[]} envs An array of environments to load. * @property {string[]} extensions An array of file extensions to check. - * @property {boolean} fix Execute in autofix mode. + * @property {boolean|Function} fix Execute in autofix mode. If a function, should return a boolean. * @property {string[]} globals An array of global variables to declare. * @property {boolean} ignore False disables use of .eslintignore. * @property {string} ignorePath The ignore file to use instead of .eslintignore. @@ -135,7 +135,7 @@ function calculateStatsPerRun(results) { * @param {string} text The source code to check. * @param {Object} configHelper The configuration options for ESLint. * @param {string} filename An optional string representing the texts filename. - * @param {boolean} fix Indicates if fixes should be processed. + * @param {boolean|Function} fix Indicates if fixes should be processed. * @param {boolean} allowInlineConfig Allow/ignore comments that change config. * @param {Linter} linter Linter context * @returns {LintResult} The results for linting on this text. @@ -195,7 +195,8 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, linte if (fix) { fixedResult = linter.verifyAndFix(text, config, { filename, - allowInlineConfig + allowInlineConfig, + fix }); messages = fixedResult.messages; } else { diff --git a/tools/eslint/lib/cli.js b/tools/eslint/lib/cli.js index 530bfbc423d00e..d398477184b53d 100644 --- a/tools/eslint/lib/cli.js +++ b/tools/eslint/lib/cli.js @@ -28,6 +28,17 @@ const debug = require("debug")("eslint:cli"); // Helpers //------------------------------------------------------------------------------ +/** + * Predicate function for whether or not to apply fixes in quiet mode. + * If a message is a warning, do not apply a fix. + * @param {LintResult} lintResult The lint result. + * @returns {boolean} True if the lint message is an error (and thus should be + * autofixed), false otherwise. + */ +function quietFixPredicate(lintResult) { + return lintResult.severity === 2; +} + /** * Translates the CLI options into the options expected by the CLIEngine. * @param {Object} cliOptions The CLI options to translate. @@ -52,7 +63,7 @@ function translateOptions(cliOptions) { cache: cliOptions.cache, cacheFile: cliOptions.cacheFile, cacheLocation: cliOptions.cacheLocation, - fix: cliOptions.fix, + fix: cliOptions.fix && (cliOptions.quiet ? quietFixPredicate : true), allowInlineConfig: cliOptions.inlineConfig }; } diff --git a/tools/eslint/lib/config/config-validator.js b/tools/eslint/lib/config/config-validator.js index 8754485f449728..fb5a9656413095 100644 --- a/tools/eslint/lib/config/config-validator.js +++ b/tools/eslint/lib/config/config-validator.js @@ -9,7 +9,7 @@ // Requirements //------------------------------------------------------------------------------ -const schemaValidator = require("is-my-json-valid"), +const ajv = require("../util/ajv"), configSchema = require("../../conf/config-schema.js"), util = require("util"); @@ -20,6 +20,7 @@ const validators = { //------------------------------------------------------------------------------ // Private //------------------------------------------------------------------------------ +let validateSchema; /** * Gets a complete options schema for a rule. @@ -79,7 +80,7 @@ function validateRuleSchema(id, localOptions, rulesContext) { const schema = getRuleOptionsSchema(id, rulesContext); if (!validators.rules[id] && schema) { - validators.rules[id] = schemaValidator(schema, { verbose: true }); + validators.rules[id] = ajv.compile(schema); } const validateRule = validators.rules[id]; @@ -87,7 +88,7 @@ function validateRuleSchema(id, localOptions, rulesContext) { if (validateRule) { validateRule(localOptions); if (validateRule.errors) { - throw new Error(validateRule.errors.map(error => `\tValue "${error.value}" ${error.message}.\n`).join("")); + throw new Error(validateRule.errors.map(error => `\tValue "${error.data}" ${error.message}.\n`).join("")); } } } @@ -158,19 +159,23 @@ function validateRules(rulesConfig, source, rulesContext) { * @returns {string} Formatted error message */ function formatErrors(errors) { - return errors.map(error => { - if (error.message === "has additional properties") { - return `Unexpected top-level property "${error.value.replace(/^data\./, "")}"`; + if (error.keyword === "additionalProperties") { + const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty; + + return `Unexpected top-level property "${formattedPropertyPath}"`; } - if (error.message === "is the wrong type") { - const formattedField = error.field.replace(/^data\./, ""); - const formattedExpectedType = typeof error.type === "string" ? error.type : error.type.join("/"); - const formattedValue = JSON.stringify(error.value); + if (error.keyword === "type") { + const formattedField = error.dataPath.slice(1); + const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema; + const formattedValue = JSON.stringify(error.data); return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`; } - return `"${error.field.replace(/^(data\.)/, "")}" ${error.message}. Value: ${JSON.stringify(error.value)}`; + + const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath; + + return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`; }).map(message => `\t- ${message}.\n`).join(""); } @@ -181,10 +186,10 @@ function formatErrors(errors) { * @returns {void} */ function validateConfigSchema(config, source) { - const validator = schemaValidator(configSchema, { verbose: true }); + validateSchema = validateSchema || ajv.compile(configSchema); - if (!validator(config)) { - throw new Error(`${source}:\n\tESLint configuration is invalid:\n${formatErrors(validator.errors)}`); + if (!validateSchema(config)) { + throw new Error(`${source}:\n\tESLint configuration is invalid:\n${formatErrors(validateSchema.errors)}`); } } diff --git a/tools/eslint/lib/linter.js b/tools/eslint/lib/linter.js index d2f1f46574ca7f..ce759756e14fcc 100755 --- a/tools/eslint/lib/linter.js +++ b/tools/eslint/lib/linter.js @@ -1197,6 +1197,7 @@ class Linter extends EventEmitter { * @param {string} options.filename The filename from which the text was read. * @param {boolean} options.allowInlineConfig Flag indicating if inline comments * should be allowed. + * @param {boolean|Function} options.fix Determines whether fixes should be applied * @returns {Object} The result of the fix operation as returned from the * SourceCodeFixer. */ @@ -1205,6 +1206,8 @@ class Linter extends EventEmitter { fixedResult, fixed = false, passNumber = 0; + const debugTextDescription = options && options.filename || `${text.slice(0, 10)}...`; + const shouldFix = options && options.fix || true; /** * This loop continues until one of the following is true: @@ -1218,11 +1221,11 @@ class Linter extends EventEmitter { do { passNumber++; - debug(`Linting code for ${options.filename} (pass ${passNumber})`); + debug(`Linting code for ${debugTextDescription} (pass ${passNumber})`); messages = this.verify(text, config, options); - debug(`Generating fixed text for ${options.filename} (pass ${passNumber})`); - fixedResult = SourceCodeFixer.applyFixes(this.getSourceCode(), messages); + debug(`Generating fixed text for ${debugTextDescription} (pass ${passNumber})`); + fixedResult = SourceCodeFixer.applyFixes(this.getSourceCode(), messages, shouldFix); // stop if there are any syntax errors. // 'fixedResult.output' is a empty string. diff --git a/tools/eslint/lib/rules/arrow-parens.js b/tools/eslint/lib/rules/arrow-parens.js index 60a043bb31bd4e..d8ca0ecafb2382 100644 --- a/tools/eslint/lib/rules/arrow-parens.js +++ b/tools/eslint/lib/rules/arrow-parens.js @@ -66,7 +66,10 @@ module.exports = { */ function fixParamsWithParenthesis(fixer) { const paramToken = sourceCode.getTokenAfter(firstTokenOfParam); - const closingParenToken = sourceCode.getTokenAfter(paramToken); + + // ES8 allows Trailing commas in function parameter lists and calls + // https://github.com/eslint/eslint/issues/8834 + const closingParenToken = sourceCode.getTokenAfter(paramToken, astUtils.isClosingParenToken); const asyncToken = isAsync ? sourceCode.getTokenBefore(firstTokenOfParam) : null; const shouldAddSpaceForAsync = asyncToken && (asyncToken.end === firstTokenOfParam.start); diff --git a/tools/eslint/lib/rules/comma-dangle.js b/tools/eslint/lib/rules/comma-dangle.js index 17066d94791c6a..ddcc0cd229e977 100644 --- a/tools/eslint/lib/rules/comma-dangle.js +++ b/tools/eslint/lib/rules/comma-dangle.js @@ -81,49 +81,49 @@ module.exports = { category: "Stylistic Issues", recommended: false }, - fixable: "code", - - schema: [ - { - defs: { - value: { - enum: [ - "always", - "always-multiline", - "only-multiline", - "never" - ] - }, - valueWithIgnore: { - anyOf: [ - { - $ref: "#/defs/value" - }, - { - enum: ["ignore"] - } - ] - } + schema: { + definitions: { + value: { + enum: [ + "always-multiline", + "always", + "never", + "only-multiline" + ] }, - anyOf: [ - { - $ref: "#/defs/value" - }, - { - type: "object", - properties: { - arrays: { $refs: "#/defs/valueWithIgnore" }, - objects: { $refs: "#/defs/valueWithIgnore" }, - imports: { $refs: "#/defs/valueWithIgnore" }, - exports: { $refs: "#/defs/valueWithIgnore" }, - functions: { $refs: "#/defs/valueWithIgnore" } + valueWithIgnore: { + enum: [ + "always-multiline", + "always", + "ignore", + "never", + "only-multiline" + ] + } + }, + type: "array", + items: [ + { + oneOf: [ + { + $ref: "#/definitions/value" }, - additionalProperties: false - } - ] - } - ] + { + type: "object", + properties: { + arrays: { $ref: "#/definitions/valueWithIgnore" }, + objects: { $ref: "#/definitions/valueWithIgnore" }, + imports: { $ref: "#/definitions/valueWithIgnore" }, + exports: { $ref: "#/definitions/valueWithIgnore" }, + functions: { $ref: "#/definitions/valueWithIgnore" } + }, + additionalProperties: false + } + ] + } + ] + } }, create(context) { diff --git a/tools/eslint/lib/rules/dot-notation.js b/tools/eslint/lib/rules/dot-notation.js index 55225b8cc41908..142f0f24a00a20 100644 --- a/tools/eslint/lib/rules/dot-notation.js +++ b/tools/eslint/lib/rules/dot-notation.js @@ -116,6 +116,15 @@ module.exports = { return null; } + if (node.object.type === "Identifier" && node.object.name === "let") { + + /* + * A statement that starts with `let[` is parsed as a destructuring variable declaration, not + * a MemberExpression. + */ + return null; + } + return fixer.replaceTextRange( [dot.range[0], node.property.range[1]], `[${textAfterDot}"${node.property.name}"]` diff --git a/tools/eslint/lib/rules/getter-return.js b/tools/eslint/lib/rules/getter-return.js new file mode 100644 index 00000000000000..8a095ad296fd9f --- /dev/null +++ b/tools/eslint/lib/rules/getter-return.js @@ -0,0 +1,151 @@ +/** + * @fileoverview Enforces that a return statement is present in property getters. + * @author Aladdin-ADD(hh_2013@foxmail.com) + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("../ast-utils"); + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * Checks a given code path segment is reachable. + * + * @param {CodePathSegment} segment - A segment to check. + * @returns {boolean} `true` if the segment is reachable. + */ +function isReachable(segment) { + return segment.reachable; +} + +/** + * Gets a readable location. + * + * - FunctionExpression -> the function name or `function` keyword. + * + * @param {ASTNode} node - A function node to get. + * @returns {ASTNode|Token} The node or the token of a location. + */ +function getId(node) { + return node.id || node; +} + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "enforce `return` statements in getters", + category: "Possible Errors", + recommended: false + }, + fixable: null, + schema: [ + { + type: "object", + properties: { + allowImplicit: { + type: "boolean" + } + }, + additionalProperties: false + } + ] + }, + + create(context) { + + const options = context.options[0] || { allowImplicit: false }; + + let funcInfo = { + upper: null, + codePath: null, + hasReturn: false, + shouldCheck: false, + node: null + }; + + /** + * Checks whether or not the last code path segment is reachable. + * Then reports this function if the segment is reachable. + * + * If the last code path segment is reachable, there are paths which are not + * returned or thrown. + * + * @param {ASTNode} node - A node to check. + * @returns {void} + */ + function checkLastSegment(node) { + if (funcInfo.shouldCheck && + funcInfo.codePath.currentSegments.some(isReachable) + ) { + context.report({ + node, + loc: getId(node).loc.start, + message: funcInfo.hasReturn + ? "Expected {{name}} to always return a value." + : "Expected to return a value in {{name}}.", + data: { + name: astUtils.getFunctionNameWithKind(funcInfo.node) + } + }); + } + } + + return { + + // Stacks this function's information. + onCodePathStart(codePath, node) { + const parent = node.parent; + + funcInfo = { + upper: funcInfo, + codePath, + hasReturn: false, + shouldCheck: + node.type === "FunctionExpression" && + node.body.type === "BlockStatement" && + + // check if it is a "getter", or a method named "get". + (parent.kind === "get" || astUtils.getStaticPropertyName(parent) === "get"), + node + }; + }, + + // Pops this function's information. + onCodePathEnd() { + funcInfo = funcInfo.upper; + }, + + // Checks the return statement is valid. + ReturnStatement(node) { + if (funcInfo.shouldCheck) { + funcInfo.hasReturn = true; + + // if allowImplicit: false, should also check node.argument + if (!options.allowImplicit && !node.argument) { + context.report({ + node, + message: "Expected to return a value in {{name}}.", + data: { + name: astUtils.getFunctionNameWithKind(funcInfo.node) + } + }); + } + } + }, + + // Reports a given function if the last path is reachable. + "FunctionExpression:exit": checkLastSegment + }; + } +}; diff --git a/tools/eslint/lib/rules/indent.js b/tools/eslint/lib/rules/indent.js index 3027e772043772..727ecfaaed2f3a 100644 --- a/tools/eslint/lib/rules/indent.js +++ b/tools/eslint/lib/rules/indent.js @@ -303,6 +303,18 @@ class OffsetStorage { } } + /** + * Sets the desired offset of a token, ignoring the usual collapsing behavior. + * **WARNING**: This is usually not what you want to use. See `setDesiredOffset` instead. + * @param {Token} token The token + * @param {Token} offsetFrom The token that `token` should be offset from + * @param {number} offset The desired indent level + * @returns {void} + */ + forceSetDesiredOffset(token, offsetFrom, offset) { + this.desiredOffsets[token.range[0]] = { offset, from: offsetFrom }; + } + /** * Sets the desired offset of multiple tokens * @param {Token[]} tokens A list of tokens. These tokens should be consecutive. @@ -374,18 +386,6 @@ class OffsetStorage { getFirstDependency(token) { return this.desiredOffsets[token.range[0]].from; } - - /** - * Increases the offset for a token from its parent by the given amount - * @param {Token} token The token whose offset should be increased - * @param {number} amount The number of indent levels that the offset should increase by - * @returns {void} - */ - increaseOffset(token, amount) { - const currentOffsetInfo = this.desiredOffsets[token.range[0]]; - - this.desiredOffsets[token.range[0]] = { offset: currentOffsetInfo.offset + amount, from: currentOffsetInfo.from }; - } } const ELEMENT_LIST_SCHEMA = { @@ -738,7 +738,7 @@ module.exports = { const firstTokenOfPreviousElement = previousElement && getFirstToken(previousElement); if (previousElement && sourceCode.getLastToken(previousElement).loc.start.line > startToken.loc.end.line) { - offsets.matchIndentOf(firstTokenOfPreviousElement, getFirstToken(element)); + offsets.setDesiredOffsets(getTokensAndComments(element), firstTokenOfPreviousElement, 0); } } }); @@ -813,7 +813,7 @@ module.exports = { */ const lastToken = sourceCode.getLastToken(node); - if (astUtils.isSemicolonToken(lastToken)) { + if (node.type !== "EmptyStatement" && astUtils.isSemicolonToken(lastToken)) { offsets.matchIndentOf(lastParentToken, lastToken); } } @@ -884,7 +884,7 @@ module.exports = { parameterParens.add(openingParen); parameterParens.add(closingParen); - offsets.matchIndentOf(sourceCode.getLastToken(node.callee), openingParen); + offsets.matchIndentOf(sourceCode.getTokenBefore(openingParen), openingParen); addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments); } @@ -1018,7 +1018,7 @@ module.exports = { const nodeTokens = getTokensAndComments(node); const tokensFromOperator = nodeTokens.slice(lodash.sortedIndexBy(nodeTokens, operator, token => token.range[0])); - offsets.setDesiredOffsets(tokensFromOperator, sourceCode.getFirstToken(node.left), 1); + offsets.setDesiredOffsets(tokensFromOperator, sourceCode.getLastToken(node.left), 1); offsets.ignoreToken(tokensFromOperator[0]); offsets.ignoreToken(tokensFromOperator[1]); }, @@ -1274,7 +1274,35 @@ module.exports = { VariableDeclaration(node) { const variableIndent = options.VariableDeclarator.hasOwnProperty(node.kind) ? options.VariableDeclarator[node.kind] : DEFAULT_VARIABLE_INDENT; - offsets.setDesiredOffsets(getTokensAndComments(node), sourceCode.getFirstToken(node), variableIndent); + if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) { + + /* + * VariableDeclarator indentation is a bit different from other forms of indentation, in that the + * indentation of an opening bracket sometimes won't match that of a closing bracket. For example, + * the following indentations are correct: + * + * var foo = { + * ok: true + * }; + * + * var foo = { + * ok: true, + * }, + * bar = 1; + * + * Account for when exiting the AST (after indentations have already been set for the nodes in + * the declaration) by manually increasing the indentation level of the tokens in this declarator + * on the same line as the start of the declaration, provided that there are declarators that + * follow this one. + */ + getTokensAndComments(node).forEach((token, index, tokens) => { + if (index !== 0) { + offsets.forceSetDesiredOffset(token, tokens[0], variableIndent); + } + }); + } else { + offsets.setDesiredOffsets(getTokensAndComments(node), sourceCode.getFirstToken(node), variableIndent); + } const lastToken = sourceCode.getLastToken(node); if (astUtils.isSemicolonToken(lastToken)) { @@ -1285,43 +1313,12 @@ module.exports = { VariableDeclarator(node) { if (node.init) { const equalOperator = sourceCode.getTokenBefore(node.init, astUtils.isNotOpeningParenToken); - const tokenAfterOperator = sourceCode.getTokenAfter(equalOperator); + const tokensAfterOperator = sourceCode.getTokensAfter(equalOperator, token => token.range[1] <= node.range[1]); offsets.ignoreToken(equalOperator); - offsets.ignoreToken(tokenAfterOperator); - offsets.matchIndentOf(equalOperator, tokenAfterOperator); - offsets.matchIndentOf(sourceCode.getFirstToken(node), equalOperator); - } - }, - - "VariableDeclarator:exit"(node) { - - /* - * VariableDeclarator indentation is a bit different from other forms of indentation, in that the - * indentation of an opening bracket sometimes won't match that of a closing bracket. For example, - * the following indentations are correct: - * - * var foo = { - * ok: true - * }; - * - * var foo = { - * ok: true, - * }, - * bar = 1; - * - * Account for when exiting the AST (after indentations have already been set for the nodes in - * the declaration) by manually increasing the indentation level of the tokens in the first declarator if the - * parent declaration has more than one declarator. - */ - if (node.parent.declarations.length > 1 && node.parent.declarations[0] === node && node.init) { - const valueTokens = new Set(getTokensAndComments(node.init)); - - valueTokens.forEach(token => { - if (!valueTokens.has(offsets.getFirstDependency(token))) { - offsets.increaseOffset(token, options.VariableDeclarator[node.parent.kind]); - } - }); + offsets.ignoreToken(tokensAfterOperator[0]); + offsets.setDesiredOffsets(tokensAfterOperator, equalOperator, 1); + offsets.matchIndentOf(sourceCode.getLastToken(node.id), equalOperator); } }, @@ -1366,13 +1363,14 @@ module.exports = { JSXExpressionContainer(node) { const openingCurly = sourceCode.getFirstToken(node); - const firstExpressionToken = sourceCode.getFirstToken(node.expression); - - if (firstExpressionToken) { - offsets.setDesiredOffset(firstExpressionToken, openingCurly, 1); - } + const closingCurly = sourceCode.getLastToken(node); - offsets.matchIndentOf(openingCurly, sourceCode.getLastToken(node)); + offsets.setDesiredOffsets( + sourceCode.getTokensBetween(openingCurly, closingCurly, { includeComments: true }), + openingCurly, + 1 + ); + offsets.matchIndentOf(openingCurly, closingCurly); }, "Program:exit"() { diff --git a/tools/eslint/lib/rules/multiline-ternary.js b/tools/eslint/lib/rules/multiline-ternary.js index de19bd43fd60ed..a74f241d86c7ca 100644 --- a/tools/eslint/lib/rules/multiline-ternary.js +++ b/tools/eslint/lib/rules/multiline-ternary.js @@ -20,13 +20,15 @@ module.exports = { }, schema: [ { - enum: ["always", "never"] + enum: ["always", "always-multiline", "never"] } ] }, create(context) { - const multiline = context.options[0] !== "never"; + const option = context.options[0]; + const multiline = option !== "never"; + const allowSingleLine = option === "always-multiline"; //-------------------------------------------------------------------------- // Helpers @@ -69,6 +71,10 @@ module.exports = { reportError(node.consequent, node, false); } } else { + if (allowSingleLine && node.loc.start.line === node.loc.end.line) { + return; + } + if (areTestAndConsequentOnSameLine) { reportError(node.test, node, true); } diff --git a/tools/eslint/lib/rules/no-debugger.js b/tools/eslint/lib/rules/no-debugger.js index a158724fef118f..d79cb1816670b2 100644 --- a/tools/eslint/lib/rules/no-debugger.js +++ b/tools/eslint/lib/rules/no-debugger.js @@ -5,6 +5,8 @@ "use strict"; +const astUtils = require("../ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -28,7 +30,10 @@ module.exports = { node, message: "Unexpected 'debugger' statement.", fix(fixer) { - return fixer.remove(node); + if (astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) { + return fixer.remove(node); + } + return null; } }); } diff --git a/tools/eslint/lib/rules/no-extra-parens.js b/tools/eslint/lib/rules/no-extra-parens.js index 9f48f1d81a9592..fd6fd0b78b6104 100644 --- a/tools/eslint/lib/rules/no-extra-parens.js +++ b/tools/eslint/lib/rules/no-extra-parens.js @@ -426,7 +426,7 @@ module.exports = { secondToken.type === "Keyword" && ( secondToken.value === "function" || secondToken.value === "class" || - secondToken.value === "let" && astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(secondToken)) + secondToken.value === "let" && astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken)) ) ) ) { @@ -512,16 +512,27 @@ module.exports = { ExportDefaultDeclaration: node => checkExpressionOrExportStatement(node.declaration), ExpressionStatement: node => checkExpressionOrExportStatement(node.expression), - ForInStatement(node) { - if (hasExcessParens(node.right)) { - report(node.right); - } - if (hasExcessParens(node.left)) { - report(node.left); - } - }, + "ForInStatement, ForOfStatement"(node) { + if (node.left.type !== "VariableDeclarator") { + const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken); + + if ( + firstLeftToken.value === "let" && ( + + // If `let` is the only thing on the left side of the loop, it's the loop variable: `for ((let) of foo);` + // Removing it will cause a syntax error, because it will be parsed as the start of a VariableDeclarator. + firstLeftToken.range[1] === node.left.range[1] || - ForOfStatement(node) { + // If `let` is followed by a `[` token, it's a property access on the `let` value: `for ((let[foo]) of bar);` + // Removing it will cause the property access to be parsed as a destructuring declaration of `foo` instead. + astUtils.isOpeningBracketToken( + sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken) + ) + ) + ) { + tokensToIgnore.add(firstLeftToken); + } + } if (hasExcessParens(node.right)) { report(node.right); } diff --git a/tools/eslint/lib/rules/no-regex-spaces.js b/tools/eslint/lib/rules/no-regex-spaces.js index 05ac86e87a9db3..09b689e8e6f26a 100644 --- a/tools/eslint/lib/rules/no-regex-spaces.js +++ b/tools/eslint/lib/rules/no-regex-spaces.js @@ -37,11 +37,11 @@ module.exports = { * @private */ function checkRegex(node, value, valueStart) { - const multipleSpacesRegex = /( {2,})+?/, + const multipleSpacesRegex = /( {2,})( [+*{?]|[^+*{?]|$)/, regexResults = multipleSpacesRegex.exec(value); if (regexResults !== null) { - const count = regexResults[0].length; + const count = regexResults[1].length; context.report({ node, diff --git a/tools/eslint/lib/rules/no-sync.js b/tools/eslint/lib/rules/no-sync.js index 885b1eb6289174..06305969a1fabf 100644 --- a/tools/eslint/lib/rules/no-sync.js +++ b/tools/eslint/lib/rules/no-sync.js @@ -19,14 +19,26 @@ module.exports = { recommended: false }, - schema: [] + schema: [ + { + type: "object", + properties: { + allowAtRootLevel: { + type: "boolean" + } + }, + additionalProperties: false + } + ] }, create(context) { + const selector = context.options[0] && context.options[0].allowAtRootLevel + ? ":function MemberExpression[property.name=/.*Sync$/]" + : "MemberExpression[property.name=/.*Sync$/]"; return { - - "MemberExpression[property.name=/.*Sync$/]"(node) { + [selector](node) { context.report({ node, message: "Unexpected sync method: '{{propertyName}}'.", diff --git a/tools/eslint/lib/testers/rule-tester.js b/tools/eslint/lib/testers/rule-tester.js index 9d747e96a884d8..fc6781fdcfc7ce 100644 --- a/tools/eslint/lib/testers/rule-tester.js +++ b/tools/eslint/lib/testers/rule-tester.js @@ -44,10 +44,9 @@ const lodash = require("lodash"), assert = require("assert"), util = require("util"), validator = require("../config/config-validator"), - validate = require("is-my-json-valid"), + ajv = require("../util/ajv"), Linter = require("../linter"), Environments = require("../config/environments"), - metaSchema = require("../../conf/json-schema-schema.json"), SourceCodeFixer = require("../util/source-code-fixer"); //------------------------------------------------------------------------------ @@ -73,8 +72,6 @@ const RuleTesterParameters = [ "output" ]; -const validateSchema = validate(metaSchema, { verbose: true }); - const hasOwnProperty = Function.call.bind(Object.hasOwnProperty); /** @@ -318,12 +315,16 @@ class RuleTester { const schema = validator.getRuleOptionsSchema(ruleName, linter.rules); if (schema) { - validateSchema(schema); + ajv.validateSchema(schema); + + if (ajv.errors) { + const errors = ajv.errors.map(error => { + const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath; + + return `\t${field}: ${error.message}`; + }).join("\n"); - if (validateSchema.errors) { - throw new Error([ - `Schema for rule ${ruleName} is invalid:` - ].concat(validateSchema.errors.map(error => `\t${error.field}: ${error.message}`)).join("\n")); + throw new Error([`Schema for rule ${ruleName} is invalid:`, errors]); } } diff --git a/tools/eslint/lib/util/ajv.js b/tools/eslint/lib/util/ajv.js new file mode 100644 index 00000000000000..f9e8b9853569ea --- /dev/null +++ b/tools/eslint/lib/util/ajv.js @@ -0,0 +1,29 @@ +/** + * @fileoverview The instance of Ajv validator. + * @author Evgeny Poberezkin + */ +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const Ajv = require("ajv"), + metaSchema = require("ajv/lib/refs/json-schema-draft-04.json"); + +//------------------------------------------------------------------------------ +// Public Interface +//------------------------------------------------------------------------------ + +const ajv = new Ajv({ + meta: false, + validateSchema: false, + missingRefs: "ignore", + verbose: true +}); + +ajv.addMetaSchema(metaSchema); +// eslint-disable-next-line no-underscore-dangle +ajv._opts.defaultMeta = metaSchema.id; + +module.exports = ajv; diff --git a/tools/eslint/lib/util/source-code-fixer.js b/tools/eslint/lib/util/source-code-fixer.js index 6490a467fa725b..1b6270a1e55f83 100644 --- a/tools/eslint/lib/util/source-code-fixer.js +++ b/tools/eslint/lib/util/source-code-fixer.js @@ -55,10 +55,10 @@ function SourceCodeFixer() { * smart about the fixes and won't apply fixes over the same area in the text. * @param {SourceCode} sourceCode The source code to apply the changes to. * @param {Message[]} messages The array of messages reported by ESLint. + * @param {boolean|Function} [shouldFix=true] Determines whether each message should be fixed * @returns {Object} An object containing the fixed text and any unfixed messages. */ -SourceCodeFixer.applyFixes = function(sourceCode, messages) { - +SourceCodeFixer.applyFixes = function(sourceCode, messages, shouldFix) { debug("Applying fixes"); if (!sourceCode) { @@ -70,6 +70,15 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { }; } + if (shouldFix === false) { + debug("shouldFix parameter was false, not attempting fixes"); + return { + fixed: false, + messages, + output: sourceCode.text + }; + } + // clone the array const remainingMessages = [], fixes = [], @@ -78,6 +87,34 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { let lastPos = Number.NEGATIVE_INFINITY, output = bom; + /** + * Try to use the 'fix' from a problem. + * @param {Message} problem The message object to apply fixes from + * @returns {boolean} Whether fix was successfully applied + */ + function attemptFix(problem) { + const fix = problem.fix; + const start = fix.range[0]; + const end = fix.range[1]; + + // Remain it as a problem if it's overlapped or it's a negative range + if (lastPos >= start || start > end) { + remainingMessages.push(problem); + return false; + } + + // Remove BOM. + if ((start < 0 && end >= 0) || (start === 0 && fix.text.startsWith(BOM))) { + output = ""; + } + + // Make output to this fix. + output += text.slice(Math.max(0, lastPos), Math.max(0, start)); + output += fix.text; + lastPos = end; + return true; + } + messages.forEach(problem => { if (problem.hasOwnProperty("fix")) { fixes.push(problem); @@ -88,32 +125,23 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { if (fixes.length) { debug("Found fixes to apply"); + let fixesWereApplied = false; for (const problem of fixes.sort(compareMessagesByFixRange)) { - const fix = problem.fix; - const start = fix.range[0]; - const end = fix.range[1]; + if (typeof shouldFix !== "function" || shouldFix(problem)) { + attemptFix(problem); - // Remain it as a problem if it's overlapped or it's a negative range - if (lastPos >= start || start > end) { + // The only time attemptFix will fail is if a previous fix was + // applied which conflicts with it. So we can mark this as true. + fixesWereApplied = true; + } else { remainingMessages.push(problem); - continue; - } - - // Remove BOM. - if ((start < 0 && end >= 0) || (start === 0 && fix.text.startsWith(BOM))) { - output = ""; } - - // Make output to this fix. - output += text.slice(Math.max(0, lastPos), Math.max(0, start)); - output += fix.text; - lastPos = end; } output += text.slice(Math.max(0, lastPos)); return { - fixed: true, + fixed: fixesWereApplied, messages: remainingMessages.sort(compareMessagesByLocation), output }; diff --git a/tools/eslint/node_modules/.bin/acorn b/tools/eslint/node_modules/.bin/acorn deleted file mode 120000 index cf76760386200f..00000000000000 --- a/tools/eslint/node_modules/.bin/acorn +++ /dev/null @@ -1 +0,0 @@ -../acorn/bin/acorn \ No newline at end of file diff --git a/tools/eslint/node_modules/.bin/esparse b/tools/eslint/node_modules/.bin/esparse deleted file mode 120000 index 7423b18b24efb0..00000000000000 --- a/tools/eslint/node_modules/.bin/esparse +++ /dev/null @@ -1 +0,0 @@ -../esprima/bin/esparse.js \ No newline at end of file diff --git a/tools/eslint/node_modules/.bin/esvalidate b/tools/eslint/node_modules/.bin/esvalidate deleted file mode 120000 index 16069effbc99a3..00000000000000 --- a/tools/eslint/node_modules/.bin/esvalidate +++ /dev/null @@ -1 +0,0 @@ -../esprima/bin/esvalidate.js \ No newline at end of file diff --git a/tools/eslint/node_modules/.bin/js-yaml b/tools/eslint/node_modules/.bin/js-yaml deleted file mode 120000 index 9dbd010d470368..00000000000000 --- a/tools/eslint/node_modules/.bin/js-yaml +++ /dev/null @@ -1 +0,0 @@ -../js-yaml/bin/js-yaml.js \ No newline at end of file diff --git a/tools/eslint/node_modules/.bin/mkdirp b/tools/eslint/node_modules/.bin/mkdirp deleted file mode 120000 index 017896cebb1416..00000000000000 --- a/tools/eslint/node_modules/.bin/mkdirp +++ /dev/null @@ -1 +0,0 @@ -../mkdirp/bin/cmd.js \ No newline at end of file diff --git a/tools/eslint/node_modules/.bin/rimraf b/tools/eslint/node_modules/.bin/rimraf deleted file mode 120000 index 4cd49a49ddfc17..00000000000000 --- a/tools/eslint/node_modules/.bin/rimraf +++ /dev/null @@ -1 +0,0 @@ -../rimraf/bin.js \ No newline at end of file diff --git a/tools/eslint/node_modules/acorn-jsx/node_modules/.bin/acorn b/tools/eslint/node_modules/acorn-jsx/node_modules/.bin/acorn deleted file mode 120000 index cf76760386200f..00000000000000 --- a/tools/eslint/node_modules/acorn-jsx/node_modules/.bin/acorn +++ /dev/null @@ -1 +0,0 @@ -../acorn/bin/acorn \ No newline at end of file diff --git a/tools/eslint/node_modules/acorn/AUTHORS b/tools/eslint/node_modules/acorn/AUTHORS index 1377f6034ed673..7b9f6a14b17ee9 100644 --- a/tools/eslint/node_modules/acorn/AUTHORS +++ b/tools/eslint/node_modules/acorn/AUTHORS @@ -8,12 +8,14 @@ Angelo Aparajita Fishman Arian Stolwijk Artem Govorov +Bradley Heinz Brandon Mills Charles Hughes Conrad Irwin Daniel Tschinder David Bonnet Domenico Matteo +ehmicky Forbes Lindesay Gilad Peleg impinball @@ -32,6 +34,7 @@ Keheliya Gallaba Kevin Irish Kevin Kwok krator +Marek Marijn Haverbeke Martin Carlberg Mat Garcia @@ -60,5 +63,6 @@ Simen Bekkhus Teddy Katz Timothy Gu Toru Nagashima +Victor Homyakov Wexpo Lyu zsjforcn diff --git a/tools/eslint/node_modules/acorn/LICENSE b/tools/eslint/node_modules/acorn/LICENSE index a35ebf44fd859e..3f01865520df3f 100644 --- a/tools/eslint/node_modules/acorn/LICENSE +++ b/tools/eslint/node_modules/acorn/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2012-2016 by various contributors (see AUTHORS) +Copyright (C) 2012-2017 by various contributors (see AUTHORS) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/tools/eslint/node_modules/acorn/README.md b/tools/eslint/node_modules/acorn/README.md index b7efe2341971aa..bd853c43bb2b1d 100644 --- a/tools/eslint/node_modules/acorn/README.md +++ b/tools/eslint/node_modules/acorn/README.md @@ -63,9 +63,9 @@ object referring to that same position. [estree]: https://github.com/estree/estree - **ecmaVersion**: Indicates the ECMAScript version to parse. Must be - either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support for strict - mode, the set of reserved words, and support for new syntax features. - Default is 7. + either 3, 5, 6 (2015), 7 (2016), 8 (2017), or 9 (2018, partial + support). This influences support for strict mode, the set of + reserved words, and support for new syntax features. Default is 7. **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being implemented by Acorn. @@ -268,10 +268,33 @@ simply visit all statements and expressions and not produce a meaningful state. (An example of a use of state is to track scope at each point in the tree.) +```js +const acorn = require("acorn") +const walk = require("acorn/dist/walk") + +walk.simple(acorn.parse("let x = 10"), { + Literal(node) { + console.log(`Found a literal: ${node.value}`) + } +}) +``` + **ancestor**`(node, visitors, base, state)` does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter. +```js +const acorn = require("acorn") +const walk = require("acorn/dist/walk") + +walk.ancestor(acorn.parse("foo('hi')"), { + Literal(_, ancestors) { + console.log("This literal's ancestors are:", + ancestors.map(n => n.type)) + } +}) +``` + **recursive**`(node, state, functions, base)` does a 'recursive' walk, where the walker functions are responsible for continuing the walk on the child nodes of their target node. `state` is the start @@ -287,6 +310,23 @@ default walkers will be used. walker functions in `functions` and filling in the missing ones by taking defaults from `base`. +**full**`(node, callback, base, state)` does a 'full' +walk over a tree, calling the callback with the arguments (node, state, type) +for each node + +**fullAncestor**`(node, callback, base, state)` does a 'full' walk over +a tree, building up an array of ancestor nodes (including the current node) +and passing the array to the callbacks as a third parameter. + +```js +const acorn = require("acorn") +const walk = require("acorn/dist/walk") + +walk.full(acorn.parse("1 + 1"), node => { + console.log(`There's a ${node.type} node at ${node.ch}`) +}) +``` + **findNodeAt**`(node, start, end, test, base, state)` tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate `test`. `start` and `end` can be either `null` @@ -407,3 +447,6 @@ looseParser.extend("readToken", function(nextMethod) { - [`acorn-object-spread`](https://github.com/UXtemple/acorn-object-spread): Parse [object spread syntax proposal](https://github.com/sebmarkbage/ecmascript-rest-spread) - [`acorn-es7`](https://www.npmjs.com/package/acorn-es7): Parse [decorator syntax proposal](https://github.com/wycats/javascript-decorators) - [`acorn-objj`](https://www.npmjs.com/package/acorn-objj): [Objective-J](http://www.cappuccino-project.org/learn/objective-j.html) language parser built as Acorn plugin + - [`acorn-object-rest-spread`](https://github.com/victor-homyakov/acorn-object-rest-spread) Parse [Object Rest/Spread Properties proposal](https://github.com/tc39/proposal-object-rest-spread), works with latest Acorn version (5.0.3) + - [`acorn-static-class-property-initializer`](https://github.com/victor-homyakov/acorn-static-class-property-initializer) Partial support for static class properties from [ES Class Fields & Static Properties Proposal](https://github.com/tc39/proposal-class-public-fields) to support static property initializers in [React components written as ES6+ classes](https://babeljs.io/blog/2015/06/07/react-on-es6-plus) + diff --git a/tools/eslint/node_modules/acorn/bin/acorn b/tools/eslint/node_modules/acorn/bin/acorn old mode 100755 new mode 100644 index 41b786f4296169..25719578044387 --- a/tools/eslint/node_modules/acorn/bin/acorn +++ b/tools/eslint/node_modules/acorn/bin/acorn @@ -10,60 +10,60 @@ var forceFile; var silent = false; var compact = false; var tokenize = false; -var options = {} +var options = {}; function help(status) { - var print = (status == 0) ? console.log : console.error - print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]") - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]") - process.exit(status) + var print = (status == 0) ? console.log : console.error; + print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]"); + print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]"); + process.exit(status); } for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i] - if ((arg == "-" || arg[0] != "-") && !infile) infile = arg - else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i] - else if (arg == "--locations") options.locations = true - else if (arg == "--allow-hash-bang") options.allowHashBang = true - else if (arg == "--silent") silent = true - else if (arg == "--compact") compact = true - else if (arg == "--help") help(0) - else if (arg == "--tokenize") tokenize = true - else if (arg == "--module") options.sourceType = "module" + var arg = process.argv[i]; + if ((arg == "-" || arg[0] != "-") && !infile) { infile = arg; } + else if (arg == "--" && !infile && i + 2 == process.argv.length) { forceFile = infile = process.argv[++i]; } + else if (arg == "--locations") { options.locations = true; } + else if (arg == "--allow-hash-bang") { options.allowHashBang = true; } + else if (arg == "--silent") { silent = true; } + else if (arg == "--compact") { compact = true; } + else if (arg == "--help") { help(0); } + else if (arg == "--tokenize") { tokenize = true; } + else if (arg == "--module") { options.sourceType = "module"; } else { - var match = arg.match(/^--ecma(\d+)$/) + var match = arg.match(/^--ecma(\d+)$/); if (match) - options.ecmaVersion = +match[1] + { options.ecmaVersion = +match[1]; } else - help(1) + { help(1); } } } function run(code) { - var result + var result; try { if (!tokenize) { - result = acorn.parse(code, options) + result = acorn.parse(code, options); } else { - result = [] - var tokenizer = acorn.tokenizer(code, options), token + result = []; + var tokenizer$$1 = acorn.tokenizer(code, options), token; do { - token = tokenizer.getToken() - result.push(token) + token = tokenizer$$1.getToken(); + result.push(token); } while (token.type != acorn.tokTypes.eof) } } catch (e) { - console.error(e.message) - process.exit(1) + console.error(e.message); + process.exit(1); } - if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2)) + if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); } } if (forceFile || infile && infile != "-") { - run(fs.readFileSync(infile, "utf8")) + run(fs.readFileSync(infile, "utf8")); } else { - var code = "" - process.stdin.resume() - process.stdin.on("data", function (chunk) { return code += chunk; }) - process.stdin.on("end", function () { return run(code); }) -} \ No newline at end of file + var code = ""; + process.stdin.resume(); + process.stdin.on("data", function (chunk) { return code += chunk; }); + process.stdin.on("end", function () { return run(code); }); +} diff --git a/tools/eslint/node_modules/acorn/dist/acorn.es.js b/tools/eslint/node_modules/acorn/dist/acorn.es.js index 74417b8aa83559..5b5977671c1f2d 100644 --- a/tools/eslint/node_modules/acorn/dist/acorn.es.js +++ b/tools/eslint/node_modules/acorn/dist/acorn.es.js @@ -6,16 +6,16 @@ var reservedWords = { 6: "enum", strict: "implements interface let package private protected public static yield", strictBind: "eval arguments" -} +}; // And the keywords -var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this" +var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"; var keywords = { 5: ecma5AndLessKeywords, 6: ecma5AndLessKeywords + " const class extends export import super" -} +}; // ## Character categories @@ -25,13 +25,13 @@ var keywords = { // code point above 128. // Generated by `bin/generate-identifier-regex.js`. -var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\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-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\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\u0af9\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-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\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-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\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\u2118-\u211d\u2124\u2126\u2128\u212a-\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\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\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" -var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d01-\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf8\u1cf9\u1dc0-\u1df5\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f" +var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\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-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\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\u0af9\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-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\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-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\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\u2118-\u211d\u2124\u2126\u2128\u212a-\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\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\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"; +var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d01-\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf8\u1cf9\u1dc0-\u1df5\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; -var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]") -var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]") +var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); +var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); -nonASCIIidentifierStartChars = nonASCIIidentifierChars = null +nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; // These are a run-length and offset encoded representation of the // >0xffff code points that are a valid part of identifiers. The @@ -40,47 +40,47 @@ nonASCIIidentifierStartChars = nonASCIIidentifierChars = null // generated by bin/generate-identifier-regex.js // eslint-disable-next-line comma-spacing -var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541] +var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541]; // eslint-disable-next-line comma-spacing -var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239] +var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]; // This has a complexity linear to the value of the code. The // assumption is that looking up astral identifier characters is // rare. function isInAstralSet(code, set) { - var pos = 0x10000 + var pos = 0x10000; for (var i = 0; i < set.length; i += 2) { - pos += set[i] - if (pos > code) return false - pos += set[i + 1] - if (pos >= code) return true + pos += set[i]; + if (pos > code) { return false } + pos += set[i + 1]; + if (pos >= code) { return true } } } // Test whether a given character code starts an identifier. function isIdentifierStart(code, astral) { - if (code < 65) return code === 36 - if (code < 91) return true - if (code < 97) return code === 95 - if (code < 123) return true - if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) - if (astral === false) return false + if (code < 65) { return code === 36 } + if (code < 91) { return true } + if (code < 97) { return code === 95 } + if (code < 123) { return true } + if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) } + if (astral === false) { return false } return isInAstralSet(code, astralIdentifierStartCodes) } // Test whether a given character is part of an identifier. function isIdentifierChar(code, astral) { - if (code < 48) return code === 36 - if (code < 58) return true - if (code < 65) return false - if (code < 91) return true - if (code < 97) return code === 95 - if (code < 123) return true - if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) - if (astral === false) return false + if (code < 48) { return code === 36 } + if (code < 58) { return true } + if (code < 65) { return false } + if (code < 91) { return true } + if (code < 97) { return code === 95 } + if (code < 123) { return true } + if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) } + if (astral === false) { return false } return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) } @@ -110,16 +110,16 @@ function isIdentifierChar(code, astral) { var TokenType = function TokenType(label, conf) { if ( conf === void 0 ) conf = {}; - this.label = label - this.keyword = conf.keyword - this.beforeExpr = !!conf.beforeExpr - this.startsExpr = !!conf.startsExpr - this.isLoop = !!conf.isLoop - this.isAssign = !!conf.isAssign - this.prefix = !!conf.prefix - this.postfix = !!conf.postfix - this.binop = conf.binop || null - this.updateContext = null + this.label = label; + this.keyword = conf.keyword; + this.beforeExpr = !!conf.beforeExpr; + this.startsExpr = !!conf.startsExpr; + this.isLoop = !!conf.isLoop; + this.isAssign = !!conf.isAssign; + this.prefix = !!conf.prefix; + this.postfix = !!conf.postfix; + this.binop = conf.binop || null; + this.updateContext = null; }; function binop(name, prec) { @@ -127,19 +127,20 @@ function binop(name, prec) { } var beforeExpr = {beforeExpr: true}; var startsExpr = {startsExpr: true}; + // Map keyword names to token types. -var keywordTypes = {} +var keywords$1 = {}; // Succinct definitions of keyword token types function kw(name, options) { if ( options === void 0 ) options = {}; - options.keyword = name - return keywordTypes[name] = new TokenType(name, options) + options.keyword = name; + return keywords$1[name] = new TokenType(name, options) } -var tt = { +var types = { num: new TokenType("num", startsExpr), regexp: new TokenType("regexp", startsExpr), string: new TokenType("string", startsExpr), @@ -160,6 +161,7 @@ var tt = { question: new TokenType("?", beforeExpr), arrow: new TokenType("=>", beforeExpr), template: new TokenType("template"), + invalidTemplate: new TokenType("invalidTemplate"), ellipsis: new TokenType("...", beforeExpr), backQuote: new TokenType("`", startsExpr), dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), @@ -220,7 +222,7 @@ var tt = { _new: kw("new", {beforeExpr: true, startsExpr: true}), _this: kw("this", startsExpr), _super: kw("super", startsExpr), - _class: kw("class"), + _class: kw("class", startsExpr), _extends: kw("extends", beforeExpr), _export: kw("export"), _import: kw("import"), @@ -232,21 +234,21 @@ var tt = { _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) -} +}; // Matches a whole line break (where CRLF is considered a single // line break). Used to count lines. -var lineBreak = /\r\n?|\n|\u2028|\u2029/ -var lineBreakG = new RegExp(lineBreak.source, "g") +var lineBreak = /\r\n?|\n|\u2028|\u2029/; +var lineBreakG = new RegExp(lineBreak.source, "g"); function isNewLine(code) { return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 } -var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/ +var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; -var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g +var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; var ref = Object.prototype; var hasOwnProperty = ref.hasOwnProperty; @@ -260,14 +262,14 @@ function has(obj, propName) { var isArray = Array.isArray || (function (obj) { return ( toString.call(obj) === "[object Array]" -); }) +); }); // These are used when `options.locations` is on, for the // `startLoc` and `endLoc` properties. var Position = function Position(line, col) { - this.line = line - this.column = col + this.line = line; + this.column = col; }; Position.prototype.offset = function offset (n) { @@ -275,9 +277,9 @@ Position.prototype.offset = function offset (n) { }; var SourceLocation = function SourceLocation(p, start, end) { - this.start = start - this.end = end - if (p.sourceFile !== null) this.source = p.sourceFile + this.start = start; + this.end = end; + if (p.sourceFile !== null) { this.source = p.sourceFile; } }; // The `getLineInfo` function is mostly useful when the @@ -288,11 +290,11 @@ var SourceLocation = function SourceLocation(p, start, end) { function getLineInfo(input, offset) { for (var line = 1, cur = 0;;) { - lineBreakG.lastIndex = cur - var match = lineBreakG.exec(input) + lineBreakG.lastIndex = cur; + var match = lineBreakG.exec(input); if (match && match.index < offset) { - ++line - cur = match.index + match[0].length + ++line; + cur = match.index + match[0].length; } else { return new Position(line, offset - cur) } @@ -382,28 +384,28 @@ var defaultOptions = { // (non-standard) ParenthesizedExpression nodes preserveParens: false, plugins: {} -} +}; // Interpret and default an options object function getOptions(opts) { - var options = {} + var options = {}; for (var opt in defaultOptions) - options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt] + { options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]; } if (options.ecmaVersion >= 2015) - options.ecmaVersion -= 2009 + { options.ecmaVersion -= 2009; } if (options.allowReserved == null) - options.allowReserved = options.ecmaVersion < 5 + { options.allowReserved = options.ecmaVersion < 5; } if (isArray(options.onToken)) { - var tokens = options.onToken - options.onToken = function (token) { return tokens.push(token); } + var tokens = options.onToken; + options.onToken = function (token) { return tokens.push(token); }; } if (isArray(options.onComment)) - options.onComment = pushComment(options, options.onComment) + { options.onComment = pushComment(options, options.onComment); } return options } @@ -415,100 +417,100 @@ function pushComment(options, array) { value: text, start: start, end: end - } + }; if (options.locations) - comment.loc = new SourceLocation(this, startLoc, endLoc) + { comment.loc = new SourceLocation(this, startLoc, endLoc); } if (options.ranges) - comment.range = [start, end] - array.push(comment) + { comment.range = [start, end]; } + array.push(comment); } } // Registered plugins -var plugins = {} +var plugins = {}; function keywordRegexp(words) { - return new RegExp("^(" + words.replace(/ /g, "|") + ")$") + return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$") } var Parser = function Parser(options, input, startPos) { - this.options = options = getOptions(options) - this.sourceFile = options.sourceFile - this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]) - var reserved = "" + this.options = options = getOptions(options); + this.sourceFile = options.sourceFile; + this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]); + var reserved = ""; if (!options.allowReserved) { for (var v = options.ecmaVersion;; v--) - if (reserved = reservedWords[v]) break - if (options.sourceType == "module") reserved += " await" + { if (reserved = reservedWords[v]) { break } } + if (options.sourceType == "module") { reserved += " await"; } } - this.reservedWords = keywordRegexp(reserved) - var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict - this.reservedWordsStrict = keywordRegexp(reservedStrict) - this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind) - this.input = String(input) + this.reservedWords = keywordRegexp(reserved); + var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict; + this.reservedWordsStrict = keywordRegexp(reservedStrict); + this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind); + this.input = String(input); // Used to signal to callers of `readWord1` whether the word // contained any escape sequences. This is needed because words with // escape sequences must not be interpreted as keywords. - this.containsEsc = false + this.containsEsc = false; // Load plugins - this.loadPlugins(options.plugins) + this.loadPlugins(options.plugins); // Set up token state // The current position of the tokenizer in the input. if (startPos) { - this.pos = startPos - this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1 - this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length + this.pos = startPos; + this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1; + this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; } else { - this.pos = this.lineStart = 0 - this.curLine = 1 + this.pos = this.lineStart = 0; + this.curLine = 1; } // Properties of the current token: // Its type - this.type = tt.eof + this.type = types.eof; // For tokens that include more information than their type, the value - this.value = null + this.value = null; // Its start and end offset - this.start = this.end = this.pos + this.start = this.end = this.pos; // And, if locations are used, the {line, column} object // corresponding to those offsets - this.startLoc = this.endLoc = this.curPosition() + this.startLoc = this.endLoc = this.curPosition(); // Position information for the previous token - this.lastTokEndLoc = this.lastTokStartLoc = null - this.lastTokStart = this.lastTokEnd = this.pos + this.lastTokEndLoc = this.lastTokStartLoc = null; + this.lastTokStart = this.lastTokEnd = this.pos; // The context stack is used to superficially track syntactic // context to predict whether a regular expression is allowed in a // given position. - this.context = this.initialContext() - this.exprAllowed = true + this.context = this.initialContext(); + this.exprAllowed = true; // Figure out if it's a module code. - this.inModule = options.sourceType === "module" - this.strict = this.inModule || this.strictDirective(this.pos) + this.inModule = options.sourceType === "module"; + this.strict = this.inModule || this.strictDirective(this.pos); // Used to signify the start of a potential arrow function - this.potentialArrowAt = -1 + this.potentialArrowAt = -1; // Flags to track whether we are in a function, a generator, an async function. - this.inFunction = this.inGenerator = this.inAsync = false + this.inFunction = this.inGenerator = this.inAsync = false; // Positions to delayed-check that yield/await does not exist in default parameters. - this.yieldPos = this.awaitPos = 0 + this.yieldPos = this.awaitPos = 0; // Labels in scope. - this.labels = [] + this.labels = []; // If enabled, skip leading hashbang line. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") - this.skipLineComment(2) + { this.skipLineComment(2); } // Scope tracking for duplicate variable names (see scope.js) - this.scopeStack = [] - this.enterFunctionScope() + this.scopeStack = []; + this.enterFunctionScope(); }; // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them @@ -516,151 +518,155 @@ Parser.prototype.isKeyword = function isKeyword (word) { return this.keywords.te Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) }; Parser.prototype.extend = function extend (name, f) { - this[name] = f(this[name]) + this[name] = f(this[name]); }; Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) { var this$1 = this; for (var name in pluginConfigs) { - var plugin = plugins[name] - if (!plugin) throw new Error("Plugin '" + name + "' not found") - plugin(this$1, pluginConfigs[name]) + var plugin = plugins[name]; + if (!plugin) { throw new Error("Plugin '" + name + "' not found") } + plugin(this$1, pluginConfigs[name]); } }; Parser.prototype.parse = function parse () { - var node = this.options.program || this.startNode() - this.nextToken() + var node = this.options.program || this.startNode(); + this.nextToken(); return this.parseTopLevel(node) }; -var pp = Parser.prototype +var pp = Parser.prototype; // ## Parser utilities -var literal = /^(?:'((?:[^']|\.)*)'|"((?:[^"]|\.)*)"|;)/ +var literal = /^(?:'((?:[^']|\.)*)'|"((?:[^"]|\.)*)"|;)/; pp.strictDirective = function(start) { var this$1 = this; for (;;) { - skipWhiteSpace.lastIndex = start - start += skipWhiteSpace.exec(this$1.input)[0].length - var match = literal.exec(this$1.input.slice(start)) - if (!match) return false - if ((match[1] || match[2]) == "use strict") return true - start += match[0].length + skipWhiteSpace.lastIndex = start; + start += skipWhiteSpace.exec(this$1.input)[0].length; + var match = literal.exec(this$1.input.slice(start)); + if (!match) { return false } + if ((match[1] || match[2]) == "use strict") { return true } + start += match[0].length; } -} +}; // Predicate that tests whether the next token is of the given // type, and if yes, consumes it as a side effect. pp.eat = function(type) { if (this.type === type) { - this.next() + this.next(); return true } else { return false } -} +}; // Tests whether parsed token is a contextual keyword. pp.isContextual = function(name) { - return this.type === tt.name && this.value === name -} + return this.type === types.name && this.value === name +}; // Consumes contextual keyword if possible. pp.eatContextual = function(name) { - return this.value === name && this.eat(tt.name) -} + return this.value === name && this.eat(types.name) +}; // Asserts that following token is given contextual keyword. pp.expectContextual = function(name) { - if (!this.eatContextual(name)) this.unexpected() -} + if (!this.eatContextual(name)) { this.unexpected(); } +}; // Test whether a semicolon can be inserted at the current position. pp.canInsertSemicolon = function() { - return this.type === tt.eof || - this.type === tt.braceR || + return this.type === types.eof || + this.type === types.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) -} +}; pp.insertSemicolon = function() { if (this.canInsertSemicolon()) { if (this.options.onInsertedSemicolon) - this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc) + { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); } return true } -} +}; // Consume a semicolon, or, failing that, see if we are allowed to // pretend that there is a semicolon at this position. pp.semicolon = function() { - if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected() -} + if (!this.eat(types.semi) && !this.insertSemicolon()) { this.unexpected(); } +}; pp.afterTrailingComma = function(tokType, notNext) { if (this.type == tokType) { if (this.options.onTrailingComma) - this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc) + { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); } if (!notNext) - this.next() + { this.next(); } return true } -} +}; // Expect a token of a given type. If found, consume it, otherwise, // raise an unexpected token error. pp.expect = function(type) { - this.eat(type) || this.unexpected() -} + this.eat(type) || this.unexpected(); +}; // Raise an unexpected token error. pp.unexpected = function(pos) { - this.raise(pos != null ? pos : this.start, "Unexpected token") -} - -var DestructuringErrors = function DestructuringErrors() { - this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = -1 + this.raise(pos != null ? pos : this.start, "Unexpected token"); }; +function DestructuringErrors() { + this.shorthandAssign = + this.trailingComma = + this.parenthesizedAssign = + this.parenthesizedBind = + -1; +} + pp.checkPatternErrors = function(refDestructuringErrors, isAssign) { - if (!refDestructuringErrors) return + if (!refDestructuringErrors) { return } if (refDestructuringErrors.trailingComma > -1) - this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element") - var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind - if (parens > -1) this.raiseRecoverable(parens, "Parenthesized pattern") -} + { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); } + var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind; + if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); } +}; pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) { - var pos = refDestructuringErrors ? refDestructuringErrors.shorthandAssign : -1 - if (!andThrow) return pos >= 0 - if (pos > -1) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns") -} + var pos = refDestructuringErrors ? refDestructuringErrors.shorthandAssign : -1; + if (!andThrow) { return pos >= 0 } + if (pos > -1) { this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns"); } +}; pp.checkYieldAwaitInDefaultParams = function() { if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) - this.raise(this.yieldPos, "Yield expression cannot be a default value") + { this.raise(this.yieldPos, "Yield expression cannot be a default value"); } if (this.awaitPos) - this.raise(this.awaitPos, "Await expression cannot be a default value") -} + { this.raise(this.awaitPos, "Await expression cannot be a default value"); } +}; pp.isSimpleAssignTarget = function(expr) { if (expr.type === "ParenthesizedExpression") - return this.isSimpleAssignTarget(expr.expression) + { return this.isSimpleAssignTarget(expr.expression) } return expr.type === "Identifier" || expr.type === "MemberExpression" -} +}; -var pp$1 = Parser.prototype +var pp$1 = Parser.prototype; // ### Statement parsing @@ -672,50 +678,51 @@ var pp$1 = Parser.prototype pp$1.parseTopLevel = function(node) { var this$1 = this; - var exports = {} - if (!node.body) node.body = [] - while (this.type !== tt.eof) { - var stmt = this$1.parseStatement(true, true, exports) - node.body.push(stmt) + var exports = {}; + if (!node.body) { node.body = []; } + while (this.type !== types.eof) { + var stmt = this$1.parseStatement(true, true, exports); + node.body.push(stmt); } - this.next() + this.next(); if (this.options.ecmaVersion >= 6) { - node.sourceType = this.options.sourceType + node.sourceType = this.options.sourceType; } return this.finishNode(node, "Program") -} +}; var loopLabel = {kind: "loop"}; var switchLabel = {kind: "switch"}; + pp$1.isLet = function() { - if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != "let") return false - skipWhiteSpace.lastIndex = this.pos - var skip = skipWhiteSpace.exec(this.input) - var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next) - if (nextCh === 91 || nextCh == 123) return true // '{' and '[' + if (this.type !== types.name || this.options.ecmaVersion < 6 || this.value != "let") { return false } + skipWhiteSpace.lastIndex = this.pos; + var skip = skipWhiteSpace.exec(this.input); + var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); + if (nextCh === 91 || nextCh == 123) { return true } // '{' and '[' if (isIdentifierStart(nextCh, true)) { - var pos = next + 1 - while (isIdentifierChar(this.input.charCodeAt(pos), true)) ++pos - var ident = this.input.slice(next, pos) - if (!this.isKeyword(ident)) return true + var pos = next + 1; + while (isIdentifierChar(this.input.charCodeAt(pos), true)) { ++pos; } + var ident = this.input.slice(next, pos); + if (!this.isKeyword(ident)) { return true } } return false -} +}; // check 'async [no LineTerminator here] function' // - 'async /*foo*/ function' is OK. // - 'async /*\n*/ function' is invalid. pp$1.isAsyncFunction = function() { - if (this.type !== tt.name || this.options.ecmaVersion < 8 || this.value != "async") - return false + if (this.type !== types.name || this.options.ecmaVersion < 8 || this.value != "async") + { return false } - skipWhiteSpace.lastIndex = this.pos - var skip = skipWhiteSpace.exec(this.input) - var next = this.pos + skip[0].length + skipWhiteSpace.lastIndex = this.pos; + var skip = skipWhiteSpace.exec(this.input); + var next = this.pos + skip[0].length; return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 == this.input.length || !isIdentifierChar(this.input.charAt(next + 8))) -} +}; // Parse a single statement. // @@ -725,11 +732,11 @@ pp$1.isAsyncFunction = function() { // does not help. pp$1.parseStatement = function(declaration, topLevel, exports) { - var starttype = this.type, node = this.startNode(), kind + var starttype = this.type, node = this.startNode(), kind; if (this.isLet()) { - starttype = tt._var - kind = "let" + starttype = types._var; + kind = "let"; } // Most types of statements are recognized by the keyword they @@ -737,38 +744,38 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { // complexity. switch (starttype) { - case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword) - case tt._debugger: return this.parseDebuggerStatement(node) - case tt._do: return this.parseDoStatement(node) - case tt._for: return this.parseForStatement(node) - case tt._function: - if (!declaration && this.options.ecmaVersion >= 6) this.unexpected() + case types._break: case types._continue: return this.parseBreakContinueStatement(node, starttype.keyword) + case types._debugger: return this.parseDebuggerStatement(node) + case types._do: return this.parseDoStatement(node) + case types._for: return this.parseForStatement(node) + case types._function: + if (!declaration && this.options.ecmaVersion >= 6) { this.unexpected(); } return this.parseFunctionStatement(node, false) - case tt._class: - if (!declaration) this.unexpected() + case types._class: + if (!declaration) { this.unexpected(); } return this.parseClass(node, true) - case tt._if: return this.parseIfStatement(node) - case tt._return: return this.parseReturnStatement(node) - case tt._switch: return this.parseSwitchStatement(node) - case tt._throw: return this.parseThrowStatement(node) - case tt._try: return this.parseTryStatement(node) - case tt._const: case tt._var: - kind = kind || this.value - if (!declaration && kind != "var") this.unexpected() + case types._if: return this.parseIfStatement(node) + case types._return: return this.parseReturnStatement(node) + case types._switch: return this.parseSwitchStatement(node) + case types._throw: return this.parseThrowStatement(node) + case types._try: return this.parseTryStatement(node) + case types._const: case types._var: + kind = kind || this.value; + if (!declaration && kind != "var") { this.unexpected(); } return this.parseVarStatement(node, kind) - case tt._while: return this.parseWhileStatement(node) - case tt._with: return this.parseWithStatement(node) - case tt.braceL: return this.parseBlock() - case tt.semi: return this.parseEmptyStatement(node) - case tt._export: - case tt._import: + case types._while: return this.parseWhileStatement(node) + case types._with: return this.parseWithStatement(node) + case types.braceL: return this.parseBlock() + case types.semi: return this.parseEmptyStatement(node) + case types._export: + case types._import: if (!this.options.allowImportExportEverywhere) { if (!topLevel) - this.raise(this.start, "'import' and 'export' may only appear at the top level") + { this.raise(this.start, "'import' and 'export' may only appear at the top level"); } if (!this.inModule) - this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'") + { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); } } - return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports) + return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports) // If the statement does not start with a statement keyword or a // brace, it's an ExpressionStatement or LabeledStatement. We @@ -777,62 +784,62 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { // Identifier node, we switch to interpreting it as a label. default: if (this.isAsyncFunction() && declaration) { - this.next() + this.next(); return this.parseFunctionStatement(node, true) } - var maybeName = this.value, expr = this.parseExpression() - if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) - return this.parseLabeledStatement(node, maybeName, expr) - else return this.parseExpressionStatement(node, expr) + var maybeName = this.value, expr = this.parseExpression(); + if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) + { return this.parseLabeledStatement(node, maybeName, expr) } + else { return this.parseExpressionStatement(node, expr) } } -} +}; pp$1.parseBreakContinueStatement = function(node, keyword) { var this$1 = this; - var isBreak = keyword == "break" - this.next() - if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null - else if (this.type !== tt.name) this.unexpected() + var isBreak = keyword == "break"; + this.next(); + if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; } + else if (this.type !== types.name) { this.unexpected(); } else { - node.label = this.parseIdent() - this.semicolon() + node.label = this.parseIdent(); + this.semicolon(); } // Verify that there is an actual destination to break or // continue to. - var i = 0 + var i = 0; for (; i < this.labels.length; ++i) { - var lab = this$1.labels[i] + var lab = this$1.labels[i]; if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === "loop")) break - if (node.label && isBreak) break + if (lab.kind != null && (isBreak || lab.kind === "loop")) { break } + if (node.label && isBreak) { break } } } - if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword) + if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); } return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement") -} +}; pp$1.parseDebuggerStatement = function(node) { - this.next() - this.semicolon() + this.next(); + this.semicolon(); return this.finishNode(node, "DebuggerStatement") -} +}; pp$1.parseDoStatement = function(node) { - this.next() - this.labels.push(loopLabel) - node.body = this.parseStatement(false) - this.labels.pop() - this.expect(tt._while) - node.test = this.parseParenExpression() + this.next(); + this.labels.push(loopLabel); + node.body = this.parseStatement(false); + this.labels.pop(); + this.expect(types._while); + node.test = this.parseParenExpression(); if (this.options.ecmaVersion >= 6) - this.eat(tt.semi) + { this.eat(types.semi); } else - this.semicolon() + { this.semicolon(); } return this.finishNode(node, "DoWhileStatement") -} +}; // Disambiguating between a `for` and a `for`/`in` or `for`/`of` // loop is non-trivial. Basically, we have to parse the init `var` @@ -843,202 +850,207 @@ pp$1.parseDoStatement = function(node) { // is a regular `for` loop. pp$1.parseForStatement = function(node) { - this.next() - this.labels.push(loopLabel) - this.enterLexicalScope() - this.expect(tt.parenL) - if (this.type === tt.semi) return this.parseFor(node, null) - var isLet = this.isLet() - if (this.type === tt._var || this.type === tt._const || isLet) { - var init$1 = this.startNode(), kind = isLet ? "let" : this.value - this.next() - this.parseVar(init$1, true, kind) - this.finishNode(init$1, "VariableDeclaration") - if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 && + this.next(); + this.labels.push(loopLabel); + this.enterLexicalScope(); + this.expect(types.parenL); + if (this.type === types.semi) { return this.parseFor(node, null) } + var isLet = this.isLet(); + if (this.type === types._var || this.type === types._const || isLet) { + var init$1 = this.startNode(), kind = isLet ? "let" : this.value; + this.next(); + this.parseVar(init$1, true, kind); + this.finishNode(init$1, "VariableDeclaration"); + if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 && !(kind !== "var" && init$1.declarations[0].init)) - return this.parseForIn(node, init$1) + { return this.parseForIn(node, init$1) } return this.parseFor(node, init$1) } - var refDestructuringErrors = new DestructuringErrors - var init = this.parseExpression(true, refDestructuringErrors) - if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) { - this.toAssignable(init) - this.checkLVal(init) - this.checkPatternErrors(refDestructuringErrors, true) + var refDestructuringErrors = new DestructuringErrors; + var init = this.parseExpression(true, refDestructuringErrors); + if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) { + this.toAssignable(init); + this.checkLVal(init); + this.checkPatternErrors(refDestructuringErrors, true); return this.parseForIn(node, init) } else { - this.checkExpressionErrors(refDestructuringErrors, true) + this.checkExpressionErrors(refDestructuringErrors, true); } return this.parseFor(node, init) -} +}; pp$1.parseFunctionStatement = function(node, isAsync) { - this.next() + this.next(); return this.parseFunction(node, true, false, isAsync) -} +}; pp$1.isFunction = function() { - return this.type === tt._function || this.isAsyncFunction() -} + return this.type === types._function || this.isAsyncFunction() +}; pp$1.parseIfStatement = function(node) { - this.next() - node.test = this.parseParenExpression() + this.next(); + node.test = this.parseParenExpression(); // allow function declarations in branches, but only in non-strict mode - node.consequent = this.parseStatement(!this.strict && this.isFunction()) - node.alternate = this.eat(tt._else) ? this.parseStatement(!this.strict && this.isFunction()) : null + node.consequent = this.parseStatement(!this.strict && this.isFunction()); + node.alternate = this.eat(types._else) ? this.parseStatement(!this.strict && this.isFunction()) : null; return this.finishNode(node, "IfStatement") -} +}; pp$1.parseReturnStatement = function(node) { if (!this.inFunction && !this.options.allowReturnOutsideFunction) - this.raise(this.start, "'return' outside of function") - this.next() + { this.raise(this.start, "'return' outside of function"); } + this.next(); // In `return` (and `break`/`continue`), the keywords with // optional arguments, we eagerly look for a semicolon or the // possibility to insert one. - if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null - else { node.argument = this.parseExpression(); this.semicolon() } + if (this.eat(types.semi) || this.insertSemicolon()) { node.argument = null; } + else { node.argument = this.parseExpression(); this.semicolon(); } return this.finishNode(node, "ReturnStatement") -} +}; pp$1.parseSwitchStatement = function(node) { var this$1 = this; - this.next() - node.discriminant = this.parseParenExpression() - node.cases = [] - this.expect(tt.braceL) - this.labels.push(switchLabel) - this.enterLexicalScope() + this.next(); + node.discriminant = this.parseParenExpression(); + node.cases = []; + this.expect(types.braceL); + this.labels.push(switchLabel); + this.enterLexicalScope(); // Statements under must be grouped (by label) in SwitchCase // nodes. `cur` is used to keep the node that we are currently // adding statements to. - var cur - for (var sawDefault = false; this.type != tt.braceR;) { - if (this$1.type === tt._case || this$1.type === tt._default) { - var isCase = this$1.type === tt._case - if (cur) this$1.finishNode(cur, "SwitchCase") - node.cases.push(cur = this$1.startNode()) - cur.consequent = [] - this$1.next() + var cur; + for (var sawDefault = false; this.type != types.braceR;) { + if (this$1.type === types._case || this$1.type === types._default) { + var isCase = this$1.type === types._case; + if (cur) { this$1.finishNode(cur, "SwitchCase"); } + node.cases.push(cur = this$1.startNode()); + cur.consequent = []; + this$1.next(); if (isCase) { - cur.test = this$1.parseExpression() + cur.test = this$1.parseExpression(); } else { - if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses") - sawDefault = true - cur.test = null + if (sawDefault) { this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses"); } + sawDefault = true; + cur.test = null; } - this$1.expect(tt.colon) + this$1.expect(types.colon); } else { - if (!cur) this$1.unexpected() - cur.consequent.push(this$1.parseStatement(true)) + if (!cur) { this$1.unexpected(); } + cur.consequent.push(this$1.parseStatement(true)); } } - this.exitLexicalScope() - if (cur) this.finishNode(cur, "SwitchCase") - this.next() // Closing brace - this.labels.pop() + this.exitLexicalScope(); + if (cur) { this.finishNode(cur, "SwitchCase"); } + this.next(); // Closing brace + this.labels.pop(); return this.finishNode(node, "SwitchStatement") -} +}; pp$1.parseThrowStatement = function(node) { - this.next() + this.next(); if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) - this.raise(this.lastTokEnd, "Illegal newline after throw") - node.argument = this.parseExpression() - this.semicolon() + { this.raise(this.lastTokEnd, "Illegal newline after throw"); } + node.argument = this.parseExpression(); + this.semicolon(); return this.finishNode(node, "ThrowStatement") -} +}; // Reused empty array added for node fields that are always empty. -var empty = [] +var empty = []; pp$1.parseTryStatement = function(node) { - this.next() - node.block = this.parseBlock() - node.handler = null - if (this.type === tt._catch) { - var clause = this.startNode() - this.next() - this.expect(tt.parenL) - clause.param = this.parseBindingAtom() - this.enterLexicalScope() - this.checkLVal(clause.param, "let") - this.expect(tt.parenR) - clause.body = this.parseBlock(false) - this.exitLexicalScope() - node.handler = this.finishNode(clause, "CatchClause") - } - node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null + this.next(); + node.block = this.parseBlock(); + node.handler = null; + if (this.type === types._catch) { + var clause = this.startNode(); + this.next(); + this.expect(types.parenL); + clause.param = this.parseBindingAtom(); + this.enterLexicalScope(); + this.checkLVal(clause.param, "let"); + this.expect(types.parenR); + clause.body = this.parseBlock(false); + this.exitLexicalScope(); + node.handler = this.finishNode(clause, "CatchClause"); + } + node.finalizer = this.eat(types._finally) ? this.parseBlock() : null; if (!node.handler && !node.finalizer) - this.raise(node.start, "Missing catch or finally clause") + { this.raise(node.start, "Missing catch or finally clause"); } return this.finishNode(node, "TryStatement") -} +}; pp$1.parseVarStatement = function(node, kind) { - this.next() - this.parseVar(node, false, kind) - this.semicolon() + this.next(); + this.parseVar(node, false, kind); + this.semicolon(); return this.finishNode(node, "VariableDeclaration") -} +}; pp$1.parseWhileStatement = function(node) { - this.next() - node.test = this.parseParenExpression() - this.labels.push(loopLabel) - node.body = this.parseStatement(false) - this.labels.pop() + this.next(); + node.test = this.parseParenExpression(); + this.labels.push(loopLabel); + node.body = this.parseStatement(false); + this.labels.pop(); return this.finishNode(node, "WhileStatement") -} +}; pp$1.parseWithStatement = function(node) { - if (this.strict) this.raise(this.start, "'with' in strict mode") - this.next() - node.object = this.parseParenExpression() - node.body = this.parseStatement(false) + if (this.strict) { this.raise(this.start, "'with' in strict mode"); } + this.next(); + node.object = this.parseParenExpression(); + node.body = this.parseStatement(false); return this.finishNode(node, "WithStatement") -} +}; pp$1.parseEmptyStatement = function(node) { - this.next() + this.next(); return this.finishNode(node, "EmptyStatement") -} +}; pp$1.parseLabeledStatement = function(node, maybeName, expr) { var this$1 = this; - for (var i = 0; i < this.labels.length; ++i) - if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, "Label '" + maybeName + "' is already declared") - var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null - for (var i$1 = this.labels.length - 1; i$1 >= 0; i$1--) { - var label = this$1.labels[i$1] - if (label.statementStart == node.start) { - label.statementStart = this$1.start - label.kind = kind - } else break - } - this.labels.push({name: maybeName, kind: kind, statementStart: this.start}) - node.body = this.parseStatement(true) + for (var i$1 = 0, list = this$1.labels; i$1 < list.length; i$1 += 1) + { + var label = list[i$1]; + + if (label.name === maybeName) + { this$1.raise(expr.start, "Label '" + maybeName + "' is already declared"); + } } + var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null; + for (var i = this.labels.length - 1; i >= 0; i--) { + var label$1 = this$1.labels[i]; + if (label$1.statementStart == node.start) { + label$1.statementStart = this$1.start; + label$1.kind = kind; + } else { break } + } + this.labels.push({name: maybeName, kind: kind, statementStart: this.start}); + node.body = this.parseStatement(true); if (node.body.type == "ClassDeclaration" || node.body.type == "VariableDeclaration" && node.body.kind != "var" || node.body.type == "FunctionDeclaration" && (this.strict || node.body.generator)) - this.raiseRecoverable(node.body.start, "Invalid labeled declaration") - this.labels.pop() - node.label = expr + { this.raiseRecoverable(node.body.start, "Invalid labeled declaration"); } + this.labels.pop(); + node.label = expr; return this.finishNode(node, "LabeledStatement") -} +}; pp$1.parseExpressionStatement = function(node, expr) { - node.expression = expr - this.semicolon() + node.expression = expr; + this.semicolon(); return this.finishNode(node, "ExpressionStatement") -} +}; // Parse a semicolon-enclosed block of statements, handling `"use // strict"` declarations when `allowStrict` is true (used for @@ -1048,129 +1060,129 @@ pp$1.parseBlock = function(createNewLexicalScope) { var this$1 = this; if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; - var node = this.startNode() - node.body = [] - this.expect(tt.braceL) + var node = this.startNode(); + node.body = []; + this.expect(types.braceL); if (createNewLexicalScope) { - this.enterLexicalScope() + this.enterLexicalScope(); } - while (!this.eat(tt.braceR)) { - var stmt = this$1.parseStatement(true) - node.body.push(stmt) + while (!this.eat(types.braceR)) { + var stmt = this$1.parseStatement(true); + node.body.push(stmt); } if (createNewLexicalScope) { - this.exitLexicalScope() + this.exitLexicalScope(); } return this.finishNode(node, "BlockStatement") -} +}; // Parse a regular `for` loop. The disambiguation code in // `parseStatement` will already have parsed the init statement or // expression. pp$1.parseFor = function(node, init) { - node.init = init - this.expect(tt.semi) - node.test = this.type === tt.semi ? null : this.parseExpression() - this.expect(tt.semi) - node.update = this.type === tt.parenR ? null : this.parseExpression() - this.expect(tt.parenR) - this.exitLexicalScope() - node.body = this.parseStatement(false) - this.labels.pop() + node.init = init; + this.expect(types.semi); + node.test = this.type === types.semi ? null : this.parseExpression(); + this.expect(types.semi); + node.update = this.type === types.parenR ? null : this.parseExpression(); + this.expect(types.parenR); + this.exitLexicalScope(); + node.body = this.parseStatement(false); + this.labels.pop(); return this.finishNode(node, "ForStatement") -} +}; // Parse a `for`/`in` and `for`/`of` loop, which are almost // same from parser's perspective. pp$1.parseForIn = function(node, init) { - var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement" - this.next() - node.left = init - node.right = this.parseExpression() - this.expect(tt.parenR) - this.exitLexicalScope() - node.body = this.parseStatement(false) - this.labels.pop() + var type = this.type === types._in ? "ForInStatement" : "ForOfStatement"; + this.next(); + node.left = init; + node.right = this.parseExpression(); + this.expect(types.parenR); + this.exitLexicalScope(); + node.body = this.parseStatement(false); + this.labels.pop(); return this.finishNode(node, type) -} +}; // Parse a list of variable declarations. pp$1.parseVar = function(node, isFor, kind) { var this$1 = this; - node.declarations = [] - node.kind = kind + node.declarations = []; + node.kind = kind; for (;;) { - var decl = this$1.startNode() - this$1.parseVarId(decl, kind) - if (this$1.eat(tt.eq)) { - decl.init = this$1.parseMaybeAssign(isFor) - } else if (kind === "const" && !(this$1.type === tt._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) { - this$1.unexpected() - } else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === tt._in || this$1.isContextual("of")))) { - this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value") + var decl = this$1.startNode(); + this$1.parseVarId(decl, kind); + if (this$1.eat(types.eq)) { + decl.init = this$1.parseMaybeAssign(isFor); + } else if (kind === "const" && !(this$1.type === types._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) { + this$1.unexpected(); + } else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === types._in || this$1.isContextual("of")))) { + this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value"); } else { - decl.init = null + decl.init = null; } - node.declarations.push(this$1.finishNode(decl, "VariableDeclarator")) - if (!this$1.eat(tt.comma)) break + node.declarations.push(this$1.finishNode(decl, "VariableDeclarator")); + if (!this$1.eat(types.comma)) { break } } return node -} +}; pp$1.parseVarId = function(decl, kind) { - decl.id = this.parseBindingAtom(kind) - this.checkLVal(decl.id, kind, false) -} + decl.id = this.parseBindingAtom(kind); + this.checkLVal(decl.id, kind, false); +}; // Parse a function declaration or literal (depending on the // `isStatement` parameter). pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { - this.initFunction(node) + this.initFunction(node); if (this.options.ecmaVersion >= 6 && !isAsync) - node.generator = this.eat(tt.star) + { node.generator = this.eat(types.star); } if (this.options.ecmaVersion >= 8) - node.async = !!isAsync + { node.async = !!isAsync; } if (isStatement) { - node.id = isStatement === "nullableID" && this.type != tt.name ? null : this.parseIdent() + node.id = isStatement === "nullableID" && this.type != types.name ? null : this.parseIdent(); if (node.id) { - this.checkLVal(node.id, "var") + this.checkLVal(node.id, "var"); } } var oldInGen = this.inGenerator, oldInAsync = this.inAsync, - oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction - this.inGenerator = node.generator - this.inAsync = node.async - this.yieldPos = 0 - this.awaitPos = 0 - this.inFunction = true - this.enterFunctionScope() + oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction; + this.inGenerator = node.generator; + this.inAsync = node.async; + this.yieldPos = 0; + this.awaitPos = 0; + this.inFunction = true; + this.enterFunctionScope(); if (!isStatement) - node.id = this.type == tt.name ? this.parseIdent() : null + { node.id = this.type == types.name ? this.parseIdent() : null; } - this.parseFunctionParams(node) - this.parseFunctionBody(node, allowExpressionBody) + this.parseFunctionParams(node); + this.parseFunctionBody(node, allowExpressionBody); - this.inGenerator = oldInGen - this.inAsync = oldInAsync - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - this.inFunction = oldInFunc + this.inGenerator = oldInGen; + this.inAsync = oldInAsync; + this.yieldPos = oldYieldPos; + this.awaitPos = oldAwaitPos; + this.inFunction = oldInFunc; return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") -} +}; pp$1.parseFunctionParams = function(node) { - this.expect(tt.parenL) - node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true) - this.checkYieldAwaitInDefaultParams() -} + this.expect(types.parenL); + node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8); + this.checkYieldAwaitInDefaultParams(); +}; // Parse a class declaration or literal (depending on the // `isStatement` parameter). @@ -1178,177 +1190,186 @@ pp$1.parseFunctionParams = function(node) { pp$1.parseClass = function(node, isStatement) { var this$1 = this; - this.next() - - this.parseClassId(node, isStatement) - this.parseClassSuper(node) - var classBody = this.startNode() - var hadConstructor = false - classBody.body = [] - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { - if (this$1.eat(tt.semi)) continue - var method = this$1.startNode() - var isGenerator = this$1.eat(tt.star) - var isAsync = false - var isMaybeStatic = this$1.type === tt.name && this$1.value === "static" - this$1.parsePropertyName(method) - method.static = isMaybeStatic && this$1.type !== tt.parenL + this.next(); + + this.parseClassId(node, isStatement); + this.parseClassSuper(node); + var classBody = this.startNode(); + var hadConstructor = false; + classBody.body = []; + this.expect(types.braceL); + while (!this.eat(types.braceR)) { + if (this$1.eat(types.semi)) { continue } + var method = this$1.startNode(); + var isGenerator = this$1.eat(types.star); + var isAsync = false; + var isMaybeStatic = this$1.type === types.name && this$1.value === "static"; + this$1.parsePropertyName(method); + method.static = isMaybeStatic && this$1.type !== types.parenL; if (method.static) { - if (isGenerator) this$1.unexpected() - isGenerator = this$1.eat(tt.star) - this$1.parsePropertyName(method) + if (isGenerator) { this$1.unexpected(); } + isGenerator = this$1.eat(types.star); + this$1.parsePropertyName(method); } if (this$1.options.ecmaVersion >= 8 && !isGenerator && !method.computed && - method.key.type === "Identifier" && method.key.name === "async" && this$1.type !== tt.parenL && + method.key.type === "Identifier" && method.key.name === "async" && this$1.type !== types.parenL && !this$1.canInsertSemicolon()) { - isAsync = true - this$1.parsePropertyName(method) + isAsync = true; + this$1.parsePropertyName(method); } - method.kind = "method" - var isGetSet = false + method.kind = "method"; + var isGetSet = false; if (!method.computed) { var key = method.key; - if (!isGenerator && !isAsync && key.type === "Identifier" && this$1.type !== tt.parenL && (key.name === "get" || key.name === "set")) { - isGetSet = true - method.kind = key.name - key = this$1.parsePropertyName(method) + if (!isGenerator && !isAsync && key.type === "Identifier" && this$1.type !== types.parenL && (key.name === "get" || key.name === "set")) { + isGetSet = true; + method.kind = key.name; + key = this$1.parsePropertyName(method); } if (!method.static && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) { - if (hadConstructor) this$1.raise(key.start, "Duplicate constructor in the same class") - if (isGetSet) this$1.raise(key.start, "Constructor can't have get/set modifier") - if (isGenerator) this$1.raise(key.start, "Constructor can't be a generator") - if (isAsync) this$1.raise(key.start, "Constructor can't be an async method") - method.kind = "constructor" - hadConstructor = true + if (hadConstructor) { this$1.raise(key.start, "Duplicate constructor in the same class"); } + if (isGetSet) { this$1.raise(key.start, "Constructor can't have get/set modifier"); } + if (isGenerator) { this$1.raise(key.start, "Constructor can't be a generator"); } + if (isAsync) { this$1.raise(key.start, "Constructor can't be an async method"); } + method.kind = "constructor"; + hadConstructor = true; } } - this$1.parseClassMethod(classBody, method, isGenerator, isAsync) + this$1.parseClassMethod(classBody, method, isGenerator, isAsync); if (isGetSet) { - var paramCount = method.kind === "get" ? 0 : 1 + var paramCount = method.kind === "get" ? 0 : 1; if (method.value.params.length !== paramCount) { - var start = method.value.start + var start = method.value.start; if (method.kind === "get") - this$1.raiseRecoverable(start, "getter should have no params") + { this$1.raiseRecoverable(start, "getter should have no params"); } else - this$1.raiseRecoverable(start, "setter should have exactly one param") + { this$1.raiseRecoverable(start, "setter should have exactly one param"); } } else { if (method.kind === "set" && method.value.params[0].type === "RestElement") - this$1.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params") + { this$1.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params"); } } } } - node.body = this.finishNode(classBody, "ClassBody") + node.body = this.finishNode(classBody, "ClassBody"); return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") -} +}; pp$1.parseClassMethod = function(classBody, method, isGenerator, isAsync) { - method.value = this.parseMethod(isGenerator, isAsync) - classBody.body.push(this.finishNode(method, "MethodDefinition")) -} + method.value = this.parseMethod(isGenerator, isAsync); + classBody.body.push(this.finishNode(method, "MethodDefinition")); +}; pp$1.parseClassId = function(node, isStatement) { - node.id = this.type === tt.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null -} + node.id = this.type === types.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null; +}; pp$1.parseClassSuper = function(node) { - node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null -} + node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null; +}; // Parses module export declaration. pp$1.parseExport = function(node, exports) { var this$1 = this; - this.next() + this.next(); // export * from '...' - if (this.eat(tt.star)) { - this.expectContextual("from") - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() - this.semicolon() + if (this.eat(types.star)) { + this.expectContextual("from"); + node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected(); + this.semicolon(); return this.finishNode(node, "ExportAllDeclaration") } - if (this.eat(tt._default)) { // export default ... - this.checkExport(exports, "default", this.lastTokStart) - var isAsync - if (this.type === tt._function || (isAsync = this.isAsyncFunction())) { - var fNode = this.startNode() - this.next() - if (isAsync) this.next() - node.declaration = this.parseFunction(fNode, "nullableID", false, isAsync) - } else if (this.type === tt._class) { - var cNode = this.startNode() - node.declaration = this.parseClass(cNode, "nullableID") + if (this.eat(types._default)) { // export default ... + this.checkExport(exports, "default", this.lastTokStart); + var isAsync; + if (this.type === types._function || (isAsync = this.isAsyncFunction())) { + var fNode = this.startNode(); + this.next(); + if (isAsync) { this.next(); } + node.declaration = this.parseFunction(fNode, "nullableID", false, isAsync); + } else if (this.type === types._class) { + var cNode = this.startNode(); + node.declaration = this.parseClass(cNode, "nullableID"); } else { - node.declaration = this.parseMaybeAssign() - this.semicolon() + node.declaration = this.parseMaybeAssign(); + this.semicolon(); } return this.finishNode(node, "ExportDefaultDeclaration") } // export var|const|let|function|class ... if (this.shouldParseExportStatement()) { - node.declaration = this.parseStatement(true) + node.declaration = this.parseStatement(true); if (node.declaration.type === "VariableDeclaration") - this.checkVariableExport(exports, node.declaration.declarations) + { this.checkVariableExport(exports, node.declaration.declarations); } else - this.checkExport(exports, node.declaration.id.name, node.declaration.id.start) - node.specifiers = [] - node.source = null + { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); } + node.specifiers = []; + node.source = null; } else { // export { x, y as z } [from '...'] - node.declaration = null - node.specifiers = this.parseExportSpecifiers(exports) + node.declaration = null; + node.specifiers = this.parseExportSpecifiers(exports); if (this.eatContextual("from")) { - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() + node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected(); } else { // check for keywords used as local names - for (var i = 0; i < node.specifiers.length; i++) { - if (this$1.keywords.test(node.specifiers[i].local.name) || this$1.reservedWords.test(node.specifiers[i].local.name)) { - this$1.unexpected(node.specifiers[i].local.start) - } + for (var i = 0, list = node.specifiers; i < list.length; i += 1) { + var spec = list[i]; + + this$1.checkUnreserved(spec.local); } - node.source = null + node.source = null; } - this.semicolon() + this.semicolon(); } return this.finishNode(node, "ExportNamedDeclaration") -} +}; pp$1.checkExport = function(exports, name, pos) { - if (!exports) return + if (!exports) { return } if (has(exports, name)) - this.raiseRecoverable(pos, "Duplicate export '" + name + "'") - exports[name] = true -} + { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); } + exports[name] = true; +}; pp$1.checkPatternExport = function(exports, pat) { var this$1 = this; - var type = pat.type + var type = pat.type; if (type == "Identifier") - this.checkExport(exports, pat.name, pat.start) + { this.checkExport(exports, pat.name, pat.start); } else if (type == "ObjectPattern") - for (var i = 0; i < pat.properties.length; ++i) - this$1.checkPatternExport(exports, pat.properties[i].value) + { for (var i = 0, list = pat.properties; i < list.length; i += 1) + { + var prop = list[i]; + + this$1.checkPatternExport(exports, prop.value); + } } else if (type == "ArrayPattern") - for (var i$1 = 0; i$1 < pat.elements.length; ++i$1) { - var elt = pat.elements[i$1] - if (elt) this$1.checkPatternExport(exports, elt) - } + { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) { + var elt = list$1[i$1]; + + if (elt) { this$1.checkPatternExport(exports, elt); } + } } else if (type == "AssignmentPattern") - this.checkPatternExport(exports, pat.left) + { this.checkPatternExport(exports, pat.left); } else if (type == "ParenthesizedExpression") - this.checkPatternExport(exports, pat.expression) -} + { this.checkPatternExport(exports, pat.expression); } +}; pp$1.checkVariableExport = function(exports, decls) { var this$1 = this; - if (!exports) return - for (var i = 0; i < decls.length; i++) - this$1.checkPatternExport(exports, decls[i].id) -} + if (!exports) { return } + for (var i = 0, list = decls; i < list.length; i += 1) + { + var decl = list[i]; + + this$1.checkPatternExport(exports, decl.id); + } +}; pp$1.shouldParseExportStatement = function() { return this.type.keyword === "var" || @@ -1357,94 +1378,93 @@ pp$1.shouldParseExportStatement = function() { this.type.keyword === "function" || this.isLet() || this.isAsyncFunction() -} +}; // Parses a comma-separated list of module exports. pp$1.parseExportSpecifiers = function(exports) { var this$1 = this; - var nodes = [], first = true + var nodes = [], first = true; // export { x, y as z } [from '...'] - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { + this.expect(types.braceL); + while (!this.eat(types.braceR)) { if (!first) { - this$1.expect(tt.comma) - if (this$1.afterTrailingComma(tt.braceR)) break - } else first = false + this$1.expect(types.comma); + if (this$1.afterTrailingComma(types.braceR)) { break } + } else { first = false; } - var node = this$1.startNode() - node.local = this$1.parseIdent(true) - node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local - this$1.checkExport(exports, node.exported.name, node.exported.start) - nodes.push(this$1.finishNode(node, "ExportSpecifier")) + var node = this$1.startNode(); + node.local = this$1.parseIdent(true); + node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local; + this$1.checkExport(exports, node.exported.name, node.exported.start); + nodes.push(this$1.finishNode(node, "ExportSpecifier")); } return nodes -} +}; // Parses import declaration. pp$1.parseImport = function(node) { - this.next() + this.next(); // import '...' - if (this.type === tt.string) { - node.specifiers = empty - node.source = this.parseExprAtom() + if (this.type === types.string) { + node.specifiers = empty; + node.source = this.parseExprAtom(); } else { - node.specifiers = this.parseImportSpecifiers() - this.expectContextual("from") - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() + node.specifiers = this.parseImportSpecifiers(); + this.expectContextual("from"); + node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected(); } - this.semicolon() + this.semicolon(); return this.finishNode(node, "ImportDeclaration") -} +}; // Parses a comma-separated list of module imports. pp$1.parseImportSpecifiers = function() { var this$1 = this; - var nodes = [], first = true - if (this.type === tt.name) { + var nodes = [], first = true; + if (this.type === types.name) { // import defaultObj, { x, y as z } from '...' - var node = this.startNode() - node.local = this.parseIdent() - this.checkLVal(node.local, "let") - nodes.push(this.finishNode(node, "ImportDefaultSpecifier")) - if (!this.eat(tt.comma)) return nodes - } - if (this.type === tt.star) { - var node$1 = this.startNode() - this.next() - this.expectContextual("as") - node$1.local = this.parseIdent() - this.checkLVal(node$1.local, "let") - nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier")) + var node = this.startNode(); + node.local = this.parseIdent(); + this.checkLVal(node.local, "let"); + nodes.push(this.finishNode(node, "ImportDefaultSpecifier")); + if (!this.eat(types.comma)) { return nodes } + } + if (this.type === types.star) { + var node$1 = this.startNode(); + this.next(); + this.expectContextual("as"); + node$1.local = this.parseIdent(); + this.checkLVal(node$1.local, "let"); + nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier")); return nodes } - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { + this.expect(types.braceL); + while (!this.eat(types.braceR)) { if (!first) { - this$1.expect(tt.comma) - if (this$1.afterTrailingComma(tt.braceR)) break - } else first = false + this$1.expect(types.comma); + if (this$1.afterTrailingComma(types.braceR)) { break } + } else { first = false; } - var node$2 = this$1.startNode() - node$2.imported = this$1.parseIdent(true) + var node$2 = this$1.startNode(); + node$2.imported = this$1.parseIdent(true); if (this$1.eatContextual("as")) { - node$2.local = this$1.parseIdent() + node$2.local = this$1.parseIdent(); } else { - node$2.local = node$2.imported - if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start) - if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raiseRecoverable(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved") + this$1.checkUnreserved(node$2.imported); + node$2.local = node$2.imported; } - this$1.checkLVal(node$2.local, "let") - nodes.push(this$1.finishNode(node$2, "ImportSpecifier")) + this$1.checkLVal(node$2.local, "let"); + nodes.push(this$1.finishNode(node$2, "ImportSpecifier")); } return nodes -} +}; -var pp$2 = Parser.prototype +var pp$2 = Parser.prototype; // Convert existing expression atom to assignable pattern // if possible. @@ -1456,7 +1476,7 @@ pp$2.toAssignable = function(node, isBinding) { switch (node.type) { case "Identifier": if (this.inAsync && node.name === "await") - this.raise(node.start, "Can not use 'await' as identifier inside an async function") + { this.raise(node.start, "Can not use 'await' as identifier inside an async function"); } break case "ObjectPattern": @@ -1464,27 +1484,28 @@ pp$2.toAssignable = function(node, isBinding) { break case "ObjectExpression": - node.type = "ObjectPattern" - for (var i = 0; i < node.properties.length; i++) { - var prop = node.properties[i] - if (prop.kind !== "init") this$1.raise(prop.key.start, "Object pattern can't contain getter or setter") - this$1.toAssignable(prop.value, isBinding) + node.type = "ObjectPattern"; + for (var i = 0, list = node.properties; i < list.length; i += 1) { + var prop = list[i]; + + if (prop.kind !== "init") { this$1.raise(prop.key.start, "Object pattern can't contain getter or setter"); } + this$1.toAssignable(prop.value, isBinding); } break case "ArrayExpression": - node.type = "ArrayPattern" - this.toAssignableList(node.elements, isBinding) + node.type = "ArrayPattern"; + this.toAssignableList(node.elements, isBinding); break case "AssignmentExpression": if (node.operator === "=") { - node.type = "AssignmentPattern" - delete node.operator - this.toAssignable(node.left, isBinding) + node.type = "AssignmentPattern"; + delete node.operator; + this.toAssignable(node.left, isBinding); // falls through to AssignmentPattern } else { - this.raise(node.left.end, "Only '=' operator can be used for specifying default value.") + this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); break } @@ -1492,131 +1513,131 @@ pp$2.toAssignable = function(node, isBinding) { break case "ParenthesizedExpression": - node.expression = this.toAssignable(node.expression, isBinding) + this.toAssignable(node.expression, isBinding); break case "MemberExpression": - if (!isBinding) break + if (!isBinding) { break } default: - this.raise(node.start, "Assigning to rvalue") + this.raise(node.start, "Assigning to rvalue"); } } return node -} +}; // Convert list of expression atoms to binding list. pp$2.toAssignableList = function(exprList, isBinding) { var this$1 = this; - var end = exprList.length + var end = exprList.length; if (end) { - var last = exprList[end - 1] + var last = exprList[end - 1]; if (last && last.type == "RestElement") { - --end + --end; } else if (last && last.type == "SpreadElement") { - last.type = "RestElement" - var arg = last.argument - this.toAssignable(arg, isBinding) - if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") - this.unexpected(arg.start) - --end + last.type = "RestElement"; + var arg = last.argument; + this.toAssignable(arg, isBinding); + --end; } - if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") - this.unexpected(last.argument.start) + if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") + { this.unexpected(last.argument.start); } } for (var i = 0; i < end; i++) { - var elt = exprList[i] - if (elt) this$1.toAssignable(elt, isBinding) + var elt = exprList[i]; + if (elt) { this$1.toAssignable(elt, isBinding); } } return exprList -} +}; // Parses spread element. pp$2.parseSpread = function(refDestructuringErrors) { - var node = this.startNode() - this.next() - node.argument = this.parseMaybeAssign(false, refDestructuringErrors) + var node = this.startNode(); + this.next(); + node.argument = this.parseMaybeAssign(false, refDestructuringErrors); return this.finishNode(node, "SpreadElement") -} +}; -pp$2.parseRest = function(allowNonIdent) { - var node = this.startNode() - this.next() +pp$2.parseRestBinding = function() { + var node = this.startNode(); + this.next(); // RestElement inside of a function parameter must be an identifier - if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected() - else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected() + if (this.options.ecmaVersion === 6 && this.type !== types.name) + { this.unexpected(); } + + node.argument = this.parseBindingAtom(); return this.finishNode(node, "RestElement") -} +}; // Parses lvalue (assignable) atom. pp$2.parseBindingAtom = function() { - if (this.options.ecmaVersion < 6) return this.parseIdent() + if (this.options.ecmaVersion < 6) { return this.parseIdent() } switch (this.type) { - case tt.name: + case types.name: return this.parseIdent() - case tt.bracketL: - var node = this.startNode() - this.next() - node.elements = this.parseBindingList(tt.bracketR, true, true) + case types.bracketL: + var node = this.startNode(); + this.next(); + node.elements = this.parseBindingList(types.bracketR, true, true); return this.finishNode(node, "ArrayPattern") - case tt.braceL: + case types.braceL: return this.parseObj(true) default: - this.unexpected() + this.unexpected(); } -} +}; -pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) { +pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) { var this$1 = this; - var elts = [], first = true + var elts = [], first = true; while (!this.eat(close)) { - if (first) first = false - else this$1.expect(tt.comma) - if (allowEmpty && this$1.type === tt.comma) { - elts.push(null) + if (first) { first = false; } + else { this$1.expect(types.comma); } + if (allowEmpty && this$1.type === types.comma) { + elts.push(null); } else if (allowTrailingComma && this$1.afterTrailingComma(close)) { break - } else if (this$1.type === tt.ellipsis) { - var rest = this$1.parseRest(allowNonIdent) - this$1.parseBindingListItem(rest) - elts.push(rest) - if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element") - this$1.expect(close) + } else if (this$1.type === types.ellipsis) { + var rest = this$1.parseRestBinding(); + this$1.parseBindingListItem(rest); + elts.push(rest); + if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); } + this$1.expect(close); break } else { - var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc) - this$1.parseBindingListItem(elem) - elts.push(elem) + var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc); + this$1.parseBindingListItem(elem); + elts.push(elem); } } return elts -} +}; pp$2.parseBindingListItem = function(param) { return param -} +}; // Parses assignment pattern around given atom if possible. pp$2.parseMaybeDefault = function(startPos, startLoc, left) { - left = left || this.parseBindingAtom() - if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left - var node = this.startNodeAt(startPos, startLoc) - node.left = left - node.right = this.parseMaybeAssign() + left = left || this.parseBindingAtom(); + if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) { return left } + var node = this.startNodeAt(startPos, startLoc); + node.left = left; + node.right = this.parseMaybeAssign(); return this.finishNode(node, "AssignmentPattern") -} +}; // Verify that a node is an lval — something that can be assigned // to. @@ -1631,59 +1652,64 @@ pp$2.checkLVal = function(expr, bindingType, checkClashes) { switch (expr.type) { case "Identifier": if (this.strict && this.reservedWordsStrictBind.test(expr.name)) - this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode") + { this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); } if (checkClashes) { if (has(checkClashes, expr.name)) - this.raiseRecoverable(expr.start, "Argument name clash") - checkClashes[expr.name] = true + { this.raiseRecoverable(expr.start, "Argument name clash"); } + checkClashes[expr.name] = true; } if (bindingType && bindingType !== "none") { if ( bindingType === "var" && !this.canDeclareVarName(expr.name) || bindingType !== "var" && !this.canDeclareLexicalName(expr.name) ) { - this.raiseRecoverable(expr.start, ("Identifier '" + (expr.name) + "' has already been declared")) + this.raiseRecoverable(expr.start, ("Identifier '" + (expr.name) + "' has already been declared")); } if (bindingType === "var") { - this.declareVarName(expr.name) + this.declareVarName(expr.name); } else { - this.declareLexicalName(expr.name) + this.declareLexicalName(expr.name); } } break case "MemberExpression": - if (bindingType) this.raiseRecoverable(expr.start, (bindingType ? "Binding" : "Assigning to") + " member expression") + if (bindingType) { this.raiseRecoverable(expr.start, (bindingType ? "Binding" : "Assigning to") + " member expression"); } break case "ObjectPattern": - for (var i = 0; i < expr.properties.length; i++) - this$1.checkLVal(expr.properties[i].value, bindingType, checkClashes) + for (var i = 0, list = expr.properties; i < list.length; i += 1) + { + var prop = list[i]; + + this$1.checkLVal(prop.value, bindingType, checkClashes); + } break case "ArrayPattern": - for (var i$1 = 0; i$1 < expr.elements.length; i$1++) { - var elem = expr.elements[i$1] - if (elem) this$1.checkLVal(elem, bindingType, checkClashes) + for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) { + var elem = list$1[i$1]; + + if (elem) { this$1.checkLVal(elem, bindingType, checkClashes); } } break case "AssignmentPattern": - this.checkLVal(expr.left, bindingType, checkClashes) + this.checkLVal(expr.left, bindingType, checkClashes); break case "RestElement": - this.checkLVal(expr.argument, bindingType, checkClashes) + this.checkLVal(expr.argument, bindingType, checkClashes); break case "ParenthesizedExpression": - this.checkLVal(expr.expression, bindingType, checkClashes) + this.checkLVal(expr.expression, bindingType, checkClashes); break default: - this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue") + this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue"); } -} +}; // A recursive descent parser operates by defining functions for all // syntactic elements, and recursively calling those, each function @@ -1703,7 +1729,7 @@ pp$2.checkLVal = function(expr, bindingType, checkClashes) { // // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser -var pp$3 = Parser.prototype +var pp$3 = Parser.prototype; // Check if property name clashes with already added. // Object/class getters and setters are not allowed to clash — @@ -1712,9 +1738,9 @@ var pp$3 = Parser.prototype pp$3.checkPropClash = function(prop, propHash) { if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) - return + { return } var key = prop.key; - var name + var name; switch (key.type) { case "Identifier": name = key.name; break case "Literal": name = String(key.value); break @@ -1723,31 +1749,31 @@ pp$3.checkPropClash = function(prop, propHash) { var kind = prop.kind; if (this.options.ecmaVersion >= 6) { if (name === "__proto__" && kind === "init") { - if (propHash.proto) this.raiseRecoverable(key.start, "Redefinition of __proto__ property") - propHash.proto = true + if (propHash.proto) { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); } + propHash.proto = true; } return } - name = "$" + name - var other = propHash[name] + name = "$" + name; + var other = propHash[name]; if (other) { - var redefinition + var redefinition; if (kind === "init") { - redefinition = this.strict && other.init || other.get || other.set + redefinition = this.strict && other.init || other.get || other.set; } else { - redefinition = other.init || other[kind] + redefinition = other.init || other[kind]; } if (redefinition) - this.raiseRecoverable(key.start, "Redefinition of property") + { this.raiseRecoverable(key.start, "Redefinition of property"); } } else { other = propHash[name] = { init: false, get: false, set: false - } + }; } - other[kind] = true -} + other[kind] = true; +}; // ### Expression parsing @@ -1767,82 +1793,82 @@ pp$3.checkPropClash = function(prop, propHash) { pp$3.parseExpression = function(noIn, refDestructuringErrors) { var this$1 = this; - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseMaybeAssign(noIn, refDestructuringErrors) - if (this.type === tt.comma) { - var node = this.startNodeAt(startPos, startLoc) - node.expressions = [expr] - while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors)) + var startPos = this.start, startLoc = this.startLoc; + var expr = this.parseMaybeAssign(noIn, refDestructuringErrors); + if (this.type === types.comma) { + var node = this.startNodeAt(startPos, startLoc); + node.expressions = [expr]; + while (this.eat(types.comma)) { node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors)); } return this.finishNode(node, "SequenceExpression") } return expr -} +}; // Parse an assignment expression. This includes applications of // operators like `+=`. pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { - if (this.inGenerator && this.isContextual("yield")) return this.parseYield() + if (this.inGenerator && this.isContextual("yield")) { return this.parseYield() } - var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1 + var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1; if (refDestructuringErrors) { - oldParenAssign = refDestructuringErrors.parenthesizedAssign - oldTrailingComma = refDestructuringErrors.trailingComma - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1 + oldParenAssign = refDestructuringErrors.parenthesizedAssign; + oldTrailingComma = refDestructuringErrors.trailingComma; + refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1; } else { - refDestructuringErrors = new DestructuringErrors - ownDestructuringErrors = true + refDestructuringErrors = new DestructuringErrors; + ownDestructuringErrors = true; } - var startPos = this.start, startLoc = this.startLoc - if (this.type == tt.parenL || this.type == tt.name) - this.potentialArrowAt = this.start - var left = this.parseMaybeConditional(noIn, refDestructuringErrors) - if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc) + var startPos = this.start, startLoc = this.startLoc; + if (this.type == types.parenL || this.type == types.name) + { this.potentialArrowAt = this.start; } + var left = this.parseMaybeConditional(noIn, refDestructuringErrors); + if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); } if (this.type.isAssign) { - this.checkPatternErrors(refDestructuringErrors, true) - if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors) - var node = this.startNodeAt(startPos, startLoc) - node.operator = this.value - node.left = this.type === tt.eq ? this.toAssignable(left) : left - refDestructuringErrors.shorthandAssign = -1 // reset because shorthand default was used correctly - this.checkLVal(left) - this.next() - node.right = this.parseMaybeAssign(noIn) + this.checkPatternErrors(refDestructuringErrors, true); + if (!ownDestructuringErrors) { DestructuringErrors.call(refDestructuringErrors); } + var node = this.startNodeAt(startPos, startLoc); + node.operator = this.value; + node.left = this.type === types.eq ? this.toAssignable(left) : left; + refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly + this.checkLVal(left); + this.next(); + node.right = this.parseMaybeAssign(noIn); return this.finishNode(node, "AssignmentExpression") } else { - if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true) + if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); } } - if (oldParenAssign > -1) refDestructuringErrors.parenthesizedAssign = oldParenAssign - if (oldTrailingComma > -1) refDestructuringErrors.trailingComma = oldTrailingComma + if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } + if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } return left -} +}; // Parse a ternary conditional (`?:`) operator. pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseExprOps(noIn, refDestructuringErrors) - if (this.checkExpressionErrors(refDestructuringErrors)) return expr - if (this.eat(tt.question)) { - var node = this.startNodeAt(startPos, startLoc) - node.test = expr - node.consequent = this.parseMaybeAssign() - this.expect(tt.colon) - node.alternate = this.parseMaybeAssign(noIn) + var startPos = this.start, startLoc = this.startLoc; + var expr = this.parseExprOps(noIn, refDestructuringErrors); + if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } + if (this.eat(types.question)) { + var node = this.startNodeAt(startPos, startLoc); + node.test = expr; + node.consequent = this.parseMaybeAssign(); + this.expect(types.colon); + node.alternate = this.parseMaybeAssign(noIn); return this.finishNode(node, "ConditionalExpression") } return expr -} +}; // Start the precedence parser. pp$3.parseExprOps = function(noIn, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseMaybeUnary(refDestructuringErrors, false) - if (this.checkExpressionErrors(refDestructuringErrors)) return expr + var startPos = this.start, startLoc = this.startLoc; + var expr = this.parseMaybeUnary(refDestructuringErrors, false); + if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } return expr.start == startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn) -} +}; // Parse binary operators with the operator precedence parsing // algorithm. `left` is the left-hand side of the operator. @@ -1851,128 +1877,128 @@ pp$3.parseExprOps = function(noIn, refDestructuringErrors) { // operator that has a lower precedence than the set it is parsing. pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) { - var prec = this.type.binop - if (prec != null && (!noIn || this.type !== tt._in)) { + var prec = this.type.binop; + if (prec != null && (!noIn || this.type !== types._in)) { if (prec > minPrec) { - var logical = this.type === tt.logicalOR || this.type === tt.logicalAND - var op = this.value - this.next() - var startPos = this.start, startLoc = this.startLoc - var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn) - var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical) + var logical = this.type === types.logicalOR || this.type === types.logicalAND; + var op = this.value; + this.next(); + var startPos = this.start, startLoc = this.startLoc; + var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn); + var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical); return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) } } return left -} +}; pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) { - var node = this.startNodeAt(startPos, startLoc) - node.left = left - node.operator = op - node.right = right + var node = this.startNodeAt(startPos, startLoc); + node.left = left; + node.operator = op; + node.right = right; return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression") -} +}; // Parse unary operators, both prefix and postfix. pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) { var this$1 = this; - var startPos = this.start, startLoc = this.startLoc, expr + var startPos = this.start, startLoc = this.startLoc, expr; if (this.inAsync && this.isContextual("await")) { - expr = this.parseAwait(refDestructuringErrors) - sawUnary = true + expr = this.parseAwait(refDestructuringErrors); + sawUnary = true; } else if (this.type.prefix) { - var node = this.startNode(), update = this.type === tt.incDec - node.operator = this.value - node.prefix = true - this.next() - node.argument = this.parseMaybeUnary(null, true) - this.checkExpressionErrors(refDestructuringErrors, true) - if (update) this.checkLVal(node.argument) + var node = this.startNode(), update = this.type === types.incDec; + node.operator = this.value; + node.prefix = true; + this.next(); + node.argument = this.parseMaybeUnary(null, true); + this.checkExpressionErrors(refDestructuringErrors, true); + if (update) { this.checkLVal(node.argument); } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") - this.raiseRecoverable(node.start, "Deleting local variable in strict mode") - else sawUnary = true - expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression") + { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); } + else { sawUnary = true; } + expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); } else { - expr = this.parseExprSubscripts(refDestructuringErrors) - if (this.checkExpressionErrors(refDestructuringErrors)) return expr + expr = this.parseExprSubscripts(refDestructuringErrors); + if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } while (this.type.postfix && !this.canInsertSemicolon()) { - var node$1 = this$1.startNodeAt(startPos, startLoc) - node$1.operator = this$1.value - node$1.prefix = false - node$1.argument = expr - this$1.checkLVal(expr) - this$1.next() - expr = this$1.finishNode(node$1, "UpdateExpression") + var node$1 = this$1.startNodeAt(startPos, startLoc); + node$1.operator = this$1.value; + node$1.prefix = false; + node$1.argument = expr; + this$1.checkLVal(expr); + this$1.next(); + expr = this$1.finishNode(node$1, "UpdateExpression"); } } - if (!sawUnary && this.eat(tt.starstar)) - return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) + if (!sawUnary && this.eat(types.starstar)) + { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) } else - return expr -} + { return expr } +}; // Parse call, dot, and `[]`-subscript expressions. pp$3.parseExprSubscripts = function(refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseExprAtom(refDestructuringErrors) - var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")" - if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr - var result = this.parseSubscripts(expr, startPos, startLoc) + var startPos = this.start, startLoc = this.startLoc; + var expr = this.parseExprAtom(refDestructuringErrors); + var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")"; + if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) { return expr } + var result = this.parseSubscripts(expr, startPos, startLoc); if (refDestructuringErrors && result.type === "MemberExpression") { - if (refDestructuringErrors.parenthesizedAssign >= result.start) refDestructuringErrors.parenthesizedAssign = -1 - if (refDestructuringErrors.parenthesizedBind >= result.start) refDestructuringErrors.parenthesizedBind = -1 + if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } + if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; } } return result -} +}; pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { var this$1 = this; var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && - this.lastTokEnd == base.end && !this.canInsertSemicolon() - for (var computed;;) { - if ((computed = this$1.eat(tt.bracketL)) || this$1.eat(tt.dot)) { - var node = this$1.startNodeAt(startPos, startLoc) - node.object = base - node.property = computed ? this$1.parseExpression() : this$1.parseIdent(true) - node.computed = !!computed - if (computed) this$1.expect(tt.bracketR) - base = this$1.finishNode(node, "MemberExpression") - } else if (!noCalls && this$1.eat(tt.parenL)) { - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this$1.yieldPos, oldAwaitPos = this$1.awaitPos - this$1.yieldPos = 0 - this$1.awaitPos = 0 - var exprList = this$1.parseExprList(tt.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors) - if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(tt.arrow)) { - this$1.checkPatternErrors(refDestructuringErrors, false) - this$1.checkYieldAwaitInDefaultParams() - this$1.yieldPos = oldYieldPos - this$1.awaitPos = oldAwaitPos + this.lastTokEnd == base.end && !this.canInsertSemicolon(); + for (var computed = (void 0);;) { + if ((computed = this$1.eat(types.bracketL)) || this$1.eat(types.dot)) { + var node = this$1.startNodeAt(startPos, startLoc); + node.object = base; + node.property = computed ? this$1.parseExpression() : this$1.parseIdent(true); + node.computed = !!computed; + if (computed) { this$1.expect(types.bracketR); } + base = this$1.finishNode(node, "MemberExpression"); + } else if (!noCalls && this$1.eat(types.parenL)) { + var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this$1.yieldPos, oldAwaitPos = this$1.awaitPos; + this$1.yieldPos = 0; + this$1.awaitPos = 0; + var exprList = this$1.parseExprList(types.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors); + if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(types.arrow)) { + this$1.checkPatternErrors(refDestructuringErrors, false); + this$1.checkYieldAwaitInDefaultParams(); + this$1.yieldPos = oldYieldPos; + this$1.awaitPos = oldAwaitPos; return this$1.parseArrowExpression(this$1.startNodeAt(startPos, startLoc), exprList, true) } - this$1.checkExpressionErrors(refDestructuringErrors, true) - this$1.yieldPos = oldYieldPos || this$1.yieldPos - this$1.awaitPos = oldAwaitPos || this$1.awaitPos - var node$1 = this$1.startNodeAt(startPos, startLoc) - node$1.callee = base - node$1.arguments = exprList - base = this$1.finishNode(node$1, "CallExpression") - } else if (this$1.type === tt.backQuote) { - var node$2 = this$1.startNodeAt(startPos, startLoc) - node$2.tag = base - node$2.quasi = this$1.parseTemplate() - base = this$1.finishNode(node$2, "TaggedTemplateExpression") + this$1.checkExpressionErrors(refDestructuringErrors, true); + this$1.yieldPos = oldYieldPos || this$1.yieldPos; + this$1.awaitPos = oldAwaitPos || this$1.awaitPos; + var node$1 = this$1.startNodeAt(startPos, startLoc); + node$1.callee = base; + node$1.arguments = exprList; + base = this$1.finishNode(node$1, "CallExpression"); + } else if (this$1.type === types.backQuote) { + var node$2 = this$1.startNodeAt(startPos, startLoc); + node$2.tag = base; + node$2.quasi = this$1.parseTemplate({isTagged: true}); + base = this$1.finishNode(node$2, "TaggedTemplateExpression"); } else { return base } } -} +}; // Parse an atomic expression — either a single token that is an // expression, an expression started by a keyword like `function` or @@ -1980,178 +2006,178 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { // or `{}`. pp$3.parseExprAtom = function(refDestructuringErrors) { - var node, canBeArrow = this.potentialArrowAt == this.start + var node, canBeArrow = this.potentialArrowAt == this.start; switch (this.type) { - case tt._super: + case types._super: if (!this.inFunction) - this.raise(this.start, "'super' outside of function or class") + { this.raise(this.start, "'super' outside of function or class"); } - case tt._this: - var type = this.type === tt._this ? "ThisExpression" : "Super" - node = this.startNode() - this.next() + case types._this: + var type = this.type === types._this ? "ThisExpression" : "Super"; + node = this.startNode(); + this.next(); return this.finishNode(node, type) - case tt.name: - var startPos = this.start, startLoc = this.startLoc - var id = this.parseIdent(this.type !== tt.name) - if (this.options.ecmaVersion >= 8 && id.name === "async" && !this.canInsertSemicolon() && this.eat(tt._function)) - return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true) + case types.name: + var startPos = this.start, startLoc = this.startLoc; + var id = this.parseIdent(this.type !== types.name); + if (this.options.ecmaVersion >= 8 && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) + { return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true) } if (canBeArrow && !this.canInsertSemicolon()) { - if (this.eat(tt.arrow)) - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) - if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === tt.name) { - id = this.parseIdent() - if (this.canInsertSemicolon() || !this.eat(tt.arrow)) - this.unexpected() + if (this.eat(types.arrow)) + { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) } + if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name) { + id = this.parseIdent(); + if (this.canInsertSemicolon() || !this.eat(types.arrow)) + { this.unexpected(); } return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true) } } return id - case tt.regexp: - var value = this.value - node = this.parseLiteral(value.value) - node.regex = {pattern: value.pattern, flags: value.flags} + case types.regexp: + var value = this.value; + node = this.parseLiteral(value.value); + node.regex = {pattern: value.pattern, flags: value.flags}; return node - case tt.num: case tt.string: + case types.num: case types.string: return this.parseLiteral(this.value) - case tt._null: case tt._true: case tt._false: - node = this.startNode() - node.value = this.type === tt._null ? null : this.type === tt._true - node.raw = this.type.keyword - this.next() + case types._null: case types._true: case types._false: + node = this.startNode(); + node.value = this.type === types._null ? null : this.type === types._true; + node.raw = this.type.keyword; + this.next(); return this.finishNode(node, "Literal") - case tt.parenL: - var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow) + case types.parenL: + var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow); if (refDestructuringErrors) { if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) - refDestructuringErrors.parenthesizedAssign = start + { refDestructuringErrors.parenthesizedAssign = start; } if (refDestructuringErrors.parenthesizedBind < 0) - refDestructuringErrors.parenthesizedBind = start + { refDestructuringErrors.parenthesizedBind = start; } } return expr - case tt.bracketL: - node = this.startNode() - this.next() - node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors) + case types.bracketL: + node = this.startNode(); + this.next(); + node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors); return this.finishNode(node, "ArrayExpression") - case tt.braceL: + case types.braceL: return this.parseObj(false, refDestructuringErrors) - case tt._function: - node = this.startNode() - this.next() + case types._function: + node = this.startNode(); + this.next(); return this.parseFunction(node, false) - case tt._class: + case types._class: return this.parseClass(this.startNode(), false) - case tt._new: + case types._new: return this.parseNew() - case tt.backQuote: + case types.backQuote: return this.parseTemplate() default: - this.unexpected() + this.unexpected(); } -} +}; pp$3.parseLiteral = function(value) { - var node = this.startNode() - node.value = value - node.raw = this.input.slice(this.start, this.end) - this.next() + var node = this.startNode(); + node.value = value; + node.raw = this.input.slice(this.start, this.end); + this.next(); return this.finishNode(node, "Literal") -} +}; pp$3.parseParenExpression = function() { - this.expect(tt.parenL) - var val = this.parseExpression() - this.expect(tt.parenR) + this.expect(types.parenL); + var val = this.parseExpression(); + this.expect(types.parenR); return val -} +}; pp$3.parseParenAndDistinguishExpression = function(canBeArrow) { var this$1 = this; - var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8 + var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8; if (this.options.ecmaVersion >= 6) { - this.next() - - var innerStartPos = this.start, innerStartLoc = this.startLoc - var exprList = [], first = true, lastIsComma = false - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart, innerParenStart - this.yieldPos = 0 - this.awaitPos = 0 - while (this.type !== tt.parenR) { - first ? first = false : this$1.expect(tt.comma) - if (allowTrailingComma && this$1.afterTrailingComma(tt.parenR, true)) { - lastIsComma = true + this.next(); + + var innerStartPos = this.start, innerStartLoc = this.startLoc; + var exprList = [], first = true, lastIsComma = false; + var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart, innerParenStart; + this.yieldPos = 0; + this.awaitPos = 0; + while (this.type !== types.parenR) { + first ? first = false : this$1.expect(types.comma); + if (allowTrailingComma && this$1.afterTrailingComma(types.parenR, true)) { + lastIsComma = true; break - } else if (this$1.type === tt.ellipsis) { - spreadStart = this$1.start - exprList.push(this$1.parseParenItem(this$1.parseRest())) - if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element") + } else if (this$1.type === types.ellipsis) { + spreadStart = this$1.start; + exprList.push(this$1.parseParenItem(this$1.parseRestBinding())); + if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); } break } else { - if (this$1.type === tt.parenL && !innerParenStart) { - innerParenStart = this$1.start + if (this$1.type === types.parenL && !innerParenStart) { + innerParenStart = this$1.start; } - exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem)) + exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem)); } } - var innerEndPos = this.start, innerEndLoc = this.startLoc - this.expect(tt.parenR) - - if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) { - this.checkPatternErrors(refDestructuringErrors, false) - this.checkYieldAwaitInDefaultParams() - if (innerParenStart) this.unexpected(innerParenStart) - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos + var innerEndPos = this.start, innerEndLoc = this.startLoc; + this.expect(types.parenR); + + if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) { + this.checkPatternErrors(refDestructuringErrors, false); + this.checkYieldAwaitInDefaultParams(); + if (innerParenStart) { this.unexpected(innerParenStart); } + this.yieldPos = oldYieldPos; + this.awaitPos = oldAwaitPos; return this.parseParenArrowList(startPos, startLoc, exprList) } - if (!exprList.length || lastIsComma) this.unexpected(this.lastTokStart) - if (spreadStart) this.unexpected(spreadStart) - this.checkExpressionErrors(refDestructuringErrors, true) - this.yieldPos = oldYieldPos || this.yieldPos - this.awaitPos = oldAwaitPos || this.awaitPos + if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); } + if (spreadStart) { this.unexpected(spreadStart); } + this.checkExpressionErrors(refDestructuringErrors, true); + this.yieldPos = oldYieldPos || this.yieldPos; + this.awaitPos = oldAwaitPos || this.awaitPos; if (exprList.length > 1) { - val = this.startNodeAt(innerStartPos, innerStartLoc) - val.expressions = exprList - this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc) + val = this.startNodeAt(innerStartPos, innerStartLoc); + val.expressions = exprList; + this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); } else { - val = exprList[0] + val = exprList[0]; } } else { - val = this.parseParenExpression() + val = this.parseParenExpression(); } if (this.options.preserveParens) { - var par = this.startNodeAt(startPos, startLoc) - par.expression = val + var par = this.startNodeAt(startPos, startLoc); + par.expression = val; return this.finishNode(par, "ParenthesizedExpression") } else { return val } -} +}; pp$3.parseParenItem = function(item) { return item -} +}; pp$3.parseParenArrowList = function(startPos, startLoc, exprList) { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList) -} +}; // New's precedence is slightly tricky. It must allow its argument to // be a `[]` or dot subscript expression, but not a call — at least, @@ -2159,282 +2185,300 @@ pp$3.parseParenArrowList = function(startPos, startLoc, exprList) { // argument to parseSubscripts to prevent it from consuming the // argument list. -var empty$1 = [] +var empty$1 = []; pp$3.parseNew = function() { - var node = this.startNode() - var meta = this.parseIdent(true) - if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) { - node.meta = meta - node.property = this.parseIdent(true) + var node = this.startNode(); + var meta = this.parseIdent(true); + if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) { + node.meta = meta; + node.property = this.parseIdent(true); if (node.property.name !== "target") - this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target") + { this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); } if (!this.inFunction) - this.raiseRecoverable(node.start, "new.target can only be used in functions") + { this.raiseRecoverable(node.start, "new.target can only be used in functions"); } return this.finishNode(node, "MetaProperty") } - var startPos = this.start, startLoc = this.startLoc - node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true) - if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false) - else node.arguments = empty$1 + var startPos = this.start, startLoc = this.startLoc; + node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); + if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); } + else { node.arguments = empty$1; } return this.finishNode(node, "NewExpression") -} +}; // Parse template expression. -pp$3.parseTemplateElement = function() { - var elem = this.startNode() - elem.value = { - raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"), - cooked: this.value +pp$3.parseTemplateElement = function(ref) { + var isTagged = ref.isTagged; + + var elem = this.startNode(); + if (this.type === types.invalidTemplate) { + if (!isTagged) { + this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"); + } + elem.value = { + raw: this.value, + cooked: null + }; + } else { + elem.value = { + raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"), + cooked: this.value + }; } - this.next() - elem.tail = this.type === tt.backQuote + this.next(); + elem.tail = this.type === types.backQuote; return this.finishNode(elem, "TemplateElement") -} +}; -pp$3.parseTemplate = function() { +pp$3.parseTemplate = function(ref) { var this$1 = this; - - var node = this.startNode() - this.next() - node.expressions = [] - var curElt = this.parseTemplateElement() - node.quasis = [curElt] + if ( ref === void 0 ) ref = {}; + var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false; + + var node = this.startNode(); + this.next(); + node.expressions = []; + var curElt = this.parseTemplateElement({isTagged: isTagged}); + node.quasis = [curElt]; while (!curElt.tail) { - this$1.expect(tt.dollarBraceL) - node.expressions.push(this$1.parseExpression()) - this$1.expect(tt.braceR) - node.quasis.push(curElt = this$1.parseTemplateElement()) + this$1.expect(types.dollarBraceL); + node.expressions.push(this$1.parseExpression()); + this$1.expect(types.braceR); + node.quasis.push(curElt = this$1.parseTemplateElement({isTagged: isTagged})); } - this.next() + this.next(); return this.finishNode(node, "TemplateLiteral") -} +}; // Parse an object literal or binding pattern. +pp$3.isAsyncProp = function(prop) { + return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && + (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL) && + !lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) +}; + pp$3.parseObj = function(isPattern, refDestructuringErrors) { var this$1 = this; - var node = this.startNode(), first = true, propHash = {} - node.properties = [] - this.next() - while (!this.eat(tt.braceR)) { + var node = this.startNode(), first = true, propHash = {}; + node.properties = []; + this.next(); + while (!this.eat(types.braceR)) { if (!first) { - this$1.expect(tt.comma) - if (this$1.afterTrailingComma(tt.braceR)) break - } else first = false + this$1.expect(types.comma); + if (this$1.afterTrailingComma(types.braceR)) { break } + } else { first = false; } - var prop = this$1.startNode(), isGenerator, isAsync, startPos, startLoc + var prop = this$1.startNode(), isGenerator = (void 0), isAsync = (void 0), startPos = (void 0), startLoc = (void 0); if (this$1.options.ecmaVersion >= 6) { - prop.method = false - prop.shorthand = false + prop.method = false; + prop.shorthand = false; if (isPattern || refDestructuringErrors) { - startPos = this$1.start - startLoc = this$1.startLoc + startPos = this$1.start; + startLoc = this$1.startLoc; } if (!isPattern) - isGenerator = this$1.eat(tt.star) + { isGenerator = this$1.eat(types.star); } } - this$1.parsePropertyName(prop) - if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && !prop.computed && - prop.key.type === "Identifier" && prop.key.name === "async" && this$1.type !== tt.parenL && - this$1.type !== tt.colon && !this$1.canInsertSemicolon()) { - isAsync = true - this$1.parsePropertyName(prop, refDestructuringErrors) + this$1.parsePropertyName(prop); + if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && this$1.isAsyncProp(prop)) { + isAsync = true; + this$1.parsePropertyName(prop, refDestructuringErrors); } else { - isAsync = false + isAsync = false; } - this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) - this$1.checkPropClash(prop, propHash) - node.properties.push(this$1.finishNode(prop, "Property")) + this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors); + this$1.checkPropClash(prop, propHash); + node.properties.push(this$1.finishNode(prop, "Property")); } return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression") -} +}; pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) { - if ((isGenerator || isAsync) && this.type === tt.colon) - this.unexpected() - - if (this.eat(tt.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors) - prop.kind = "init" - } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) { - if (isPattern) this.unexpected() - prop.kind = "init" - prop.method = true - prop.value = this.parseMethod(isGenerator, isAsync) + if ((isGenerator || isAsync) && this.type === types.colon) + { this.unexpected(); } + + if (this.eat(types.colon)) { + prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors); + prop.kind = "init"; + } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) { + if (isPattern) { this.unexpected(); } + prop.kind = "init"; + prop.method = true; + prop.value = this.parseMethod(isGenerator, isAsync); } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && - (this.type != tt.comma && this.type != tt.braceR)) { - if (isGenerator || isAsync || isPattern) this.unexpected() - prop.kind = prop.key.name - this.parsePropertyName(prop) - prop.value = this.parseMethod(false) - var paramCount = prop.kind === "get" ? 0 : 1 + (this.type != types.comma && this.type != types.braceR)) { + if (isGenerator || isAsync || isPattern) { this.unexpected(); } + prop.kind = prop.key.name; + this.parsePropertyName(prop); + prop.value = this.parseMethod(false); + var paramCount = prop.kind === "get" ? 0 : 1; if (prop.value.params.length !== paramCount) { - var start = prop.value.start + var start = prop.value.start; if (prop.kind === "get") - this.raiseRecoverable(start, "getter should have no params") + { this.raiseRecoverable(start, "getter should have no params"); } else - this.raiseRecoverable(start, "setter should have exactly one param") + { this.raiseRecoverable(start, "setter should have exactly one param"); } } else { if (prop.kind === "set" && prop.value.params[0].type === "RestElement") - this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params") + { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); } } } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { - if (this.keywords.test(prop.key.name) || - (this.strict ? this.reservedWordsStrict : this.reservedWords).test(prop.key.name) || - (this.inGenerator && prop.key.name == "yield") || - (this.inAsync && prop.key.name == "await")) - this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property") - prop.kind = "init" + this.checkUnreserved(prop.key); + prop.kind = "init"; if (isPattern) { - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) - } else if (this.type === tt.eq && refDestructuringErrors) { + prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key); + } else if (this.type === types.eq && refDestructuringErrors) { if (refDestructuringErrors.shorthandAssign < 0) - refDestructuringErrors.shorthandAssign = this.start - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) + { refDestructuringErrors.shorthandAssign = this.start; } + prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key); } else { - prop.value = prop.key + prop.value = prop.key; } - prop.shorthand = true - } else this.unexpected() -} + prop.shorthand = true; + } else { this.unexpected(); } +}; pp$3.parsePropertyName = function(prop) { if (this.options.ecmaVersion >= 6) { - if (this.eat(tt.bracketL)) { - prop.computed = true - prop.key = this.parseMaybeAssign() - this.expect(tt.bracketR) + if (this.eat(types.bracketL)) { + prop.computed = true; + prop.key = this.parseMaybeAssign(); + this.expect(types.bracketR); return prop.key } else { - prop.computed = false + prop.computed = false; } } - return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true) -} + return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(true) +}; // Initialize empty function node. pp$3.initFunction = function(node) { - node.id = null + node.id = null; if (this.options.ecmaVersion >= 6) { - node.generator = false - node.expression = false + node.generator = false; + node.expression = false; } if (this.options.ecmaVersion >= 8) - node.async = false -} + { node.async = false; } +}; // Parse object or class method. pp$3.parseMethod = function(isGenerator, isAsync) { var node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync, - oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction + oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction; - this.initFunction(node) + this.initFunction(node); if (this.options.ecmaVersion >= 6) - node.generator = isGenerator + { node.generator = isGenerator; } if (this.options.ecmaVersion >= 8) - node.async = !!isAsync - - this.inGenerator = node.generator - this.inAsync = node.async - this.yieldPos = 0 - this.awaitPos = 0 - this.inFunction = true - this.enterFunctionScope() - - this.expect(tt.parenL) - node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8) - this.checkYieldAwaitInDefaultParams() - this.parseFunctionBody(node, false) - - this.inGenerator = oldInGen - this.inAsync = oldInAsync - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - this.inFunction = oldInFunc + { node.async = !!isAsync; } + + this.inGenerator = node.generator; + this.inAsync = node.async; + this.yieldPos = 0; + this.awaitPos = 0; + this.inFunction = true; + this.enterFunctionScope(); + + this.expect(types.parenL); + node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8); + this.checkYieldAwaitInDefaultParams(); + this.parseFunctionBody(node, false); + + this.inGenerator = oldInGen; + this.inAsync = oldInAsync; + this.yieldPos = oldYieldPos; + this.awaitPos = oldAwaitPos; + this.inFunction = oldInFunc; return this.finishNode(node, "FunctionExpression") -} +}; // Parse arrow function expression with given parameters. pp$3.parseArrowExpression = function(node, params, isAsync) { var oldInGen = this.inGenerator, oldInAsync = this.inAsync, - oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction + oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction; - this.enterFunctionScope() - this.initFunction(node) + this.enterFunctionScope(); + this.initFunction(node); if (this.options.ecmaVersion >= 8) - node.async = !!isAsync - - this.inGenerator = false - this.inAsync = node.async - this.yieldPos = 0 - this.awaitPos = 0 - this.inFunction = true - - node.params = this.toAssignableList(params, true) - this.parseFunctionBody(node, true) - - this.inGenerator = oldInGen - this.inAsync = oldInAsync - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - this.inFunction = oldInFunc + { node.async = !!isAsync; } + + this.inGenerator = false; + this.inAsync = node.async; + this.yieldPos = 0; + this.awaitPos = 0; + this.inFunction = true; + + node.params = this.toAssignableList(params, true); + this.parseFunctionBody(node, true); + + this.inGenerator = oldInGen; + this.inAsync = oldInAsync; + this.yieldPos = oldYieldPos; + this.awaitPos = oldAwaitPos; + this.inFunction = oldInFunc; return this.finishNode(node, "ArrowFunctionExpression") -} +}; // Parse function body and check parameters. pp$3.parseFunctionBody = function(node, isArrowFunction) { - var isExpression = isArrowFunction && this.type !== tt.braceL - var oldStrict = this.strict, useStrict = false + var isExpression = isArrowFunction && this.type !== types.braceL; + var oldStrict = this.strict, useStrict = false; if (isExpression) { - node.body = this.parseMaybeAssign() - node.expression = true - this.checkParams(node, false) + node.body = this.parseMaybeAssign(); + node.expression = true; + this.checkParams(node, false); } else { - var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params) + var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params); if (!oldStrict || nonSimple) { - useStrict = this.strictDirective(this.end) + useStrict = this.strictDirective(this.end); // If this is a strict mode function, verify that argument names // are not repeated, and it does not try to bind the words `eval` // or `arguments`. if (useStrict && nonSimple) - this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list") + { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); } } // Start a new scope with regard to labels and the `inFunction` // flag (restore them to their old value afterwards). - var oldLabels = this.labels - this.labels = [] - if (useStrict) this.strict = true + var oldLabels = this.labels; + this.labels = []; + if (useStrict) { this.strict = true; } // Add the params to varDeclaredNames to ensure that an error is thrown // if a let/const declaration in the function clashes with one of the params. - this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params)) - node.body = this.parseBlock(false) - node.expression = false - this.labels = oldLabels + this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params)); + node.body = this.parseBlock(false); + node.expression = false; + this.labels = oldLabels; } - this.exitFunctionScope() + this.exitFunctionScope(); if (this.strict && node.id) { // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - this.checkLVal(node.id, "none") + this.checkLVal(node.id, "none"); } - this.strict = oldStrict -} + this.strict = oldStrict; +}; pp$3.isSimpleParamList = function(params) { - for (var i = 0; i < params.length; i++) - if (params[i].type !== "Identifier") return false + for (var i = 0, list = params; i < list.length; i += 1) + { + var param = list[i]; + + if (param.type !== "Identifier") { return false + } } return true -} +}; // Checks function params for various disallowed patterns such as using "eval" // or "arguments" and duplicate parameters. @@ -2442,9 +2486,14 @@ pp$3.isSimpleParamList = function(params) { pp$3.checkParams = function(node, allowDuplicates) { var this$1 = this; - var nameHash = {} - for (var i = 0; i < node.params.length; i++) this$1.checkLVal(node.params[i], "var", allowDuplicates ? null : nameHash) -} + var nameHash = {}; + for (var i = 0, list = node.params; i < list.length; i += 1) + { + var param = list[i]; + + this$1.checkLVal(param, "var", allowDuplicates ? null : nameHash); + } +}; // Parses a comma-separated list of expressions, and returns them as // an array. `close` is the token type that ends the list, and @@ -2455,81 +2504,93 @@ pp$3.checkParams = function(node, allowDuplicates) { pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) { var this$1 = this; - var elts = [], first = true + var elts = [], first = true; while (!this.eat(close)) { if (!first) { - this$1.expect(tt.comma) - if (allowTrailingComma && this$1.afterTrailingComma(close)) break - } else first = false - - var elt - if (allowEmpty && this$1.type === tt.comma) - elt = null - else if (this$1.type === tt.ellipsis) { - elt = this$1.parseSpread(refDestructuringErrors) - if (refDestructuringErrors && this$1.type === tt.comma && refDestructuringErrors.trailingComma < 0) - refDestructuringErrors.trailingComma = this$1.start + this$1.expect(types.comma); + if (allowTrailingComma && this$1.afterTrailingComma(close)) { break } + } else { first = false; } + + var elt = (void 0); + if (allowEmpty && this$1.type === types.comma) + { elt = null; } + else if (this$1.type === types.ellipsis) { + elt = this$1.parseSpread(refDestructuringErrors); + if (refDestructuringErrors && this$1.type === types.comma && refDestructuringErrors.trailingComma < 0) + { refDestructuringErrors.trailingComma = this$1.start; } } else { - elt = this$1.parseMaybeAssign(false, refDestructuringErrors) + elt = this$1.parseMaybeAssign(false, refDestructuringErrors); } - elts.push(elt) + elts.push(elt); } return elts -} +}; // Parse the next token as an identifier. If `liberal` is true (used // when parsing properties), it will also convert keywords into // identifiers. -pp$3.parseIdent = function(liberal) { - var node = this.startNode() - if (liberal && this.options.allowReserved == "never") liberal = false - if (this.type === tt.name) { - if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) && - (this.options.ecmaVersion >= 6 || - this.input.slice(this.start, this.end).indexOf("\\") == -1)) - this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved") - if (this.inGenerator && this.value === "yield") - this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator") - if (this.inAsync && this.value === "await") - this.raiseRecoverable(this.start, "Can not use 'await' as identifier inside an async function") - node.name = this.value - } else if (liberal && this.type.keyword) { - node.name = this.type.keyword +pp$3.checkUnreserved = function(ref) { + var start = ref.start; + var end = ref.end; + var name = ref.name; + + if (this.inGenerator && name === "yield") + { this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator"); } + if (this.inAsync && name === "await") + { this.raiseRecoverable(start, "Can not use 'await' as identifier inside an async function"); } + if (this.isKeyword(name)) + { this.raise(start, ("Unexpected keyword '" + name + "'")); } + if (this.options.ecmaVersion < 6 && + this.input.slice(start, end).indexOf("\\") != -1) { return } + var re = this.strict ? this.reservedWordsStrict : this.reservedWords; + if (re.test(name)) + { this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); } +}; + +pp$3.parseIdent = function(liberal, isBinding) { + var node = this.startNode(); + if (liberal && this.options.allowReserved == "never") { liberal = false; } + if (this.type === types.name) { + node.name = this.value; + } else if (this.type.keyword) { + node.name = this.type.keyword; } else { - this.unexpected() + this.unexpected(); } - this.next() - return this.finishNode(node, "Identifier") -} + this.next(); + this.finishNode(node, "Identifier"); + if (!liberal) { this.checkUnreserved(node); } + return node +}; // Parses yield expression inside generator. pp$3.parseYield = function() { - if (!this.yieldPos) this.yieldPos = this.start + if (!this.yieldPos) { this.yieldPos = this.start; } - var node = this.startNode() - this.next() - if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) { - node.delegate = false - node.argument = null + var node = this.startNode(); + this.next(); + if (this.type == types.semi || this.canInsertSemicolon() || (this.type != types.star && !this.type.startsExpr)) { + node.delegate = false; + node.argument = null; } else { - node.delegate = this.eat(tt.star) - node.argument = this.parseMaybeAssign() + node.delegate = this.eat(types.star); + node.argument = this.parseMaybeAssign(); } return this.finishNode(node, "YieldExpression") -} +}; pp$3.parseAwait = function() { - if (!this.awaitPos) this.awaitPos = this.start + if (!this.awaitPos) { this.awaitPos = this.start; } - var node = this.startNode() - this.next() - node.argument = this.parseMaybeUnary(null, true) + var node = this.startNode(); + this.next(); + node.argument = this.parseMaybeUnary(null, true); return this.finishNode(node, "AwaitExpression") -} +}; -var pp$4 = Parser.prototype +var pp$4 = Parser.prototype; // This function is used to raise exceptions on parse errors. It // takes an offset integer (into the current `input`) to indicate @@ -2538,38 +2599,39 @@ var pp$4 = Parser.prototype // message. pp$4.raise = function(pos, message) { - var loc = getLineInfo(this.input, pos) - message += " (" + loc.line + ":" + loc.column + ")" - var err = new SyntaxError(message) - err.pos = pos; err.loc = loc; err.raisedAt = this.pos + var loc = getLineInfo(this.input, pos); + message += " (" + loc.line + ":" + loc.column + ")"; + var err = new SyntaxError(message); + err.pos = pos; err.loc = loc; err.raisedAt = this.pos; throw err -} +}; -pp$4.raiseRecoverable = pp$4.raise +pp$4.raiseRecoverable = pp$4.raise; pp$4.curPosition = function() { if (this.options.locations) { return new Position(this.curLine, this.pos - this.lineStart) } -} +}; -var pp$5 = Parser.prototype +var pp$5 = Parser.prototype; // Object.assign polyfill var assign = Object.assign || function(target) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - for (var i = 0; i < sources.length; i++) { - var source = sources[i] + for (var i = 0, list = sources; i < list.length; i += 1) { + var source = list[i]; + for (var key in source) { if (has(source, key)) { - target[key] = source[key] + target[key] = source[key]; } } } return target -} +}; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. @@ -2578,37 +2640,37 @@ pp$5.enterFunctionScope = function() { // lexical: a hash of lexically-declared names in the current lexical scope // childVar: a hash of var-declared names in all child lexical scopes of the current lexical scope (within the current function scope) // parentLexical: a hash of lexically-declared names in all parent lexical scopes of the current lexical scope (within the current function scope) - this.scopeStack.push({var: {}, lexical: {}, childVar: {}, parentLexical: {}}) -} + this.scopeStack.push({var: {}, lexical: {}, childVar: {}, parentLexical: {}}); +}; pp$5.exitFunctionScope = function() { - this.scopeStack.pop() -} + this.scopeStack.pop(); +}; pp$5.enterLexicalScope = function() { - var parentScope = this.scopeStack[this.scopeStack.length - 1] - var childScope = {var: {}, lexical: {}, childVar: {}, parentLexical: {}} + var parentScope = this.scopeStack[this.scopeStack.length - 1]; + var childScope = {var: {}, lexical: {}, childVar: {}, parentLexical: {}}; - this.scopeStack.push(childScope) - assign(childScope.parentLexical, parentScope.lexical, parentScope.parentLexical) -} + this.scopeStack.push(childScope); + assign(childScope.parentLexical, parentScope.lexical, parentScope.parentLexical); +}; pp$5.exitLexicalScope = function() { - var childScope = this.scopeStack.pop() - var parentScope = this.scopeStack[this.scopeStack.length - 1] + var childScope = this.scopeStack.pop(); + var parentScope = this.scopeStack[this.scopeStack.length - 1]; - assign(parentScope.childVar, childScope.var, childScope.childVar) -} + assign(parentScope.childVar, childScope.var, childScope.childVar); +}; /** * A name can be declared with `var` if there are no variables with the same name declared with `let`/`const` * in the current lexical scope or any of the parent lexical scopes in this function. */ pp$5.canDeclareVarName = function(name) { - var currentScope = this.scopeStack[this.scopeStack.length - 1] + var currentScope = this.scopeStack[this.scopeStack.length - 1]; return !has(currentScope.lexical, name) && !has(currentScope.parentLexical, name) -} +}; /** * A name can be declared with `let`/`const` if there are no variables with the same name declared with `let`/`const` @@ -2616,329 +2678,337 @@ pp$5.canDeclareVarName = function(name) { * any child lexical scopes in this function. */ pp$5.canDeclareLexicalName = function(name) { - var currentScope = this.scopeStack[this.scopeStack.length - 1] + var currentScope = this.scopeStack[this.scopeStack.length - 1]; return !has(currentScope.lexical, name) && !has(currentScope.var, name) && !has(currentScope.childVar, name) -} +}; pp$5.declareVarName = function(name) { - this.scopeStack[this.scopeStack.length - 1].var[name] = true -} + this.scopeStack[this.scopeStack.length - 1].var[name] = true; +}; pp$5.declareLexicalName = function(name) { - this.scopeStack[this.scopeStack.length - 1].lexical[name] = true -} + this.scopeStack[this.scopeStack.length - 1].lexical[name] = true; +}; var Node = function Node(parser, pos, loc) { - this.type = "" - this.start = pos - this.end = 0 + this.type = ""; + this.start = pos; + this.end = 0; if (parser.options.locations) - this.loc = new SourceLocation(parser, loc) + { this.loc = new SourceLocation(parser, loc); } if (parser.options.directSourceFile) - this.sourceFile = parser.options.directSourceFile + { this.sourceFile = parser.options.directSourceFile; } if (parser.options.ranges) - this.range = [pos, 0] + { this.range = [pos, 0]; } }; // Start an AST node, attaching a start offset. -var pp$6 = Parser.prototype +var pp$6 = Parser.prototype; pp$6.startNode = function() { return new Node(this, this.start, this.startLoc) -} +}; pp$6.startNodeAt = function(pos, loc) { return new Node(this, pos, loc) -} +}; // Finish an AST node, adding `type` and `end` properties. function finishNodeAt(node, type, pos, loc) { - node.type = type - node.end = pos + node.type = type; + node.end = pos; if (this.options.locations) - node.loc.end = loc + { node.loc.end = loc; } if (this.options.ranges) - node.range[1] = pos + { node.range[1] = pos; } return node } pp$6.finishNode = function(node, type) { return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc) -} +}; // Finish node at given position pp$6.finishNodeAt = function(node, type, pos, loc) { return finishNodeAt.call(this, node, type, pos, loc) -} +}; // The algorithm used to determine whether a regexp can appear at a // given point in the program is loosely based on sweet.js' approach. // See https://github.com/mozilla/sweet.js/wiki/design var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) { - this.token = token - this.isExpr = !!isExpr - this.preserveSpace = !!preserveSpace - this.override = override - this.generator = !!generator + this.token = token; + this.isExpr = !!isExpr; + this.preserveSpace = !!preserveSpace; + this.override = override; + this.generator = !!generator; }; -var types = { +var types$1 = { b_stat: new TokContext("{", false), b_expr: new TokContext("{", true), - b_tmpl: new TokContext("${", true), + b_tmpl: new TokContext("${", false), p_stat: new TokContext("(", false), p_expr: new TokContext("(", true), - q_tmpl: new TokContext("`", true, true, function (p) { return p.readTmplToken(); }), + q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }), + f_stat: new TokContext("function", false), f_expr: new TokContext("function", true), f_expr_gen: new TokContext("function", true, false, null, true), f_gen: new TokContext("function", false, false, null, true) -} +}; -var pp$7 = Parser.prototype +var pp$7 = Parser.prototype; pp$7.initialContext = function() { - return [types.b_stat] -} + return [types$1.b_stat] +}; pp$7.braceIsBlock = function(prevType) { - if (prevType === tt.colon) { - var parent = this.curContext() - if (parent === types.b_stat || parent === types.b_expr) - return !parent.isExpr - } - if (prevType === tt._return) - return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR || prevType == tt.arrow) - return true - if (prevType == tt.braceL) - return this.curContext() === types.b_stat + var parent = this.curContext(); + if (parent === types$1.f_expr || parent === types$1.f_stat) + { return true } + if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr)) + { return !parent.isExpr } + + // The check for `tt.name && exprAllowed` detects whether we are + // after a `yield` or `of` construct. See the `updateContext` for + // `tt.name`. + if (prevType === types._return || prevType == types.name && this.exprAllowed) + { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) } + if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType == types.arrow) + { return true } + if (prevType == types.braceL) + { return parent === types$1.b_stat } + if (prevType == types._var || prevType == types.name) + { return false } return !this.exprAllowed -} +}; pp$7.inGeneratorContext = function() { var this$1 = this; - for (var i = this.context.length - 1; i >= 0; i--) - if (this$1.context[i].generator) return true + for (var i = this.context.length - 1; i >= 1; i--) { + var context = this$1.context[i]; + if (context.token === "function") + { return context.generator } + } return false -} +}; pp$7.updateContext = function(prevType) { - var update, type = this.type - if (type.keyword && prevType == tt.dot) - this.exprAllowed = false + var update, type = this.type; + if (type.keyword && prevType == types.dot) + { this.exprAllowed = false; } else if (update = type.updateContext) - update.call(this, prevType) + { update.call(this, prevType); } else - this.exprAllowed = type.beforeExpr -} + { this.exprAllowed = type.beforeExpr; } +}; // Token-specific context update code -tt.parenR.updateContext = tt.braceR.updateContext = function() { +types.parenR.updateContext = types.braceR.updateContext = function() { if (this.context.length == 1) { - this.exprAllowed = true + this.exprAllowed = true; return } - var out = this.context.pop(), cur - if (out === types.b_stat && (cur = this.curContext()) && cur.token === "function") { - this.context.pop() - this.exprAllowed = false - } else if (out === types.b_tmpl) { - this.exprAllowed = true - } else { - this.exprAllowed = !out.isExpr + var out = this.context.pop(); + if (out === types$1.b_stat && this.curContext().token === "function") { + out = this.context.pop(); } -} + this.exprAllowed = !out.isExpr; +}; -tt.braceL.updateContext = function(prevType) { - this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr) - this.exprAllowed = true -} +types.braceL.updateContext = function(prevType) { + this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr); + this.exprAllowed = true; +}; -tt.dollarBraceL.updateContext = function() { - this.context.push(types.b_tmpl) - this.exprAllowed = true -} +types.dollarBraceL.updateContext = function() { + this.context.push(types$1.b_tmpl); + this.exprAllowed = true; +}; -tt.parenL.updateContext = function(prevType) { - var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while - this.context.push(statementParens ? types.p_stat : types.p_expr) - this.exprAllowed = true -} +types.parenL.updateContext = function(prevType) { + var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while; + this.context.push(statementParens ? types$1.p_stat : types$1.p_expr); + this.exprAllowed = true; +}; -tt.incDec.updateContext = function() { +types.incDec.updateContext = function() { // tokExprAllowed stays unchanged -} +}; -tt._function.updateContext = function(prevType) { - if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else && - !((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat)) - this.context.push(types.f_expr) - this.exprAllowed = false -} +types._function.updateContext = types._class.updateContext = function(prevType) { + if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && + !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) + { this.context.push(types$1.f_expr); } + else + { this.context.push(types$1.f_stat); } + this.exprAllowed = false; +}; -tt.backQuote.updateContext = function() { - if (this.curContext() === types.q_tmpl) - this.context.pop() +types.backQuote.updateContext = function() { + if (this.curContext() === types$1.q_tmpl) + { this.context.pop(); } else - this.context.push(types.q_tmpl) - this.exprAllowed = false -} + { this.context.push(types$1.q_tmpl); } + this.exprAllowed = false; +}; -tt.star.updateContext = function(prevType) { - if (prevType == tt._function) { - if (this.curContext() === types.f_expr) - this.context[this.context.length - 1] = types.f_expr_gen +types.star.updateContext = function(prevType) { + if (prevType == types._function) { + var index = this.context.length - 1; + if (this.context[index] === types$1.f_expr) + { this.context[index] = types$1.f_expr_gen; } else - this.context.push(types.f_gen) + { this.context[index] = types$1.f_gen; } } - this.exprAllowed = true -} + this.exprAllowed = true; +}; -tt.name.updateContext = function(prevType) { - var allowed = false +types.name.updateContext = function(prevType) { + var allowed = false; if (this.options.ecmaVersion >= 6) { if (this.value == "of" && !this.exprAllowed || this.value == "yield" && this.inGeneratorContext()) - allowed = true + { allowed = true; } } - this.exprAllowed = allowed -} + this.exprAllowed = allowed; +}; // Object type used to represent tokens. Note that normally, tokens // simply exist as properties on the parser object. This is only // used for the onToken callback and the external tokenizer. var Token = function Token(p) { - this.type = p.type - this.value = p.value - this.start = p.start - this.end = p.end + this.type = p.type; + this.value = p.value; + this.start = p.start; + this.end = p.end; if (p.options.locations) - this.loc = new SourceLocation(p, p.startLoc, p.endLoc) + { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); } if (p.options.ranges) - this.range = [p.start, p.end] + { this.range = [p.start, p.end]; } }; // ## Tokenizer -var pp$8 = Parser.prototype +var pp$8 = Parser.prototype; // Are we running under Rhino? -var isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]" +var isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]"; // Move to the next token pp$8.next = function() { if (this.options.onToken) - this.options.onToken(new Token(this)) + { this.options.onToken(new Token(this)); } - this.lastTokEnd = this.end - this.lastTokStart = this.start - this.lastTokEndLoc = this.endLoc - this.lastTokStartLoc = this.startLoc - this.nextToken() -} + this.lastTokEnd = this.end; + this.lastTokStart = this.start; + this.lastTokEndLoc = this.endLoc; + this.lastTokStartLoc = this.startLoc; + this.nextToken(); +}; pp$8.getToken = function() { - this.next() + this.next(); return new Token(this) -} +}; // If we're in an ES6 environment, make parsers iterable if (typeof Symbol !== "undefined") - pp$8[Symbol.iterator] = function() { + { pp$8[Symbol.iterator] = function() { var this$1 = this; return { next: function () { - var token = this$1.getToken() + var token = this$1.getToken(); return { - done: token.type === tt.eof, + done: token.type === types.eof, value: token } } } - } + }; } // Toggle strict mode. Re-reads the next number or string to please // pedantic tests (`"use strict"; 010;` should fail). pp$8.curContext = function() { return this.context[this.context.length - 1] -} +}; // Read a single token, updating the parser object's token-related // properties. pp$8.nextToken = function() { - var curContext = this.curContext() - if (!curContext || !curContext.preserveSpace) this.skipSpace() + var curContext = this.curContext(); + if (!curContext || !curContext.preserveSpace) { this.skipSpace(); } - this.start = this.pos - if (this.options.locations) this.startLoc = this.curPosition() - if (this.pos >= this.input.length) return this.finishToken(tt.eof) + this.start = this.pos; + if (this.options.locations) { this.startLoc = this.curPosition(); } + if (this.pos >= this.input.length) { return this.finishToken(types.eof) } - if (curContext.override) return curContext.override(this) - else this.readToken(this.fullCharCodeAtPos()) -} + if (curContext.override) { return curContext.override(this) } + else { this.readToken(this.fullCharCodeAtPos()); } +}; pp$8.readToken = function(code) { // Identifier or keyword. '\uXXXX' sequences are allowed in // identifiers, so '\' also dispatches to that. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) - return this.readWord() + { return this.readWord() } return this.getTokenFromCode(code) -} +}; pp$8.fullCharCodeAtPos = function() { - var code = this.input.charCodeAt(this.pos) - if (code <= 0xd7ff || code >= 0xe000) return code - var next = this.input.charCodeAt(this.pos + 1) + var code = this.input.charCodeAt(this.pos); + if (code <= 0xd7ff || code >= 0xe000) { return code } + var next = this.input.charCodeAt(this.pos + 1); return (code << 10) + next - 0x35fdc00 -} +}; pp$8.skipBlockComment = function() { var this$1 = this; - var startLoc = this.options.onComment && this.curPosition() - var start = this.pos, end = this.input.indexOf("*/", this.pos += 2) - if (end === -1) this.raise(this.pos - 2, "Unterminated comment") - this.pos = end + 2 + var startLoc = this.options.onComment && this.curPosition(); + var start = this.pos, end = this.input.indexOf("*/", this.pos += 2); + if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); } + this.pos = end + 2; if (this.options.locations) { - lineBreakG.lastIndex = start - var match + lineBreakG.lastIndex = start; + var match; while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) { - ++this$1.curLine - this$1.lineStart = match.index + match[0].length + ++this$1.curLine; + this$1.lineStart = match.index + match[0].length; } } if (this.options.onComment) - this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, - startLoc, this.curPosition()) -} + { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, + startLoc, this.curPosition()); } +}; pp$8.skipLineComment = function(startSkip) { var this$1 = this; - var start = this.pos - var startLoc = this.options.onComment && this.curPosition() - var ch = this.input.charCodeAt(this.pos += startSkip) - while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) { - ++this$1.pos - ch = this$1.input.charCodeAt(this$1.pos) + var start = this.pos; + var startLoc = this.options.onComment && this.curPosition(); + var ch = this.input.charCodeAt(this.pos += startSkip); + while (this.pos < this.input.length && !isNewLine(ch)) { + ch = this$1.input.charCodeAt(++this$1.pos); } if (this.options.onComment) - this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, - startLoc, this.curPosition()) -} + { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, + startLoc, this.curPosition()); } +}; // Called at the start of the parse and after every token. Skips // whitespace and comments, and. @@ -2947,29 +3017,29 @@ pp$8.skipSpace = function() { var this$1 = this; loop: while (this.pos < this.input.length) { - var ch = this$1.input.charCodeAt(this$1.pos) + var ch = this$1.input.charCodeAt(this$1.pos); switch (ch) { case 32: case 160: // ' ' - ++this$1.pos + ++this$1.pos; break case 13: if (this$1.input.charCodeAt(this$1.pos + 1) === 10) { - ++this$1.pos + ++this$1.pos; } case 10: case 8232: case 8233: - ++this$1.pos + ++this$1.pos; if (this$1.options.locations) { - ++this$1.curLine - this$1.lineStart = this$1.pos + ++this$1.curLine; + this$1.lineStart = this$1.pos; } break case 47: // '/' switch (this$1.input.charCodeAt(this$1.pos + 1)) { case 42: // '*' - this$1.skipBlockComment() + this$1.skipBlockComment(); break case 47: - this$1.skipLineComment(2) + this$1.skipLineComment(2); break default: break loop @@ -2977,13 +3047,13 @@ pp$8.skipSpace = function() { break default: if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { - ++this$1.pos + ++this$1.pos; } else { break loop } } } -} +}; // Called at the end of every token. Sets `end`, `val`, and // maintains `context` and `exprAllowed`, and skips the space after @@ -2991,14 +3061,14 @@ pp$8.skipSpace = function() { // right position. pp$8.finishToken = function(type, val) { - this.end = this.pos - if (this.options.locations) this.endLoc = this.curPosition() - var prevType = this.type - this.type = type - this.value = val + this.end = this.pos; + if (this.options.locations) { this.endLoc = this.curPosition(); } + var prevType = this.type; + this.type = type; + this.value = val; - this.updateContext(prevType) -} + this.updateContext(prevType); +}; // ### Token reading @@ -3010,99 +3080,99 @@ pp$8.finishToken = function(type, val) { // All in the name of speed. // pp$8.readToken_dot = function() { - var next = this.input.charCodeAt(this.pos + 1) - if (next >= 48 && next <= 57) return this.readNumber(true) - var next2 = this.input.charCodeAt(this.pos + 2) + var next = this.input.charCodeAt(this.pos + 1); + if (next >= 48 && next <= 57) { return this.readNumber(true) } + var next2 = this.input.charCodeAt(this.pos + 2); if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.' - this.pos += 3 - return this.finishToken(tt.ellipsis) + this.pos += 3; + return this.finishToken(types.ellipsis) } else { - ++this.pos - return this.finishToken(tt.dot) + ++this.pos; + return this.finishToken(types.dot) } -} +}; pp$8.readToken_slash = function() { // '/' - var next = this.input.charCodeAt(this.pos + 1) + var next = this.input.charCodeAt(this.pos + 1); if (this.exprAllowed) { ++this.pos; return this.readRegexp() } - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.slash, 1) -} + if (next === 61) { return this.finishOp(types.assign, 2) } + return this.finishOp(types.slash, 1) +}; pp$8.readToken_mult_modulo_exp = function(code) { // '%*' - var next = this.input.charCodeAt(this.pos + 1) - var size = 1 - var tokentype = code === 42 ? tt.star : tt.modulo + var next = this.input.charCodeAt(this.pos + 1); + var size = 1; + var tokentype = code === 42 ? types.star : types.modulo; // exponentiation operator ** and **= if (this.options.ecmaVersion >= 7 && next === 42) { - ++size - tokentype = tt.starstar - next = this.input.charCodeAt(this.pos + 2) + ++size; + tokentype = types.starstar; + next = this.input.charCodeAt(this.pos + 2); } - if (next === 61) return this.finishOp(tt.assign, size + 1) + if (next === 61) { return this.finishOp(types.assign, size + 1) } return this.finishOp(tokentype, size) -} +}; pp$8.readToken_pipe_amp = function(code) { // '|&' - var next = this.input.charCodeAt(this.pos + 1) - if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2) - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1) -} + var next = this.input.charCodeAt(this.pos + 1); + if (next === code) { return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2) } + if (next === 61) { return this.finishOp(types.assign, 2) } + return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1) +}; pp$8.readToken_caret = function() { // '^' - var next = this.input.charCodeAt(this.pos + 1) - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.bitwiseXOR, 1) -} + var next = this.input.charCodeAt(this.pos + 1); + if (next === 61) { return this.finishOp(types.assign, 2) } + return this.finishOp(types.bitwiseXOR, 1) +}; pp$8.readToken_plus_min = function(code) { // '+-' - var next = this.input.charCodeAt(this.pos + 1) + var next = this.input.charCodeAt(this.pos + 1); if (next === code) { if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && - lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) { + (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) { // A `-->` line comment - this.skipLineComment(3) - this.skipSpace() + this.skipLineComment(3); + this.skipSpace(); return this.nextToken() } - return this.finishOp(tt.incDec, 2) + return this.finishOp(types.incDec, 2) } - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.plusMin, 1) -} + if (next === 61) { return this.finishOp(types.assign, 2) } + return this.finishOp(types.plusMin, 1) +}; pp$8.readToken_lt_gt = function(code) { // '<>' - var next = this.input.charCodeAt(this.pos + 1) - var size = 1 + var next = this.input.charCodeAt(this.pos + 1); + var size = 1; if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2 - if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1) - return this.finishOp(tt.bitShift, size) + size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2; + if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) } + return this.finishOp(types.bitShift, size) } if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) { - if (this.inModule) this.unexpected() + if (this.inModule) { this.unexpected(); } // `` line comment - this.skipLineComment(3) - this.skipSpace() + this.skipLineComment(3); + this.skipSpace(); return this.nextToken() } - return this.finishOp(tt.incDec, 2) + return this.finishOp(types.incDec, 2) } - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.plusMin, 1) -} + if (next === 61) { return this.finishOp(types.assign, 2) } + return this.finishOp(types.plusMin, 1) +}; pp$8.readToken_lt_gt = function(code) { // '<>' - var next = this.input.charCodeAt(this.pos + 1) - var size = 1 + var next = this.input.charCodeAt(this.pos + 1); + var size = 1; if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2 - if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1) - return this.finishOp(tt.bitShift, size) + size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2; + if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) } + return this.finishOp(types.bitShift, size) } if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) { - if (this.inModule) this.unexpected() + if (this.inModule) { this.unexpected(); } // `` line comment - this.skipLineComment(3) - this.skipSpace() - return this.nextToken() - } - return this.finishOp(tt.incDec, 2) - } - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.plusMin, 1) -} - -pp.readToken_lt_gt = function(code) { // '<>' - let next = this.input.charCodeAt(this.pos + 1) - let size = 1 - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2 - if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1) - return this.finishOp(tt.bitShift, size) - } - if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && - this.input.charCodeAt(this.pos + 3) == 45) { - if (this.inModule) this.unexpected() - // ` - - - -1.0.1 / 2016-07-23 -================== - -* Rewrite module ([`75e6d41`](https://github.com/wooorm/bail/commit/75e6d41)) -* Update dev-dependencies ([`9ec98f9`](https://github.com/wooorm/bail/commit/9ec98f9)) - -1.0.0 / 2015-07-28 -================== diff --git a/tools/eslint/node_modules/bail/index.js b/tools/eslint/node_modules/bail/index.js index 7772d5634feccf..f5842e2590e48b 100644 --- a/tools/eslint/node_modules/bail/index.js +++ b/tools/eslint/node_modules/bail/index.js @@ -1,32 +1,7 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module bail - * @fileoverview Throw a given error. - */ - 'use strict'; -/* Expose. */ module.exports = bail; -/** - * Throw a given error. - * - * @example - * bail(); - * - * @example - * bail(new Error('failure')); - * // Error: failure - * // at repl:1:6 - * // at REPLServer.defaultEval (repl.js:154:27) - * // ... - * - * @param {Error?} [err] - Optional error. - * @throws {Error} - `err`, when given. - */ function bail(err) { if (err) { throw err; diff --git a/tools/eslint/node_modules/bail/package.json b/tools/eslint/node_modules/bail/package.json index 244f4c5082c4ec..1d9d614c9a4dcf 100644 --- a/tools/eslint/node_modules/bail/package.json +++ b/tools/eslint/node_modules/bail/package.json @@ -1,8 +1,8 @@ { "_from": "bail@^1.0.0", - "_id": "bail@1.0.1", + "_id": "bail@1.0.2", "_inBundle": false, - "_integrity": "sha1-kSV53os5Gq3zxf30zSoPwiXfO8I=", + "_integrity": "sha1-99bBcxYwqfnw1NNe0fli4gdKF2Q=", "_location": "/bail", "_phantomChildren": {}, "_requested": { @@ -18,8 +18,8 @@ "_requiredBy": [ "/unified" ], - "_resolved": "https://registry.npmjs.org/bail/-/bail-1.0.1.tgz", - "_shasum": "912579de8b391aadf3c5fdf4cd2a0fc225df3bc2", + "_resolved": "https://registry.npmjs.org/bail/-/bail-1.0.2.tgz", + "_shasum": "f7d6c1731630a9f9f0d4d35ed1f962e2074a1764", "_spec": "bail@^1.0.0", "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/unified", "author": { @@ -42,16 +42,13 @@ "deprecated": false, "description": "Throw a given error", "devDependencies": { - "browserify": "^13.0.1", + "browserify": "^14.0.0", "esmangle": "^1.0.1", - "nyc": "^7.0.0", - "remark-cli": "^1.0.0", - "remark-comment-config": "^4.0.0", - "remark-github": "^5.0.0", - "remark-lint": "^4.0.0", - "remark-validate-links": "^4.0.0", + "nyc": "^11.0.0", + "remark-cli": "^3.0.0", + "remark-preset-wooorm": "^3.0.0", "tape": "^4.0.0", - "xo": "^0.16.0" + "xo": "^0.18.0" }, "files": [ "index.js" @@ -66,17 +63,16 @@ ], "license": "MIT", "name": "bail", + "nyc": { + "check-coverage": true, + "lines": 100, + "functions": 100, + "branches": 100 + }, "remarkConfig": { - "output": true, "plugins": [ - "comment-config", - "github", - "lint", - "validate-links" - ], - "settings": { - "bullet": "*" - } + "preset-wooorm" + ] }, "repository": { "type": "git", @@ -86,18 +82,18 @@ "build": "npm run build-md && npm run build-bundle && npm run build-mangle", "build-bundle": "browserify index.js --bare -s bail > bail.js", "build-mangle": "esmangle bail.js > bail.min.js", - "build-md": "remark . --quiet --frail", + "build-md": "remark . -qfo", "lint": "xo", "test": "npm run build && npm run lint && npm run test-coverage", "test-api": "node test", "test-coverage": "nyc --reporter lcov tape test.js" }, - "version": "1.0.1", + "version": "1.0.2", "xo": { "space": true, + "esnext": false, "ignores": [ - "bail.js", - "bail.min.js" + "bail.js" ] } } diff --git a/tools/eslint/node_modules/bail/readme.md b/tools/eslint/node_modules/bail/readme.md index b35158cd735f64..a5ca45d0f09130 100644 --- a/tools/eslint/node_modules/bail/readme.md +++ b/tools/eslint/node_modules/bail/readme.md @@ -1,7 +1,5 @@ # bail [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] - - :warning: Throw a given error. ## Installation @@ -42,9 +40,9 @@ Throw a given error. ## Related -* [`noop`][noop]; -* [`noop2`][noop2]; -* [`noop3`][noop3]; +* [`noop`][noop] +* [`noop2`][noop2] +* [`noop3`][noop3] ## License diff --git a/tools/eslint/node_modules/chalk/package.json b/tools/eslint/node_modules/chalk/package.json index d39cc17864619f..9993ee8a22df90 100644 --- a/tools/eslint/node_modules/chalk/package.json +++ b/tools/eslint/node_modules/chalk/package.json @@ -18,7 +18,6 @@ "_requiredBy": [ "/eslint", "/eslint/babel-code-frame", - "/eslint/inquirer", "/eslint/table" ], "_resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", diff --git a/tools/eslint/node_modules/character-entities-legacy/package.json b/tools/eslint/node_modules/character-entities-legacy/package.json index 23c7ff9011a550..902e5f63842ae1 100644 --- a/tools/eslint/node_modules/character-entities-legacy/package.json +++ b/tools/eslint/node_modules/character-entities-legacy/package.json @@ -16,8 +16,7 @@ "fetchSpec": "^1.0.0" }, "_requiredBy": [ - "/parse-entities", - "/stringify-entities" + "/parse-entities" ], "_resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.0.tgz", "_shasum": "b18aad98f6b7bcc646c1e4c81f9f1956376a561a", diff --git a/tools/eslint/node_modules/co/package.json b/tools/eslint/node_modules/co/package.json index df96c6ef90a86d..422645a1f49a5e 100644 --- a/tools/eslint/node_modules/co/package.json +++ b/tools/eslint/node_modules/co/package.json @@ -16,7 +16,8 @@ "fetchSpec": "^4.6.0" }, "_requiredBy": [ - "/eslint/ajv" + "/eslint/ajv", + "/eslint/table/ajv" ], "_resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "_shasum": "6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184", diff --git a/tools/eslint/node_modules/collapse-white-space/package.json b/tools/eslint/node_modules/collapse-white-space/package.json index 988384fb1efaab..014e8e6556f941 100644 --- a/tools/eslint/node_modules/collapse-white-space/package.json +++ b/tools/eslint/node_modules/collapse-white-space/package.json @@ -1,5 +1,5 @@ { - "_from": "collapse-white-space@^1.0.0", + "_from": "collapse-white-space@^1.0.2", "_id": "collapse-white-space@1.0.3", "_inBundle": false, "_integrity": "sha1-S5BvZw5aljqHt2sOFolkM0G2Ajw=", @@ -8,19 +8,19 @@ "_requested": { "type": "range", "registry": true, - "raw": "collapse-white-space@^1.0.0", + "raw": "collapse-white-space@^1.0.2", "name": "collapse-white-space", "escapedName": "collapse-white-space", - "rawSpec": "^1.0.0", + "rawSpec": "^1.0.2", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "^1.0.2" }, "_requiredBy": [ "/remark-parse" ], "_resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.3.tgz", "_shasum": "4b906f670e5a963a87b76b0e1689643341b6023c", - "_spec": "collapse-white-space@^1.0.0", + "_spec": "collapse-white-space@^1.0.2", "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/remark-parse", "author": { "name": "Titus Wormer", diff --git a/tools/eslint/node_modules/color-convert/LICENSE b/tools/eslint/node_modules/color-convert/LICENSE new file mode 100644 index 00000000000000..5b4c386f9269b3 --- /dev/null +++ b/tools/eslint/node_modules/color-convert/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2011-2016 Heather Arthur + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/tools/eslint/node_modules/color-convert/README.md b/tools/eslint/node_modules/color-convert/README.md new file mode 100644 index 00000000000000..d4b08fc369948d --- /dev/null +++ b/tools/eslint/node_modules/color-convert/README.md @@ -0,0 +1,68 @@ +# color-convert + +[![Build Status](https://travis-ci.org/Qix-/color-convert.svg?branch=master)](https://travis-ci.org/Qix-/color-convert) + +Color-convert is a color conversion library for JavaScript and node. +It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest): + +```js +var convert = require('color-convert'); + +convert.rgb.hsl(140, 200, 100); // [96, 48, 59] +convert.keyword.rgb('blue'); // [0, 0, 255] + +var rgbChannels = convert.rgb.channels; // 3 +var cmykChannels = convert.cmyk.channels; // 4 +var ansiChannels = convert.ansi16.channels; // 1 +``` + +# Install + +```console +$ npm install color-convert +``` + +# API + +Simply get the property of the _from_ and _to_ conversion that you're looking for. + +All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function. + +All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha). + +```js +var convert = require('color-convert'); + +// Hex to LAB +convert.hex.lab('DEADBF'); // [ 76, 21, -2 ] +convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ] + +// RGB to CMYK +convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ] +convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ] +``` + +### Arrays +All functions that accept multiple arguments also support passing an array. + +Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.) + +```js +var convert = require('color-convert'); + +convert.rgb.hex(123, 45, 67); // '7B2D43' +convert.rgb.hex([123, 45, 67]); // '7B2D43' +``` + +## Routing + +Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex). + +Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js). + +# Contribute + +If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request. + +# License +Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE). diff --git a/tools/eslint/node_modules/color-convert/conversions.js b/tools/eslint/node_modules/color-convert/conversions.js new file mode 100644 index 00000000000000..19ca4a9bf5aabb --- /dev/null +++ b/tools/eslint/node_modules/color-convert/conversions.js @@ -0,0 +1,861 @@ +/* MIT license */ +var cssKeywords = require('color-name'); + +// NOTE: conversions should only return primitive values (i.e. arrays, or +// values that give correct `typeof` results). +// do not use box values types (i.e. Number(), String(), etc.) + +var reverseKeywords = {}; +for (var key in cssKeywords) { + if (cssKeywords.hasOwnProperty(key)) { + reverseKeywords[cssKeywords[key]] = key; + } +} + +var convert = module.exports = { + rgb: {channels: 3, labels: 'rgb'}, + hsl: {channels: 3, labels: 'hsl'}, + hsv: {channels: 3, labels: 'hsv'}, + hwb: {channels: 3, labels: 'hwb'}, + cmyk: {channels: 4, labels: 'cmyk'}, + xyz: {channels: 3, labels: 'xyz'}, + lab: {channels: 3, labels: 'lab'}, + lch: {channels: 3, labels: 'lch'}, + hex: {channels: 1, labels: ['hex']}, + keyword: {channels: 1, labels: ['keyword']}, + ansi16: {channels: 1, labels: ['ansi16']}, + ansi256: {channels: 1, labels: ['ansi256']}, + hcg: {channels: 3, labels: ['h', 'c', 'g']}, + apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, + gray: {channels: 1, labels: ['gray']} +}; + +// hide .channels and .labels properties +for (var model in convert) { + if (convert.hasOwnProperty(model)) { + if (!('channels' in convert[model])) { + throw new Error('missing channels property: ' + model); + } + + if (!('labels' in convert[model])) { + throw new Error('missing channel labels property: ' + model); + } + + if (convert[model].labels.length !== convert[model].channels) { + throw new Error('channel and label counts mismatch: ' + model); + } + + var channels = convert[model].channels; + var labels = convert[model].labels; + delete convert[model].channels; + delete convert[model].labels; + Object.defineProperty(convert[model], 'channels', {value: channels}); + Object.defineProperty(convert[model], 'labels', {value: labels}); + } +} + +convert.rgb.hsl = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var delta = max - min; + var h; + var s; + var l; + + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } + + h = Math.min(h * 60, 360); + + if (h < 0) { + h += 360; + } + + l = (min + max) / 2; + + if (max === min) { + s = 0; + } else if (l <= 0.5) { + s = delta / (max + min); + } else { + s = delta / (2 - max - min); + } + + return [h, s * 100, l * 100]; +}; + +convert.rgb.hsv = function (rgb) { + var r = rgb[0]; + var g = rgb[1]; + var b = rgb[2]; + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var delta = max - min; + var h; + var s; + var v; + + if (max === 0) { + s = 0; + } else { + s = (delta / max * 1000) / 10; + } + + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } + + h = Math.min(h * 60, 360); + + if (h < 0) { + h += 360; + } + + v = ((max / 255) * 1000) / 10; + + return [h, s, v]; +}; + +convert.rgb.hwb = function (rgb) { + var r = rgb[0]; + var g = rgb[1]; + var b = rgb[2]; + var h = convert.rgb.hsl(rgb)[0]; + var w = 1 / 255 * Math.min(r, Math.min(g, b)); + + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); + + return [h, w * 100, b * 100]; +}; + +convert.rgb.cmyk = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var c; + var m; + var y; + var k; + + k = Math.min(1 - r, 1 - g, 1 - b); + c = (1 - r - k) / (1 - k) || 0; + m = (1 - g - k) / (1 - k) || 0; + y = (1 - b - k) / (1 - k) || 0; + + return [c * 100, m * 100, y * 100, k * 100]; +}; + +/** + * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance + * */ +function comparativeDistance(x, y) { + return ( + Math.pow(x[0] - y[0], 2) + + Math.pow(x[1] - y[1], 2) + + Math.pow(x[2] - y[2], 2) + ); +} + +convert.rgb.keyword = function (rgb) { + var reversed = reverseKeywords[rgb]; + if (reversed) { + return reversed; + } + + var currentClosestDistance = Infinity; + var currentClosestKeyword; + + for (var keyword in cssKeywords) { + if (cssKeywords.hasOwnProperty(keyword)) { + var value = cssKeywords[keyword]; + + // Compute comparative distance + var distance = comparativeDistance(rgb, value); + + // Check if its less, if so set as closest + if (distance < currentClosestDistance) { + currentClosestDistance = distance; + currentClosestKeyword = keyword; + } + } + } + + return currentClosestKeyword; +}; + +convert.keyword.rgb = function (keyword) { + return cssKeywords[keyword]; +}; + +convert.rgb.xyz = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + + // assume sRGB + r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); + g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); + b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); + + var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); + var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); + var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); + + return [x * 100, y * 100, z * 100]; +}; + +convert.rgb.lab = function (rgb) { + var xyz = convert.rgb.xyz(rgb); + var x = xyz[0]; + var y = xyz[1]; + var z = xyz[2]; + var l; + var a; + var b; + + x /= 95.047; + y /= 100; + z /= 108.883; + + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); + + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); + + return [l, a, b]; +}; + +convert.hsl.rgb = function (hsl) { + var h = hsl[0] / 360; + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var t1; + var t2; + var t3; + var rgb; + var val; + + if (s === 0) { + val = l * 255; + return [val, val, val]; + } + + if (l < 0.5) { + t2 = l * (1 + s); + } else { + t2 = l + s - l * s; + } + + t1 = 2 * l - t2; + + rgb = [0, 0, 0]; + for (var i = 0; i < 3; i++) { + t3 = h + 1 / 3 * -(i - 1); + if (t3 < 0) { + t3++; + } + if (t3 > 1) { + t3--; + } + + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3; + } else if (2 * t3 < 1) { + val = t2; + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + } else { + val = t1; + } + + rgb[i] = val * 255; + } + + return rgb; +}; + +convert.hsl.hsv = function (hsl) { + var h = hsl[0]; + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var smin = s; + var lmin = Math.max(l, 0.01); + var sv; + var v; + + l *= 2; + s *= (l <= 1) ? l : 2 - l; + smin *= lmin <= 1 ? lmin : 2 - lmin; + v = (l + s) / 2; + sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); + + return [h, sv * 100, v * 100]; +}; + +convert.hsv.rgb = function (hsv) { + var h = hsv[0] / 60; + var s = hsv[1] / 100; + var v = hsv[2] / 100; + var hi = Math.floor(h) % 6; + + var f = h - Math.floor(h); + var p = 255 * v * (1 - s); + var q = 255 * v * (1 - (s * f)); + var t = 255 * v * (1 - (s * (1 - f))); + v *= 255; + + switch (hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; + } +}; + +convert.hsv.hsl = function (hsv) { + var h = hsv[0]; + var s = hsv[1] / 100; + var v = hsv[2] / 100; + var vmin = Math.max(v, 0.01); + var lmin; + var sl; + var l; + + l = (2 - s) * v; + lmin = (2 - s) * vmin; + sl = s * vmin; + sl /= (lmin <= 1) ? lmin : 2 - lmin; + sl = sl || 0; + l /= 2; + + return [h, sl * 100, l * 100]; +}; + +// http://dev.w3.org/csswg/css-color/#hwb-to-rgb +convert.hwb.rgb = function (hwb) { + var h = hwb[0] / 360; + var wh = hwb[1] / 100; + var bl = hwb[2] / 100; + var ratio = wh + bl; + var i; + var v; + var f; + var n; + + // wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio; + bl /= ratio; + } + + i = Math.floor(6 * h); + v = 1 - bl; + f = 6 * h - i; + + if ((i & 0x01) !== 0) { + f = 1 - f; + } + + n = wh + f * (v - wh); // linear interpolation + + var r; + var g; + var b; + switch (i) { + default: + case 6: + case 0: r = v; g = n; b = wh; break; + case 1: r = n; g = v; b = wh; break; + case 2: r = wh; g = v; b = n; break; + case 3: r = wh; g = n; b = v; break; + case 4: r = n; g = wh; b = v; break; + case 5: r = v; g = wh; b = n; break; + } + + return [r * 255, g * 255, b * 255]; +}; + +convert.cmyk.rgb = function (cmyk) { + var c = cmyk[0] / 100; + var m = cmyk[1] / 100; + var y = cmyk[2] / 100; + var k = cmyk[3] / 100; + var r; + var g; + var b; + + r = 1 - Math.min(1, c * (1 - k) + k); + g = 1 - Math.min(1, m * (1 - k) + k); + b = 1 - Math.min(1, y * (1 - k) + k); + + return [r * 255, g * 255, b * 255]; +}; + +convert.xyz.rgb = function (xyz) { + var x = xyz[0] / 100; + var y = xyz[1] / 100; + var z = xyz[2] / 100; + var r; + var g; + var b; + + r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); + g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); + b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); + + // assume sRGB + r = r > 0.0031308 + ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) + : r * 12.92; + + g = g > 0.0031308 + ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) + : g * 12.92; + + b = b > 0.0031308 + ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) + : b * 12.92; + + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); + + return [r * 255, g * 255, b * 255]; +}; + +convert.xyz.lab = function (xyz) { + var x = xyz[0]; + var y = xyz[1]; + var z = xyz[2]; + var l; + var a; + var b; + + x /= 95.047; + y /= 100; + z /= 108.883; + + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); + + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); + + return [l, a, b]; +}; + +convert.lab.xyz = function (lab) { + var l = lab[0]; + var a = lab[1]; + var b = lab[2]; + var x; + var y; + var z; + + y = (l + 16) / 116; + x = a / 500 + y; + z = y - b / 200; + + var y2 = Math.pow(y, 3); + var x2 = Math.pow(x, 3); + var z2 = Math.pow(z, 3); + y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; + x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; + z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; + + x *= 95.047; + y *= 100; + z *= 108.883; + + return [x, y, z]; +}; + +convert.lab.lch = function (lab) { + var l = lab[0]; + var a = lab[1]; + var b = lab[2]; + var hr; + var h; + var c; + + hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; + + if (h < 0) { + h += 360; + } + + c = Math.sqrt(a * a + b * b); + + return [l, c, h]; +}; + +convert.lch.lab = function (lch) { + var l = lch[0]; + var c = lch[1]; + var h = lch[2]; + var a; + var b; + var hr; + + hr = h / 360 * 2 * Math.PI; + a = c * Math.cos(hr); + b = c * Math.sin(hr); + + return [l, a, b]; +}; + +convert.rgb.ansi16 = function (args) { + var r = args[0]; + var g = args[1]; + var b = args[2]; + var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization + + value = Math.round(value / 50); + + if (value === 0) { + return 30; + } + + var ansi = 30 + + ((Math.round(b / 255) << 2) + | (Math.round(g / 255) << 1) + | Math.round(r / 255)); + + if (value === 2) { + ansi += 60; + } + + return ansi; +}; + +convert.hsv.ansi16 = function (args) { + // optimization here; we already know the value and don't need to get + // it converted for us. + return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); +}; + +convert.rgb.ansi256 = function (args) { + var r = args[0]; + var g = args[1]; + var b = args[2]; + + // we use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r === g && g === b) { + if (r < 8) { + return 16; + } + + if (r > 248) { + return 231; + } + + return Math.round(((r - 8) / 247) * 24) + 232; + } + + var ansi = 16 + + (36 * Math.round(r / 255 * 5)) + + (6 * Math.round(g / 255 * 5)) + + Math.round(b / 255 * 5); + + return ansi; +}; + +convert.ansi16.rgb = function (args) { + var color = args % 10; + + // handle greyscale + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5; + } + + color = color / 10.5 * 255; + + return [color, color, color]; + } + + var mult = (~~(args > 50) + 1) * 0.5; + var r = ((color & 1) * mult) * 255; + var g = (((color >> 1) & 1) * mult) * 255; + var b = (((color >> 2) & 1) * mult) * 255; + + return [r, g, b]; +}; + +convert.ansi256.rgb = function (args) { + // handle greyscale + if (args >= 232) { + var c = (args - 232) * 10 + 8; + return [c, c, c]; + } + + args -= 16; + + var rem; + var r = Math.floor(args / 36) / 5 * 255; + var g = Math.floor((rem = args % 36) / 6) / 5 * 255; + var b = (rem % 6) / 5 * 255; + + return [r, g, b]; +}; + +convert.rgb.hex = function (args) { + var integer = ((Math.round(args[0]) & 0xFF) << 16) + + ((Math.round(args[1]) & 0xFF) << 8) + + (Math.round(args[2]) & 0xFF); + + var string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; + +convert.hex.rgb = function (args) { + var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); + if (!match) { + return [0, 0, 0]; + } + + var colorString = match[0]; + + if (match[0].length === 3) { + colorString = colorString.split('').map(function (char) { + return char + char; + }).join(''); + } + + var integer = parseInt(colorString, 16); + var r = (integer >> 16) & 0xFF; + var g = (integer >> 8) & 0xFF; + var b = integer & 0xFF; + + return [r, g, b]; +}; + +convert.rgb.hcg = function (rgb) { + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var max = Math.max(Math.max(r, g), b); + var min = Math.min(Math.min(r, g), b); + var chroma = (max - min); + var grayscale; + var hue; + + if (chroma < 1) { + grayscale = min / (1 - chroma); + } else { + grayscale = 0; + } + + if (chroma <= 0) { + hue = 0; + } else + if (max === r) { + hue = ((g - b) / chroma) % 6; + } else + if (max === g) { + hue = 2 + (b - r) / chroma; + } else { + hue = 4 + (r - g) / chroma + 4; + } + + hue /= 6; + hue %= 1; + + return [hue * 360, chroma * 100, grayscale * 100]; +}; + +convert.hsl.hcg = function (hsl) { + var s = hsl[1] / 100; + var l = hsl[2] / 100; + var c = 1; + var f = 0; + + if (l < 0.5) { + c = 2.0 * s * l; + } else { + c = 2.0 * s * (1.0 - l); + } + + if (c < 1.0) { + f = (l - 0.5 * c) / (1.0 - c); + } + + return [hsl[0], c * 100, f * 100]; +}; + +convert.hsv.hcg = function (hsv) { + var s = hsv[1] / 100; + var v = hsv[2] / 100; + + var c = s * v; + var f = 0; + + if (c < 1.0) { + f = (v - c) / (1 - c); + } + + return [hsv[0], c * 100, f * 100]; +}; + +convert.hcg.rgb = function (hcg) { + var h = hcg[0] / 360; + var c = hcg[1] / 100; + var g = hcg[2] / 100; + + if (c === 0.0) { + return [g * 255, g * 255, g * 255]; + } + + var pure = [0, 0, 0]; + var hi = (h % 1) * 6; + var v = hi % 1; + var w = 1 - v; + var mg = 0; + + switch (Math.floor(hi)) { + case 0: + pure[0] = 1; pure[1] = v; pure[2] = 0; break; + case 1: + pure[0] = w; pure[1] = 1; pure[2] = 0; break; + case 2: + pure[0] = 0; pure[1] = 1; pure[2] = v; break; + case 3: + pure[0] = 0; pure[1] = w; pure[2] = 1; break; + case 4: + pure[0] = v; pure[1] = 0; pure[2] = 1; break; + default: + pure[0] = 1; pure[1] = 0; pure[2] = w; + } + + mg = (1.0 - c) * g; + + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ]; +}; + +convert.hcg.hsv = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + + var v = c + g * (1.0 - c); + var f = 0; + + if (v > 0.0) { + f = c / v; + } + + return [hcg[0], f * 100, v * 100]; +}; + +convert.hcg.hsl = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + + var l = g * (1.0 - c) + 0.5 * c; + var s = 0; + + if (l > 0.0 && l < 0.5) { + s = c / (2 * l); + } else + if (l >= 0.5 && l < 1.0) { + s = c / (2 * (1 - l)); + } + + return [hcg[0], s * 100, l * 100]; +}; + +convert.hcg.hwb = function (hcg) { + var c = hcg[1] / 100; + var g = hcg[2] / 100; + var v = c + g * (1.0 - c); + return [hcg[0], (v - c) * 100, (1 - v) * 100]; +}; + +convert.hwb.hcg = function (hwb) { + var w = hwb[1] / 100; + var b = hwb[2] / 100; + var v = 1 - b; + var c = v - w; + var g = 0; + + if (c < 1) { + g = (v - c) / (1 - c); + } + + return [hwb[0], c * 100, g * 100]; +}; + +convert.apple.rgb = function (apple) { + return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; +}; + +convert.rgb.apple = function (rgb) { + return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; +}; + +convert.gray.rgb = function (args) { + return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; +}; + +convert.gray.hsl = convert.gray.hsv = function (args) { + return [0, 0, args[0]]; +}; + +convert.gray.hwb = function (gray) { + return [0, 100, gray[0]]; +}; + +convert.gray.cmyk = function (gray) { + return [0, 0, 0, gray[0]]; +}; + +convert.gray.lab = function (gray) { + return [gray[0], 0, 0]; +}; + +convert.gray.hex = function (gray) { + var val = Math.round(gray[0] / 100 * 255) & 0xFF; + var integer = (val << 16) + (val << 8) + val; + + var string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; + +convert.rgb.gray = function (rgb) { + var val = (rgb[0] + rgb[1] + rgb[2]) / 3; + return [val / 255 * 100]; +}; diff --git a/tools/eslint/node_modules/color-convert/index.js b/tools/eslint/node_modules/color-convert/index.js new file mode 100644 index 00000000000000..e65b5d775da353 --- /dev/null +++ b/tools/eslint/node_modules/color-convert/index.js @@ -0,0 +1,78 @@ +var conversions = require('./conversions'); +var route = require('./route'); + +var convert = {}; + +var models = Object.keys(conversions); + +function wrapRaw(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } + + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } + + return fn(args); + }; + + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } + + return wrappedFn; +} + +function wrapRounded(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } + + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } + + var result = fn(args); + + // we're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (var len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } + + return result; + }; + + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } + + return wrappedFn; +} + +models.forEach(function (fromModel) { + convert[fromModel] = {}; + + Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); + Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); + + var routes = route(fromModel); + var routeModels = Object.keys(routes); + + routeModels.forEach(function (toModel) { + var fn = routes[toModel]; + + convert[fromModel][toModel] = wrapRounded(fn); + convert[fromModel][toModel].raw = wrapRaw(fn); + }); +}); + +module.exports = convert; diff --git a/tools/eslint/node_modules/color-convert/package.json b/tools/eslint/node_modules/color-convert/package.json new file mode 100644 index 00000000000000..4d862d1dcd8382 --- /dev/null +++ b/tools/eslint/node_modules/color-convert/package.json @@ -0,0 +1,81 @@ +{ + "_from": "color-convert@^1.0.0", + "_id": "color-convert@1.9.0", + "_inBundle": false, + "_integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "_location": "/eslint/color-convert", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "color-convert@^1.0.0", + "name": "color-convert", + "escapedName": "color-convert", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/eslint/inquirer/ansi-styles" + ], + "_resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "_shasum": "1accf97dd739b983bf994d56fec8f95853641b7a", + "_spec": "color-convert@^1.0.0", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/inquirer/node_modules/ansi-styles", + "author": { + "name": "Heather Arthur", + "email": "fayearthur@gmail.com" + }, + "bugs": { + "url": "https://github.com/Qix-/color-convert/issues" + }, + "bundleDependencies": false, + "dependencies": { + "color-name": "^1.1.1" + }, + "deprecated": false, + "description": "Plain color conversion functions", + "devDependencies": { + "chalk": "^1.1.1", + "xo": "^0.11.2" + }, + "files": [ + "index.js", + "conversions.js", + "css-keywords.js", + "route.js" + ], + "homepage": "https://github.com/Qix-/color-convert#readme", + "keywords": [ + "color", + "colour", + "convert", + "converter", + "conversion", + "rgb", + "hsl", + "hsv", + "hwb", + "cmyk", + "ansi", + "ansi16" + ], + "license": "MIT", + "name": "color-convert", + "repository": { + "type": "git", + "url": "git+https://github.com/Qix-/color-convert.git" + }, + "scripts": { + "pretest": "xo", + "test": "node test/basic.js" + }, + "version": "1.9.0", + "xo": { + "rules": { + "default-case": 0, + "no-inline-comments": 0, + "operator-linebreak": 0 + } + } +} diff --git a/tools/eslint/node_modules/color-convert/route.js b/tools/eslint/node_modules/color-convert/route.js new file mode 100644 index 00000000000000..c365e1ed2849a1 --- /dev/null +++ b/tools/eslint/node_modules/color-convert/route.js @@ -0,0 +1,98 @@ +var conversions = require('./conversions'); + +/* + this function routes a model to all other models. + + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). + + conversions that are not possible simply are not included. +*/ + +// https://jsperf.com/object-keys-vs-for-in-with-closure/3 +var models = Object.keys(conversions); + +function buildGraph() { + var graph = {}; + + for (var len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } + + return graph; +} + +// https://en.wikipedia.org/wiki/Breadth-first_search +function deriveBFS(fromModel) { + var graph = buildGraph(); + var queue = [fromModel]; // unshift -> queue -> pop + + graph[fromModel].distance = 0; + + while (queue.length) { + var current = queue.pop(); + var adjacents = Object.keys(conversions[current]); + + for (var len = adjacents.length, i = 0; i < len; i++) { + var adjacent = adjacents[i]; + var node = graph[adjacent]; + + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } + + return graph; +} + +function link(from, to) { + return function (args) { + return to(from(args)); + }; +} + +function wrapConversion(toModel, graph) { + var path = [graph[toModel].parent, toModel]; + var fn = conversions[graph[toModel].parent][toModel]; + + var cur = graph[toModel].parent; + while (graph[cur].parent) { + path.unshift(graph[cur].parent); + fn = link(conversions[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } + + fn.conversion = path; + return fn; +} + +module.exports = function (fromModel) { + var graph = deriveBFS(fromModel); + var conversion = {}; + + var models = Object.keys(graph); + for (var len = models.length, i = 0; i < len; i++) { + var toModel = models[i]; + var node = graph[toModel]; + + if (node.parent === null) { + // no possible conversion, or this node is the source model. + continue; + } + + conversion[toModel] = wrapConversion(toModel, graph); + } + + return conversion; +}; + diff --git a/tools/eslint/node_modules/color-name/LICENSE b/tools/eslint/node_modules/color-name/LICENSE new file mode 100644 index 00000000000000..4d9802a89e2999 --- /dev/null +++ b/tools/eslint/node_modules/color-name/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2015 Dmitry Ivanov + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/tools/eslint/node_modules/color-name/README.md b/tools/eslint/node_modules/color-name/README.md new file mode 100644 index 00000000000000..3611a6b523fe85 --- /dev/null +++ b/tools/eslint/node_modules/color-name/README.md @@ -0,0 +1,11 @@ +A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors. + +[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/) + + +```js +var colors = require('color-name'); +colors.red //[255,0,0] +``` + + diff --git a/tools/eslint/node_modules/color-name/index.js b/tools/eslint/node_modules/color-name/index.js new file mode 100644 index 00000000000000..7d85e58c9a93ef --- /dev/null +++ b/tools/eslint/node_modules/color-name/index.js @@ -0,0 +1,150 @@ +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; \ No newline at end of file diff --git a/tools/eslint/node_modules/color-name/package.json b/tools/eslint/node_modules/color-name/package.json new file mode 100644 index 00000000000000..bd009b0c541d1c --- /dev/null +++ b/tools/eslint/node_modules/color-name/package.json @@ -0,0 +1,56 @@ +{ + "_from": "color-name@^1.1.1", + "_id": "color-name@1.1.2", + "_inBundle": false, + "_integrity": "sha1-XIq3K2S9IhXWF66VWeuxSEdc+Y0=", + "_location": "/eslint/color-name", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "color-name@^1.1.1", + "name": "color-name", + "escapedName": "color-name", + "rawSpec": "^1.1.1", + "saveSpec": null, + "fetchSpec": "^1.1.1" + }, + "_requiredBy": [ + "/eslint/color-convert" + ], + "_resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.2.tgz", + "_shasum": "5c8ab72b64bd2215d617ae9559ebb148475cf98d", + "_spec": "color-name@^1.1.1", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/color-convert", + "author": { + "name": "DY", + "email": "dfcreative@gmail.com" + }, + "bugs": { + "url": "https://github.com/dfcreative/color-name/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "A list of color names and its values", + "files": [ + "index.js" + ], + "homepage": "https://github.com/dfcreative/color-name", + "keywords": [ + "color-name", + "color", + "color-keyword", + "keyword" + ], + "license": "MIT", + "main": "index.js", + "name": "color-name", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/dfcreative/color-name.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.1.2" +} diff --git a/tools/eslint/node_modules/escape-string-regexp/package.json b/tools/eslint/node_modules/escape-string-regexp/package.json index 0b716286c45605..fa7fe566c83070 100644 --- a/tools/eslint/node_modules/escape-string-regexp/package.json +++ b/tools/eslint/node_modules/escape-string-regexp/package.json @@ -17,7 +17,8 @@ }, "_requiredBy": [ "/eslint/chalk", - "/eslint/figures" + "/eslint/figures", + "/eslint/inquirer/chalk" ], "_resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "_shasum": "1b61c0562190a8dff6ae3bb2cf0200ca130b86d4", diff --git a/tools/eslint/node_modules/eslint-plugin-markdown/package.json b/tools/eslint/node_modules/eslint-plugin-markdown/package.json index 54d03e7a41309a..41f14cb9acb7be 100644 --- a/tools/eslint/node_modules/eslint-plugin-markdown/package.json +++ b/tools/eslint/node_modules/eslint-plugin-markdown/package.json @@ -1,19 +1,19 @@ { - "_from": "eslint-plugin-markdown@1.0.0-beta.7", + "_from": "eslint-plugin-markdown@next", "_id": "eslint-plugin-markdown@1.0.0-beta.7", "_inBundle": false, "_integrity": "sha1-Euc6QSfEpLedlm+fR1hR3Q949+c=", "_location": "/eslint-plugin-markdown", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "tag", "registry": true, - "raw": "eslint-plugin-markdown@1.0.0-beta.7", + "raw": "eslint-plugin-markdown@next", "name": "eslint-plugin-markdown", "escapedName": "eslint-plugin-markdown", - "rawSpec": "1.0.0-beta.7", + "rawSpec": "next", "saveSpec": null, - "fetchSpec": "1.0.0-beta.7" + "fetchSpec": "next" }, "_requiredBy": [ "#USER", @@ -21,8 +21,8 @@ ], "_resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.0-beta.7.tgz", "_shasum": "12e73a4127c4a4b79d966f9f475851dd0f78f7e7", - "_spec": "eslint-plugin-markdown@1.0.0-beta.7", - "_where": "j:\\temp\\_git\\node-fork\\tools\\eslint", + "_spec": "eslint-plugin-markdown@next", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint", "author": { "name": "Brandon Mills", "url": "https://github.com/btmills" diff --git a/tools/eslint/node_modules/esprima/README.md b/tools/eslint/node_modules/esprima/README.md index e59d0833364f79..8fb25e6c1fa6a4 100644 --- a/tools/eslint/node_modules/esprima/README.md +++ b/tools/eslint/node_modules/esprima/README.md @@ -12,11 +12,11 @@ with the help of [many contributors](https://github.com/jquery/esprima/contribut ### Features -- Full support for ECMAScript 2016 ([ECMA-262 7th Edition](http://www.ecma-international.org/publications/standards/Ecma-262.htm)) +- Full support for ECMAScript 2017 ([ECMA-262 8th Edition](http://www.ecma-international.org/publications/standards/Ecma-262.htm)) - Sensible [syntax tree format](https://github.com/estree/estree/blob/master/es5.md) as standardized by [ESTree project](https://github.com/estree/estree) - Experimental support for [JSX](https://facebook.github.io/jsx/), a syntax extension for [React](https://facebook.github.io/react/) - Optional tracking of syntax node location (index-based and line-column) -- [Heavily tested](http://esprima.org/test/ci.html) (~1300 [unit tests](https://github.com/jquery/esprima/tree/master/test/fixtures) with [full code coverage](https://codecov.io/github/jquery/esprima)) +- [Heavily tested](http://esprima.org/test/ci.html) (~1500 [unit tests](https://github.com/jquery/esprima/tree/master/test/fixtures) with [full code coverage](https://codecov.io/github/jquery/esprima)) ### API @@ -34,7 +34,7 @@ A simple example on Node.js REPL: { type: 'Punctuator', value: '=' }, { type: 'Numeric', value: '42' } ] -> esprima.parse(program); +> esprima.parseScript(program); { type: 'Program', body: [ { type: 'VariableDeclaration', @@ -42,3 +42,5 @@ A simple example on Node.js REPL: kind: 'const' } ], sourceType: 'script' } ``` + +For more information, please read the [complete documentation](http://esprima.org/doc). \ No newline at end of file diff --git a/tools/eslint/node_modules/esprima/bin/esparse.js b/tools/eslint/node_modules/esprima/bin/esparse.js old mode 100755 new mode 100644 diff --git a/tools/eslint/node_modules/esprima/bin/esvalidate.js b/tools/eslint/node_modules/esprima/bin/esvalidate.js old mode 100755 new mode 100644 index 4faf760e20f852..d49a7e40a8c3d4 --- a/tools/eslint/node_modules/esprima/bin/esvalidate.js +++ b/tools/eslint/node_modules/esprima/bin/esvalidate.js @@ -194,7 +194,7 @@ function run(fname, content) { console.log(' '); console.log(''); } else { - console.log('Error: ' + e.message); + console.log(fname + ':' + e.lineNumber + ': ' + e.message.replace(/^Line\ [0-9]*\:\ /, '')); } } } diff --git a/tools/eslint/node_modules/esprima/dist/esprima.js b/tools/eslint/node_modules/esprima/dist/esprima.js index 34675c03dc7f80..2c2f93cbd34ddd 100644 --- a/tools/eslint/node_modules/esprima/dist/esprima.js +++ b/tools/eslint/node_modules/esprima/dist/esprima.js @@ -57,6 +57,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 0 */ /***/ function(module, exports, __webpack_require__) { + "use strict"; /* Copyright JS Foundation and other contributors, https://js.foundation/ @@ -80,10 +81,10 @@ return /******/ (function(modules) { // webpackBootstrap (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var comment_handler_1 = __webpack_require__(1); - var parser_1 = __webpack_require__(3); - var jsx_parser_1 = __webpack_require__(11); + var jsx_parser_1 = __webpack_require__(3); + var parser_1 = __webpack_require__(8); var tokenizer_1 = __webpack_require__(15); function parse(code, options, delegate) { var commentHandler = null; @@ -107,6 +108,10 @@ return /******/ (function(modules) { // webpackBootstrap parserDelegate = proxyDelegate; } } + var isModule = false; + if (options && typeof options.sourceType === 'string') { + isModule = (options.sourceType === 'module'); + } var parser; if (options && typeof options.jsx === 'boolean' && options.jsx) { parser = new jsx_parser_1.JSXParser(code, options, parserDelegate); @@ -114,8 +119,9 @@ return /******/ (function(modules) { // webpackBootstrap else { parser = new parser_1.Parser(code, options, parserDelegate); } - var ast = (parser.parseProgram()); - if (collectComment) { + var program = isModule ? parser.parseModule() : parser.parseScript(); + var ast = program; + if (collectComment && commentHandler) { ast.comments = commentHandler.comments; } if (parser.config.tokens) { @@ -127,6 +133,18 @@ return /******/ (function(modules) { // webpackBootstrap return ast; } exports.parse = parse; + function parseModule(code, options, delegate) { + var parsingOptions = options || {}; + parsingOptions.sourceType = 'module'; + return parse(code, parsingOptions, delegate); + } + exports.parseModule = parseModule; + function parseScript(code, options, delegate) { + var parsingOptions = options || {}; + parsingOptions.sourceType = 'script'; + return parse(code, parsingOptions, delegate); + } + exports.parseScript = parseScript; function tokenize(code, options, delegate) { var tokenizer = new tokenizer_1.Tokenizer(code, options); var tokens; @@ -155,7 +173,7 @@ return /******/ (function(modules) { // webpackBootstrap var syntax_1 = __webpack_require__(2); exports.Syntax = syntax_1.Syntax; // Sync with *.json manifests. - exports.version = '3.1.3'; + exports.version = '4.0.0'; /***/ }, @@ -163,6 +181,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var syntax_1 = __webpack_require__(2); var CommentHandler = (function () { function CommentHandler() { @@ -190,7 +209,7 @@ return /******/ (function(modules) { // webpackBootstrap } } }; - CommentHandler.prototype.findTrailingComments = function (node, metadata) { + CommentHandler.prototype.findTrailingComments = function (metadata) { var trailingComments = []; if (this.trailing.length > 0) { for (var i = this.trailing.length - 1; i >= 0; --i) { @@ -212,13 +231,14 @@ return /******/ (function(modules) { // webpackBootstrap } return trailingComments; }; - CommentHandler.prototype.findLeadingComments = function (node, metadata) { + CommentHandler.prototype.findLeadingComments = function (metadata) { var leadingComments = []; var target; while (this.stack.length > 0) { var entry = this.stack[this.stack.length - 1]; if (entry && entry.start >= metadata.start.offset) { - target = this.stack.pop().node; + target = entry.node; + this.stack.pop(); } else { break; @@ -252,8 +272,8 @@ return /******/ (function(modules) { // webpackBootstrap return; } this.insertInnerComments(node, metadata); - var trailingComments = this.findTrailingComments(node, metadata); - var leadingComments = this.findLeadingComments(node, metadata); + var trailingComments = this.findTrailingComments(metadata); + var leadingComments = this.findLeadingComments(metadata); if (leadingComments.length > 0) { node.leadingComments = leadingComments; } @@ -316,12 +336,14 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.Syntax = { AssignmentExpression: 'AssignmentExpression', AssignmentPattern: 'AssignmentPattern', ArrayExpression: 'ArrayExpression', ArrayPattern: 'ArrayPattern', ArrowFunctionExpression: 'ArrowFunctionExpression', + AwaitExpression: 'AwaitExpression', BlockStatement: 'BlockStatement', BinaryExpression: 'BinaryExpression', BreakStatement: 'BreakStatement', @@ -390,4254 +412,551 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { "use strict"; - var assert_1 = __webpack_require__(4); - var messages_1 = __webpack_require__(5); - var error_handler_1 = __webpack_require__(6); - var token_1 = __webpack_require__(7); - var scanner_1 = __webpack_require__(8); - var syntax_1 = __webpack_require__(2); - var Node = __webpack_require__(10); - var ArrowParameterPlaceHolder = 'ArrowParameterPlaceHolder'; - var Parser = (function () { - function Parser(code, options, delegate) { - if (options === void 0) { options = {}; } - this.config = { - range: (typeof options.range === 'boolean') && options.range, - loc: (typeof options.loc === 'boolean') && options.loc, - source: null, - tokens: (typeof options.tokens === 'boolean') && options.tokens, - comment: (typeof options.comment === 'boolean') && options.comment, - tolerant: (typeof options.tolerant === 'boolean') && options.tolerant - }; - if (this.config.loc && options.source && options.source !== null) { - this.config.source = String(options.source); - } - this.delegate = delegate; - this.errorHandler = new error_handler_1.ErrorHandler(); - this.errorHandler.tolerant = this.config.tolerant; - this.scanner = new scanner_1.Scanner(code, this.errorHandler); - this.scanner.trackComment = this.config.comment; - this.operatorPrecedence = { - ')': 0, - ';': 0, - ',': 0, - '=': 0, - ']': 0, - '||': 1, - '&&': 2, - '|': 3, - '^': 4, - '&': 5, - '==': 6, - '!=': 6, - '===': 6, - '!==': 6, - '<': 7, - '>': 7, - '<=': 7, - '>=': 7, - '<<': 8, - '>>': 8, - '>>>': 8, - '+': 9, - '-': 9, - '*': 11, - '/': 11, - '%': 11 - }; - this.sourceType = (options && options.sourceType === 'module') ? 'module' : 'script'; - this.lookahead = null; - this.hasLineTerminator = false; - this.context = { - allowIn: true, - allowYield: true, - firstCoverInitializedNameError: null, - isAssignmentTarget: false, - isBindingElement: false, - inFunctionBody: false, - inIteration: false, - inSwitch: false, - labelSet: {}, - strict: (this.sourceType === 'module') - }; - this.tokens = []; - this.startMarker = { - index: 0, - lineNumber: this.scanner.lineNumber, - lineStart: 0 - }; - this.lastMarker = { - index: 0, - lineNumber: this.scanner.lineNumber, - lineStart: 0 - }; - this.nextToken(); - this.lastMarker = { - index: this.scanner.index, - lineNumber: this.scanner.lineNumber, - lineStart: this.scanner.lineStart - }; +/* istanbul ignore next */ + var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + var character_1 = __webpack_require__(4); + var JSXNode = __webpack_require__(5); + var jsx_syntax_1 = __webpack_require__(6); + var Node = __webpack_require__(7); + var parser_1 = __webpack_require__(8); + var token_1 = __webpack_require__(13); + var xhtml_entities_1 = __webpack_require__(14); + token_1.TokenName[100 /* Identifier */] = 'JSXIdentifier'; + token_1.TokenName[101 /* Text */] = 'JSXText'; + // Fully qualified element name, e.g. returns "svg:path" + function getQualifiedElementName(elementName) { + var qualifiedName; + switch (elementName.type) { + case jsx_syntax_1.JSXSyntax.JSXIdentifier: + var id = elementName; + qualifiedName = id.name; + break; + case jsx_syntax_1.JSXSyntax.JSXNamespacedName: + var ns = elementName; + qualifiedName = getQualifiedElementName(ns.namespace) + ':' + + getQualifiedElementName(ns.name); + break; + case jsx_syntax_1.JSXSyntax.JSXMemberExpression: + var expr = elementName; + qualifiedName = getQualifiedElementName(expr.object) + '.' + + getQualifiedElementName(expr.property); + break; + /* istanbul ignore next */ + default: + break; } - Parser.prototype.throwError = function (messageFormat) { - var values = []; - for (var _i = 1; _i < arguments.length; _i++) { - values[_i - 1] = arguments[_i]; - } - var args = Array.prototype.slice.call(arguments, 1); - var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) { - assert_1.assert(idx < args.length, 'Message reference must be in range'); - return args[idx]; - }); - var index = this.lastMarker.index; - var line = this.lastMarker.lineNumber; - var column = this.lastMarker.index - this.lastMarker.lineStart + 1; - throw this.errorHandler.createError(index, line, column, msg); + return qualifiedName; + } + var JSXParser = (function (_super) { + __extends(JSXParser, _super); + function JSXParser(code, options, delegate) { + return _super.call(this, code, options, delegate) || this; + } + JSXParser.prototype.parsePrimaryExpression = function () { + return this.match('<') ? this.parseJSXRoot() : _super.prototype.parsePrimaryExpression.call(this); }; - Parser.prototype.tolerateError = function (messageFormat) { - var values = []; - for (var _i = 1; _i < arguments.length; _i++) { - values[_i - 1] = arguments[_i]; - } - var args = Array.prototype.slice.call(arguments, 1); - var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) { - assert_1.assert(idx < args.length, 'Message reference must be in range'); - return args[idx]; - }); - var index = this.lastMarker.index; - var line = this.scanner.lineNumber; - var column = this.lastMarker.index - this.lastMarker.lineStart + 1; - this.errorHandler.tolerateError(index, line, column, msg); + JSXParser.prototype.startJSX = function () { + // Unwind the scanner before the lookahead token. + this.scanner.index = this.startMarker.index; + this.scanner.lineNumber = this.startMarker.line; + this.scanner.lineStart = this.startMarker.index - this.startMarker.column; }; - // Throw an exception because of the token. - Parser.prototype.unexpectedTokenError = function (token, message) { - var msg = message || messages_1.Messages.UnexpectedToken; - var value; - if (token) { - if (!message) { - msg = (token.type === token_1.Token.EOF) ? messages_1.Messages.UnexpectedEOS : - (token.type === token_1.Token.Identifier) ? messages_1.Messages.UnexpectedIdentifier : - (token.type === token_1.Token.NumericLiteral) ? messages_1.Messages.UnexpectedNumber : - (token.type === token_1.Token.StringLiteral) ? messages_1.Messages.UnexpectedString : - (token.type === token_1.Token.Template) ? messages_1.Messages.UnexpectedTemplate : - messages_1.Messages.UnexpectedToken; - if (token.type === token_1.Token.Keyword) { - if (this.scanner.isFutureReservedWord(token.value)) { - msg = messages_1.Messages.UnexpectedReserved; - } - else if (this.context.strict && this.scanner.isStrictModeReservedWord(token.value)) { - msg = messages_1.Messages.StrictReservedWord; - } - } - } - value = (token.type === token_1.Token.Template) ? token.value.raw : token.value; - } - else { - value = 'ILLEGAL'; - } - msg = msg.replace('%0', value); - if (token && typeof token.lineNumber === 'number') { - var index = token.start; - var line = token.lineNumber; - var column = token.start - this.lastMarker.lineStart + 1; - return this.errorHandler.createError(index, line, column, msg); - } - else { - var index = this.lastMarker.index; - var line = this.lastMarker.lineNumber; - var column = index - this.lastMarker.lineStart + 1; - return this.errorHandler.createError(index, line, column, msg); + JSXParser.prototype.finishJSX = function () { + // Prime the next lookahead. + this.nextToken(); + }; + JSXParser.prototype.reenterJSX = function () { + this.startJSX(); + this.expectJSX('}'); + // Pop the closing '}' added from the lookahead. + if (this.config.tokens) { + this.tokens.pop(); } }; - Parser.prototype.throwUnexpectedToken = function (token, message) { - throw this.unexpectedTokenError(token, message); + JSXParser.prototype.createJSXNode = function () { + this.collectComments(); + return { + index: this.scanner.index, + line: this.scanner.lineNumber, + column: this.scanner.index - this.scanner.lineStart + }; }; - Parser.prototype.tolerateUnexpectedToken = function (token, message) { - this.errorHandler.tolerate(this.unexpectedTokenError(token, message)); + JSXParser.prototype.createJSXChildNode = function () { + return { + index: this.scanner.index, + line: this.scanner.lineNumber, + column: this.scanner.index - this.scanner.lineStart + }; }; - Parser.prototype.collectComments = function () { - if (!this.config.comment) { - this.scanner.scanComments(); - } - else { - var comments = this.scanner.scanComments(); - if (comments.length > 0 && this.delegate) { - for (var i = 0; i < comments.length; ++i) { - var e = comments[i]; - var node = void 0; - node = { - type: e.multiLine ? 'BlockComment' : 'LineComment', - value: this.scanner.source.slice(e.slice[0], e.slice[1]) - }; - if (this.config.range) { - node.range = e.range; - } - if (this.config.loc) { - node.loc = e.loc; - } - var metadata = { - start: { - line: e.loc.start.line, - column: e.loc.start.column, - offset: e.range[0] - }, - end: { - line: e.loc.end.line, - column: e.loc.end.column, - offset: e.range[1] + JSXParser.prototype.scanXHTMLEntity = function (quote) { + var result = '&'; + var valid = true; + var terminated = false; + var numeric = false; + var hex = false; + while (!this.scanner.eof() && valid && !terminated) { + var ch = this.scanner.source[this.scanner.index]; + if (ch === quote) { + break; + } + terminated = (ch === ';'); + result += ch; + ++this.scanner.index; + if (!terminated) { + switch (result.length) { + case 2: + // e.g. '{' + numeric = (ch === '#'); + break; + case 3: + if (numeric) { + // e.g. 'A' + hex = (ch === 'x'); + valid = hex || character_1.Character.isDecimalDigit(ch.charCodeAt(0)); + numeric = numeric && !hex; } - }; - this.delegate(node, metadata); + break; + default: + valid = valid && !(numeric && !character_1.Character.isDecimalDigit(ch.charCodeAt(0))); + valid = valid && !(hex && !character_1.Character.isHexDigit(ch.charCodeAt(0))); + break; } } } + if (valid && terminated && result.length > 2) { + // e.g. 'A' becomes just '#x41' + var str = result.substr(1, result.length - 2); + if (numeric && str.length > 1) { + result = String.fromCharCode(parseInt(str.substr(1), 10)); + } + else if (hex && str.length > 2) { + result = String.fromCharCode(parseInt('0' + str.substr(1), 16)); + } + else if (!numeric && !hex && xhtml_entities_1.XHTMLEntities[str]) { + result = xhtml_entities_1.XHTMLEntities[str]; + } + } + return result; }; - // From internal representation to an external structure - Parser.prototype.getTokenRaw = function (token) { - return this.scanner.source.slice(token.start, token.end); - }; - Parser.prototype.convertToken = function (token) { - var t; - t = { - type: token_1.TokenName[token.type], - value: this.getTokenRaw(token) - }; - if (this.config.range) { - t.range = [token.start, token.end]; + // Scan the next JSX token. This replaces Scanner#lex when in JSX mode. + JSXParser.prototype.lexJSX = function () { + var cp = this.scanner.source.charCodeAt(this.scanner.index); + // < > / : = { } + if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) { + var value = this.scanner.source[this.scanner.index++]; + return { + type: 7 /* Punctuator */, + value: value, + lineNumber: this.scanner.lineNumber, + lineStart: this.scanner.lineStart, + start: this.scanner.index - 1, + end: this.scanner.index + }; } - if (this.config.loc) { - t.loc = { - start: { - line: this.startMarker.lineNumber, - column: this.startMarker.index - this.startMarker.lineStart - }, - end: { - line: this.scanner.lineNumber, - column: this.scanner.index - this.scanner.lineStart + // " ' + if (cp === 34 || cp === 39) { + var start = this.scanner.index; + var quote = this.scanner.source[this.scanner.index++]; + var str = ''; + while (!this.scanner.eof()) { + var ch = this.scanner.source[this.scanner.index++]; + if (ch === quote) { + break; + } + else if (ch === '&') { + str += this.scanXHTMLEntity(quote); } + else { + str += ch; + } + } + return { + type: 8 /* StringLiteral */, + value: str, + lineNumber: this.scanner.lineNumber, + lineStart: this.scanner.lineStart, + start: start, + end: this.scanner.index + }; + } + // ... or . + if (cp === 46) { + var n1 = this.scanner.source.charCodeAt(this.scanner.index + 1); + var n2 = this.scanner.source.charCodeAt(this.scanner.index + 2); + var value = (n1 === 46 && n2 === 46) ? '...' : '.'; + var start = this.scanner.index; + this.scanner.index += value.length; + return { + type: 7 /* Punctuator */, + value: value, + lineNumber: this.scanner.lineNumber, + lineStart: this.scanner.lineStart, + start: start, + end: this.scanner.index }; } - if (token.regex) { - t.regex = token.regex; + // ` + if (cp === 96) { + // Only placeholder, since it will be rescanned as a real assignment expression. + return { + type: 10 /* Template */, + value: '', + lineNumber: this.scanner.lineNumber, + lineStart: this.scanner.lineStart, + start: this.scanner.index, + end: this.scanner.index + }; } - return t; - }; - Parser.prototype.nextToken = function () { - var token = this.lookahead; - this.lastMarker.index = this.scanner.index; - this.lastMarker.lineNumber = this.scanner.lineNumber; - this.lastMarker.lineStart = this.scanner.lineStart; - this.collectComments(); - this.startMarker.index = this.scanner.index; - this.startMarker.lineNumber = this.scanner.lineNumber; - this.startMarker.lineStart = this.scanner.lineStart; - var next; - next = this.scanner.lex(); - this.hasLineTerminator = (token && next) ? (token.lineNumber !== next.lineNumber) : false; - if (next && this.context.strict && next.type === token_1.Token.Identifier) { - if (this.scanner.isStrictModeReservedWord(next.value)) { - next.type = token_1.Token.Keyword; + // Identifer can not contain backslash (char code 92). + if (character_1.Character.isIdentifierStart(cp) && (cp !== 92)) { + var start = this.scanner.index; + ++this.scanner.index; + while (!this.scanner.eof()) { + var ch = this.scanner.source.charCodeAt(this.scanner.index); + if (character_1.Character.isIdentifierPart(ch) && (ch !== 92)) { + ++this.scanner.index; + } + else if (ch === 45) { + // Hyphen (char code 45) can be part of an identifier. + ++this.scanner.index; + } + else { + break; + } } + var id = this.scanner.source.slice(start, this.scanner.index); + return { + type: 100 /* Identifier */, + value: id, + lineNumber: this.scanner.lineNumber, + lineStart: this.scanner.lineStart, + start: start, + end: this.scanner.index + }; } - this.lookahead = next; - if (this.config.tokens && next.type !== token_1.Token.EOF) { - this.tokens.push(this.convertToken(next)); - } - return token; + return this.scanner.lex(); }; - Parser.prototype.nextRegexToken = function () { + JSXParser.prototype.nextJSXToken = function () { this.collectComments(); - var token = this.scanner.scanRegExp(); + this.startMarker.index = this.scanner.index; + this.startMarker.line = this.scanner.lineNumber; + this.startMarker.column = this.scanner.index - this.scanner.lineStart; + var token = this.lexJSX(); + this.lastMarker.index = this.scanner.index; + this.lastMarker.line = this.scanner.lineNumber; + this.lastMarker.column = this.scanner.index - this.scanner.lineStart; if (this.config.tokens) { - // Pop the previous token, '/' or '/=' - // This is added from the lookahead token. - this.tokens.pop(); this.tokens.push(this.convertToken(token)); } - // Prime the next lookahead. - this.lookahead = token; - this.nextToken(); return token; }; - Parser.prototype.createNode = function () { - return { - index: this.startMarker.index, - line: this.startMarker.lineNumber, - column: this.startMarker.index - this.startMarker.lineStart - }; - }; - Parser.prototype.startNode = function (token) { - return { - index: token.start, - line: token.lineNumber, - column: token.start - token.lineStart - }; - }; - Parser.prototype.finalize = function (meta, node) { - if (this.config.range) { - node.range = [meta.index, this.lastMarker.index]; - } - if (this.config.loc) { - node.loc = { - start: { - line: meta.line, - column: meta.column - }, - end: { - line: this.lastMarker.lineNumber, - column: this.lastMarker.index - this.lastMarker.lineStart + JSXParser.prototype.nextJSXText = function () { + this.startMarker.index = this.scanner.index; + this.startMarker.line = this.scanner.lineNumber; + this.startMarker.column = this.scanner.index - this.scanner.lineStart; + var start = this.scanner.index; + var text = ''; + while (!this.scanner.eof()) { + var ch = this.scanner.source[this.scanner.index]; + if (ch === '{' || ch === '<') { + break; + } + ++this.scanner.index; + text += ch; + if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) { + ++this.scanner.lineNumber; + if (ch === '\r' && this.scanner.source[this.scanner.index] === '\n') { + ++this.scanner.index; } - }; - if (this.config.source) { - node.loc.source = this.config.source; + this.scanner.lineStart = this.scanner.index; } } - if (this.delegate) { - var metadata = { - start: { - line: meta.line, - column: meta.column, - offset: meta.index - }, - end: { - line: this.lastMarker.lineNumber, - column: this.lastMarker.index - this.lastMarker.lineStart, - offset: this.lastMarker.index - } - }; - this.delegate(node, metadata); + this.lastMarker.index = this.scanner.index; + this.lastMarker.line = this.scanner.lineNumber; + this.lastMarker.column = this.scanner.index - this.scanner.lineStart; + var token = { + type: 101 /* Text */, + value: text, + lineNumber: this.scanner.lineNumber, + lineStart: this.scanner.lineStart, + start: start, + end: this.scanner.index + }; + if ((text.length > 0) && this.config.tokens) { + this.tokens.push(this.convertToken(token)); } - return node; + return token; }; - // Expect the next token to match the specified punctuator. + JSXParser.prototype.peekJSXToken = function () { + var state = this.scanner.saveState(); + this.scanner.scanComments(); + var next = this.lexJSX(); + this.scanner.restoreState(state); + return next; + }; + // Expect the next JSX token to match the specified punctuator. // If not, an exception will be thrown. - Parser.prototype.expect = function (value) { - var token = this.nextToken(); - if (token.type !== token_1.Token.Punctuator || token.value !== value) { + JSXParser.prototype.expectJSX = function (value) { + var token = this.nextJSXToken(); + if (token.type !== 7 /* Punctuator */ || token.value !== value) { this.throwUnexpectedToken(token); } }; - // Quietly expect a comma when in tolerant mode, otherwise delegates to expect(). - Parser.prototype.expectCommaSeparator = function () { - if (this.config.tolerant) { - var token = this.lookahead; - if (token.type === token_1.Token.Punctuator && token.value === ',') { - this.nextToken(); - } - else if (token.type === token_1.Token.Punctuator && token.value === ';') { - this.nextToken(); - this.tolerateUnexpectedToken(token); - } - else { - this.tolerateUnexpectedToken(token, messages_1.Messages.UnexpectedToken); - } - } - else { - this.expect(','); - } + // Return true if the next JSX token matches the specified punctuator. + JSXParser.prototype.matchJSX = function (value) { + var next = this.peekJSXToken(); + return next.type === 7 /* Punctuator */ && next.value === value; }; - // Expect the next token to match the specified keyword. - // If not, an exception will be thrown. - Parser.prototype.expectKeyword = function (keyword) { - var token = this.nextToken(); - if (token.type !== token_1.Token.Keyword || token.value !== keyword) { + JSXParser.prototype.parseJSXIdentifier = function () { + var node = this.createJSXNode(); + var token = this.nextJSXToken(); + if (token.type !== 100 /* Identifier */) { this.throwUnexpectedToken(token); } + return this.finalize(node, new JSXNode.JSXIdentifier(token.value)); }; - // Return true if the next token matches the specified punctuator. - Parser.prototype.match = function (value) { - return this.lookahead.type === token_1.Token.Punctuator && this.lookahead.value === value; - }; - // Return true if the next token matches the specified keyword - Parser.prototype.matchKeyword = function (keyword) { - return this.lookahead.type === token_1.Token.Keyword && this.lookahead.value === keyword; - }; - // Return true if the next token matches the specified contextual keyword - // (where an identifier is sometimes a keyword depending on the context) - Parser.prototype.matchContextualKeyword = function (keyword) { - return this.lookahead.type === token_1.Token.Identifier && this.lookahead.value === keyword; - }; - // Return true if the next token is an assignment operator - Parser.prototype.matchAssign = function () { - if (this.lookahead.type !== token_1.Token.Punctuator) { - return false; + JSXParser.prototype.parseJSXElementName = function () { + var node = this.createJSXNode(); + var elementName = this.parseJSXIdentifier(); + if (this.matchJSX(':')) { + var namespace = elementName; + this.expectJSX(':'); + var name_1 = this.parseJSXIdentifier(); + elementName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_1)); } - var op = this.lookahead.value; - return op === '=' || - op === '*=' || - op === '**=' || - op === '/=' || - op === '%=' || - op === '+=' || - op === '-=' || - op === '<<=' || - op === '>>=' || - op === '>>>=' || - op === '&=' || - op === '^=' || - op === '|='; - }; - // Cover grammar support. - // - // When an assignment expression position starts with an left parenthesis, the determination of the type - // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead) - // or the first comma. This situation also defers the determination of all the expressions nested in the pair. - // - // There are three productions that can be parsed in a parentheses pair that needs to be determined - // after the outermost pair is closed. They are: - // - // 1. AssignmentExpression - // 2. BindingElements - // 3. AssignmentTargets - // - // In order to avoid exponential backtracking, we use two flags to denote if the production can be - // binding element or assignment target. - // - // The three productions have the relationship: - // - // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression - // - // with a single exception that CoverInitializedName when used directly in an Expression, generates - // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the - // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair. - // - // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not - // effect the current flags. This means the production the parser parses is only used as an expression. Therefore - // the CoverInitializedName check is conducted. - // - // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates - // the flags outside of the parser. This means the production the parser parses is used as a part of a potential - // pattern. The CoverInitializedName check is deferred. - Parser.prototype.isolateCoverGrammar = function (parseFunction) { - var previousIsBindingElement = this.context.isBindingElement; - var previousIsAssignmentTarget = this.context.isAssignmentTarget; - var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError; - this.context.isBindingElement = true; - this.context.isAssignmentTarget = true; - this.context.firstCoverInitializedNameError = null; - var result = parseFunction.call(this); - if (this.context.firstCoverInitializedNameError !== null) { - this.throwUnexpectedToken(this.context.firstCoverInitializedNameError); + else if (this.matchJSX('.')) { + while (this.matchJSX('.')) { + var object = elementName; + this.expectJSX('.'); + var property = this.parseJSXIdentifier(); + elementName = this.finalize(node, new JSXNode.JSXMemberExpression(object, property)); + } } - this.context.isBindingElement = previousIsBindingElement; - this.context.isAssignmentTarget = previousIsAssignmentTarget; - this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError; - return result; - }; - Parser.prototype.inheritCoverGrammar = function (parseFunction) { - var previousIsBindingElement = this.context.isBindingElement; - var previousIsAssignmentTarget = this.context.isAssignmentTarget; - var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError; - this.context.isBindingElement = true; - this.context.isAssignmentTarget = true; - this.context.firstCoverInitializedNameError = null; - var result = parseFunction.call(this); - this.context.isBindingElement = this.context.isBindingElement && previousIsBindingElement; - this.context.isAssignmentTarget = this.context.isAssignmentTarget && previousIsAssignmentTarget; - this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError || this.context.firstCoverInitializedNameError; - return result; + return elementName; }; - Parser.prototype.consumeSemicolon = function () { - if (this.match(';')) { - this.nextToken(); + JSXParser.prototype.parseJSXAttributeName = function () { + var node = this.createJSXNode(); + var attributeName; + var identifier = this.parseJSXIdentifier(); + if (this.matchJSX(':')) { + var namespace = identifier; + this.expectJSX(':'); + var name_2 = this.parseJSXIdentifier(); + attributeName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_2)); } - else if (!this.hasLineTerminator) { - if (this.lookahead.type !== token_1.Token.EOF && !this.match('}')) { - this.throwUnexpectedToken(this.lookahead); - } - this.lastMarker.index = this.startMarker.index; - this.lastMarker.lineNumber = this.startMarker.lineNumber; - this.lastMarker.lineStart = this.startMarker.lineStart; + else { + attributeName = identifier; } + return attributeName; }; - // ECMA-262 12.2 Primary Expressions - Parser.prototype.parsePrimaryExpression = function () { - var node = this.createNode(); - var expr; - var value, token, raw; - switch (this.lookahead.type) { - case token_1.Token.Identifier: - if (this.sourceType === 'module' && this.lookahead.value === 'await') { - this.tolerateUnexpectedToken(this.lookahead); - } - expr = this.finalize(node, new Node.Identifier(this.nextToken().value)); - break; - case token_1.Token.NumericLiteral: - case token_1.Token.StringLiteral: - if (this.context.strict && this.lookahead.octal) { - this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.StrictOctalLiteral); - } - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - token = this.nextToken(); - raw = this.getTokenRaw(token); - expr = this.finalize(node, new Node.Literal(token.value, raw)); - break; - case token_1.Token.BooleanLiteral: - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - token = this.nextToken(); - token.value = (token.value === 'true'); - raw = this.getTokenRaw(token); - expr = this.finalize(node, new Node.Literal(token.value, raw)); - break; - case token_1.Token.NullLiteral: - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - token = this.nextToken(); - token.value = null; - raw = this.getTokenRaw(token); - expr = this.finalize(node, new Node.Literal(token.value, raw)); - break; - case token_1.Token.Template: - expr = this.parseTemplateLiteral(); - break; - case token_1.Token.Punctuator: - value = this.lookahead.value; - switch (value) { - case '(': - this.context.isBindingElement = false; - expr = this.inheritCoverGrammar(this.parseGroupExpression); - break; - case '[': - expr = this.inheritCoverGrammar(this.parseArrayInitializer); - break; - case '{': - expr = this.inheritCoverGrammar(this.parseObjectInitializer); - break; - case '/': - case '/=': - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - this.scanner.index = this.startMarker.index; - token = this.nextRegexToken(); - raw = this.getTokenRaw(token); - expr = this.finalize(node, new Node.RegexLiteral(token.value, raw, token.regex)); - break; - default: - this.throwUnexpectedToken(this.nextToken()); - } - break; - case token_1.Token.Keyword: - if (!this.context.strict && this.context.allowYield && this.matchKeyword('yield')) { - expr = this.parseIdentifierName(); - } - else if (!this.context.strict && this.matchKeyword('let')) { - expr = this.finalize(node, new Node.Identifier(this.nextToken().value)); - } - else { - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - if (this.matchKeyword('function')) { - expr = this.parseFunctionExpression(); - } - else if (this.matchKeyword('this')) { - this.nextToken(); - expr = this.finalize(node, new Node.ThisExpression()); - } - else if (this.matchKeyword('class')) { - expr = this.parseClassExpression(); - } - else { - this.throwUnexpectedToken(this.nextToken()); - } - } - break; - default: - this.throwUnexpectedToken(this.nextToken()); + JSXParser.prototype.parseJSXStringLiteralAttribute = function () { + var node = this.createJSXNode(); + var token = this.nextJSXToken(); + if (token.type !== 8 /* StringLiteral */) { + this.throwUnexpectedToken(token); } - return expr; - }; - // ECMA-262 12.2.5 Array Initializer - Parser.prototype.parseSpreadElement = function () { - var node = this.createNode(); - this.expect('...'); - var arg = this.inheritCoverGrammar(this.parseAssignmentExpression); - return this.finalize(node, new Node.SpreadElement(arg)); + var raw = this.getTokenRaw(token); + return this.finalize(node, new Node.Literal(token.value, raw)); }; - Parser.prototype.parseArrayInitializer = function () { - var node = this.createNode(); - var elements = []; - this.expect('['); - while (!this.match(']')) { - if (this.match(',')) { - this.nextToken(); - elements.push(null); - } - else if (this.match('...')) { - var element = this.parseSpreadElement(); - if (!this.match(']')) { - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - this.expect(','); - } - elements.push(element); - } - else { - elements.push(this.inheritCoverGrammar(this.parseAssignmentExpression)); - if (!this.match(']')) { - this.expect(','); - } - } + JSXParser.prototype.parseJSXExpressionAttribute = function () { + var node = this.createJSXNode(); + this.expectJSX('{'); + this.finishJSX(); + if (this.match('}')) { + this.tolerateError('JSX attributes must only be assigned a non-empty expression'); } - this.expect(']'); - return this.finalize(node, new Node.ArrayExpression(elements)); + var expression = this.parseAssignmentExpression(); + this.reenterJSX(); + return this.finalize(node, new JSXNode.JSXExpressionContainer(expression)); }; - // ECMA-262 12.2.6 Object Initializer - Parser.prototype.parsePropertyMethod = function (params) { - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - var previousStrict = this.context.strict; - var body = this.isolateCoverGrammar(this.parseFunctionSourceElements); - if (this.context.strict && params.firstRestricted) { - this.tolerateUnexpectedToken(params.firstRestricted, params.message); - } - if (this.context.strict && params.stricted) { - this.tolerateUnexpectedToken(params.stricted, params.message); - } - this.context.strict = previousStrict; - return body; + JSXParser.prototype.parseJSXAttributeValue = function () { + return this.matchJSX('{') ? this.parseJSXExpressionAttribute() : + this.matchJSX('<') ? this.parseJSXElement() : this.parseJSXStringLiteralAttribute(); }; - Parser.prototype.parsePropertyMethodFunction = function () { - var isGenerator = false; - var node = this.createNode(); - var previousAllowYield = this.context.allowYield; - this.context.allowYield = false; - var params = this.parseFormalParameters(); - var method = this.parsePropertyMethod(params); - this.context.allowYield = previousAllowYield; - return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator)); + JSXParser.prototype.parseJSXNameValueAttribute = function () { + var node = this.createJSXNode(); + var name = this.parseJSXAttributeName(); + var value = null; + if (this.matchJSX('=')) { + this.expectJSX('='); + value = this.parseJSXAttributeValue(); + } + return this.finalize(node, new JSXNode.JSXAttribute(name, value)); }; - Parser.prototype.parseObjectPropertyKey = function () { - var node = this.createNode(); - var token = this.nextToken(); - var key = null; - switch (token.type) { - case token_1.Token.StringLiteral: - case token_1.Token.NumericLiteral: - if (this.context.strict && token.octal) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictOctalLiteral); - } - var raw = this.getTokenRaw(token); - key = this.finalize(node, new Node.Literal(token.value, raw)); - break; - case token_1.Token.Identifier: - case token_1.Token.BooleanLiteral: - case token_1.Token.NullLiteral: - case token_1.Token.Keyword: - key = this.finalize(node, new Node.Identifier(token.value)); - break; - case token_1.Token.Punctuator: - if (token.value === '[') { - key = this.isolateCoverGrammar(this.parseAssignmentExpression); - this.expect(']'); - } - else { - this.throwUnexpectedToken(token); - } - break; - default: - this.throwUnexpectedToken(token); - } - return key; - }; - Parser.prototype.isPropertyKey = function (key, value) { - return (key.type === syntax_1.Syntax.Identifier && key.name === value) || - (key.type === syntax_1.Syntax.Literal && key.value === value); + JSXParser.prototype.parseJSXSpreadAttribute = function () { + var node = this.createJSXNode(); + this.expectJSX('{'); + this.expectJSX('...'); + this.finishJSX(); + var argument = this.parseAssignmentExpression(); + this.reenterJSX(); + return this.finalize(node, new JSXNode.JSXSpreadAttribute(argument)); }; - Parser.prototype.parseObjectProperty = function (hasProto) { - var node = this.createNode(); - var token = this.lookahead; - var kind; - var key; - var value; - var computed = false; - var method = false; - var shorthand = false; - if (token.type === token_1.Token.Identifier) { - this.nextToken(); - key = this.finalize(node, new Node.Identifier(token.value)); - } - else if (this.match('*')) { - this.nextToken(); + JSXParser.prototype.parseJSXAttributes = function () { + var attributes = []; + while (!this.matchJSX('/') && !this.matchJSX('>')) { + var attribute = this.matchJSX('{') ? this.parseJSXSpreadAttribute() : + this.parseJSXNameValueAttribute(); + attributes.push(attribute); } - else { - computed = this.match('['); - key = this.parseObjectPropertyKey(); + return attributes; + }; + JSXParser.prototype.parseJSXOpeningElement = function () { + var node = this.createJSXNode(); + this.expectJSX('<'); + var name = this.parseJSXElementName(); + var attributes = this.parseJSXAttributes(); + var selfClosing = this.matchJSX('/'); + if (selfClosing) { + this.expectJSX('/'); } - var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead); - if (token.type === token_1.Token.Identifier && token.value === 'get' && lookaheadPropertyKey) { - kind = 'get'; - computed = this.match('['); - key = this.parseObjectPropertyKey(); - this.context.allowYield = false; - value = this.parseGetterMethod(); + this.expectJSX('>'); + return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes)); + }; + JSXParser.prototype.parseJSXBoundaryElement = function () { + var node = this.createJSXNode(); + this.expectJSX('<'); + if (this.matchJSX('/')) { + this.expectJSX('/'); + var name_3 = this.parseJSXElementName(); + this.expectJSX('>'); + return this.finalize(node, new JSXNode.JSXClosingElement(name_3)); } - else if (token.type === token_1.Token.Identifier && token.value === 'set' && lookaheadPropertyKey) { - kind = 'set'; - computed = this.match('['); - key = this.parseObjectPropertyKey(); - value = this.parseSetterMethod(); + var name = this.parseJSXElementName(); + var attributes = this.parseJSXAttributes(); + var selfClosing = this.matchJSX('/'); + if (selfClosing) { + this.expectJSX('/'); } - else if (token.type === token_1.Token.Punctuator && token.value === '*' && lookaheadPropertyKey) { - kind = 'init'; - computed = this.match('['); - key = this.parseObjectPropertyKey(); - value = this.parseGeneratorMethod(); - method = true; + this.expectJSX('>'); + return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes)); + }; + JSXParser.prototype.parseJSXEmptyExpression = function () { + var node = this.createJSXChildNode(); + this.collectComments(); + this.lastMarker.index = this.scanner.index; + this.lastMarker.line = this.scanner.lineNumber; + this.lastMarker.column = this.scanner.index - this.scanner.lineStart; + return this.finalize(node, new JSXNode.JSXEmptyExpression()); + }; + JSXParser.prototype.parseJSXExpressionContainer = function () { + var node = this.createJSXNode(); + this.expectJSX('{'); + var expression; + if (this.matchJSX('}')) { + expression = this.parseJSXEmptyExpression(); + this.expectJSX('}'); } else { - if (!key) { - this.throwUnexpectedToken(this.lookahead); + this.finishJSX(); + expression = this.parseAssignmentExpression(); + this.reenterJSX(); + } + return this.finalize(node, new JSXNode.JSXExpressionContainer(expression)); + }; + JSXParser.prototype.parseJSXChildren = function () { + var children = []; + while (!this.scanner.eof()) { + var node = this.createJSXChildNode(); + var token = this.nextJSXText(); + if (token.start < token.end) { + var raw = this.getTokenRaw(token); + var child = this.finalize(node, new JSXNode.JSXText(token.value, raw)); + children.push(child); } - kind = 'init'; - if (this.match(':')) { - if (!computed && this.isPropertyKey(key, '__proto__')) { - if (hasProto.value) { - this.tolerateError(messages_1.Messages.DuplicateProtoProperty); - } - hasProto.value = true; - } - this.nextToken(); - value = this.inheritCoverGrammar(this.parseAssignmentExpression); + if (this.scanner.source[this.scanner.index] === '{') { + var container = this.parseJSXExpressionContainer(); + children.push(container); } - else if (this.match('(')) { - value = this.parsePropertyMethodFunction(); - method = true; + else { + break; } - else if (token.type === token_1.Token.Identifier) { - var id = this.finalize(node, new Node.Identifier(token.value)); - if (this.match('=')) { - this.context.firstCoverInitializedNameError = this.lookahead; - this.nextToken(); - shorthand = true; - var init = this.isolateCoverGrammar(this.parseAssignmentExpression); - value = this.finalize(node, new Node.AssignmentPattern(id, init)); + } + return children; + }; + JSXParser.prototype.parseComplexJSXElement = function (el) { + var stack = []; + while (!this.scanner.eof()) { + el.children = el.children.concat(this.parseJSXChildren()); + var node = this.createJSXChildNode(); + var element = this.parseJSXBoundaryElement(); + if (element.type === jsx_syntax_1.JSXSyntax.JSXOpeningElement) { + var opening = element; + if (opening.selfClosing) { + var child = this.finalize(node, new JSXNode.JSXElement(opening, [], null)); + el.children.push(child); } else { - shorthand = true; - value = id; + stack.push(el); + el = { node: node, opening: opening, closing: null, children: [] }; } } - else { - this.throwUnexpectedToken(this.nextToken()); + if (element.type === jsx_syntax_1.JSXSyntax.JSXClosingElement) { + el.closing = element; + var open_1 = getQualifiedElementName(el.opening.name); + var close_1 = getQualifiedElementName(el.closing.name); + if (open_1 !== close_1) { + this.tolerateError('Expected corresponding JSX closing tag for %0', open_1); + } + if (stack.length > 0) { + var child = this.finalize(el.node, new JSXNode.JSXElement(el.opening, el.children, el.closing)); + el = stack[stack.length - 1]; + el.children.push(child); + stack.pop(); + } + else { + break; + } } } - return this.finalize(node, new Node.Property(kind, key, computed, value, method, shorthand)); + return el; }; - Parser.prototype.parseObjectInitializer = function () { - var node = this.createNode(); - this.expect('{'); - var properties = []; - var hasProto = { value: false }; - while (!this.match('}')) { - properties.push(this.parseObjectProperty(hasProto)); - if (!this.match('}')) { - this.expectCommaSeparator(); - } + JSXParser.prototype.parseJSXElement = function () { + var node = this.createJSXNode(); + var opening = this.parseJSXOpeningElement(); + var children = []; + var closing = null; + if (!opening.selfClosing) { + var el = this.parseComplexJSXElement({ node: node, opening: opening, closing: closing, children: children }); + children = el.children; + closing = el.closing; } - this.expect('}'); - return this.finalize(node, new Node.ObjectExpression(properties)); - }; - // ECMA-262 12.2.9 Template Literals - Parser.prototype.parseTemplateHead = function () { - assert_1.assert(this.lookahead.head, 'Template literal must start with a template head'); - var node = this.createNode(); - var token = this.nextToken(); - var value = { - raw: token.value.raw, - cooked: token.value.cooked - }; - return this.finalize(node, new Node.TemplateElement(value, token.tail)); + return this.finalize(node, new JSXNode.JSXElement(opening, children, closing)); }; - Parser.prototype.parseTemplateElement = function () { - if (this.lookahead.type !== token_1.Token.Template) { - this.throwUnexpectedToken(); + JSXParser.prototype.parseJSXRoot = function () { + // Pop the opening '<' added from the lookahead. + if (this.config.tokens) { + this.tokens.pop(); } - var node = this.createNode(); - var token = this.nextToken(); - var value = { - raw: token.value.raw, - cooked: token.value.cooked - }; - return this.finalize(node, new Node.TemplateElement(value, token.tail)); + this.startJSX(); + var element = this.parseJSXElement(); + this.finishJSX(); + return element; }; - Parser.prototype.parseTemplateLiteral = function () { - var node = this.createNode(); - var expressions = []; - var quasis = []; - var quasi = this.parseTemplateHead(); - quasis.push(quasi); - while (!quasi.tail) { - expressions.push(this.parseExpression()); - quasi = this.parseTemplateElement(); - quasis.push(quasi); - } - return this.finalize(node, new Node.TemplateLiteral(quasis, expressions)); + JSXParser.prototype.isStartOfExpression = function () { + return _super.prototype.isStartOfExpression.call(this) || this.match('<'); }; - // ECMA-262 12.2.10 The Grouping Operator - Parser.prototype.reinterpretExpressionAsPattern = function (expr) { - switch (expr.type) { - case syntax_1.Syntax.Identifier: - case syntax_1.Syntax.MemberExpression: - case syntax_1.Syntax.RestElement: - case syntax_1.Syntax.AssignmentPattern: - break; - case syntax_1.Syntax.SpreadElement: - expr.type = syntax_1.Syntax.RestElement; - this.reinterpretExpressionAsPattern(expr.argument); - break; - case syntax_1.Syntax.ArrayExpression: - expr.type = syntax_1.Syntax.ArrayPattern; - for (var i = 0; i < expr.elements.length; i++) { - if (expr.elements[i] !== null) { - this.reinterpretExpressionAsPattern(expr.elements[i]); - } - } - break; - case syntax_1.Syntax.ObjectExpression: - expr.type = syntax_1.Syntax.ObjectPattern; - for (var i = 0; i < expr.properties.length; i++) { - this.reinterpretExpressionAsPattern(expr.properties[i].value); - } - break; - case syntax_1.Syntax.AssignmentExpression: - expr.type = syntax_1.Syntax.AssignmentPattern; - delete expr.operator; - this.reinterpretExpressionAsPattern(expr.left); - break; - default: - // Allow other node type for tolerant parsing. - break; - } - }; - Parser.prototype.parseGroupExpression = function () { - var expr; - this.expect('('); - if (this.match(')')) { - this.nextToken(); - if (!this.match('=>')) { - this.expect('=>'); - } - expr = { - type: ArrowParameterPlaceHolder, - params: [] - }; - } - else { - var startToken = this.lookahead; - var params = []; - if (this.match('...')) { - expr = this.parseRestElement(params); - this.expect(')'); - if (!this.match('=>')) { - this.expect('=>'); - } - expr = { - type: ArrowParameterPlaceHolder, - params: [expr] - }; - } - else { - var arrow = false; - this.context.isBindingElement = true; - expr = this.inheritCoverGrammar(this.parseAssignmentExpression); - if (this.match(',')) { - var expressions = []; - this.context.isAssignmentTarget = false; - expressions.push(expr); - while (this.startMarker.index < this.scanner.length) { - if (!this.match(',')) { - break; - } - this.nextToken(); - if (this.match('...')) { - if (!this.context.isBindingElement) { - this.throwUnexpectedToken(this.lookahead); - } - expressions.push(this.parseRestElement(params)); - this.expect(')'); - if (!this.match('=>')) { - this.expect('=>'); - } - this.context.isBindingElement = false; - for (var i = 0; i < expressions.length; i++) { - this.reinterpretExpressionAsPattern(expressions[i]); - } - arrow = true; - expr = { - type: ArrowParameterPlaceHolder, - params: expressions - }; - } - else { - expressions.push(this.inheritCoverGrammar(this.parseAssignmentExpression)); - } - if (arrow) { - break; - } - } - if (!arrow) { - expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions)); - } - } - if (!arrow) { - this.expect(')'); - if (this.match('=>')) { - if (expr.type === syntax_1.Syntax.Identifier && expr.name === 'yield') { - arrow = true; - expr = { - type: ArrowParameterPlaceHolder, - params: [expr] - }; - } - if (!arrow) { - if (!this.context.isBindingElement) { - this.throwUnexpectedToken(this.lookahead); - } - if (expr.type === syntax_1.Syntax.SequenceExpression) { - for (var i = 0; i < expr.expressions.length; i++) { - this.reinterpretExpressionAsPattern(expr.expressions[i]); - } - } - else { - this.reinterpretExpressionAsPattern(expr); - } - var params_1 = (expr.type === syntax_1.Syntax.SequenceExpression ? expr.expressions : [expr]); - expr = { - type: ArrowParameterPlaceHolder, - params: params_1 - }; - } - } - this.context.isBindingElement = false; - } - } - } - return expr; - }; - // ECMA-262 12.3 Left-Hand-Side Expressions - Parser.prototype.parseArguments = function () { - this.expect('('); - var args = []; - if (!this.match(')')) { - while (true) { - var expr = this.match('...') ? this.parseSpreadElement() : - this.isolateCoverGrammar(this.parseAssignmentExpression); - args.push(expr); - if (this.match(')')) { - break; - } - this.expectCommaSeparator(); - } - } - this.expect(')'); - return args; - }; - Parser.prototype.isIdentifierName = function (token) { - return token.type === token_1.Token.Identifier || - token.type === token_1.Token.Keyword || - token.type === token_1.Token.BooleanLiteral || - token.type === token_1.Token.NullLiteral; - }; - Parser.prototype.parseIdentifierName = function () { - var node = this.createNode(); - var token = this.nextToken(); - if (!this.isIdentifierName(token)) { - this.throwUnexpectedToken(token); - } - return this.finalize(node, new Node.Identifier(token.value)); - }; - Parser.prototype.parseNewExpression = function () { - var node = this.createNode(); - var id = this.parseIdentifierName(); - assert_1.assert(id.name === 'new', 'New expression must start with `new`'); - var expr; - if (this.match('.')) { - this.nextToken(); - if (this.lookahead.type === token_1.Token.Identifier && this.context.inFunctionBody && this.lookahead.value === 'target') { - var property = this.parseIdentifierName(); - expr = new Node.MetaProperty(id, property); - } - else { - this.throwUnexpectedToken(this.lookahead); - } - } - else { - var callee = this.isolateCoverGrammar(this.parseLeftHandSideExpression); - var args = this.match('(') ? this.parseArguments() : []; - expr = new Node.NewExpression(callee, args); - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - } - return this.finalize(node, expr); - }; - Parser.prototype.parseLeftHandSideExpressionAllowCall = function () { - var startToken = this.lookahead; - var previousAllowIn = this.context.allowIn; - this.context.allowIn = true; - var expr; - if (this.matchKeyword('super') && this.context.inFunctionBody) { - expr = this.createNode(); - this.nextToken(); - expr = this.finalize(expr, new Node.Super()); - if (!this.match('(') && !this.match('.') && !this.match('[')) { - this.throwUnexpectedToken(this.lookahead); - } - } - else { - expr = this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression); - } - while (true) { - if (this.match('.')) { - this.context.isBindingElement = false; - this.context.isAssignmentTarget = true; - this.expect('.'); - var property = this.parseIdentifierName(); - expr = this.finalize(this.startNode(startToken), new Node.StaticMemberExpression(expr, property)); - } - else if (this.match('(')) { - this.context.isBindingElement = false; - this.context.isAssignmentTarget = false; - var args = this.parseArguments(); - expr = this.finalize(this.startNode(startToken), new Node.CallExpression(expr, args)); - } - else if (this.match('[')) { - this.context.isBindingElement = false; - this.context.isAssignmentTarget = true; - this.expect('['); - var property = this.isolateCoverGrammar(this.parseExpression); - this.expect(']'); - expr = this.finalize(this.startNode(startToken), new Node.ComputedMemberExpression(expr, property)); - } - else if (this.lookahead.type === token_1.Token.Template && this.lookahead.head) { - var quasi = this.parseTemplateLiteral(); - expr = this.finalize(this.startNode(startToken), new Node.TaggedTemplateExpression(expr, quasi)); - } - else { - break; - } - } - this.context.allowIn = previousAllowIn; - return expr; - }; - Parser.prototype.parseSuper = function () { - var node = this.createNode(); - this.expectKeyword('super'); - if (!this.match('[') && !this.match('.')) { - this.throwUnexpectedToken(this.lookahead); - } - return this.finalize(node, new Node.Super()); - }; - Parser.prototype.parseLeftHandSideExpression = function () { - assert_1.assert(this.context.allowIn, 'callee of new expression always allow in keyword.'); - var node = this.startNode(this.lookahead); - var expr = (this.matchKeyword('super') && this.context.inFunctionBody) ? this.parseSuper() : - this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression); - while (true) { - if (this.match('[')) { - this.context.isBindingElement = false; - this.context.isAssignmentTarget = true; - this.expect('['); - var property = this.isolateCoverGrammar(this.parseExpression); - this.expect(']'); - expr = this.finalize(node, new Node.ComputedMemberExpression(expr, property)); - } - else if (this.match('.')) { - this.context.isBindingElement = false; - this.context.isAssignmentTarget = true; - this.expect('.'); - var property = this.parseIdentifierName(); - expr = this.finalize(node, new Node.StaticMemberExpression(expr, property)); - } - else if (this.lookahead.type === token_1.Token.Template && this.lookahead.head) { - var quasi = this.parseTemplateLiteral(); - expr = this.finalize(node, new Node.TaggedTemplateExpression(expr, quasi)); - } - else { - break; - } - } - return expr; - }; - // ECMA-262 12.4 Update Expressions - Parser.prototype.parseUpdateExpression = function () { - var expr; - var startToken = this.lookahead; - if (this.match('++') || this.match('--')) { - var node = this.startNode(startToken); - var token = this.nextToken(); - expr = this.inheritCoverGrammar(this.parseUnaryExpression); - if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) { - this.tolerateError(messages_1.Messages.StrictLHSPrefix); - } - if (!this.context.isAssignmentTarget) { - this.tolerateError(messages_1.Messages.InvalidLHSInAssignment); - } - var prefix = true; - expr = this.finalize(node, new Node.UpdateExpression(token.value, expr, prefix)); - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - } - else { - expr = this.inheritCoverGrammar(this.parseLeftHandSideExpressionAllowCall); - if (!this.hasLineTerminator && this.lookahead.type === token_1.Token.Punctuator) { - if (this.match('++') || this.match('--')) { - if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) { - this.tolerateError(messages_1.Messages.StrictLHSPostfix); - } - if (!this.context.isAssignmentTarget) { - this.tolerateError(messages_1.Messages.InvalidLHSInAssignment); - } - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - var operator = this.nextToken().value; - var prefix = false; - expr = this.finalize(this.startNode(startToken), new Node.UpdateExpression(operator, expr, prefix)); - } - } - } - return expr; - }; - // ECMA-262 12.5 Unary Operators - Parser.prototype.parseUnaryExpression = function () { - var expr; - if (this.match('+') || this.match('-') || this.match('~') || this.match('!') || - this.matchKeyword('delete') || this.matchKeyword('void') || this.matchKeyword('typeof')) { - var node = this.startNode(this.lookahead); - var token = this.nextToken(); - expr = this.inheritCoverGrammar(this.parseUnaryExpression); - expr = this.finalize(node, new Node.UnaryExpression(token.value, expr)); - if (this.context.strict && expr.operator === 'delete' && expr.argument.type === syntax_1.Syntax.Identifier) { - this.tolerateError(messages_1.Messages.StrictDelete); - } - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - } - else { - expr = this.parseUpdateExpression(); - } - return expr; - }; - Parser.prototype.parseExponentiationExpression = function () { - var startToken = this.lookahead; - var expr = this.inheritCoverGrammar(this.parseUnaryExpression); - if (expr.type !== syntax_1.Syntax.UnaryExpression && this.match('**')) { - this.nextToken(); - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - var left = expr; - var right = this.isolateCoverGrammar(this.parseExponentiationExpression); - expr = this.finalize(this.startNode(startToken), new Node.BinaryExpression('**', left, right)); - } - return expr; - }; - // ECMA-262 12.6 Exponentiation Operators - // ECMA-262 12.7 Multiplicative Operators - // ECMA-262 12.8 Additive Operators - // ECMA-262 12.9 Bitwise Shift Operators - // ECMA-262 12.10 Relational Operators - // ECMA-262 12.11 Equality Operators - // ECMA-262 12.12 Binary Bitwise Operators - // ECMA-262 12.13 Binary Logical Operators - Parser.prototype.binaryPrecedence = function (token) { - var op = token.value; - var precedence; - if (token.type === token_1.Token.Punctuator) { - precedence = this.operatorPrecedence[op] || 0; - } - else if (token.type === token_1.Token.Keyword) { - precedence = (op === 'instanceof' || (this.context.allowIn && op === 'in')) ? 7 : 0; - } - else { - precedence = 0; - } - return precedence; - }; - Parser.prototype.parseBinaryExpression = function () { - var startToken = this.lookahead; - var expr = this.inheritCoverGrammar(this.parseExponentiationExpression); - var token = this.lookahead; - var prec = this.binaryPrecedence(token); - if (prec > 0) { - this.nextToken(); - token.prec = prec; - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - var markers = [startToken, this.lookahead]; - var left = expr; - var right = this.isolateCoverGrammar(this.parseExponentiationExpression); - var stack = [left, token, right]; - while (true) { - prec = this.binaryPrecedence(this.lookahead); - if (prec <= 0) { - break; - } - // Reduce: make a binary expression from the three topmost entries. - while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { - right = stack.pop(); - var operator = stack.pop().value; - left = stack.pop(); - markers.pop(); - var node = this.startNode(markers[markers.length - 1]); - stack.push(this.finalize(node, new Node.BinaryExpression(operator, left, right))); - } - // Shift. - token = this.nextToken(); - token.prec = prec; - stack.push(token); - markers.push(this.lookahead); - stack.push(this.isolateCoverGrammar(this.parseExponentiationExpression)); - } - // Final reduce to clean-up the stack. - var i = stack.length - 1; - expr = stack[i]; - markers.pop(); - while (i > 1) { - var node = this.startNode(markers.pop()); - expr = this.finalize(node, new Node.BinaryExpression(stack[i - 1].value, stack[i - 2], expr)); - i -= 2; - } - } - return expr; - }; - // ECMA-262 12.14 Conditional Operator - Parser.prototype.parseConditionalExpression = function () { - var startToken = this.lookahead; - var expr = this.inheritCoverGrammar(this.parseBinaryExpression); - if (this.match('?')) { - this.nextToken(); - var previousAllowIn = this.context.allowIn; - this.context.allowIn = true; - var consequent = this.isolateCoverGrammar(this.parseAssignmentExpression); - this.context.allowIn = previousAllowIn; - this.expect(':'); - var alternate = this.isolateCoverGrammar(this.parseAssignmentExpression); - expr = this.finalize(this.startNode(startToken), new Node.ConditionalExpression(expr, consequent, alternate)); - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - } - return expr; - }; - // ECMA-262 12.15 Assignment Operators - Parser.prototype.checkPatternParam = function (options, param) { - switch (param.type) { - case syntax_1.Syntax.Identifier: - this.validateParam(options, param, param.name); - break; - case syntax_1.Syntax.RestElement: - this.checkPatternParam(options, param.argument); - break; - case syntax_1.Syntax.AssignmentPattern: - this.checkPatternParam(options, param.left); - break; - case syntax_1.Syntax.ArrayPattern: - for (var i = 0; i < param.elements.length; i++) { - if (param.elements[i] !== null) { - this.checkPatternParam(options, param.elements[i]); - } - } - break; - case syntax_1.Syntax.YieldExpression: - break; - default: - assert_1.assert(param.type === syntax_1.Syntax.ObjectPattern, 'Invalid type'); - for (var i = 0; i < param.properties.length; i++) { - this.checkPatternParam(options, param.properties[i].value); - } - break; - } - }; - Parser.prototype.reinterpretAsCoverFormalsList = function (expr) { - var params = [expr]; - var options; - switch (expr.type) { - case syntax_1.Syntax.Identifier: - break; - case ArrowParameterPlaceHolder: - params = expr.params; - break; - default: - return null; - } - options = { - paramSet: {} - }; - for (var i = 0; i < params.length; ++i) { - var param = params[i]; - if (param.type === syntax_1.Syntax.AssignmentPattern) { - if (param.right.type === syntax_1.Syntax.YieldExpression) { - if (param.right.argument) { - this.throwUnexpectedToken(this.lookahead); - } - param.right.type = syntax_1.Syntax.Identifier; - param.right.name = 'yield'; - delete param.right.argument; - delete param.right.delegate; - } - } - this.checkPatternParam(options, param); - params[i] = param; - } - if (this.context.strict || !this.context.allowYield) { - for (var i = 0; i < params.length; ++i) { - var param = params[i]; - if (param.type === syntax_1.Syntax.YieldExpression) { - this.throwUnexpectedToken(this.lookahead); - } - } - } - if (options.message === messages_1.Messages.StrictParamDupe) { - var token = this.context.strict ? options.stricted : options.firstRestricted; - this.throwUnexpectedToken(token, options.message); - } - return { - params: params, - stricted: options.stricted, - firstRestricted: options.firstRestricted, - message: options.message - }; - }; - Parser.prototype.parseAssignmentExpression = function () { - var expr; - if (!this.context.allowYield && this.matchKeyword('yield')) { - expr = this.parseYieldExpression(); - } - else { - var startToken = this.lookahead; - var token = startToken; - expr = this.parseConditionalExpression(); - if (expr.type === ArrowParameterPlaceHolder || this.match('=>')) { - // ECMA-262 14.2 Arrow Function Definitions - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - var list = this.reinterpretAsCoverFormalsList(expr); - if (list) { - if (this.hasLineTerminator) { - this.tolerateUnexpectedToken(this.lookahead); - } - this.context.firstCoverInitializedNameError = null; - var previousStrict = this.context.strict; - var previousAllowYield = this.context.allowYield; - this.context.allowYield = true; - var node = this.startNode(startToken); - this.expect('=>'); - var body = this.match('{') ? this.parseFunctionSourceElements() : - this.isolateCoverGrammar(this.parseAssignmentExpression); - var expression = body.type !== syntax_1.Syntax.BlockStatement; - if (this.context.strict && list.firstRestricted) { - this.throwUnexpectedToken(list.firstRestricted, list.message); - } - if (this.context.strict && list.stricted) { - this.tolerateUnexpectedToken(list.stricted, list.message); - } - expr = this.finalize(node, new Node.ArrowFunctionExpression(list.params, body, expression)); - this.context.strict = previousStrict; - this.context.allowYield = previousAllowYield; - } - } - else { - if (this.matchAssign()) { - if (!this.context.isAssignmentTarget) { - this.tolerateError(messages_1.Messages.InvalidLHSInAssignment); - } - if (this.context.strict && expr.type === syntax_1.Syntax.Identifier) { - var id = (expr); - if (this.scanner.isRestrictedWord(id.name)) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictLHSAssignment); - } - if (this.scanner.isStrictModeReservedWord(id.name)) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord); - } - } - if (!this.match('=')) { - this.context.isAssignmentTarget = false; - this.context.isBindingElement = false; - } - else { - this.reinterpretExpressionAsPattern(expr); - } - token = this.nextToken(); - var right = this.isolateCoverGrammar(this.parseAssignmentExpression); - expr = this.finalize(this.startNode(startToken), new Node.AssignmentExpression(token.value, expr, right)); - this.context.firstCoverInitializedNameError = null; - } - } - } - return expr; - }; - // ECMA-262 12.16 Comma Operator - Parser.prototype.parseExpression = function () { - var startToken = this.lookahead; - var expr = this.isolateCoverGrammar(this.parseAssignmentExpression); - if (this.match(',')) { - var expressions = []; - expressions.push(expr); - while (this.startMarker.index < this.scanner.length) { - if (!this.match(',')) { - break; - } - this.nextToken(); - expressions.push(this.isolateCoverGrammar(this.parseAssignmentExpression)); - } - expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions)); - } - return expr; - }; - // ECMA-262 13.2 Block - Parser.prototype.parseStatementListItem = function () { - var statement = null; - this.context.isAssignmentTarget = true; - this.context.isBindingElement = true; - if (this.lookahead.type === token_1.Token.Keyword) { - switch (this.lookahead.value) { - case 'export': - if (this.sourceType !== 'module') { - this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalExportDeclaration); - } - statement = this.parseExportDeclaration(); - break; - case 'import': - if (this.sourceType !== 'module') { - this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalImportDeclaration); - } - statement = this.parseImportDeclaration(); - break; - case 'const': - statement = this.parseLexicalDeclaration({ inFor: false }); - break; - case 'function': - statement = this.parseFunctionDeclaration(); - break; - case 'class': - statement = this.parseClassDeclaration(); - break; - case 'let': - statement = this.isLexicalDeclaration() ? this.parseLexicalDeclaration({ inFor: false }) : this.parseStatement(); - break; - default: - statement = this.parseStatement(); - break; - } - } - else { - statement = this.parseStatement(); - } - return statement; - }; - Parser.prototype.parseBlock = function () { - var node = this.createNode(); - this.expect('{'); - var block = []; - while (true) { - if (this.match('}')) { - break; - } - block.push(this.parseStatementListItem()); - } - this.expect('}'); - return this.finalize(node, new Node.BlockStatement(block)); - }; - // ECMA-262 13.3.1 Let and Const Declarations - Parser.prototype.parseLexicalBinding = function (kind, options) { - var node = this.createNode(); - var params = []; - var id = this.parsePattern(params, kind); - // ECMA-262 12.2.1 - if (this.context.strict && id.type === syntax_1.Syntax.Identifier) { - if (this.scanner.isRestrictedWord((id).name)) { - this.tolerateError(messages_1.Messages.StrictVarName); - } - } - var init = null; - if (kind === 'const') { - if (!this.matchKeyword('in') && !this.matchContextualKeyword('of')) { - this.expect('='); - init = this.isolateCoverGrammar(this.parseAssignmentExpression); - } - } - else if ((!options.inFor && id.type !== syntax_1.Syntax.Identifier) || this.match('=')) { - this.expect('='); - init = this.isolateCoverGrammar(this.parseAssignmentExpression); - } - return this.finalize(node, new Node.VariableDeclarator(id, init)); - }; - Parser.prototype.parseBindingList = function (kind, options) { - var list = [this.parseLexicalBinding(kind, options)]; - while (this.match(',')) { - this.nextToken(); - list.push(this.parseLexicalBinding(kind, options)); - } - return list; - }; - Parser.prototype.isLexicalDeclaration = function () { - var previousIndex = this.scanner.index; - var previousLineNumber = this.scanner.lineNumber; - var previousLineStart = this.scanner.lineStart; - this.collectComments(); - var next = this.scanner.lex(); - this.scanner.index = previousIndex; - this.scanner.lineNumber = previousLineNumber; - this.scanner.lineStart = previousLineStart; - return (next.type === token_1.Token.Identifier) || - (next.type === token_1.Token.Punctuator && next.value === '[') || - (next.type === token_1.Token.Punctuator && next.value === '{') || - (next.type === token_1.Token.Keyword && next.value === 'let') || - (next.type === token_1.Token.Keyword && next.value === 'yield'); - }; - Parser.prototype.parseLexicalDeclaration = function (options) { - var node = this.createNode(); - var kind = this.nextToken().value; - assert_1.assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const'); - var declarations = this.parseBindingList(kind, options); - this.consumeSemicolon(); - return this.finalize(node, new Node.VariableDeclaration(declarations, kind)); - }; - // ECMA-262 13.3.3 Destructuring Binding Patterns - Parser.prototype.parseBindingRestElement = function (params, kind) { - var node = this.createNode(); - this.expect('...'); - var arg = this.parsePattern(params, kind); - return this.finalize(node, new Node.RestElement(arg)); - }; - Parser.prototype.parseArrayPattern = function (params, kind) { - var node = this.createNode(); - this.expect('['); - var elements = []; - while (!this.match(']')) { - if (this.match(',')) { - this.nextToken(); - elements.push(null); - } - else { - if (this.match('...')) { - elements.push(this.parseBindingRestElement(params, kind)); - break; - } - else { - elements.push(this.parsePatternWithDefault(params, kind)); - } - if (!this.match(']')) { - this.expect(','); - } - } - } - this.expect(']'); - return this.finalize(node, new Node.ArrayPattern(elements)); - }; - Parser.prototype.parsePropertyPattern = function (params, kind) { - var node = this.createNode(); - var computed = false; - var shorthand = false; - var method = false; - var key; - var value; - if (this.lookahead.type === token_1.Token.Identifier) { - var keyToken = this.lookahead; - key = this.parseVariableIdentifier(); - var init = this.finalize(node, new Node.Identifier(keyToken.value)); - if (this.match('=')) { - params.push(keyToken); - shorthand = true; - this.nextToken(); - var expr = this.parseAssignmentExpression(); - value = this.finalize(this.startNode(keyToken), new Node.AssignmentPattern(init, expr)); - } - else if (!this.match(':')) { - params.push(keyToken); - shorthand = true; - value = init; - } - else { - this.expect(':'); - value = this.parsePatternWithDefault(params, kind); - } - } - else { - computed = this.match('['); - key = this.parseObjectPropertyKey(); - this.expect(':'); - value = this.parsePatternWithDefault(params, kind); - } - return this.finalize(node, new Node.Property('init', key, computed, value, method, shorthand)); - }; - Parser.prototype.parseObjectPattern = function (params, kind) { - var node = this.createNode(); - var properties = []; - this.expect('{'); - while (!this.match('}')) { - properties.push(this.parsePropertyPattern(params, kind)); - if (!this.match('}')) { - this.expect(','); - } - } - this.expect('}'); - return this.finalize(node, new Node.ObjectPattern(properties)); - }; - Parser.prototype.parsePattern = function (params, kind) { - var pattern; - if (this.match('[')) { - pattern = this.parseArrayPattern(params, kind); - } - else if (this.match('{')) { - pattern = this.parseObjectPattern(params, kind); - } - else { - if (this.matchKeyword('let') && (kind === 'const' || kind === 'let')) { - this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.UnexpectedToken); - } - params.push(this.lookahead); - pattern = this.parseVariableIdentifier(kind); - } - return pattern; - }; - Parser.prototype.parsePatternWithDefault = function (params, kind) { - var startToken = this.lookahead; - var pattern = this.parsePattern(params, kind); - if (this.match('=')) { - this.nextToken(); - var previousAllowYield = this.context.allowYield; - this.context.allowYield = true; - var right = this.isolateCoverGrammar(this.parseAssignmentExpression); - this.context.allowYield = previousAllowYield; - pattern = this.finalize(this.startNode(startToken), new Node.AssignmentPattern(pattern, right)); - } - return pattern; - }; - // ECMA-262 13.3.2 Variable Statement - Parser.prototype.parseVariableIdentifier = function (kind) { - var node = this.createNode(); - var token = this.nextToken(); - if (token.type === token_1.Token.Keyword && token.value === 'yield') { - if (this.context.strict) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord); - } - if (!this.context.allowYield) { - this.throwUnexpectedToken(token); - } - } - else if (token.type !== token_1.Token.Identifier) { - if (this.context.strict && token.type === token_1.Token.Keyword && this.scanner.isStrictModeReservedWord(token.value)) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord); - } - else { - if (this.context.strict || token.value !== 'let' || kind !== 'var') { - this.throwUnexpectedToken(token); - } - } - } - else if (this.sourceType === 'module' && token.type === token_1.Token.Identifier && token.value === 'await') { - this.tolerateUnexpectedToken(token); - } - return this.finalize(node, new Node.Identifier(token.value)); - }; - Parser.prototype.parseVariableDeclaration = function (options) { - var node = this.createNode(); - var params = []; - var id = this.parsePattern(params, 'var'); - // ECMA-262 12.2.1 - if (this.context.strict && id.type === syntax_1.Syntax.Identifier) { - if (this.scanner.isRestrictedWord((id).name)) { - this.tolerateError(messages_1.Messages.StrictVarName); - } - } - var init = null; - if (this.match('=')) { - this.nextToken(); - init = this.isolateCoverGrammar(this.parseAssignmentExpression); - } - else if (id.type !== syntax_1.Syntax.Identifier && !options.inFor) { - this.expect('='); - } - return this.finalize(node, new Node.VariableDeclarator(id, init)); - }; - Parser.prototype.parseVariableDeclarationList = function (options) { - var opt = { inFor: options.inFor }; - var list = []; - list.push(this.parseVariableDeclaration(opt)); - while (this.match(',')) { - this.nextToken(); - list.push(this.parseVariableDeclaration(opt)); - } - return list; - }; - Parser.prototype.parseVariableStatement = function () { - var node = this.createNode(); - this.expectKeyword('var'); - var declarations = this.parseVariableDeclarationList({ inFor: false }); - this.consumeSemicolon(); - return this.finalize(node, new Node.VariableDeclaration(declarations, 'var')); - }; - // ECMA-262 13.4 Empty Statement - Parser.prototype.parseEmptyStatement = function () { - var node = this.createNode(); - this.expect(';'); - return this.finalize(node, new Node.EmptyStatement()); - }; - // ECMA-262 13.5 Expression Statement - Parser.prototype.parseExpressionStatement = function () { - var node = this.createNode(); - var expr = this.parseExpression(); - this.consumeSemicolon(); - return this.finalize(node, new Node.ExpressionStatement(expr)); - }; - // ECMA-262 13.6 If statement - Parser.prototype.parseIfStatement = function () { - var node = this.createNode(); - var consequent; - var alternate = null; - this.expectKeyword('if'); - this.expect('('); - var test = this.parseExpression(); - if (!this.match(')') && this.config.tolerant) { - this.tolerateUnexpectedToken(this.nextToken()); - consequent = this.finalize(this.createNode(), new Node.EmptyStatement()); - } - else { - this.expect(')'); - consequent = this.parseStatement(); - if (this.matchKeyword('else')) { - this.nextToken(); - alternate = this.parseStatement(); - } - } - return this.finalize(node, new Node.IfStatement(test, consequent, alternate)); - }; - // ECMA-262 13.7.2 The do-while Statement - Parser.prototype.parseDoWhileStatement = function () { - var node = this.createNode(); - this.expectKeyword('do'); - var previousInIteration = this.context.inIteration; - this.context.inIteration = true; - var body = this.parseStatement(); - this.context.inIteration = previousInIteration; - this.expectKeyword('while'); - this.expect('('); - var test = this.parseExpression(); - this.expect(')'); - if (this.match(';')) { - this.nextToken(); - } - return this.finalize(node, new Node.DoWhileStatement(body, test)); - }; - // ECMA-262 13.7.3 The while Statement - Parser.prototype.parseWhileStatement = function () { - var node = this.createNode(); - var body; - this.expectKeyword('while'); - this.expect('('); - var test = this.parseExpression(); - if (!this.match(')') && this.config.tolerant) { - this.tolerateUnexpectedToken(this.nextToken()); - body = this.finalize(this.createNode(), new Node.EmptyStatement()); - } - else { - this.expect(')'); - var previousInIteration = this.context.inIteration; - this.context.inIteration = true; - body = this.parseStatement(); - this.context.inIteration = previousInIteration; - } - return this.finalize(node, new Node.WhileStatement(test, body)); - }; - // ECMA-262 13.7.4 The for Statement - // ECMA-262 13.7.5 The for-in and for-of Statements - Parser.prototype.parseForStatement = function () { - var init = null; - var test = null; - var update = null; - var forIn = true; - var left, right; - var node = this.createNode(); - this.expectKeyword('for'); - this.expect('('); - if (this.match(';')) { - this.nextToken(); - } - else { - if (this.matchKeyword('var')) { - init = this.createNode(); - this.nextToken(); - var previousAllowIn = this.context.allowIn; - this.context.allowIn = false; - var declarations = this.parseVariableDeclarationList({ inFor: true }); - this.context.allowIn = previousAllowIn; - if (declarations.length === 1 && this.matchKeyword('in')) { - var decl = declarations[0]; - if (decl.init && (decl.id.type === syntax_1.Syntax.ArrayPattern || decl.id.type === syntax_1.Syntax.ObjectPattern || this.context.strict)) { - this.tolerateError(messages_1.Messages.ForInOfLoopInitializer, 'for-in'); - } - init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var')); - this.nextToken(); - left = init; - right = this.parseExpression(); - init = null; - } - else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) { - init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var')); - this.nextToken(); - left = init; - right = this.parseAssignmentExpression(); - init = null; - forIn = false; - } - else { - init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var')); - this.expect(';'); - } - } - else if (this.matchKeyword('const') || this.matchKeyword('let')) { - init = this.createNode(); - var kind = this.nextToken().value; - if (!this.context.strict && this.lookahead.value === 'in') { - init = this.finalize(init, new Node.Identifier(kind)); - this.nextToken(); - left = init; - right = this.parseExpression(); - init = null; - } - else { - var previousAllowIn = this.context.allowIn; - this.context.allowIn = false; - var declarations = this.parseBindingList(kind, { inFor: true }); - this.context.allowIn = previousAllowIn; - if (declarations.length === 1 && declarations[0].init === null && this.matchKeyword('in')) { - init = this.finalize(init, new Node.VariableDeclaration(declarations, kind)); - this.nextToken(); - left = init; - right = this.parseExpression(); - init = null; - } - else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) { - init = this.finalize(init, new Node.VariableDeclaration(declarations, kind)); - this.nextToken(); - left = init; - right = this.parseAssignmentExpression(); - init = null; - forIn = false; - } - else { - this.consumeSemicolon(); - init = this.finalize(init, new Node.VariableDeclaration(declarations, kind)); - } - } - } - else { - var initStartToken = this.lookahead; - var previousAllowIn = this.context.allowIn; - this.context.allowIn = false; - init = this.inheritCoverGrammar(this.parseAssignmentExpression); - this.context.allowIn = previousAllowIn; - if (this.matchKeyword('in')) { - if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) { - this.tolerateError(messages_1.Messages.InvalidLHSInForIn); - } - this.nextToken(); - this.reinterpretExpressionAsPattern(init); - left = init; - right = this.parseExpression(); - init = null; - } - else if (this.matchContextualKeyword('of')) { - if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) { - this.tolerateError(messages_1.Messages.InvalidLHSInForLoop); - } - this.nextToken(); - this.reinterpretExpressionAsPattern(init); - left = init; - right = this.parseAssignmentExpression(); - init = null; - forIn = false; - } - else { - if (this.match(',')) { - var initSeq = [init]; - while (this.match(',')) { - this.nextToken(); - initSeq.push(this.isolateCoverGrammar(this.parseAssignmentExpression)); - } - init = this.finalize(this.startNode(initStartToken), new Node.SequenceExpression(initSeq)); - } - this.expect(';'); - } - } - } - if (typeof left === 'undefined') { - if (!this.match(';')) { - test = this.parseExpression(); - } - this.expect(';'); - if (!this.match(')')) { - update = this.parseExpression(); - } - } - var body; - if (!this.match(')') && this.config.tolerant) { - this.tolerateUnexpectedToken(this.nextToken()); - body = this.finalize(this.createNode(), new Node.EmptyStatement()); - } - else { - this.expect(')'); - var previousInIteration = this.context.inIteration; - this.context.inIteration = true; - body = this.isolateCoverGrammar(this.parseStatement); - this.context.inIteration = previousInIteration; - } - return (typeof left === 'undefined') ? - this.finalize(node, new Node.ForStatement(init, test, update, body)) : - forIn ? this.finalize(node, new Node.ForInStatement(left, right, body)) : - this.finalize(node, new Node.ForOfStatement(left, right, body)); - }; - // ECMA-262 13.8 The continue statement - Parser.prototype.parseContinueStatement = function () { - var node = this.createNode(); - this.expectKeyword('continue'); - var label = null; - if (this.lookahead.type === token_1.Token.Identifier && !this.hasLineTerminator) { - label = this.parseVariableIdentifier(); - var key = '$' + label.name; - if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) { - this.throwError(messages_1.Messages.UnknownLabel, label.name); - } - } - this.consumeSemicolon(); - if (label === null && !this.context.inIteration) { - this.throwError(messages_1.Messages.IllegalContinue); - } - return this.finalize(node, new Node.ContinueStatement(label)); - }; - // ECMA-262 13.9 The break statement - Parser.prototype.parseBreakStatement = function () { - var node = this.createNode(); - this.expectKeyword('break'); - var label = null; - if (this.lookahead.type === token_1.Token.Identifier && !this.hasLineTerminator) { - label = this.parseVariableIdentifier(); - var key = '$' + label.name; - if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) { - this.throwError(messages_1.Messages.UnknownLabel, label.name); - } - } - this.consumeSemicolon(); - if (label === null && !this.context.inIteration && !this.context.inSwitch) { - this.throwError(messages_1.Messages.IllegalBreak); - } - return this.finalize(node, new Node.BreakStatement(label)); - }; - // ECMA-262 13.10 The return statement - Parser.prototype.parseReturnStatement = function () { - if (!this.context.inFunctionBody) { - this.tolerateError(messages_1.Messages.IllegalReturn); - } - var node = this.createNode(); - this.expectKeyword('return'); - var hasArgument = !this.match(';') && !this.match('}') && - !this.hasLineTerminator && this.lookahead.type !== token_1.Token.EOF; - var argument = hasArgument ? this.parseExpression() : null; - this.consumeSemicolon(); - return this.finalize(node, new Node.ReturnStatement(argument)); - }; - // ECMA-262 13.11 The with statement - Parser.prototype.parseWithStatement = function () { - if (this.context.strict) { - this.tolerateError(messages_1.Messages.StrictModeWith); - } - var node = this.createNode(); - this.expectKeyword('with'); - this.expect('('); - var object = this.parseExpression(); - this.expect(')'); - var body = this.parseStatement(); - return this.finalize(node, new Node.WithStatement(object, body)); - }; - // ECMA-262 13.12 The switch statement - Parser.prototype.parseSwitchCase = function () { - var node = this.createNode(); - var test; - if (this.matchKeyword('default')) { - this.nextToken(); - test = null; - } - else { - this.expectKeyword('case'); - test = this.parseExpression(); - } - this.expect(':'); - var consequent = []; - while (true) { - if (this.match('}') || this.matchKeyword('default') || this.matchKeyword('case')) { - break; - } - consequent.push(this.parseStatementListItem()); - } - return this.finalize(node, new Node.SwitchCase(test, consequent)); - }; - Parser.prototype.parseSwitchStatement = function () { - var node = this.createNode(); - this.expectKeyword('switch'); - this.expect('('); - var discriminant = this.parseExpression(); - this.expect(')'); - var previousInSwitch = this.context.inSwitch; - this.context.inSwitch = true; - var cases = []; - var defaultFound = false; - this.expect('{'); - while (true) { - if (this.match('}')) { - break; - } - var clause = this.parseSwitchCase(); - if (clause.test === null) { - if (defaultFound) { - this.throwError(messages_1.Messages.MultipleDefaultsInSwitch); - } - defaultFound = true; - } - cases.push(clause); - } - this.expect('}'); - this.context.inSwitch = previousInSwitch; - return this.finalize(node, new Node.SwitchStatement(discriminant, cases)); - }; - // ECMA-262 13.13 Labelled Statements - Parser.prototype.parseLabelledStatement = function () { - var node = this.createNode(); - var expr = this.parseExpression(); - var statement; - if ((expr.type === syntax_1.Syntax.Identifier) && this.match(':')) { - this.nextToken(); - var id = (expr); - var key = '$' + id.name; - if (Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) { - this.throwError(messages_1.Messages.Redeclaration, 'Label', id.name); - } - this.context.labelSet[key] = true; - var labeledBody = this.parseStatement(); - delete this.context.labelSet[key]; - statement = new Node.LabeledStatement(id, labeledBody); - } - else { - this.consumeSemicolon(); - statement = new Node.ExpressionStatement(expr); - } - return this.finalize(node, statement); - }; - // ECMA-262 13.14 The throw statement - Parser.prototype.parseThrowStatement = function () { - var node = this.createNode(); - this.expectKeyword('throw'); - if (this.hasLineTerminator) { - this.throwError(messages_1.Messages.NewlineAfterThrow); - } - var argument = this.parseExpression(); - this.consumeSemicolon(); - return this.finalize(node, new Node.ThrowStatement(argument)); - }; - // ECMA-262 13.15 The try statement - Parser.prototype.parseCatchClause = function () { - var node = this.createNode(); - this.expectKeyword('catch'); - this.expect('('); - if (this.match(')')) { - this.throwUnexpectedToken(this.lookahead); - } - var params = []; - var param = this.parsePattern(params); - var paramMap = {}; - for (var i = 0; i < params.length; i++) { - var key = '$' + params[i].value; - if (Object.prototype.hasOwnProperty.call(paramMap, key)) { - this.tolerateError(messages_1.Messages.DuplicateBinding, params[i].value); - } - paramMap[key] = true; - } - if (this.context.strict && param.type === syntax_1.Syntax.Identifier) { - if (this.scanner.isRestrictedWord((param).name)) { - this.tolerateError(messages_1.Messages.StrictCatchVariable); - } - } - this.expect(')'); - var body = this.parseBlock(); - return this.finalize(node, new Node.CatchClause(param, body)); - }; - Parser.prototype.parseFinallyClause = function () { - this.expectKeyword('finally'); - return this.parseBlock(); - }; - Parser.prototype.parseTryStatement = function () { - var node = this.createNode(); - this.expectKeyword('try'); - var block = this.parseBlock(); - var handler = this.matchKeyword('catch') ? this.parseCatchClause() : null; - var finalizer = this.matchKeyword('finally') ? this.parseFinallyClause() : null; - if (!handler && !finalizer) { - this.throwError(messages_1.Messages.NoCatchOrFinally); - } - return this.finalize(node, new Node.TryStatement(block, handler, finalizer)); - }; - // ECMA-262 13.16 The debugger statement - Parser.prototype.parseDebuggerStatement = function () { - var node = this.createNode(); - this.expectKeyword('debugger'); - this.consumeSemicolon(); - return this.finalize(node, new Node.DebuggerStatement()); - }; - // ECMA-262 13 Statements - Parser.prototype.parseStatement = function () { - var statement = null; - switch (this.lookahead.type) { - case token_1.Token.BooleanLiteral: - case token_1.Token.NullLiteral: - case token_1.Token.NumericLiteral: - case token_1.Token.StringLiteral: - case token_1.Token.Template: - case token_1.Token.RegularExpression: - statement = this.parseExpressionStatement(); - break; - case token_1.Token.Punctuator: - var value = this.lookahead.value; - if (value === '{') { - statement = this.parseBlock(); - } - else if (value === '(') { - statement = this.parseExpressionStatement(); - } - else if (value === ';') { - statement = this.parseEmptyStatement(); - } - else { - statement = this.parseExpressionStatement(); - } - break; - case token_1.Token.Identifier: - statement = this.parseLabelledStatement(); - break; - case token_1.Token.Keyword: - switch (this.lookahead.value) { - case 'break': - statement = this.parseBreakStatement(); - break; - case 'continue': - statement = this.parseContinueStatement(); - break; - case 'debugger': - statement = this.parseDebuggerStatement(); - break; - case 'do': - statement = this.parseDoWhileStatement(); - break; - case 'for': - statement = this.parseForStatement(); - break; - case 'function': - statement = this.parseFunctionDeclaration(); - break; - case 'if': - statement = this.parseIfStatement(); - break; - case 'return': - statement = this.parseReturnStatement(); - break; - case 'switch': - statement = this.parseSwitchStatement(); - break; - case 'throw': - statement = this.parseThrowStatement(); - break; - case 'try': - statement = this.parseTryStatement(); - break; - case 'var': - statement = this.parseVariableStatement(); - break; - case 'while': - statement = this.parseWhileStatement(); - break; - case 'with': - statement = this.parseWithStatement(); - break; - default: - statement = this.parseExpressionStatement(); - break; - } - break; - default: - this.throwUnexpectedToken(this.lookahead); - } - return statement; - }; - // ECMA-262 14.1 Function Definition - Parser.prototype.parseFunctionSourceElements = function () { - var node = this.createNode(); - this.expect('{'); - var body = this.parseDirectivePrologues(); - var previousLabelSet = this.context.labelSet; - var previousInIteration = this.context.inIteration; - var previousInSwitch = this.context.inSwitch; - var previousInFunctionBody = this.context.inFunctionBody; - this.context.labelSet = {}; - this.context.inIteration = false; - this.context.inSwitch = false; - this.context.inFunctionBody = true; - while (this.startMarker.index < this.scanner.length) { - if (this.match('}')) { - break; - } - body.push(this.parseStatementListItem()); - } - this.expect('}'); - this.context.labelSet = previousLabelSet; - this.context.inIteration = previousInIteration; - this.context.inSwitch = previousInSwitch; - this.context.inFunctionBody = previousInFunctionBody; - return this.finalize(node, new Node.BlockStatement(body)); - }; - Parser.prototype.validateParam = function (options, param, name) { - var key = '$' + name; - if (this.context.strict) { - if (this.scanner.isRestrictedWord(name)) { - options.stricted = param; - options.message = messages_1.Messages.StrictParamName; - } - if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) { - options.stricted = param; - options.message = messages_1.Messages.StrictParamDupe; - } - } - else if (!options.firstRestricted) { - if (this.scanner.isRestrictedWord(name)) { - options.firstRestricted = param; - options.message = messages_1.Messages.StrictParamName; - } - else if (this.scanner.isStrictModeReservedWord(name)) { - options.firstRestricted = param; - options.message = messages_1.Messages.StrictReservedWord; - } - else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) { - options.stricted = param; - options.message = messages_1.Messages.StrictParamDupe; - } - } - /* istanbul ignore next */ - if (typeof Object.defineProperty === 'function') { - Object.defineProperty(options.paramSet, key, { value: true, enumerable: true, writable: true, configurable: true }); - } - else { - options.paramSet[key] = true; - } - }; - Parser.prototype.parseRestElement = function (params) { - var node = this.createNode(); - this.expect('...'); - var arg = this.parsePattern(params); - if (this.match('=')) { - this.throwError(messages_1.Messages.DefaultRestParameter); - } - if (!this.match(')')) { - this.throwError(messages_1.Messages.ParameterAfterRestParameter); - } - return this.finalize(node, new Node.RestElement(arg)); - }; - Parser.prototype.parseFormalParameter = function (options) { - var params = []; - var param = this.match('...') ? this.parseRestElement(params) : this.parsePatternWithDefault(params); - for (var i = 0; i < params.length; i++) { - this.validateParam(options, params[i], params[i].value); - } - options.params.push(param); - return !this.match(')'); - }; - Parser.prototype.parseFormalParameters = function (firstRestricted) { - var options; - options = { - params: [], - firstRestricted: firstRestricted - }; - this.expect('('); - if (!this.match(')')) { - options.paramSet = {}; - while (this.startMarker.index < this.scanner.length) { - if (!this.parseFormalParameter(options)) { - break; - } - this.expect(','); - } - } - this.expect(')'); - return { - params: options.params, - stricted: options.stricted, - firstRestricted: options.firstRestricted, - message: options.message - }; - }; - Parser.prototype.parseFunctionDeclaration = function (identifierIsOptional) { - var node = this.createNode(); - this.expectKeyword('function'); - var isGenerator = this.match('*'); - if (isGenerator) { - this.nextToken(); - } - var message; - var id = null; - var firstRestricted = null; - if (!identifierIsOptional || !this.match('(')) { - var token = this.lookahead; - id = this.parseVariableIdentifier(); - if (this.context.strict) { - if (this.scanner.isRestrictedWord(token.value)) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName); - } - } - else { - if (this.scanner.isRestrictedWord(token.value)) { - firstRestricted = token; - message = messages_1.Messages.StrictFunctionName; - } - else if (this.scanner.isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = messages_1.Messages.StrictReservedWord; - } - } - } - var previousAllowYield = this.context.allowYield; - this.context.allowYield = !isGenerator; - var formalParameters = this.parseFormalParameters(firstRestricted); - var params = formalParameters.params; - var stricted = formalParameters.stricted; - firstRestricted = formalParameters.firstRestricted; - if (formalParameters.message) { - message = formalParameters.message; - } - var previousStrict = this.context.strict; - var body = this.parseFunctionSourceElements(); - if (this.context.strict && firstRestricted) { - this.throwUnexpectedToken(firstRestricted, message); - } - if (this.context.strict && stricted) { - this.tolerateUnexpectedToken(stricted, message); - } - this.context.strict = previousStrict; - this.context.allowYield = previousAllowYield; - return this.finalize(node, new Node.FunctionDeclaration(id, params, body, isGenerator)); - }; - Parser.prototype.parseFunctionExpression = function () { - var node = this.createNode(); - this.expectKeyword('function'); - var isGenerator = this.match('*'); - if (isGenerator) { - this.nextToken(); - } - var message; - var id = null; - var firstRestricted; - var previousAllowYield = this.context.allowYield; - this.context.allowYield = !isGenerator; - if (!this.match('(')) { - var token = this.lookahead; - id = (!this.context.strict && !isGenerator && this.matchKeyword('yield')) ? this.parseIdentifierName() : this.parseVariableIdentifier(); - if (this.context.strict) { - if (this.scanner.isRestrictedWord(token.value)) { - this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName); - } - } - else { - if (this.scanner.isRestrictedWord(token.value)) { - firstRestricted = token; - message = messages_1.Messages.StrictFunctionName; - } - else if (this.scanner.isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = messages_1.Messages.StrictReservedWord; - } - } - } - var formalParameters = this.parseFormalParameters(firstRestricted); - var params = formalParameters.params; - var stricted = formalParameters.stricted; - firstRestricted = formalParameters.firstRestricted; - if (formalParameters.message) { - message = formalParameters.message; - } - var previousStrict = this.context.strict; - var body = this.parseFunctionSourceElements(); - if (this.context.strict && firstRestricted) { - this.throwUnexpectedToken(firstRestricted, message); - } - if (this.context.strict && stricted) { - this.tolerateUnexpectedToken(stricted, message); - } - this.context.strict = previousStrict; - this.context.allowYield = previousAllowYield; - return this.finalize(node, new Node.FunctionExpression(id, params, body, isGenerator)); - }; - // ECMA-262 14.1.1 Directive Prologues - Parser.prototype.parseDirective = function () { - var token = this.lookahead; - var directive = null; - var node = this.createNode(); - var expr = this.parseExpression(); - if (expr.type === syntax_1.Syntax.Literal) { - directive = this.getTokenRaw(token).slice(1, -1); - } - this.consumeSemicolon(); - return this.finalize(node, directive ? new Node.Directive(expr, directive) : - new Node.ExpressionStatement(expr)); - }; - Parser.prototype.parseDirectivePrologues = function () { - var firstRestricted = null; - var body = []; - while (true) { - var token = this.lookahead; - if (token.type !== token_1.Token.StringLiteral) { - break; - } - var statement = this.parseDirective(); - body.push(statement); - var directive = statement.directive; - if (typeof directive !== 'string') { - break; - } - if (directive === 'use strict') { - this.context.strict = true; - if (firstRestricted) { - this.tolerateUnexpectedToken(firstRestricted, messages_1.Messages.StrictOctalLiteral); - } - } - else { - if (!firstRestricted && token.octal) { - firstRestricted = token; - } - } - } - return body; - }; - // ECMA-262 14.3 Method Definitions - Parser.prototype.qualifiedPropertyName = function (token) { - switch (token.type) { - case token_1.Token.Identifier: - case token_1.Token.StringLiteral: - case token_1.Token.BooleanLiteral: - case token_1.Token.NullLiteral: - case token_1.Token.NumericLiteral: - case token_1.Token.Keyword: - return true; - case token_1.Token.Punctuator: - return token.value === '['; - } - return false; - }; - Parser.prototype.parseGetterMethod = function () { - var node = this.createNode(); - this.expect('('); - this.expect(')'); - var isGenerator = false; - var params = { - params: [], - stricted: null, - firstRestricted: null, - message: null - }; - var previousAllowYield = this.context.allowYield; - this.context.allowYield = false; - var method = this.parsePropertyMethod(params); - this.context.allowYield = previousAllowYield; - return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator)); - }; - Parser.prototype.parseSetterMethod = function () { - var node = this.createNode(); - var options = { - params: [], - firstRestricted: null, - paramSet: {} - }; - var isGenerator = false; - var previousAllowYield = this.context.allowYield; - this.context.allowYield = false; - this.expect('('); - if (this.match(')')) { - this.tolerateUnexpectedToken(this.lookahead); - } - else { - this.parseFormalParameter(options); - } - this.expect(')'); - var method = this.parsePropertyMethod(options); - this.context.allowYield = previousAllowYield; - return this.finalize(node, new Node.FunctionExpression(null, options.params, method, isGenerator)); - }; - Parser.prototype.parseGeneratorMethod = function () { - var node = this.createNode(); - var isGenerator = true; - var previousAllowYield = this.context.allowYield; - this.context.allowYield = true; - var params = this.parseFormalParameters(); - this.context.allowYield = false; - var method = this.parsePropertyMethod(params); - this.context.allowYield = previousAllowYield; - return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator)); - }; - // ECMA-262 14.4 Generator Function Definitions - Parser.prototype.isStartOfExpression = function () { - var start = true; - var value = this.lookahead.value; - switch (this.lookahead.type) { - case token_1.Token.Punctuator: - start = (value === '[') || (value === '(') || (value === '{') || - (value === '+') || (value === '-') || - (value === '!') || (value === '~') || - (value === '++') || (value === '--') || - (value === '/') || (value === '/='); // regular expression literal - break; - case token_1.Token.Keyword: - start = (value === 'class') || (value === 'delete') || - (value === 'function') || (value === 'let') || (value === 'new') || - (value === 'super') || (value === 'this') || (value === 'typeof') || - (value === 'void') || (value === 'yield'); - break; - default: - break; - } - return start; - }; - Parser.prototype.parseYieldExpression = function () { - var node = this.createNode(); - this.expectKeyword('yield'); - var argument = null; - var delegate = false; - if (!this.hasLineTerminator) { - var previousAllowYield = this.context.allowYield; - this.context.allowYield = false; - delegate = this.match('*'); - if (delegate) { - this.nextToken(); - argument = this.parseAssignmentExpression(); - } - else if (this.isStartOfExpression()) { - argument = this.parseAssignmentExpression(); - } - this.context.allowYield = previousAllowYield; - } - return this.finalize(node, new Node.YieldExpression(argument, delegate)); - }; - // ECMA-262 14.5 Class Definitions - Parser.prototype.parseClassElement = function (hasConstructor) { - var token = this.lookahead; - var node = this.createNode(); - var kind; - var key; - var value; - var computed = false; - var method = false; - var isStatic = false; - if (this.match('*')) { - this.nextToken(); - } - else { - computed = this.match('['); - key = this.parseObjectPropertyKey(); - var id = key; - if (id.name === 'static' && (this.qualifiedPropertyName(this.lookahead) || this.match('*'))) { - token = this.lookahead; - isStatic = true; - computed = this.match('['); - if (this.match('*')) { - this.nextToken(); - } - else { - key = this.parseObjectPropertyKey(); - } - } - } - var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead); - if (token.type === token_1.Token.Identifier) { - if (token.value === 'get' && lookaheadPropertyKey) { - kind = 'get'; - computed = this.match('['); - key = this.parseObjectPropertyKey(); - this.context.allowYield = false; - value = this.parseGetterMethod(); - } - else if (token.value === 'set' && lookaheadPropertyKey) { - kind = 'set'; - computed = this.match('['); - key = this.parseObjectPropertyKey(); - value = this.parseSetterMethod(); - } - } - else if (token.type === token_1.Token.Punctuator && token.value === '*' && lookaheadPropertyKey) { - kind = 'init'; - computed = this.match('['); - key = this.parseObjectPropertyKey(); - value = this.parseGeneratorMethod(); - method = true; - } - if (!kind && key && this.match('(')) { - kind = 'init'; - value = this.parsePropertyMethodFunction(); - method = true; - } - if (!kind) { - this.throwUnexpectedToken(this.lookahead); - } - if (kind === 'init') { - kind = 'method'; - } - if (!computed) { - if (isStatic && this.isPropertyKey(key, 'prototype')) { - this.throwUnexpectedToken(token, messages_1.Messages.StaticPrototype); - } - if (!isStatic && this.isPropertyKey(key, 'constructor')) { - if (kind !== 'method' || !method || value.generator) { - this.throwUnexpectedToken(token, messages_1.Messages.ConstructorSpecialMethod); - } - if (hasConstructor.value) { - this.throwUnexpectedToken(token, messages_1.Messages.DuplicateConstructor); - } - else { - hasConstructor.value = true; - } - kind = 'constructor'; - } - } - return this.finalize(node, new Node.MethodDefinition(key, computed, value, kind, isStatic)); - }; - Parser.prototype.parseClassElementList = function () { - var body = []; - var hasConstructor = { value: false }; - this.expect('{'); - while (!this.match('}')) { - if (this.match(';')) { - this.nextToken(); - } - else { - body.push(this.parseClassElement(hasConstructor)); - } - } - this.expect('}'); - return body; - }; - Parser.prototype.parseClassBody = function () { - var node = this.createNode(); - var elementList = this.parseClassElementList(); - return this.finalize(node, new Node.ClassBody(elementList)); - }; - Parser.prototype.parseClassDeclaration = function (identifierIsOptional) { - var node = this.createNode(); - var previousStrict = this.context.strict; - this.context.strict = true; - this.expectKeyword('class'); - var id = (identifierIsOptional && (this.lookahead.type !== token_1.Token.Identifier)) ? null : this.parseVariableIdentifier(); - var superClass = null; - if (this.matchKeyword('extends')) { - this.nextToken(); - superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall); - } - var classBody = this.parseClassBody(); - this.context.strict = previousStrict; - return this.finalize(node, new Node.ClassDeclaration(id, superClass, classBody)); - }; - Parser.prototype.parseClassExpression = function () { - var node = this.createNode(); - var previousStrict = this.context.strict; - this.context.strict = true; - this.expectKeyword('class'); - var id = (this.lookahead.type === token_1.Token.Identifier) ? this.parseVariableIdentifier() : null; - var superClass = null; - if (this.matchKeyword('extends')) { - this.nextToken(); - superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall); - } - var classBody = this.parseClassBody(); - this.context.strict = previousStrict; - return this.finalize(node, new Node.ClassExpression(id, superClass, classBody)); - }; - // ECMA-262 15.1 Scripts - // ECMA-262 15.2 Modules - Parser.prototype.parseProgram = function () { - var node = this.createNode(); - var body = this.parseDirectivePrologues(); - while (this.startMarker.index < this.scanner.length) { - body.push(this.parseStatementListItem()); - } - return this.finalize(node, new Node.Program(body, this.sourceType)); - }; - // ECMA-262 15.2.2 Imports - Parser.prototype.parseModuleSpecifier = function () { - var node = this.createNode(); - if (this.lookahead.type !== token_1.Token.StringLiteral) { - this.throwError(messages_1.Messages.InvalidModuleSpecifier); - } - var token = this.nextToken(); - var raw = this.getTokenRaw(token); - return this.finalize(node, new Node.Literal(token.value, raw)); - }; - // import {} ...; - Parser.prototype.parseImportSpecifier = function () { - var node = this.createNode(); - var imported; - var local; - if (this.lookahead.type === token_1.Token.Identifier) { - imported = this.parseVariableIdentifier(); - local = imported; - if (this.matchContextualKeyword('as')) { - this.nextToken(); - local = this.parseVariableIdentifier(); - } - } - else { - imported = this.parseIdentifierName(); - local = imported; - if (this.matchContextualKeyword('as')) { - this.nextToken(); - local = this.parseVariableIdentifier(); - } - else { - this.throwUnexpectedToken(this.nextToken()); - } - } - return this.finalize(node, new Node.ImportSpecifier(local, imported)); - }; - // {foo, bar as bas} - Parser.prototype.parseNamedImports = function () { - this.expect('{'); - var specifiers = []; - while (!this.match('}')) { - specifiers.push(this.parseImportSpecifier()); - if (!this.match('}')) { - this.expect(','); - } - } - this.expect('}'); - return specifiers; - }; - // import ...; - Parser.prototype.parseImportDefaultSpecifier = function () { - var node = this.createNode(); - var local = this.parseIdentifierName(); - return this.finalize(node, new Node.ImportDefaultSpecifier(local)); - }; - // import <* as foo> ...; - Parser.prototype.parseImportNamespaceSpecifier = function () { - var node = this.createNode(); - this.expect('*'); - if (!this.matchContextualKeyword('as')) { - this.throwError(messages_1.Messages.NoAsAfterImportNamespace); - } - this.nextToken(); - var local = this.parseIdentifierName(); - return this.finalize(node, new Node.ImportNamespaceSpecifier(local)); - }; - Parser.prototype.parseImportDeclaration = function () { - if (this.context.inFunctionBody) { - this.throwError(messages_1.Messages.IllegalImportDeclaration); - } - var node = this.createNode(); - this.expectKeyword('import'); - var src; - var specifiers = []; - if (this.lookahead.type === token_1.Token.StringLiteral) { - // import 'foo'; - src = this.parseModuleSpecifier(); - } - else { - if (this.match('{')) { - // import {bar} - specifiers = specifiers.concat(this.parseNamedImports()); - } - else if (this.match('*')) { - // import * as foo - specifiers.push(this.parseImportNamespaceSpecifier()); - } - else if (this.isIdentifierName(this.lookahead) && !this.matchKeyword('default')) { - // import foo - specifiers.push(this.parseImportDefaultSpecifier()); - if (this.match(',')) { - this.nextToken(); - if (this.match('*')) { - // import foo, * as foo - specifiers.push(this.parseImportNamespaceSpecifier()); - } - else if (this.match('{')) { - // import foo, {bar} - specifiers = specifiers.concat(this.parseNamedImports()); - } - else { - this.throwUnexpectedToken(this.lookahead); - } - } - } - else { - this.throwUnexpectedToken(this.nextToken()); - } - if (!this.matchContextualKeyword('from')) { - var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause; - this.throwError(message, this.lookahead.value); - } - this.nextToken(); - src = this.parseModuleSpecifier(); - } - this.consumeSemicolon(); - return this.finalize(node, new Node.ImportDeclaration(specifiers, src)); - }; - // ECMA-262 15.2.3 Exports - Parser.prototype.parseExportSpecifier = function () { - var node = this.createNode(); - var local = this.parseIdentifierName(); - var exported = local; - if (this.matchContextualKeyword('as')) { - this.nextToken(); - exported = this.parseIdentifierName(); - } - return this.finalize(node, new Node.ExportSpecifier(local, exported)); - }; - Parser.prototype.parseExportDeclaration = function () { - if (this.context.inFunctionBody) { - this.throwError(messages_1.Messages.IllegalExportDeclaration); - } - var node = this.createNode(); - this.expectKeyword('export'); - var exportDeclaration; - if (this.matchKeyword('default')) { - // export default ... - this.nextToken(); - if (this.matchKeyword('function')) { - // export default function foo () {} - // export default function () {} - var declaration = this.parseFunctionDeclaration(true); - exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration)); - } - else if (this.matchKeyword('class')) { - // export default class foo {} - var declaration = this.parseClassDeclaration(true); - exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration)); - } - else { - if (this.matchContextualKeyword('from')) { - this.throwError(messages_1.Messages.UnexpectedToken, this.lookahead.value); - } - // export default {}; - // export default []; - // export default (1 + 2); - var declaration = this.match('{') ? this.parseObjectInitializer() : - this.match('[') ? this.parseArrayInitializer() : this.parseAssignmentExpression(); - this.consumeSemicolon(); - exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration)); - } - } - else if (this.match('*')) { - // export * from 'foo'; - this.nextToken(); - if (!this.matchContextualKeyword('from')) { - var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause; - this.throwError(message, this.lookahead.value); - } - this.nextToken(); - var src = this.parseModuleSpecifier(); - this.consumeSemicolon(); - exportDeclaration = this.finalize(node, new Node.ExportAllDeclaration(src)); - } - else if (this.lookahead.type === token_1.Token.Keyword) { - // export var f = 1; - var declaration = void 0; - switch (this.lookahead.value) { - case 'let': - case 'const': - declaration = this.parseLexicalDeclaration({ inFor: false }); - break; - case 'var': - case 'class': - case 'function': - declaration = this.parseStatementListItem(); - break; - default: - this.throwUnexpectedToken(this.lookahead); - } - exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null)); - } - else { - var specifiers = []; - var source = null; - var isExportFromIdentifier = false; - this.expect('{'); - while (!this.match('}')) { - isExportFromIdentifier = isExportFromIdentifier || this.matchKeyword('default'); - specifiers.push(this.parseExportSpecifier()); - if (!this.match('}')) { - this.expect(','); - } - } - this.expect('}'); - if (this.matchContextualKeyword('from')) { - // export {default} from 'foo'; - // export {foo} from 'foo'; - this.nextToken(); - source = this.parseModuleSpecifier(); - this.consumeSemicolon(); - } - else if (isExportFromIdentifier) { - // export {default}; // missing fromClause - var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause; - this.throwError(message, this.lookahead.value); - } - else { - // export {foo}; - this.consumeSemicolon(); - } - exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(null, specifiers, source)); - } - return exportDeclaration; - }; - return Parser; - }()); - exports.Parser = Parser; - - -/***/ }, -/* 4 */ -/***/ function(module, exports) { - - // Ensure the condition is true, otherwise throw an error. - // This is only to have a better contract semantic, i.e. another safety net - // to catch a logic error. The condition shall be fulfilled in normal case. - // Do NOT use this to enforce a certain condition on any user input. - "use strict"; - function assert(condition, message) { - /* istanbul ignore if */ - if (!condition) { - throw new Error('ASSERT: ' + message); - } - } - exports.assert = assert; - - -/***/ }, -/* 5 */ -/***/ function(module, exports) { - - "use strict"; - // Error messages should be identical to V8. - exports.Messages = { - UnexpectedToken: 'Unexpected token %0', - UnexpectedTokenIllegal: 'Unexpected token ILLEGAL', - UnexpectedNumber: 'Unexpected number', - UnexpectedString: 'Unexpected string', - UnexpectedIdentifier: 'Unexpected identifier', - UnexpectedReserved: 'Unexpected reserved word', - UnexpectedTemplate: 'Unexpected quasi %0', - UnexpectedEOS: 'Unexpected end of input', - NewlineAfterThrow: 'Illegal newline after throw', - InvalidRegExp: 'Invalid regular expression', - UnterminatedRegExp: 'Invalid regular expression: missing /', - InvalidLHSInAssignment: 'Invalid left-hand side in assignment', - InvalidLHSInForIn: 'Invalid left-hand side in for-in', - InvalidLHSInForLoop: 'Invalid left-hand side in for-loop', - MultipleDefaultsInSwitch: 'More than one default clause in switch statement', - NoCatchOrFinally: 'Missing catch or finally after try', - UnknownLabel: 'Undefined label \'%0\'', - Redeclaration: '%0 \'%1\' has already been declared', - IllegalContinue: 'Illegal continue statement', - IllegalBreak: 'Illegal break statement', - IllegalReturn: 'Illegal return statement', - StrictModeWith: 'Strict mode code may not include a with statement', - StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', - StrictVarName: 'Variable name may not be eval or arguments in strict mode', - StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', - StrictParamDupe: 'Strict mode function may not have duplicate parameter names', - StrictFunctionName: 'Function name may not be eval or arguments in strict mode', - StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', - StrictDelete: 'Delete of an unqualified identifier in strict mode.', - StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', - StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', - StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', - StrictReservedWord: 'Use of future reserved word in strict mode', - TemplateOctalLiteral: 'Octal literals are not allowed in template strings.', - ParameterAfterRestParameter: 'Rest parameter must be last formal parameter', - DefaultRestParameter: 'Unexpected token =', - DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals', - ConstructorSpecialMethod: 'Class constructor may not be an accessor', - DuplicateConstructor: 'A class may only have one constructor', - StaticPrototype: 'Classes may not have static property named prototype', - MissingFromClause: 'Unexpected token', - NoAsAfterImportNamespace: 'Unexpected token', - InvalidModuleSpecifier: 'Unexpected token', - IllegalImportDeclaration: 'Unexpected token', - IllegalExportDeclaration: 'Unexpected token', - DuplicateBinding: 'Duplicate binding %0', - ForInOfLoopInitializer: '%0 loop variable declaration may not have an initializer' - }; - - -/***/ }, -/* 6 */ -/***/ function(module, exports) { - - "use strict"; - var ErrorHandler = (function () { - function ErrorHandler() { - this.errors = []; - this.tolerant = false; - } - ; - ErrorHandler.prototype.recordError = function (error) { - this.errors.push(error); - }; - ; - ErrorHandler.prototype.tolerate = function (error) { - if (this.tolerant) { - this.recordError(error); - } - else { - throw error; - } - }; - ; - ErrorHandler.prototype.constructError = function (msg, column) { - var error = new Error(msg); - try { - throw error; - } - catch (base) { - /* istanbul ignore else */ - if (Object.create && Object.defineProperty) { - error = Object.create(base); - Object.defineProperty(error, 'column', { value: column }); - } - } - finally { - return error; - } - }; - ; - ErrorHandler.prototype.createError = function (index, line, col, description) { - var msg = 'Line ' + line + ': ' + description; - var error = this.constructError(msg, col); - error.index = index; - error.lineNumber = line; - error.description = description; - return error; - }; - ; - ErrorHandler.prototype.throwError = function (index, line, col, description) { - throw this.createError(index, line, col, description); - }; - ; - ErrorHandler.prototype.tolerateError = function (index, line, col, description) { - var error = this.createError(index, line, col, description); - if (this.tolerant) { - this.recordError(error); - } - else { - throw error; - } - }; - ; - return ErrorHandler; - }()); - exports.ErrorHandler = ErrorHandler; - - -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - "use strict"; - (function (Token) { - Token[Token["BooleanLiteral"] = 1] = "BooleanLiteral"; - Token[Token["EOF"] = 2] = "EOF"; - Token[Token["Identifier"] = 3] = "Identifier"; - Token[Token["Keyword"] = 4] = "Keyword"; - Token[Token["NullLiteral"] = 5] = "NullLiteral"; - Token[Token["NumericLiteral"] = 6] = "NumericLiteral"; - Token[Token["Punctuator"] = 7] = "Punctuator"; - Token[Token["StringLiteral"] = 8] = "StringLiteral"; - Token[Token["RegularExpression"] = 9] = "RegularExpression"; - Token[Token["Template"] = 10] = "Template"; - })(exports.Token || (exports.Token = {})); - var Token = exports.Token; - ; - exports.TokenName = {}; - exports.TokenName[Token.BooleanLiteral] = 'Boolean'; - exports.TokenName[Token.EOF] = ''; - exports.TokenName[Token.Identifier] = 'Identifier'; - exports.TokenName[Token.Keyword] = 'Keyword'; - exports.TokenName[Token.NullLiteral] = 'Null'; - exports.TokenName[Token.NumericLiteral] = 'Numeric'; - exports.TokenName[Token.Punctuator] = 'Punctuator'; - exports.TokenName[Token.StringLiteral] = 'String'; - exports.TokenName[Token.RegularExpression] = 'RegularExpression'; - exports.TokenName[Token.Template] = 'Template'; - - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var assert_1 = __webpack_require__(4); - var messages_1 = __webpack_require__(5); - var character_1 = __webpack_require__(9); - var token_1 = __webpack_require__(7); - function hexValue(ch) { - return '0123456789abcdef'.indexOf(ch.toLowerCase()); - } - function octalValue(ch) { - return '01234567'.indexOf(ch); - } - var Scanner = (function () { - function Scanner(code, handler) { - this.source = code; - this.errorHandler = handler; - this.trackComment = false; - this.length = code.length; - this.index = 0; - this.lineNumber = (code.length > 0) ? 1 : 0; - this.lineStart = 0; - this.curlyStack = []; - } - ; - Scanner.prototype.eof = function () { - return this.index >= this.length; - }; - ; - Scanner.prototype.throwUnexpectedToken = function (message) { - if (message === void 0) { message = messages_1.Messages.UnexpectedTokenIllegal; } - this.errorHandler.throwError(this.index, this.lineNumber, this.index - this.lineStart + 1, message); - }; - ; - Scanner.prototype.tolerateUnexpectedToken = function () { - this.errorHandler.tolerateError(this.index, this.lineNumber, this.index - this.lineStart + 1, messages_1.Messages.UnexpectedTokenIllegal); - }; - ; - // ECMA-262 11.4 Comments - Scanner.prototype.skipSingleLineComment = function (offset) { - var comments; - var start, loc; - if (this.trackComment) { - comments = []; - start = this.index - offset; - loc = { - start: { - line: this.lineNumber, - column: this.index - this.lineStart - offset - }, - end: {} - }; - } - while (!this.eof()) { - var ch = this.source.charCodeAt(this.index); - ++this.index; - if (character_1.Character.isLineTerminator(ch)) { - if (this.trackComment) { - loc.end = { - line: this.lineNumber, - column: this.index - this.lineStart - 1 - }; - var entry = { - multiLine: false, - slice: [start + offset, this.index - 1], - range: [start, this.index - 1], - loc: loc - }; - comments.push(entry); - } - if (ch === 13 && this.source.charCodeAt(this.index) === 10) { - ++this.index; - } - ++this.lineNumber; - this.lineStart = this.index; - return comments; - } - } - if (this.trackComment) { - loc.end = { - line: this.lineNumber, - column: this.index - this.lineStart - }; - var entry = { - multiLine: false, - slice: [start + offset, this.index], - range: [start, this.index], - loc: loc - }; - comments.push(entry); - } - return comments; - }; - ; - Scanner.prototype.skipMultiLineComment = function () { - var comments; - var start, loc; - if (this.trackComment) { - comments = []; - start = this.index - 2; - loc = { - start: { - line: this.lineNumber, - column: this.index - this.lineStart - 2 - }, - end: {} - }; - } - while (!this.eof()) { - var ch = this.source.charCodeAt(this.index); - if (character_1.Character.isLineTerminator(ch)) { - if (ch === 0x0D && this.source.charCodeAt(this.index + 1) === 0x0A) { - ++this.index; - } - ++this.lineNumber; - ++this.index; - this.lineStart = this.index; - } - else if (ch === 0x2A) { - // Block comment ends with '*/'. - if (this.source.charCodeAt(this.index + 1) === 0x2F) { - this.index += 2; - if (this.trackComment) { - loc.end = { - line: this.lineNumber, - column: this.index - this.lineStart - }; - var entry = { - multiLine: true, - slice: [start + 2, this.index - 2], - range: [start, this.index], - loc: loc - }; - comments.push(entry); - } - return comments; - } - ++this.index; - } - else { - ++this.index; - } - } - // Ran off the end of the file - the whole thing is a comment - if (this.trackComment) { - loc.end = { - line: this.lineNumber, - column: this.index - this.lineStart - }; - var entry = { - multiLine: true, - slice: [start + 2, this.index], - range: [start, this.index], - loc: loc - }; - comments.push(entry); - } - this.tolerateUnexpectedToken(); - return comments; - }; - ; - Scanner.prototype.scanComments = function () { - var comments; - if (this.trackComment) { - comments = []; - } - var start = (this.index === 0); - while (!this.eof()) { - var ch = this.source.charCodeAt(this.index); - if (character_1.Character.isWhiteSpace(ch)) { - ++this.index; - } - else if (character_1.Character.isLineTerminator(ch)) { - ++this.index; - if (ch === 0x0D && this.source.charCodeAt(this.index) === 0x0A) { - ++this.index; - } - ++this.lineNumber; - this.lineStart = this.index; - start = true; - } - else if (ch === 0x2F) { - ch = this.source.charCodeAt(this.index + 1); - if (ch === 0x2F) { - this.index += 2; - var comment = this.skipSingleLineComment(2); - if (this.trackComment) { - comments = comments.concat(comment); - } - start = true; - } - else if (ch === 0x2A) { - this.index += 2; - var comment = this.skipMultiLineComment(); - if (this.trackComment) { - comments = comments.concat(comment); - } - } - else { - break; - } - } - else if (start && ch === 0x2D) { - // U+003E is '>' - if ((this.source.charCodeAt(this.index + 1) === 0x2D) && (this.source.charCodeAt(this.index + 2) === 0x3E)) { - // '-->' is a single-line comment - this.index += 3; - var comment = this.skipSingleLineComment(3); - if (this.trackComment) { - comments = comments.concat(comment); - } - } - else { - break; - } - } - else if (ch === 0x3C) { - if (this.source.slice(this.index + 1, this.index + 4) === '!--') { - this.index += 4; // `' is a single-line comment + this.index += 3; + var comment = this.skipSingleLineComment(3); + if (this.trackComment) { + comments = comments.concat(comment); + } + } + else { + break; + } + } + else if (ch === 0x3C) { + if (this.source.slice(this.index + 1, this.index + 4) === '!--') { + this.index += 4; // ` - - - -1.0.0 / 2016-08-01 -================== diff --git a/tools/eslint/node_modules/trough/index.js b/tools/eslint/node_modules/trough/index.js index 9d8eb90a00108b..a041e8c257509e 100644 --- a/tools/eslint/node_modules/trough/index.js +++ b/tools/eslint/node_modules/trough/index.js @@ -1,13 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2016 Titus Wormer - * @license MIT - * @module trough - * @fileoverview Middleware. Inspired by `segmentio/ware`, - * but able to change the values from transformer to - * transformer. - */ - 'use strict'; /* Expose. */ @@ -16,11 +6,7 @@ module.exports = trough; /* Methods. */ var slice = [].slice; -/** - * Create new middleware. - * - * @return {Object} - Middlewre. - */ +/* Create new middleware. */ function trough() { var fns = []; var middleware = {}; @@ -30,12 +16,8 @@ function trough() { return middleware; - /** - * Run `fns`. Last argument must be - * a completion handler. - * - * @param {...*} input - Parameters - */ + /* Run `fns`. Last argument must be + * a completion handler. */ function run() { var index = -1; var input = slice.call(arguments, 0, -1); @@ -47,14 +29,7 @@ function trough() { next.apply(null, [null].concat(input)); - return; - - /** - * Run the next `fn`, if any. - * - * @param {Error?} err - Failure. - * @param {...*} values - Other input. - */ + /* Run the next `fn`, if any. */ function next(err) { var fn = fns[++index]; var params = slice.call(arguments, 0); @@ -85,11 +60,7 @@ function trough() { } } - /** - * Add `fn` to the list. - * - * @param {Function} fn - Anything `wrap` accepts. - */ + /* Add `fn` to the list. */ function use(fn) { if (typeof fn !== 'function') { throw new Error('Expected `fn` to be a function, not ' + fn); @@ -101,15 +72,9 @@ function trough() { } } -/** - * Wrap `fn`. Can be sync or async; return a promise, +/* Wrap `fn`. Can be sync or async; return a promise, * receive a completion handler, return new values and - * errors. - * - * @param {Function} fn - Thing to wrap. - * @param {Function} next - Completion handler. - * @return {Function} - Wrapped `fn`. - */ + * errors. */ function wrap(fn, next) { var invoked; @@ -151,11 +116,7 @@ function wrap(fn, next) { } } - /** - * Invoke `next`, only once. - * - * @param {Error?} err - Optional error. - */ + /* Invoke `next`, only once. */ function done() { if (!invoked) { invoked = true; @@ -164,12 +125,8 @@ function wrap(fn, next) { } } - /** - * Invoke `done` with one value. - * Tracks if an error is passed, too. - * - * @param {*} value - Optional value. - */ + /* Invoke `done` with one value. + * Tracks if an error is passed, too. */ function then(value) { done(null, value); } diff --git a/tools/eslint/node_modules/trough/package.json b/tools/eslint/node_modules/trough/package.json index 4b7a8373fe882e..13bd3a6c82699e 100644 --- a/tools/eslint/node_modules/trough/package.json +++ b/tools/eslint/node_modules/trough/package.json @@ -1,8 +1,8 @@ { "_from": "trough@^1.0.0", - "_id": "trough@1.0.0", + "_id": "trough@1.0.1", "_inBundle": false, - "_integrity": "sha1-a97f5/KqSabzxDIldodVWVfzQv0=", + "_integrity": "sha1-qf2LA5Swro//guBjOgo2zK1bX4Y=", "_location": "/trough", "_phantomChildren": {}, "_requested": { @@ -18,8 +18,8 @@ "_requiredBy": [ "/unified" ], - "_resolved": "https://registry.npmjs.org/trough/-/trough-1.0.0.tgz", - "_shasum": "6bdedfe7f2aa49a6f3c432257687555957f342fd", + "_resolved": "https://registry.npmjs.org/trough/-/trough-1.0.1.tgz", + "_shasum": "a9fd8b0394b0ae8fff82e0633a0a36ccad5b5f86", "_spec": "trough@^1.0.0", "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/unified", "author": { @@ -42,20 +42,13 @@ "deprecated": false, "description": "Middleware: a channel used to convey a liquid", "devDependencies": { - "browserify": "^13.0.0", + "browserify": "^14.1.0", "esmangle": "^1.0.0", - "nyc": "^7.1.0", - "remark-cli": "^1.0.0", - "remark-comment-config": "^4.0.0", - "remark-github": "^5.0.0", - "remark-lint": "^4.0.0", - "remark-toc": "^3.0.0", - "remark-validate-links": "^4.0.0", + "nyc": "^11.0.0", + "remark-cli": "^3.0.0", + "remark-preset-wooorm": "^3.0.0", "tape": "^4.4.0", - "xo": "^0.16.0" - }, - "engines": { - "node": ">=0.11.0" + "xo": "^0.18.0" }, "files": [ "index.js" @@ -74,24 +67,9 @@ "branches": 100 }, "remarkConfig": { - "output": true, - "plugins": { - "comment-config": null, - "lint": { - "heading-increment": false, - "no-duplicate-headings": false, - "list-item-spacing": false - }, - "github": null, - "toc": { - "tight": true, - "maxDepth": 3 - }, - "validate-links": null - }, - "settings": { - "bullet": "*" - } + "plugins": [ + "preset-wooorm" + ] }, "repository": { "type": "git", @@ -101,22 +79,22 @@ "build": "npm run build-md && npm run build-bundle && npm run build-mangle", "build-bundle": "browserify index.js -s trough > trough.js", "build-mangle": "esmangle trough.js > trough.min.js", - "build-md": "remark . --quiet --frail", + "build-md": "remark . -qfo", "lint": "xo", "test": "npm run build && npm run lint && npm run test-coverage", "test-api": "node test", "test-coverage": "nyc --reporter lcov tape test.js" }, - "version": "1.0.0", + "version": "1.0.1", "xo": { "space": true, + "esnext": false, "rules": { "guard-for-in": "off", - "max-lines": "off" + "unicorn/prefer-type-error": "off" }, "ignores": [ - "trough.js", - "trough.min.js" + "trough.js" ] } } diff --git a/tools/eslint/node_modules/trough/readme.md b/tools/eslint/node_modules/trough/readme.md index 1b1d8047ba2a92..3dc62650e97084 100644 --- a/tools/eslint/node_modules/trough/readme.md +++ b/tools/eslint/node_modules/trough/readme.md @@ -2,7 +2,7 @@ > **trough** /trôf/ — a channel used to convey a liquid. -**trough** is like [`ware`][ware] with less sugar, and middleware +`trough` is like [`ware`][ware] with less sugar, and middleware functions can change the input of the next. ## Installation @@ -50,12 +50,12 @@ Yields: Checking... readme.md Checking... node_modules Error: Expected file - at ~/example.js:18:12 - at wrapped (~/node_modules/trough/index.js:120:19) - at next (~/node_modules/trough/index.js:77:24) - at done (~/node_modules/trough/index.js:157:12) - at ~/example.js:11:7 - at FSReqWrap.oncomplete (fs.js:123:15) + at ~/example.js:21:12 + at wrapped (~/node_modules/trough/index.js:93:19) + at next (~/node_modules/trough/index.js:56:24) + at done (~/node_modules/trough/index.js:124:12) + at ~/node_modules/example.js:14:7 + at FSReqWrap.oncomplete (fs.js:153:5) null ``` @@ -108,16 +108,18 @@ The following example shows how returning an error stops the pipeline: ```js var trough = require('trough'); -trough().use(function (val) { - return new Error('Got: ' + val); -}).run('some value', console.log); +trough() + .use(function (val) { + return new Error('Got: ' + val); + }) + .run('some value', console.log); ``` Yields: ```txt Error: Got: some value - at ~example.js:6:10 + at ~/example.js:5:12 ... ``` @@ -126,16 +128,18 @@ The following example shows how throwing an error stops the pipeline: ```js var trough = require('trough'); -trough().use(function (val) { - throw new Error('Got: ' + val); -}).run('more value', console.log); +trough() + .use(function (val) { + throw new Error('Got: ' + val); + }) + .run('more value', console.log); ``` Yields: ```txt Error: Got: more value - at ~example.js:6:10 + at ~/example.js:5:11 ... ``` @@ -144,9 +148,11 @@ The following example shows how the first output can be modified: ```js var trough = require('trough'); -trough().use(function (val) { - return 'even ' + val; -}).run('more value', 'untouched', console.log); +trough() + .use(function (val) { + return 'even ' + val; + }) + .run('more value', 'untouched', console.log); ``` Yields: @@ -169,11 +175,15 @@ is set to that value (all other `input` is passed through). The following example shows how rejecting a promise stops the pipeline: ```js -trough().use(function (val) { - return new Promise(function (resolve, reject) { - reject('Got: ' + val); - }); -}).run('val', console.log); +var trough = require('trough'); + +trough() + .use(function (val) { + return new Promise(function (resolve, reject) { + reject('Got: ' + val); + }); + }) + .run('val', console.log); ``` Yields: @@ -186,11 +196,17 @@ The following example shows how the input isn’t touched by resolving to `null`. ```js -trough().use(function (val) { - return new Promise(function (resolve, reject) { - setTimeout(function () { resolve(null); }, 100); - }); -}).run('Input', console.log); +var trough = require('trough'); + +trough() + .use(function () { + return new Promise(function (resolve) { + setTimeout(function () { + resolve(null); + }, 100); + }); + }) + .run('Input', console.log); ``` Yields: @@ -205,7 +221,7 @@ If `fn` accepts one more argument than the given `input`, a `next` function is given (after the input). `next` must be called, but doesn’t have to be called async. -If `next` is given a a value (neither `null` nor `undefined`) as its first +If `next` is given a value (neither `null` nor `undefined`) as its first argument, the pipeline fails and `done` is invoked with that value. If `next` is given no value (either `null` or `undefined`) as the first @@ -218,26 +234,34 @@ The following example shows how passing a first argument stops the pipeline: ```js -trough().use(function (val, next) { - next(new Error('Got: ' + val)); -}).run('val', console.log); +var trough = require('trough'); + +trough() + .use(function (val, next) { + next(new Error('Got: ' + val)); + }) + .run('val', console.log); ``` Yields: ```txt Error: Got: val - at ~/example.js:6:8 + at ~/example.js:5:10 ``` The following example shows how more values than the input are passed. ```js -trough().use(function (val, next) { - setTimeout(function () { - next(null, null, 'values'); - }, 100); -}).run('some', console.log); +var trough = require('trough'); + +trough() + .use(function (val, next) { + setTimeout(function () { + next(null, null, 'values'); + }, 100); + }) + .run('some', console.log); ``` Yields: diff --git a/tools/eslint/node_modules/unherit/package.json b/tools/eslint/node_modules/unherit/package.json index d8ecb6740a0e36..80d286419b5c4f 100644 --- a/tools/eslint/node_modules/unherit/package.json +++ b/tools/eslint/node_modules/unherit/package.json @@ -16,8 +16,7 @@ "fetchSpec": "^1.0.4" }, "_requiredBy": [ - "/remark-parse", - "/remark-stringify" + "/remark-parse" ], "_resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.0.tgz", "_shasum": "6b9aaedfbf73df1756ad9e316dd981885840cd7d", diff --git a/tools/eslint/node_modules/unified/package.json b/tools/eslint/node_modules/unified/package.json index 4046284fba7e07..578fde26ba7dab 100644 --- a/tools/eslint/node_modules/unified/package.json +++ b/tools/eslint/node_modules/unified/package.json @@ -20,11 +20,24 @@ ], "_resolved": "https://registry.npmjs.org/unified/-/unified-6.1.5.tgz", "_shasum": "716937872621a63135e62ced2f3ac6a063c6fb87", - "_shrinkwrap": null, "_spec": "unified@^6.1.2", - "_where": "j:\\temp\\_git\\node-fork\\tools\\eslint\\node_modules\\eslint-plugin-markdown", - "bin": null, + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/eslint-plugin-markdown", + "author": { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + }, + "bugs": { + "url": "https://github.com/unifiedjs/unified/issues" + }, "bundleDependencies": false, + "contributors": [ + { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + } + ], "dependencies": { "bail": "^1.0.0", "extend": "^3.0.0", @@ -35,7 +48,7 @@ "x-is-string": "^0.1.0" }, "deprecated": false, - "description": "[![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]", + "description": "Pluggable text processing interface", "devDependencies": { "browserify": "^14.0.0", "esmangle": "^1.0.0", @@ -45,9 +58,60 @@ "tape": "^4.4.0", "xo": "^0.18.1" }, + "files": [ + "index.js", + "lib" + ], + "homepage": "https://github.com/unifiedjs/unified#readme", + "keywords": [ + "process", + "parse", + "transform", + "compile", + "stringify", + "rehype", + "retext", + "remark" + ], + "license": "MIT", "name": "unified", - "optionalDependencies": {}, - "peerDependencies": {}, - "scripts": {}, - "version": "6.1.5" + "nyc": { + "check-coverage": true, + "lines": 100, + "functions": 100, + "branches": 100 + }, + "remarkConfig": { + "plugins": [ + "preset-wooorm" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/unifiedjs/unified.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js -s unified > unified.js", + "build-mangle": "esmangle unified.js > unified.min.js", + "build-md": "remark . -qfo", + "lint": "xo", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test", + "test-coverage": "nyc --reporter lcov tape test" + }, + "version": "6.1.5", + "xo": { + "space": true, + "esnext": false, + "rules": { + "unicorn/prefer-type-error": "off", + "import/no-unassigned-import": "off", + "guard-for-in": "off", + "max-lines": "off" + }, + "ignores": [ + "unified.js" + ] + } } diff --git a/tools/eslint/node_modules/unist-util-stringify-position/package.json b/tools/eslint/node_modules/unist-util-stringify-position/package.json index 01eadc6acc9344..3d068f37eef63b 100644 --- a/tools/eslint/node_modules/unist-util-stringify-position/package.json +++ b/tools/eslint/node_modules/unist-util-stringify-position/package.json @@ -16,12 +16,12 @@ "fetchSpec": "^1.0.0" }, "_requiredBy": [ - "/eslint-plugin-markdown/vfile" + "/vfile" ], "_resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.1.tgz", "_shasum": "3ccbdc53679eed6ecf3777dd7f5e3229c1b6aa3c", "_spec": "unist-util-stringify-position@^1.0.0", - "_where": "j:\\temp\\_git\\node-fork\\tools\\eslint\\node_modules\\eslint-plugin-markdown\\node_modules\\vfile", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/vfile", "author": { "name": "Titus Wormer", "email": "tituswormer@gmail.com", diff --git a/tools/eslint/node_modules/vfile/package.json b/tools/eslint/node_modules/vfile/package.json index d0b6c122f725c2..014377bf2775cb 100644 --- a/tools/eslint/node_modules/vfile/package.json +++ b/tools/eslint/node_modules/vfile/package.json @@ -20,18 +20,47 @@ ], "_resolved": "https://registry.npmjs.org/vfile/-/vfile-2.1.0.tgz", "_shasum": "d3ce8b825e7b8d53b896164341273381936f02bd", - "_shrinkwrap": null, "_spec": "vfile@^2.0.0", - "_where": "j:\\temp\\_git\\node-fork\\tools\\eslint\\node_modules\\unified", - "bin": null, + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/unified", + "author": { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + }, + "bugs": { + "url": "https://github.com/vfile/vfile/issues" + }, "bundleDependencies": false, + "contributors": [ + { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + }, + { + "name": "Denys Dovhan", + "email": "email@denysdovhan.com" + }, + { + "name": "Kyle Mathews", + "email": "mathews.kyle@gmail.com" + }, + { + "name": "Shinnosuke Watanabe", + "email": "snnskwtnb@gmail.com" + }, + { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com" + } + ], "dependencies": { "is-buffer": "^1.1.4", "replace-ext": "1.0.0", "unist-util-stringify-position": "^1.0.0" }, "deprecated": false, - "description": "[![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]", + "description": "Virtual file format for text processing", "devDependencies": { "browserify": "^14.0.0", "esmangle": "^1.0.0", @@ -41,9 +70,57 @@ "tape": "^4.4.0", "xo": "^0.18.0" }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/vfile/vfile#readme", + "keywords": [ + "virtual", + "file", + "text", + "processing", + "message", + "warning", + "error", + "remark", + "retext" + ], + "license": "MIT", "name": "vfile", - "optionalDependencies": {}, - "peerDependencies": {}, - "scripts": {}, - "version": "2.1.0" + "nyc": { + "check-coverage": true, + "lines": 100, + "functions": 100, + "branches": 100 + }, + "remarkConfig": { + "plugins": [ + "preset-wooorm" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/vfile/vfile.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js -s VFile > vfile.js", + "build-mangle": "esmangle vfile.js > vfile.min.js", + "build-md": "remark . -qfo", + "lint": "xo", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test", + "test-coverage": "nyc --reporter lcov tape test.js" + }, + "version": "2.1.0", + "xo": { + "space": true, + "esnext": false, + "rules": { + "unicorn/no-new-buffer": "off" + }, + "ignores": [ + "vfile.js" + ] + } } diff --git a/tools/eslint/node_modules/x-is-function/package.json b/tools/eslint/node_modules/x-is-function/package.json index ec0a7db4b2759f..6a8ced6788953d 100644 --- a/tools/eslint/node_modules/x-is-function/package.json +++ b/tools/eslint/node_modules/x-is-function/package.json @@ -16,12 +16,12 @@ "fetchSpec": "^1.0.4" }, "_requiredBy": [ - "/eslint-plugin-markdown/unified" + "/unified" ], "_resolved": "https://registry.npmjs.org/x-is-function/-/x-is-function-1.0.4.tgz", "_shasum": "5d294dc3d268cbdd062580e0c5df77a391d1fa1e", "_spec": "x-is-function@^1.0.4", - "_where": "j:\\temp\\_git\\node-fork\\tools\\eslint\\node_modules\\eslint-plugin-markdown\\node_modules\\unified", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/unified", "author": { "name": "@serapath" }, diff --git a/tools/eslint/node_modules/x-is-string/package.json b/tools/eslint/node_modules/x-is-string/package.json index 8ec07a4d69d7fd..cfc0c71147cea9 100644 --- a/tools/eslint/node_modules/x-is-string/package.json +++ b/tools/eslint/node_modules/x-is-string/package.json @@ -16,12 +16,12 @@ "fetchSpec": "^0.1.0" }, "_requiredBy": [ - "/eslint-plugin-markdown/unified" + "/unified" ], "_resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz", "_shasum": "474b50865af3a49a9c4657f05acd145458f77d82", "_spec": "x-is-string@^0.1.0", - "_where": "j:\\temp\\_git\\node-fork\\tools\\eslint\\node_modules\\eslint-plugin-markdown\\node_modules\\unified", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/unified", "author": { "name": "Matt-Esch", "email": "matt@mattesch.info" diff --git a/tools/eslint/node_modules/xtend/package.json b/tools/eslint/node_modules/xtend/package.json index f1ed0de01e8f68..c04cd90c78994d 100644 --- a/tools/eslint/node_modules/xtend/package.json +++ b/tools/eslint/node_modules/xtend/package.json @@ -1,27 +1,28 @@ { - "_from": "xtend@^4.0.0", + "_from": "xtend@^4.0.1", "_id": "xtend@4.0.1", "_inBundle": false, "_integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "_location": "/eslint/xtend", + "_location": "/xtend", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "xtend@^4.0.0", + "raw": "xtend@^4.0.1", "name": "xtend", "escapedName": "xtend", - "rawSpec": "^4.0.0", + "rawSpec": "^4.0.1", "saveSpec": null, - "fetchSpec": "^4.0.0" + "fetchSpec": "^4.0.1" }, "_requiredBy": [ - "/eslint/is-my-json-valid" + "/remark-parse", + "/unherit" ], "_resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "_shasum": "a5c6d532be656e23db820efb943a1f04998d63af", - "_spec": "xtend@^4.0.0", - "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/is-my-json-valid", + "_spec": "xtend@^4.0.1", + "_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint/node_modules/remark-parse", "author": { "name": "Raynos", "email": "raynos2@gmail.com" diff --git a/tools/eslint/package-lock.json b/tools/eslint/package-lock.json index 2038ec2453484f..114bbc6e101d98 100644 --- a/tools/eslint/package-lock.json +++ b/tools/eslint/package-lock.json @@ -1,17 +1,21 @@ { "name": "eslint", - "version": "4.1.1", + "version": "4.2.0", "lockfileVersion": 1, + "requires": true, "dependencies": { "acorn": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.0.3.tgz", - "integrity": "sha1-xGDfCEkUY/AozLguqzcwvwEIez0=" + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.1.tgz", + "integrity": "sha512-vOk6uEMctu0vQrvuSqFdJyqj1Q0S5VTDL79qtjo+DhRr+1mmaD+tluFSCZqhvi/JUhXSzoZN2BhtstaPEeE8cw==" }, "acorn-jsx": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "requires": { + "acorn": "3.3.0" + }, "dependencies": { "acorn": { "version": "3.3.0", @@ -21,9 +25,15 @@ } }, "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.1.tgz", + "integrity": "sha1-3NAwRRdYg7obY25a6ew9+auFMjo=", + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "json-schema-traverse": "0.3.1", + "json-stable-stringify": "1.0.1" + } }, "ajv-keywords": { "version": "1.5.1", @@ -48,12 +58,18 @@ "argparse": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", - "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=" + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "requires": { + "sprintf-js": "1.0.3" + } }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=" + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "requires": { + "array-uniq": "1.0.3" + } }, "array-uniq": { "version": "1.0.3", @@ -68,12 +84,17 @@ "babel-code-frame": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", - "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=" + "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } }, "bail": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.1.tgz", - "integrity": "sha1-kSV53os5Gq3zxf30zSoPwiXfO8I=" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.2.tgz", + "integrity": "sha1-99bBcxYwqfnw1NNe0fli4gdKF2Q=" }, "balanced-match": { "version": "1.0.0", @@ -83,12 +104,19 @@ "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=" + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=" + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "requires": { + "callsites": "0.2.0" + } }, "callsites": { "version": "0.2.0", @@ -98,7 +126,14 @@ "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=" + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } }, "character-entities": { "version": "1.2.0", @@ -123,7 +158,10 @@ "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=" + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "requires": { + "restore-cursor": "2.0.0" + } }, "cli-width": { "version": "2.1.0", @@ -140,6 +178,19 @@ "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.3.tgz", "integrity": "sha1-S5BvZw5aljqHt2sOFolkM0G2Ajw=" }, + "color-convert": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "requires": { + "color-name": "1.1.2" + } + }, + "color-name": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.2.tgz", + "integrity": "sha1-XIq3K2S9IhXWF66VWeuxSEdc+Y0=" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -148,7 +199,12 @@ "concat-stream": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=" + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } }, "core-util-is": { "version": "1.0.2", @@ -158,7 +214,10 @@ "debug": { "version": "2.6.8", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", - "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=" + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } }, "deep-is": { "version": "0.1.3", @@ -168,12 +227,25 @@ "del": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=" + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.1" + } }, "doctrine": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=" + "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "requires": { + "esutils": "2.0.2", + "isarray": "1.0.0" + } }, "escape-string-regexp": { "version": "1.0.5", @@ -183,32 +255,52 @@ "eslint-plugin-markdown": { "version": "1.0.0-beta.7", "resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.0-beta.7.tgz", - "integrity": "sha1-Euc6QSfEpLedlm+fR1hR3Q949+c=" + "integrity": "sha1-Euc6QSfEpLedlm+fR1hR3Q949+c=", + "requires": { + "object-assign": "4.1.1", + "remark-parse": "3.0.1", + "unified": "6.1.5" + } }, "eslint-scope": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", - "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=" + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", + "requires": { + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + } }, "espree": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", - "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=" + "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", + "requires": { + "acorn": "5.1.1", + "acorn-jsx": "3.0.1" + } }, "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==" }, "esquery": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", - "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=" + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "requires": { + "estraverse": "4.2.0" + } }, "esrecurse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz", - "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=" + "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", + "requires": { + "estraverse": "4.2.0", + "object-assign": "4.1.1" + } }, "estraverse": { "version": "4.2.0", @@ -228,7 +320,17 @@ "external-editor": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz", - "integrity": "sha1-HtkZnanL/i7y96MbL96LDRI2iXI=" + "integrity": "sha1-HtkZnanL/i7y96MbL96LDRI2iXI=", + "requires": { + "iconv-lite": "0.4.18", + "jschardet": "1.4.2", + "tmp": "0.0.31" + } + }, + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" }, "fast-levenshtein": { "version": "2.0.6", @@ -238,17 +340,30 @@ "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=" + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "requires": { + "escape-string-regexp": "1.0.5" + } }, "file-entry-cache": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=" + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "requires": { + "flat-cache": "1.2.2", + "object-assign": "4.1.1" + } }, "flat-cache": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz", - "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=" + "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=", + "requires": { + "circular-json": "0.3.1", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + } }, "fs.realpath": { "version": "1.0.0", @@ -260,20 +375,18 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=" }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=" - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=" - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==" + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } }, "globals": { "version": "9.18.0", @@ -283,7 +396,15 @@ "globby": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", - "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=" + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } }, "graceful-fs": { "version": "4.1.11", @@ -293,12 +414,23 @@ "has": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", - "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=" + "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "requires": { + "function-bind": "1.1.0" + } }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=" + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" }, "iconv-lite": { "version": "0.4.18", @@ -318,7 +450,11 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=" + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } }, "inherits": { "version": "2.0.3", @@ -326,9 +462,66 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "inquirer": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.1.1.tgz", - "integrity": "sha512-H50sHQwgvvaTBd3HpKMVtL/u6LoHDvYym51gd7bGQe/+9HkCE+J0/3N5FJLfd6O6oz44hHewC2Pc2LodzWVafQ==" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.2.0.tgz", + "integrity": "sha512-4CyUYMP7lOBkiUU1rR24WGrfRX6SucwbY2Mqb1PdApU24wnTIk4TsnkQwV72dDdIKZ2ycLP+fWCV+tA7wwgoew==", + "requires": { + "ansi-escapes": "2.0.0", + "chalk": "2.0.1", + "cli-cursor": "2.1.0", + "cli-width": "2.1.0", + "external-editor": "2.0.4", + "figures": "2.0.0", + "lodash": "4.17.4", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.0", + "strip-ansi": "4.0.0", + "through": "2.3.8" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "ansi-styles": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.1.0.tgz", + "integrity": "sha1-CcIC1ckX7CMYjKpcnLkXnNlUd1A=", + "requires": { + "color-convert": "1.9.0" + } + }, + "chalk": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.0.1.tgz", + "integrity": "sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g==", + "requires": { + "ansi-styles": "3.1.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.2.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.0.tgz", + "integrity": "sha512-Ts0Mu/A1S1aZxEJNG88I4Oc9rcZSBFNac5e27yh4j2mqbhZSSzR1Ah79EYwSn9Zuh7lrlGD2cVGzw1RKGzyLSg==", + "requires": { + "has-flag": "2.0.0" + } + } + } }, "is-alphabetical": { "version": "1.0.0", @@ -338,7 +531,11 @@ "is-alphanumerical": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.0.tgz", - "integrity": "sha1-4GSS5xnBvxXewjnk8a9fZ7TW578=" + "integrity": "sha1-4GSS5xnBvxXewjnk8a9fZ7TW578=", + "requires": { + "is-alphabetical": "1.0.0", + "is-decimal": "1.0.0" + } }, "is-buffer": { "version": "1.1.5", @@ -360,11 +557,6 @@ "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.0.tgz", "integrity": "sha1-XEWXcdKvmi45Ungf1U/LG8/kETw=" }, - "is-my-json-valid": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz", - "integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=" - }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", @@ -373,12 +565,18 @@ "is-path-in-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", - "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=" + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "requires": { + "is-path-inside": "1.0.0" + } }, "is-path-inside": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", - "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=" + "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "requires": { + "path-is-inside": "1.0.2" + } }, "is-plain-obj": { "version": "1.1.0", @@ -390,15 +588,13 @@ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=" - }, "is-resolvable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", - "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=" + "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", + "requires": { + "tryit": "1.0.3" + } }, "is-whitespace-character": { "version": "1.0.0", @@ -416,39 +612,50 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "js-tokens": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz", - "integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" }, "js-yaml": { - "version": "3.8.4", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz", - "integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=" + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.9.0.tgz", + "integrity": "sha512-0LoUNELX4S+iofCT8f4uEHIiRBR+c2AINyC8qRWfC6QNruLtxVZRJaPcu/xwMgFIgDxF25tGHaDjvxzJCNE9yw==", + "requires": { + "argparse": "1.0.9", + "esprima": "4.0.0" + } }, "jschardet": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-1.4.2.tgz", "integrity": "sha1-KqEH8UKvQSHRRWWdRPUIMJYeaZo=" }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, "json-stable-stringify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=" + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "requires": { + "jsonify": "0.0.0" + } }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=" - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=" + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } }, "lodash": { "version": "4.17.4", @@ -468,7 +675,10 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==" + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.8" + } }, "minimist": { "version": "0.0.8", @@ -478,7 +688,10 @@ "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=" + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } }, "ms": { "version": "2.0.0", @@ -503,17 +716,31 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } }, "onetime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=" + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "requires": { + "mimic-fn": "1.1.0" + } }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=" + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" + } }, "os-tmpdir": { "version": "1.0.2", @@ -523,7 +750,15 @@ "parse-entities": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.1.1.tgz", - "integrity": "sha1-gRLYhHExnyerrk1klksSL+ThuJA=" + "integrity": "sha1-gRLYhHExnyerrk1klksSL+ThuJA=", + "requires": { + "character-entities": "1.2.0", + "character-entities-legacy": "1.1.0", + "character-reference-invalid": "1.1.0", + "is-alphanumerical": "1.0.0", + "is-decimal": "1.0.0", + "is-hexadecimal": "1.0.0" + } }, "path-is-absolute": { "version": "1.0.1", @@ -548,7 +783,10 @@ "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=" + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "2.0.4" + } }, "pluralize": { "version": "4.0.0", @@ -571,14 +809,41 @@ "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=" }, "readable-stream": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz", - "integrity": "sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=" + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } }, "remark-parse": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-3.0.1.tgz", - "integrity": "sha1-G5+EGkTY9PvyJGhQJlRZpOs1TIA=" + "integrity": "sha1-G5+EGkTY9PvyJGhQJlRZpOs1TIA=", + "requires": { + "collapse-white-space": "1.0.3", + "has": "1.0.1", + "is-alphabetical": "1.0.0", + "is-decimal": "1.0.0", + "is-whitespace-character": "1.0.0", + "is-word-character": "1.0.0", + "markdown-escapes": "1.0.0", + "parse-entities": "1.1.1", + "repeat-string": "1.6.1", + "state-toggle": "1.0.0", + "trim": "0.0.1", + "trim-trailing-lines": "1.1.0", + "unherit": "1.1.0", + "unist-util-remove-position": "1.1.1", + "vfile-location": "2.0.1", + "xtend": "4.0.1" + } }, "repeat-string": { "version": "1.6.1", @@ -593,7 +858,11 @@ "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=" + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "requires": { + "caller-path": "0.1.0", + "resolve-from": "1.0.1" + } }, "resolve-from": { "version": "1.0.1", @@ -603,17 +872,27 @@ "restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=" + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "requires": { + "onetime": "2.0.1", + "signal-exit": "3.0.2" + } }, "rimraf": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", - "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=" + "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", + "requires": { + "glob": "7.1.2" + } }, "run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=" + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "requires": { + "is-promise": "2.1.0" + } }, "rx-lite": { "version": "4.0.8", @@ -623,7 +902,10 @@ "rx-lite-aggregates": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=" + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "requires": { + "rx-lite": "4.0.8" + } }, "safe-buffer": { "version": "5.1.1", @@ -653,12 +935,19 @@ "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==" + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } }, "string-width": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.0.tgz", "integrity": "sha1-AwZkVh/BRslCPsfZeP4kV0N/5tA=", + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, "dependencies": { "ansi-regex": { "version": "3.0.0", @@ -668,14 +957,20 @@ "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=" + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } } } }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=" + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } }, "strip-json-comments": { "version": "2.0.1", @@ -690,7 +985,26 @@ "table": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/table/-/table-4.0.1.tgz", - "integrity": "sha1-qBFsEz+sLGH0pCCrbN9cTWHw5DU=" + "integrity": "sha1-qBFsEz+sLGH0pCCrbN9cTWHw5DU=", + "requires": { + "ajv": "4.11.8", + "ajv-keywords": "1.5.1", + "chalk": "1.1.3", + "lodash": "4.17.4", + "slice-ansi": "0.0.4", + "string-width": "2.1.0" + }, + "dependencies": { + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + } + } }, "text-table": { "version": "0.2.0", @@ -705,7 +1019,10 @@ "tmp": { "version": "0.0.31", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", - "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=" + "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "requires": { + "os-tmpdir": "1.0.2" + } }, "trim": { "version": "0.0.1", @@ -718,9 +1035,9 @@ "integrity": "sha1-eu+7eAjfnWafbaLkOMrIxGradoQ=" }, "trough": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.0.tgz", - "integrity": "sha1-a97f5/KqSabzxDIldodVWVfzQv0=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.1.tgz", + "integrity": "sha1-qf2LA5Swro//guBjOgo2zK1bX4Y=" }, "tryit": { "version": "1.0.3", @@ -730,7 +1047,10 @@ "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=" + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "1.1.2" + } }, "typedarray": { "version": "0.0.6", @@ -740,17 +1060,33 @@ "unherit": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.0.tgz", - "integrity": "sha1-a5qu379z3xdWrZ4xbdmBiFhAzX0=" + "integrity": "sha1-a5qu379z3xdWrZ4xbdmBiFhAzX0=", + "requires": { + "inherits": "2.0.3", + "xtend": "4.0.1" + } }, "unified": { "version": "6.1.5", "resolved": "https://registry.npmjs.org/unified/-/unified-6.1.5.tgz", - "integrity": "sha1-cWk3hyYhpjE15iztLzrGoGPG+4c=" + "integrity": "sha1-cWk3hyYhpjE15iztLzrGoGPG+4c=", + "requires": { + "bail": "1.0.2", + "extend": "3.0.1", + "is-plain-obj": "1.1.0", + "trough": "1.0.1", + "vfile": "2.1.0", + "x-is-function": "1.0.4", + "x-is-string": "0.1.0" + } }, "unist-util-remove-position": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.1.tgz", - "integrity": "sha1-WoXBVV/BugwQG4ZwfRXlD6TIcbs=" + "integrity": "sha1-WoXBVV/BugwQG4ZwfRXlD6TIcbs=", + "requires": { + "unist-util-visit": "1.1.3" + } }, "unist-util-stringify-position": { "version": "1.1.1", @@ -770,7 +1106,12 @@ "vfile": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/vfile/-/vfile-2.1.0.tgz", - "integrity": "sha1-086Lgl57jVO4lhZDQSczgZNvAr0=" + "integrity": "sha1-086Lgl57jVO4lhZDQSczgZNvAr0=", + "requires": { + "is-buffer": "1.1.5", + "replace-ext": "1.0.0", + "unist-util-stringify-position": "1.1.1" + } }, "vfile-location": { "version": "2.0.1", @@ -790,7 +1131,10 @@ "write": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=" + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "requires": { + "mkdirp": "0.5.1" + } }, "x-is-function": { "version": "1.0.4", diff --git a/tools/eslint/package.json b/tools/eslint/package.json index df68de2e4ac6d8..5d9698e6c35477 100644 --- a/tools/eslint/package.json +++ b/tools/eslint/package.json @@ -1,8 +1,8 @@ { "_from": "eslint@latest", - "_id": "eslint@4.1.1", + "_id": "eslint@4.2.0", "_inBundle": false, - "_integrity": "sha1-+svfz+Pg+s06i4DcmMTmwTrlgt8=", + "_integrity": "sha1-orMYQRGxmOAunH88ymJaXgHFaz0=", "_location": "/eslint", "_phantomChildren": {}, "_requested": { @@ -19,8 +19,8 @@ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/eslint/-/eslint-4.1.1.tgz", - "_shasum": "facbdfcfe3e0facd3a8b80dc98c4e6c13ae582df", + "_resolved": "https://registry.npmjs.org/eslint/-/eslint-4.2.0.tgz", + "_shasum": "a2b3184111b198e02e9c7f3cca625a5e01c56b3d", "_spec": "eslint@latest", "_where": "/Users/trott/io.js/tools/eslint-tmp", "author": { @@ -35,6 +35,7 @@ }, "bundleDependencies": false, "dependencies": { + "ajv": "^5.2.0", "babel-code-frame": "^6.22.0", "chalk": "^1.1.3", "concat-stream": "^1.6.0", @@ -52,7 +53,6 @@ "ignore": "^3.3.3", "imurmurhash": "^0.1.4", "inquirer": "^3.0.6", - "is-my-json-valid": "^2.16.0", "is-resolvable": "^1.0.0", "js-yaml": "^3.8.4", "json-stable-stringify": "^1.0.1", @@ -84,8 +84,8 @@ "coveralls": "^2.13.1", "dateformat": "^2.0.0", "ejs": "^2.5.6", - "eslint-plugin-eslint-plugin": "^0.7.2", - "eslint-plugin-node": "^5.0.0", + "eslint-plugin-eslint-plugin": "^0.7.4", + "eslint-plugin-node": "^5.1.0", "eslint-release": "^0.10.1", "esprima": "^3.1.3", "esprima-fb": "^15001.1001.0-dev-harmony-fb", @@ -152,5 +152,5 @@ "release": "node Makefile.js release", "test": "node Makefile.js test" }, - "version": "4.1.1" + "version": "4.2.0" }