From 77b39c2eb2c9fe437d0e09e3e7682564d815c7fb Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 15 Feb 2019 16:51:43 -0500 Subject: [PATCH] tools: update ESLint to 5.14.0 Update ESLint to 5.14.0 PR-URL: https://github.com/nodejs/node/pull/26142 Reviewed-By: Rich Trott Reviewed-By: Wyatt Preul --- tools/node_modules/eslint/README.md | 224 ++---- tools/node_modules/eslint/lib/cli-engine.js | 3 + .../eslint/lib/config/config-file.js | 27 +- .../eslint/lib/config/config-initializer.js | 293 ++++---- .../eslint/lib/config/config-ops.js | 2 + .../eslint/lib/rules/accessor-pairs.js | 6 +- .../eslint/lib/rules/array-bracket-newline.js | 6 +- .../eslint/lib/rules/array-callback-return.js | 3 +- .../eslint/lib/rules/array-element-newline.js | 6 +- .../eslint/lib/rules/arrow-body-style.js | 2 +- .../eslint/lib/rules/arrow-parens.js | 3 +- .../eslint/lib/rules/arrow-spacing.js | 13 +- .../eslint/lib/rules/brace-style.js | 3 +- .../eslint/lib/rules/camelcase.js | 5 +- .../eslint/lib/rules/capitalized-comments.js | 29 +- .../lib/rules/class-methods-use-this.js | 2 +- .../eslint/lib/rules/comma-spacing.js | 14 +- .../eslint/lib/rules/complexity.js | 16 +- .../eslint/lib/rules/consistent-return.js | 3 +- .../eslint/lib/rules/dot-notation.js | 8 +- tools/node_modules/eslint/lib/rules/eqeqeq.js | 3 +- .../eslint/lib/rules/func-call-spacing.js | 3 +- .../eslint/lib/rules/func-style.js | 5 +- .../eslint/lib/rules/getter-return.js | 3 +- .../eslint/lib/rules/id-length.js | 5 +- .../node_modules/eslint/lib/rules/id-match.js | 9 +- tools/node_modules/eslint/lib/rules/indent.js | 11 +- .../eslint/lib/rules/init-declarations.js | 3 +- .../eslint/lib/rules/key-spacing.js | 81 +- .../eslint/lib/rules/keyword-spacing.js | 14 +- .../eslint/lib/rules/line-comment-position.js | 13 +- .../eslint/lib/rules/lines-around-comment.js | 26 +- .../lib/rules/lines-between-class-members.js | 3 +- .../eslint/lib/rules/max-depth.js | 13 +- .../node_modules/eslint/lib/rules/max-len.js | 27 +- .../lib/rules/max-lines-per-function.js | 28 +- .../eslint/lib/rules/max-lines.js | 17 +- .../eslint/lib/rules/max-nested-callbacks.js | 16 +- .../eslint/lib/rules/max-params.js | 13 +- .../lib/rules/max-statements-per-line.js | 3 +- .../eslint/lib/rules/max-statements.js | 16 +- .../node_modules/eslint/lib/rules/new-cap.js | 11 +- .../lib/rules/newline-per-chained-call.js | 3 +- .../eslint/lib/rules/no-bitwise.js | 3 +- .../eslint/lib/rules/no-confusing-arrow.js | 2 +- .../eslint/lib/rules/no-constant-condition.js | 3 +- .../eslint/lib/rules/no-duplicate-imports.js | 3 +- .../eslint/lib/rules/no-else-return.js | 3 +- .../node_modules/eslint/lib/rules/no-empty.js | 3 +- .../node_modules/eslint/lib/rules/no-eval.js | 2 +- .../eslint/lib/rules/no-extra-parens.js | 8 +- .../eslint/lib/rules/no-fallthrough.js | 3 +- .../eslint/lib/rules/no-implicit-coercion.js | 15 +- .../lib/rules/no-irregular-whitespace.js | 12 +- .../eslint/lib/rules/no-labels.js | 10 +- .../eslint/lib/rules/no-magic-numbers.js | 9 +- .../eslint/lib/rules/no-mixed-operators.js | 9 +- .../eslint/lib/rules/no-mixed-requires.js | 6 +- .../eslint/lib/rules/no-multi-spaces.js | 3 +- .../eslint/lib/rules/no-param-reassign.js | 2 +- .../eslint/lib/rules/no-plusplus.js | 3 +- .../eslint/lib/rules/no-redeclare.js | 4 +- .../eslint/lib/rules/no-self-assign.js | 3 +- .../lib/rules/no-shadow-restricted-names.js | 18 +- .../eslint/lib/rules/no-shadow.js | 6 +- .../node_modules/eslint/lib/rules/no-sync.js | 3 +- .../node_modules/eslint/lib/rules/no-tabs.js | 3 +- .../eslint/lib/rules/no-trailing-spaces.js | 8 +- .../node_modules/eslint/lib/rules/no-undef.js | 3 +- .../eslint/lib/rules/no-underscore-dangle.js | 9 +- .../eslint/lib/rules/no-unneeded-ternary.js | 3 +- .../eslint/lib/rules/no-unused-expressions.js | 9 +- .../eslint/lib/rules/no-unused-vars.js | 12 +- .../eslint/lib/rules/no-use-before-define.js | 6 +- .../eslint/lib/rules/no-useless-rename.js | 6 +- .../eslint/lib/rules/object-curly-newline.js | 10 +- .../lib/rules/object-property-newline.js | 8 +- .../eslint/lib/rules/object-shorthand.js | 12 +- .../node_modules/eslint/lib/rules/one-var.js | 62 +- .../eslint/lib/rules/padded-blocks.js | 41 +- .../eslint/lib/rules/prefer-arrow-callback.js | 6 +- .../eslint/lib/rules/prefer-const.js | 4 +- .../eslint/lib/rules/prefer-destructuring.js | 82 ++- .../lib/rules/prefer-promise-reject-errors.js | 2 +- .../eslint/lib/rules/prefer-spread.js | 15 +- .../eslint/lib/rules/quote-props.js | 15 +- tools/node_modules/eslint/lib/rules/quotes.js | 6 +- .../eslint/lib/rules/require-jsdoc.js | 20 +- .../eslint/lib/rules/semi-spacing.js | 14 +- tools/node_modules/eslint/lib/rules/semi.js | 9 +- .../eslint/lib/rules/sort-imports.js | 9 +- .../eslint/lib/rules/sort-keys.js | 16 +- .../eslint/lib/rules/sort-vars.js | 3 +- .../lib/rules/space-before-function-paren.js | 9 +- .../eslint/lib/rules/space-infix-ops.js | 3 +- .../eslint/lib/rules/space-unary-ops.js | 8 +- .../eslint/lib/rules/spaced-comment.js | 3 +- .../eslint/lib/rules/switch-colon-spacing.js | 4 +- .../eslint/lib/rules/valid-jsdoc.js | 15 +- .../eslint/lib/rules/valid-typeof.js | 3 +- .../eslint/lib/rules/wrap-iife.js | 5 +- .../eslint/lib/rules/yield-star-spacing.js | 4 +- tools/node_modules/eslint/lib/rules/yoda.js | 6 +- tools/node_modules/eslint/lib/util/ajv.js | 1 + .../eslint/node_modules/acorn/README.md | 2 +- .../eslint/node_modules/acorn/dist/acorn.js | 693 ++++-------------- .../node_modules/acorn/dist/acorn.js.map | 2 +- .../eslint/node_modules/acorn/dist/acorn.mjs | 693 ++++-------------- .../node_modules/acorn/dist/acorn.mjs.map | 2 +- .../eslint/node_modules/acorn/package.json | 2 +- .../eslint/node_modules/ajv/README.md | 69 +- .../node_modules/ajv/dist/ajv.bundle.js | 85 ++- .../eslint/node_modules/ajv/dist/ajv.min.js | 4 +- .../node_modules/ajv/dist/ajv.min.js.map | 2 +- .../eslint/node_modules/ajv/lib/ajv.js | 2 +- .../node_modules/ajv/lib/compile/index.js | 22 +- .../eslint/node_modules/ajv/lib/keyword.js | 59 +- .../ajv/lib/refs/json-schema-secure.json | 94 +++ .../eslint/node_modules/ajv/package.json | 4 +- .../node_modules/circular-json/LICENSE.txt | 19 - .../node_modules/circular-json/README.md | 135 ---- .../circular-json/build/circular-json.js | 2 - .../circular-json/build/circular-json.max.js | 189 ----- .../circular-json/build/circular-json.node.js | 185 ----- .../node_modules/circular-json/package.json | 42 -- .../circular-json/template/license.after | 2 - .../circular-json/template/license.before | 1 - .../node_modules/doctrine/lib/doctrine.js | 1 - .../eslint/node_modules/doctrine/package.json | 17 +- .../node_modules/emoji-regex/LICENSE-MIT.txt | 20 + .../eslint/node_modules/emoji-regex/README.md | 73 ++ .../node_modules/emoji-regex/es2015/index.js | 6 + .../node_modules/emoji-regex/es2015/text.js | 6 + .../eslint/node_modules/emoji-regex/index.js | 6 + .../node_modules/emoji-regex/package.json | 55 ++ .../eslint/node_modules/emoji-regex/text.js | 6 + .../eslint/node_modules/espree/package.json | 4 +- .../node_modules/file-entry-cache/README.md | 17 +- .../node_modules/file-entry-cache/cache.js | 106 ++- .../file-entry-cache/changelog.md | 67 ++ .../file-entry-cache/package.json | 14 +- .../eslint/node_modules/flat-cache/cache.js | 2 +- .../node_modules/flat-cache/changelog.md | 149 ++-- .../eslint/node_modules/flat-cache/del.js | 2 +- .../node_modules/flat-cache/package.json | 11 +- .../eslint/node_modules/flat-cache/utils.js | 14 +- .../eslint/node_modules/flatted/LICENSE | 15 + .../eslint/node_modules/flatted/README.md | 52 ++ .../eslint/node_modules/flatted/cjs/index.js | 116 +++ .../eslint/node_modules/flatted/esm/index.js | 118 +++ .../eslint/node_modules/flatted/index.js | 115 +++ .../eslint/node_modules/flatted/min.js | 2 + .../eslint/node_modules/flatted/package.json | 48 ++ .../eslint/node_modules/globals/globals.json | 3 + .../eslint/node_modules/globals/package.json | 2 +- .../eslint/node_modules/graceful-fs/LICENSE | 15 - .../eslint/node_modules/graceful-fs/README.md | 133 ---- .../eslint/node_modules/graceful-fs/clone.js | 19 - .../node_modules/graceful-fs/graceful-fs.js | 279 ------- .../graceful-fs/legacy-streams.js | 118 --- .../node_modules/graceful-fs/package.json | 55 -- .../node_modules/graceful-fs/polyfills.js | 329 --------- .../node_modules/rxjs/bundles/rxjs.umd.js | 64 +- .../table/dist/calculateCellWidthIndex.js | 4 +- .../dist/calculateCellWidthIndex.js.flow | 6 +- .../table/dist/calculateCellWidthIndex.js.map | 2 +- .../table/node_modules/ansi-regex/index.js | 14 + .../table/node_modules/ansi-regex/license | 9 + .../node_modules/ansi-regex/package.json | 62 ++ .../table/node_modules/ansi-regex/readme.md | 65 ++ .../table/node_modules/string-width/index.js | 39 + .../table/node_modules/string-width/license | 9 + .../node_modules/string-width/package.json | 65 ++ .../table/node_modules/string-width/readme.md | 42 ++ .../table/node_modules/strip-ansi/index.js | 4 + .../table/node_modules/strip-ansi/license | 9 + .../node_modules/strip-ansi/package.json | 61 ++ .../table/node_modules/strip-ansi/readme.md | 53 ++ .../eslint/node_modules/table/package.json | 38 +- .../eslint/node_modules/write/LICENSE | 4 +- .../eslint/node_modules/write/README.md | 163 ++-- .../eslint/node_modules/write/index.js | 161 ++-- .../eslint/node_modules/write/package.json | 51 +- tools/node_modules/eslint/package.json | 39 +- 184 files changed, 3205 insertions(+), 3645 deletions(-) create mode 100644 tools/node_modules/eslint/node_modules/ajv/lib/refs/json-schema-secure.json delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/LICENSE.txt delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/README.md delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/build/circular-json.js delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/build/circular-json.max.js delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/build/circular-json.node.js delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/package.json delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/template/license.after delete mode 100644 tools/node_modules/eslint/node_modules/circular-json/template/license.before create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/LICENSE-MIT.txt create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/README.md create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/es2015/index.js create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/es2015/text.js create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/index.js create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/package.json create mode 100644 tools/node_modules/eslint/node_modules/emoji-regex/text.js create mode 100644 tools/node_modules/eslint/node_modules/flatted/LICENSE create mode 100644 tools/node_modules/eslint/node_modules/flatted/README.md create mode 100644 tools/node_modules/eslint/node_modules/flatted/cjs/index.js create mode 100644 tools/node_modules/eslint/node_modules/flatted/esm/index.js create mode 100644 tools/node_modules/eslint/node_modules/flatted/index.js create mode 100644 tools/node_modules/eslint/node_modules/flatted/min.js create mode 100644 tools/node_modules/eslint/node_modules/flatted/package.json delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/LICENSE delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/README.md delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/clone.js delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/graceful-fs.js delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/legacy-streams.js delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/package.json delete mode 100644 tools/node_modules/eslint/node_modules/graceful-fs/polyfills.js create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/ansi-regex/index.js create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/ansi-regex/license create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/ansi-regex/package.json create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/ansi-regex/readme.md create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/string-width/index.js create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/string-width/license create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/string-width/package.json create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/string-width/readme.md create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/strip-ansi/index.js create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/strip-ansi/license create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/strip-ansi/package.json create mode 100644 tools/node_modules/eslint/node_modules/table/node_modules/strip-ansi/readme.md diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index e1855ec3f49b1b..e0ee6a74ff5768 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -197,170 +197,82 @@ These folks keep the project moving and are resources for help. The people who manage releases, review feature requests, and meet regularly to ensure ESLint is properly maintained. - - - - - - - - - - - - - - -
- -
- Nicholas C. Zakas
-
- -
- Ilya Volodin
-
- -
- Brandon Mills
-
- -
- Gyandeep Singh
-
- -
- Toru Nagashima
-
- -
- Alberto Rodríguez
-
- -
- Kai Cataldo
-
- -
- Teddy Katz
-
- -
- Kevin Partington
-
+ + +
+ +
+Nicholas C. Zakas +
+
+ +
+Kevin Partington +
+
+ +
+Ilya Volodin +
+
+ +
+Brandon Mills +
+
+ +
+Toru Nagashima +
+
+ +
+Gyandeep Singh +
+
+ +
+Kai Cataldo +
+
+ +
+Teddy Katz +
+
### Committers The people who review and fix bugs and help triage issues. - - - - - - - -
- -
- 薛定谔的猫
-
- -
- Pig Fang
-
- - -### Alumni - -Former TSC members and committers who previously helped maintain ESLint. - - - - - - - - - - - - - - - - - - - - - - - -
- -
- Mathias Schreck
-
- -
- Jamund Ferguson
-
- -
- Ian VanSchooten
-
- -
- Burak Yiğit Kaya
-
- -
- Michael Ficarra
-
- -
- Mark Pedrotti
-
- -
- Oleg Gaidarenko
-
- -
- Mike Sherov
-
- -
- Henry Zhu
-
- -
- Marat Dulin
-
- -
- Alexej Yaroshevich
-
- -
- Vitor Balocco
-
- -
- James Henry
-
- -
- Reyad Attiyat
-
- -
- Victor Hom
-
+ + +
+ +
+薛定谔的猫 +
+
+ +
+Pig Fang +
+
## Sponsors +The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://opencollective.com/eslint) to get your logo on our README and website. + + + +

Gold Sponsors

+

Facebook Open Source Airbnb

Silver Sponsors

+

AMP Project

Bronze Sponsors

+

Faithlife

+ + +## Technology Sponsors + * Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com) diff --git a/tools/node_modules/eslint/lib/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine.js index d7de2592a16d8f..dbf1abd00430c6 100644 --- a/tools/node_modules/eslint/lib/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine.js @@ -455,6 +455,9 @@ class CLIEngine { if (this.options.rules && Object.keys(this.options.rules).length) { const loadedRules = this.linter.getRules(); + // Ajv validator with default schema will mutate original object, so we must clone it recursively. + this.options.rules = lodash.cloneDeep(this.options.rules); + Object.keys(this.options.rules).forEach(name => { validator.validateRuleOptions(loadedRules.get(name), name, this.options.rules[name], "CLI"); }); diff --git a/tools/node_modules/eslint/lib/config/config-file.js b/tools/node_modules/eslint/lib/config/config-file.js index dde79cb40c87d9..f76b92830c447c 100644 --- a/tools/node_modules/eslint/lib/config/config-file.js +++ b/tools/node_modules/eslint/lib/config/config-file.js @@ -280,15 +280,38 @@ function writeYAMLConfigFile(config, filePath) { * Writes a configuration file in JavaScript format. * @param {Object} config The configuration object to write. * @param {string} filePath The filename to write to. + * @throws {Error} If an error occurs linting the config file contents. * @returns {void} * @private */ function writeJSConfigFile(config, filePath) { debug(`Writing JS config file: ${filePath}`); - const content = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`; + let contentToWrite; + const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`; - fs.writeFileSync(filePath, content, "utf8"); + try { + const CLIEngine = require("../cli-engine"); + const linter = new CLIEngine({ + baseConfig: config, + fix: true, + useEslintrc: false + }); + const report = linter.executeOnText(stringifiedContent); + + contentToWrite = report.results[0].output || stringifiedContent; + } catch (e) { + debug("Error linting JavaScript config file, writing unlinted version"); + const errorMessage = e.message; + + contentToWrite = stringifiedContent; + e.message = "An error occurred while generating your JavaScript config file. "; + e.message += "A config file was still generated, but the config file itself may not follow your linting rules."; + e.message += `\nError: ${errorMessage}`; + throw e; + } finally { + fs.writeFileSync(filePath, contentToWrite, "utf8"); + } } /** diff --git a/tools/node_modules/eslint/lib/config/config-initializer.js b/tools/node_modules/eslint/lib/config/config-initializer.js index a6791ba85307d2..b8126d4735c3c1 100644 --- a/tools/node_modules/eslint/lib/config/config-initializer.js +++ b/tools/node_modules/eslint/lib/config/config-initializer.js @@ -3,6 +3,7 @@ * @author Ilya Volodin */ + "use strict"; //------------------------------------------------------------------------------ @@ -28,6 +29,8 @@ const debug = require("debug")("eslint:config-initializer"); // Private //------------------------------------------------------------------------------ +const DEFAULT_ECMA_VERSION = 2018; + /* istanbul ignore next: hard to test fs function */ /** * Create .eslintrc file in the current working directory @@ -239,43 +242,65 @@ function configureRules(answers, config) { * @returns {Object} config object */ function processAnswers(answers) { - let config = { rules: {}, env: {}, parserOptions: {} }; + let config = { + rules: {}, + env: {}, + parserOptions: {}, + extends: [] + }; - config.parserOptions.ecmaVersion = answers.ecmaVersion; - if (answers.ecmaVersion >= 2015) { - if (answers.modules) { - config.parserOptions.sourceType = "module"; - } - config.env.es6 = true; - } + // set the latest ECMAScript version + config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION; + config.env.es6 = true; + config.globals = { + Atomics: "readonly", + SharedArrayBuffer: "readonly" + }; - if (answers.commonjs) { + // set the module type + if (answers.moduleType === "esm") { + config.parserOptions.sourceType = "module"; + } else if (answers.moduleType === "commonjs") { config.env.commonjs = true; } + + // add in browser and node environments if necessary answers.env.forEach(env => { config.env[env] = true; }); - if (answers.jsx) { - config.parserOptions = config.parserOptions || {}; - config.parserOptions.ecmaFeatures = config.parserOptions.ecmaFeatures || {}; - config.parserOptions.ecmaFeatures.jsx = true; - if (answers.react) { - config.plugins = ["react"]; - config.parserOptions.ecmaVersion = 2018; - } + + // add in library information + if (answers.framework === "react") { + config.parserOptions.ecmaFeatures = { + jsx: true + }; + config.plugins = ["react"]; + } else if (answers.framework === "vue") { + config.plugins = ["vue"]; + config.extends.push("plugin:vue/essential"); } - if (answers.source === "prompt") { - config.extends = "eslint:recommended"; - config.rules.indent = ["error", answers.indent]; - config.rules.quotes = ["error", answers.quotes]; - config.rules["linebreak-style"] = ["error", answers.linebreak]; - config.rules.semi = ["error", answers.semi ? "always" : "never"]; + // setup rules based on problems/style enforcement preferences + if (answers.purpose === "problems") { + config.extends.unshift("eslint:recommended"); + } else if (answers.purpose === "style") { + if (answers.source === "prompt") { + config.extends.unshift("eslint:recommended"); + config.rules.indent = ["error", answers.indent]; + config.rules.quotes = ["error", answers.quotes]; + config.rules["linebreak-style"] = ["error", answers.linebreak]; + config.rules.semi = ["error", answers.semi ? "always" : "never"]; + } else if (answers.source === "auto") { + config = configureRules(answers, config); + config = autoconfig.extendFromRecommended(config); + } } - if (answers.source === "auto") { - config = configureRules(answers, config); - config = autoconfig.extendFromRecommended(config); + // normalize extends + if (config.extends.length === 0) { + delete config.extends; + } else if (config.extends.length === 1) { + config.extends = config.extends[0]; } ConfigOps.normalizeToStrings(config); @@ -324,7 +349,7 @@ function getLocalESLintVersion() { * @returns {string} The shareable config name. */ function getStyleGuideName(answers) { - if (answers.styleguide === "airbnb" && !answers.airbnbReact) { + if (answers.styleguide === "airbnb" && answers.framework !== "react") { return "airbnb-base"; } return answers.styleguide; @@ -417,16 +442,62 @@ function askInstallModules(modules, packageJsonExists) { function promptUser() { return inquirer.prompt([ + { + type: "list", + name: "purpose", + message: "How would you like to use ESLint?", + default: "problems", + choices: [ + { name: "To check syntax only", value: "syntax" }, + { name: "To check syntax and find problems", value: "problems" }, + { name: "To check syntax, find problems, and enforce code style", value: "style" } + ] + }, + { + type: "list", + name: "moduleType", + message: "What type of modules does your project use?", + default: "esm", + choices: [ + { name: "JavaScript modules (import/export)", value: "esm" }, + { name: "CommonJS (require/exports)", value: "commonjs" }, + { name: "None of these", value: "none" } + ] + }, + { + type: "list", + name: "framework", + message: "Which framework does your project use?", + default: "react", + choices: [ + { name: "React", value: "react" }, + { name: "Vue.js", value: "vue" }, + { name: "None of these", value: "none" } + ] + }, + { + type: "checkbox", + name: "env", + message: "Where does your code run?", + default: ["browser"], + choices: [ + { name: "Browser", value: "browser" }, + { name: "Node", value: "node" } + ] + }, { type: "list", name: "source", - message: "How would you like to configure ESLint?", - default: "prompt", + message: "How would you like to define a style for your project?", + default: "guide", choices: [ { name: "Use a popular style guide", value: "guide" }, { name: "Answer questions about your style", value: "prompt" }, { name: "Inspect your JavaScript file(s)", value: "auto" } - ] + ], + when(answers) { + return answers.purpose === "style"; + } }, { type: "list", @@ -442,15 +513,6 @@ function promptUser() { return answers.source === "guide" && answers.packageJsonExists; } }, - { - type: "confirm", - name: "airbnbReact", - message: "Do you use React?", - default: false, - when(answers) { - return answers.styleguide === "airbnb"; - } - }, { type: "input", name: "patterns", @@ -470,10 +532,7 @@ function promptUser() { name: "format", message: "What format do you want your config file to be in?", default: "JavaScript", - choices: ["JavaScript", "YAML", "JSON"], - when(answers) { - return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto"); - } + choices: ["JavaScript", "YAML", "JSON"] }, { type: "confirm", @@ -492,6 +551,15 @@ function promptUser() { } ]).then(earlyAnswers => { + // early exit if no style guide is necessary + if (earlyAnswers.purpose !== "style") { + const config = processAnswers(earlyAnswers); + const modules = getModulesList(config); + + return askInstallModules(modules, earlyAnswers.packageJsonExists) + .then(() => writeFile(config, earlyAnswers.format)); + } + // early exit if you are using a style guide if (earlyAnswers.source === "guide") { if (!earlyAnswers.packageJsonExists) { @@ -501,130 +569,69 @@ function promptUser() { if (earlyAnswers.installESLint === false && !semver.satisfies(earlyAnswers.localESLintVersion, earlyAnswers.requiredESLintVersionRange)) { log.info(`Note: it might not work since ESLint's version is mismatched with the ${earlyAnswers.styleguide} config.`); } - if (earlyAnswers.styleguide === "airbnb" && !earlyAnswers.airbnbReact) { + if (earlyAnswers.styleguide === "airbnb" && earlyAnswers.framework !== "react") { earlyAnswers.styleguide = "airbnb-base"; } - const config = getConfigForStyleGuide(earlyAnswers.styleguide); + const config = ConfigOps.merge(processAnswers(earlyAnswers), getConfigForStyleGuide(earlyAnswers.styleguide)); const modules = getModulesList(config); return askInstallModules(modules, earlyAnswers.packageJsonExists) .then(() => writeFile(config, earlyAnswers.format)); + } - // continue with the questions otherwise... + if (earlyAnswers.source === "auto") { + const combinedAnswers = Object.assign({}, earlyAnswers); + const config = processAnswers(combinedAnswers); + const modules = getModulesList(config); + + return askInstallModules(modules).then(() => writeFile(config, earlyAnswers.format)); + } + + // continue with the style questions otherwise... return inquirer.prompt([ { type: "list", - name: "ecmaVersion", - message: "Which version of ECMAScript do you use?", - choices: [ - { name: "ES3", value: 3 }, - { name: "ES5", value: 5 }, - { name: "ES2015", value: 2015 }, - { name: "ES2016", value: 2016 }, - { name: "ES2017", value: 2017 }, - { name: "ES2018", value: 2018 } - ], - default: 1 // This is the index in the choices list + name: "indent", + message: "What style of indentation do you use?", + default: "tab", + choices: [{ name: "Tabs", value: "tab" }, { name: "Spaces", value: 4 }] }, { - type: "confirm", - name: "modules", - message: "Are you using ES6 modules?", - default: false, - when(answers) { - return answers.ecmaVersion >= 2015; - } - }, - { - type: "checkbox", - name: "env", - message: "Where will your code run?", - default: ["browser"], - choices: [{ name: "Browser", value: "browser" }, { name: "Node", value: "node" }] + type: "list", + name: "quotes", + message: "What quotes do you use for strings?", + default: "double", + choices: [{ name: "Double", value: "double" }, { name: "Single", value: "single" }] }, { - type: "confirm", - name: "commonjs", - message: "Do you use CommonJS?", - default: false, - when(answers) { - return answers.env.some(env => env === "browser"); - } + type: "list", + name: "linebreak", + message: "What line endings do you use?", + default: "unix", + choices: [{ name: "Unix", value: "unix" }, { name: "Windows", value: "windows" }] }, { type: "confirm", - name: "jsx", - message: "Do you use JSX?", - default: false + name: "semi", + message: "Do you require semicolons?", + default: true }, { - type: "confirm", - name: "react", - message: "Do you use React?", - default: false, - when(answers) { - return answers.jsx; - } - } - ]).then(secondAnswers => { - - // early exit if you are using automatic style generation - if (earlyAnswers.source === "auto") { - const combinedAnswers = Object.assign({}, earlyAnswers, secondAnswers); - - const config = processAnswers(combinedAnswers); - - const modules = getModulesList(config); - - return askInstallModules(modules).then(() => writeFile(config, earlyAnswers.format)); + type: "list", + name: "format", + message: "What format do you want your config file to be in?", + default: "JavaScript", + choices: ["JavaScript", "YAML", "JSON"] } + ]).then(answers => { + const totalAnswers = Object.assign({}, earlyAnswers, answers); - // continue with the style questions otherwise... - return inquirer.prompt([ - { - type: "list", - name: "indent", - message: "What style of indentation do you use?", - default: "tab", - choices: [{ name: "Tabs", value: "tab" }, { name: "Spaces", value: 4 }] - }, - { - type: "list", - name: "quotes", - message: "What quotes do you use for strings?", - default: "double", - choices: [{ name: "Double", value: "double" }, { name: "Single", value: "single" }] - }, - { - type: "list", - name: "linebreak", - message: "What line endings do you use?", - default: "unix", - choices: [{ name: "Unix", value: "unix" }, { name: "Windows", value: "windows" }] - }, - { - type: "confirm", - name: "semi", - message: "Do you require semicolons?", - default: true - }, - { - type: "list", - name: "format", - message: "What format do you want your config file to be in?", - default: "JavaScript", - choices: ["JavaScript", "YAML", "JSON"] - } - ]).then(answers => { - const totalAnswers = Object.assign({}, earlyAnswers, secondAnswers, answers); - - const config = processAnswers(totalAnswers); - const modules = getModulesList(config); + const config = processAnswers(totalAnswers); + const modules = getModulesList(config); - return askInstallModules(modules).then(() => writeFile(config, answers.format)); - }); + return askInstallModules(modules).then(() => writeFile(config, answers.format)); }); }); } diff --git a/tools/node_modules/eslint/lib/config/config-ops.js b/tools/node_modules/eslint/lib/config/config-ops.js index 48f38b490528a8..b38cdf7d7ca1f4 100644 --- a/tools/node_modules/eslint/lib/config/config-ops.js +++ b/tools/node_modules/eslint/lib/config/config-ops.js @@ -386,12 +386,14 @@ module.exports = { case true: case "true": case "writeable": + case "writable": return "writeable"; case null: case false: case "false": case "readable": + case "readonly": return "readable"; // Fallback to minimize compatibility impact diff --git a/tools/node_modules/eslint/lib/rules/accessor-pairs.js b/tools/node_modules/eslint/lib/rules/accessor-pairs.js index 032e89430571fa..aca231848633ad 100644 --- a/tools/node_modules/eslint/lib/rules/accessor-pairs.js +++ b/tools/node_modules/eslint/lib/rules/accessor-pairs.js @@ -85,10 +85,12 @@ module.exports = { type: "object", properties: { getWithoutSet: { - type: "boolean" + type: "boolean", + default: false }, setWithoutGet: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/array-bracket-newline.js b/tools/node_modules/eslint/lib/rules/array-bracket-newline.js index a458e69f761687..b98fa9d27ca1b6 100644 --- a/tools/node_modules/eslint/lib/rules/array-bracket-newline.js +++ b/tools/node_modules/eslint/lib/rules/array-bracket-newline.js @@ -34,11 +34,13 @@ module.exports = { type: "object", properties: { multiline: { - type: "boolean" + type: "boolean", + default: true }, minItems: { type: ["integer", "null"], - minimum: 0 + minimum: 0, + default: null } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/array-callback-return.js b/tools/node_modules/eslint/lib/rules/array-callback-return.js index bfee39b037bc7d..f88f4b8bfaeddd 100644 --- a/tools/node_modules/eslint/lib/rules/array-callback-return.js +++ b/tools/node_modules/eslint/lib/rules/array-callback-return.js @@ -155,7 +155,8 @@ module.exports = { type: "object", properties: { allowImplicit: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/array-element-newline.js b/tools/node_modules/eslint/lib/rules/array-element-newline.js index dadb26fdd226de..0efceedd27e691 100644 --- a/tools/node_modules/eslint/lib/rules/array-element-newline.js +++ b/tools/node_modules/eslint/lib/rules/array-element-newline.js @@ -34,11 +34,13 @@ module.exports = { type: "object", properties: { multiline: { - type: "boolean" + type: "boolean", + default: false }, minItems: { type: ["integer", "null"], - minimum: 0 + minimum: 0, + default: null } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/arrow-body-style.js b/tools/node_modules/eslint/lib/rules/arrow-body-style.js index c2ce3b59e4f436..83fc28aba06fab 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-body-style.js +++ b/tools/node_modules/eslint/lib/rules/arrow-body-style.js @@ -46,7 +46,7 @@ module.exports = { { type: "object", properties: { - requireReturnForObjectLiteral: { type: "boolean" } + requireReturnForObjectLiteral: { type: "boolean", default: false } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/arrow-parens.js b/tools/node_modules/eslint/lib/rules/arrow-parens.js index 637a0c1f1f13a5..217a9b60e13cbb 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-parens.js +++ b/tools/node_modules/eslint/lib/rules/arrow-parens.js @@ -35,7 +35,8 @@ module.exports = { type: "object", properties: { requireForBlockBody: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/arrow-spacing.js b/tools/node_modules/eslint/lib/rules/arrow-spacing.js index 87d381840a95dc..95acb78772584b 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-spacing.js +++ b/tools/node_modules/eslint/lib/rules/arrow-spacing.js @@ -32,10 +32,12 @@ module.exports = { type: "object", properties: { before: { - type: "boolean" + type: "boolean", + default: true }, after: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -54,11 +56,10 @@ module.exports = { create(context) { // merge rules with default - const rule = { before: true, after: true }, - option = context.options[0] || {}; + const rule = Object.assign({}, context.options[0]); - rule.before = option.before !== false; - rule.after = option.after !== false; + rule.before = rule.before !== false; + rule.after = rule.after !== false; const sourceCode = context.getSourceCode(); diff --git a/tools/node_modules/eslint/lib/rules/brace-style.js b/tools/node_modules/eslint/lib/rules/brace-style.js index d172124d2f48f7..17a5c7fdf9a37f 100644 --- a/tools/node_modules/eslint/lib/rules/brace-style.js +++ b/tools/node_modules/eslint/lib/rules/brace-style.js @@ -30,7 +30,8 @@ module.exports = { type: "object", properties: { allowSingleLine: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/camelcase.js b/tools/node_modules/eslint/lib/rules/camelcase.js index a8341c84b67bc1..6dd3793f665ed2 100644 --- a/tools/node_modules/eslint/lib/rules/camelcase.js +++ b/tools/node_modules/eslint/lib/rules/camelcase.js @@ -25,7 +25,8 @@ module.exports = { type: "object", properties: { ignoreDestructuring: { - type: "boolean" + type: "boolean", + default: false }, properties: { enum: ["always", "never"] @@ -54,7 +55,7 @@ module.exports = { const options = context.options[0] || {}; let properties = options.properties || ""; - const ignoreDestructuring = options.ignoreDestructuring || false; + const ignoreDestructuring = options.ignoreDestructuring; const allow = options.allow || []; if (properties !== "always" && properties !== "never") { diff --git a/tools/node_modules/eslint/lib/rules/capitalized-comments.js b/tools/node_modules/eslint/lib/rules/capitalized-comments.js index 7947833b270444..285f856379d487 100644 --- a/tools/node_modules/eslint/lib/rules/capitalized-comments.js +++ b/tools/node_modules/eslint/lib/rules/capitalized-comments.js @@ -17,12 +17,7 @@ const astUtils = require("../util/ast-utils"); const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN, WHITESPACE = /\s/g, - MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/, // TODO: Combine w/ max-len pattern? - DEFAULTS = { - ignorePattern: null, - ignoreInlineComments: false, - ignoreConsecutiveComments: false - }; + MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/; // TODO: Combine w/ max-len pattern? /* * Base schema body for defining the basic capitalization rule, ignorePattern, @@ -33,17 +28,27 @@ const SCHEMA_BODY = { type: "object", properties: { ignorePattern: { - type: "string" + type: "string", + default: "" }, ignoreInlineComments: { - type: "boolean" + type: "boolean", + default: false }, ignoreConsecutiveComments: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false }; +const DEFAULTS = Object.keys(SCHEMA_BODY.properties).reduce( + (obj, current) => { + obj[current] = SCHEMA_BODY.properties[current].default; + return obj; + }, + {} +); /** * Get normalized options for either block or line comments from the given @@ -59,11 +64,7 @@ const SCHEMA_BODY = { * @param {string} which Either "line" or "block". * @returns {Object} The normalized options. */ -function getNormalizedOptions(rawOptions, which) { - if (!rawOptions) { - return Object.assign({}, DEFAULTS); - } - +function getNormalizedOptions(rawOptions = {}, which) { return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions); } diff --git a/tools/node_modules/eslint/lib/rules/class-methods-use-this.js b/tools/node_modules/eslint/lib/rules/class-methods-use-this.js index a15ab6b89e480f..0eb1da87f4c227 100644 --- a/tools/node_modules/eslint/lib/rules/class-methods-use-this.js +++ b/tools/node_modules/eslint/lib/rules/class-methods-use-this.js @@ -38,7 +38,7 @@ module.exports = { } }, create(context) { - const config = context.options[0] ? Object.assign({}, context.options[0]) : {}; + const config = Object.assign({}, context.options[0]); const exceptMethods = new Set(config.exceptMethods || []); const stack = []; diff --git a/tools/node_modules/eslint/lib/rules/comma-spacing.js b/tools/node_modules/eslint/lib/rules/comma-spacing.js index 2db0035b545348..a9f89676a4a3cd 100644 --- a/tools/node_modules/eslint/lib/rules/comma-spacing.js +++ b/tools/node_modules/eslint/lib/rules/comma-spacing.js @@ -28,10 +28,12 @@ module.exports = { type: "object", properties: { before: { - type: "boolean" + type: "boolean", + default: false }, after: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -50,8 +52,8 @@ module.exports = { const tokensAndComments = sourceCode.tokensAndComments; const options = { - before: context.options[0] ? !!context.options[0].before : false, - after: context.options[0] ? !!context.options[0].after : true + before: context.options[0] ? context.options[0].before : false, + after: context.options[0] ? context.options[0].after : true }; //-------------------------------------------------------------------------- @@ -118,6 +120,10 @@ module.exports = { report(reportItem, "before", tokens.left); } + if (tokens.right && astUtils.isClosingParenToken(tokens.right)) { + return; + } + if (tokens.right && !options.after && tokens.right.type === "Line") { return; } diff --git a/tools/node_modules/eslint/lib/rules/complexity.js b/tools/node_modules/eslint/lib/rules/complexity.js index af583c02791dd0..9f791e6de7c49a 100644 --- a/tools/node_modules/eslint/lib/rules/complexity.js +++ b/tools/node_modules/eslint/lib/rules/complexity.js @@ -41,11 +41,13 @@ module.exports = { properties: { maximum: { type: "integer", - minimum: 0 + minimum: 0, + default: 20 }, max: { type: "integer", - minimum: 0 + minimum: 0, + default: 20 } }, additionalProperties: false @@ -63,13 +65,9 @@ module.exports = { const option = context.options[0]; let THRESHOLD = 20; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { - THRESHOLD = option.maximum; - } - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { - THRESHOLD = option.max; - } - if (typeof option === "number") { + if (typeof option === "object") { + THRESHOLD = option.maximum || option.max; + } else if (typeof option === "number") { THRESHOLD = option; } diff --git a/tools/node_modules/eslint/lib/rules/consistent-return.js b/tools/node_modules/eslint/lib/rules/consistent-return.js index ffd7ef20589490..68f9f9d8fbcad4 100644 --- a/tools/node_modules/eslint/lib/rules/consistent-return.js +++ b/tools/node_modules/eslint/lib/rules/consistent-return.js @@ -66,7 +66,8 @@ module.exports = { type: "object", properties: { treatUndefinedAsUnspecified: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/dot-notation.js b/tools/node_modules/eslint/lib/rules/dot-notation.js index 55ccea4ce38f4c..a1b091da0ea90d 100644 --- a/tools/node_modules/eslint/lib/rules/dot-notation.js +++ b/tools/node_modules/eslint/lib/rules/dot-notation.js @@ -33,10 +33,12 @@ module.exports = { type: "object", properties: { allowKeywords: { - type: "boolean" + type: "boolean", + default: true }, allowPattern: { - type: "string" + type: "string", + default: "" } }, additionalProperties: false @@ -53,7 +55,7 @@ module.exports = { create(context) { const options = context.options[0] || {}; - const allowKeywords = options.allowKeywords === void 0 || !!options.allowKeywords; + const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords; const sourceCode = context.getSourceCode(); let allowPattern; diff --git a/tools/node_modules/eslint/lib/rules/eqeqeq.js b/tools/node_modules/eslint/lib/rules/eqeqeq.js index 3e8a392cf6983e..a52de67d750e95 100644 --- a/tools/node_modules/eslint/lib/rules/eqeqeq.js +++ b/tools/node_modules/eslint/lib/rules/eqeqeq.js @@ -38,7 +38,8 @@ module.exports = { type: "object", properties: { null: { - enum: ["always", "never", "ignore"] + enum: ["always", "never", "ignore"], + default: "always" } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/func-call-spacing.js b/tools/node_modules/eslint/lib/rules/func-call-spacing.js index c49aa9e59f7e9c..62bba144e6ff97 100644 --- a/tools/node_modules/eslint/lib/rules/func-call-spacing.js +++ b/tools/node_modules/eslint/lib/rules/func-call-spacing.js @@ -50,7 +50,8 @@ module.exports = { type: "object", properties: { allowNewlines: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/func-style.js b/tools/node_modules/eslint/lib/rules/func-style.js index b7e368cbd2ea08..e150b1a76f26a6 100644 --- a/tools/node_modules/eslint/lib/rules/func-style.js +++ b/tools/node_modules/eslint/lib/rules/func-style.js @@ -27,7 +27,8 @@ module.exports = { type: "object", properties: { allowArrowFunctions: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -43,7 +44,7 @@ module.exports = { create(context) { const style = context.options[0], - allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions === true, + allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions, enforceDeclarations = (style === "declaration"), stack = []; diff --git a/tools/node_modules/eslint/lib/rules/getter-return.js b/tools/node_modules/eslint/lib/rules/getter-return.js index dc3d9d6b627e62..a1806c357b1afa 100644 --- a/tools/node_modules/eslint/lib/rules/getter-return.js +++ b/tools/node_modules/eslint/lib/rules/getter-return.js @@ -60,7 +60,8 @@ module.exports = { type: "object", properties: { allowImplicit: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/id-length.js b/tools/node_modules/eslint/lib/rules/id-length.js index 1f9c696e2a93b1..c8586ea3481895 100644 --- a/tools/node_modules/eslint/lib/rules/id-length.js +++ b/tools/node_modules/eslint/lib/rules/id-length.js @@ -26,10 +26,11 @@ module.exports = { type: "object", properties: { min: { - type: "number" + type: "integer", + default: 2 }, max: { - type: "number" + type: "integer" }, exceptions: { type: "array", diff --git a/tools/node_modules/eslint/lib/rules/id-match.js b/tools/node_modules/eslint/lib/rules/id-match.js index 5dc86f8dbfd7ac..3978a5ef684b7f 100644 --- a/tools/node_modules/eslint/lib/rules/id-match.js +++ b/tools/node_modules/eslint/lib/rules/id-match.js @@ -28,13 +28,16 @@ module.exports = { type: "object", properties: { properties: { - type: "boolean" + type: "boolean", + default: false }, onlyDeclarations: { - type: "boolean" + type: "boolean", + default: false }, ignoreDestructuring: { - type: "boolean" + type: "boolean", + default: false } } } diff --git a/tools/node_modules/eslint/lib/rules/indent.js b/tools/node_modules/eslint/lib/rules/indent.js index c30d1f1e7bccc9..08b9250f05c09d 100644 --- a/tools/node_modules/eslint/lib/rules/indent.js +++ b/tools/node_modules/eslint/lib/rules/indent.js @@ -518,7 +518,8 @@ module.exports = { properties: { SwitchCase: { type: "integer", - minimum: 0 + minimum: 0, + default: 0 }, VariableDeclarator: { oneOf: [ @@ -582,7 +583,8 @@ module.exports = { ObjectExpression: ELEMENT_LIST_SCHEMA, ImportDeclaration: ELEMENT_LIST_SCHEMA, flatTernaryExpressions: { - type: "boolean" + type: "boolean", + default: false }, ignoredNodes: { type: "array", @@ -594,7 +596,8 @@ module.exports = { } }, ignoreComments: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -650,7 +653,7 @@ module.exports = { } if (context.options[1]) { - lodash.merge(options, context.options[1]); + Object.assign(options, context.options[1]); if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") { options.VariableDeclarator = { diff --git a/tools/node_modules/eslint/lib/rules/init-declarations.js b/tools/node_modules/eslint/lib/rules/init-declarations.js index 65197358e60df8..484cbef0a57c4c 100644 --- a/tools/node_modules/eslint/lib/rules/init-declarations.js +++ b/tools/node_modules/eslint/lib/rules/init-declarations.js @@ -75,7 +75,8 @@ module.exports = { type: "object", properties: { ignoreForLoopInit: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/key-spacing.js b/tools/node_modules/eslint/lib/rules/key-spacing.js index c52a74d499f9ad..31ba9522e9bb72 100644 --- a/tools/node_modules/eslint/lib/rules/key-spacing.js +++ b/tools/node_modules/eslint/lib/rules/key-spacing.js @@ -148,16 +148,20 @@ module.exports = { type: "object", properties: { mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, on: { - enum: ["colon", "value"] + enum: ["colon", "value"], + default: "colon" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -165,13 +169,16 @@ module.exports = { ] }, mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -183,13 +190,16 @@ module.exports = { type: "object", properties: { mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -206,16 +216,20 @@ module.exports = { type: "object", properties: { mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, on: { - enum: ["colon", "value"] + enum: ["colon", "value"], + default: "colon" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -223,13 +237,16 @@ module.exports = { ] }, mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -244,13 +261,16 @@ module.exports = { type: "object", properties: { mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -259,13 +279,16 @@ module.exports = { type: "object", properties: { mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -274,16 +297,20 @@ module.exports = { type: "object", properties: { mode: { - enum: ["strict", "minimum"] + enum: ["strict", "minimum"], + default: "strict" }, on: { - enum: ["colon", "value"] + enum: ["colon", "value"], + default: "colon" }, beforeColon: { - type: "boolean" + type: "boolean", + default: false }, afterColon: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/keyword-spacing.js b/tools/node_modules/eslint/lib/rules/keyword-spacing.js index 833092e4160c48..83ad6282688bab 100644 --- a/tools/node_modules/eslint/lib/rules/keyword-spacing.js +++ b/tools/node_modules/eslint/lib/rules/keyword-spacing.js @@ -80,16 +80,16 @@ module.exports = { { type: "object", properties: { - before: { type: "boolean" }, - after: { type: "boolean" }, + before: { type: "boolean", default: true }, + after: { type: "boolean", default: true }, overrides: { type: "object", properties: KEYS.reduce((retv, key) => { retv[key] = { type: "object", properties: { - before: { type: "boolean" }, - after: { type: "boolean" } + before: { type: "boolean", default: true }, + after: { type: "boolean", default: true } }, additionalProperties: false }; @@ -228,9 +228,9 @@ module.exports = { * Keys are keywords (there are for every keyword). * Values are instances of `{"before": function, "after": function}`. */ - function parseOptions(options) { - const before = !options || options.before !== false; - const after = !options || options.after !== false; + function parseOptions(options = {}) { + const before = options.before !== false; + const after = options.after !== false; const defaultValue = { before: before ? expectSpaceBefore : unexpectSpaceBefore, after: after ? expectSpaceAfter : unexpectSpaceAfter diff --git a/tools/node_modules/eslint/lib/rules/line-comment-position.js b/tools/node_modules/eslint/lib/rules/line-comment-position.js index 6d0ac6d2ba8c4e..132a8ad875f558 100644 --- a/tools/node_modules/eslint/lib/rules/line-comment-position.js +++ b/tools/node_modules/eslint/lib/rules/line-comment-position.js @@ -31,16 +31,19 @@ module.exports = { type: "object", properties: { position: { - enum: ["above", "beside"] + enum: ["above", "beside"], + default: "above" }, ignorePattern: { type: "string" }, applyDefaultPatterns: { - type: "boolean" + type: "boolean", + default: true }, applyDefaultIgnorePatterns: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -69,9 +72,9 @@ module.exports = { ignorePattern = options.ignorePattern; if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) { - applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false; + applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns; } else { - applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false; + applyDefaultIgnorePatterns = options.applyDefaultPatterns; } } diff --git a/tools/node_modules/eslint/lib/rules/lines-around-comment.js b/tools/node_modules/eslint/lib/rules/lines-around-comment.js index 62bef94831d281..0f9851f7241180 100644 --- a/tools/node_modules/eslint/lib/rules/lines-around-comment.js +++ b/tools/node_modules/eslint/lib/rules/lines-around-comment.js @@ -68,22 +68,28 @@ module.exports = { type: "object", properties: { beforeBlockComment: { - type: "boolean" + type: "boolean", + default: true }, afterBlockComment: { - type: "boolean" + type: "boolean", + default: false }, beforeLineComment: { - type: "boolean" + type: "boolean", + default: false }, afterLineComment: { - type: "boolean" + type: "boolean", + default: false }, allowBlockStart: { - type: "boolean" + type: "boolean", + default: false }, allowBlockEnd: { - type: "boolean" + type: "boolean", + default: false }, allowClassStart: { type: "boolean" @@ -121,19 +127,13 @@ module.exports = { create(context) { - const options = context.options[0] ? Object.assign({}, context.options[0]) : {}; + const options = Object.assign({}, context.options[0]); const ignorePattern = options.ignorePattern; const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN; const customIgnoreRegExp = new RegExp(ignorePattern); const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false; - - options.beforeLineComment = options.beforeLineComment || false; - options.afterLineComment = options.afterLineComment || false; options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true; - options.afterBlockComment = options.afterBlockComment || false; - options.allowBlockStart = options.allowBlockStart || false; - options.allowBlockEnd = options.allowBlockEnd || false; const sourceCode = context.getSourceCode(); diff --git a/tools/node_modules/eslint/lib/rules/lines-between-class-members.js b/tools/node_modules/eslint/lib/rules/lines-between-class-members.js index 2937d24f81f1bc..19ae8a6a292c27 100644 --- a/tools/node_modules/eslint/lib/rules/lines-between-class-members.js +++ b/tools/node_modules/eslint/lib/rules/lines-between-class-members.js @@ -31,7 +31,8 @@ module.exports = { type: "object", properties: { exceptAfterSingleLine: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/max-depth.js b/tools/node_modules/eslint/lib/rules/max-depth.js index 500e9318817d41..3b997e21bc6384 100644 --- a/tools/node_modules/eslint/lib/rules/max-depth.js +++ b/tools/node_modules/eslint/lib/rules/max-depth.js @@ -32,11 +32,13 @@ module.exports = { properties: { maximum: { type: "integer", - minimum: 0 + minimum: 0, + default: 4 }, max: { type: "integer", - minimum: 0 + minimum: 0, + default: 4 } }, additionalProperties: false @@ -59,11 +61,8 @@ module.exports = { option = context.options[0]; let maxDepth = 4; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { - maxDepth = option.maximum; - } - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { - maxDepth = option.max; + if (typeof option === "object") { + maxDepth = option.maximum || option.max; } if (typeof option === "number") { maxDepth = option; diff --git a/tools/node_modules/eslint/lib/rules/max-len.js b/tools/node_modules/eslint/lib/rules/max-len.js index d74373e9ea85e3..f6f0b6d3ac093d 100644 --- a/tools/node_modules/eslint/lib/rules/max-len.js +++ b/tools/node_modules/eslint/lib/rules/max-len.js @@ -14,7 +14,8 @@ const OPTIONS_SCHEMA = { properties: { code: { type: "integer", - minimum: 0 + minimum: 0, + default: 80 }, comments: { type: "integer", @@ -22,28 +23,35 @@ const OPTIONS_SCHEMA = { }, tabWidth: { type: "integer", - minimum: 0 + minimum: 0, + default: 4 }, ignorePattern: { type: "string" }, ignoreComments: { - type: "boolean" + type: "boolean", + default: false }, ignoreStrings: { - type: "boolean" + type: "boolean", + default: false }, ignoreUrls: { - type: "boolean" + type: "boolean", + default: false }, ignoreTemplateLiterals: { - type: "boolean" + type: "boolean", + default: false }, ignoreRegExpLiterals: { - type: "boolean" + type: "boolean", + default: false }, ignoreTrailingComments: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -121,8 +129,7 @@ module.exports = { } // The options object must be the last option specified… - const lastOption = context.options[context.options.length - 1]; - const options = typeof lastOption === "object" ? Object.create(lastOption) : {}; + const options = Object.assign({}, context.options[context.options.length - 1]); // …but max code length… if (typeof context.options[0] === "number") { diff --git a/tools/node_modules/eslint/lib/rules/max-lines-per-function.js b/tools/node_modules/eslint/lib/rules/max-lines-per-function.js index d1e4597a2218b1..2a0e1a645a375b 100644 --- a/tools/node_modules/eslint/lib/rules/max-lines-per-function.js +++ b/tools/node_modules/eslint/lib/rules/max-lines-per-function.js @@ -19,16 +19,20 @@ const OPTIONS_SCHEMA = { properties: { max: { type: "integer", - minimum: 0 + minimum: 0, + default: 50 }, skipComments: { - type: "boolean" + type: "boolean", + default: false }, skipBlankLines: { - type: "boolean" + type: "boolean", + default: false }, IIFEs: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -97,18 +101,10 @@ module.exports = { let IIFEs = false; if (typeof option === "object") { - if (typeof option.max === "number") { - maxLines = option.max; - } - if (typeof option.skipComments === "boolean") { - skipComments = option.skipComments; - } - if (typeof option.skipBlankLines === "boolean") { - skipBlankLines = option.skipBlankLines; - } - if (typeof option.IIFEs === "boolean") { - IIFEs = option.IIFEs; - } + maxLines = option.max; + skipComments = option.skipComments; + skipBlankLines = option.skipBlankLines; + IIFEs = option.IIFEs; } else if (typeof option === "number") { maxLines = option; } diff --git a/tools/node_modules/eslint/lib/rules/max-lines.js b/tools/node_modules/eslint/lib/rules/max-lines.js index da7ddd8a88fca0..0fae4ec2fa13fa 100644 --- a/tools/node_modules/eslint/lib/rules/max-lines.js +++ b/tools/node_modules/eslint/lib/rules/max-lines.js @@ -38,13 +38,16 @@ module.exports = { properties: { max: { type: "integer", - minimum: 0 + minimum: 0, + default: 300 }, skipComments: { - type: "boolean" + type: "boolean", + default: false }, skipBlankLines: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -61,11 +64,9 @@ module.exports = { const option = context.options[0]; let max = 300; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { + if (typeof option === "object") { max = option.max; - } - - if (typeof option === "number") { + } else if (typeof option === "number") { max = option; } @@ -86,7 +87,7 @@ module.exports = { /** * Returns the line numbers of a comment that don't have any code on the same line * @param {Node} comment The comment node to check - * @returns {int[]} The line numbers + * @returns {number[]} The line numbers */ function getLinesWithoutCode(comment) { let start = comment.loc.start.line; diff --git a/tools/node_modules/eslint/lib/rules/max-nested-callbacks.js b/tools/node_modules/eslint/lib/rules/max-nested-callbacks.js index 754fa168d39ab2..cbbb0ed6c70d9a 100644 --- a/tools/node_modules/eslint/lib/rules/max-nested-callbacks.js +++ b/tools/node_modules/eslint/lib/rules/max-nested-callbacks.js @@ -32,11 +32,13 @@ module.exports = { properties: { maximum: { type: "integer", - minimum: 0 + minimum: 0, + default: 10 }, max: { type: "integer", - minimum: 0 + minimum: 0, + default: 10 } }, additionalProperties: false @@ -57,13 +59,9 @@ module.exports = { const option = context.options[0]; let THRESHOLD = 10; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { - THRESHOLD = option.maximum; - } - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { - THRESHOLD = option.max; - } - if (typeof option === "number") { + if (typeof option === "object") { + THRESHOLD = option.maximum || option.max; + } else if (typeof option === "number") { THRESHOLD = option; } diff --git a/tools/node_modules/eslint/lib/rules/max-params.js b/tools/node_modules/eslint/lib/rules/max-params.js index e082ec8e980cec..5e1e558ab53e0b 100644 --- a/tools/node_modules/eslint/lib/rules/max-params.js +++ b/tools/node_modules/eslint/lib/rules/max-params.js @@ -40,11 +40,13 @@ module.exports = { properties: { maximum: { type: "integer", - minimum: 0 + minimum: 0, + default: 3 }, max: { type: "integer", - minimum: 0 + minimum: 0, + default: 3 } }, additionalProperties: false @@ -62,11 +64,8 @@ module.exports = { const option = context.options[0]; let numParams = 3; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { - numParams = option.maximum; - } - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { - numParams = option.max; + if (typeof option === "object") { + numParams = option.maximum || option.max; } if (typeof option === "number") { numParams = option; diff --git a/tools/node_modules/eslint/lib/rules/max-statements-per-line.js b/tools/node_modules/eslint/lib/rules/max-statements-per-line.js index b834cedc03f318..444bdfa21aa1b0 100644 --- a/tools/node_modules/eslint/lib/rules/max-statements-per-line.js +++ b/tools/node_modules/eslint/lib/rules/max-statements-per-line.js @@ -31,7 +31,8 @@ module.exports = { properties: { max: { type: "integer", - minimum: 1 + minimum: 1, + default: 1 } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/max-statements.js b/tools/node_modules/eslint/lib/rules/max-statements.js index b33ca429824e45..cd0e50ae399910 100644 --- a/tools/node_modules/eslint/lib/rules/max-statements.js +++ b/tools/node_modules/eslint/lib/rules/max-statements.js @@ -40,11 +40,13 @@ module.exports = { properties: { maximum: { type: "integer", - minimum: 0 + minimum: 0, + default: 10 }, max: { type: "integer", - minimum: 0 + minimum: 0, + default: 10 } }, additionalProperties: false @@ -78,13 +80,9 @@ module.exports = { topLevelFunctions = []; let maxStatements = 10; - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { - maxStatements = option.maximum; - } - if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { - maxStatements = option.max; - } - if (typeof option === "number") { + if (typeof option === "object") { + maxStatements = option.maximum || option.max; + } else if (typeof option === "number") { maxStatements = option; } diff --git a/tools/node_modules/eslint/lib/rules/new-cap.js b/tools/node_modules/eslint/lib/rules/new-cap.js index 4a01dcfa7f385b..ab70fcfadd5e13 100644 --- a/tools/node_modules/eslint/lib/rules/new-cap.js +++ b/tools/node_modules/eslint/lib/rules/new-cap.js @@ -88,10 +88,12 @@ module.exports = { type: "object", properties: { newIsCap: { - type: "boolean" + type: "boolean", + default: true }, capIsNew: { - type: "boolean" + type: "boolean", + default: true }, newIsCapExceptions: { type: "array", @@ -112,7 +114,8 @@ module.exports = { type: "string" }, properties: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -126,7 +129,7 @@ module.exports = { create(context) { - const config = context.options[0] ? Object.assign({}, context.options[0]) : {}; + const config = Object.assign({}, context.options[0]); config.newIsCap = config.newIsCap !== false; config.capIsNew = config.capIsNew !== false; diff --git a/tools/node_modules/eslint/lib/rules/newline-per-chained-call.js b/tools/node_modules/eslint/lib/rules/newline-per-chained-call.js index 0bf2365de5aa11..90b540c484d495 100644 --- a/tools/node_modules/eslint/lib/rules/newline-per-chained-call.js +++ b/tools/node_modules/eslint/lib/rules/newline-per-chained-call.js @@ -31,7 +31,8 @@ module.exports = { ignoreChainWithDepth: { type: "integer", minimum: 1, - maximum: 10 + maximum: 10, + default: 2 } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-bitwise.js b/tools/node_modules/eslint/lib/rules/no-bitwise.js index df492937c0b5bb..a9c3360a7c5b42 100644 --- a/tools/node_modules/eslint/lib/rules/no-bitwise.js +++ b/tools/node_modules/eslint/lib/rules/no-bitwise.js @@ -43,7 +43,8 @@ module.exports = { uniqueItems: true }, int32Hint: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js index f18ec194530c19..79df9a5138759a 100644 --- a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js +++ b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js @@ -41,7 +41,7 @@ module.exports = { schema: [{ type: "object", properties: { - allowParens: { type: "boolean" } + allowParens: { type: "boolean", default: false } }, additionalProperties: false }], diff --git a/tools/node_modules/eslint/lib/rules/no-constant-condition.js b/tools/node_modules/eslint/lib/rules/no-constant-condition.js index fb36207ebbb741..d6d04174298cff 100644 --- a/tools/node_modules/eslint/lib/rules/no-constant-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-constant-condition.js @@ -32,7 +32,8 @@ module.exports = { type: "object", properties: { checkLoops: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-duplicate-imports.js b/tools/node_modules/eslint/lib/rules/no-duplicate-imports.js index 7d35b41b4d49ad..03b5e2c12393ae 100644 --- a/tools/node_modules/eslint/lib/rules/no-duplicate-imports.js +++ b/tools/node_modules/eslint/lib/rules/no-duplicate-imports.js @@ -113,7 +113,8 @@ module.exports = { type: "object", properties: { includeExports: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-else-return.js b/tools/node_modules/eslint/lib/rules/no-else-return.js index 5ba02de29136f8..5c21fb1b3fc21e 100644 --- a/tools/node_modules/eslint/lib/rules/no-else-return.js +++ b/tools/node_modules/eslint/lib/rules/no-else-return.js @@ -31,7 +31,8 @@ module.exports = { type: "object", properties: { allowElseIf: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-empty.js b/tools/node_modules/eslint/lib/rules/no-empty.js index 9d72969e67eb6f..2d55dee66596a3 100644 --- a/tools/node_modules/eslint/lib/rules/no-empty.js +++ b/tools/node_modules/eslint/lib/rules/no-empty.js @@ -30,7 +30,8 @@ module.exports = { type: "object", properties: { allowEmptyCatch: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-eval.js b/tools/node_modules/eslint/lib/rules/no-eval.js index 39d91e776e9c79..d4b79468f194a4 100644 --- a/tools/node_modules/eslint/lib/rules/no-eval.js +++ b/tools/node_modules/eslint/lib/rules/no-eval.js @@ -89,7 +89,7 @@ module.exports = { { type: "object", properties: { - allowIndirect: { type: "boolean" } + allowIndirect: { type: "boolean", default: false } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/no-extra-parens.js b/tools/node_modules/eslint/lib/rules/no-extra-parens.js index 3a21b69580b820..9f16e0e6ccc622 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-parens.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-parens.js @@ -44,11 +44,11 @@ module.exports = { { type: "object", properties: { - conditionalAssign: { type: "boolean" }, - nestedBinaryExpressions: { type: "boolean" }, - returnAssign: { type: "boolean" }, + conditionalAssign: { type: "boolean", default: true }, + nestedBinaryExpressions: { type: "boolean", default: true }, + returnAssign: { type: "boolean", default: true }, ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] }, - enforceForArrowConditionals: { type: "boolean" } + enforceForArrowConditionals: { type: "boolean", default: true } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/no-fallthrough.js b/tools/node_modules/eslint/lib/rules/no-fallthrough.js index 79cbe81c0bbc8e..dfd9d8541587b2 100644 --- a/tools/node_modules/eslint/lib/rules/no-fallthrough.js +++ b/tools/node_modules/eslint/lib/rules/no-fallthrough.js @@ -69,7 +69,8 @@ module.exports = { type: "object", properties: { commentPattern: { - type: "string" + type: "string", + default: "" } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js index 826d9398cab56e..d54c578646d555 100644 --- a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js +++ b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js @@ -21,9 +21,9 @@ const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"]; */ function parseOptions(options) { return { - boolean: "boolean" in options ? Boolean(options.boolean) : true, - number: "number" in options ? Boolean(options.number) : true, - string: "string" in options ? Boolean(options.string) : true, + boolean: "boolean" in options ? options.boolean : true, + number: "number" in options ? options.number : true, + string: "string" in options ? options.string : true, allow: options.allow || [] }; } @@ -167,13 +167,16 @@ module.exports = { type: "object", properties: { boolean: { - type: "boolean" + type: "boolean", + default: true }, number: { - type: "boolean" + type: "boolean", + default: true }, string: { - type: "boolean" + type: "boolean", + default: true }, allow: { type: "array", diff --git a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js index 90d1a79a1c349a..ddbfd1c91cc88d 100644 --- a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js @@ -41,16 +41,20 @@ module.exports = { type: "object", properties: { skipComments: { - type: "boolean" + type: "boolean", + default: false }, skipStrings: { - type: "boolean" + type: "boolean", + default: true }, skipTemplates: { - type: "boolean" + type: "boolean", + default: false }, skipRegExps: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-labels.js b/tools/node_modules/eslint/lib/rules/no-labels.js index 34db20725b0af3..29580bd236bbd8 100644 --- a/tools/node_modules/eslint/lib/rules/no-labels.js +++ b/tools/node_modules/eslint/lib/rules/no-labels.js @@ -30,10 +30,12 @@ module.exports = { type: "object", properties: { allowLoop: { - type: "boolean" + type: "boolean", + default: false }, allowSwitch: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -43,8 +45,8 @@ module.exports = { create(context) { const options = context.options[0]; - const allowLoop = Boolean(options && options.allowLoop); - const allowSwitch = Boolean(options && options.allowSwitch); + const allowLoop = options && options.allowLoop; + const allowSwitch = options && options.allowSwitch; let scopeInfo = null; /** diff --git a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js index 84c08dfb08e717..2c6ea61e283315 100644 --- a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js +++ b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js @@ -24,10 +24,12 @@ module.exports = { type: "object", properties: { detectObjects: { - type: "boolean" + type: "boolean", + default: false }, enforceConst: { - type: "boolean" + type: "boolean", + default: false }, ignore: { type: "array", @@ -37,7 +39,8 @@ module.exports = { uniqueItems: true }, ignoreArrayIndexes: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js index 22ed65f5b1f0fd..2b603a86df5571 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js @@ -42,10 +42,10 @@ const TARGET_NODE_TYPE = /^(?:Binary|Logical)Expression$/; * @param {Object|undefined} options - A options object to normalize. * @returns {Object} Normalized option object. */ -function normalizeOptions(options) { - const hasGroups = (options && options.groups && options.groups.length > 0); +function normalizeOptions(options = {}) { + const hasGroups = options.groups && options.groups.length > 0; const groups = hasGroups ? options.groups : DEFAULT_GROUPS; - const allowSamePrecedence = (options && options.allowSamePrecedence) !== false; + const allowSamePrecedence = options.allowSamePrecedence !== false; return { groups, @@ -95,7 +95,8 @@ module.exports = { uniqueItems: true }, allowSamePrecedence: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-requires.js b/tools/node_modules/eslint/lib/rules/no-mixed-requires.js index 438ac668a805af..5b07a5f2938753 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-requires.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-requires.js @@ -30,10 +30,12 @@ module.exports = { type: "object", properties: { grouping: { - type: "boolean" + type: "boolean", + default: false }, allowCall: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-multi-spaces.js b/tools/node_modules/eslint/lib/rules/no-multi-spaces.js index f1792c31ed7e7e..c5fb07403421af 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-spaces.js @@ -38,7 +38,8 @@ module.exports = { additionalProperties: false }, ignoreEOLComments: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-param-reassign.js b/tools/node_modules/eslint/lib/rules/no-param-reassign.js index 349345c148a76b..83760edb8c2fec 100644 --- a/tools/node_modules/eslint/lib/rules/no-param-reassign.js +++ b/tools/node_modules/eslint/lib/rules/no-param-reassign.js @@ -55,7 +55,7 @@ module.exports = { }, create(context) { - const props = context.options[0] && Boolean(context.options[0].props); + const props = context.options[0] && context.options[0].props; const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || []; /** diff --git a/tools/node_modules/eslint/lib/rules/no-plusplus.js b/tools/node_modules/eslint/lib/rules/no-plusplus.js index 4c854de1a06ff7..1d122dcd31f086 100644 --- a/tools/node_modules/eslint/lib/rules/no-plusplus.js +++ b/tools/node_modules/eslint/lib/rules/no-plusplus.js @@ -26,7 +26,8 @@ module.exports = { type: "object", properties: { allowForLoopAfterthoughts: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-redeclare.js b/tools/node_modules/eslint/lib/rules/no-redeclare.js index e88436d7c57b73..4d689cc6138716 100644 --- a/tools/node_modules/eslint/lib/rules/no-redeclare.js +++ b/tools/node_modules/eslint/lib/rules/no-redeclare.js @@ -24,7 +24,7 @@ module.exports = { { type: "object", properties: { - builtinGlobals: { type: "boolean" } + builtinGlobals: { type: "boolean", default: false } }, additionalProperties: false } @@ -33,7 +33,7 @@ module.exports = { create(context) { const options = { - builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals) + builtinGlobals: context.options[0] && context.options[0].builtinGlobals }; /** diff --git a/tools/node_modules/eslint/lib/rules/no-self-assign.js b/tools/node_modules/eslint/lib/rules/no-self-assign.js index d493855efe9c68..8bc7afbe38e9b8 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-self-assign.js @@ -179,7 +179,8 @@ module.exports = { type: "object", properties: { props: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js b/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js index 9bdd50868042c3..f09f3767da4257 100644 --- a/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +++ b/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js @@ -4,6 +4,19 @@ */ "use strict"; +/** + * Determines if a variable safely shadows undefined. + * This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value + * as the global). + * @param {eslintScope.Variable} variable The variable to check + * @returns {boolean} true if this variable safely shadows `undefined` + */ +function safelyShadowsUndefined(variable) { + return variable.name === "undefined" && + variable.references.every(ref => !ref.isWrite()) && + variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null); +} + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -24,12 +37,13 @@ module.exports = { create(context) { - const RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"]; + + const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]); return { "VariableDeclaration, :function, CatchClause"(node) { for (const variable of context.getDeclaredVariables(node)) { - if (variable.defs.length > 0 && RESTRICTED.includes(variable.name)) { + if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) { context.report({ node: variable.defs[0].name, message: "Shadowing of global property '{{idName}}'.", diff --git a/tools/node_modules/eslint/lib/rules/no-shadow.js b/tools/node_modules/eslint/lib/rules/no-shadow.js index f910230d6a27f3..5f617e52a74ba0 100644 --- a/tools/node_modules/eslint/lib/rules/no-shadow.js +++ b/tools/node_modules/eslint/lib/rules/no-shadow.js @@ -30,8 +30,8 @@ module.exports = { { type: "object", properties: { - builtinGlobals: { type: "boolean" }, - hoist: { enum: ["all", "functions", "never"] }, + builtinGlobals: { type: "boolean", default: false }, + hoist: { enum: ["all", "functions", "never"], default: "functions" }, allow: { type: "array", items: { @@ -47,7 +47,7 @@ module.exports = { create(context) { const options = { - builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals), + builtinGlobals: context.options[0] && context.options[0].builtinGlobals, hoist: (context.options[0] && context.options[0].hoist) || "functions", allow: (context.options[0] && context.options[0].allow) || [] }; diff --git a/tools/node_modules/eslint/lib/rules/no-sync.js b/tools/node_modules/eslint/lib/rules/no-sync.js index a0096e3d04313f..578bac96d3d061 100644 --- a/tools/node_modules/eslint/lib/rules/no-sync.js +++ b/tools/node_modules/eslint/lib/rules/no-sync.js @@ -27,7 +27,8 @@ module.exports = { type: "object", properties: { allowAtRootLevel: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-tabs.js b/tools/node_modules/eslint/lib/rules/no-tabs.js index 0002f5592900c1..91fb000796f369 100644 --- a/tools/node_modules/eslint/lib/rules/no-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-tabs.js @@ -30,7 +30,8 @@ module.exports = { type: "object", properties: { allowIndentationTabs: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js index 18f0340ef011c7..1f0b53aca2abad 100644 --- a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js @@ -32,10 +32,12 @@ module.exports = { type: "object", properties: { skipBlankLines: { - type: "boolean" + type: "boolean", + default: false }, ignoreComments: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -52,7 +54,7 @@ module.exports = { const options = context.options[0] || {}, skipBlankLines = options.skipBlankLines || false, - ignoreComments = typeof options.ignoreComments === "boolean" && options.ignoreComments; + ignoreComments = options.ignoreComments || false; /** * Report the error message diff --git a/tools/node_modules/eslint/lib/rules/no-undef.js b/tools/node_modules/eslint/lib/rules/no-undef.js index e6cd152761fca7..6b5140819bbd30 100644 --- a/tools/node_modules/eslint/lib/rules/no-undef.js +++ b/tools/node_modules/eslint/lib/rules/no-undef.js @@ -39,7 +39,8 @@ module.exports = { type: "object", properties: { typeof: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js index 926803b992d98a..3f59815b575f84 100644 --- a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js +++ b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js @@ -31,13 +31,16 @@ module.exports = { } }, allowAfterThis: { - type: "boolean" + type: "boolean", + default: false }, allowAfterSuper: { - type: "boolean" + type: "boolean", + default: false }, enforceInMethodNames: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js index 3a7dd5fad7db19..e75a36430fe8aa 100644 --- a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js @@ -38,7 +38,8 @@ module.exports = { type: "object", properties: { defaultAssignment: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js index 854298b411978b..25c21775b0de05 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -24,13 +24,16 @@ module.exports = { type: "object", properties: { allowShortCircuit: { - type: "boolean" + type: "boolean", + default: false }, allowTernary: { - type: "boolean" + type: "boolean", + default: false }, allowTaggedTemplates: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/no-unused-vars.js b/tools/node_modules/eslint/lib/rules/no-unused-vars.js index e76e3251038c00..e56ba221bbc841 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-vars.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-vars.js @@ -37,22 +37,26 @@ module.exports = { type: "object", properties: { vars: { - enum: ["all", "local"] + enum: ["all", "local"], + default: "all" }, varsIgnorePattern: { type: "string" }, args: { - enum: ["all", "after-used", "none"] + enum: ["all", "after-used", "none"], + default: "after-used" }, ignoreRestSiblings: { - type: "boolean" + type: "boolean", + default: false }, argsIgnorePattern: { type: "string" }, caughtErrors: { - enum: ["all", "none"] + enum: ["all", "none"], + default: "none" }, caughtErrorsIgnorePattern: { type: "string" diff --git a/tools/node_modules/eslint/lib/rules/no-use-before-define.js b/tools/node_modules/eslint/lib/rules/no-use-before-define.js index 500cd3a4103672..e0b2d23a7e6c94 100644 --- a/tools/node_modules/eslint/lib/rules/no-use-before-define.js +++ b/tools/node_modules/eslint/lib/rules/no-use-before-define.js @@ -154,9 +154,9 @@ module.exports = { { type: "object", properties: { - functions: { type: "boolean" }, - classes: { type: "boolean" }, - variables: { type: "boolean" } + functions: { type: "boolean", default: true }, + classes: { type: "boolean", default: true }, + variables: { type: "boolean", default: true } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-rename.js b/tools/node_modules/eslint/lib/rules/no-useless-rename.js index 337f875b4564d8..c1860645ea698e 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-rename.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-rename.js @@ -26,9 +26,9 @@ module.exports = { { type: "object", properties: { - ignoreDestructuring: { type: "boolean" }, - ignoreImport: { type: "boolean" }, - ignoreExport: { type: "boolean" } + ignoreDestructuring: { type: "boolean", default: false }, + ignoreImport: { type: "boolean", default: false }, + ignoreExport: { type: "boolean", default: false } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/object-curly-newline.js b/tools/node_modules/eslint/lib/rules/object-curly-newline.js index d1a6bc20f6361e..d45620d53c568f 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-newline.js @@ -26,14 +26,16 @@ const OPTION_VALUE = { type: "object", properties: { multiline: { - type: "boolean" + type: "boolean", + default: false }, minProperties: { type: "integer", minimum: 0 }, consistent: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false, @@ -59,9 +61,9 @@ function normalizeOptionValue(value) { } else if (value === "never") { minProperties = Number.POSITIVE_INFINITY; } else { - multiline = Boolean(value.multiline); + multiline = value.multiline; minProperties = value.minProperties || Number.POSITIVE_INFINITY; - consistent = Boolean(value.consistent); + consistent = value.consistent; } } else { consistent = true; diff --git a/tools/node_modules/eslint/lib/rules/object-property-newline.js b/tools/node_modules/eslint/lib/rules/object-property-newline.js index 3e2c0171577594..bf777b5ff65ba2 100644 --- a/tools/node_modules/eslint/lib/rules/object-property-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-property-newline.js @@ -25,10 +25,12 @@ module.exports = { type: "object", properties: { allowAllPropertiesOnSameLine: { - type: "boolean" + type: "boolean", + default: false }, allowMultiplePropertiesPerLine: { // Deprecated - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -40,7 +42,7 @@ module.exports = { create(context) { const allowSameLine = context.options[0] && ( - (Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(context.options[0].allowMultiplePropertiesPerLine)) // Deprecated + (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */) ); const errorMessage = allowSameLine ? "Object properties must go on a new line if they aren't all on the same line." diff --git a/tools/node_modules/eslint/lib/rules/object-shorthand.js b/tools/node_modules/eslint/lib/rules/object-shorthand.js index 31010f0e7386db..98917fb6ee20ce 100644 --- a/tools/node_modules/eslint/lib/rules/object-shorthand.js +++ b/tools/node_modules/eslint/lib/rules/object-shorthand.js @@ -57,7 +57,8 @@ module.exports = { type: "object", properties: { avoidQuotes: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -76,13 +77,16 @@ module.exports = { type: "object", properties: { ignoreConstructors: { - type: "boolean" + type: "boolean", + default: false }, avoidQuotes: { - type: "boolean" + type: "boolean", + default: false }, avoidExplicitReturnArrows: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/one-var.js b/tools/node_modules/eslint/lib/rules/one-var.js index 0e9dff416588f7..5a5c71b1874e01 100644 --- a/tools/node_modules/eslint/lib/rules/one-var.js +++ b/tools/node_modules/eslint/lib/rules/one-var.js @@ -32,16 +32,20 @@ module.exports = { type: "object", properties: { separateRequires: { - type: "boolean" + type: "boolean", + default: false }, var: { - enum: ["always", "never", "consecutive"] + enum: ["always", "never", "consecutive"], + default: "always" }, let: { - enum: ["always", "never", "consecutive"] + enum: ["always", "never", "consecutive"], + default: "always" }, const: { - enum: ["always", "never", "consecutive"] + enum: ["always", "never", "consecutive"], + default: "always" } }, additionalProperties: false @@ -76,42 +80,16 @@ module.exports = { options.let = { uninitialized: mode, initialized: mode }; options.const = { uninitialized: mode, initialized: mode }; } else if (typeof mode === "object") { // options configuration is an object - if (Object.prototype.hasOwnProperty.call(mode, "separateRequires")) { - options.separateRequires = !!mode.separateRequires; - } - if (Object.prototype.hasOwnProperty.call(mode, "var")) { - options.var = { uninitialized: mode.var, initialized: mode.var }; - } - if (Object.prototype.hasOwnProperty.call(mode, "let")) { - options.let = { uninitialized: mode.let, initialized: mode.let }; - } - if (Object.prototype.hasOwnProperty.call(mode, "const")) { - options.const = { uninitialized: mode.const, initialized: mode.const }; - } + options.separateRequires = mode.separateRequires; + options.var = { uninitialized: mode.var, initialized: mode.var }; + options.let = { uninitialized: mode.let, initialized: mode.let }; + options.const = { uninitialized: mode.const, initialized: mode.const }; if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) { - if (!options.var) { - options.var = {}; - } - if (!options.let) { - options.let = {}; - } - if (!options.const) { - options.const = {}; - } options.var.uninitialized = mode.uninitialized; options.let.uninitialized = mode.uninitialized; options.const.uninitialized = mode.uninitialized; } if (Object.prototype.hasOwnProperty.call(mode, "initialized")) { - if (!options.var) { - options.var = {}; - } - if (!options.let) { - options.let = {}; - } - if (!options.const) { - options.const = {}; - } options.var.initialized = mode.initialized; options.let.initialized = mode.initialized; options.const.initialized = mode.initialized; @@ -257,7 +235,9 @@ module.exports = { if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) { if (currentScope.uninitialized || currentScope.initialized) { - return false; + if (!hasRequires) { + return false; + } } } @@ -268,7 +248,9 @@ module.exports = { } if (declarationCounts.initialized > 0) { if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) { - return false; + if (!hasRequires) { + return false; + } } } if (currentScope.required && hasRequires) { @@ -340,7 +322,11 @@ module.exports = { * y` * ^ afterComma */ - if (afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || afterComma.type === "Line" || afterComma.type === "Block") { + if ( + afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || + afterComma.type === "Line" || + afterComma.type === "Block" + ) { let lastComment = afterComma; while (lastComment.type === "Line" || lastComment.type === "Block") { @@ -349,7 +335,7 @@ module.exports = { return fixer.replaceTextRange( [tokenAfterDeclarator.range[0], lastComment.range[0]], - `;\n${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}\n${declaration.kind} ` + `;${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}${declaration.kind} ` ); } diff --git a/tools/node_modules/eslint/lib/rules/padded-blocks.js b/tools/node_modules/eslint/lib/rules/padded-blocks.js index 7c0b56ba7f8553..e4dd37f4cdb42e 100644 --- a/tools/node_modules/eslint/lib/rules/padded-blocks.js +++ b/tools/node_modules/eslint/lib/rules/padded-blocks.js @@ -5,6 +5,12 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("../util/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -45,32 +51,45 @@ module.exports = { minProperties: 1 } ] + }, + { + type: "object", + properties: { + allowSingleLineBlocks: { + type: "boolean" + } + } } ] }, create(context) { const options = {}; - const config = context.options[0] || "always"; + const typeOptions = context.options[0] || "always"; + const exceptOptions = context.options[1] || {}; - if (typeof config === "string") { - const shouldHavePadding = config === "always"; + if (typeof typeOptions === "string") { + const shouldHavePadding = typeOptions === "always"; options.blocks = shouldHavePadding; options.switches = shouldHavePadding; options.classes = shouldHavePadding; } else { - if (Object.prototype.hasOwnProperty.call(config, "blocks")) { - options.blocks = config.blocks === "always"; + if (Object.prototype.hasOwnProperty.call(typeOptions, "blocks")) { + options.blocks = typeOptions.blocks === "always"; } - if (Object.prototype.hasOwnProperty.call(config, "switches")) { - options.switches = config.switches === "always"; + if (Object.prototype.hasOwnProperty.call(typeOptions, "switches")) { + options.switches = typeOptions.switches === "always"; } - if (Object.prototype.hasOwnProperty.call(config, "classes")) { - options.classes = config.classes === "always"; + if (Object.prototype.hasOwnProperty.call(typeOptions, "classes")) { + options.classes = typeOptions.classes === "always"; } } + if (Object.prototype.hasOwnProperty.call(exceptOptions, "allowSingleLineBlocks")) { + options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true; + } + const ALWAYS_MESSAGE = "Block must be padded by blank lines.", NEVER_MESSAGE = "Block must not be padded by blank lines."; @@ -177,6 +196,10 @@ module.exports = { blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken), blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast); + if (options.allowSingleLineBlocks && astUtils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)) { + return; + } + if (requirePaddingFor(node)) { if (!blockHasTopPadding) { context.report({ diff --git a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js index b4bbf33f296ab8..a0957399ea5ad1 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js +++ b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js @@ -146,10 +146,12 @@ module.exports = { type: "object", properties: { allowNamedFunctions: { - type: "boolean" + type: "boolean", + default: false }, allowUnboundThis: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/prefer-const.js b/tools/node_modules/eslint/lib/rules/prefer-const.js index 5f75376c95c343..023f69cbd32a30 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-const.js +++ b/tools/node_modules/eslint/lib/rules/prefer-const.js @@ -345,8 +345,8 @@ module.exports = { { type: "object", properties: { - destructuring: { enum: ["any", "all"] }, - ignoreReadBeforeAssign: { type: "boolean" } + destructuring: { enum: ["any", "all"], default: "any" }, + ignoreReadBeforeAssign: { type: "boolean", default: false } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js index 119fae560895e7..c30c9170cd9cd2 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js +++ b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js @@ -19,6 +19,8 @@ module.exports = { url: "https://eslint.org/docs/rules/prefer-destructuring" }, + fixable: "code", + schema: [ { @@ -34,10 +36,12 @@ module.exports = { type: "object", properties: { array: { - type: "boolean" + type: "boolean", + default: true }, object: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -46,10 +50,12 @@ module.exports = { type: "object", properties: { array: { - type: "boolean" + type: "boolean", + default: true }, object: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -61,10 +67,12 @@ module.exports = { type: "object", properties: { array: { - type: "boolean" + type: "boolean", + default: true }, object: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -75,7 +83,8 @@ module.exports = { type: "object", properties: { enforceForRenamedProperties: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -130,10 +139,55 @@ module.exports = { * * @param {ASTNode} reportNode the node to report * @param {string} type the type of destructuring that should have been done + * @param {Function|null} fix the fix function or null to pass to context.report * @returns {void} */ - function report(reportNode, type) { - context.report({ node: reportNode, message: "Use {{type}} destructuring.", data: { type } }); + function report(reportNode, type, fix) { + context.report({ + node: reportNode, + message: "Use {{type}} destructuring.", + data: { type }, + fix + }); + } + + /** + * Determines if a node should be fixed into object destructuring + * + * The fixer only fixes the simplest case of object destructuring, + * like: `let x = a.x`; + * + * Assignment expression is not fixed. + * Array destructuring is not fixed. + * Renamed property is not fixed. + * + * @param {ASTNode} node the the node to evaluate + * @returns {boolean} whether or not the node should be fixed + */ + function shouldFix(node) { + return node.type === "VariableDeclarator" && + node.id.type === "Identifier" && + node.init.type === "MemberExpression" && + node.id.name === node.init.property.name; + } + + /** + * Fix a node into object destructuring. + * This function only handles the simplest case of object destructuring, + * see {@link shouldFix}. + * + * @param {SourceCodeFixer} fixer the fixer object + * @param {ASTNode} node the node to be fixed. + * @returns {Object} a fix for the node + */ + function fixIntoObjectDestructuring(fixer, node) { + const rightNode = node.init; + const sourceCode = context.getSourceCode(); + + return fixer.replaceText( + node, + `{${rightNode.property.name}} = ${sourceCode.getText(rightNode.object)}` + ); } /** @@ -155,13 +209,17 @@ module.exports = { if (isArrayIndexAccess(rightNode)) { if (shouldCheck(reportNode.type, "array")) { - report(reportNode, "array"); + report(reportNode, "array", null); } return; } + const fix = shouldFix(reportNode) + ? fixer => fixIntoObjectDestructuring(fixer, reportNode) + : null; + if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) { - report(reportNode, "object"); + report(reportNode, "object", fix); return; } @@ -172,7 +230,7 @@ module.exports = { (property.type === "Literal" && leftNode.name === property.value) || (property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed) ) { - report(reportNode, "object"); + report(reportNode, "object", fix); } } } diff --git a/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js b/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js index 0db5ae874cfd9f..275e705f6d5ca7 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +++ b/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js @@ -27,7 +27,7 @@ module.exports = { { type: "object", properties: { - allowEmptyReject: { type: "boolean" } + allowEmptyReject: { type: "boolean", default: false } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/prefer-spread.js b/tools/node_modules/eslint/lib/rules/prefer-spread.js index 790fd3b82aab41..5f3a477329b700 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-spread.js @@ -59,7 +59,7 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: null }, create(context) { @@ -78,18 +78,7 @@ module.exports = { if (isValidThisArg(expectedThis, thisArg, sourceCode)) { context.report({ node, - message: "Use the spread operator instead of '.apply()'.", - fix(fixer) { - if (expectedThis && expectedThis.type !== "Identifier") { - - // Don't fix cases where the `this` value could be a computed expression. - return null; - } - - const propertyDot = sourceCode.getFirstTokenBetween(applied, node.callee.property, token => token.value === "."); - - return fixer.replaceTextRange([propertyDot.range[0], node.range[1]], `(...${sourceCode.getText(node.arguments[1])})`); - } + message: "Use the spread operator instead of '.apply()'." }); } } diff --git a/tools/node_modules/eslint/lib/rules/quote-props.js b/tools/node_modules/eslint/lib/rules/quote-props.js index 7184bd34d35fd1..f4582dd1f4a87c 100644 --- a/tools/node_modules/eslint/lib/rules/quote-props.js +++ b/tools/node_modules/eslint/lib/rules/quote-props.js @@ -32,7 +32,8 @@ module.exports = { type: "array", items: [ { - enum: ["always", "as-needed", "consistent", "consistent-as-needed"] + enum: ["always", "as-needed", "consistent", "consistent-as-needed"], + default: "always" } ], minItems: 0, @@ -42,19 +43,23 @@ module.exports = { type: "array", items: [ { - enum: ["always", "as-needed", "consistent", "consistent-as-needed"] + enum: ["always", "as-needed", "consistent", "consistent-as-needed"], + default: "always" }, { type: "object", properties: { keywords: { - type: "boolean" + type: "boolean", + default: false }, unnecessary: { - type: "boolean" + type: "boolean", + default: true }, numbers: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/quotes.js b/tools/node_modules/eslint/lib/rules/quotes.js index c3c077822462b8..e0797f9e8be3bb 100644 --- a/tools/node_modules/eslint/lib/rules/quotes.js +++ b/tools/node_modules/eslint/lib/rules/quotes.js @@ -100,10 +100,12 @@ module.exports = { type: "object", properties: { avoidEscape: { - type: "boolean" + type: "boolean", + default: false }, allowTemplateLiterals: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/require-jsdoc.js b/tools/node_modules/eslint/lib/rules/require-jsdoc.js index 389bfb692bbae8..416a22ce6c4375 100644 --- a/tools/node_modules/eslint/lib/rules/require-jsdoc.js +++ b/tools/node_modules/eslint/lib/rules/require-jsdoc.js @@ -23,22 +23,28 @@ module.exports = { type: "object", properties: { ClassDeclaration: { - type: "boolean" + type: "boolean", + default: false }, MethodDefinition: { - type: "boolean" + type: "boolean", + default: false }, FunctionDeclaration: { - type: "boolean" + type: "boolean", + default: true }, ArrowFunctionExpression: { - type: "boolean" + type: "boolean", + default: false }, FunctionExpression: { - type: "boolean" + type: "boolean", + default: false } }, - additionalProperties: false + additionalProperties: false, + default: {} } }, additionalProperties: false @@ -58,7 +64,7 @@ module.exports = { ArrowFunctionExpression: false, FunctionExpression: false }; - const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require || {}); + const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require); /** * Report the error message diff --git a/tools/node_modules/eslint/lib/rules/semi-spacing.js b/tools/node_modules/eslint/lib/rules/semi-spacing.js index 56ae687d8560a0..3a6d8a052a343b 100644 --- a/tools/node_modules/eslint/lib/rules/semi-spacing.js +++ b/tools/node_modules/eslint/lib/rules/semi-spacing.js @@ -29,10 +29,12 @@ module.exports = { type: "object", properties: { before: { - type: "boolean" + type: "boolean", + default: false }, after: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false @@ -48,12 +50,8 @@ module.exports = { requireSpaceAfter = true; if (typeof config === "object") { - if (Object.prototype.hasOwnProperty.call(config, "before")) { - requireSpaceBefore = config.before; - } - if (Object.prototype.hasOwnProperty.call(config, "after")) { - requireSpaceAfter = config.after; - } + requireSpaceBefore = config.before; + requireSpaceAfter = config.after; } /** diff --git a/tools/node_modules/eslint/lib/rules/semi.js b/tools/node_modules/eslint/lib/rules/semi.js index e8f4c959d4c7df..f7bc0f5fd66198 100644 --- a/tools/node_modules/eslint/lib/rules/semi.js +++ b/tools/node_modules/eslint/lib/rules/semi.js @@ -40,7 +40,8 @@ module.exports = { type: "object", properties: { beforeStatementContinuationChars: { - enum: ["always", "any", "never"] + enum: ["always", "any", "never"], + default: "any" } }, additionalProperties: false @@ -58,7 +59,7 @@ module.exports = { { type: "object", properties: { - omitLastInOneLineBlock: { type: "boolean" } + omitLastInOneLineBlock: { type: "boolean", default: false } }, additionalProperties: false } @@ -75,8 +76,8 @@ module.exports = { const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-` const options = context.options[1]; const never = context.options[0] === "never"; - const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock); - const beforeStatementContinuationChars = (options && options.beforeStatementContinuationChars) || "any"; + const exceptOneLine = options && options.omitLastInOneLineBlock; + const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars; const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- diff --git a/tools/node_modules/eslint/lib/rules/sort-imports.js b/tools/node_modules/eslint/lib/rules/sort-imports.js index 1c0d134046d9f4..05e643ca0611d5 100644 --- a/tools/node_modules/eslint/lib/rules/sort-imports.js +++ b/tools/node_modules/eslint/lib/rules/sort-imports.js @@ -25,7 +25,8 @@ module.exports = { type: "object", properties: { ignoreCase: { - type: "boolean" + type: "boolean", + default: false }, memberSyntaxSortOrder: { type: "array", @@ -37,10 +38,12 @@ module.exports = { maxItems: 4 }, ignoreDeclarationSort: { - type: "boolean" + type: "boolean", + default: false }, ignoreMemberSort: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/sort-keys.js b/tools/node_modules/eslint/lib/rules/sort-keys.js index 0668e617d3c785..08bfcdf3d8335b 100644 --- a/tools/node_modules/eslint/lib/rules/sort-keys.js +++ b/tools/node_modules/eslint/lib/rules/sort-keys.js @@ -90,10 +90,12 @@ module.exports = { type: "object", properties: { caseSensitive: { - type: "boolean" + type: "boolean", + default: true }, natural: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -106,8 +108,8 @@ module.exports = { // Parse options. const order = context.options[0] || "asc"; const options = context.options[1]; - const insensitive = (options && options.caseSensitive) === false; - const natual = Boolean(options && options.natural); + const insensitive = options && options.caseSensitive === false; + const natual = options && options.natural; const isValidOrder = isValidOrders[ order + (insensitive ? "I" : "") + (natual ? "N" : "") ]; @@ -127,8 +129,12 @@ module.exports = { stack = stack.upper; }, + SpreadElement() { + stack.prevName = null; + }, + Property(node) { - if (node.parent.type === "ObjectPattern" || node.parent.properties.some(n => n.type === "SpreadElement")) { + if (node.parent.type === "ObjectPattern") { return; } diff --git a/tools/node_modules/eslint/lib/rules/sort-vars.js b/tools/node_modules/eslint/lib/rules/sort-vars.js index b6a2c86779c095..e85c6534e3a189 100644 --- a/tools/node_modules/eslint/lib/rules/sort-vars.js +++ b/tools/node_modules/eslint/lib/rules/sort-vars.js @@ -25,7 +25,8 @@ module.exports = { type: "object", properties: { ignoreCase: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/space-before-function-paren.js b/tools/node_modules/eslint/lib/rules/space-before-function-paren.js index 64ba72bf9ead29..c0d8e509fddd63 100644 --- a/tools/node_modules/eslint/lib/rules/space-before-function-paren.js +++ b/tools/node_modules/eslint/lib/rules/space-before-function-paren.js @@ -37,13 +37,16 @@ module.exports = { type: "object", properties: { anonymous: { - enum: ["always", "never", "ignore"] + enum: ["always", "never", "ignore"], + default: "always" }, named: { - enum: ["always", "never", "ignore"] + enum: ["always", "never", "ignore"], + default: "always" }, asyncArrow: { - enum: ["always", "never", "ignore"] + enum: ["always", "never", "ignore"], + default: "always" } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/space-infix-ops.js b/tools/node_modules/eslint/lib/rules/space-infix-ops.js index 254616d998d40d..8d1d172c6697b6 100644 --- a/tools/node_modules/eslint/lib/rules/space-infix-ops.js +++ b/tools/node_modules/eslint/lib/rules/space-infix-ops.js @@ -26,7 +26,8 @@ module.exports = { type: "object", properties: { int32Hint: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/space-unary-ops.js b/tools/node_modules/eslint/lib/rules/space-unary-ops.js index 046be22bec8644..779697b5b39b08 100644 --- a/tools/node_modules/eslint/lib/rules/space-unary-ops.js +++ b/tools/node_modules/eslint/lib/rules/space-unary-ops.js @@ -32,10 +32,12 @@ module.exports = { type: "object", properties: { words: { - type: "boolean" + type: "boolean", + default: true }, nonwords: { - type: "boolean" + type: "boolean", + default: false }, overrides: { type: "object", @@ -58,7 +60,7 @@ module.exports = { }, create(context) { - const options = context.options && Array.isArray(context.options) && context.options[0] || { words: true, nonwords: false }; + const options = context.options[0] || { words: true, nonwords: false }; const sourceCode = context.getSourceCode(); diff --git a/tools/node_modules/eslint/lib/rules/spaced-comment.js b/tools/node_modules/eslint/lib/rules/spaced-comment.js index d4c86d27cf8fc7..63177eb1c7f4f4 100644 --- a/tools/node_modules/eslint/lib/rules/spaced-comment.js +++ b/tools/node_modules/eslint/lib/rules/spaced-comment.js @@ -215,7 +215,8 @@ module.exports = { } }, balanced: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/switch-colon-spacing.js b/tools/node_modules/eslint/lib/rules/switch-colon-spacing.js index 9c7c0d589e0552..40154862d19215 100644 --- a/tools/node_modules/eslint/lib/rules/switch-colon-spacing.js +++ b/tools/node_modules/eslint/lib/rules/switch-colon-spacing.js @@ -30,8 +30,8 @@ module.exports = { { type: "object", properties: { - before: { type: "boolean" }, - after: { type: "boolean" } + before: { type: "boolean", default: false }, + after: { type: "boolean", default: true } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/valid-jsdoc.js b/tools/node_modules/eslint/lib/rules/valid-jsdoc.js index 515ba78b1d4fcf..46eb02211a4872 100644 --- a/tools/node_modules/eslint/lib/rules/valid-jsdoc.js +++ b/tools/node_modules/eslint/lib/rules/valid-jsdoc.js @@ -42,22 +42,27 @@ module.exports = { } }, requireReturn: { - type: "boolean" + type: "boolean", + default: true }, requireParamDescription: { - type: "boolean" + type: "boolean", + default: true }, requireReturnDescription: { - type: "boolean" + type: "boolean", + default: true }, matchDescription: { type: "string" }, requireReturnType: { - type: "boolean" + type: "boolean", + default: true }, requireParamType: { - type: "boolean" + type: "boolean", + default: true } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/valid-typeof.js b/tools/node_modules/eslint/lib/rules/valid-typeof.js index 7fa2b89bd051a5..16b2a47d371ca6 100644 --- a/tools/node_modules/eslint/lib/rules/valid-typeof.js +++ b/tools/node_modules/eslint/lib/rules/valid-typeof.js @@ -24,7 +24,8 @@ module.exports = { type: "object", properties: { requireStringLiterals: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/rules/wrap-iife.js b/tools/node_modules/eslint/lib/rules/wrap-iife.js index 628ebf532e0254..0e54157f102f7d 100644 --- a/tools/node_modules/eslint/lib/rules/wrap-iife.js +++ b/tools/node_modules/eslint/lib/rules/wrap-iife.js @@ -34,7 +34,8 @@ module.exports = { type: "object", properties: { functionPrototypeMethods: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false @@ -52,7 +53,7 @@ module.exports = { create(context) { const style = context.options[0] || "outside"; - const includeFunctionPrototypeMethods = (context.options[1] && context.options[1].functionPrototypeMethods) || false; + const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods; const sourceCode = context.getSourceCode(); diff --git a/tools/node_modules/eslint/lib/rules/yield-star-spacing.js b/tools/node_modules/eslint/lib/rules/yield-star-spacing.js index 20b8e9ea91eb2e..17124dd6ec7c7d 100644 --- a/tools/node_modules/eslint/lib/rules/yield-star-spacing.js +++ b/tools/node_modules/eslint/lib/rules/yield-star-spacing.js @@ -31,8 +31,8 @@ module.exports = { { type: "object", properties: { - before: { type: "boolean" }, - after: { type: "boolean" } + before: { type: "boolean", default: false }, + after: { type: "boolean", default: true } }, additionalProperties: false } diff --git a/tools/node_modules/eslint/lib/rules/yoda.js b/tools/node_modules/eslint/lib/rules/yoda.js index 83c435a4f74c3a..825634a79f6899 100644 --- a/tools/node_modules/eslint/lib/rules/yoda.js +++ b/tools/node_modules/eslint/lib/rules/yoda.js @@ -169,10 +169,12 @@ module.exports = { type: "object", properties: { exceptRange: { - type: "boolean" + type: "boolean", + default: false }, onlyEquality: { - type: "boolean" + type: "boolean", + default: false } }, additionalProperties: false diff --git a/tools/node_modules/eslint/lib/util/ajv.js b/tools/node_modules/eslint/lib/util/ajv.js index 285176da87dc42..ecf0ebd172cd51 100644 --- a/tools/node_modules/eslint/lib/util/ajv.js +++ b/tools/node_modules/eslint/lib/util/ajv.js @@ -17,6 +17,7 @@ const Ajv = require("ajv"), const ajv = new Ajv({ meta: false, + useDefaults: true, validateSchema: false, missingRefs: "ignore", verbose: true, diff --git a/tools/node_modules/eslint/node_modules/acorn/README.md b/tools/node_modules/eslint/node_modules/acorn/README.md index e66dac31de22b2..3e5f58d95dea95 100644 --- a/tools/node_modules/eslint/node_modules/acorn/README.md +++ b/tools/node_modules/eslint/node_modules/acorn/README.md @@ -5,7 +5,7 @@ A tiny, fast JavaScript parser written in JavaScript. ## Community Acorn is open source software released under an -[MIT license](https://github.com/acornjs/acorn/blob/master/LICENSE). +[MIT license](https://github.com/acornjs/acorn/blob/master/acorn/LICENSE). You are welcome to [report bugs](https://github.com/acornjs/acorn/issues) or create pull diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js index e4a0fe3a3bc3b3..44d95c5fae74db 100644 --- a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js @@ -254,7 +254,7 @@ function isNewLine(code, ecma2019String) { return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029)) } -var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; +var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/; var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; @@ -272,6 +272,10 @@ var isArray = Array.isArray || (function (obj) { return ( toString.call(obj) === "[object Array]" ); }); +function wordsRegexp(words) { + return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$") +} + // These are used when `options.locations` is on, for the // `startLoc` and `endLoc` properties. @@ -460,24 +464,20 @@ var BIND_FUNCTION = 3; var BIND_SIMPLE_CATCH = 4; var BIND_OUTSIDE = 5; // Special case for function names as bound inside the function -function keywordRegexp(words) { - 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]); + this.keywords = wordsRegexp(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"; } } - this.reservedWords = keywordRegexp(reserved); + this.reservedWords = wordsRegexp(reserved); var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict; - this.reservedWordsStrict = keywordRegexp(reservedStrict); - this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind); + this.reservedWordsStrict = wordsRegexp(reservedStrict); + this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind); this.input = String(input); // Used to signal to callers of `readWord1` whether the word @@ -526,9 +526,11 @@ var Parser = function Parser(options, input, startPos) { this.potentialArrowAt = -1; // Positions to delayed-check that yield/await does not exist in default parameters. - this.yieldPos = this.awaitPos = 0; + this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; // Labels in scope. this.labels = []; + // Thus-far undefined exports. + this.undefinedExports = {}; // If enabled, skip leading hashbang line. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") @@ -605,7 +607,7 @@ pp.strictDirective = function(start) { // Skip semicolon, if any. skipWhiteSpace.lastIndex = start; start += skipWhiteSpace.exec(this$1.input)[0].length; - if (this$1.input[start] === ';') + if (this$1.input[start] === ";") { start++; } } }; @@ -747,6 +749,13 @@ pp$1.parseTopLevel = function(node) { var stmt = this$1.parseStatement(null, true, exports); node.body.push(stmt); } + if (this.inModule) + { for (var i = 0, list = Object.keys(this$1.undefinedExports); i < list.length; i += 1) + { + var name = list[i]; + + this$1.raiseRecoverable(this$1.undefinedExports[name].start, ("Export '" + name + "' is not defined")); + } } this.adaptDirectivePrologue(node.body); this.next(); if (this.options.ecmaVersion >= 6) { @@ -1238,8 +1247,9 @@ var FUNC_HANGING_STATEMENT = 2; var FUNC_NULLABLE_ID = 4; // Parse a function declaration or literal (depending on the -// `isStatement` parameter). +// `statement & FUNC_STATEMENT`). +// Remove `allowExpressionBody` for 7.0.0, as it is only called with false pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) { this.initFunction(node); if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) { @@ -1260,19 +1270,21 @@ pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) { { this.checkLVal(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); } } - var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; + var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.yieldPos = 0; this.awaitPos = 0; + this.awaitIdentPos = 0; this.enterScope(functionFlags(node.async, node.generator)); if (!(statement & FUNC_STATEMENT)) { node.id = this.type === types.name ? this.parseIdent() : null; } this.parseFunctionParams(node); - this.parseFunctionBody(node, allowExpressionBody); + this.parseFunctionBody(node, allowExpressionBody, false); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; + this.awaitIdentPos = oldAwaitIdentPos; return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression") }; @@ -1415,7 +1427,7 @@ pp$1.parseExport = function(node, exports) { var fNode = this.startNode(); this.next(); if (isAsync) { this.next(); } - node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync, true); + node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync); } else if (this.type === types._class) { var cNode = this.startNode(); node.declaration = this.parseClass(cNode, "nullableID"); @@ -1441,11 +1453,13 @@ pp$1.parseExport = function(node, exports) { if (this.type !== types.string) { this.unexpected(); } node.source = this.parseExprAtom(); } else { - // check for keywords used as local names for (var i = 0, list = node.specifiers; i < list.length; i += 1) { + // check for keywords used as local names var spec = list[i]; this$1.checkUnreserved(spec.local); + // check if export is defined + this$1.checkLocalExport(spec.local); } node.source = null; @@ -1624,7 +1638,7 @@ pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) { 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, "Cannot use 'await' as identifier inside an async function"); } break case "ObjectPattern": @@ -2125,42 +2139,53 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; - 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 === 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 + while (true) { + var element = this$1.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow); + if (element === base || element.type === "ArrowFunctionExpression") { return element } + base = element; + } +}; + +pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow) { + var computed = this.eat(types.bracketL); + if (computed || this.eat(types.dot)) { + var node = this.startNodeAt(startPos, startLoc); + node.object = base; + node.property = computed ? this.parseExpression() : this.parseIdent(true); + node.computed = !!computed; + if (computed) { this.expect(types.bracketR); } + base = this.finishNode(node, "MemberExpression"); + } else if (!noCalls && this.eat(types.parenL)) { + var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; + this.yieldPos = 0; + this.awaitPos = 0; + this.awaitIdentPos = 0; + var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors); + if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) { + this.checkPatternErrors(refDestructuringErrors, false); + this.checkYieldAwaitInDefaultParams(); + if (this.awaitIdentPos > 0) + { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); } + this.yieldPos = oldYieldPos; + this.awaitPos = oldAwaitPos; + this.awaitIdentPos = oldAwaitIdentPos; + return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true) } + this.checkExpressionErrors(refDestructuringErrors, true); + this.yieldPos = oldYieldPos || this.yieldPos; + this.awaitPos = oldAwaitPos || this.awaitPos; + this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos; + var node$1 = this.startNodeAt(startPos, startLoc); + node$1.callee = base; + node$1.arguments = exprList; + base = this.finishNode(node$1, "CallExpression"); + } else if (this.type === types.backQuote) { + var node$2 = this.startNodeAt(startPos, startLoc); + node$2.tag = base; + node$2.quasi = this.parseTemplate({isTagged: true}); + base = this.finishNode(node$2, "TaggedTemplateExpression"); } + return base }; // Parse an atomic expression — either a single token that is an @@ -2199,14 +2224,14 @@ pp$3.parseExprAtom = function(refDestructuringErrors) { case types.name: var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc; - var id = this.parseIdent(this.type !== types.name); + var id = this.parseIdent(false); if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) { return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true) } if (canBeArrow && !this.canInsertSemicolon()) { 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 && !containsEsc) { - id = this.parseIdent(); + id = this.parseIdent(false); if (this.canInsertSemicolon() || !this.eat(types.arrow)) { this.unexpected(); } return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true) @@ -2295,6 +2320,7 @@ pp$3.parseParenAndDistinguishExpression = function(canBeArrow) { var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart; this.yieldPos = 0; this.awaitPos = 0; + // Do not save awaitIdentPos to allow checking awaits nested in parameters while (this.type !== types.parenR) { first ? first = false : this$1.expect(types.comma); if (allowTrailingComma && this$1.afterTrailingComma(types.parenR, true)) { @@ -2538,7 +2564,10 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP { 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 (isGenerator || isAsync) { this.unexpected(); } this.checkUnreserved(prop.key); + if (prop.key.name === "await" && !this.awaitIdentPos) + { this.awaitIdentPos = startPos; } prop.kind = "init"; if (isPattern) { prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key); @@ -2578,7 +2607,7 @@ pp$3.initFunction = function(node) { // Parse object or class method. pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) { - var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; + var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.initFunction(node); if (this.options.ecmaVersion >= 6) @@ -2588,22 +2617,24 @@ pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) { this.yieldPos = 0; this.awaitPos = 0; + this.awaitIdentPos = 0; this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)); this.expect(types.parenL); node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8); this.checkYieldAwaitInDefaultParams(); - this.parseFunctionBody(node, false); + this.parseFunctionBody(node, false, true); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; + this.awaitIdentPos = oldAwaitIdentPos; return this.finishNode(node, "FunctionExpression") }; // Parse arrow function expression with given parameters. pp$3.parseArrowExpression = function(node, params, isAsync) { - var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; + var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW); this.initFunction(node); @@ -2611,18 +2642,20 @@ pp$3.parseArrowExpression = function(node, params, isAsync) { this.yieldPos = 0; this.awaitPos = 0; + this.awaitIdentPos = 0; node.params = this.toAssignableList(params, true); - this.parseFunctionBody(node, true); + this.parseFunctionBody(node, true, false); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; + this.awaitIdentPos = oldAwaitIdentPos; return this.finishNode(node, "ArrowFunctionExpression") }; // Parse function body and check parameters. -pp$3.parseFunctionBody = function(node, isArrowFunction) { +pp$3.parseFunctionBody = function(node, isArrowFunction, isMethod) { var isExpression = isArrowFunction && this.type !== types.braceL; var oldStrict = this.strict, useStrict = false; @@ -2648,7 +2681,7 @@ pp$3.parseFunctionBody = function(node, isArrowFunction) { // 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)); + this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); node.body = this.parseBlock(false); node.expression = false; this.adaptDirectivePrologue(node.body.body); @@ -2723,9 +2756,9 @@ pp$3.checkUnreserved = function(ref) { var name = ref.name; if (this.inGenerator && name === "yield") - { this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator"); } + { this.raiseRecoverable(start, "Cannot 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"); } + { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); } if (this.keywords.test(name)) { this.raise(start, ("Unexpected keyword '" + name + "'")); } if (this.options.ecmaVersion < 6 && @@ -2733,7 +2766,7 @@ pp$3.checkUnreserved = function(ref) { var re = this.strict ? this.reservedWordsStrict : this.reservedWords; if (re.test(name)) { if (!this.inAsync && name === "await") - { this.raiseRecoverable(start, "Can not use keyword 'await' outside an async function"); } + { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); } this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); } }; @@ -2763,7 +2796,11 @@ pp$3.parseIdent = function(liberal, isBinding) { } this.next(); this.finishNode(node, "Identifier"); - if (!liberal) { this.checkUnreserved(node); } + if (!liberal) { + this.checkUnreserved(node); + if (node.name === "await" && !this.awaitIdentPos) + { this.awaitIdentPos = node.start; } + } return node }; @@ -2843,7 +2880,7 @@ pp$5.exitScope = function() { // > At the top level of a function, or script, function declarations are // > treated like var declarations rather than like lexical declarations. pp$5.treatFunctionsAsVarInScope = function(scope) { - return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP); + return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP) }; pp$5.declareName = function(name, bindingType, pos) { @@ -2854,6 +2891,8 @@ pp$5.declareName = function(name, bindingType, pos) { var scope = this.currentScope(); redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1; scope.lexical.push(name); + if (this.inModule && (scope.flags & SCOPE_TOP)) + { delete this.undefinedExports[name]; } } else if (bindingType === BIND_SIMPLE_CATCH) { var scope$1 = this.currentScope(); scope$1.lexical.push(name); @@ -2867,18 +2906,28 @@ pp$5.declareName = function(name, bindingType, pos) { } else { for (var i = this.scopeStack.length - 1; i >= 0; --i) { var scope$3 = this$1.scopeStack[i]; - if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name || + if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) || !this$1.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) { redeclared = true; break } scope$3.var.push(name); + if (this$1.inModule && (scope$3.flags & SCOPE_TOP)) + { delete this$1.undefinedExports[name]; } if (scope$3.flags & SCOPE_VAR) { break } } } if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); } }; +pp$5.checkLocalExport = function(id) { + // scope.functions must be empty as Module code is always strict. + if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && + this.scopeStack[0].var.indexOf(id.name) === -1) { + this.undefinedExports[id.name] = id; + } +}; + pp$5.currentScope = function() { return this.scopeStack[this.scopeStack.length - 1] }; @@ -3094,473 +3143,51 @@ types.name.updateContext = function(prevType) { this.exprAllowed = allowed; }; -var data = { - "$LONE": [ - "ASCII", - "ASCII_Hex_Digit", - "AHex", - "Alphabetic", - "Alpha", - "Any", - "Assigned", - "Bidi_Control", - "Bidi_C", - "Bidi_Mirrored", - "Bidi_M", - "Case_Ignorable", - "CI", - "Cased", - "Changes_When_Casefolded", - "CWCF", - "Changes_When_Casemapped", - "CWCM", - "Changes_When_Lowercased", - "CWL", - "Changes_When_NFKC_Casefolded", - "CWKCF", - "Changes_When_Titlecased", - "CWT", - "Changes_When_Uppercased", - "CWU", - "Dash", - "Default_Ignorable_Code_Point", - "DI", - "Deprecated", - "Dep", - "Diacritic", - "Dia", - "Emoji", - "Emoji_Component", - "Emoji_Modifier", - "Emoji_Modifier_Base", - "Emoji_Presentation", - "Extender", - "Ext", - "Grapheme_Base", - "Gr_Base", - "Grapheme_Extend", - "Gr_Ext", - "Hex_Digit", - "Hex", - "IDS_Binary_Operator", - "IDSB", - "IDS_Trinary_Operator", - "IDST", - "ID_Continue", - "IDC", - "ID_Start", - "IDS", - "Ideographic", - "Ideo", - "Join_Control", - "Join_C", - "Logical_Order_Exception", - "LOE", - "Lowercase", - "Lower", - "Math", - "Noncharacter_Code_Point", - "NChar", - "Pattern_Syntax", - "Pat_Syn", - "Pattern_White_Space", - "Pat_WS", - "Quotation_Mark", - "QMark", - "Radical", - "Regional_Indicator", - "RI", - "Sentence_Terminal", - "STerm", - "Soft_Dotted", - "SD", - "Terminal_Punctuation", - "Term", - "Unified_Ideograph", - "UIdeo", - "Uppercase", - "Upper", - "Variation_Selector", - "VS", - "White_Space", - "space", - "XID_Continue", - "XIDC", - "XID_Start", - "XIDS" - ], - "General_Category": [ - "Cased_Letter", - "LC", - "Close_Punctuation", - "Pe", - "Connector_Punctuation", - "Pc", - "Control", - "Cc", - "cntrl", - "Currency_Symbol", - "Sc", - "Dash_Punctuation", - "Pd", - "Decimal_Number", - "Nd", - "digit", - "Enclosing_Mark", - "Me", - "Final_Punctuation", - "Pf", - "Format", - "Cf", - "Initial_Punctuation", - "Pi", - "Letter", - "L", - "Letter_Number", - "Nl", - "Line_Separator", - "Zl", - "Lowercase_Letter", - "Ll", - "Mark", - "M", - "Combining_Mark", - "Math_Symbol", - "Sm", - "Modifier_Letter", - "Lm", - "Modifier_Symbol", - "Sk", - "Nonspacing_Mark", - "Mn", - "Number", - "N", - "Open_Punctuation", - "Ps", - "Other", - "C", - "Other_Letter", - "Lo", - "Other_Number", - "No", - "Other_Punctuation", - "Po", - "Other_Symbol", - "So", - "Paragraph_Separator", - "Zp", - "Private_Use", - "Co", - "Punctuation", - "P", - "punct", - "Separator", - "Z", - "Space_Separator", - "Zs", - "Spacing_Mark", - "Mc", - "Surrogate", - "Cs", - "Symbol", - "S", - "Titlecase_Letter", - "Lt", - "Unassigned", - "Cn", - "Uppercase_Letter", - "Lu" - ], - "Script": [ - "Adlam", - "Adlm", - "Ahom", - "Anatolian_Hieroglyphs", - "Hluw", - "Arabic", - "Arab", - "Armenian", - "Armn", - "Avestan", - "Avst", - "Balinese", - "Bali", - "Bamum", - "Bamu", - "Bassa_Vah", - "Bass", - "Batak", - "Batk", - "Bengali", - "Beng", - "Bhaiksuki", - "Bhks", - "Bopomofo", - "Bopo", - "Brahmi", - "Brah", - "Braille", - "Brai", - "Buginese", - "Bugi", - "Buhid", - "Buhd", - "Canadian_Aboriginal", - "Cans", - "Carian", - "Cari", - "Caucasian_Albanian", - "Aghb", - "Chakma", - "Cakm", - "Cham", - "Cherokee", - "Cher", - "Common", - "Zyyy", - "Coptic", - "Copt", - "Qaac", - "Cuneiform", - "Xsux", - "Cypriot", - "Cprt", - "Cyrillic", - "Cyrl", - "Deseret", - "Dsrt", - "Devanagari", - "Deva", - "Duployan", - "Dupl", - "Egyptian_Hieroglyphs", - "Egyp", - "Elbasan", - "Elba", - "Ethiopic", - "Ethi", - "Georgian", - "Geor", - "Glagolitic", - "Glag", - "Gothic", - "Goth", - "Grantha", - "Gran", - "Greek", - "Grek", - "Gujarati", - "Gujr", - "Gurmukhi", - "Guru", - "Han", - "Hani", - "Hangul", - "Hang", - "Hanunoo", - "Hano", - "Hatran", - "Hatr", - "Hebrew", - "Hebr", - "Hiragana", - "Hira", - "Imperial_Aramaic", - "Armi", - "Inherited", - "Zinh", - "Qaai", - "Inscriptional_Pahlavi", - "Phli", - "Inscriptional_Parthian", - "Prti", - "Javanese", - "Java", - "Kaithi", - "Kthi", - "Kannada", - "Knda", - "Katakana", - "Kana", - "Kayah_Li", - "Kali", - "Kharoshthi", - "Khar", - "Khmer", - "Khmr", - "Khojki", - "Khoj", - "Khudawadi", - "Sind", - "Lao", - "Laoo", - "Latin", - "Latn", - "Lepcha", - "Lepc", - "Limbu", - "Limb", - "Linear_A", - "Lina", - "Linear_B", - "Linb", - "Lisu", - "Lycian", - "Lyci", - "Lydian", - "Lydi", - "Mahajani", - "Mahj", - "Malayalam", - "Mlym", - "Mandaic", - "Mand", - "Manichaean", - "Mani", - "Marchen", - "Marc", - "Masaram_Gondi", - "Gonm", - "Meetei_Mayek", - "Mtei", - "Mende_Kikakui", - "Mend", - "Meroitic_Cursive", - "Merc", - "Meroitic_Hieroglyphs", - "Mero", - "Miao", - "Plrd", - "Modi", - "Mongolian", - "Mong", - "Mro", - "Mroo", - "Multani", - "Mult", - "Myanmar", - "Mymr", - "Nabataean", - "Nbat", - "New_Tai_Lue", - "Talu", - "Newa", - "Nko", - "Nkoo", - "Nushu", - "Nshu", - "Ogham", - "Ogam", - "Ol_Chiki", - "Olck", - "Old_Hungarian", - "Hung", - "Old_Italic", - "Ital", - "Old_North_Arabian", - "Narb", - "Old_Permic", - "Perm", - "Old_Persian", - "Xpeo", - "Old_South_Arabian", - "Sarb", - "Old_Turkic", - "Orkh", - "Oriya", - "Orya", - "Osage", - "Osge", - "Osmanya", - "Osma", - "Pahawh_Hmong", - "Hmng", - "Palmyrene", - "Palm", - "Pau_Cin_Hau", - "Pauc", - "Phags_Pa", - "Phag", - "Phoenician", - "Phnx", - "Psalter_Pahlavi", - "Phlp", - "Rejang", - "Rjng", - "Runic", - "Runr", - "Samaritan", - "Samr", - "Saurashtra", - "Saur", - "Sharada", - "Shrd", - "Shavian", - "Shaw", - "Siddham", - "Sidd", - "SignWriting", - "Sgnw", - "Sinhala", - "Sinh", - "Sora_Sompeng", - "Sora", - "Soyombo", - "Soyo", - "Sundanese", - "Sund", - "Syloti_Nagri", - "Sylo", - "Syriac", - "Syrc", - "Tagalog", - "Tglg", - "Tagbanwa", - "Tagb", - "Tai_Le", - "Tale", - "Tai_Tham", - "Lana", - "Tai_Viet", - "Tavt", - "Takri", - "Takr", - "Tamil", - "Taml", - "Tangut", - "Tang", - "Telugu", - "Telu", - "Thaana", - "Thaa", - "Thai", - "Tibetan", - "Tibt", - "Tifinagh", - "Tfng", - "Tirhuta", - "Tirh", - "Ugaritic", - "Ugar", - "Vai", - "Vaii", - "Warang_Citi", - "Wara", - "Yi", - "Yiii", - "Zanabazar_Square", - "Zanb" - ] -}; -Array.prototype.push.apply(data.$LONE, data.General_Category); -data.gc = data.General_Category; -data.sc = data.Script_Extensions = data.scx = data.Script; +// This file contains Unicode properties extracted from the ECMAScript +// specification. The lists are extracted like so: +// $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText) + +// #table-binary-unicode-properties +var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS"; +var unicodeBinaryProperties = { + 9: ecma9BinaryProperties, + 10: ecma9BinaryProperties + " Extended_Pictographic" +}; + +// #table-unicode-general-category-values +var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu"; + +// #table-unicode-script-values +var ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb"; +var unicodeScriptValues = { + 9: ecma9ScriptValues, + 10: ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd" +}; + +var data = {}; +function buildUnicodeData(ecmaVersion) { + var d = data[ecmaVersion] = { + binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues), + nonBinary: { + General_Category: wordsRegexp(unicodeGeneralCategoryValues), + Script: wordsRegexp(unicodeScriptValues[ecmaVersion]) + } + }; + d.nonBinary.Script_Extensions = d.nonBinary.Script; + + d.nonBinary.gc = d.nonBinary.General_Category; + d.nonBinary.sc = d.nonBinary.Script; + d.nonBinary.scx = d.nonBinary.Script_Extensions; +} +buildUnicodeData(9); +buildUnicodeData(10); var pp$9 = Parser.prototype; var RegExpValidationState = function RegExpValidationState(parser) { this.parser = parser; this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : ""); + this.unicodeProperties = data[parser.options.ecmaVersion >= 10 ? 10 : parser.options.ecmaVersion]; this.source = ""; this.flags = ""; this.start = 0; @@ -4344,14 +3971,14 @@ pp$9.regexp_eatUnicodePropertyValueExpression = function(state) { return false }; pp$9.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) { - if (!data.hasOwnProperty(name) || data[name].indexOf(value) === -1) { - state.raise("Invalid property name"); - } + if (!has(state.unicodeProperties.nonBinary, name)) + { state.raise("Invalid property name"); } + if (!state.unicodeProperties.nonBinary[name].test(value)) + { state.raise("Invalid property value"); } }; pp$9.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) { - if (data.$LONE.indexOf(nameOrValue) === -1) { - state.raise("Invalid property name"); - } + if (!state.unicodeProperties.binary.test(nameOrValue)) + { state.raise("Invalid property name"); } }; // UnicodePropertyName :: @@ -5334,7 +4961,7 @@ pp$8.readWord = function() { // // [walk]: util/walk.js -var version = "6.0.6"; +var version = "6.1.0"; // The main exported interface (under `self.acorn` when in the // browser) is a `parse` function that takes a code string and diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map index 63bbd1d8fb4fc7..219dac5954a3be 100644 --- a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js.map @@ -1 +1 @@ -{"version":3,"file":"acorn.js","sources":["../src/identifier.js","../src/tokentype.js","../src/whitespace.js","../src/util.js","../src/locutil.js","../src/options.js","../src/scopeflags.js","../src/state.js","../src/parseutil.js","../src/statement.js","../src/lval.js","../src/expression.js","../src/location.js","../src/scope.js","../src/node.js","../src/tokencontext.js","../src/unicode-property-data.js","../src/regexp.js","../src/tokenize.js","../src/index.js"],"sourcesContent":["// Reserved word lists for various dialects of the language\n\nexport const reservedWords = {\n 3: \"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile\",\n 5: \"class enum extends super const export import\",\n 6: \"enum\",\n strict: \"implements interface let package private protected public static yield\",\n strictBind: \"eval arguments\"\n}\n\n// And the keywords\n\nconst 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\"\n\nexport const keywords = {\n 5: ecma5AndLessKeywords,\n 6: ecma5AndLessKeywords + \" const class extends export import super\"\n}\n\nexport const keywordRelationalOperator = /^in(stanceof)?$/\n\n// ## Character categories\n\n// Big ugly regular expressions that match characters in the\n// whitespace, identifier, and identifier-start categories. These\n// are only applied when a character is found to actually have a\n// code point above 128.\n// Generated by `bin/generate-identifier-regex.js`.\n\nlet 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\\u0560-\\u0588\\u05d0-\\u05ea\\u05ef-\\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\\u0860-\\u086a\\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\\u09fc\\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-\\u1878\\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\\u1c90-\\u1cba\\u1cbd-\\u1cbf\\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-\\u312f\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fef\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7b9\\ua7f7-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua8fd\\ua8fe\\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\"\nlet 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\\u07fd\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u08d3-\\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\\u09fe\\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\\u0afa-\\u0aff\\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-\\u0c04\\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\\u0d00-\\u0d03\\u0d3b\\u0d3c\\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\\u1cf7-\\u1cf9\\u1dc0-\\u1df9\\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\\ua8ff-\\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\"\n\nconst nonASCIIidentifierStart = new RegExp(\"[\" + nonASCIIidentifierStartChars + \"]\")\nconst nonASCIIidentifier = new RegExp(\"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\")\n\nnonASCIIidentifierStartChars = nonASCIIidentifierChars = null\n\n// These are a run-length and offset encoded representation of the\n// >0xffff code points that are a valid part of identifiers. The\n// offset starts at 0x10000, and each pair of numbers represents an\n// offset to the next range, and then a size of the range. They were\n// generated by bin/generate-identifier-regex.js\n\n// eslint-disable-next-line comma-spacing\nconst astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,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,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,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,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,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,15,7472,3104,541]\n\n// eslint-disable-next-line comma-spacing\nconst astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,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]\n\n// This has a complexity linear to the value of the code. The\n// assumption is that looking up astral identifier characters is\n// rare.\nfunction isInAstralSet(code, set) {\n let pos = 0x10000\n for (let i = 0; i < set.length; i += 2) {\n pos += set[i]\n if (pos > code) return false\n pos += set[i + 1]\n if (pos >= code) return true\n }\n}\n\n// Test whether a given character code starts an identifier.\n\nexport function isIdentifierStart(code, astral) {\n if (code < 65) return code === 36\n if (code < 91) return true\n if (code < 97) return code === 95\n if (code < 123) return true\n if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))\n if (astral === false) return false\n return isInAstralSet(code, astralIdentifierStartCodes)\n}\n\n// Test whether a given character is part of an identifier.\n\nexport function isIdentifierChar(code, astral) {\n if (code < 48) return code === 36\n if (code < 58) return true\n if (code < 65) return false\n if (code < 91) return true\n if (code < 97) return code === 95\n if (code < 123) return true\n if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code))\n if (astral === false) return false\n return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)\n}\n","// ## Token types\n\n// The assignment of fine-grained, information-carrying type objects\n// allows the tokenizer to store the information it has about a\n// token in a way that is very cheap for the parser to look up.\n\n// All token type variables start with an underscore, to make them\n// easy to recognize.\n\n// The `beforeExpr` property is used to disambiguate between regular\n// expressions and divisions. It is set on all token types that can\n// be followed by an expression (thus, a slash after them would be a\n// regular expression).\n//\n// The `startsExpr` property is used to check if the token ends a\n// `yield` expression. It is set on all token types that either can\n// directly start an expression (like a quotation mark) or can\n// continue an expression (like the body of a string).\n//\n// `isLoop` marks a keyword as starting a loop, which is important\n// to know when parsing a label, in order to allow or disallow\n// continue jumps to that label.\n\nexport class TokenType {\n constructor(label, conf = {}) {\n this.label = label\n this.keyword = conf.keyword\n this.beforeExpr = !!conf.beforeExpr\n this.startsExpr = !!conf.startsExpr\n this.isLoop = !!conf.isLoop\n this.isAssign = !!conf.isAssign\n this.prefix = !!conf.prefix\n this.postfix = !!conf.postfix\n this.binop = conf.binop || null\n this.updateContext = null\n }\n}\n\nfunction binop(name, prec) {\n return new TokenType(name, {beforeExpr: true, binop: prec})\n}\nconst beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true}\n\n// Map keyword names to token types.\n\nexport const keywords = {}\n\n// Succinct definitions of keyword token types\nfunction kw(name, options = {}) {\n options.keyword = name\n return keywords[name] = new TokenType(name, options)\n}\n\nexport const types = {\n num: new TokenType(\"num\", startsExpr),\n regexp: new TokenType(\"regexp\", startsExpr),\n string: new TokenType(\"string\", startsExpr),\n name: new TokenType(\"name\", startsExpr),\n eof: new TokenType(\"eof\"),\n\n // Punctuation token types.\n bracketL: new TokenType(\"[\", {beforeExpr: true, startsExpr: true}),\n bracketR: new TokenType(\"]\"),\n braceL: new TokenType(\"{\", {beforeExpr: true, startsExpr: true}),\n braceR: new TokenType(\"}\"),\n parenL: new TokenType(\"(\", {beforeExpr: true, startsExpr: true}),\n parenR: new TokenType(\")\"),\n comma: new TokenType(\",\", beforeExpr),\n semi: new TokenType(\";\", beforeExpr),\n colon: new TokenType(\":\", beforeExpr),\n dot: new TokenType(\".\"),\n question: new TokenType(\"?\", beforeExpr),\n arrow: new TokenType(\"=>\", beforeExpr),\n template: new TokenType(\"template\"),\n invalidTemplate: new TokenType(\"invalidTemplate\"),\n ellipsis: new TokenType(\"...\", beforeExpr),\n backQuote: new TokenType(\"`\", startsExpr),\n dollarBraceL: new TokenType(\"${\", {beforeExpr: true, startsExpr: true}),\n\n // Operators. These carry several kinds of properties to help the\n // parser use them properly (the presence of these properties is\n // what categorizes them as operators).\n //\n // `binop`, when present, specifies that this operator is a binary\n // operator, and will refer to its precedence.\n //\n // `prefix` and `postfix` mark the operator as a prefix or postfix\n // unary operator.\n //\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\n // binary operators with a very low precedence, that should result\n // in AssignmentExpression nodes.\n\n eq: new TokenType(\"=\", {beforeExpr: true, isAssign: true}),\n assign: new TokenType(\"_=\", {beforeExpr: true, isAssign: true}),\n incDec: new TokenType(\"++/--\", {prefix: true, postfix: true, startsExpr: true}),\n prefix: new TokenType(\"!/~\", {beforeExpr: true, prefix: true, startsExpr: true}),\n logicalOR: binop(\"||\", 1),\n logicalAND: binop(\"&&\", 2),\n bitwiseOR: binop(\"|\", 3),\n bitwiseXOR: binop(\"^\", 4),\n bitwiseAND: binop(\"&\", 5),\n equality: binop(\"==/!=/===/!==\", 6),\n relational: binop(\"/<=/>=\", 7),\n bitShift: binop(\"<>/>>>\", 8),\n plusMin: new TokenType(\"+/-\", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),\n modulo: binop(\"%\", 10),\n star: binop(\"*\", 10),\n slash: binop(\"/\", 10),\n starstar: new TokenType(\"**\", {beforeExpr: true}),\n\n // Keyword token types.\n _break: kw(\"break\"),\n _case: kw(\"case\", beforeExpr),\n _catch: kw(\"catch\"),\n _continue: kw(\"continue\"),\n _debugger: kw(\"debugger\"),\n _default: kw(\"default\", beforeExpr),\n _do: kw(\"do\", {isLoop: true, beforeExpr: true}),\n _else: kw(\"else\", beforeExpr),\n _finally: kw(\"finally\"),\n _for: kw(\"for\", {isLoop: true}),\n _function: kw(\"function\", startsExpr),\n _if: kw(\"if\"),\n _return: kw(\"return\", beforeExpr),\n _switch: kw(\"switch\"),\n _throw: kw(\"throw\", beforeExpr),\n _try: kw(\"try\"),\n _var: kw(\"var\"),\n _const: kw(\"const\"),\n _while: kw(\"while\", {isLoop: true}),\n _with: kw(\"with\"),\n _new: kw(\"new\", {beforeExpr: true, startsExpr: true}),\n _this: kw(\"this\", startsExpr),\n _super: kw(\"super\", startsExpr),\n _class: kw(\"class\", startsExpr),\n _extends: kw(\"extends\", beforeExpr),\n _export: kw(\"export\"),\n _import: kw(\"import\"),\n _null: kw(\"null\", startsExpr),\n _true: kw(\"true\", startsExpr),\n _false: kw(\"false\", startsExpr),\n _in: kw(\"in\", {beforeExpr: true, binop: 7}),\n _instanceof: kw(\"instanceof\", {beforeExpr: true, binop: 7}),\n _typeof: kw(\"typeof\", {beforeExpr: true, prefix: true, startsExpr: true}),\n _void: kw(\"void\", {beforeExpr: true, prefix: true, startsExpr: true}),\n _delete: kw(\"delete\", {beforeExpr: true, prefix: true, startsExpr: true})\n}\n","// Matches a whole line break (where CRLF is considered a single\n// line break). Used to count lines.\n\nexport const lineBreak = /\\r\\n?|\\n|\\u2028|\\u2029/\nexport const lineBreakG = new RegExp(lineBreak.source, \"g\")\n\nexport function isNewLine(code, ecma2019String) {\n return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029))\n}\n\nexport const nonASCIIwhitespace = /[\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/\n\nexport const skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g\n","const {hasOwnProperty, toString} = Object.prototype\n\n// Checks if an object has a property.\n\nexport function has(obj, propName) {\n return hasOwnProperty.call(obj, propName)\n}\n\nexport const isArray = Array.isArray || ((obj) => (\n toString.call(obj) === \"[object Array]\"\n))\n","import {lineBreakG} from \"./whitespace\"\n\n// These are used when `options.locations` is on, for the\n// `startLoc` and `endLoc` properties.\n\nexport class Position {\n constructor(line, col) {\n this.line = line\n this.column = col\n }\n\n offset(n) {\n return new Position(this.line, this.column + n)\n }\n}\n\nexport class SourceLocation {\n constructor(p, start, end) {\n this.start = start\n this.end = end\n if (p.sourceFile !== null) this.source = p.sourceFile\n }\n}\n\n// The `getLineInfo` function is mostly useful when the\n// `locations` option is off (for performance reasons) and you\n// want to find the line/column position for a given character\n// offset. `input` should be the code string that the offset refers\n// into.\n\nexport function getLineInfo(input, offset) {\n for (let line = 1, cur = 0;;) {\n lineBreakG.lastIndex = cur\n let match = lineBreakG.exec(input)\n if (match && match.index < offset) {\n ++line\n cur = match.index + match[0].length\n } else {\n return new Position(line, offset - cur)\n }\n }\n}\n","import {has, isArray} from \"./util\"\nimport {SourceLocation} from \"./locutil\"\n\n// A second optional argument can be given to further configure\n// the parser process. These options are recognized:\n\nexport const defaultOptions = {\n // `ecmaVersion` indicates the ECMAScript version to parse. Must be\n // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10\n // (2019). This influences support for strict mode, the set of\n // reserved words, and support for new syntax features. The default\n // is 9.\n ecmaVersion: 9,\n // `sourceType` indicates the mode the code should be parsed in.\n // Can be either `\"script\"` or `\"module\"`. This influences global\n // strict mode and parsing of `import` and `export` declarations.\n sourceType: \"script\",\n // `onInsertedSemicolon` can be a callback that will be called\n // when a semicolon is automatically inserted. It will be passed\n // the position of the comma as an offset, and if `locations` is\n // enabled, it is given the location as a `{line, column}` object\n // as second argument.\n onInsertedSemicolon: null,\n // `onTrailingComma` is similar to `onInsertedSemicolon`, but for\n // trailing commas.\n onTrailingComma: null,\n // By default, reserved words are only enforced if ecmaVersion >= 5.\n // Set `allowReserved` to a boolean value to explicitly turn this on\n // an off. When this option has the value \"never\", reserved words\n // and keywords can also not be used as property names.\n allowReserved: null,\n // When enabled, a return at the top level is not considered an\n // error.\n allowReturnOutsideFunction: false,\n // When enabled, import/export statements are not constrained to\n // appearing at the top of the program.\n allowImportExportEverywhere: false,\n // When enabled, await identifiers are allowed to appear at the top-level scope,\n // but they are still not allowed in non-async functions.\n allowAwaitOutsideFunction: false,\n // When enabled, hashbang directive in the beginning of file\n // is allowed and treated as a line comment.\n allowHashBang: false,\n // When `locations` is on, `loc` properties holding objects with\n // `start` and `end` properties in `{line, column}` form (with\n // line being 1-based and column 0-based) will be attached to the\n // nodes.\n locations: false,\n // A function can be passed as `onToken` option, which will\n // cause Acorn to call that function with object in the same\n // format as tokens returned from `tokenizer().getToken()`. Note\n // that you are not allowed to call the parser from the\n // callback—that will corrupt its internal state.\n onToken: null,\n // A function can be passed as `onComment` option, which will\n // cause Acorn to call that function with `(block, text, start,\n // end)` parameters whenever a comment is skipped. `block` is a\n // boolean indicating whether this is a block (`/* */`) comment,\n // `text` is the content of the comment, and `start` and `end` are\n // character offsets that denote the start and end of the comment.\n // When the `locations` option is on, two more parameters are\n // passed, the full `{line, column}` locations of the start and\n // end of the comments. Note that you are not allowed to call the\n // parser from the callback—that will corrupt its internal state.\n onComment: null,\n // Nodes have their start and end characters offsets recorded in\n // `start` and `end` properties (directly on the node, rather than\n // the `loc` object, which holds line/column data. To also add a\n // [semi-standardized][range] `range` property holding a `[start,\n // end]` array with the same numbers, set the `ranges` option to\n // `true`.\n //\n // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678\n ranges: false,\n // It is possible to parse multiple files into a single AST by\n // passing the tree produced by parsing the first file as\n // `program` option in subsequent parses. This will add the\n // toplevel forms of the parsed file to the `Program` (top) node\n // of an existing parse tree.\n program: null,\n // When `locations` is on, you can pass this to record the source\n // file in every node's `loc` object.\n sourceFile: null,\n // This value, if given, is stored in every node, whether\n // `locations` is on or off.\n directSourceFile: null,\n // When enabled, parenthesized expressions are represented by\n // (non-standard) ParenthesizedExpression nodes\n preserveParens: false\n}\n\n// Interpret and default an options object\n\nexport function getOptions(opts) {\n let options = {}\n\n for (let opt in defaultOptions)\n options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]\n\n if (options.ecmaVersion >= 2015)\n options.ecmaVersion -= 2009\n\n if (options.allowReserved == null)\n options.allowReserved = options.ecmaVersion < 5\n\n if (isArray(options.onToken)) {\n let tokens = options.onToken\n options.onToken = (token) => tokens.push(token)\n }\n if (isArray(options.onComment))\n options.onComment = pushComment(options, options.onComment)\n\n return options\n}\n\nfunction pushComment(options, array) {\n return function(block, text, start, end, startLoc, endLoc) {\n let comment = {\n type: block ? \"Block\" : \"Line\",\n value: text,\n start: start,\n end: end\n }\n if (options.locations)\n comment.loc = new SourceLocation(this, startLoc, endLoc)\n if (options.ranges)\n comment.range = [start, end]\n array.push(comment)\n }\n}\n","// Each scope gets a bitset that may contain these flags\nexport const\n SCOPE_TOP = 1,\n SCOPE_FUNCTION = 2,\n SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,\n SCOPE_ASYNC = 4,\n SCOPE_GENERATOR = 8,\n SCOPE_ARROW = 16,\n SCOPE_SIMPLE_CATCH = 32,\n SCOPE_SUPER = 64,\n SCOPE_DIRECT_SUPER = 128\n\nexport function functionFlags(async, generator) {\n return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)\n}\n\n// Used in checkLVal and declareName to determine the type of a binding\nexport const\n BIND_NONE = 0, // Not a binding\n BIND_VAR = 1, // Var-style binding\n BIND_LEXICAL = 2, // Let- or const-style binding\n BIND_FUNCTION = 3, // Function declaration\n BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding\n BIND_OUTSIDE = 5 // Special case for function names as bound inside the function\n","import {reservedWords, keywords} from \"./identifier\"\nimport {types as tt} from \"./tokentype\"\nimport {lineBreak} from \"./whitespace\"\nimport {getOptions} from \"./options\"\nimport {SCOPE_TOP, SCOPE_FUNCTION, SCOPE_ASYNC, SCOPE_GENERATOR, SCOPE_SUPER, SCOPE_DIRECT_SUPER} from \"./scopeflags\"\n\nfunction keywordRegexp(words) {\n return new RegExp(\"^(?:\" + words.replace(/ /g, \"|\") + \")$\")\n}\n\nexport class Parser {\n constructor(options, input, startPos) {\n this.options = options = getOptions(options)\n this.sourceFile = options.sourceFile\n this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])\n let reserved = \"\"\n if (!options.allowReserved) {\n for (let v = options.ecmaVersion;; v--)\n if (reserved = reservedWords[v]) break\n if (options.sourceType === \"module\") reserved += \" await\"\n }\n this.reservedWords = keywordRegexp(reserved)\n let reservedStrict = (reserved ? reserved + \" \" : \"\") + reservedWords.strict\n this.reservedWordsStrict = keywordRegexp(reservedStrict)\n this.reservedWordsStrictBind = keywordRegexp(reservedStrict + \" \" + reservedWords.strictBind)\n this.input = String(input)\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n this.containsEsc = false\n\n // Set up token state\n\n // The current position of the tokenizer in the input.\n if (startPos) {\n this.pos = startPos\n this.lineStart = this.input.lastIndexOf(\"\\n\", startPos - 1) + 1\n this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length\n } else {\n this.pos = this.lineStart = 0\n this.curLine = 1\n }\n\n // Properties of the current token:\n // Its type\n this.type = tt.eof\n // For tokens that include more information than their type, the value\n this.value = null\n // Its start and end offset\n this.start = this.end = this.pos\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n this.startLoc = this.endLoc = this.curPosition()\n\n // Position information for the previous token\n this.lastTokEndLoc = this.lastTokStartLoc = null\n this.lastTokStart = this.lastTokEnd = this.pos\n\n // The context stack is used to superficially track syntactic\n // context to predict whether a regular expression is allowed in a\n // given position.\n this.context = this.initialContext()\n this.exprAllowed = true\n\n // Figure out if it's a module code.\n this.inModule = options.sourceType === \"module\"\n this.strict = this.inModule || this.strictDirective(this.pos)\n\n // Used to signify the start of a potential arrow function\n this.potentialArrowAt = -1\n\n // Positions to delayed-check that yield/await does not exist in default parameters.\n this.yieldPos = this.awaitPos = 0\n // Labels in scope.\n this.labels = []\n\n // If enabled, skip leading hashbang line.\n if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === \"#!\")\n this.skipLineComment(2)\n\n // Scope tracking for duplicate variable names (see scope.js)\n this.scopeStack = []\n this.enterScope(SCOPE_TOP)\n\n // For RegExp validation\n this.regexpState = null\n }\n\n parse() {\n let node = this.options.program || this.startNode()\n this.nextToken()\n return this.parseTopLevel(node)\n }\n\n get inFunction() { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }\n get inGenerator() { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }\n get inAsync() { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }\n get allowSuper() { return (this.currentThisScope().flags & SCOPE_SUPER) > 0 }\n get allowDirectSuper() { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }\n get treatFunctionsAsVar() { return this.treatFunctionsAsVarInScope(this.currentScope()) }\n\n // Switch to a getter for 7.0.0.\n inNonArrowFunction() { return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0 }\n\n static extend(...plugins) {\n let cls = this\n for (let i = 0; i < plugins.length; i++) cls = plugins[i](cls)\n return cls\n }\n\n static parse(input, options) {\n return new this(options, input).parse()\n }\n\n static parseExpressionAt(input, pos, options) {\n let parser = new this(options, input, pos)\n parser.nextToken()\n return parser.parseExpression()\n }\n\n static tokenizer(input, options) {\n return new this(options, input)\n }\n}\n","import {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {lineBreak, skipWhiteSpace} from \"./whitespace\"\n\nconst pp = Parser.prototype\n\n// ## Parser utilities\n\nconst literal = /^(?:'((?:\\\\.|[^'])*?)'|\"((?:\\\\.|[^\"])*?)\")/\npp.strictDirective = function(start) {\n for (;;) {\n // Try to find string literal.\n skipWhiteSpace.lastIndex = start\n start += skipWhiteSpace.exec(this.input)[0].length\n let match = literal.exec(this.input.slice(start))\n if (!match) return false\n if ((match[1] || match[2]) === \"use strict\") return true\n start += match[0].length\n\n // Skip semicolon, if any.\n skipWhiteSpace.lastIndex = start\n start += skipWhiteSpace.exec(this.input)[0].length\n if (this.input[start] === ';')\n start++\n }\n}\n\n// Predicate that tests whether the next token is of the given\n// type, and if yes, consumes it as a side effect.\n\npp.eat = function(type) {\n if (this.type === type) {\n this.next()\n return true\n } else {\n return false\n }\n}\n\n// Tests whether parsed token is a contextual keyword.\n\npp.isContextual = function(name) {\n return this.type === tt.name && this.value === name && !this.containsEsc\n}\n\n// Consumes contextual keyword if possible.\n\npp.eatContextual = function(name) {\n if (!this.isContextual(name)) return false\n this.next()\n return true\n}\n\n// Asserts that following token is given contextual keyword.\n\npp.expectContextual = function(name) {\n if (!this.eatContextual(name)) this.unexpected()\n}\n\n// Test whether a semicolon can be inserted at the current position.\n\npp.canInsertSemicolon = function() {\n return this.type === tt.eof ||\n this.type === tt.braceR ||\n lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n}\n\npp.insertSemicolon = function() {\n if (this.canInsertSemicolon()) {\n if (this.options.onInsertedSemicolon)\n this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)\n return true\n }\n}\n\n// Consume a semicolon, or, failing that, see if we are allowed to\n// pretend that there is a semicolon at this position.\n\npp.semicolon = function() {\n if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()\n}\n\npp.afterTrailingComma = function(tokType, notNext) {\n if (this.type === tokType) {\n if (this.options.onTrailingComma)\n this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)\n if (!notNext)\n this.next()\n return true\n }\n}\n\n// Expect a token of a given type. If found, consume it, otherwise,\n// raise an unexpected token error.\n\npp.expect = function(type) {\n this.eat(type) || this.unexpected()\n}\n\n// Raise an unexpected token error.\n\npp.unexpected = function(pos) {\n this.raise(pos != null ? pos : this.start, \"Unexpected token\")\n}\n\nexport function DestructuringErrors() {\n this.shorthandAssign =\n this.trailingComma =\n this.parenthesizedAssign =\n this.parenthesizedBind =\n this.doubleProto =\n -1\n}\n\npp.checkPatternErrors = function(refDestructuringErrors, isAssign) {\n if (!refDestructuringErrors) return\n if (refDestructuringErrors.trailingComma > -1)\n this.raiseRecoverable(refDestructuringErrors.trailingComma, \"Comma is not permitted after the rest element\")\n let parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind\n if (parens > -1) this.raiseRecoverable(parens, \"Parenthesized pattern\")\n}\n\npp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {\n if (!refDestructuringErrors) return false\n let {shorthandAssign, doubleProto} = refDestructuringErrors\n if (!andThrow) return shorthandAssign >= 0 || doubleProto >= 0\n if (shorthandAssign >= 0)\n this.raise(shorthandAssign, \"Shorthand property assignments are valid only in destructuring patterns\")\n if (doubleProto >= 0)\n this.raiseRecoverable(doubleProto, \"Redefinition of __proto__ property\")\n}\n\npp.checkYieldAwaitInDefaultParams = function() {\n if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))\n this.raise(this.yieldPos, \"Yield expression cannot be a default value\")\n if (this.awaitPos)\n this.raise(this.awaitPos, \"Await expression cannot be a default value\")\n}\n\npp.isSimpleAssignTarget = function(expr) {\n if (expr.type === \"ParenthesizedExpression\")\n return this.isSimpleAssignTarget(expr.expression)\n return expr.type === \"Identifier\" || expr.type === \"MemberExpression\"\n}\n","import {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {lineBreak, skipWhiteSpace} from \"./whitespace\"\nimport {isIdentifierStart, isIdentifierChar, keywordRelationalOperator} from \"./identifier\"\nimport {has} from \"./util\"\nimport {DestructuringErrors} from \"./parseutil\"\nimport {functionFlags, SCOPE_SIMPLE_CATCH, BIND_SIMPLE_CATCH, BIND_LEXICAL, BIND_VAR, BIND_FUNCTION} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\n// ### Statement parsing\n\n// Parse a program. Initializes the parser, reads any number of\n// statements, and wraps them in a Program node. Optionally takes a\n// `program` argument. If present, the statements will be appended\n// to its body instead of creating a new node.\n\npp.parseTopLevel = function(node) {\n let exports = {}\n if (!node.body) node.body = []\n while (this.type !== tt.eof) {\n let stmt = this.parseStatement(null, true, exports)\n node.body.push(stmt)\n }\n this.adaptDirectivePrologue(node.body)\n this.next()\n if (this.options.ecmaVersion >= 6) {\n node.sourceType = this.options.sourceType\n }\n return this.finishNode(node, \"Program\")\n}\n\nconst loopLabel = {kind: \"loop\"}, switchLabel = {kind: \"switch\"}\n\npp.isLet = function(context) {\n if (this.options.ecmaVersion < 6 || !this.isContextual(\"let\")) return false\n skipWhiteSpace.lastIndex = this.pos\n let skip = skipWhiteSpace.exec(this.input)\n let next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)\n // For ambiguous cases, determine if a LexicalDeclaration (or only a\n // Statement) is allowed here. If context is not empty then only a Statement\n // is allowed. However, `let [` is an explicit negative lookahead for\n // ExpressionStatement, so special-case it first.\n if (nextCh === 91) return true // '['\n if (context) return false\n\n if (nextCh === 123) return true // '{'\n if (isIdentifierStart(nextCh, true)) {\n let pos = next + 1\n while (isIdentifierChar(this.input.charCodeAt(pos), true)) ++pos\n let ident = this.input.slice(next, pos)\n if (!keywordRelationalOperator.test(ident)) return true\n }\n return false\n}\n\n// check 'async [no LineTerminator here] function'\n// - 'async /*foo*/ function' is OK.\n// - 'async /*\\n*/ function' is invalid.\npp.isAsyncFunction = function() {\n if (this.options.ecmaVersion < 8 || !this.isContextual(\"async\"))\n return false\n\n skipWhiteSpace.lastIndex = this.pos\n let skip = skipWhiteSpace.exec(this.input)\n let next = this.pos + skip[0].length\n return !lineBreak.test(this.input.slice(this.pos, next)) &&\n this.input.slice(next, next + 8) === \"function\" &&\n (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))\n}\n\n// Parse a single statement.\n//\n// If expecting a statement and finding a slash operator, parse a\n// regular expression literal. This is to handle cases like\n// `if (foo) /blah/.exec(foo)`, where looking at the previous token\n// does not help.\n\npp.parseStatement = function(context, topLevel, exports) {\n let starttype = this.type, node = this.startNode(), kind\n\n if (this.isLet(context)) {\n starttype = tt._var\n kind = \"let\"\n }\n\n // Most types of statements are recognized by the keyword they\n // start with. Many are trivial to parse, some require a bit of\n // complexity.\n\n switch (starttype) {\n case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword)\n case tt._debugger: return this.parseDebuggerStatement(node)\n case tt._do: return this.parseDoStatement(node)\n case tt._for: return this.parseForStatement(node)\n case tt._function:\n // Function as sole body of either an if statement or a labeled statement\n // works, but not when it is part of a labeled statement that is the sole\n // body of an if statement.\n if ((context && (this.strict || context !== \"if\" && context !== \"label\")) && this.options.ecmaVersion >= 6) this.unexpected()\n return this.parseFunctionStatement(node, false, !context)\n case tt._class:\n if (context) this.unexpected()\n return this.parseClass(node, true)\n case tt._if: return this.parseIfStatement(node)\n case tt._return: return this.parseReturnStatement(node)\n case tt._switch: return this.parseSwitchStatement(node)\n case tt._throw: return this.parseThrowStatement(node)\n case tt._try: return this.parseTryStatement(node)\n case tt._const: case tt._var:\n kind = kind || this.value\n if (context && kind !== \"var\") this.unexpected()\n return this.parseVarStatement(node, kind)\n case tt._while: return this.parseWhileStatement(node)\n case tt._with: return this.parseWithStatement(node)\n case tt.braceL: return this.parseBlock(true, node)\n case tt.semi: return this.parseEmptyStatement(node)\n case tt._export:\n case tt._import:\n if (!this.options.allowImportExportEverywhere) {\n if (!topLevel)\n this.raise(this.start, \"'import' and 'export' may only appear at the top level\")\n if (!this.inModule)\n this.raise(this.start, \"'import' and 'export' may appear only with 'sourceType: module'\")\n }\n return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports)\n\n // If the statement does not start with a statement keyword or a\n // brace, it's an ExpressionStatement or LabeledStatement. We\n // simply start parsing an expression, and afterwards, if the\n // next token is a colon and the expression was a simple\n // Identifier node, we switch to interpreting it as a label.\n default:\n if (this.isAsyncFunction()) {\n if (context) this.unexpected()\n this.next()\n return this.parseFunctionStatement(node, true, !context)\n }\n\n let maybeName = this.value, expr = this.parseExpression()\n if (starttype === tt.name && expr.type === \"Identifier\" && this.eat(tt.colon))\n return this.parseLabeledStatement(node, maybeName, expr, context)\n else return this.parseExpressionStatement(node, expr)\n }\n}\n\npp.parseBreakContinueStatement = function(node, keyword) {\n let isBreak = keyword === \"break\"\n this.next()\n if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null\n else if (this.type !== tt.name) this.unexpected()\n else {\n node.label = this.parseIdent()\n this.semicolon()\n }\n\n // Verify that there is an actual destination to break or\n // continue to.\n let i = 0\n for (; i < this.labels.length; ++i) {\n let lab = this.labels[i]\n if (node.label == null || lab.name === node.label.name) {\n if (lab.kind != null && (isBreak || lab.kind === \"loop\")) break\n if (node.label && isBreak) break\n }\n }\n if (i === this.labels.length) this.raise(node.start, \"Unsyntactic \" + keyword)\n return this.finishNode(node, isBreak ? \"BreakStatement\" : \"ContinueStatement\")\n}\n\npp.parseDebuggerStatement = function(node) {\n this.next()\n this.semicolon()\n return this.finishNode(node, \"DebuggerStatement\")\n}\n\npp.parseDoStatement = function(node) {\n this.next()\n this.labels.push(loopLabel)\n node.body = this.parseStatement(\"do\")\n this.labels.pop()\n this.expect(tt._while)\n node.test = this.parseParenExpression()\n if (this.options.ecmaVersion >= 6)\n this.eat(tt.semi)\n else\n this.semicolon()\n return this.finishNode(node, \"DoWhileStatement\")\n}\n\n// Disambiguating between a `for` and a `for`/`in` or `for`/`of`\n// loop is non-trivial. Basically, we have to parse the init `var`\n// statement or expression, disallowing the `in` operator (see\n// the second parameter to `parseExpression`), and then check\n// whether the next token is `in` or `of`. When there is no init\n// part (semicolon immediately after the opening parenthesis), it\n// is a regular `for` loop.\n\npp.parseForStatement = function(node) {\n this.next()\n let awaitAt = (this.options.ecmaVersion >= 9 && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual(\"await\")) ? this.lastTokStart : -1\n this.labels.push(loopLabel)\n this.enterScope(0)\n this.expect(tt.parenL)\n if (this.type === tt.semi) {\n if (awaitAt > -1) this.unexpected(awaitAt)\n return this.parseFor(node, null)\n }\n let isLet = this.isLet()\n if (this.type === tt._var || this.type === tt._const || isLet) {\n let init = this.startNode(), kind = isLet ? \"let\" : this.value\n this.next()\n this.parseVar(init, true, kind)\n this.finishNode(init, \"VariableDeclaration\")\n if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) && init.declarations.length === 1 &&\n !(kind !== \"var\" && init.declarations[0].init)) {\n if (this.options.ecmaVersion >= 9) {\n if (this.type === tt._in) {\n if (awaitAt > -1) this.unexpected(awaitAt)\n } else node.await = awaitAt > -1\n }\n return this.parseForIn(node, init)\n }\n if (awaitAt > -1) this.unexpected(awaitAt)\n return this.parseFor(node, init)\n }\n let refDestructuringErrors = new DestructuringErrors\n let init = this.parseExpression(true, refDestructuringErrors)\n if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) {\n if (this.options.ecmaVersion >= 9) {\n if (this.type === tt._in) {\n if (awaitAt > -1) this.unexpected(awaitAt)\n } else node.await = awaitAt > -1\n }\n this.toAssignable(init, false, refDestructuringErrors)\n this.checkLVal(init)\n return this.parseForIn(node, init)\n } else {\n this.checkExpressionErrors(refDestructuringErrors, true)\n }\n if (awaitAt > -1) this.unexpected(awaitAt)\n return this.parseFor(node, init)\n}\n\npp.parseFunctionStatement = function(node, isAsync, declarationPosition) {\n this.next()\n return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)\n}\n\npp.parseIfStatement = function(node) {\n this.next()\n node.test = this.parseParenExpression()\n // allow function declarations in branches, but only in non-strict mode\n node.consequent = this.parseStatement(\"if\")\n node.alternate = this.eat(tt._else) ? this.parseStatement(\"if\") : null\n return this.finishNode(node, \"IfStatement\")\n}\n\npp.parseReturnStatement = function(node) {\n if (!this.inFunction && !this.options.allowReturnOutsideFunction)\n this.raise(this.start, \"'return' outside of function\")\n this.next()\n\n // In `return` (and `break`/`continue`), the keywords with\n // optional arguments, we eagerly look for a semicolon or the\n // possibility to insert one.\n\n if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null\n else { node.argument = this.parseExpression(); this.semicolon() }\n return this.finishNode(node, \"ReturnStatement\")\n}\n\npp.parseSwitchStatement = function(node) {\n this.next()\n node.discriminant = this.parseParenExpression()\n node.cases = []\n this.expect(tt.braceL)\n this.labels.push(switchLabel)\n this.enterScope(0)\n\n // Statements under must be grouped (by label) in SwitchCase\n // nodes. `cur` is used to keep the node that we are currently\n // adding statements to.\n\n let cur\n for (let sawDefault = false; this.type !== tt.braceR;) {\n if (this.type === tt._case || this.type === tt._default) {\n let isCase = this.type === tt._case\n if (cur) this.finishNode(cur, \"SwitchCase\")\n node.cases.push(cur = this.startNode())\n cur.consequent = []\n this.next()\n if (isCase) {\n cur.test = this.parseExpression()\n } else {\n if (sawDefault) this.raiseRecoverable(this.lastTokStart, \"Multiple default clauses\")\n sawDefault = true\n cur.test = null\n }\n this.expect(tt.colon)\n } else {\n if (!cur) this.unexpected()\n cur.consequent.push(this.parseStatement(null))\n }\n }\n this.exitScope()\n if (cur) this.finishNode(cur, \"SwitchCase\")\n this.next() // Closing brace\n this.labels.pop()\n return this.finishNode(node, \"SwitchStatement\")\n}\n\npp.parseThrowStatement = function(node) {\n this.next()\n if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))\n this.raise(this.lastTokEnd, \"Illegal newline after throw\")\n node.argument = this.parseExpression()\n this.semicolon()\n return this.finishNode(node, \"ThrowStatement\")\n}\n\n// Reused empty array added for node fields that are always empty.\n\nconst empty = []\n\npp.parseTryStatement = function(node) {\n this.next()\n node.block = this.parseBlock()\n node.handler = null\n if (this.type === tt._catch) {\n let clause = this.startNode()\n this.next()\n if (this.eat(tt.parenL)) {\n clause.param = this.parseBindingAtom()\n let simple = clause.param.type === \"Identifier\"\n this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0)\n this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL)\n this.expect(tt.parenR)\n } else {\n if (this.options.ecmaVersion < 10) this.unexpected()\n clause.param = null\n this.enterScope(0)\n }\n clause.body = this.parseBlock(false)\n this.exitScope()\n node.handler = this.finishNode(clause, \"CatchClause\")\n }\n node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null\n if (!node.handler && !node.finalizer)\n this.raise(node.start, \"Missing catch or finally clause\")\n return this.finishNode(node, \"TryStatement\")\n}\n\npp.parseVarStatement = function(node, kind) {\n this.next()\n this.parseVar(node, false, kind)\n this.semicolon()\n return this.finishNode(node, \"VariableDeclaration\")\n}\n\npp.parseWhileStatement = function(node) {\n this.next()\n node.test = this.parseParenExpression()\n this.labels.push(loopLabel)\n node.body = this.parseStatement(\"while\")\n this.labels.pop()\n return this.finishNode(node, \"WhileStatement\")\n}\n\npp.parseWithStatement = function(node) {\n if (this.strict) this.raise(this.start, \"'with' in strict mode\")\n this.next()\n node.object = this.parseParenExpression()\n node.body = this.parseStatement(\"with\")\n return this.finishNode(node, \"WithStatement\")\n}\n\npp.parseEmptyStatement = function(node) {\n this.next()\n return this.finishNode(node, \"EmptyStatement\")\n}\n\npp.parseLabeledStatement = function(node, maybeName, expr, context) {\n for (let label of this.labels)\n if (label.name === maybeName)\n this.raise(expr.start, \"Label '\" + maybeName + \"' is already declared\")\n let kind = this.type.isLoop ? \"loop\" : this.type === tt._switch ? \"switch\" : null\n for (let i = this.labels.length - 1; i >= 0; i--) {\n let label = this.labels[i]\n if (label.statementStart === node.start) {\n // Update information about previous labels on this node\n label.statementStart = this.start\n label.kind = kind\n } else break\n }\n this.labels.push({name: maybeName, kind, statementStart: this.start})\n node.body = this.parseStatement(context ? context.indexOf(\"label\") === -1 ? context + \"label\" : context : \"label\")\n this.labels.pop()\n node.label = expr\n return this.finishNode(node, \"LabeledStatement\")\n}\n\npp.parseExpressionStatement = function(node, expr) {\n node.expression = expr\n this.semicolon()\n return this.finishNode(node, \"ExpressionStatement\")\n}\n\n// Parse a semicolon-enclosed block of statements, handling `\"use\n// strict\"` declarations when `allowStrict` is true (used for\n// function bodies).\n\npp.parseBlock = function(createNewLexicalScope = true, node = this.startNode()) {\n node.body = []\n this.expect(tt.braceL)\n if (createNewLexicalScope) this.enterScope(0)\n while (!this.eat(tt.braceR)) {\n let stmt = this.parseStatement(null)\n node.body.push(stmt)\n }\n if (createNewLexicalScope) this.exitScope()\n return this.finishNode(node, \"BlockStatement\")\n}\n\n// Parse a regular `for` loop. The disambiguation code in\n// `parseStatement` will already have parsed the init statement or\n// expression.\n\npp.parseFor = function(node, init) {\n node.init = init\n this.expect(tt.semi)\n node.test = this.type === tt.semi ? null : this.parseExpression()\n this.expect(tt.semi)\n node.update = this.type === tt.parenR ? null : this.parseExpression()\n this.expect(tt.parenR)\n node.body = this.parseStatement(\"for\")\n this.exitScope()\n this.labels.pop()\n return this.finishNode(node, \"ForStatement\")\n}\n\n// Parse a `for`/`in` and `for`/`of` loop, which are almost\n// same from parser's perspective.\n\npp.parseForIn = function(node, init) {\n let type = this.type === tt._in ? \"ForInStatement\" : \"ForOfStatement\"\n this.next()\n if (type === \"ForInStatement\") {\n if (init.type === \"AssignmentPattern\" ||\n (init.type === \"VariableDeclaration\" && init.declarations[0].init != null &&\n (this.strict || init.declarations[0].id.type !== \"Identifier\")))\n this.raise(init.start, \"Invalid assignment in for-in loop head\")\n }\n node.left = init\n node.right = type === \"ForInStatement\" ? this.parseExpression() : this.parseMaybeAssign()\n this.expect(tt.parenR)\n node.body = this.parseStatement(\"for\")\n this.exitScope()\n this.labels.pop()\n return this.finishNode(node, type)\n}\n\n// Parse a list of variable declarations.\n\npp.parseVar = function(node, isFor, kind) {\n node.declarations = []\n node.kind = kind\n for (;;) {\n let decl = this.startNode()\n this.parseVarId(decl, kind)\n if (this.eat(tt.eq)) {\n decl.init = this.parseMaybeAssign(isFor)\n } else if (kind === \"const\" && !(this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\")))) {\n this.unexpected()\n } else if (decl.id.type !== \"Identifier\" && !(isFor && (this.type === tt._in || this.isContextual(\"of\")))) {\n this.raise(this.lastTokEnd, \"Complex binding patterns require an initialization value\")\n } else {\n decl.init = null\n }\n node.declarations.push(this.finishNode(decl, \"VariableDeclarator\"))\n if (!this.eat(tt.comma)) break\n }\n return node\n}\n\npp.parseVarId = function(decl, kind) {\n if ((kind === \"const\" || kind === \"let\") && this.isContextual(\"let\")) {\n this.raiseRecoverable(this.start, \"let is disallowed as a lexically bound name\");\n }\n decl.id = this.parseBindingAtom()\n this.checkLVal(decl.id, kind === \"var\" ? BIND_VAR : BIND_LEXICAL, false)\n}\n\nconst FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4\n\n// Parse a function declaration or literal (depending on the\n// `isStatement` parameter).\n\npp.parseFunction = function(node, statement, allowExpressionBody, isAsync) {\n this.initFunction(node)\n if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {\n if (this.type === tt.star && (statement & FUNC_HANGING_STATEMENT))\n this.unexpected()\n node.generator = this.eat(tt.star)\n }\n if (this.options.ecmaVersion >= 8)\n node.async = !!isAsync\n\n if (statement & FUNC_STATEMENT) {\n node.id = (statement & FUNC_NULLABLE_ID) && this.type !== tt.name ? null : this.parseIdent()\n if (node.id && !(statement & FUNC_HANGING_STATEMENT))\n // If it is a regular function declaration in sloppy mode, then it is\n // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding\n // mode depends on properties of the current scope (see\n // treatFunctionsAsVar).\n this.checkLVal(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION);\n }\n\n let oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n this.yieldPos = 0\n this.awaitPos = 0\n this.enterScope(functionFlags(node.async, node.generator))\n\n if (!(statement & FUNC_STATEMENT))\n node.id = this.type === tt.name ? this.parseIdent() : null\n\n this.parseFunctionParams(node)\n this.parseFunctionBody(node, allowExpressionBody)\n\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.finishNode(node, (statement & FUNC_STATEMENT) ? \"FunctionDeclaration\" : \"FunctionExpression\")\n}\n\npp.parseFunctionParams = function(node) {\n this.expect(tt.parenL)\n node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8)\n this.checkYieldAwaitInDefaultParams()\n}\n\n// Parse a class declaration or literal (depending on the\n// `isStatement` parameter).\n\npp.parseClass = function(node, isStatement) {\n this.next()\n\n // ecma-262 14.6 Class Definitions\n // A class definition is always strict mode code.\n const oldStrict = this.strict;\n this.strict = true;\n\n this.parseClassId(node, isStatement)\n this.parseClassSuper(node)\n let classBody = this.startNode()\n let hadConstructor = false\n classBody.body = []\n this.expect(tt.braceL)\n while (!this.eat(tt.braceR)) {\n const element = this.parseClassElement(node.superClass !== null)\n if (element) {\n classBody.body.push(element)\n if (element.type === \"MethodDefinition\" && element.kind === \"constructor\") {\n if (hadConstructor) this.raise(element.start, \"Duplicate constructor in the same class\")\n hadConstructor = true\n }\n }\n }\n node.body = this.finishNode(classBody, \"ClassBody\")\n this.strict = oldStrict;\n return this.finishNode(node, isStatement ? \"ClassDeclaration\" : \"ClassExpression\")\n}\n\npp.parseClassElement = function(constructorAllowsSuper) {\n if (this.eat(tt.semi)) return null\n\n let method = this.startNode()\n const tryContextual = (k, noLineBreak = false) => {\n const start = this.start, startLoc = this.startLoc\n if (!this.eatContextual(k)) return false\n if (this.type !== tt.parenL && (!noLineBreak || !this.canInsertSemicolon())) return true\n if (method.key) this.unexpected()\n method.computed = false\n method.key = this.startNodeAt(start, startLoc)\n method.key.name = k\n this.finishNode(method.key, \"Identifier\")\n return false\n }\n\n method.kind = \"method\"\n method.static = tryContextual(\"static\")\n let isGenerator = this.eat(tt.star)\n let isAsync = false\n if (!isGenerator) {\n if (this.options.ecmaVersion >= 8 && tryContextual(\"async\", true)) {\n isAsync = true\n isGenerator = this.options.ecmaVersion >= 9 && this.eat(tt.star)\n } else if (tryContextual(\"get\")) {\n method.kind = \"get\"\n } else if (tryContextual(\"set\")) {\n method.kind = \"set\"\n }\n }\n if (!method.key) this.parsePropertyName(method)\n let {key} = method\n let allowsDirectSuper = false\n if (!method.computed && !method.static && (key.type === \"Identifier\" && key.name === \"constructor\" ||\n key.type === \"Literal\" && key.value === \"constructor\")) {\n if (method.kind !== \"method\") this.raise(key.start, \"Constructor can't have get/set modifier\")\n if (isGenerator) this.raise(key.start, \"Constructor can't be a generator\")\n if (isAsync) this.raise(key.start, \"Constructor can't be an async method\")\n method.kind = \"constructor\"\n allowsDirectSuper = constructorAllowsSuper\n } else if (method.static && key.type === \"Identifier\" && key.name === \"prototype\") {\n this.raise(key.start, \"Classes may not have a static property named prototype\")\n }\n this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper)\n if (method.kind === \"get\" && method.value.params.length !== 0)\n this.raiseRecoverable(method.value.start, \"getter should have no params\")\n if (method.kind === \"set\" && method.value.params.length !== 1)\n this.raiseRecoverable(method.value.start, \"setter should have exactly one param\")\n if (method.kind === \"set\" && method.value.params[0].type === \"RestElement\")\n this.raiseRecoverable(method.value.params[0].start, \"Setter cannot use rest params\")\n return method\n}\n\npp.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {\n method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper)\n return this.finishNode(method, \"MethodDefinition\")\n}\n\npp.parseClassId = function(node, isStatement) {\n if (this.type === tt.name) {\n node.id = this.parseIdent();\n if (isStatement === true)\n this.checkLVal(node.id, BIND_LEXICAL, false)\n } else {\n if (isStatement === true)\n this.unexpected();\n node.id = null;\n }\n}\n\npp.parseClassSuper = function(node) {\n node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null\n}\n\n// Parses module export declaration.\n\npp.parseExport = function(node, exports) {\n this.next()\n // export * from '...'\n if (this.eat(tt.star)) {\n this.expectContextual(\"from\")\n if (this.type !== tt.string) this.unexpected()\n node.source = this.parseExprAtom()\n this.semicolon()\n return this.finishNode(node, \"ExportAllDeclaration\")\n }\n if (this.eat(tt._default)) { // export default ...\n this.checkExport(exports, \"default\", this.lastTokStart)\n let isAsync\n if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {\n let fNode = this.startNode()\n this.next()\n if (isAsync) this.next()\n node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync, true)\n } else if (this.type === tt._class) {\n let cNode = this.startNode()\n node.declaration = this.parseClass(cNode, \"nullableID\")\n } else {\n node.declaration = this.parseMaybeAssign()\n this.semicolon()\n }\n return this.finishNode(node, \"ExportDefaultDeclaration\")\n }\n // export var|const|let|function|class ...\n if (this.shouldParseExportStatement()) {\n node.declaration = this.parseStatement(null)\n if (node.declaration.type === \"VariableDeclaration\")\n this.checkVariableExport(exports, node.declaration.declarations)\n else\n this.checkExport(exports, node.declaration.id.name, node.declaration.id.start)\n node.specifiers = []\n node.source = null\n } else { // export { x, y as z } [from '...']\n node.declaration = null\n node.specifiers = this.parseExportSpecifiers(exports)\n if (this.eatContextual(\"from\")) {\n if (this.type !== tt.string) this.unexpected()\n node.source = this.parseExprAtom()\n } else {\n // check for keywords used as local names\n for (let spec of node.specifiers) {\n this.checkUnreserved(spec.local)\n }\n\n node.source = null\n }\n this.semicolon()\n }\n return this.finishNode(node, \"ExportNamedDeclaration\")\n}\n\npp.checkExport = function(exports, name, pos) {\n if (!exports) return\n if (has(exports, name))\n this.raiseRecoverable(pos, \"Duplicate export '\" + name + \"'\")\n exports[name] = true\n}\n\npp.checkPatternExport = function(exports, pat) {\n let type = pat.type\n if (type === \"Identifier\")\n this.checkExport(exports, pat.name, pat.start)\n else if (type === \"ObjectPattern\")\n for (let prop of pat.properties)\n this.checkPatternExport(exports, prop)\n else if (type === \"ArrayPattern\")\n for (let elt of pat.elements) {\n if (elt) this.checkPatternExport(exports, elt)\n }\n else if (type === \"Property\")\n this.checkPatternExport(exports, pat.value)\n else if (type === \"AssignmentPattern\")\n this.checkPatternExport(exports, pat.left)\n else if (type === \"RestElement\")\n this.checkPatternExport(exports, pat.argument)\n else if (type === \"ParenthesizedExpression\")\n this.checkPatternExport(exports, pat.expression)\n}\n\npp.checkVariableExport = function(exports, decls) {\n if (!exports) return\n for (let decl of decls)\n this.checkPatternExport(exports, decl.id)\n}\n\npp.shouldParseExportStatement = function() {\n return this.type.keyword === \"var\" ||\n this.type.keyword === \"const\" ||\n this.type.keyword === \"class\" ||\n this.type.keyword === \"function\" ||\n this.isLet() ||\n this.isAsyncFunction()\n}\n\n// Parses a comma-separated list of module exports.\n\npp.parseExportSpecifiers = function(exports) {\n let nodes = [], first = true\n // export { x, y as z } [from '...']\n this.expect(tt.braceL)\n while (!this.eat(tt.braceR)) {\n if (!first) {\n this.expect(tt.comma)\n if (this.afterTrailingComma(tt.braceR)) break\n } else first = false\n\n let node = this.startNode()\n node.local = this.parseIdent(true)\n node.exported = this.eatContextual(\"as\") ? this.parseIdent(true) : node.local\n this.checkExport(exports, node.exported.name, node.exported.start)\n nodes.push(this.finishNode(node, \"ExportSpecifier\"))\n }\n return nodes\n}\n\n// Parses import declaration.\n\npp.parseImport = function(node) {\n this.next()\n // import '...'\n if (this.type === tt.string) {\n node.specifiers = empty\n node.source = this.parseExprAtom()\n } else {\n node.specifiers = this.parseImportSpecifiers()\n this.expectContextual(\"from\")\n node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()\n }\n this.semicolon()\n return this.finishNode(node, \"ImportDeclaration\")\n}\n\n// Parses a comma-separated list of module imports.\n\npp.parseImportSpecifiers = function() {\n let nodes = [], first = true\n if (this.type === tt.name) {\n // import defaultObj, { x, y as z } from '...'\n let node = this.startNode()\n node.local = this.parseIdent()\n this.checkLVal(node.local, BIND_LEXICAL)\n nodes.push(this.finishNode(node, \"ImportDefaultSpecifier\"))\n if (!this.eat(tt.comma)) return nodes\n }\n if (this.type === tt.star) {\n let node = this.startNode()\n this.next()\n this.expectContextual(\"as\")\n node.local = this.parseIdent()\n this.checkLVal(node.local, BIND_LEXICAL)\n nodes.push(this.finishNode(node, \"ImportNamespaceSpecifier\"))\n return nodes\n }\n this.expect(tt.braceL)\n while (!this.eat(tt.braceR)) {\n if (!first) {\n this.expect(tt.comma)\n if (this.afterTrailingComma(tt.braceR)) break\n } else first = false\n\n let node = this.startNode()\n node.imported = this.parseIdent(true)\n if (this.eatContextual(\"as\")) {\n node.local = this.parseIdent()\n } else {\n this.checkUnreserved(node.imported)\n node.local = node.imported\n }\n this.checkLVal(node.local, BIND_LEXICAL)\n nodes.push(this.finishNode(node, \"ImportSpecifier\"))\n }\n return nodes\n}\n\n// Set `ExpressionStatement#directive` property for directive prologues.\npp.adaptDirectivePrologue = function(statements) {\n for (let i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {\n statements[i].directive = statements[i].expression.raw.slice(1, -1)\n }\n}\npp.isDirectiveCandidate = function(statement) {\n return (\n statement.type === \"ExpressionStatement\" &&\n statement.expression.type === \"Literal\" &&\n typeof statement.expression.value === \"string\" &&\n // Reject parenthesized strings.\n (this.input[statement.start] === \"\\\"\" || this.input[statement.start] === \"'\")\n )\n}\n","import {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {has} from \"./util\"\nimport {BIND_NONE, BIND_OUTSIDE} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\n// Convert existing expression atom to assignable pattern\n// if possible.\n\npp.toAssignable = function(node, isBinding, refDestructuringErrors) {\n if (this.options.ecmaVersion >= 6 && node) {\n switch (node.type) {\n case \"Identifier\":\n if (this.inAsync && node.name === \"await\")\n this.raise(node.start, \"Can not use 'await' as identifier inside an async function\")\n break\n\n case \"ObjectPattern\":\n case \"ArrayPattern\":\n case \"RestElement\":\n break\n\n case \"ObjectExpression\":\n node.type = \"ObjectPattern\"\n if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true)\n for (let prop of node.properties) {\n this.toAssignable(prop, isBinding)\n // Early error:\n // AssignmentRestProperty[Yield, Await] :\n // `...` DestructuringAssignmentTarget[Yield, Await]\n //\n // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.\n if (\n prop.type === \"RestElement\" &&\n (prop.argument.type === \"ArrayPattern\" || prop.argument.type === \"ObjectPattern\")\n ) {\n this.raise(prop.argument.start, \"Unexpected token\")\n }\n }\n break\n\n case \"Property\":\n // AssignmentProperty has type === \"Property\"\n if (node.kind !== \"init\") this.raise(node.key.start, \"Object pattern can't contain getter or setter\")\n this.toAssignable(node.value, isBinding)\n break\n\n case \"ArrayExpression\":\n node.type = \"ArrayPattern\"\n if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true)\n this.toAssignableList(node.elements, isBinding)\n break\n\n case \"SpreadElement\":\n node.type = \"RestElement\"\n this.toAssignable(node.argument, isBinding)\n if (node.argument.type === \"AssignmentPattern\")\n this.raise(node.argument.start, \"Rest elements cannot have a default value\")\n break\n\n case \"AssignmentExpression\":\n if (node.operator !== \"=\") this.raise(node.left.end, \"Only '=' operator can be used for specifying default value.\")\n node.type = \"AssignmentPattern\"\n delete node.operator\n this.toAssignable(node.left, isBinding)\n // falls through to AssignmentPattern\n\n case \"AssignmentPattern\":\n break\n\n case \"ParenthesizedExpression\":\n this.toAssignable(node.expression, isBinding, refDestructuringErrors)\n break\n\n case \"MemberExpression\":\n if (!isBinding) break\n\n default:\n this.raise(node.start, \"Assigning to rvalue\")\n }\n } else if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true)\n return node\n}\n\n// Convert list of expression atoms to binding list.\n\npp.toAssignableList = function(exprList, isBinding) {\n let end = exprList.length\n for (let i = 0; i < end; i++) {\n let elt = exprList[i]\n if (elt) this.toAssignable(elt, isBinding)\n }\n if (end) {\n let last = exprList[end - 1]\n if (this.options.ecmaVersion === 6 && isBinding && last && last.type === \"RestElement\" && last.argument.type !== \"Identifier\")\n this.unexpected(last.argument.start)\n }\n return exprList\n}\n\n// Parses spread element.\n\npp.parseSpread = function(refDestructuringErrors) {\n let node = this.startNode()\n this.next()\n node.argument = this.parseMaybeAssign(false, refDestructuringErrors)\n return this.finishNode(node, \"SpreadElement\")\n}\n\npp.parseRestBinding = function() {\n let node = this.startNode()\n this.next()\n\n // RestElement inside of a function parameter must be an identifier\n if (this.options.ecmaVersion === 6 && this.type !== tt.name)\n this.unexpected()\n\n node.argument = this.parseBindingAtom()\n\n return this.finishNode(node, \"RestElement\")\n}\n\n// Parses lvalue (assignable) atom.\n\npp.parseBindingAtom = function() {\n if (this.options.ecmaVersion >= 6) {\n switch (this.type) {\n case tt.bracketL:\n let node = this.startNode()\n this.next()\n node.elements = this.parseBindingList(tt.bracketR, true, true)\n return this.finishNode(node, \"ArrayPattern\")\n\n case tt.braceL:\n return this.parseObj(true)\n }\n }\n return this.parseIdent()\n}\n\npp.parseBindingList = function(close, allowEmpty, allowTrailingComma) {\n let elts = [], first = true\n while (!this.eat(close)) {\n if (first) first = false\n else this.expect(tt.comma)\n if (allowEmpty && this.type === tt.comma) {\n elts.push(null)\n } else if (allowTrailingComma && this.afterTrailingComma(close)) {\n break\n } else if (this.type === tt.ellipsis) {\n let rest = this.parseRestBinding()\n this.parseBindingListItem(rest)\n elts.push(rest)\n if (this.type === tt.comma) this.raise(this.start, \"Comma is not permitted after the rest element\")\n this.expect(close)\n break\n } else {\n let elem = this.parseMaybeDefault(this.start, this.startLoc)\n this.parseBindingListItem(elem)\n elts.push(elem)\n }\n }\n return elts\n}\n\npp.parseBindingListItem = function(param) {\n return param\n}\n\n// Parses assignment pattern around given atom if possible.\n\npp.parseMaybeDefault = function(startPos, startLoc, left) {\n left = left || this.parseBindingAtom()\n if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left\n let node = this.startNodeAt(startPos, startLoc)\n node.left = left\n node.right = this.parseMaybeAssign()\n return this.finishNode(node, \"AssignmentPattern\")\n}\n\n// Verify that a node is an lval — something that can be assigned\n// to.\n// bindingType can be either:\n// 'var' indicating that the lval creates a 'var' binding\n// 'let' indicating that the lval creates a lexical ('let' or 'const') binding\n// 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references\n\npp.checkLVal = function(expr, bindingType = BIND_NONE, checkClashes) {\n switch (expr.type) {\n case \"Identifier\":\n if (this.strict && this.reservedWordsStrictBind.test(expr.name))\n this.raiseRecoverable(expr.start, (bindingType ? \"Binding \" : \"Assigning to \") + expr.name + \" in strict mode\")\n if (checkClashes) {\n if (has(checkClashes, expr.name))\n this.raiseRecoverable(expr.start, \"Argument name clash\")\n checkClashes[expr.name] = true\n }\n if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) this.declareName(expr.name, bindingType, expr.start)\n break\n\n case \"MemberExpression\":\n if (bindingType) this.raiseRecoverable(expr.start, \"Binding member expression\")\n break\n\n case \"ObjectPattern\":\n for (let prop of expr.properties)\n this.checkLVal(prop, bindingType, checkClashes)\n break\n\n case \"Property\":\n // AssignmentProperty has type === \"Property\"\n this.checkLVal(expr.value, bindingType, checkClashes)\n break\n\n case \"ArrayPattern\":\n for (let elem of expr.elements) {\n if (elem) this.checkLVal(elem, bindingType, checkClashes)\n }\n break\n\n case \"AssignmentPattern\":\n this.checkLVal(expr.left, bindingType, checkClashes)\n break\n\n case \"RestElement\":\n this.checkLVal(expr.argument, bindingType, checkClashes)\n break\n\n case \"ParenthesizedExpression\":\n this.checkLVal(expr.expression, bindingType, checkClashes)\n break\n\n default:\n this.raise(expr.start, (bindingType ? \"Binding\" : \"Assigning to\") + \" rvalue\")\n }\n}\n","// A recursive descent parser operates by defining functions for all\n// syntactic elements, and recursively calling those, each function\n// advancing the input stream and returning an AST node. Precedence\n// of constructs (for example, the fact that `!x[1]` means `!(x[1])`\n// instead of `(!x)[1]` is handled by the fact that the parser\n// function that parses unary prefix operators is called first, and\n// in turn calls the function that parses `[]` subscripts — that\n// way, it'll receive the node for `x[1]` already parsed, and wraps\n// *that* in the unary operator node.\n//\n// Acorn uses an [operator precedence parser][opp] to handle binary\n// operator precedence, because it is much more compact than using\n// the technique outlined above, which uses different, nesting\n// functions to specify precedence, for all of the ten binary\n// precedence levels that JavaScript defines.\n//\n// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser\n\nimport {types as tt} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {DestructuringErrors} from \"./parseutil\"\nimport {lineBreak} from \"./whitespace\"\nimport {functionFlags, SCOPE_ARROW, SCOPE_SUPER, SCOPE_DIRECT_SUPER, BIND_OUTSIDE, BIND_VAR} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\n// Check if property name clashes with already added.\n// Object/class getters and setters are not allowed to clash —\n// either with each other or with an init property — and in\n// strict mode, init properties are also not allowed to be repeated.\n\npp.checkPropClash = function(prop, propHash, refDestructuringErrors) {\n if (this.options.ecmaVersion >= 9 && prop.type === \"SpreadElement\")\n return\n if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))\n return\n let {key} = prop, name\n switch (key.type) {\n case \"Identifier\": name = key.name; break\n case \"Literal\": name = String(key.value); break\n default: return\n }\n let {kind} = prop\n if (this.options.ecmaVersion >= 6) {\n if (name === \"__proto__\" && kind === \"init\") {\n if (propHash.proto) {\n if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) refDestructuringErrors.doubleProto = key.start\n // Backwards-compat kludge. Can be removed in version 6.0\n else this.raiseRecoverable(key.start, \"Redefinition of __proto__ property\")\n }\n propHash.proto = true\n }\n return\n }\n name = \"$\" + name\n let other = propHash[name]\n if (other) {\n let redefinition\n if (kind === \"init\") {\n redefinition = this.strict && other.init || other.get || other.set\n } else {\n redefinition = other.init || other[kind]\n }\n if (redefinition)\n this.raiseRecoverable(key.start, \"Redefinition of property\")\n } else {\n other = propHash[name] = {\n init: false,\n get: false,\n set: false\n }\n }\n other[kind] = true\n}\n\n// ### Expression parsing\n\n// These nest, from the most general expression type at the top to\n// 'atomic', nondivisible expression types at the bottom. Most of\n// the functions will simply let the function(s) below them parse,\n// and, *if* the syntactic construct they handle is present, wrap\n// the AST node that the inner parser gave them in another node.\n\n// Parse a full expression. The optional arguments are used to\n// forbid the `in` operator (in for loops initalization expressions)\n// and provide reference for storing '=' operator inside shorthand\n// property assignment in contexts where both object expression\n// and object pattern might appear (so it's possible to raise\n// delayed syntax error at correct position).\n\npp.parseExpression = function(noIn, refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseMaybeAssign(noIn, refDestructuringErrors)\n if (this.type === tt.comma) {\n let node = this.startNodeAt(startPos, startLoc)\n node.expressions = [expr]\n while (this.eat(tt.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refDestructuringErrors))\n return this.finishNode(node, \"SequenceExpression\")\n }\n return expr\n}\n\n// Parse an assignment expression. This includes applications of\n// operators like `+=`.\n\npp.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {\n if (this.isContextual(\"yield\")) {\n if (this.inGenerator) return this.parseYield(noIn)\n // The tokenizer will assume an expression is allowed after\n // `yield`, but this isn't that kind of yield\n else this.exprAllowed = false\n }\n\n let ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldShorthandAssign = -1\n if (refDestructuringErrors) {\n oldParenAssign = refDestructuringErrors.parenthesizedAssign\n oldTrailingComma = refDestructuringErrors.trailingComma\n oldShorthandAssign = refDestructuringErrors.shorthandAssign\n refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1\n } else {\n refDestructuringErrors = new DestructuringErrors\n ownDestructuringErrors = true\n }\n\n let startPos = this.start, startLoc = this.startLoc\n if (this.type === tt.parenL || this.type === tt.name)\n this.potentialArrowAt = this.start\n let left = this.parseMaybeConditional(noIn, refDestructuringErrors)\n if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc)\n if (this.type.isAssign) {\n let node = this.startNodeAt(startPos, startLoc)\n node.operator = this.value\n node.left = this.type === tt.eq ? this.toAssignable(left, false, refDestructuringErrors) : left\n if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors)\n refDestructuringErrors.shorthandAssign = -1 // reset because shorthand default was used correctly\n this.checkLVal(left)\n this.next()\n node.right = this.parseMaybeAssign(noIn)\n return this.finishNode(node, \"AssignmentExpression\")\n } else {\n if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true)\n }\n if (oldParenAssign > -1) refDestructuringErrors.parenthesizedAssign = oldParenAssign\n if (oldTrailingComma > -1) refDestructuringErrors.trailingComma = oldTrailingComma\n if (oldShorthandAssign > -1) refDestructuringErrors.shorthandAssign = oldShorthandAssign\n return left\n}\n\n// Parse a ternary conditional (`?:`) operator.\n\npp.parseMaybeConditional = function(noIn, refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseExprOps(noIn, refDestructuringErrors)\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\n if (this.eat(tt.question)) {\n let node = this.startNodeAt(startPos, startLoc)\n node.test = expr\n node.consequent = this.parseMaybeAssign()\n this.expect(tt.colon)\n node.alternate = this.parseMaybeAssign(noIn)\n return this.finishNode(node, \"ConditionalExpression\")\n }\n return expr\n}\n\n// Start the precedence parser.\n\npp.parseExprOps = function(noIn, refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseMaybeUnary(refDestructuringErrors, false)\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\n return expr.start === startPos && expr.type === \"ArrowFunctionExpression\" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn)\n}\n\n// Parse binary operators with the operator precedence parsing\n// algorithm. `left` is the left-hand side of the operator.\n// `minPrec` provides context that allows the function to stop and\n// defer further parser to one of its callers when it encounters an\n// operator that has a lower precedence than the set it is parsing.\n\npp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {\n let prec = this.type.binop\n if (prec != null && (!noIn || this.type !== tt._in)) {\n if (prec > minPrec) {\n let logical = this.type === tt.logicalOR || this.type === tt.logicalAND\n let op = this.value\n this.next()\n let startPos = this.start, startLoc = this.startLoc\n let right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn)\n let node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical)\n return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)\n }\n }\n return left\n}\n\npp.buildBinary = function(startPos, startLoc, left, right, op, logical) {\n let node = this.startNodeAt(startPos, startLoc)\n node.left = left\n node.operator = op\n node.right = right\n return this.finishNode(node, logical ? \"LogicalExpression\" : \"BinaryExpression\")\n}\n\n// Parse unary operators, both prefix and postfix.\n\npp.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {\n let startPos = this.start, startLoc = this.startLoc, expr\n if (this.isContextual(\"await\") && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction))) {\n expr = this.parseAwait()\n sawUnary = true\n } else if (this.type.prefix) {\n let node = this.startNode(), update = this.type === tt.incDec\n node.operator = this.value\n node.prefix = true\n this.next()\n node.argument = this.parseMaybeUnary(null, true)\n this.checkExpressionErrors(refDestructuringErrors, true)\n if (update) this.checkLVal(node.argument)\n else if (this.strict && node.operator === \"delete\" &&\n node.argument.type === \"Identifier\")\n this.raiseRecoverable(node.start, \"Deleting local variable in strict mode\")\n else sawUnary = true\n expr = this.finishNode(node, update ? \"UpdateExpression\" : \"UnaryExpression\")\n } else {\n expr = this.parseExprSubscripts(refDestructuringErrors)\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\n while (this.type.postfix && !this.canInsertSemicolon()) {\n let node = this.startNodeAt(startPos, startLoc)\n node.operator = this.value\n node.prefix = false\n node.argument = expr\n this.checkLVal(expr)\n this.next()\n expr = this.finishNode(node, \"UpdateExpression\")\n }\n }\n\n if (!sawUnary && this.eat(tt.starstar))\n return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), \"**\", false)\n else\n return expr\n}\n\n// Parse call, dot, and `[]`-subscript expressions.\n\npp.parseExprSubscripts = function(refDestructuringErrors) {\n let startPos = this.start, startLoc = this.startLoc\n let expr = this.parseExprAtom(refDestructuringErrors)\n let skipArrowSubscripts = expr.type === \"ArrowFunctionExpression\" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== \")\"\n if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr\n let result = this.parseSubscripts(expr, startPos, startLoc)\n if (refDestructuringErrors && result.type === \"MemberExpression\") {\n if (refDestructuringErrors.parenthesizedAssign >= result.start) refDestructuringErrors.parenthesizedAssign = -1\n if (refDestructuringErrors.parenthesizedBind >= result.start) refDestructuringErrors.parenthesizedBind = -1\n }\n return result\n}\n\npp.parseSubscripts = function(base, startPos, startLoc, noCalls) {\n let maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === \"Identifier\" && base.name === \"async\" &&\n this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === \"async\"\n for (let computed;;) {\n if ((computed = this.eat(tt.bracketL)) || this.eat(tt.dot)) {\n let node = this.startNodeAt(startPos, startLoc)\n node.object = base\n node.property = computed ? this.parseExpression() : this.parseIdent(true)\n node.computed = !!computed\n if (computed) this.expect(tt.bracketR)\n base = this.finishNode(node, \"MemberExpression\")\n } else if (!noCalls && this.eat(tt.parenL)) {\n let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n this.yieldPos = 0\n this.awaitPos = 0\n let exprList = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors)\n if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {\n this.checkPatternErrors(refDestructuringErrors, false)\n this.checkYieldAwaitInDefaultParams()\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true)\n }\n this.checkExpressionErrors(refDestructuringErrors, true)\n this.yieldPos = oldYieldPos || this.yieldPos\n this.awaitPos = oldAwaitPos || this.awaitPos\n let node = this.startNodeAt(startPos, startLoc)\n node.callee = base\n node.arguments = exprList\n base = this.finishNode(node, \"CallExpression\")\n } else if (this.type === tt.backQuote) {\n let node = this.startNodeAt(startPos, startLoc)\n node.tag = base\n node.quasi = this.parseTemplate({isTagged: true})\n base = this.finishNode(node, \"TaggedTemplateExpression\")\n } else {\n return base\n }\n }\n}\n\n// Parse an atomic expression — either a single token that is an\n// expression, an expression started by a keyword like `function` or\n// `new`, or an expression wrapped in punctuation like `()`, `[]`,\n// or `{}`.\n\npp.parseExprAtom = function(refDestructuringErrors) {\n // If a division operator appears in an expression position, the\n // tokenizer got confused, and we force it to read a regexp instead.\n if (this.type === tt.slash) this.readRegexp()\n\n let node, canBeArrow = this.potentialArrowAt === this.start\n switch (this.type) {\n case tt._super:\n if (!this.allowSuper)\n this.raise(this.start, \"'super' keyword outside a method\")\n node = this.startNode()\n this.next()\n if (this.type === tt.parenL && !this.allowDirectSuper)\n this.raise(node.start, \"super() call outside constructor of a subclass\")\n // The `super` keyword can appear at below:\n // SuperProperty:\n // super [ Expression ]\n // super . IdentifierName\n // SuperCall:\n // super Arguments\n if (this.type !== tt.dot && this.type !== tt.bracketL && this.type !== tt.parenL)\n this.unexpected()\n return this.finishNode(node, \"Super\")\n\n case tt._this:\n node = this.startNode()\n this.next()\n return this.finishNode(node, \"ThisExpression\")\n\n case tt.name:\n let startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc\n let id = this.parseIdent(this.type !== tt.name)\n if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === \"async\" && !this.canInsertSemicolon() && this.eat(tt._function))\n return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true)\n if (canBeArrow && !this.canInsertSemicolon()) {\n if (this.eat(tt.arrow))\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false)\n if (this.options.ecmaVersion >= 8 && id.name === \"async\" && this.type === tt.name && !containsEsc) {\n id = this.parseIdent()\n if (this.canInsertSemicolon() || !this.eat(tt.arrow))\n this.unexpected()\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)\n }\n }\n return id\n\n case tt.regexp:\n let value = this.value\n node = this.parseLiteral(value.value)\n node.regex = {pattern: value.pattern, flags: value.flags}\n return node\n\n case tt.num: case tt.string:\n return this.parseLiteral(this.value)\n\n case tt._null: case tt._true: case tt._false:\n node = this.startNode()\n node.value = this.type === tt._null ? null : this.type === tt._true\n node.raw = this.type.keyword\n this.next()\n return this.finishNode(node, \"Literal\")\n\n case tt.parenL:\n let start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow)\n if (refDestructuringErrors) {\n if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))\n refDestructuringErrors.parenthesizedAssign = start\n if (refDestructuringErrors.parenthesizedBind < 0)\n refDestructuringErrors.parenthesizedBind = start\n }\n return expr\n\n case tt.bracketL:\n node = this.startNode()\n this.next()\n node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors)\n return this.finishNode(node, \"ArrayExpression\")\n\n case tt.braceL:\n return this.parseObj(false, refDestructuringErrors)\n\n case tt._function:\n node = this.startNode()\n this.next()\n return this.parseFunction(node, 0)\n\n case tt._class:\n return this.parseClass(this.startNode(), false)\n\n case tt._new:\n return this.parseNew()\n\n case tt.backQuote:\n return this.parseTemplate()\n\n default:\n this.unexpected()\n }\n}\n\npp.parseLiteral = function(value) {\n let node = this.startNode()\n node.value = value\n node.raw = this.input.slice(this.start, this.end)\n this.next()\n return this.finishNode(node, \"Literal\")\n}\n\npp.parseParenExpression = function() {\n this.expect(tt.parenL)\n let val = this.parseExpression()\n this.expect(tt.parenR)\n return val\n}\n\npp.parseParenAndDistinguishExpression = function(canBeArrow) {\n let startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8\n if (this.options.ecmaVersion >= 6) {\n this.next()\n\n let innerStartPos = this.start, innerStartLoc = this.startLoc\n let exprList = [], first = true, lastIsComma = false\n let refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart\n this.yieldPos = 0\n this.awaitPos = 0\n while (this.type !== tt.parenR) {\n first ? first = false : this.expect(tt.comma)\n if (allowTrailingComma && this.afterTrailingComma(tt.parenR, true)) {\n lastIsComma = true\n break\n } else if (this.type === tt.ellipsis) {\n spreadStart = this.start\n exprList.push(this.parseParenItem(this.parseRestBinding()))\n if (this.type === tt.comma) this.raise(this.start, \"Comma is not permitted after the rest element\")\n break\n } else {\n exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem))\n }\n }\n let innerEndPos = this.start, innerEndLoc = this.startLoc\n this.expect(tt.parenR)\n\n if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {\n this.checkPatternErrors(refDestructuringErrors, false)\n this.checkYieldAwaitInDefaultParams()\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.parseParenArrowList(startPos, startLoc, exprList)\n }\n\n if (!exprList.length || lastIsComma) this.unexpected(this.lastTokStart)\n if (spreadStart) this.unexpected(spreadStart)\n this.checkExpressionErrors(refDestructuringErrors, true)\n this.yieldPos = oldYieldPos || this.yieldPos\n this.awaitPos = oldAwaitPos || this.awaitPos\n\n if (exprList.length > 1) {\n val = this.startNodeAt(innerStartPos, innerStartLoc)\n val.expressions = exprList\n this.finishNodeAt(val, \"SequenceExpression\", innerEndPos, innerEndLoc)\n } else {\n val = exprList[0]\n }\n } else {\n val = this.parseParenExpression()\n }\n\n if (this.options.preserveParens) {\n let par = this.startNodeAt(startPos, startLoc)\n par.expression = val\n return this.finishNode(par, \"ParenthesizedExpression\")\n } else {\n return val\n }\n}\n\npp.parseParenItem = function(item) {\n return item\n}\n\npp.parseParenArrowList = function(startPos, startLoc, exprList) {\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)\n}\n\n// New's precedence is slightly tricky. It must allow its argument to\n// be a `[]` or dot subscript expression, but not a call — at least,\n// not without wrapping it in parentheses. Thus, it uses the noCalls\n// argument to parseSubscripts to prevent it from consuming the\n// argument list.\n\nconst empty = []\n\npp.parseNew = function() {\n let node = this.startNode()\n let meta = this.parseIdent(true)\n if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {\n node.meta = meta\n let containsEsc = this.containsEsc\n node.property = this.parseIdent(true)\n if (node.property.name !== \"target\" || containsEsc)\n this.raiseRecoverable(node.property.start, \"The only valid meta property for new is new.target\")\n if (!this.inNonArrowFunction())\n this.raiseRecoverable(node.start, \"new.target can only be used in functions\")\n return this.finishNode(node, \"MetaProperty\")\n }\n let startPos = this.start, startLoc = this.startLoc\n node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true)\n if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false)\n else node.arguments = empty\n return this.finishNode(node, \"NewExpression\")\n}\n\n// Parse template expression.\n\npp.parseTemplateElement = function({isTagged}) {\n let elem = this.startNode()\n if (this.type === tt.invalidTemplate) {\n if (!isTagged) {\n this.raiseRecoverable(this.start, \"Bad escape sequence in untagged template literal\")\n }\n elem.value = {\n raw: this.value,\n cooked: null\n }\n } else {\n elem.value = {\n raw: this.input.slice(this.start, this.end).replace(/\\r\\n?/g, \"\\n\"),\n cooked: this.value\n }\n }\n this.next()\n elem.tail = this.type === tt.backQuote\n return this.finishNode(elem, \"TemplateElement\")\n}\n\npp.parseTemplate = function({isTagged = false} = {}) {\n let node = this.startNode()\n this.next()\n node.expressions = []\n let curElt = this.parseTemplateElement({isTagged})\n node.quasis = [curElt]\n while (!curElt.tail) {\n if (this.type === tt.eof) this.raise(this.pos, \"Unterminated template literal\")\n this.expect(tt.dollarBraceL)\n node.expressions.push(this.parseExpression())\n this.expect(tt.braceR)\n node.quasis.push(curElt = this.parseTemplateElement({isTagged}))\n }\n this.next()\n return this.finishNode(node, \"TemplateLiteral\")\n}\n\npp.isAsyncProp = function(prop) {\n return !prop.computed && prop.key.type === \"Identifier\" && prop.key.name === \"async\" &&\n (this.type === tt.name || this.type === tt.num || this.type === tt.string || this.type === tt.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === tt.star)) &&\n !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n}\n\n// Parse an object literal or binding pattern.\n\npp.parseObj = function(isPattern, refDestructuringErrors) {\n let node = this.startNode(), first = true, propHash = {}\n node.properties = []\n this.next()\n while (!this.eat(tt.braceR)) {\n if (!first) {\n this.expect(tt.comma)\n if (this.afterTrailingComma(tt.braceR)) break\n } else first = false\n\n const prop = this.parseProperty(isPattern, refDestructuringErrors)\n if (!isPattern) this.checkPropClash(prop, propHash, refDestructuringErrors)\n node.properties.push(prop)\n }\n return this.finishNode(node, isPattern ? \"ObjectPattern\" : \"ObjectExpression\")\n}\n\npp.parseProperty = function(isPattern, refDestructuringErrors) {\n let prop = this.startNode(), isGenerator, isAsync, startPos, startLoc\n if (this.options.ecmaVersion >= 9 && this.eat(tt.ellipsis)) {\n if (isPattern) {\n prop.argument = this.parseIdent(false)\n if (this.type === tt.comma) {\n this.raise(this.start, \"Comma is not permitted after the rest element\")\n }\n return this.finishNode(prop, \"RestElement\")\n }\n // To disallow parenthesized identifier via `this.toAssignable()`.\n if (this.type === tt.parenL && refDestructuringErrors) {\n if (refDestructuringErrors.parenthesizedAssign < 0) {\n refDestructuringErrors.parenthesizedAssign = this.start\n }\n if (refDestructuringErrors.parenthesizedBind < 0) {\n refDestructuringErrors.parenthesizedBind = this.start\n }\n }\n // Parse argument.\n prop.argument = this.parseMaybeAssign(false, refDestructuringErrors)\n // To disallow trailing comma via `this.toAssignable()`.\n if (this.type === tt.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {\n refDestructuringErrors.trailingComma = this.start\n }\n // Finish\n return this.finishNode(prop, \"SpreadElement\")\n }\n if (this.options.ecmaVersion >= 6) {\n prop.method = false\n prop.shorthand = false\n if (isPattern || refDestructuringErrors) {\n startPos = this.start\n startLoc = this.startLoc\n }\n if (!isPattern)\n isGenerator = this.eat(tt.star)\n }\n let containsEsc = this.containsEsc\n this.parsePropertyName(prop)\n if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {\n isAsync = true\n isGenerator = this.options.ecmaVersion >= 9 && this.eat(tt.star)\n this.parsePropertyName(prop, refDestructuringErrors)\n } else {\n isAsync = false\n }\n this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc)\n return this.finishNode(prop, \"Property\")\n}\n\npp.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {\n if ((isGenerator || isAsync) && this.type === tt.colon)\n this.unexpected()\n\n if (this.eat(tt.colon)) {\n prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors)\n prop.kind = \"init\"\n } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {\n if (isPattern) this.unexpected()\n prop.kind = \"init\"\n prop.method = true\n prop.value = this.parseMethod(isGenerator, isAsync)\n } else if (!isPattern && !containsEsc &&\n this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === \"Identifier\" &&\n (prop.key.name === \"get\" || prop.key.name === \"set\") &&\n (this.type !== tt.comma && this.type !== tt.braceR)) {\n if (isGenerator || isAsync) this.unexpected()\n prop.kind = prop.key.name\n this.parsePropertyName(prop)\n prop.value = this.parseMethod(false)\n let paramCount = prop.kind === \"get\" ? 0 : 1\n if (prop.value.params.length !== paramCount) {\n let start = prop.value.start\n if (prop.kind === \"get\")\n this.raiseRecoverable(start, \"getter should have no params\")\n else\n this.raiseRecoverable(start, \"setter should have exactly one param\")\n } else {\n if (prop.kind === \"set\" && prop.value.params[0].type === \"RestElement\")\n this.raiseRecoverable(prop.value.params[0].start, \"Setter cannot use rest params\")\n }\n } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === \"Identifier\") {\n this.checkUnreserved(prop.key)\n prop.kind = \"init\"\n if (isPattern) {\n prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)\n } else if (this.type === tt.eq && refDestructuringErrors) {\n if (refDestructuringErrors.shorthandAssign < 0)\n refDestructuringErrors.shorthandAssign = this.start\n prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)\n } else {\n prop.value = prop.key\n }\n prop.shorthand = true\n } else this.unexpected()\n}\n\npp.parsePropertyName = function(prop) {\n if (this.options.ecmaVersion >= 6) {\n if (this.eat(tt.bracketL)) {\n prop.computed = true\n prop.key = this.parseMaybeAssign()\n this.expect(tt.bracketR)\n return prop.key\n } else {\n prop.computed = false\n }\n }\n return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true)\n}\n\n// Initialize empty function node.\n\npp.initFunction = function(node) {\n node.id = null\n if (this.options.ecmaVersion >= 6) node.generator = node.expression = false\n if (this.options.ecmaVersion >= 8) node.async = false\n}\n\n// Parse object or class method.\n\npp.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {\n let node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n\n this.initFunction(node)\n if (this.options.ecmaVersion >= 6)\n node.generator = isGenerator\n if (this.options.ecmaVersion >= 8)\n node.async = !!isAsync\n\n this.yieldPos = 0\n this.awaitPos = 0\n this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0))\n\n this.expect(tt.parenL)\n node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8)\n this.checkYieldAwaitInDefaultParams()\n this.parseFunctionBody(node, false)\n\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.finishNode(node, \"FunctionExpression\")\n}\n\n// Parse arrow function expression with given parameters.\n\npp.parseArrowExpression = function(node, params, isAsync) {\n let oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos\n\n this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW)\n this.initFunction(node)\n if (this.options.ecmaVersion >= 8) node.async = !!isAsync\n\n this.yieldPos = 0\n this.awaitPos = 0\n\n node.params = this.toAssignableList(params, true)\n this.parseFunctionBody(node, true)\n\n this.yieldPos = oldYieldPos\n this.awaitPos = oldAwaitPos\n return this.finishNode(node, \"ArrowFunctionExpression\")\n}\n\n// Parse function body and check parameters.\n\npp.parseFunctionBody = function(node, isArrowFunction) {\n let isExpression = isArrowFunction && this.type !== tt.braceL\n let oldStrict = this.strict, useStrict = false\n\n if (isExpression) {\n node.body = this.parseMaybeAssign()\n node.expression = true\n this.checkParams(node, false)\n } else {\n let nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params)\n if (!oldStrict || nonSimple) {\n useStrict = this.strictDirective(this.end)\n // If this is a strict mode function, verify that argument names\n // are not repeated, and it does not try to bind the words `eval`\n // or `arguments`.\n if (useStrict && nonSimple)\n this.raiseRecoverable(node.start, \"Illegal 'use strict' directive in function with non-simple parameter list\")\n }\n // Start a new scope with regard to labels and the `inFunction`\n // flag (restore them to their old value afterwards).\n let oldLabels = this.labels\n this.labels = []\n if (useStrict) this.strict = true\n\n // Add the params to varDeclaredNames to ensure that an error is thrown\n // if a let/const declaration in the function clashes with one of the params.\n this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params))\n node.body = this.parseBlock(false)\n node.expression = false\n this.adaptDirectivePrologue(node.body.body)\n this.labels = oldLabels\n }\n this.exitScope()\n\n // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'\n if (this.strict && node.id) this.checkLVal(node.id, BIND_OUTSIDE)\n this.strict = oldStrict\n}\n\npp.isSimpleParamList = function(params) {\n for (let param of params)\n if (param.type !== \"Identifier\") return false\n return true\n}\n\n// Checks function params for various disallowed patterns such as using \"eval\"\n// or \"arguments\" and duplicate parameters.\n\npp.checkParams = function(node, allowDuplicates) {\n let nameHash = {}\n for (let param of node.params)\n this.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash)\n}\n\n// Parses a comma-separated list of expressions, and returns them as\n// an array. `close` is the token type that ends the list, and\n// `allowEmpty` can be turned on to allow subsequent commas with\n// nothing in between them to be parsed as `null` (which is needed\n// for array literals).\n\npp.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {\n let elts = [], first = true\n while (!this.eat(close)) {\n if (!first) {\n this.expect(tt.comma)\n if (allowTrailingComma && this.afterTrailingComma(close)) break\n } else first = false\n\n let elt\n if (allowEmpty && this.type === tt.comma)\n elt = null\n else if (this.type === tt.ellipsis) {\n elt = this.parseSpread(refDestructuringErrors)\n if (refDestructuringErrors && this.type === tt.comma && refDestructuringErrors.trailingComma < 0)\n refDestructuringErrors.trailingComma = this.start\n } else {\n elt = this.parseMaybeAssign(false, refDestructuringErrors)\n }\n elts.push(elt)\n }\n return elts\n}\n\npp.checkUnreserved = function({start, end, name}) {\n if (this.inGenerator && name === \"yield\")\n this.raiseRecoverable(start, \"Can not use 'yield' as identifier inside a generator\")\n if (this.inAsync && name === \"await\")\n this.raiseRecoverable(start, \"Can not use 'await' as identifier inside an async function\")\n if (this.keywords.test(name))\n this.raise(start, `Unexpected keyword '${name}'`)\n if (this.options.ecmaVersion < 6 &&\n this.input.slice(start, end).indexOf(\"\\\\\") !== -1) return\n const re = this.strict ? this.reservedWordsStrict : this.reservedWords\n if (re.test(name)) {\n if (!this.inAsync && name === \"await\")\n this.raiseRecoverable(start, \"Can not use keyword 'await' outside an async function\")\n this.raiseRecoverable(start, `The keyword '${name}' is reserved`)\n }\n}\n\n// Parse the next token as an identifier. If `liberal` is true (used\n// when parsing properties), it will also convert keywords into\n// identifiers.\n\npp.parseIdent = function(liberal, isBinding) {\n let node = this.startNode()\n if (liberal && this.options.allowReserved === \"never\") liberal = false\n if (this.type === tt.name) {\n node.name = this.value\n } else if (this.type.keyword) {\n node.name = this.type.keyword\n\n // To fix https://github.com/acornjs/acorn/issues/575\n // `class` and `function` keywords push new context into this.context.\n // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.\n // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword\n if ((node.name === \"class\" || node.name === \"function\") &&\n (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {\n this.context.pop()\n }\n } else {\n this.unexpected()\n }\n this.next()\n this.finishNode(node, \"Identifier\")\n if (!liberal) this.checkUnreserved(node)\n return node\n}\n\n// Parses yield expression inside generator.\n\npp.parseYield = function(noIn) {\n if (!this.yieldPos) this.yieldPos = this.start\n\n let node = this.startNode()\n this.next()\n if (this.type === tt.semi || this.canInsertSemicolon() || (this.type !== tt.star && !this.type.startsExpr)) {\n node.delegate = false\n node.argument = null\n } else {\n node.delegate = this.eat(tt.star)\n node.argument = this.parseMaybeAssign(noIn)\n }\n return this.finishNode(node, \"YieldExpression\")\n}\n\npp.parseAwait = function() {\n if (!this.awaitPos) this.awaitPos = this.start\n\n let node = this.startNode()\n this.next()\n node.argument = this.parseMaybeUnary(null, true)\n return this.finishNode(node, \"AwaitExpression\")\n}\n","import {Parser} from \"./state\"\nimport {Position, getLineInfo} from \"./locutil\"\n\nconst pp = Parser.prototype\n\n// This function is used to raise exceptions on parse errors. It\n// takes an offset integer (into the current `input`) to indicate\n// the location of the error, attaches the position to the end\n// of the error message, and then raises a `SyntaxError` with that\n// message.\n\npp.raise = function(pos, message) {\n let loc = getLineInfo(this.input, pos)\n message += \" (\" + loc.line + \":\" + loc.column + \")\"\n let err = new SyntaxError(message)\n err.pos = pos; err.loc = loc; err.raisedAt = this.pos\n throw err\n}\n\npp.raiseRecoverable = pp.raise\n\npp.curPosition = function() {\n if (this.options.locations) {\n return new Position(this.curLine, this.pos - this.lineStart)\n }\n}\n","import {Parser} from \"./state\"\nimport {SCOPE_VAR, SCOPE_FUNCTION, SCOPE_TOP, SCOPE_ARROW, SCOPE_SIMPLE_CATCH, BIND_LEXICAL, BIND_SIMPLE_CATCH, BIND_FUNCTION} from \"./scopeflags\"\n\nconst pp = Parser.prototype\n\nclass Scope {\n constructor(flags) {\n this.flags = flags\n // A list of var-declared names in the current lexical scope\n this.var = []\n // A list of lexically-declared names in the current lexical scope\n this.lexical = []\n // A list of lexically-declared FunctionDeclaration names in the current lexical scope\n this.functions = []\n }\n}\n\n// The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.\n\npp.enterScope = function(flags) {\n this.scopeStack.push(new Scope(flags))\n}\n\npp.exitScope = function() {\n this.scopeStack.pop()\n}\n\n// The spec says:\n// > At the top level of a function, or script, function declarations are\n// > treated like var declarations rather than like lexical declarations.\npp.treatFunctionsAsVarInScope = function(scope) {\n return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP);\n}\n\npp.declareName = function(name, bindingType, pos) {\n let redeclared = false\n if (bindingType === BIND_LEXICAL) {\n const scope = this.currentScope()\n redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1\n scope.lexical.push(name)\n } else if (bindingType === BIND_SIMPLE_CATCH) {\n const scope = this.currentScope()\n scope.lexical.push(name)\n } else if (bindingType === BIND_FUNCTION) {\n const scope = this.currentScope()\n if (this.treatFunctionsAsVar)\n redeclared = scope.lexical.indexOf(name) > -1;\n else\n redeclared = scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1\n scope.functions.push(name)\n } else {\n for (let i = this.scopeStack.length - 1; i >= 0; --i) {\n const scope = this.scopeStack[i]\n if (scope.lexical.indexOf(name) > -1 && !(scope.flags & SCOPE_SIMPLE_CATCH) && scope.lexical[0] === name ||\n !this.treatFunctionsAsVarInScope(scope) && scope.functions.indexOf(name) > -1) {\n redeclared = true\n break\n }\n scope.var.push(name)\n if (scope.flags & SCOPE_VAR) break\n }\n }\n if (redeclared) this.raiseRecoverable(pos, `Identifier '${name}' has already been declared`)\n}\n\npp.currentScope = function() {\n return this.scopeStack[this.scopeStack.length - 1]\n}\n\npp.currentVarScope = function() {\n for (let i = this.scopeStack.length - 1;; i--) {\n let scope = this.scopeStack[i]\n if (scope.flags & SCOPE_VAR) return scope\n }\n}\n\n// Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.\npp.currentThisScope = function() {\n for (let i = this.scopeStack.length - 1;; i--) {\n let scope = this.scopeStack[i]\n if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) return scope\n }\n}\n","import {Parser} from \"./state\"\nimport {SourceLocation} from \"./locutil\"\n\nexport class Node {\n constructor(parser, pos, loc) {\n this.type = \"\"\n this.start = pos\n this.end = 0\n if (parser.options.locations)\n this.loc = new SourceLocation(parser, loc)\n if (parser.options.directSourceFile)\n this.sourceFile = parser.options.directSourceFile\n if (parser.options.ranges)\n this.range = [pos, 0]\n }\n}\n\n// Start an AST node, attaching a start offset.\n\nconst pp = Parser.prototype\n\npp.startNode = function() {\n return new Node(this, this.start, this.startLoc)\n}\n\npp.startNodeAt = function(pos, loc) {\n return new Node(this, pos, loc)\n}\n\n// Finish an AST node, adding `type` and `end` properties.\n\nfunction finishNodeAt(node, type, pos, loc) {\n node.type = type\n node.end = pos\n if (this.options.locations)\n node.loc.end = loc\n if (this.options.ranges)\n node.range[1] = pos\n return node\n}\n\npp.finishNode = function(node, type) {\n return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)\n}\n\n// Finish node at given position\n\npp.finishNodeAt = function(node, type, pos, loc) {\n return finishNodeAt.call(this, node, type, pos, loc)\n}\n","// The algorithm used to determine whether a regexp can appear at a\n// given point in the program is loosely based on sweet.js' approach.\n// See https://github.com/mozilla/sweet.js/wiki/design\n\nimport {Parser} from \"./state\"\nimport {types as tt} from \"./tokentype\"\nimport {lineBreak} from \"./whitespace\"\n\nexport class TokContext {\n constructor(token, isExpr, preserveSpace, override, generator) {\n this.token = token\n this.isExpr = !!isExpr\n this.preserveSpace = !!preserveSpace\n this.override = override\n this.generator = !!generator\n }\n}\n\nexport const types = {\n b_stat: new TokContext(\"{\", false),\n b_expr: new TokContext(\"{\", true),\n b_tmpl: new TokContext(\"${\", false),\n p_stat: new TokContext(\"(\", false),\n p_expr: new TokContext(\"(\", true),\n q_tmpl: new TokContext(\"`\", true, true, p => p.tryReadTemplateToken()),\n f_stat: new TokContext(\"function\", false),\n f_expr: new TokContext(\"function\", true),\n f_expr_gen: new TokContext(\"function\", true, false, null, true),\n f_gen: new TokContext(\"function\", false, false, null, true)\n}\n\nconst pp = Parser.prototype\n\npp.initialContext = function() {\n return [types.b_stat]\n}\n\npp.braceIsBlock = function(prevType) {\n let parent = this.curContext()\n if (parent === types.f_expr || parent === types.f_stat)\n return true\n if (prevType === tt.colon && (parent === types.b_stat || parent === types.b_expr))\n return !parent.isExpr\n\n // The check for `tt.name && exprAllowed` detects whether we are\n // after a `yield` or `of` construct. See the `updateContext` for\n // `tt.name`.\n if (prevType === tt._return || prevType === tt.name && this.exprAllowed)\n return lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR || prevType === tt.arrow)\n return true\n if (prevType === tt.braceL)\n return parent === types.b_stat\n if (prevType === tt._var || prevType === tt._const || prevType === tt.name)\n return false\n return !this.exprAllowed\n}\n\npp.inGeneratorContext = function() {\n for (let i = this.context.length - 1; i >= 1; i--) {\n let context = this.context[i]\n if (context.token === \"function\")\n return context.generator\n }\n return false\n}\n\npp.updateContext = function(prevType) {\n let update, type = this.type\n if (type.keyword && prevType === tt.dot)\n this.exprAllowed = false\n else if (update = type.updateContext)\n update.call(this, prevType)\n else\n this.exprAllowed = type.beforeExpr\n}\n\n// Token-specific context update code\n\ntt.parenR.updateContext = tt.braceR.updateContext = function() {\n if (this.context.length === 1) {\n this.exprAllowed = true\n return\n }\n let out = this.context.pop()\n if (out === types.b_stat && this.curContext().token === \"function\") {\n out = this.context.pop()\n }\n this.exprAllowed = !out.isExpr\n}\n\ntt.braceL.updateContext = function(prevType) {\n this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr)\n this.exprAllowed = true\n}\n\ntt.dollarBraceL.updateContext = function() {\n this.context.push(types.b_tmpl)\n this.exprAllowed = true\n}\n\ntt.parenL.updateContext = function(prevType) {\n let statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while\n this.context.push(statementParens ? types.p_stat : types.p_expr)\n this.exprAllowed = true\n}\n\ntt.incDec.updateContext = function() {\n // tokExprAllowed stays unchanged\n}\n\ntt._function.updateContext = tt._class.updateContext = function(prevType) {\n if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else &&\n !(prevType === tt._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&\n !((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat))\n this.context.push(types.f_expr)\n else\n this.context.push(types.f_stat)\n this.exprAllowed = false\n}\n\ntt.backQuote.updateContext = function() {\n if (this.curContext() === types.q_tmpl)\n this.context.pop()\n else\n this.context.push(types.q_tmpl)\n this.exprAllowed = false\n}\n\ntt.star.updateContext = function(prevType) {\n if (prevType === tt._function) {\n let index = this.context.length - 1\n if (this.context[index] === types.f_expr)\n this.context[index] = types.f_expr_gen\n else\n this.context[index] = types.f_gen\n }\n this.exprAllowed = true\n}\n\ntt.name.updateContext = function(prevType) {\n let allowed = false\n if (this.options.ecmaVersion >= 6 && prevType !== tt.dot) {\n if (this.value === \"of\" && !this.exprAllowed ||\n this.value === \"yield\" && this.inGeneratorContext())\n allowed = true\n }\n this.exprAllowed = allowed\n}\n","const data = {\n \"$LONE\": [\n \"ASCII\",\n \"ASCII_Hex_Digit\",\n \"AHex\",\n \"Alphabetic\",\n \"Alpha\",\n \"Any\",\n \"Assigned\",\n \"Bidi_Control\",\n \"Bidi_C\",\n \"Bidi_Mirrored\",\n \"Bidi_M\",\n \"Case_Ignorable\",\n \"CI\",\n \"Cased\",\n \"Changes_When_Casefolded\",\n \"CWCF\",\n \"Changes_When_Casemapped\",\n \"CWCM\",\n \"Changes_When_Lowercased\",\n \"CWL\",\n \"Changes_When_NFKC_Casefolded\",\n \"CWKCF\",\n \"Changes_When_Titlecased\",\n \"CWT\",\n \"Changes_When_Uppercased\",\n \"CWU\",\n \"Dash\",\n \"Default_Ignorable_Code_Point\",\n \"DI\",\n \"Deprecated\",\n \"Dep\",\n \"Diacritic\",\n \"Dia\",\n \"Emoji\",\n \"Emoji_Component\",\n \"Emoji_Modifier\",\n \"Emoji_Modifier_Base\",\n \"Emoji_Presentation\",\n \"Extender\",\n \"Ext\",\n \"Grapheme_Base\",\n \"Gr_Base\",\n \"Grapheme_Extend\",\n \"Gr_Ext\",\n \"Hex_Digit\",\n \"Hex\",\n \"IDS_Binary_Operator\",\n \"IDSB\",\n \"IDS_Trinary_Operator\",\n \"IDST\",\n \"ID_Continue\",\n \"IDC\",\n \"ID_Start\",\n \"IDS\",\n \"Ideographic\",\n \"Ideo\",\n \"Join_Control\",\n \"Join_C\",\n \"Logical_Order_Exception\",\n \"LOE\",\n \"Lowercase\",\n \"Lower\",\n \"Math\",\n \"Noncharacter_Code_Point\",\n \"NChar\",\n \"Pattern_Syntax\",\n \"Pat_Syn\",\n \"Pattern_White_Space\",\n \"Pat_WS\",\n \"Quotation_Mark\",\n \"QMark\",\n \"Radical\",\n \"Regional_Indicator\",\n \"RI\",\n \"Sentence_Terminal\",\n \"STerm\",\n \"Soft_Dotted\",\n \"SD\",\n \"Terminal_Punctuation\",\n \"Term\",\n \"Unified_Ideograph\",\n \"UIdeo\",\n \"Uppercase\",\n \"Upper\",\n \"Variation_Selector\",\n \"VS\",\n \"White_Space\",\n \"space\",\n \"XID_Continue\",\n \"XIDC\",\n \"XID_Start\",\n \"XIDS\"\n ],\n \"General_Category\": [\n \"Cased_Letter\",\n \"LC\",\n \"Close_Punctuation\",\n \"Pe\",\n \"Connector_Punctuation\",\n \"Pc\",\n \"Control\",\n \"Cc\",\n \"cntrl\",\n \"Currency_Symbol\",\n \"Sc\",\n \"Dash_Punctuation\",\n \"Pd\",\n \"Decimal_Number\",\n \"Nd\",\n \"digit\",\n \"Enclosing_Mark\",\n \"Me\",\n \"Final_Punctuation\",\n \"Pf\",\n \"Format\",\n \"Cf\",\n \"Initial_Punctuation\",\n \"Pi\",\n \"Letter\",\n \"L\",\n \"Letter_Number\",\n \"Nl\",\n \"Line_Separator\",\n \"Zl\",\n \"Lowercase_Letter\",\n \"Ll\",\n \"Mark\",\n \"M\",\n \"Combining_Mark\",\n \"Math_Symbol\",\n \"Sm\",\n \"Modifier_Letter\",\n \"Lm\",\n \"Modifier_Symbol\",\n \"Sk\",\n \"Nonspacing_Mark\",\n \"Mn\",\n \"Number\",\n \"N\",\n \"Open_Punctuation\",\n \"Ps\",\n \"Other\",\n \"C\",\n \"Other_Letter\",\n \"Lo\",\n \"Other_Number\",\n \"No\",\n \"Other_Punctuation\",\n \"Po\",\n \"Other_Symbol\",\n \"So\",\n \"Paragraph_Separator\",\n \"Zp\",\n \"Private_Use\",\n \"Co\",\n \"Punctuation\",\n \"P\",\n \"punct\",\n \"Separator\",\n \"Z\",\n \"Space_Separator\",\n \"Zs\",\n \"Spacing_Mark\",\n \"Mc\",\n \"Surrogate\",\n \"Cs\",\n \"Symbol\",\n \"S\",\n \"Titlecase_Letter\",\n \"Lt\",\n \"Unassigned\",\n \"Cn\",\n \"Uppercase_Letter\",\n \"Lu\"\n ],\n \"Script\": [\n \"Adlam\",\n \"Adlm\",\n \"Ahom\",\n \"Anatolian_Hieroglyphs\",\n \"Hluw\",\n \"Arabic\",\n \"Arab\",\n \"Armenian\",\n \"Armn\",\n \"Avestan\",\n \"Avst\",\n \"Balinese\",\n \"Bali\",\n \"Bamum\",\n \"Bamu\",\n \"Bassa_Vah\",\n \"Bass\",\n \"Batak\",\n \"Batk\",\n \"Bengali\",\n \"Beng\",\n \"Bhaiksuki\",\n \"Bhks\",\n \"Bopomofo\",\n \"Bopo\",\n \"Brahmi\",\n \"Brah\",\n \"Braille\",\n \"Brai\",\n \"Buginese\",\n \"Bugi\",\n \"Buhid\",\n \"Buhd\",\n \"Canadian_Aboriginal\",\n \"Cans\",\n \"Carian\",\n \"Cari\",\n \"Caucasian_Albanian\",\n \"Aghb\",\n \"Chakma\",\n \"Cakm\",\n \"Cham\",\n \"Cherokee\",\n \"Cher\",\n \"Common\",\n \"Zyyy\",\n \"Coptic\",\n \"Copt\",\n \"Qaac\",\n \"Cuneiform\",\n \"Xsux\",\n \"Cypriot\",\n \"Cprt\",\n \"Cyrillic\",\n \"Cyrl\",\n \"Deseret\",\n \"Dsrt\",\n \"Devanagari\",\n \"Deva\",\n \"Duployan\",\n \"Dupl\",\n \"Egyptian_Hieroglyphs\",\n \"Egyp\",\n \"Elbasan\",\n \"Elba\",\n \"Ethiopic\",\n \"Ethi\",\n \"Georgian\",\n \"Geor\",\n \"Glagolitic\",\n \"Glag\",\n \"Gothic\",\n \"Goth\",\n \"Grantha\",\n \"Gran\",\n \"Greek\",\n \"Grek\",\n \"Gujarati\",\n \"Gujr\",\n \"Gurmukhi\",\n \"Guru\",\n \"Han\",\n \"Hani\",\n \"Hangul\",\n \"Hang\",\n \"Hanunoo\",\n \"Hano\",\n \"Hatran\",\n \"Hatr\",\n \"Hebrew\",\n \"Hebr\",\n \"Hiragana\",\n \"Hira\",\n \"Imperial_Aramaic\",\n \"Armi\",\n \"Inherited\",\n \"Zinh\",\n \"Qaai\",\n \"Inscriptional_Pahlavi\",\n \"Phli\",\n \"Inscriptional_Parthian\",\n \"Prti\",\n \"Javanese\",\n \"Java\",\n \"Kaithi\",\n \"Kthi\",\n \"Kannada\",\n \"Knda\",\n \"Katakana\",\n \"Kana\",\n \"Kayah_Li\",\n \"Kali\",\n \"Kharoshthi\",\n \"Khar\",\n \"Khmer\",\n \"Khmr\",\n \"Khojki\",\n \"Khoj\",\n \"Khudawadi\",\n \"Sind\",\n \"Lao\",\n \"Laoo\",\n \"Latin\",\n \"Latn\",\n \"Lepcha\",\n \"Lepc\",\n \"Limbu\",\n \"Limb\",\n \"Linear_A\",\n \"Lina\",\n \"Linear_B\",\n \"Linb\",\n \"Lisu\",\n \"Lycian\",\n \"Lyci\",\n \"Lydian\",\n \"Lydi\",\n \"Mahajani\",\n \"Mahj\",\n \"Malayalam\",\n \"Mlym\",\n \"Mandaic\",\n \"Mand\",\n \"Manichaean\",\n \"Mani\",\n \"Marchen\",\n \"Marc\",\n \"Masaram_Gondi\",\n \"Gonm\",\n \"Meetei_Mayek\",\n \"Mtei\",\n \"Mende_Kikakui\",\n \"Mend\",\n \"Meroitic_Cursive\",\n \"Merc\",\n \"Meroitic_Hieroglyphs\",\n \"Mero\",\n \"Miao\",\n \"Plrd\",\n \"Modi\",\n \"Mongolian\",\n \"Mong\",\n \"Mro\",\n \"Mroo\",\n \"Multani\",\n \"Mult\",\n \"Myanmar\",\n \"Mymr\",\n \"Nabataean\",\n \"Nbat\",\n \"New_Tai_Lue\",\n \"Talu\",\n \"Newa\",\n \"Nko\",\n \"Nkoo\",\n \"Nushu\",\n \"Nshu\",\n \"Ogham\",\n \"Ogam\",\n \"Ol_Chiki\",\n \"Olck\",\n \"Old_Hungarian\",\n \"Hung\",\n \"Old_Italic\",\n \"Ital\",\n \"Old_North_Arabian\",\n \"Narb\",\n \"Old_Permic\",\n \"Perm\",\n \"Old_Persian\",\n \"Xpeo\",\n \"Old_South_Arabian\",\n \"Sarb\",\n \"Old_Turkic\",\n \"Orkh\",\n \"Oriya\",\n \"Orya\",\n \"Osage\",\n \"Osge\",\n \"Osmanya\",\n \"Osma\",\n \"Pahawh_Hmong\",\n \"Hmng\",\n \"Palmyrene\",\n \"Palm\",\n \"Pau_Cin_Hau\",\n \"Pauc\",\n \"Phags_Pa\",\n \"Phag\",\n \"Phoenician\",\n \"Phnx\",\n \"Psalter_Pahlavi\",\n \"Phlp\",\n \"Rejang\",\n \"Rjng\",\n \"Runic\",\n \"Runr\",\n \"Samaritan\",\n \"Samr\",\n \"Saurashtra\",\n \"Saur\",\n \"Sharada\",\n \"Shrd\",\n \"Shavian\",\n \"Shaw\",\n \"Siddham\",\n \"Sidd\",\n \"SignWriting\",\n \"Sgnw\",\n \"Sinhala\",\n \"Sinh\",\n \"Sora_Sompeng\",\n \"Sora\",\n \"Soyombo\",\n \"Soyo\",\n \"Sundanese\",\n \"Sund\",\n \"Syloti_Nagri\",\n \"Sylo\",\n \"Syriac\",\n \"Syrc\",\n \"Tagalog\",\n \"Tglg\",\n \"Tagbanwa\",\n \"Tagb\",\n \"Tai_Le\",\n \"Tale\",\n \"Tai_Tham\",\n \"Lana\",\n \"Tai_Viet\",\n \"Tavt\",\n \"Takri\",\n \"Takr\",\n \"Tamil\",\n \"Taml\",\n \"Tangut\",\n \"Tang\",\n \"Telugu\",\n \"Telu\",\n \"Thaana\",\n \"Thaa\",\n \"Thai\",\n \"Tibetan\",\n \"Tibt\",\n \"Tifinagh\",\n \"Tfng\",\n \"Tirhuta\",\n \"Tirh\",\n \"Ugaritic\",\n \"Ugar\",\n \"Vai\",\n \"Vaii\",\n \"Warang_Citi\",\n \"Wara\",\n \"Yi\",\n \"Yiii\",\n \"Zanabazar_Square\",\n \"Zanb\"\n ]\n}\nArray.prototype.push.apply(data.$LONE, data.General_Category)\ndata.gc = data.General_Category\ndata.sc = data.Script_Extensions = data.scx = data.Script\n\nexport default data\n","import {isIdentifierStart, isIdentifierChar} from \"./identifier.js\"\nimport {Parser} from \"./state.js\"\nimport UNICODE_PROPERTY_VALUES from \"./unicode-property-data.js\"\n\nconst pp = Parser.prototype\n\nexport class RegExpValidationState {\n constructor(parser) {\n this.parser = parser\n this.validFlags = `gim${parser.options.ecmaVersion >= 6 ? \"uy\" : \"\"}${parser.options.ecmaVersion >= 9 ? \"s\" : \"\"}`\n this.source = \"\"\n this.flags = \"\"\n this.start = 0\n this.switchU = false\n this.switchN = false\n this.pos = 0\n this.lastIntValue = 0\n this.lastStringValue = \"\"\n this.lastAssertionIsQuantifiable = false\n this.numCapturingParens = 0\n this.maxBackReference = 0\n this.groupNames = []\n this.backReferenceNames = []\n }\n\n reset(start, pattern, flags) {\n const unicode = flags.indexOf(\"u\") !== -1\n this.start = start | 0\n this.source = pattern + \"\"\n this.flags = flags\n this.switchU = unicode && this.parser.options.ecmaVersion >= 6\n this.switchN = unicode && this.parser.options.ecmaVersion >= 9\n }\n\n raise(message) {\n this.parser.raiseRecoverable(this.start, `Invalid regular expression: /${this.source}/: ${message}`)\n }\n\n // If u flag is given, this returns the code point at the index (it combines a surrogate pair).\n // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).\n at(i) {\n const s = this.source\n const l = s.length\n if (i >= l) {\n return -1\n }\n const c = s.charCodeAt(i)\n if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {\n return c\n }\n return (c << 10) + s.charCodeAt(i + 1) - 0x35FDC00\n }\n\n nextIndex(i) {\n const s = this.source\n const l = s.length\n if (i >= l) {\n return l\n }\n const c = s.charCodeAt(i)\n if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {\n return i + 1\n }\n return i + 2\n }\n\n current() {\n return this.at(this.pos)\n }\n\n lookahead() {\n return this.at(this.nextIndex(this.pos))\n }\n\n advance() {\n this.pos = this.nextIndex(this.pos)\n }\n\n eat(ch) {\n if (this.current() === ch) {\n this.advance()\n return true\n }\n return false\n }\n}\n\nfunction codePointToString(ch) {\n if (ch <= 0xFFFF) return String.fromCharCode(ch)\n ch -= 0x10000\n return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)\n}\n\n/**\n * Validate the flags part of a given RegExpLiteral.\n *\n * @param {RegExpValidationState} state The state to validate RegExp.\n * @returns {void}\n */\npp.validateRegExpFlags = function(state) {\n const validFlags = state.validFlags\n const flags = state.flags\n\n for (let i = 0; i < flags.length; i++) {\n const flag = flags.charAt(i)\n if (validFlags.indexOf(flag) === -1) {\n this.raise(state.start, \"Invalid regular expression flag\")\n }\n if (flags.indexOf(flag, i + 1) > -1) {\n this.raise(state.start, \"Duplicate regular expression flag\")\n }\n }\n}\n\n/**\n * Validate the pattern part of a given RegExpLiteral.\n *\n * @param {RegExpValidationState} state The state to validate RegExp.\n * @returns {void}\n */\npp.validateRegExpPattern = function(state) {\n this.regexp_pattern(state)\n\n // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of\n // parsing contains a |GroupName|, reparse with the goal symbol\n // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*\n // exception if _P_ did not conform to the grammar, if any elements of _P_\n // were not matched by the parse, or if any Early Error conditions exist.\n if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {\n state.switchN = true\n this.regexp_pattern(state)\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern\npp.regexp_pattern = function(state) {\n state.pos = 0\n state.lastIntValue = 0\n state.lastStringValue = \"\"\n state.lastAssertionIsQuantifiable = false\n state.numCapturingParens = 0\n state.maxBackReference = 0\n state.groupNames.length = 0\n state.backReferenceNames.length = 0\n\n this.regexp_disjunction(state)\n\n if (state.pos !== state.source.length) {\n // Make the same messages as V8.\n if (state.eat(0x29 /* ) */)) {\n state.raise(\"Unmatched ')'\")\n }\n if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) {\n state.raise(\"Lone quantifier brackets\")\n }\n }\n if (state.maxBackReference > state.numCapturingParens) {\n state.raise(\"Invalid escape\")\n }\n for (const name of state.backReferenceNames) {\n if (state.groupNames.indexOf(name) === -1) {\n state.raise(\"Invalid named capture referenced\")\n }\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction\npp.regexp_disjunction = function(state) {\n this.regexp_alternative(state)\n while (state.eat(0x7C /* | */)) {\n this.regexp_alternative(state)\n }\n\n // Make the same message as V8.\n if (this.regexp_eatQuantifier(state, true)) {\n state.raise(\"Nothing to repeat\")\n }\n if (state.eat(0x7B /* { */)) {\n state.raise(\"Lone quantifier brackets\")\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative\npp.regexp_alternative = function(state) {\n while (state.pos < state.source.length && this.regexp_eatTerm(state))\n ;\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term\npp.regexp_eatTerm = function(state) {\n if (this.regexp_eatAssertion(state)) {\n // Handle `QuantifiableAssertion Quantifier` alternative.\n // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion\n // is a QuantifiableAssertion.\n if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {\n // Make the same message as V8.\n if (state.switchU) {\n state.raise(\"Invalid quantifier\")\n }\n }\n return true\n }\n\n if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {\n this.regexp_eatQuantifier(state)\n return true\n }\n\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion\npp.regexp_eatAssertion = function(state) {\n const start = state.pos\n state.lastAssertionIsQuantifiable = false\n\n // ^, $\n if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {\n return true\n }\n\n // \\b \\B\n if (state.eat(0x5C /* \\ */)) {\n if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {\n return true\n }\n state.pos = start\n }\n\n // Lookahead / Lookbehind\n if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {\n let lookbehind = false\n if (this.options.ecmaVersion >= 9) {\n lookbehind = state.eat(0x3C /* < */)\n }\n if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {\n this.regexp_disjunction(state)\n if (!state.eat(0x29 /* ) */)) {\n state.raise(\"Unterminated group\")\n }\n state.lastAssertionIsQuantifiable = !lookbehind\n return true\n }\n }\n\n state.pos = start\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier\npp.regexp_eatQuantifier = function(state, noError = false) {\n if (this.regexp_eatQuantifierPrefix(state, noError)) {\n state.eat(0x3F /* ? */)\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix\npp.regexp_eatQuantifierPrefix = function(state, noError) {\n return (\n state.eat(0x2A /* * */) ||\n state.eat(0x2B /* + */) ||\n state.eat(0x3F /* ? */) ||\n this.regexp_eatBracedQuantifier(state, noError)\n )\n}\npp.regexp_eatBracedQuantifier = function(state, noError) {\n const start = state.pos\n if (state.eat(0x7B /* { */)) {\n let min = 0, max = -1\n if (this.regexp_eatDecimalDigits(state)) {\n min = state.lastIntValue\n if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {\n max = state.lastIntValue\n }\n if (state.eat(0x7D /* } */)) {\n // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term\n if (max !== -1 && max < min && !noError) {\n state.raise(\"numbers out of order in {} quantifier\")\n }\n return true\n }\n }\n if (state.switchU && !noError) {\n state.raise(\"Incomplete quantifier\")\n }\n state.pos = start\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Atom\npp.regexp_eatAtom = function(state) {\n return (\n this.regexp_eatPatternCharacters(state) ||\n state.eat(0x2E /* . */) ||\n this.regexp_eatReverseSolidusAtomEscape(state) ||\n this.regexp_eatCharacterClass(state) ||\n this.regexp_eatUncapturingGroup(state) ||\n this.regexp_eatCapturingGroup(state)\n )\n}\npp.regexp_eatReverseSolidusAtomEscape = function(state) {\n const start = state.pos\n if (state.eat(0x5C /* \\ */)) {\n if (this.regexp_eatAtomEscape(state)) {\n return true\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatUncapturingGroup = function(state) {\n const start = state.pos\n if (state.eat(0x28 /* ( */)) {\n if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {\n this.regexp_disjunction(state)\n if (state.eat(0x29 /* ) */)) {\n return true\n }\n state.raise(\"Unterminated group\")\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatCapturingGroup = function(state) {\n if (state.eat(0x28 /* ( */)) {\n if (this.options.ecmaVersion >= 9) {\n this.regexp_groupSpecifier(state)\n } else if (state.current() === 0x3F /* ? */) {\n state.raise(\"Invalid group\")\n }\n this.regexp_disjunction(state)\n if (state.eat(0x29 /* ) */)) {\n state.numCapturingParens += 1\n return true\n }\n state.raise(\"Unterminated group\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom\npp.regexp_eatExtendedAtom = function(state) {\n return (\n state.eat(0x2E /* . */) ||\n this.regexp_eatReverseSolidusAtomEscape(state) ||\n this.regexp_eatCharacterClass(state) ||\n this.regexp_eatUncapturingGroup(state) ||\n this.regexp_eatCapturingGroup(state) ||\n this.regexp_eatInvalidBracedQuantifier(state) ||\n this.regexp_eatExtendedPatternCharacter(state)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier\npp.regexp_eatInvalidBracedQuantifier = function(state) {\n if (this.regexp_eatBracedQuantifier(state, true)) {\n state.raise(\"Nothing to repeat\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter\npp.regexp_eatSyntaxCharacter = function(state) {\n const ch = state.current()\n if (isSyntaxCharacter(ch)) {\n state.lastIntValue = ch\n state.advance()\n return true\n }\n return false\n}\nfunction isSyntaxCharacter(ch) {\n return (\n ch === 0x24 /* $ */ ||\n ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||\n ch === 0x2E /* . */ ||\n ch === 0x3F /* ? */ ||\n ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||\n ch >= 0x7B /* { */ && ch <= 0x7D /* } */\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter\n// But eat eager.\npp.regexp_eatPatternCharacters = function(state) {\n const start = state.pos\n let ch = 0\n while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {\n state.advance()\n }\n return state.pos !== start\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter\npp.regexp_eatExtendedPatternCharacter = function(state) {\n const ch = state.current()\n if (\n ch !== -1 &&\n ch !== 0x24 /* $ */ &&\n !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&\n ch !== 0x2E /* . */ &&\n ch !== 0x3F /* ? */ &&\n ch !== 0x5B /* [ */ &&\n ch !== 0x5E /* ^ */ &&\n ch !== 0x7C /* | */\n ) {\n state.advance()\n return true\n }\n return false\n}\n\n// GroupSpecifier[U] ::\n// [empty]\n// `?` GroupName[?U]\npp.regexp_groupSpecifier = function(state) {\n if (state.eat(0x3F /* ? */)) {\n if (this.regexp_eatGroupName(state)) {\n if (state.groupNames.indexOf(state.lastStringValue) !== -1) {\n state.raise(\"Duplicate capture group name\")\n }\n state.groupNames.push(state.lastStringValue)\n return\n }\n state.raise(\"Invalid group\")\n }\n}\n\n// GroupName[U] ::\n// `<` RegExpIdentifierName[?U] `>`\n// Note: this updates `state.lastStringValue` property with the eaten name.\npp.regexp_eatGroupName = function(state) {\n state.lastStringValue = \"\"\n if (state.eat(0x3C /* < */)) {\n if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {\n return true\n }\n state.raise(\"Invalid capture group name\")\n }\n return false\n}\n\n// RegExpIdentifierName[U] ::\n// RegExpIdentifierStart[?U]\n// RegExpIdentifierName[?U] RegExpIdentifierPart[?U]\n// Note: this updates `state.lastStringValue` property with the eaten name.\npp.regexp_eatRegExpIdentifierName = function(state) {\n state.lastStringValue = \"\"\n if (this.regexp_eatRegExpIdentifierStart(state)) {\n state.lastStringValue += codePointToString(state.lastIntValue)\n while (this.regexp_eatRegExpIdentifierPart(state)) {\n state.lastStringValue += codePointToString(state.lastIntValue)\n }\n return true\n }\n return false\n}\n\n// RegExpIdentifierStart[U] ::\n// UnicodeIDStart\n// `$`\n// `_`\n// `\\` RegExpUnicodeEscapeSequence[?U]\npp.regexp_eatRegExpIdentifierStart = function(state) {\n const start = state.pos\n let ch = state.current()\n state.advance()\n\n if (ch === 0x5C /* \\ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {\n ch = state.lastIntValue\n }\n if (isRegExpIdentifierStart(ch)) {\n state.lastIntValue = ch\n return true\n }\n\n state.pos = start\n return false\n}\nfunction isRegExpIdentifierStart(ch) {\n return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */\n}\n\n// RegExpIdentifierPart[U] ::\n// UnicodeIDContinue\n// `$`\n// `_`\n// `\\` RegExpUnicodeEscapeSequence[?U]\n// \n// \npp.regexp_eatRegExpIdentifierPart = function(state) {\n const start = state.pos\n let ch = state.current()\n state.advance()\n\n if (ch === 0x5C /* \\ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {\n ch = state.lastIntValue\n }\n if (isRegExpIdentifierPart(ch)) {\n state.lastIntValue = ch\n return true\n }\n\n state.pos = start\n return false\n}\nfunction isRegExpIdentifierPart(ch) {\n return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape\npp.regexp_eatAtomEscape = function(state) {\n if (\n this.regexp_eatBackReference(state) ||\n this.regexp_eatCharacterClassEscape(state) ||\n this.regexp_eatCharacterEscape(state) ||\n (state.switchN && this.regexp_eatKGroupName(state))\n ) {\n return true\n }\n if (state.switchU) {\n // Make the same message as V8.\n if (state.current() === 0x63 /* c */) {\n state.raise(\"Invalid unicode escape\")\n }\n state.raise(\"Invalid escape\")\n }\n return false\n}\npp.regexp_eatBackReference = function(state) {\n const start = state.pos\n if (this.regexp_eatDecimalEscape(state)) {\n const n = state.lastIntValue\n if (state.switchU) {\n // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape\n if (n > state.maxBackReference) {\n state.maxBackReference = n\n }\n return true\n }\n if (n <= state.numCapturingParens) {\n return true\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatKGroupName = function(state) {\n if (state.eat(0x6B /* k */)) {\n if (this.regexp_eatGroupName(state)) {\n state.backReferenceNames.push(state.lastStringValue)\n return true\n }\n state.raise(\"Invalid named reference\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape\npp.regexp_eatCharacterEscape = function(state) {\n return (\n this.regexp_eatControlEscape(state) ||\n this.regexp_eatCControlLetter(state) ||\n this.regexp_eatZero(state) ||\n this.regexp_eatHexEscapeSequence(state) ||\n this.regexp_eatRegExpUnicodeEscapeSequence(state) ||\n (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||\n this.regexp_eatIdentityEscape(state)\n )\n}\npp.regexp_eatCControlLetter = function(state) {\n const start = state.pos\n if (state.eat(0x63 /* c */)) {\n if (this.regexp_eatControlLetter(state)) {\n return true\n }\n state.pos = start\n }\n return false\n}\npp.regexp_eatZero = function(state) {\n if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {\n state.lastIntValue = 0\n state.advance()\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape\npp.regexp_eatControlEscape = function(state) {\n const ch = state.current()\n if (ch === 0x74 /* t */) {\n state.lastIntValue = 0x09 /* \\t */\n state.advance()\n return true\n }\n if (ch === 0x6E /* n */) {\n state.lastIntValue = 0x0A /* \\n */\n state.advance()\n return true\n }\n if (ch === 0x76 /* v */) {\n state.lastIntValue = 0x0B /* \\v */\n state.advance()\n return true\n }\n if (ch === 0x66 /* f */) {\n state.lastIntValue = 0x0C /* \\f */\n state.advance()\n return true\n }\n if (ch === 0x72 /* r */) {\n state.lastIntValue = 0x0D /* \\r */\n state.advance()\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter\npp.regexp_eatControlLetter = function(state) {\n const ch = state.current()\n if (isControlLetter(ch)) {\n state.lastIntValue = ch % 0x20\n state.advance()\n return true\n }\n return false\n}\nfunction isControlLetter(ch) {\n return (\n (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||\n (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence\npp.regexp_eatRegExpUnicodeEscapeSequence = function(state) {\n const start = state.pos\n\n if (state.eat(0x75 /* u */)) {\n if (this.regexp_eatFixedHexDigits(state, 4)) {\n const lead = state.lastIntValue\n if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) {\n const leadSurrogateEnd = state.pos\n if (state.eat(0x5C /* \\ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {\n const trail = state.lastIntValue\n if (trail >= 0xDC00 && trail <= 0xDFFF) {\n state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000\n return true\n }\n }\n state.pos = leadSurrogateEnd\n state.lastIntValue = lead\n }\n return true\n }\n if (\n state.switchU &&\n state.eat(0x7B /* { */) &&\n this.regexp_eatHexDigits(state) &&\n state.eat(0x7D /* } */) &&\n isValidUnicode(state.lastIntValue)\n ) {\n return true\n }\n if (state.switchU) {\n state.raise(\"Invalid unicode escape\")\n }\n state.pos = start\n }\n\n return false\n}\nfunction isValidUnicode(ch) {\n return ch >= 0 && ch <= 0x10FFFF\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape\npp.regexp_eatIdentityEscape = function(state) {\n if (state.switchU) {\n if (this.regexp_eatSyntaxCharacter(state)) {\n return true\n }\n if (state.eat(0x2F /* / */)) {\n state.lastIntValue = 0x2F /* / */\n return true\n }\n return false\n }\n\n const ch = state.current()\n if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {\n state.lastIntValue = ch\n state.advance()\n return true\n }\n\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape\npp.regexp_eatDecimalEscape = function(state) {\n state.lastIntValue = 0\n let ch = state.current()\n if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {\n do {\n state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */)\n state.advance()\n } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape\npp.regexp_eatCharacterClassEscape = function(state) {\n const ch = state.current()\n\n if (isCharacterClassEscape(ch)) {\n state.lastIntValue = -1\n state.advance()\n return true\n }\n\n if (\n state.switchU &&\n this.options.ecmaVersion >= 9 &&\n (ch === 0x50 /* P */ || ch === 0x70 /* p */)\n ) {\n state.lastIntValue = -1\n state.advance()\n if (\n state.eat(0x7B /* { */) &&\n this.regexp_eatUnicodePropertyValueExpression(state) &&\n state.eat(0x7D /* } */)\n ) {\n return true\n }\n state.raise(\"Invalid property name\")\n }\n\n return false\n}\nfunction isCharacterClassEscape(ch) {\n return (\n ch === 0x64 /* d */ ||\n ch === 0x44 /* D */ ||\n ch === 0x73 /* s */ ||\n ch === 0x53 /* S */ ||\n ch === 0x77 /* w */ ||\n ch === 0x57 /* W */\n )\n}\n\n// UnicodePropertyValueExpression ::\n// UnicodePropertyName `=` UnicodePropertyValue\n// LoneUnicodePropertyNameOrValue\npp.regexp_eatUnicodePropertyValueExpression = function(state) {\n const start = state.pos\n\n // UnicodePropertyName `=` UnicodePropertyValue\n if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {\n const name = state.lastStringValue\n if (this.regexp_eatUnicodePropertyValue(state)) {\n const value = state.lastStringValue\n this.regexp_validateUnicodePropertyNameAndValue(state, name, value)\n return true\n }\n }\n state.pos = start\n\n // LoneUnicodePropertyNameOrValue\n if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {\n const nameOrValue = state.lastStringValue\n this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)\n return true\n }\n return false\n}\npp.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {\n if (!UNICODE_PROPERTY_VALUES.hasOwnProperty(name) || UNICODE_PROPERTY_VALUES[name].indexOf(value) === -1) {\n state.raise(\"Invalid property name\")\n }\n}\npp.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {\n if (UNICODE_PROPERTY_VALUES.$LONE.indexOf(nameOrValue) === -1) {\n state.raise(\"Invalid property name\")\n }\n}\n\n// UnicodePropertyName ::\n// UnicodePropertyNameCharacters\npp.regexp_eatUnicodePropertyName = function(state) {\n let ch = 0\n state.lastStringValue = \"\"\n while (isUnicodePropertyNameCharacter(ch = state.current())) {\n state.lastStringValue += codePointToString(ch)\n state.advance()\n }\n return state.lastStringValue !== \"\"\n}\nfunction isUnicodePropertyNameCharacter(ch) {\n return isControlLetter(ch) || ch === 0x5F /* _ */\n}\n\n// UnicodePropertyValue ::\n// UnicodePropertyValueCharacters\npp.regexp_eatUnicodePropertyValue = function(state) {\n let ch = 0\n state.lastStringValue = \"\"\n while (isUnicodePropertyValueCharacter(ch = state.current())) {\n state.lastStringValue += codePointToString(ch)\n state.advance()\n }\n return state.lastStringValue !== \"\"\n}\nfunction isUnicodePropertyValueCharacter(ch) {\n return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)\n}\n\n// LoneUnicodePropertyNameOrValue ::\n// UnicodePropertyValueCharacters\npp.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {\n return this.regexp_eatUnicodePropertyValue(state)\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass\npp.regexp_eatCharacterClass = function(state) {\n if (state.eat(0x5B /* [ */)) {\n state.eat(0x5E /* ^ */)\n this.regexp_classRanges(state)\n if (state.eat(0x5D /* [ */)) {\n return true\n }\n // Unreachable since it threw \"unterminated regular expression\" error before.\n state.raise(\"Unterminated character class\")\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges\n// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges\n// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash\npp.regexp_classRanges = function(state) {\n while (this.regexp_eatClassAtom(state)) {\n const left = state.lastIntValue\n if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {\n const right = state.lastIntValue\n if (state.switchU && (left === -1 || right === -1)) {\n state.raise(\"Invalid character class\")\n }\n if (left !== -1 && right !== -1 && left > right) {\n state.raise(\"Range out of order in character class\")\n }\n }\n }\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash\npp.regexp_eatClassAtom = function(state) {\n const start = state.pos\n\n if (state.eat(0x5C /* \\ */)) {\n if (this.regexp_eatClassEscape(state)) {\n return true\n }\n if (state.switchU) {\n // Make the same message as V8.\n const ch = state.current()\n if (ch === 0x63 /* c */ || isOctalDigit(ch)) {\n state.raise(\"Invalid class escape\")\n }\n state.raise(\"Invalid escape\")\n }\n state.pos = start\n }\n\n const ch = state.current()\n if (ch !== 0x5D /* [ */) {\n state.lastIntValue = ch\n state.advance()\n return true\n }\n\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape\npp.regexp_eatClassEscape = function(state) {\n const start = state.pos\n\n if (state.eat(0x62 /* b */)) {\n state.lastIntValue = 0x08 /* */\n return true\n }\n\n if (state.switchU && state.eat(0x2D /* - */)) {\n state.lastIntValue = 0x2D /* - */\n return true\n }\n\n if (!state.switchU && state.eat(0x63 /* c */)) {\n if (this.regexp_eatClassControlLetter(state)) {\n return true\n }\n state.pos = start\n }\n\n return (\n this.regexp_eatCharacterClassEscape(state) ||\n this.regexp_eatCharacterEscape(state)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter\npp.regexp_eatClassControlLetter = function(state) {\n const ch = state.current()\n if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {\n state.lastIntValue = ch % 0x20\n state.advance()\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence\npp.regexp_eatHexEscapeSequence = function(state) {\n const start = state.pos\n if (state.eat(0x78 /* x */)) {\n if (this.regexp_eatFixedHexDigits(state, 2)) {\n return true\n }\n if (state.switchU) {\n state.raise(\"Invalid escape\")\n }\n state.pos = start\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits\npp.regexp_eatDecimalDigits = function(state) {\n const start = state.pos\n let ch = 0\n state.lastIntValue = 0\n while (isDecimalDigit(ch = state.current())) {\n state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */)\n state.advance()\n }\n return state.pos !== start\n}\nfunction isDecimalDigit(ch) {\n return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits\npp.regexp_eatHexDigits = function(state) {\n const start = state.pos\n let ch = 0\n state.lastIntValue = 0\n while (isHexDigit(ch = state.current())) {\n state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch)\n state.advance()\n }\n return state.pos !== start\n}\nfunction isHexDigit(ch) {\n return (\n (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||\n (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||\n (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)\n )\n}\nfunction hexToInt(ch) {\n if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {\n return 10 + (ch - 0x41 /* A */)\n }\n if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {\n return 10 + (ch - 0x61 /* a */)\n }\n return ch - 0x30 /* 0 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence\n// Allows only 0-377(octal) i.e. 0-255(decimal).\npp.regexp_eatLegacyOctalEscapeSequence = function(state) {\n if (this.regexp_eatOctalDigit(state)) {\n const n1 = state.lastIntValue\n if (this.regexp_eatOctalDigit(state)) {\n const n2 = state.lastIntValue\n if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {\n state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue\n } else {\n state.lastIntValue = n1 * 8 + n2\n }\n } else {\n state.lastIntValue = n1\n }\n return true\n }\n return false\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit\npp.regexp_eatOctalDigit = function(state) {\n const ch = state.current()\n if (isOctalDigit(ch)) {\n state.lastIntValue = ch - 0x30 /* 0 */\n state.advance()\n return true\n }\n state.lastIntValue = 0\n return false\n}\nfunction isOctalDigit(ch) {\n return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit\n// And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence\npp.regexp_eatFixedHexDigits = function(state, length) {\n const start = state.pos\n state.lastIntValue = 0\n for (let i = 0; i < length; ++i) {\n const ch = state.current()\n if (!isHexDigit(ch)) {\n state.pos = start\n return false\n }\n state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch)\n state.advance()\n }\n return true\n}\n","import {isIdentifierStart, isIdentifierChar} from \"./identifier\"\nimport {types as tt, keywords as keywordTypes} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {SourceLocation} from \"./locutil\"\nimport {RegExpValidationState} from \"./regexp\"\nimport {lineBreak, lineBreakG, isNewLine, nonASCIIwhitespace} from \"./whitespace\"\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nexport class Token {\n constructor(p) {\n this.type = p.type\n this.value = p.value\n this.start = p.start\n this.end = p.end\n if (p.options.locations)\n this.loc = new SourceLocation(p, p.startLoc, p.endLoc)\n if (p.options.ranges)\n this.range = [p.start, p.end]\n }\n}\n\n// ## Tokenizer\n\nconst pp = Parser.prototype\n\n// Move to the next token\n\npp.next = function() {\n if (this.options.onToken)\n this.options.onToken(new Token(this))\n\n this.lastTokEnd = this.end\n this.lastTokStart = this.start\n this.lastTokEndLoc = this.endLoc\n this.lastTokStartLoc = this.startLoc\n this.nextToken()\n}\n\npp.getToken = function() {\n this.next()\n return new Token(this)\n}\n\n// If we're in an ES6 environment, make parsers iterable\nif (typeof Symbol !== \"undefined\")\n pp[Symbol.iterator] = function() {\n return {\n next: () => {\n let token = this.getToken()\n return {\n done: token.type === tt.eof,\n value: token\n }\n }\n }\n }\n\n// Toggle strict mode. Re-reads the next number or string to please\n// pedantic tests (`\"use strict\"; 010;` should fail).\n\npp.curContext = function() {\n return this.context[this.context.length - 1]\n}\n\n// Read a single token, updating the parser object's token-related\n// properties.\n\npp.nextToken = function() {\n let curContext = this.curContext()\n if (!curContext || !curContext.preserveSpace) this.skipSpace()\n\n this.start = this.pos\n if (this.options.locations) this.startLoc = this.curPosition()\n if (this.pos >= this.input.length) return this.finishToken(tt.eof)\n\n if (curContext.override) return curContext.override(this)\n else this.readToken(this.fullCharCodeAtPos())\n}\n\npp.readToken = function(code) {\n // Identifier or keyword. '\\uXXXX' sequences are allowed in\n // identifiers, so '\\' also dispatches to that.\n if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\\' */)\n return this.readWord()\n\n return this.getTokenFromCode(code)\n}\n\npp.fullCharCodeAtPos = function() {\n let code = this.input.charCodeAt(this.pos)\n if (code <= 0xd7ff || code >= 0xe000) return code\n let next = this.input.charCodeAt(this.pos + 1)\n return (code << 10) + next - 0x35fdc00\n}\n\npp.skipBlockComment = function() {\n let startLoc = this.options.onComment && this.curPosition()\n let start = this.pos, end = this.input.indexOf(\"*/\", this.pos += 2)\n if (end === -1) this.raise(this.pos - 2, \"Unterminated comment\")\n this.pos = end + 2\n if (this.options.locations) {\n lineBreakG.lastIndex = start\n let match\n while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {\n ++this.curLine\n this.lineStart = match.index + match[0].length\n }\n }\n if (this.options.onComment)\n this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,\n startLoc, this.curPosition())\n}\n\npp.skipLineComment = function(startSkip) {\n let start = this.pos\n let startLoc = this.options.onComment && this.curPosition()\n let ch = this.input.charCodeAt(this.pos += startSkip)\n while (this.pos < this.input.length && !isNewLine(ch)) {\n ch = this.input.charCodeAt(++this.pos)\n }\n if (this.options.onComment)\n this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,\n startLoc, this.curPosition())\n}\n\n// Called at the start of the parse and after every token. Skips\n// whitespace and comments, and.\n\npp.skipSpace = function() {\n loop: while (this.pos < this.input.length) {\n let ch = this.input.charCodeAt(this.pos)\n switch (ch) {\n case 32: case 160: // ' '\n ++this.pos\n break\n case 13:\n if (this.input.charCodeAt(this.pos + 1) === 10) {\n ++this.pos\n }\n case 10: case 8232: case 8233:\n ++this.pos\n if (this.options.locations) {\n ++this.curLine\n this.lineStart = this.pos\n }\n break\n case 47: // '/'\n switch (this.input.charCodeAt(this.pos + 1)) {\n case 42: // '*'\n this.skipBlockComment()\n break\n case 47:\n this.skipLineComment(2)\n break\n default:\n break loop\n }\n break\n default:\n if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {\n ++this.pos\n } else {\n break loop\n }\n }\n }\n}\n\n// Called at the end of every token. Sets `end`, `val`, and\n// maintains `context` and `exprAllowed`, and skips the space after\n// the token, so that the next one's `start` will point at the\n// right position.\n\npp.finishToken = function(type, val) {\n this.end = this.pos\n if (this.options.locations) this.endLoc = this.curPosition()\n let prevType = this.type\n this.type = type\n this.value = val\n\n this.updateContext(prevType)\n}\n\n// ### Token reading\n\n// This is the function that is called to fetch the next token. It\n// is somewhat obscure, because it works in character codes rather\n// than characters, and because operator parsing has been inlined\n// into it.\n//\n// All in the name of speed.\n//\npp.readToken_dot = function() {\n let next = this.input.charCodeAt(this.pos + 1)\n if (next >= 48 && next <= 57) return this.readNumber(true)\n let next2 = this.input.charCodeAt(this.pos + 2)\n if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'\n this.pos += 3\n return this.finishToken(tt.ellipsis)\n } else {\n ++this.pos\n return this.finishToken(tt.dot)\n }\n}\n\npp.readToken_slash = function() { // '/'\n let next = this.input.charCodeAt(this.pos + 1)\n if (this.exprAllowed) { ++this.pos; return this.readRegexp() }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.slash, 1)\n}\n\npp.readToken_mult_modulo_exp = function(code) { // '%*'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n let tokentype = code === 42 ? tt.star : tt.modulo\n\n // exponentiation operator ** and **=\n if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {\n ++size\n tokentype = tt.starstar\n next = this.input.charCodeAt(this.pos + 2)\n }\n\n if (next === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tokentype, size)\n}\n\npp.readToken_pipe_amp = function(code) { // '|&'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)\n}\n\npp.readToken_caret = function() { // '^'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.bitwiseXOR, 1)\n}\n\npp.readToken_plus_min = function(code) { // '+-'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === code) {\n if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&\n (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {\n // A `-->` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // ` \ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 11, 2017._ \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/write/index.js b/tools/node_modules/eslint/node_modules/write/index.js index f952638d0d4520..b2b4b4380a359c 100644 --- a/tools/node_modules/eslint/node_modules/write/index.js +++ b/tools/node_modules/eslint/node_modules/write/index.js @@ -1,93 +1,160 @@ /*! * write * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. */ 'use strict'; var fs = require('fs'); var path = require('path'); -var mkdir = require('mkdirp'); +var mkdirp = require('mkdirp'); /** - * Asynchronously write a file to disk. Creates any intermediate - * directories if they don't already exist. + * Asynchronously writes data to a file, replacing the file if it already + * exists and creating any intermediate directories if they don't already + * exist. Data can be a string or a buffer. Returns a promise if a callback + * function is not passed. * * ```js * var writeFile = require('write'); - * writeFile('foo.txt', 'This is content to write.', function(err) { + * writeFile('foo.txt', 'This is content...', function(err) { * if (err) console.log(err); * }); + * + * // promise + * writeFile('foo.txt', 'This is content...') + * .then(function() { + * // do stuff + * }); * ``` + * @name writeFile + * @param {string|Buffer|integer} `filepath` filepath or file descriptor. + * @param {string|Buffer|Uint8Array} `data` String to write to disk. + * @param {object} `options` Options to pass to [fs.writeFile][fs]{#fs_fs_writefile_file_data_options_callback} and/or [mkdirp][] + * @param {Function} `callback` (optional) If no callback is provided, a promise is returned. + * @api public + */ + +function writeFile(filepath, data, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } + + if (typeof cb !== 'function') { + return writeFile.promise.apply(null, arguments); + } + + if (typeof filepath !== 'string') { + cb(new TypeError('expected filepath to be a string')); + return; + } + + mkdirp(path.dirname(filepath), options, function(err) { + if (err) { + cb(err); + return; + } + fs.writeFile(filepath, data, options, cb); + }); +}; + +/** + * The promise version of [writeFile](#writefile). Returns a promise. * - * @name writeFile - * @param {String} `dest` Destination file path - * @param {String} `str` String to write to disk. - * @param {Function} `callback` + * ```js + * var writeFile = require('write'); + * writeFile.promise('foo.txt', 'This is content...') + * .then(function() { + * // do stuff + * }); + * ``` + * @name .promise + * @param {string|Buffer|integer} `filepath` filepath or file descriptor. + * @param {string|Buffer|Uint8Array} `val` String or buffer to write to disk. + * @param {object} `options` Options to pass to [fs.writeFile][fs]{#fs_fs_writefile_file_data_options_callback} and/or [mkdirp][] + * @return {Promise} * @api public */ -module.exports = function writeFile(dest, str, cb) { - var dir = path.dirname(dest); - fs.exists(dir, function (exists) { - if (exists) { - fs.writeFile(dest, str, cb); - } else { - mkdir(dir, function (err) { +writeFile.promise = function(filepath, val, options) { + if (typeof filepath !== 'string') { + return Promise.reject(new TypeError('expected filepath to be a string')); + } + + return new Promise(function(resolve, reject) { + mkdirp(path.dirname(filepath), options, function(err) { + if (err) { + reject(err); + return; + } + + fs.writeFile(filepath, val, options, function(err) { if (err) { - return cb(err); - } else { - fs.writeFile(dest, str, cb); + reject(err); + return; } + resolve(val); }); - } + }); }); }; /** - * Synchronously write files to disk. Creates any intermediate - * directories if they don't already exist. + * The synchronous version of [writeFile](#writefile). Returns undefined. * * ```js * var writeFile = require('write'); - * writeFile.sync('foo.txt', 'This is content to write.'); + * writeFile.sync('foo.txt', 'This is content...'); * ``` - * - * @name writeFile.sync - * @param {String} `dest` Destination file path - * @param {String} `str` String to write to disk. + * @name .sync + * @param {string|Buffer|integer} `filepath` filepath or file descriptor. + * @param {string|Buffer|Uint8Array} `data` String or buffer to write to disk. + * @param {object} `options` Options to pass to [fs.writeFileSync][fs]{#fs_fs_writefilesync_file_data_options} and/or [mkdirp][] + * @return {undefined} * @api public */ -module.exports.sync = function writeFileSync(dest, str) { - var dir = path.dirname(dest); - if (!fs.existsSync(dir)) { - mkdir.sync(dir); +writeFile.sync = function(filepath, data, options) { + if (typeof filepath !== 'string') { + throw new TypeError('expected filepath to be a string'); } - fs.writeFileSync(dest, str); + mkdirp.sync(path.dirname(filepath), options); + fs.writeFileSync(filepath, data, options); }; /** - * Uses `fs.createWriteStream`, but also creates any intermediate - * directories if they don't already exist. + * Uses `fs.createWriteStream` to write data to a file, replacing the + * file if it already exists and creating any intermediate directories + * if they don't already exist. Data can be a string or a buffer. Returns + * a new [WriteStream](https://nodejs.org/api/fs.html#fs_class_fs_writestream) + * object. * * ```js - * var write = require('write'); - * write.stream('foo.txt'); + * var fs = require('fs'); + * var writeFile = require('write'); + * fs.createReadStream('README.md') + * .pipe(writeFile.stream('a/b/c/other-file.md')) + * .on('close', function() { + * // do stuff + * }); * ``` - * - * @name writeFile.stream - * @param {String} `dest` Destination file path - * @return {Stream} Returns a write stream. + * @name .stream + * @param {string|Buffer|integer} `filepath` filepath or file descriptor. + * @param {object} `options` Options to pass to [mkdirp][] and [fs.createWriteStream][fs]{#fs_fs_createwritestream_path_options} + * @return {Stream} Returns a new [WriteStream](https://nodejs.org/api/fs.html#fs_class_fs_writestream) object. (See [Writable Stream](https://nodejs.org/api/stream.html#stream_class_stream_writable)). * @api public */ -module.exports.stream = function writeFileStream(dest) { - var dir = path.dirname(dest); - if (!fs.existsSync(dir)) { - mkdir.sync(dir); - } - return fs.createWriteStream(dest); +writeFile.stream = function(filepath, options) { + mkdirp.sync(path.dirname(filepath), options); + return fs.createWriteStream(filepath, options); }; + +/** + * Expose `writeFile` + */ + +module.exports = writeFile; diff --git a/tools/node_modules/eslint/node_modules/write/package.json b/tools/node_modules/eslint/node_modules/write/package.json index dd3dc91a5b3796..4805b30afd5c42 100644 --- a/tools/node_modules/eslint/node_modules/write/package.json +++ b/tools/node_modules/eslint/node_modules/write/package.json @@ -7,19 +7,29 @@ "url": "https://github.com/jonschlinkert/write/issues" }, "bundleDependencies": false, + "contributors": [ + { + "name": "Charlike Mike Reagent", + "url": "https://i.am.charlike.online" + }, + { + "name": "Jon Schlinkert", + "url": "http://twitter.com/jonschlinkert" + } + ], "dependencies": { "mkdirp": "^0.5.1" }, "deprecated": false, - "description": "Write files to disk, creating intermediate directories if they don't exist.", + "description": "Write data to a file, replacing the file if it already exists and creating any intermediate directories if they don't already exist. Thin wrapper around node's native fs methods.", "devDependencies": { - "async": "^1.4.0", - "delete": "^0.2.1", - "mocha": "^2.2.5", - "should": "^7.0.2" + "async-each": "^1.0.1", + "delete": "^1.1.0", + "gulp-format-md": "^1.0.0", + "mocha": "^3.4.2" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" }, "files": [ "index.js" @@ -47,5 +57,32 @@ "scripts": { "test": "mocha" }, - "version": "0.2.1" + "verb": { + "run": true, + "toc": false, + "layout": "default", + "tasks": [ + "readme" + ], + "plugins": [ + "gulp-format-md" + ], + "related": { + "list": [ + "delete", + "read-data", + "read-yaml", + "write-data", + "write-json", + "write-yaml" + ] + }, + "reflinks": [ + "verb" + ], + "lint": { + "reflinks": true + } + }, + "version": "1.0.3" } \ No newline at end of file diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 4ef338ee35b850..316fa200c454e7 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -12,30 +12,30 @@ "bundleDependencies": false, "dependencies": { "@babel/code-frame": "^7.0.0", - "ajv": "^6.5.3", + "ajv": "^6.9.1", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", "debug": "^4.0.1", - "doctrine": "^2.1.0", + "doctrine": "^3.0.0", "eslint-plugin-markdown": "^1.0.0-rc.1", "eslint-scope": "^4.0.0", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.0", + "espree": "^5.0.1", "esquery": "^1.0.1", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", + "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", "glob": "^7.1.2", "globals": "^11.7.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.1.0", + "inquirer": "^6.2.2", "js-yaml": "^3.12.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", @@ -46,21 +46,22 @@ "semver": "^5.5.1", "strip-ansi": "^4.0.0", "strip-json-comments": "^2.0.1", - "table": "^5.0.2", + "table": "^5.2.3", "text-table": "^0.2.0" }, "deprecated": false, "description": "An AST-based pattern checker for JavaScript.", "devDependencies": { - "babel-core": "^6.26.3", - "babel-polyfill": "^6.26.0", - "babel-preset-es2015": "^6.24.1", - "babelify": "^8.0.0", + "@babel/core": "^7.2.2", + "@babel/polyfill": "^7.2.5", + "@babel/preset-env": "^7.3.1", + "babelify": "^10.0.0", "beefy": "^2.1.8", "brfs": "^2.0.0", "browserify": "^16.2.2", "chai": "^4.0.1", "cheerio": "^0.22.0", + "common-tags": "^1.8.0", "coveralls": "^3.0.1", "dateformat": "^3.0.3", "ejs": "^2.6.1", @@ -69,26 +70,26 @@ "eslint-plugin-rulesdir": "^0.1.0", "eslint-release": "^1.2.0", "eslint-rule-composer": "^0.3.0", - "eslump": "^1.6.2", + "eslump": "^2.0.0", "esprima": "^4.0.1", "istanbul": "^0.4.5", "jsdoc": "^3.5.5", - "karma": "^3.0.0", - "karma-babel-preprocessor": "^7.0.0", + "karma": "^3.1.4", + "karma-babel-preprocessor": "^8.0.0", "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", "karma-mocha-reporter": "^2.2.3", "leche": "^2.2.3", "load-perf": "^0.2.0", - "markdownlint": "^0.11.0", + "markdownlint": "^0.12.0", "mocha": "^5.0.5", - "mock-fs": "^4.6.0", + "mock-fs": "^4.8.0", "npm-license": "^0.3.3", "proxyquire": "^2.0.1", - "puppeteer": "^1.9.0", + "puppeteer": "^1.12.2", "shelljs": "^0.8.2", "sinon": "^3.3.0", - "temp": "^0.8.3", + "temp": "^0.9.0", "through": "^2.3.8" }, "engines": { @@ -133,5 +134,5 @@ "publish-release": "node Makefile.js publishRelease", "test": "node Makefile.js test" }, - "version": "5.13.0" + "version": "5.14.0" } \ No newline at end of file