diff --git a/.travis.yml b/.travis.yml index 80c729a772fed5..3de388e838436f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,16 @@ language: cpp -sudo: false cache: ccache os: linux matrix: include: + - name: "First commit message adheres to guidelines at https://goo.gl/p2fr5Q" + if: type = pull_request + language: node_js + node_js: "node" + script: + - if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then + bash -x tools/lint-pr-commit-message.sh ${TRAVIS_PULL_REQUEST}; + fi - name: "Linter" language: node_js node_js: "node" @@ -11,10 +18,6 @@ matrix: - NODE=$(which node) script: - make lint - # Lint the first commit in the PR. - - if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then - bash tools/lint-pr-commit-message.sh ${TRAVIS_PULL_REQUEST} || true; - fi - name: "Test Suite" addons: apt: diff --git a/BUILDING.md b/BUILDING.md index efe39e656b383a..36d87c0f141b79 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -69,8 +69,7 @@ There are three support tiers: ### Supported platforms The community does not build or test against end-of-life distributions (EoL). -Thus, we do not recommend that you use Node.js on end-of-life or unsupported -platforms in production. +For production applications, run Node.js on supported platforms only. | System | Support type | Version | Architectures | Notes | |--------------|--------------|----------------------------------|----------------------|------------------| @@ -134,21 +133,20 @@ OpenSSL-1.1.0 requires the following assembler version for use of asm support on x86_64 and ia32. * gas (GNU assembler) version 2.23 or higher -* xcode version 5.0 or higher +* Xcode version 5.0 or higher * llvm version 3.3 or higher * nasm version 2.10 or higher in Windows -Otherwise `configure` will fail with an error. This can be avoided by -either providing a newer assembler as per the list above or by -using the `--openssl-no-asm` flag. +If compiling without one of the above, use `configure` with the +`--openssl-no-asm` flag. Otherwise, `configure` will fail. The forthcoming OpenSSL-1.1.1 will have different requirements. Please refer to https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_ia32cap.html for details. ## Building Node.js on supported platforms -*Note:* All prerequisites can be easily installed by following -[this bootstrapping guide](https://github.com/nodejs/node/blob/master/tools/bootstrap/README.md). +The [bootstrapping guide](https://github.com/nodejs/node/blob/master/tools/bootstrap/README.md) +explains how to install all prerequisites. ### Unix/macOS @@ -159,7 +157,7 @@ The forthcoming OpenSSL-1.1.1 will have different requirements. Please refer to * Python 2.6 or 2.7 * GNU Make 3.81 or newer -On macOS, you will need to install the `Xcode Command Line Tools` by running +On macOS, install the `Xcode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode installed, you can find them under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`. This step will install `clang`, `clang++`, and @@ -180,13 +178,9 @@ $ ./configure $ make -j4 ``` -Running `make` with the `-j4` flag will cause it to run 4 compilation jobs -concurrently which may significantly reduce build time. The number after `-j` -can be changed to best suit the number of processor cores on your machine. If -you run into problems running `make` with concurrency, try running it without -the `-j4` flag. See the -[GNU Make Documentation](https://www.gnu.org/software/make/manual/html_node/Parallel.html) -for more information. +The `-j4` option will cause `make` to run 4 simultaneous compilation jobs which +may reduce build time. For more information, see the +[GNU Make Documentation](https://www.gnu.org/software/make/manual/html_node/Parallel.html). Note that the above requires that `python` resolve to Python 2.6 or 2.7 and not a newer version. diff --git a/CHANGELOG.md b/CHANGELOG.md index 5482c756de5422..5a6db4ac97f80b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ release. -10.15.0
+10.15.1
+10.15.0
10.14.2
10.14.1
10.14.0
diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 7fa6fee197aabc..0be47023ea7263 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -3,7 +3,6 @@ ## Contents * [Issues and Pull Requests](#issues-and-pull-requests) - - [Managing Issues and Pull Requests](#managing-issues-and-pull-requests) - [Welcoming First-Time Contributors](#welcoming-first-time-contributors) - [Closing Issues and Pull Requests](#closing-issues-and-pull-requests) - [Author ready pull requests](#author-ready-pull-requests) @@ -45,46 +44,40 @@ Collaborators should understand the ## Issues and Pull Requests -### Managing Issues and Pull Requests - -Collaborators should take full responsibility for managing issues and pull -requests they feel qualified to handle. Make sure this is done while being -mindful of these guidelines, the opinions of other Collaborators, and guidance -of the [TSC][]. They may also notify other qualified parties for more input on -an issue or a pull request. -See [Who to CC in the issue tracker](#who-to-cc-in-the-issue-tracker). +Mind these guidelines, the opinions of other Collaborators, and guidance of the +[TSC][]. Notify other qualified parties for more input on an issue or a pull +request. See [Who to CC in the issue tracker](#who-to-cc-in-the-issue-tracker). ### Welcoming First-Time Contributors -Courtesy should always be shown to individuals submitting issues and pull -requests to the Node.js project. Be welcoming to first-time contributors, -identified by the GitHub ![First-time contributor](./doc/first_timer_badge.png) -badge. +Always show courtesy to individuals submitting issues and pull requests. Be +welcoming to first-time contributors, identified by the GitHub +![First-time contributor](./doc/first_timer_badge.png) badge. -For first-time contributors, check if the commit author is the same as the -pull request author, and ask if they have configured their git +For first-time contributors, check if the commit author is the same as the pull +request author. This way, once their pull request lands, GitHub will show them +as a _Contributor_. Ask if they have configured their git [username][git-username] and [email][git-email] to their liking. -This is to make sure they would be promoted to "contributor" once their -pull request lands. ### Closing Issues and Pull Requests -Collaborators may close any issue or pull request they believe is -not relevant for the future of the Node.js project. Where this is -unclear, the issue should be left open for several days to allow for -additional discussion. Where this does not yield input from Node.js -Collaborators or additional evidence that the issue has relevance, the -issue may be closed. Remember that issues can always be re-opened if -necessary. +Collaborators may close any issue or pull request that is not relevant to the +future of the Node.js project. Where this is unclear, leave the issue or pull +request open for several days to allow for discussion. Where this does not yield +evidence that the issue or pull request has relevance, close it. Remember that +issues and pull requests can always be re-opened if necessary. ### Author ready pull requests -A pull request that is still awaiting the minimum review time is considered -_author ready_ as soon as the CI has been started, it has at least two approvals -(one Collaborator approval is enough if the pull request has been open for more -than 7 days), and it has no outstanding review comments. Please always make sure -to add the `author ready` label to the PR in that case and remove it again as -soon as that condition is not met anymore. +A pull request is _author ready_ when: + +* There is a CI run in progress or completed. +* There are at least two Collaborator approvals, or at least one approval if the + pull request is older than 7 days. +* There are no outstanding review comments. + +Please always add the `author ready` label to the PR in that case. Please always +remove it again as soon as the conditions are not met anymore. ### Handling own pull requests @@ -800,8 +793,8 @@ TSC for further discussion. #### How are LTS Branches Managed? -There are multiple LTS branches, e.g. `v8.x` and `v6.x`. Each of these is paired -with a staging branch: `v8.x-staging` and `v6.x-staging`. +There are multiple LTS branches, e.g. `v10.x` and `v8.x`. Each of these is +paired with a staging branch: `v10.x-staging` and `v8.x-staging`. As commits land on the master branch, they are cherry-picked back to each staging branch as appropriate. If the commit applies only to the LTS branch, the @@ -810,9 +803,8 @@ pulled from the staging branch into the LTS branch only when a release is being prepared and may be pulled into the LTS branch in a different order than they were landed in staging. -Any Collaborator may land commits into a staging branch, but only the release -team should land commits into the LTS branch while preparing a new -LTS release. +Only the members of the @nodejs/backporters team should land commits onto +LTS staging branches. #### How can I help? @@ -823,14 +815,18 @@ on backporting, please see the [backporting guide][]. Several LTS related issue and PR labels have been provided: -* `lts-watch-v6.x` - tells the LTS WG that the issue/PR needs to be considered - for landing in the `v6.x-staging` branch. -* `lts-watch-v4.x` - tells the LTS WG that the issue/PR needs to be considered - for landing in the `v4.x-staging` branch. +* `lts-watch-v10.x` - tells the LTS WG that the issue/PR needs to be + considered for landing in the `v10.x-staging` branch. +* `lts-watch-v8.x` - tells the LTS WG that the issue/PR needs to be + considered for landing in the `v8.x-staging` branch. +* `lts-watch-v6.x` - tells the LTS WG that the issue/PR needs to be + considered for landing in the `v6.x-staging` branch. +* `land-on-v10.x` - tells the release team that the commit should be landed + in a future v10.x release. +* `land-on-v8.x` - tells the release team that the commit should be landed + in a future v8.x release. * `land-on-v6.x` - tells the release team that the commit should be landed - in a future v6.x release -* `land-on-v4.x` - tells the release team that the commit should be landed - in a future v4.x release + in a future v6.x release. Any Collaborator can attach these labels to any PR/issue. As commits are landed into the staging branches, the `lts-watch-` label will be removed. diff --git a/Makefile b/Makefile index ae3830ddd40e00..3a343301d640bc 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,7 @@ v8: tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS) .PHONY: jstest -jstest: build-addons build-addons-napi bench-addons-build ## Runs addon tests and JS tests +jstest: build-addons build-addons-napi ## Runs addon tests and JS tests $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \ --skip-tests=$(CI_SKIP_TESTS) \ $(CI_JS_SUITES) \ @@ -308,7 +308,7 @@ test-valgrind: all test-check-deopts: all $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential -benchmark/napi/function_call/build/Release/binding.node: \ +benchmark/napi/function_call/build/$(BUILDTYPE)/binding.node: \ benchmark/napi/function_call/napi_binding.c \ benchmark/napi/function_call/binding.cc \ benchmark/napi/function_call/binding.gyp | all @@ -317,7 +317,7 @@ benchmark/napi/function_call/build/Release/binding.node: \ --directory="$(shell pwd)/benchmark/napi/function_call" \ --nodedir="$(shell pwd)" -benchmark/napi/function_args/build/Release/binding.node: \ +benchmark/napi/function_args/build/$(BUILDTYPE)/binding.node: \ benchmark/napi/function_args/napi_binding.c \ benchmark/napi/function_args/binding.cc \ benchmark/napi/function_args/binding.gyp | all @@ -332,16 +332,16 @@ ifeq ($(OSTYPE),aix) DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp endif -node_use_openssl = $(shell $(call available-node,"-p" \ - "process.versions.openssl != undefined")) +node_use_openssl = $(call available-node,"-p" \ + "process.versions.openssl != undefined") test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules -ifeq ($(node_use_openssl),true) - $(RM) -r test/addons/??_*/ - [ -x $(NODE) ] && $(NODE) $< || node $< - touch $@ -else - @echo "Skipping .docbuildstamp (no crypto)" -endif + @if [ "$(shell $(node_use_openssl))" != "true" ]; then \ + echo "Skipping .docbuildstamp (no crypto)"; \ + else \ + $(RM) -r test/addons/??_*/; \ + [ -x $(NODE) ] && $(NODE) $< || node $< ; \ + touch $@; \ + fi ADDONS_BINDING_GYPS := \ $(filter-out test/addons/??_*/binding.gyp, \ @@ -414,7 +414,7 @@ clear-stalled: echo $${PS_OUT} | xargs kill -9; \ fi -test-build: | all build-addons build-addons-napi bench-addons-build +test-build: | all build-addons build-addons-napi test-build-addons-napi: all build-addons-napi @@ -455,7 +455,7 @@ test-ci-js: | clear-stalled .PHONY: test-ci # Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned test-ci: LOGLEVEL := info -test-ci: | clear-stalled build-addons build-addons-napi doc-only bench-addons-build +test-ci: | clear-stalled build-addons build-addons-napi doc-only out/Release/cctest --gtest_output=tap:cctest.tap $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ --mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \ @@ -496,7 +496,7 @@ test-debug: test-build test-message: test-build $(PYTHON) tools/test.py $(PARALLEL_ARGS) message -test-simple: | cctest bench-addons-build # Depends on 'all'. +test-simple: | cctest # Depends on 'all'. $(PYTHON) tools/test.py $(PARALLEL_ARGS) parallel sequential test-pummel: all @@ -509,6 +509,9 @@ test-node-inspect: $(NODE_EXE) USE_EMBEDDED_NODE_INSPECT=1 $(NODE) tools/test-npm-package \ --install deps/node-inspect test +test-benchmark: | bench-addons-build + $(PYTHON) tools/test.py $(PARALLEL_ARGS) benchmark + test-tick-processor: all $(PYTHON) tools/test.py $(PARALLEL_ARGS) tick-processor @@ -609,11 +612,11 @@ apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json)) apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*))) tools/doc/node_modules: tools/doc/package.json -ifeq ($(node_use_openssl),true) - cd tools/doc && $(call available-node,$(run-npm-ci)) -else - @echo "Skipping tools/doc/node_modules (no crypto)" -endif + @if [ "$(shell $(node_use_openssl))" != "true" ]; then \ + echo "Skipping tools/doc/node_modules (no crypto)"; \ + else \ + cd tools/doc && $(call available-node,$(run-npm-ci)) \ + fi .PHONY: doc-only doc-only: tools/doc/node_modules \ @@ -1043,8 +1046,8 @@ bench: bench-addons-build # Build required addons for benchmark before running it. .PHONY: bench-addons-build -bench-addons-build: benchmark/napi/function_call/build/Release/binding.node \ - benchmark/napi/function_args/build/Release/binding.node +bench-addons-build: benchmark/napi/function_call/build/$(BUILDTYPE)/binding.node \ + benchmark/napi/function_args/build/$(BUILDTYPE)/binding.node .PHONY: bench-addons-clean bench-addons-clean: @@ -1053,13 +1056,11 @@ bench-addons-clean: .PHONY: lint-md-rollup lint-md-rollup: - cd tools/node-lint-md-cli-rollup/remark-preset-lint-node && npm up - cd tools/node-lint-md-cli-rollup && npm up + cd tools/node-lint-md-cli-rollup && npm install cd tools/node-lint-md-cli-rollup && npm run build-node .PHONY: lint-md-clean lint-md-clean: - $(RM) -r tools/node-lint-md-cli-rollup/remark-preset-lint-node/node_modules $(RM) -r tools/node-lint-md-cli-rollup/node_modules $(RM) tools/.*mdlintstamp diff --git a/README.md b/README.md index 79b12e289a58f4..71da2e4b59ff80 100644 --- a/README.md +++ b/README.md @@ -203,10 +203,6 @@ For information about the governance of the Node.js project, see **Michaël Zasso** <targos@protonmail.com> (he/him) * [thefourtheye](https://github.com/thefourtheye) - **Sakthipriyan Vairamani** <thechargingvolcano@gmail.com> (he/him) -* [TimothyGu](https://github.com/TimothyGu) - -**Tiancheng "Timothy" Gu** <timothygu99@gmail.com> (he/him) -* [Trott](https://github.com/Trott) - -**Rich Trott** <rtrott@gmail.com> (he/him) ### TSC Emeriti @@ -234,8 +230,12 @@ For information about the governance of the Node.js project, see **Bert Belder** <bertbelder@gmail.com> * [shigeki](https://github.com/shigeki) - **Shigeki Ohtsu** <ohtsu@ohtsu.org> (he/him) +* [TimothyGu](https://github.com/TimothyGu) - +**Tiancheng "Timothy" Gu** <timothygu99@gmail.com> (he/him) * [trevnorris](https://github.com/trevnorris) - **Trevor Norris** <trev.norris@gmail.com> +* [Trott](https://github.com/Trott) - +**Rich Trott** <rtrott@gmail.com> (he/him) ### Collaborators @@ -401,6 +401,8 @@ For information about the governance of the Node.js project, see **Alexis Campailla** <orangemocha@nodejs.org> * [othiym23](https://github.com/othiym23) - **Forrest L Norvell** <ogd@aoaioxxysz.net> (he/him) +* [oyyd](https://github.com/oyyd) - +**Ouyang Yadong** <oyydoibh@gmail.com> (he/him) * [pmq20](https://github.com/pmq20) - **Minqi Pan** <pmq2001@gmail.com> * [princejwesley](https://github.com/princejwesley) - @@ -528,6 +530,8 @@ maintaining the Node.js project. GPG keys used to sign Node.js releases: +* **Beth Griggs** <bethany.griggs@uk.ibm.com> +`4ED778F539E3634C779C87C6D7062848A1AB005C` * **Colin Ihrig** <cjihrig@gmail.com> `94AE36675C464D64BAFA68DD7434390BDBE9B9C5` * **Evan Lucas** <evanlucas@me.com> @@ -544,10 +548,13 @@ GPG keys used to sign Node.js releases: `C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8` * **Rod Vagg** <rod@vagg.org> `DD8F2338BAE7501E3DD5AC78C273792F7D83545D` +* **Ruben Bridgewater** <ruben@bridgewater.de> +`A48C2BEE680E841632CD4E44F07496B3EB3C1762` To import the full set of trusted release keys: ```shell +gpg --keyserver pool.sks-keyservers.net --recv-keys 4ED778F539E3634C779C87C6D7062848A1AB005C gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 gpg --keyserver pool.sks-keyservers.net --recv-keys B9AE9905FFD7803F25714661B63B535A4C206CA9 gpg --keyserver pool.sks-keyservers.net --recv-keys 77984A986EBC2AA786BC0F66B01FBB92821C587A @@ -556,6 +563,7 @@ gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE gpg --keyserver pool.sks-keyservers.net --recv-keys 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 gpg --keyserver pool.sks-keyservers.net --recv-keys C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C273792F7D83545D +gpg --keyserver pool.sks-keyservers.net --recv-keys A48C2BEE680E841632CD4E44F07496B3EB3C1762 ``` See the section above on [Verifying Binaries](#verifying-binaries) for how to diff --git a/benchmark/common.js b/benchmark/common.js index 148f51830f7b8d..bc4177d512d037 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -3,6 +3,8 @@ const child_process = require('child_process'); const http_benchmarkers = require('./_http-benchmarkers.js'); +exports.buildType = process.features.debug ? 'Debug' : 'Release'; + exports.createBenchmark = function(fn, configs, options) { return new Benchmark(fn, configs, options); }; diff --git a/benchmark/fixtures/require-cachable.js b/benchmark/fixtures/require-cachable.js new file mode 100644 index 00000000000000..f651728dc78f35 --- /dev/null +++ b/benchmark/fixtures/require-cachable.js @@ -0,0 +1,13 @@ +'use strict'; + +const list = require('internal/bootstrap/cache'); +const { + isMainThread +} = require('worker_threads'); + +for (const key of list.cachableBuiltins) { + if (!isMainThread && key === 'trace_events') { + continue; + } + require(key); +} diff --git a/benchmark/misc/startup.js b/benchmark/misc/startup.js index 703146f081b3c6..1350cd291e2b18 100644 --- a/benchmark/misc/startup.js +++ b/benchmark/misc/startup.js @@ -1,36 +1,76 @@ 'use strict'; const common = require('../common.js'); -const spawn = require('child_process').spawn; +const { spawn } = require('child_process'); const path = require('path'); -const emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js'); -const bench = common.createBenchmark(startNode, { - dur: [1] +let Worker; // Lazy loaded in main + +const bench = common.createBenchmark(main, { + dur: [1], + script: ['benchmark/fixtures/require-cachable', 'test/fixtures/semicolon'], + mode: ['process', 'worker'] +}, { + flags: ['--expose-internals', '--experimental-worker'] // for workers }); -function startNode({ dur }) { - var go = true; - var starts = 0; +function spawnProcess(script) { + const cmd = process.execPath || process.argv[0]; + const argv = ['--expose-internals', script]; + return spawn(cmd, argv); +} + +function spawnWorker(script) { + return new Worker(script, { stderr: true, stdout: true }); +} + +function start(state, script, bench, getNode) { + const node = getNode(script); + let stdout = ''; + let stderr = ''; + + node.stdout.on('data', (data) => { + stdout += data; + }); + + node.stderr.on('data', (data) => { + stderr += data; + }); + + node.on('exit', (code) => { + if (code !== 0) { + console.error('------ stdout ------'); + console.error(stdout); + console.error('------ stderr ------'); + console.error(stderr); + throw new Error(`Error during node startup, exit code ${code}`); + } + state.throughput++; + + if (state.go) { + start(state, script, bench, getNode); + } else { + bench.end(state.throughput); + } + }); +} + +function main({ dur, script, mode }) { + const state = { + go: true, + throughput: 0 + }; setTimeout(function() { - go = false; + state.go = false; }, dur * 1000); - bench.start(); - start(); - - function start() { - const node = spawn(process.execPath || process.argv[0], [emptyJsFile]); - node.on('exit', function(exitCode) { - if (exitCode !== 0) { - throw new Error('Error during node startup'); - } - starts++; - - if (go) - start(); - else - bench.end(starts); - }); + script = path.resolve(__dirname, '../../', `${script}.js`); + if (mode === 'worker') { + Worker = require('worker_threads').Worker; + bench.start(); + start(state, script, bench, spawnWorker); + } else { + bench.start(); + start(state, script, bench, spawnProcess); } } diff --git a/benchmark/napi/function_args/binding.cc b/benchmark/napi/function_args/binding.cc index d0c1a079210532..9f250aaa83db50 100644 --- a/benchmark/napi/function_args/binding.cc +++ b/benchmark/napi/function_args/binding.cc @@ -33,7 +33,8 @@ void CallWithArray(const FunctionCallbackInfo& args) { uint32_t length = array->Length(); for (uint32_t i = 0; i < length; ++ i) { Local v; - v = array->Get(i); + v = array->Get(args.GetIsolate()->GetCurrentContext(), + i).ToLocalChecked(); } } } diff --git a/benchmark/napi/function_args/index.js b/benchmark/napi/function_args/index.js index c41b5d78abadd9..df567dcfcc55bc 100644 --- a/benchmark/napi/function_args/index.js +++ b/benchmark/napi/function_args/index.js @@ -10,14 +10,14 @@ let v8; let napi; try { - v8 = require('./build/Release/binding'); + v8 = require(`./build/${common.buildType}/binding`); } catch { console.error(`${__filename}: V8 Binding failed to load`); process.exit(0); } try { - napi = require('./build/Release/napi_binding'); + napi = require(`./build/${common.buildType}/napi_binding`); } catch { console.error(`${__filename}: NAPI-Binding failed to load`); process.exit(0); diff --git a/benchmark/napi/function_call/index.js b/benchmark/napi/function_call/index.js index 272c41662d2830..59063e500f7a84 100644 --- a/benchmark/napi/function_call/index.js +++ b/benchmark/napi/function_call/index.js @@ -12,7 +12,7 @@ const common = require('../../common.js'); // abort quietly. try { - var binding = require('./build/Release/binding'); + var binding = require(`./build/${common.buildType}/binding`); } catch { console.error('misc/function_call.js Binding failed to load'); process.exit(0); @@ -21,7 +21,7 @@ const cxx = binding.hello; let napi_binding; try { - napi_binding = require('./build/Release/napi_binding'); + napi_binding = require(`./build/${common.buildType}/napi_binding`); } catch { console.error('misc/function_call/index.js NAPI-Binding failed to load'); process.exit(0); diff --git a/common.gypi b/common.gypi index e2295ee35de832..0a4ed881a5b925 100644 --- a/common.gypi +++ b/common.gypi @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.45', + 'v8_embedder_string': '-node.12', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/configure.py b/configure.py index a5075bd9d8a60b..b62be2302c846d 100755 --- a/configure.py +++ b/configure.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import json import sys import errno @@ -429,7 +431,7 @@ dest='with_icu_source', help='Intl mode: optional local path to icu/ dir, or path/URL of ' 'the icu4c source archive. ' - 'v%d.x or later recommended.' % icu_versions["minimum_icu"]) + 'v%d.x or later recommended.' % icu_versions['minimum_icu']) parser.add_option('--with-ltcg', action='store_true', @@ -608,7 +610,7 @@ def print_verbose(x): if not options.verbose: return if type(x) is str: - print x + print(x) else: pprint.pprint(x, indent=2) @@ -621,9 +623,13 @@ def b(value): def pkg_config(pkg): + """Run pkg-config on the specified package + Returns ("-l flags", "-I flags", "-L flags", "version") + otherwise (None, None, None, None)""" pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') retval = () - for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L']: + for flag in ['--libs-only-l', '--cflags-only-I', + '--libs-only-L', '--modversion']: try: proc = subprocess.Popen( shlex.split(pkg_config) + ['--silence-errors', flag, pkg], @@ -631,7 +637,7 @@ def pkg_config(pkg): val = proc.communicate()[0].strip() except OSError as e: if e.errno != errno.ENOENT: raise e # Unexpected error. - return (None, None, None) # No pkg-config/pkgconf installed. + return (None, None, None, None) # No pkg-config/pkgconf installed. retval += (val,) return retval @@ -1123,7 +1129,7 @@ def configure_library(lib, output): output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib)) if getattr(options, shared_lib): - (pkg_libs, pkg_cflags, pkg_libpath) = pkg_config(lib) + (pkg_libs, pkg_cflags, pkg_libpath, pkg_modversion) = pkg_config(lib) if options.__dict__[shared_lib + '_includes']: output['include_dirs'] += [options.__dict__[shared_lib + '_includes']] @@ -1356,7 +1362,12 @@ def write_config(data, name): if pkgicu[0] is None: error('''Could not load pkg-config data for "icu-i18n". See above errors or the README.md.''') - (libs, cflags, libpath) = pkgicu + (libs, cflags, libpath, icuversion) = pkgicu + icu_ver_major = icuversion.split('.')[0] + o['variables']['icu_ver_major'] = icu_ver_major + if int(icu_ver_major) < icu_versions['minimum_icu']: + error('icu4c v%s is too old, v%d.x or later is required.' % + (icuversion, icu_versions['minimum_icu'])) # libpath provides linker path which may contain spaces if libpath: o['libraries'] += [libpath] @@ -1474,9 +1485,9 @@ def write_config(data, name): icu_ver_major = m.group(1) if not icu_ver_major: error('Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h) - elif int(icu_ver_major) < icu_versions["minimum_icu"]: - error('icu4c v%d.x is too old, v%d.x or later is required.' % (int(icu_ver_major), - icu_versions["minimum_icu"])) + elif int(icu_ver_major) < icu_versions['minimum_icu']: + error('icu4c v%s.x is too old, v%d.x or later is required.' % + (icu_ver_major, icu_versions['minimum_icu'])) icu_endianness = sys.byteorder[0]; o['variables']['icu_ver_major'] = icu_ver_major o['variables']['icu_endianness'] = icu_endianness diff --git a/deps/v8/src/compiler/js-operator.cc b/deps/v8/src/compiler/js-operator.cc index 04feec6827aad0..8dedd68d946032 100644 --- a/deps/v8/src/compiler/js-operator.cc +++ b/deps/v8/src/compiler/js-operator.cc @@ -598,7 +598,7 @@ CompareOperationHint CompareOperationHintOf(const Operator* op) { V(CreateKeyValueArray, Operator::kEliminatable, 2, 1) \ V(CreatePromise, Operator::kEliminatable, 0, 1) \ V(CreateTypedArray, Operator::kNoProperties, 5, 1) \ - V(CreateObject, Operator::kNoWrite, 1, 1) \ + V(CreateObject, Operator::kNoProperties, 1, 1) \ V(ObjectIsArray, Operator::kNoProperties, 1, 1) \ V(HasProperty, Operator::kNoProperties, 2, 1) \ V(HasInPrototypeChain, Operator::kNoProperties, 2, 1) \ diff --git a/deps/v8/src/profiler/heap-profiler.cc b/deps/v8/src/profiler/heap-profiler.cc index 02b80c21d6e7e7..a4f53d69d5e40a 100644 --- a/deps/v8/src/profiler/heap-profiler.cc +++ b/deps/v8/src/profiler/heap-profiler.cc @@ -23,9 +23,14 @@ HeapProfiler::~HeapProfiler() = default; void HeapProfiler::DeleteAllSnapshots() { snapshots_.clear(); - names_.reset(new StringsStorage()); + MaybeClearStringsStorage(); } +void HeapProfiler::MaybeClearStringsStorage() { + if (snapshots_.empty() && !sampling_heap_profiler_ && !allocation_tracker_) { + names_.reset(new StringsStorage()); + } +} void HeapProfiler::RemoveSnapshot(HeapSnapshot* snapshot) { snapshots_.erase( @@ -126,6 +131,7 @@ bool HeapProfiler::StartSamplingHeapProfiler( void HeapProfiler::StopSamplingHeapProfiler() { sampling_heap_profiler_.reset(); + MaybeClearStringsStorage(); } @@ -159,6 +165,7 @@ void HeapProfiler::StopHeapObjectsTracking() { ids_->StopHeapObjectsTracking(); if (allocation_tracker_) { allocation_tracker_.reset(); + MaybeClearStringsStorage(); heap()->RemoveHeapObjectAllocationTracker(this); } } diff --git a/deps/v8/src/profiler/heap-profiler.h b/deps/v8/src/profiler/heap-profiler.h index fc0b005e1c67ce..bdc98521231a7d 100644 --- a/deps/v8/src/profiler/heap-profiler.h +++ b/deps/v8/src/profiler/heap-profiler.h @@ -92,6 +92,8 @@ class HeapProfiler : public HeapObjectAllocationTracker { v8::PersistentValueVector* objects); private: + void MaybeClearStringsStorage(); + Heap* heap() const; // Mapping from HeapObject addresses to objects' uids. diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index 70dc07d3dc872e..e8d974be3ef9a2 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -3690,3 +3690,45 @@ TEST(WeakReference) { const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); CHECK(ValidateSnapshot(snapshot)); } + +TEST(Bug8373_1) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); + + heap_profiler->StartSamplingHeapProfiler(100); + + heap_profiler->TakeHeapSnapshot(); + // Causes the StringsStorage to be deleted. + heap_profiler->DeleteAllHeapSnapshots(); + + // Triggers an allocation sample that tries to use the StringsStorage. + for (int i = 0; i < 2 * 1024; ++i) { + CompileRun( + "new Array(64);" + "new Uint8Array(16);"); + } + + heap_profiler->StopSamplingHeapProfiler(); +} + +TEST(Bug8373_2) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); + + heap_profiler->StartTrackingHeapObjects(true); + + heap_profiler->TakeHeapSnapshot(); + // Causes the StringsStorage to be deleted. + heap_profiler->DeleteAllHeapSnapshots(); + + // Triggers an allocations that try to use the StringsStorage. + for (int i = 0; i < 2 * 1024; ++i) { + CompileRun( + "new Array(64);" + "new Uint8Array(16);"); + } + + heap_profiler->StopTrackingHeapObjects(); +} diff --git a/deps/v8/test/mjsunit/compiler/regress-888923.js b/deps/v8/test/mjsunit/compiler/regress-888923.js new file mode 100644 index 00000000000000..e352673b7d933d --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-888923.js @@ -0,0 +1,31 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + function f(o) { + o.x; + Object.create(o); + return o.y.a; + } + + f({ x : 0, y : { a : 1 } }); + f({ x : 0, y : { a : 2 } }); + %OptimizeFunctionOnNextCall(f); + assertEquals(3, f({ x : 0, y : { a : 3 } })); +})(); + +(function() { + function f(o) { + let a = o.y; + Object.create(o); + return o.x + a; + } + + f({ x : 42, y : 21 }); + f({ x : 42, y : 21 }); + %OptimizeFunctionOnNextCall(f); + assertEquals(63, f({ x : 42, y : 21 })); +})(); diff --git a/doc/api/addons.md b/doc/api/addons.md index 757f24c5194271..d993c72d346495 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -63,13 +63,15 @@ namespace demo { using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::String; using v8::Value; void Method(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); - args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world")); + args.GetReturnValue().Set(String::NewFromUtf8( + isolate, "world", NewStringType::kNormal).ToLocalChecked()); } void Initialize(Local exports) { @@ -464,6 +466,7 @@ using v8::Exception; using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Number; using v8::Object; using v8::String; @@ -479,14 +482,18 @@ void Add(const FunctionCallbackInfo& args) { if (args.Length() < 2) { // Throw an Error that is passed back to JavaScript isolate->ThrowException(Exception::TypeError( - String::NewFromUtf8(isolate, "Wrong number of arguments"))); + String::NewFromUtf8(isolate, + "Wrong number of arguments", + NewStringType::kNormal).ToLocalChecked())); return; } // Check the argument types if (!args[0]->IsNumber() || !args[1]->IsNumber()) { isolate->ThrowException(Exception::TypeError( - String::NewFromUtf8(isolate, "Wrong arguments"))); + String::NewFromUtf8(isolate, + "Wrong arguments", + NewStringType::kNormal).ToLocalChecked())); return; } @@ -530,10 +537,12 @@ to invoke such callbacks: namespace demo { +using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Null; using v8::Object; using v8::String; @@ -541,10 +550,14 @@ using v8::Value; void RunCallback(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); Local cb = Local::Cast(args[0]); const unsigned argc = 1; - Local argv[argc] = { String::NewFromUtf8(isolate, "hello world") }; - cb->Call(Null(isolate), argc, argv); + Local argv[argc] = { + String::NewFromUtf8(isolate, + "hello world", + NewStringType::kNormal).ToLocalChecked() }; + cb->Call(context, Null(isolate), argc, argv).ToLocalChecked(); } void Init(Local exports, Local module) { @@ -591,6 +604,7 @@ using v8::Context; using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::String; using v8::Value; @@ -600,8 +614,12 @@ void CreateObject(const FunctionCallbackInfo& args) { Local context = isolate->GetCurrentContext(); Local obj = Object::New(isolate); - obj->Set(String::NewFromUtf8(isolate, "msg"), - args[0]->ToString(context).ToLocalChecked()); + obj->Set(context, + String::NewFromUtf8(isolate, + "msg", + NewStringType::kNormal).ToLocalChecked(), + args[0]->ToString(context).ToLocalChecked()) + .FromJust(); args.GetReturnValue().Set(obj); } @@ -644,13 +662,15 @@ using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::String; using v8::Value; void MyFunction(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); - args.GetReturnValue().Set(String::NewFromUtf8(isolate, "hello world")); + args.GetReturnValue().Set(String::NewFromUtf8( + isolate, "hello world", NewStringType::kNormal).ToLocalChecked()); } void CreateFunction(const FunctionCallbackInfo& args) { @@ -661,7 +681,8 @@ void CreateFunction(const FunctionCallbackInfo& args) { Local fn = tpl->GetFunction(context).ToLocalChecked(); // omit this to make it anonymous - fn->SetName(String::NewFromUtf8(isolate, "theFunction")); + fn->SetName(String::NewFromUtf8( + isolate, "theFunction", NewStringType::kNormal).ToLocalChecked()); args.GetReturnValue().Set(fn); } @@ -757,6 +778,7 @@ using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Number; using v8::Object; using v8::Persistent; @@ -776,7 +798,8 @@ void MyObject::Init(Local exports) { // Prepare constructor template Local tpl = FunctionTemplate::New(isolate, New); - tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject")); + tpl->SetClassName(String::NewFromUtf8( + isolate, "MyObject", NewStringType::kNormal).ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); // Prototype @@ -784,8 +807,9 @@ void MyObject::Init(Local exports) { Local context = isolate->GetCurrentContext(); constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); - exports->Set(String::NewFromUtf8(isolate, "MyObject"), - tpl->GetFunction(context).ToLocalChecked()); + exports->Set(context, String::NewFromUtf8( + isolate, "MyObject", NewStringType::kNormal).ToLocalChecked(), + tpl->GetFunction(context).ToLocalChecked()).FromJust(); } void MyObject::New(const FunctionCallbackInfo& args) { @@ -952,6 +976,7 @@ using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Number; using v8::Object; using v8::Persistent; @@ -969,7 +994,8 @@ MyObject::~MyObject() { void MyObject::Init(Isolate* isolate) { // Prepare constructor template Local tpl = FunctionTemplate::New(isolate, New); - tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject")); + tpl->SetClassName(String::NewFromUtf8( + isolate, "MyObject", NewStringType::kNormal).ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); // Prototype @@ -1167,6 +1193,7 @@ using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Isolate; using v8::Local; +using v8::NewStringType; using v8::Object; using v8::Persistent; using v8::String; @@ -1183,7 +1210,8 @@ MyObject::~MyObject() { void MyObject::Init(Isolate* isolate) { // Prepare constructor template Local tpl = FunctionTemplate::New(isolate, New); - tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject")); + tpl->SetClassName(String::NewFromUtf8( + isolate, "MyObject", NewStringType::kNormal).ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); Local context = isolate->GetCurrentContext(); diff --git a/doc/api/assert.md b/doc/api/assert.md index 50519b831c9a2c..ab664d94d88a65 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -1233,8 +1233,8 @@ assert.throws(throwingFirst, /Second$/); Due to the confusing notation, it is recommended not to use a string as the second argument. This might lead to difficult-to-spot errors. -[`ERR_INVALID_RETURN_VALUE`]: errors.html#errors_err_invalid_return_value [`Class`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes +[`ERR_INVALID_RETURN_VALUE`]: errors.html#errors_err_invalid_return_value [`Error.captureStackTrace`]: errors.html#errors_error_capturestacktrace_targetobject_constructoropt [`Error`]: errors.html#errors_class_error [`Map`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map @@ -1255,10 +1255,10 @@ second argument. This might lead to difficult-to-spot errors. [`assert.throws()`]: #assert_assert_throws_fn_error_message [`strict mode`]: #assert_strict_mode [Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison +[Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript [Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring [SameValue Comparison]: https://tc39.github.io/ecma262/#sec-samevalue [Strict Equality Comparison]: https://tc39.github.io/ecma262/#sec-strict-equality-comparison [enumerable "own" properties]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties [mdn-equality-guide]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness [prototype-spec]: https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots -[Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index f0752a5892c362..6a6cc781a79f1f 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -238,8 +238,8 @@ resource's constructor. ```text FSEVENTWRAP, FSREQWRAP, GETADDRINFOREQWRAP, GETNAMEINFOREQWRAP, HTTPPARSER, JSSTREAM, PIPECONNECTWRAP, PIPEWRAP, PROCESSWRAP, QUERYWRAP, SHUTDOWNWRAP, -SIGNALWRAP, STATWATCHER, TCPCONNECTWRAP, TCPSERVER, TCPWRAP, TIMERWRAP, TTYWRAP, -UDPSENDWRAP, UDPWRAP, WRITEWRAP, ZLIB, SSLCONNECTION, PBKDF2REQUEST, +SIGNALWRAP, STATWATCHER, TCPCONNECTWRAP, TCPSERVERWRAP, TCPWRAP, TIMERWRAP, +TTYWRAP, UDPSENDWRAP, UDPWRAP, WRITEWRAP, ZLIB, SSLCONNECTION, PBKDF2REQUEST, RANDOMBYTESREQUEST, TLSWRAP, Timeout, Immediate, TickObject ``` @@ -276,8 +276,8 @@ require('net').createServer((conn) => {}).listen(8080); Output when hitting the server with `nc localhost 8080`: ```console -TCPSERVERWRAP(2): trigger: 1 execution: 1 -TCPWRAP(4): trigger: 2 execution: 0 +TCPSERVERWRAP(5): trigger: 1 execution: 1 +TCPWRAP(7): trigger: 5 execution: 0 ``` The `TCPSERVERWRAP` is the server which receives the connections. @@ -296,7 +296,7 @@ of propagating what resource is responsible for the new resource's existence. been initialized. This can contain useful information that can vary based on the value of `type`. For instance, for the `GETADDRINFOREQWRAP` resource type, `resource` provides the hostname used when looking up the IP address for the -hostname in `net.Server.listen()`. The API for accessing this information is +host in `net.Server.listen()`. The API for accessing this information is currently not considered public, but using the Embedder API, users can provide and document their own resource objects. For example, such a resource object could contain the SQL query being executed. @@ -355,27 +355,18 @@ require('net').createServer(() => {}).listen(8080, () => { Output from only starting the server: ```console -TCPSERVERWRAP(2): trigger: 1 execution: 1 -TickObject(3): trigger: 2 execution: 1 -before: 3 - Timeout(4): trigger: 3 execution: 3 - TIMERWRAP(5): trigger: 3 execution: 3 -after: 3 -destroy: 3 -before: 5 - before: 4 - TTYWRAP(6): trigger: 4 execution: 4 - SIGNALWRAP(7): trigger: 4 execution: 4 - TTYWRAP(8): trigger: 4 execution: 4 ->>> 4 - TickObject(9): trigger: 4 execution: 4 - after: 4 -after: 5 -before: 9 -after: 9 -destroy: 4 -destroy: 9 -destroy: 5 +TCPSERVERWRAP(5): trigger: 1 execution: 1 +TickObject(6): trigger: 5 execution: 1 +before: 6 + Timeout(7): trigger: 6 execution: 6 +after: 6 +destroy: 6 +before: 7 +>>> 7 + TickObject(8): trigger: 7 execution: 7 +after: 7 +before: 8 +after: 8 ``` As illustrated in the example, `executionAsyncId()` and `execution` each specify @@ -385,7 +376,7 @@ the value of the current execution context; which is delineated by calls to Only using `execution` to graph resource allocation results in the following: ```console -TTYWRAP(6) -> Timeout(4) -> TIMERWRAP(5) -> TickObject(3) -> root(1) +Timeout(7) -> TickObject(6) -> root(1) ``` The `TCPSERVERWRAP` is not part of this graph, even though it was the reason for @@ -720,6 +711,7 @@ never be called. * Returns: {number} The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. +[`Worker`]: worker_threads.html#worker_threads_class_worker [`after` callback]: #async_hooks_after_asyncid [`asyncResource.runInAsyncScope()`]: #async_hooks_asyncresource_runinasyncscope_fn_thisarg_args [`before` callback]: #async_hooks_before_asyncid @@ -728,4 +720,3 @@ never be called. [Hook Callbacks]: #async_hooks_hook_callbacks [PromiseHooks]: https://docs.google.com/document/d/1rda3yKGHimKIhg5YeoAmCOtyURgsbTH_qaYR79FELlk/edit [promise execution tracking]: #async_hooks_promise_execution_tracking -[`Worker`]: worker_threads.html#worker_threads_class_worker diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 897512ae000805..97fc170c02c9c6 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -2669,9 +2669,9 @@ This value may depend on the JS engine that is being used. [`buf.length`]: #buffer_buf_length [`buf.slice()`]: #buffer_buf_slice_start_end [`buf.values()`]: #buffer_buf_values -[`buffer.kMaxLength`]: #buffer_buffer_kmaxlength [`buffer.constants.MAX_LENGTH`]: #buffer_buffer_constants_max_length [`buffer.constants.MAX_STRING_LENGTH`]: #buffer_buffer_constants_max_string_length +[`buffer.kMaxLength`]: #buffer_buffer_kmaxlength [`util.inspect()`]: util.html#util_util_inspect_object_options [RFC1345]: https://tools.ietf.org/html/rfc1345 [RFC4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5 diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 23715b2dd1080f..04f8fa8a3d9bb6 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1432,13 +1432,6 @@ unavailable. [`ChildProcess`]: #child_process_child_process [`Error`]: errors.html#errors_class_error [`EventEmitter`]: events.html#events_class_eventemitter -[`subprocess.connected`]: #child_process_subprocess_connected -[`subprocess.disconnect()`]: #child_process_subprocess_disconnect -[`subprocess.kill()`]: #child_process_subprocess_kill_signal -[`subprocess.send()`]: #child_process_subprocess_send_message_sendhandle_options_callback -[`subprocess.stderr`]: #child_process_subprocess_stderr -[`subprocess.stdin`]: #child_process_subprocess_stdin -[`subprocess.stdout`]: #child_process_subprocess_stdout [`child_process.exec()`]: #child_process_child_process_exec_command_options_callback [`child_process.execFile()`]: #child_process_child_process_execfile_file_args_options_callback [`child_process.execFileSync()`]: #child_process_child_process_execfilesync_file_args_options @@ -1455,6 +1448,13 @@ unavailable. [`process.execPath`]: process.html#process_process_execpath [`process.send()`]: process.html#process_process_send_message_sendhandle_options_callback [`stdio`]: #child_process_options_stdio +[`subprocess.connected`]: #child_process_subprocess_connected +[`subprocess.disconnect()`]: #child_process_subprocess_disconnect +[`subprocess.kill()`]: #child_process_subprocess_kill_signal +[`subprocess.send()`]: #child_process_subprocess_send_message_sendhandle_options_callback +[`subprocess.stderr`]: #child_process_subprocess_stderr +[`subprocess.stdin`]: #child_process_subprocess_stdin +[`subprocess.stdout`]: #child_process_subprocess_stdout [`util.promisify()`]: util.html#util_util_promisify_original [Default Windows Shell]: #child_process_default_windows_shell [Shell Requirements]: #child_process_shell_requirements diff --git a/doc/api/cli.md b/doc/api/cli.md index a994eaa6066765..7563515b9f9b21 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -530,6 +530,10 @@ added: v0.1.32 `','`-separated list of core modules that should print debug information. +### `NODE_DEBUG_NATIVE=module[,…]` + +`','`-separated list of core C++ modules that should print debug information. + ### `NODE_DISABLE_COLORS=1` * `spkac` {string | Buffer | TypedArray | DataView} -* `encoding` {string} +* `encoding` {string} The [encoding][] of the `spkac` string. * Returns: {Buffer} The public key component of the `spkac` data structure, which includes a public key and a challenge. @@ -185,7 +185,18 @@ Example: Using `Cipher` objects as streams: ```js const crypto = require('crypto'); -const cipher = crypto.createCipher('aes192', 'a password'); + +const algorithm = 'aes-192-cbc'; +const password = 'Password used to generate key'; +// Key length is dependent on the algorithm. In this case for aes192, it is +// 24 bytes (192 bits). +// Use async `crypto.scrypt()` instead. +const key = crypto.scryptSync(password, 'salt', 24); +// Use `crypto.randomBytes()` to generate a random iv instead of the static iv +// shown here. +const iv = Buffer.alloc(16, 0); // Initialization vector. + +const cipher = crypto.createCipheriv(algorithm, key, iv); let encrypted = ''; cipher.on('readable', () => { @@ -195,7 +206,7 @@ cipher.on('readable', () => { }); cipher.on('end', () => { console.log(encrypted); - // Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504 + // Prints: e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa }); cipher.write('some clear text data'); @@ -207,7 +218,16 @@ Example: Using `Cipher` and piped streams: ```js const crypto = require('crypto'); const fs = require('fs'); -const cipher = crypto.createCipher('aes192', 'a password'); + +const algorithm = 'aes-192-cbc'; +const password = 'Password used to generate key'; +// Use the async `crypto.scrypt()` instead. +const key = crypto.scryptSync(password, 'salt', 24); +// Use `crypto.randomBytes()` to generate a random iv instead of the static iv +// shown here. +const iv = Buffer.alloc(16, 0); // Initialization vector. + +const cipher = crypto.createCipheriv(algorithm, key, iv); const input = fs.createReadStream('test.js'); const output = fs.createWriteStream('test.enc'); @@ -219,21 +239,30 @@ Example: Using the [`cipher.update()`][] and [`cipher.final()`][] methods: ```js const crypto = require('crypto'); -const cipher = crypto.createCipher('aes192', 'a password'); + +const algorithm = 'aes-192-cbc'; +const password = 'Password used to generate key'; +// Use the async `crypto.scrypt()` instead. +const key = crypto.scryptSync(password, 'salt', 24); +// Use `crypto.randomBytes` to generate a random iv instead of the static iv +// shown here. +const iv = Buffer.alloc(16, 0); // Initialization vector. + +const cipher = crypto.createCipheriv(algorithm, key, iv); let encrypted = cipher.update('some clear text data', 'utf8', 'hex'); encrypted += cipher.final('hex'); console.log(encrypted); -// Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504 +// Prints: e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa ``` ### cipher.final([outputEncoding]) -* `outputEncoding` {string} +* `outputEncoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Any remaining enciphered contents. - If `outputEncoding` is one of `'latin1'`, `'base64'` or `'hex'`, a string is + If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a [`Buffer`][] is returned. Once the `cipher.final()` method has been called, the `Cipher` object can no @@ -299,19 +328,19 @@ changes: description: The default `inputEncoding` changed from `binary` to `utf8`. --> * `data` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} -* `outputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the data. +* `outputEncoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Updates the cipher with `data`. If the `inputEncoding` argument is given, -its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data` +the `data` argument is a string using the specified encoding. If the `inputEncoding` argument is not given, `data` must be a [`Buffer`][], `TypedArray`, or `DataView`. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then `inputEncoding` is ignored. The `outputEncoding` specifies the output format of the enciphered -data, and can be `'latin1'`, `'base64'` or `'hex'`. If the `outputEncoding` +data. If the `outputEncoding` is specified, a string using the specified encoding is returned. If no `outputEncoding` is provided, a [`Buffer`][] is returned. @@ -340,7 +369,17 @@ Example: Using `Decipher` objects as streams: ```js const crypto = require('crypto'); -const decipher = crypto.createDecipher('aes192', 'a password'); + +const algorithm = 'aes-192-cbc'; +const password = 'Password used to generate key'; +// Key length is dependent on the algorithm. In this case for aes192, it is +// 24 bytes (192 bits). +// Use the async `crypto.scrypt()` instead. +const key = crypto.scryptSync(password, 'salt', 24); +// The IV is usually passed along with the ciphertext. +const iv = Buffer.alloc(16, 0); // Initialization vector. + +const decipher = crypto.createDecipheriv(algorithm, key, iv); let decrypted = ''; decipher.on('readable', () => { @@ -353,8 +392,9 @@ decipher.on('end', () => { // Prints: some clear text data }); +// Encrypted with same algorithm, key and iv. const encrypted = - 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; + 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; decipher.write(encrypted, 'hex'); decipher.end(); ``` @@ -364,7 +404,15 @@ Example: Using `Decipher` and piped streams: ```js const crypto = require('crypto'); const fs = require('fs'); -const decipher = crypto.createDecipher('aes192', 'a password'); + +const algorithm = 'aes-192-cbc'; +const password = 'Password used to generate key'; +// Use the async `crypto.scrypt()` instead. +const key = crypto.scryptSync(password, 'salt', 24); +// The IV is usually passed along with the ciphertext. +const iv = Buffer.alloc(16, 0); // Initialization vector. + +const decipher = crypto.createDecipheriv(algorithm, key, iv); const input = fs.createReadStream('test.enc'); const output = fs.createWriteStream('test.js'); @@ -376,10 +424,19 @@ Example: Using the [`decipher.update()`][] and [`decipher.final()`][] methods: ```js const crypto = require('crypto'); -const decipher = crypto.createDecipher('aes192', 'a password'); +const algorithm = 'aes-192-cbc'; +const password = 'Password used to generate key'; +// Use the async `crypto.scrypt()` instead. +const key = crypto.scryptSync(password, 'salt', 24); +// The IV is usually passed along with the ciphertext. +const iv = Buffer.alloc(16, 0); // Initialization vector. + +const decipher = crypto.createDecipheriv(algorithm, key, iv); + +// Encrypted using same algorithm, key and iv. const encrypted = - 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; + 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); console.log(decrypted); @@ -390,9 +447,9 @@ console.log(decrypted); -* `outputEncoding` {string} +* `outputEncoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Any remaining deciphered contents. - If `outputEncoding` is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is + If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a [`Buffer`][] is returned. Once the `decipher.final()` method has been called, the `Decipher` object can @@ -476,18 +533,18 @@ changes: description: The default `inputEncoding` changed from `binary` to `utf8`. --> * `data` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} -* `outputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `data` string. +* `outputEncoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Updates the decipher with `data`. If the `inputEncoding` argument is given, -its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data` +the `data` argument is a string using the specified encoding. If the `inputEncoding` argument is not given, `data` must be a [`Buffer`][]. If `data` is a [`Buffer`][] then `inputEncoding` is ignored. The `outputEncoding` specifies the output format of the enciphered -data, and can be `'latin1'`, `'ascii'` or `'utf8'`. If the `outputEncoding` +data. If the `outputEncoding` is specified, a string using the specified encoding is returned. If no `outputEncoding` is provided, a [`Buffer`][] is returned. @@ -531,15 +588,15 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); added: v0.5.0 --> * `otherPublicKey` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} -* `outputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of an `otherPublicKey` string. +* `outputEncoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Computes the shared secret using `otherPublicKey` as the other party's public key and returns the computed shared secret. The supplied key is interpreted using the specified `inputEncoding`, and secret is -encoded using specified `outputEncoding`. Encodings can be -`'latin1'`, `'hex'`, or `'base64'`. If the `inputEncoding` is not +encoded using specified `outputEncoding`. +If the `inputEncoding` is not provided, `otherPublicKey` is expected to be a [`Buffer`][], `TypedArray`, or `DataView`. @@ -550,57 +607,57 @@ If `outputEncoding` is given a string is returned; otherwise, a -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Generates private and public Diffie-Hellman key values, and returns the public key in the specified `encoding`. This key should be -transferred to the other party. Encoding can be `'latin1'`, `'hex'`, -or `'base64'`. If `encoding` is provided a string is returned; otherwise a +transferred to the other party. +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. ### diffieHellman.getGenerator([encoding]) -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} -Returns the Diffie-Hellman generator in the specified `encoding`, which can -be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is +Returns the Diffie-Hellman generator in the specified `encoding`. +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. ### diffieHellman.getPrime([encoding]) -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} -Returns the Diffie-Hellman prime in the specified `encoding`, which can -be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is +Returns the Diffie-Hellman prime in the specified `encoding`. +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. ### diffieHellman.getPrivateKey([encoding]) -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} -Returns the Diffie-Hellman private key in the specified `encoding`, -which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a +Returns the Diffie-Hellman private key in the specified `encoding`. +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. ### diffieHellman.getPublicKey([encoding]) -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} -Returns the Diffie-Hellman public key in the specified `encoding`, which -can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a +Returns the Diffie-Hellman public key in the specified `encoding`. +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. ### diffieHellman.setPrivateKey(privateKey[, encoding]) @@ -608,10 +665,10 @@ string is returned; otherwise a [`Buffer`][] is returned. added: v0.5.0 --> * `privateKey` {string | Buffer | TypedArray | DataView} -* `encoding` {string} +* `encoding` {string} The [encoding][] of the `privateKey` string. -Sets the Diffie-Hellman private key. If the `encoding` argument is provided -and is either `'latin1'`, `'hex'`, or `'base64'`, `privateKey` is expected +Sets the Diffie-Hellman private key. If the `encoding` argument is provided, +`privateKey` is expected to be a string. If no `encoding` is provided, `privateKey` is expected to be a [`Buffer`][], `TypedArray`, or `DataView`. @@ -620,10 +677,10 @@ to be a [`Buffer`][], `TypedArray`, or `DataView`. added: v0.5.0 --> * `publicKey` {string | Buffer | TypedArray | DataView} -* `encoding` {string} +* `encoding` {string} The [encoding][] of the `publicKey` string. -Sets the Diffie-Hellman public key. If the `encoding` argument is provided -and is either `'latin1'`, `'hex'` or `'base64'`, `publicKey` is expected +Sets the Diffie-Hellman public key. If the `encoding` argument is provided, +`publicKey` is expected to be a string. If no `encoding` is provided, `publicKey` is expected to be a [`Buffer`][], `TypedArray`, or `DataView`. @@ -681,8 +738,8 @@ added: v10.0.0 * `key` {string | Buffer | TypedArray | DataView} * `curve` {string} -* `inputEncoding` {string} -* `outputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `key` string. +* `outputEncoding` {string} The [encoding][] of the return value. * `format` {string} **Default:** `'uncompressed'` * Returns: {Buffer | string} @@ -690,8 +747,7 @@ Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the format specified by `format`. The `format` argument specifies point encoding and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is interpreted using the specified `inputEncoding`, and the returned key is encoded -using the specified `outputEncoding`. Encodings can be `'latin1'`, `'hex'`, -or `'base64'`. +using the specified `outputEncoding`. Use [`crypto.getCurves()`][] to obtain a list of available curve names. On recent OpenSSL releases, `openssl ecparam -list_curves` will also display @@ -736,15 +792,15 @@ changes: error --> * `otherPublicKey` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} -* `outputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `otherPublicKey` string. +* `outputEncoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Computes the shared secret using `otherPublicKey` as the other party's public key and returns the computed shared secret. The supplied key is interpreted using specified `inputEncoding`, and the returned secret -is encoded using the specified `outputEncoding`. Encodings can be -`'latin1'`, `'hex'`, or `'base64'`. If the `inputEncoding` is not +is encoded using the specified `outputEncoding`. +If the `inputEncoding` is not provided, `otherPublicKey` is expected to be a [`Buffer`][], `TypedArray`, or `DataView`. @@ -761,7 +817,7 @@ its recommended for developers to handle this exception accordingly. -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * `format` {string} **Default:** `'uncompressed'` * Returns: {Buffer | string} @@ -773,24 +829,24 @@ The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified, the point will be returned in `'uncompressed'` format. -The `encoding` argument can be `'latin1'`, `'hex'`, or `'base64'`. If -`encoding` is provided a string is returned; otherwise a [`Buffer`][] +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. ### ecdh.getPrivateKey([encoding]) -* `encoding` {string} -* Returns: {Buffer | string} The EC Diffie-Hellman private key in the specified - `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` - is provided a string is returned; otherwise a [`Buffer`][] is returned. +* `encoding` {string} The [encoding][] of the return value. +* Returns: {Buffer | string} The EC Diffie-Hellman in the specified `encoding`. + +If `encoding` is specified, a string is returned; otherwise a [`Buffer`][] is +returned. ### ecdh.getPublicKey([encoding][, format]) -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * `format` {string} **Default:** `'uncompressed'` * Returns: {Buffer | string} The EC Diffie-Hellman public key in the specified `encoding` and `format`. @@ -799,8 +855,7 @@ The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in `'uncompressed'` format. -The `encoding` argument can be `'latin1'`, `'hex'`, or `'base64'`. If -`encoding` is specified, a string is returned; otherwise a [`Buffer`][] is +If `encoding` is specified, a string is returned; otherwise a [`Buffer`][] is returned. ### ecdh.setPrivateKey(privateKey[, encoding]) @@ -808,10 +863,10 @@ returned. added: v0.11.14 --> * `privateKey` {string | Buffer | TypedArray | DataView} -* `encoding` {string} +* `encoding` {string} The [encoding][] of the `privateKey` string. -Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'`, -`'hex'` or `'base64'`. If `encoding` is provided, `privateKey` is expected +Sets the EC Diffie-Hellman private key. +If `encoding` is provided, `privateKey` is expected to be a string; otherwise `privateKey` is expected to be a [`Buffer`][], `TypedArray`, or `DataView`. @@ -828,10 +883,10 @@ deprecated: v5.2.0 > Stability: 0 - Deprecated * `publicKey` {string | Buffer | TypedArray | DataView} -* `encoding` {string} +* `encoding` {string} The [encoding][] of the `publicKey` string. -Sets the EC Diffie-Hellman public key. Key encoding can be `'latin1'`, -`'hex'` or `'base64'`. If `encoding` is provided `publicKey` is expected to +Sets the EC Diffie-Hellman public key. +If `encoding` is provided `publicKey` is expected to be a string; otherwise a [`Buffer`][], `TypedArray`, or `DataView` is expected. Note that there is not normally a reason to call this method because `ECDH` @@ -928,12 +983,12 @@ console.log(hash.digest('hex')); -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Calculates the digest of all of the data passed to be hashed (using the -[`hash.update()`][] method). The `encoding` can be `'hex'`, `'latin1'` or -`'base64'`. If `encoding` is provided a string will be returned; otherwise +[`hash.update()`][] method). +If `encoding` is provided a string will be returned; otherwise a [`Buffer`][] is returned. The `Hash` object can not be used again after `hash.digest()` method has been @@ -948,11 +1003,11 @@ changes: description: The default `inputEncoding` changed from `binary` to `utf8`. --> * `data` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `data` string. Updates the hash content with the given `data`, the encoding of which -is given in `inputEncoding` and can be `'utf8'`, `'ascii'` or -`'latin1'`. If `encoding` is not provided, and the `data` is a string, an +is given in `inputEncoding`. +If `encoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then `inputEncoding` is ignored. @@ -1020,11 +1075,11 @@ console.log(hmac.digest('hex')); -* `encoding` {string} +* `encoding` {string} The [encoding][] of the return value. * Returns: {Buffer | string} Calculates the HMAC digest of all of the data passed using [`hmac.update()`][]. -The `encoding` can be `'hex'`, `'latin1'` or `'base64'`. If `encoding` is +If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned; The `Hmac` object can not be used again after `hmac.digest()` has been @@ -1039,11 +1094,11 @@ changes: description: The default `inputEncoding` changed from `binary` to `utf8`. --> * `data` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `data` string. Updates the `Hmac` content with the given `data`, the encoding of which -is given in `inputEncoding` and can be `'utf8'`, `'ascii'` or -`'latin1'`. If `encoding` is not provided, and the `data` is a string, an +is given in `inputEncoding`. +If `encoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then `inputEncoding` is ignored. @@ -1113,7 +1168,7 @@ console.log(sign.sign(privateKey, 'hex')); // Prints: the calculated signature ``` -### sign.sign(privateKey[, outputFormat]) +### sign.sign(privateKey[, outputEncoding]) * `data` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `data` string. Updates the `Sign` content with the given `data`, the encoding of which -is given in `inputEncoding` and can be `'utf8'`, `'ascii'` or -`'latin1'`. If `encoding` is not provided, and the `data` is a string, an +is given in `inputEncoding`. +If `encoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then `inputEncoding` is ignored. @@ -1230,17 +1284,17 @@ changes: description: The default `inputEncoding` changed from `binary` to `utf8`. --> * `data` {string | Buffer | TypedArray | DataView} -* `inputEncoding` {string} +* `inputEncoding` {string} The [encoding][] of the `data` string. Updates the `Verify` content with the given `data`, the encoding of which -is given in `inputEncoding` and can be `'utf8'`, `'ascii'` or -`'latin1'`. If `encoding` is not provided, and the `data` is a string, an +is given in `inputEncoding`. +If `inputEncoding` is not provided, and the `data` is a string, an encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then `inputEncoding` is ignored. This can be called many times with new data as it is streamed. -### verify.verify(object, signature[, signatureFormat]) +### verify.verify(object, signature[, signatureEncoding]) * `object` {string | Object} * `signature` {string | Buffer | TypedArray | DataView} -* `signatureFormat` {string} +* `signatureEncoding` {string} The [encoding][] of the `signature` string. * Returns: {boolean} `true` or `false` depending on the validity of the signature for the data and public key. @@ -1273,8 +1327,8 @@ or an object with one or more of the following properties: determined automatically. The `signature` argument is the previously calculated signature for the data, in -the `signatureFormat` which can be `'latin1'`, `'hex'` or `'base64'`. -If a `signatureFormat` is specified, the `signature` is expected to be a +the `signatureEncoding`. +If a `signatureEncoding` is specified, the `signature` is expected to be a string; otherwise `signature` is expected to be a [`Buffer`][], `TypedArray`, or `DataView`. @@ -1551,10 +1605,10 @@ changes: from `binary` to `utf8`. --> * `prime` {string | Buffer | TypedArray | DataView} -* `primeEncoding` {string} +* `primeEncoding` {string} The [encoding][] of the `prime` string. * `generator` {number | string | Buffer | TypedArray | DataView} **Default:** `2` -* `generatorEncoding` {string} +* `generatorEncoding` {string} The [encoding][] of the `generator` string. * Returns: {DiffieHellman} Creates a `DiffieHellman` key exchange object using the supplied `prime` and an @@ -1563,9 +1617,6 @@ optional specific `generator`. The `generator` argument can be a number, string, or [`Buffer`][]. If `generator` is not specified, the value `2` is used. -The `primeEncoding` and `generatorEncoding` arguments can be `'latin1'`, -`'hex'`, or `'base64'`. - If `primeEncoding` is specified, `prime` is expected to be a string; otherwise a [`Buffer`][], `TypedArray`, or `DataView` is expected. @@ -2912,17 +2963,17 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL. [`hash.update()`]: #crypto_hash_update_data_inputencoding [`hmac.digest()`]: #crypto_hmac_digest_encoding [`hmac.update()`]: #crypto_hmac_update_data_inputencoding -[`sign.sign()`]: #crypto_sign_sign_privatekey_outputformat +[`sign.sign()`]: #crypto_sign_sign_privatekey_outputencoding [`sign.update()`]: #crypto_sign_update_data_inputencoding -[`stream.transform` options]: stream.html#stream_new_stream_transform_options [`stream.Writable` options]: stream.html#stream_constructor_new_stream_writable_options +[`stream.transform` options]: stream.html#stream_new_stream_transform_options [`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options [`util.promisify()`]: util.html#util_util_promisify_original [`verify.update()`]: #crypto_verify_update_data_inputencoding -[`verify.verify()`]: #crypto_verify_verify_object_signature_signatureformat +[`verify.verify()`]: #crypto_verify_verify_object_signature_signatureencoding [AEAD algorithms]: https://en.wikipedia.org/wiki/Authenticated_encryption -[Caveats]: #crypto_support_for_weak_or_compromised_algorithms [CCM mode]: #crypto_ccm_mode +[Caveats]: #crypto_support_for_weak_or_compromised_algorithms [Crypto Constants]: #crypto_crypto_constants_1 [HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed [HTML5's `keygen` element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen @@ -2935,6 +2986,7 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL. [RFC 3526]: https://www.rfc-editor.org/rfc/rfc3526.txt [RFC 3610]: https://www.rfc-editor.org/rfc/rfc3610.txt [RFC 4055]: https://www.rfc-editor.org/rfc/rfc4055.txt +[encoding]: buffer.html#buffer_buffers_and_character_encodings [initialization vector]: https://en.wikipedia.org/wiki/Initialization_vector [scrypt]: https://en.wikipedia.org/wiki/Scrypt [stream-writable-write]: stream.html#stream_writable_write_chunk_encoding_callback diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 22f40da01c4fe1..4374d4dd3c7afa 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2072,24 +2072,25 @@ only. Use of `process.binding()` by userland code is unsupported. [`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj [`Cipher`]: crypto.html#crypto_class_cipher [`Decipher`]: crypto.html#crypto_class_decipher -[`assert`]: assert.html -[`clearInterval()`]: timers.html#timers_clearinterval_timeout -[`clearTimeout()`]: timers.html#timers_cleartimeout_timeout [`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname +[`REPLServer.clearBufferedCommand()`]: repl.html#repl_replserver_clearbufferedcommand [`Server.connections`]: net.html#net_server_connections [`Server.getConnections()`]: net.html#net_server_getconnections_callback [`Server.listen({fd: })`]: net.html#net_server_listen_handle_backlog_callback [`SlowBuffer`]: buffer.html#buffer_class_slowbuffer +[`assert`]: assert.html [`asyncResource.runInAsyncScope()`]: async_hooks.html#async_hooks_asyncresource_runinasyncscope_fn_thisarg_args [`child_process`]: child_process.html +[`clearInterval()`]: timers.html#timers_clearinterval_timeout +[`clearTimeout()`]: timers.html#timers_cleartimeout_timeout [`console.error()`]: console.html#console_console_error_data_args [`console.log()`]: console.html#console_console_log_data_args +[`crypto.DEFAULT_ENCODING`]: crypto.html#crypto_crypto_default_encoding [`crypto.createCipher()`]: crypto.html#crypto_crypto_createcipher_algorithm_password_options [`crypto.createCipheriv()`]: crypto.html#crypto_crypto_createcipheriv_algorithm_key_iv_options [`crypto.createCredentials()`]: crypto.html#crypto_crypto_createcredentials_details [`crypto.createDecipher()`]: crypto.html#crypto_crypto_createdecipher_algorithm_password_options [`crypto.createDecipheriv()`]: crypto.html#crypto_crypto_createdecipheriv_algorithm_key_iv_options -[`crypto.DEFAULT_ENCODING`]: crypto.html#crypto_crypto_default_encoding [`crypto.fips`]: crypto.html#crypto_crypto_fips [`crypto.pbkdf2()`]: crypto.html#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback [`crypto.scrypt()`]: crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback @@ -2147,9 +2148,8 @@ only. Use of `process.binding()` by userland code is unsupported. [`util`]: util.html [`worker.exitedAfterDisconnect`]: cluster.html#cluster_worker_exitedafterdisconnect [`zlib.bytesWritten`]: zlib.html#zlib_zlib_byteswritten +[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding [alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size [from_arraybuffer]: buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length [from_string_encoding]: buffer.html#buffer_class_method_buffer_from_string_encoding -[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf -[`REPLServer.clearBufferedCommand()`]: repl.html#repl_replserver_clearbufferedcommand diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 7db8cdf3650342..1bd9c967030d8b 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -640,6 +640,7 @@ and `udp6` sockets). The bound address and port can be retrieved using [`'close'`]: #dgram_event_close [`Error`]: errors.html#errors_class_error [`EventEmitter`]: events.html +[`System Error`]: errors.html#errors_class_systemerror [`close()`]: #dgram_socket_close_callback [`cluster`]: cluster.html [`dgram.Socket#bind()`]: #dgram_socket_bind_options_callback @@ -648,7 +649,6 @@ and `udp6` sockets). The bound address and port can be retrieved using [`socket.address().address`]: #dgram_socket_address [`socket.address().port`]: #dgram_socket_address [`socket.bind()`]: #dgram_socket_bind_port_address_callback -[`System Error`]: errors.html#errors_class_systemerror -[byte length]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding [IPv6 Zone Indices]: https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses [RFC 4007]: https://tools.ietf.org/html/rfc4007 +[byte length]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding diff --git a/doc/api/documentation.md b/doc/api/documentation.md index a1b0d5903b5130..440f21c7af08dc 100644 --- a/doc/api/documentation.md +++ b/doc/api/documentation.md @@ -86,7 +86,7 @@ sometimes impossible to replace Unix syscall semantics on Windows, see [Node.js issue 4760](https://github.com/nodejs/node/issues/4760). [`'warning'`]: process.html#process_event_warning -[`stderr`]: process.html#process_process_stderr [`fs.open()`]: fs.html#fs_fs_open_path_flags_mode_callback +[`stderr`]: process.html#process_process_stderr [submit an issue]: https://github.com/nodejs/node/issues/new [the contributing guide]: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md diff --git a/doc/api/errors.md b/doc/api/errors.md index f51ba038d9cbbf..72df6b27cb7b08 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2103,24 +2103,25 @@ instance.setEncoding('utf8'); An attempt has been made to create a string larger than the maximum allowed size. -[`--force-fips`]: cli.html#cli_force_fips [`'uncaughtException'`]: process.html#process_event_uncaughtexception +[`--force-fips`]: cli.html#cli_force_fips +[`Class: assert.AssertionError`]: assert.html#assert_class_assert_assertionerror +[`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE +[`EventEmitter`]: events.html#events_class_eventemitter +[`Writable`]: stream.html#stream_class_stream_writable [`child_process`]: child_process.html [`cipher.getAuthTag()`]: crypto.html#crypto_cipher_getauthtag -[`Class: assert.AssertionError`]: assert.html#assert_class_assert_assertionerror [`crypto.scrypt()`]: crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback [`crypto.scryptSync()`]: crypto.html#crypto_crypto_scryptsync_password_salt_keylen_options [`crypto.timingSafeEqual()`]: crypto.html#crypto_crypto_timingsafeequal_a_b [`dgram.createSocket()`]: dgram.html#dgram_dgram_createsocket_options_callback -[`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE -[`EventEmitter`]: events.html#events_class_eventemitter -[`fs`]: fs.html [`errno`(3) man page]: http://man7.org/linux/man-pages/man3/errno.3.html [`fs.readFileSync`]: fs.html#fs_fs_readfilesync_path_options [`fs.readdir`]: fs.html#fs_fs_readdir_path_options_callback [`fs.symlink()`]: fs.html#fs_fs_symlink_target_path_type_callback [`fs.symlinkSync()`]: fs.html#fs_fs_symlinksync_target_path_type [`fs.unlink`]: fs.html#fs_fs_unlink_path_callback +[`fs`]: fs.html [`hash.digest()`]: crypto.html#crypto_hash_digest_encoding [`hash.update()`]: crypto.html#crypto_hash_update_data_inputencoding [`http`]: http.html @@ -2132,22 +2133,23 @@ size. [`process.send()`]: process.html#process_process_send_message_sendhandle_options_callback [`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn [`readable._read()`]: stream.html#stream_readable_read_size_1 -[`require()`]: modules.html#modules_require [`require('crypto').setEngine()`]: crypto.html#crypto_crypto_setengine_engine_flags -[`server.listen()`]: net.html#net_server_listen +[`require()`]: modules.html#modules_require [`server.close()`]: net.html#net_server_close_callback -[`sign.sign()`]: crypto.html#crypto_sign_sign_privatekey_outputformat +[`server.listen()`]: net.html#net_server_listen +[`sign.sign()`]: crypto.html#crypto_sign_sign_privatekey_outputencoding [`stream.pipe()`]: stream.html#stream_readable_pipe_destination_options [`stream.push()`]: stream.html#stream_readable_push_chunk_encoding [`stream.unshift()`]: stream.html#stream_readable_unshift_chunk [`stream.write()`]: stream.html#stream_writable_write_chunk_encoding_callback [`subprocess.kill()`]: child_process.html#child_process_subprocess_kill_signal [`subprocess.send()`]: child_process.html#child_process_subprocess_send_message_sendhandle_options_callback -[`Writable`]: stream.html#stream_class_stream_writable [`zlib`]: zlib.html [ES6 module]: esm.html +[ICU]: intl.html#intl_internationalization_support [Node.js Error Codes]: #nodejs-error-codes [V8's stack trace API]: https://github.com/v8/v8/wiki/Stack-Trace-API +[WHATWG Supported Encodings]: util.html#util_whatwg_supported_encodings [WHATWG URL API]: url.html#url_the_whatwg_url_api [crypto digest algorithm]: crypto.html#crypto_crypto_gethashes [domains]: domain.html @@ -2157,4 +2159,3 @@ size. [syscall]: http://man7.org/linux/man-pages/man2/syscalls.2.html [try-catch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch [vm]: vm.html -[WHATWG Supported Encodings]: util.html#util_whatwg_supported_encodings diff --git a/doc/api/fs.md b/doc/api/fs.md index 21f1b91db6e15e..1978fcb61cbfab 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2308,6 +2308,9 @@ object with an `encoding` property specifying the character encoding to use. + +* `string` {string} +* `position` {integer} +* `encoding` {string} **Default:** `'utf8'` +* Returns: {Promise} + +Write `string` to the file. If `string` is not a string, then +the value will be coerced to one. + +The `Promise` is resolved with an object containing a `bytesWritten` property +identifying the number of bytes written, and a `buffer` property containing +a reference to the `string` written. + +`position` refers to the offset from the beginning of the file where this data +should be written. If the type of `position` is not a `number` the data +will be written at the current position. See pwrite(2). + +`encoding` is the expected string encoding. + +It is unsafe to use `filehandle.write()` multiple times on the same file +without waiting for the `Promise` to be resolved (or rejected). For this +scenario, [`fs.createWriteStream()`][] is strongly recommended. + +On Linux, positional writes do not work when the file is opened in append mode. +The kernel ignores the position argument and always appends the data to +the end of the file. + #### filehandle.writeFile(data, options) * `path` {string|Buffer|URL} * `flags` {string|number} See [support of file system `flags`][]. + **Default:** `'r'`. * `mode` {integer} **Default:** `0o666` (readable and writable) * Returns: {Promise} @@ -4798,13 +4843,13 @@ the file contents. [`AHAFS`]: https://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/ [`Buffer.byteLength`]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding [`Buffer`]: buffer.html#buffer_buffer +[`EventEmitter`]: events.html [`FSEvents`]: https://developer.apple.com/documentation/coreservices/file_system_events [`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw [`ReadStream`]: #fs_class_fs_readstream [`URL`]: url.html#url_the_whatwg_url_api [`UV_THREADPOOL_SIZE`]: cli.html#cli_uv_threadpool_size_size [`WriteStream`]: #fs_class_fs_writestream -[`EventEmitter`]: events.html [`event ports`]: http://illumos.org/man/port_create [`fs.Dirent`]: #fs_class_fs_dirent [`fs.FSWatcher`]: #fs_class_fs_fswatcher @@ -4823,10 +4868,10 @@ the file contents. [`fs.mkdtemp()`]: #fs_fs_mkdtemp_prefix_options_callback [`fs.open()`]: #fs_fs_open_path_flags_mode_callback [`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback -[`fs.readdir()`]: #fs_fs_readdir_path_options_callback -[`fs.readdirSync()`]: #fs_fs_readdirsync_path_options [`fs.readFile()`]: #fs_fs_readfile_path_options_callback [`fs.readFileSync()`]: #fs_fs_readfilesync_path_options +[`fs.readdir()`]: #fs_fs_readdir_path_options_callback +[`fs.readdirSync()`]: #fs_fs_readdirsync_path_options [`fs.realpath()`]: #fs_fs_realpath_path_options_callback [`fs.rmdir()`]: #fs_fs_rmdir_path_callback [`fs.stat()`]: #fs_fs_stat_path_options_callback @@ -4844,13 +4889,13 @@ the file contents. [Caveats]: #fs_caveats [Common System Errors]: errors.html#errors_common_system_errors [FS Constants]: #fs_fs_constants_1 +[File Access Constants]: #fs_file_access_constants [MDN-Date]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date [MDN-Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type [MSDN-Rel-Path]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths +[MSDN-Using-Streams]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams +[Naming Files, Paths, and Namespaces]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file [Readable Streams]: stream.html#stream_class_stream_readable [Writable Stream]: stream.html#stream_class_stream_writable [inode]: https://en.wikipedia.org/wiki/Inode -[Naming Files, Paths, and Namespaces]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file -[MSDN-Using-Streams]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams [support of file system `flags`]: #fs_file_system_flags -[File Access Constants]: #fs_file_access_constants diff --git a/doc/api/globals.md b/doc/api/globals.md index 0277f7db603ef8..a3f76db9d6d692 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -169,6 +169,8 @@ The object that acts as the namespace for all W3C [WebAssembly][webassembly-org] related functionality. See the [Mozilla Developer Network][webassembly-mdn] for usage and compatibility. +[`URLSearchParams`]: url.html#url_class_urlsearchparams +[`URL`]: url.html#url_class_url [`__dirname`]: modules.html#modules_dirname [`__filename`]: modules.html#modules_filename [`clearImmediate`]: timers.html#timers_clearimmediate_immediate @@ -182,8 +184,6 @@ The object that acts as the namespace for all W3C [`setImmediate`]: timers.html#timers_setimmediate_callback_args [`setInterval`]: timers.html#timers_setinterval_callback_delay_args [`setTimeout`]: timers.html#timers_settimeout_callback_delay_args -[`URL`]: url.html#url_class_url -[`URLSearchParams`]: url.html#url_class_urlsearchparams [buffer section]: buffer.html [built-in objects]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects [module system documentation]: modules.html diff --git a/doc/api/http.md b/doc/api/http.md index af4c2c65f53b6c..bbddbb295d5a66 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -368,7 +368,7 @@ proxy.listen(1337, '127.0.0.1', () => { // make a request to a tunneling proxy const options = { port: 1337, - hostname: '127.0.0.1', + host: '127.0.0.1', method: 'CONNECT', path: 'www.google.com:80' }; @@ -415,7 +415,7 @@ event is emitted with a callback containing an object with a status code. const http = require('http'); const options = { - hostname: '127.0.0.1', + host: '127.0.0.1', port: 8080, path: '/length_request' }; @@ -502,7 +502,7 @@ srv.listen(1337, '127.0.0.1', () => { // make a request const options = { port: 1337, - hostname: '127.0.0.1', + host: '127.0.0.1', headers: { 'Connection': 'Upgrade', 'Upgrade': 'websocket' @@ -569,6 +569,17 @@ If `data` is specified, it is equivalent to calling If `callback` is specified, it will be called when the request stream is finished. +### request.finished + + +* {boolean} + +The `request.finished` property will be `true` if [`request.end()`][] +has been called. `request.end()` will automatically be called if the +request was initiated via [`http.get()`][]. + ### request.flushHeaders() + +* {boolean} + +Is `true` if it is safe to call [`writable.write()`][]. + ##### writable.writableHighWaterMark + +* {boolean} + +Is `true` if it is safe to call [`readable.read()`][]. + ##### readable.readableHighWaterMark -* Returns: {number} +* {number} Returns the value of `highWaterMark` passed when constructing this `Readable`. @@ -1028,7 +1046,7 @@ Returns the value of `highWaterMark` passed when constructing this added: v9.4.0 --> -* Returns: {number} +* {number} This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding @@ -1091,7 +1109,7 @@ const readable = getReadableStreamSomehow(); readable.setEncoding('utf8'); readable.on('data', (chunk) => { assert.equal(typeof chunk, 'string'); - console.log('got %d characters of string data', chunk.length); + console.log('Got %d characters of string data:', chunk.length); }); ``` @@ -1119,9 +1137,9 @@ const writable = fs.createWriteStream('file.txt'); // but only for the first second readable.pipe(writable); setTimeout(() => { - console.log('Stop writing to file.txt'); + console.log('Stop writing to file.txt.'); readable.unpipe(writable); - console.log('Manually close the file stream'); + console.log('Manually close the file stream.'); writable.end(); }, 1000); ``` @@ -1329,9 +1347,9 @@ const rs = fs.createReadStream('archive.tar'); finished(rs, (err) => { if (err) { - console.error('Stream failed', err); + console.error('Stream failed.', err); } else { - console.log('Stream is done reading'); + console.log('Stream is done reading.'); } }); @@ -1351,7 +1369,7 @@ const rs = fs.createReadStream('archive.tar'); async function run() { await finished(rs); - console.log('Stream is done reading'); + console.log('Stream is done reading.'); } run().catch(console.error); @@ -1386,9 +1404,9 @@ pipeline( fs.createWriteStream('archive.tar.gz'), (err) => { if (err) { - console.error('Pipeline failed', err); + console.error('Pipeline failed.', err); } else { - console.log('Pipeline succeeded'); + console.log('Pipeline succeeded.'); } } ); @@ -1405,7 +1423,7 @@ async function run() { zlib.createGzip(), fs.createWriteStream('archive.tar.gz') ); - console.log('Pipeline succeeded'); + console.log('Pipeline succeeded.'); } run().catch(console.error); @@ -2421,57 +2439,57 @@ contain multi-byte characters. [`'end'`]: #stream_event_end [`'finish'`]: #stream_event_finish [`'readable'`]: #stream_event_readable +[`Duplex`]: #stream_class_stream_duplex [`EventEmitter`]: events.html#events_class_eventemitter +[`Readable`]: #stream_class_stream_readable [`Symbol.hasInstance`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance +[`Transform`]: #stream_class_stream_transform +[`Writable`]: #stream_class_stream_writable [`fs.createReadStream()`]: fs.html#fs_fs_createreadstream_path_options [`fs.createWriteStream()`]: fs.html#fs_fs_createwritestream_path_options [`net.Socket`]: net.html#net_class_net_socket [`process.stderr`]: process.html#process_process_stderr [`process.stdin`]: process.html#process_process_stdin [`process.stdout`]: process.html#process_process_stdout +[`readable.push('')`]: #stream_readable_push [`stream.cork()`]: #stream_writable_cork [`stream.pipe()`]: #stream_readable_pipe_destination_options [`stream.uncork()`]: #stream_writable_uncork [`stream.unpipe()`]: #stream_readable_unpipe_destination [`stream.wrap()`]: #stream_readable_wrap_stream -[`readable.push('')`]: #stream_readable_push [`writable.cork()`]: #stream_writable_cork [`writable.uncork()`]: #stream_writable_uncork [`zlib.createDeflate()`]: zlib.html#zlib_zlib_createdeflate_options [API for Stream Consumers]: #stream_api_for_stream_consumers [API for Stream Implementers]: #stream_api_for_stream_implementers [Compatibility]: #stream_compatibility_with_older_node_js_versions -[`Duplex`]: #stream_class_stream_duplex [HTTP requests, on the client]: http.html#http_class_http_clientrequest [HTTP responses, on the server]: http.html#http_class_http_serverresponse -[`Readable`]: #stream_class_stream_readable [TCP sockets]: net.html#net_class_net_socket -[`Transform`]: #stream_class_stream_transform -[`Writable`]: #stream_class_stream_writable [child process stdin]: child_process.html#child_process_subprocess_stdin [child process stdout and stderr]: child_process.html#child_process_subprocess_stdout [crypto]: crypto.html +[finished]: #stream_stream_finished_stream_callback [fs read streams]: fs.html#fs_class_fs_readstream [fs write streams]: fs.html#fs_class_fs_writestream [http-incoming-message]: http.html#http_class_http_incomingmessage -[zlib]: zlib.html [hwm-gotcha]: #stream_highwatermark_discrepancy_after_calling_readable_setencoding +[object-mode]: #stream_object_mode [pipeline]: #stream_stream_pipeline_streams_callback -[finished]: #stream_stream_finished_stream_callback +[readable-_destroy]: #stream_readable_destroy_err_callback +[readable-destroy]: #stream_readable_destroy_error +[stream-_final]: #stream_writable_final_callback [stream-_flush]: #stream_transform_flush_callback [stream-_read]: #stream_readable_read_size_1 [stream-_transform]: #stream_transform_transform_chunk_encoding_callback [stream-_write]: #stream_writable_write_chunk_encoding_callback_1 [stream-_writev]: #stream_writable_writev_chunks_callback -[stream-_final]: #stream_writable_final_callback [stream-end]: #stream_writable_end_chunk_encoding_callback [stream-pause]: #stream_readable_pause [stream-push]: #stream_readable_push_chunk_encoding [stream-read]: #stream_readable_read_size [stream-resume]: #stream_readable_resume [stream-write]: #stream_writable_write_chunk_encoding_callback -[readable-_destroy]: #stream_readable_destroy_err_callback -[readable-destroy]: #stream_readable_destroy_error [writable-_destroy]: #stream_writable_destroy_err_callback [writable-destroy]: #stream_writable_destroy_error -[object-mode]: #stream_object_mode +[zlib]: zlib.html diff --git a/doc/api/tls.md b/doc/api/tls.md index 30dfb9c31e01fe..e66e7ffe719506 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -669,19 +669,19 @@ to implement the `tls-unique` channel binding from [RFC 5929][]. added: v5.7.0 --> -* Returns: {string} +* Returns: {string|null} Returns a string containing the negotiated SSL/TLS protocol version of the current connection. The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process. The value `null` will be returned for server sockets or disconnected client sockets. -Example responses include: +Protocol versions are: -* `TLSv1` -* `TLSv1.1` -* `TLSv1.2` -* `unknown` +* `'TLSv1'` +* `'TLSv1.1'` +* `'TLSv1.2'` +* `'SSLv3'` See for more information. @@ -799,14 +799,15 @@ decrease overall server throughput. added: v0.8.4 --> -* `hostname` {string} The hostname to verify the certificate against +* `hostname` {string} The host name or IP address to verify the certificate + against. * `cert` {Object} An object representing the peer's certificate. The returned object has some properties corresponding to the fields of the certificate. * Returns: {Error|undefined} Verifies the certificate `cert` is issued to `hostname`. -Returns {Error} object, populating it with the reason, host, and cert on +Returns {Error} object, populating it with `reason`, `host`, and `cert` on failure. On success, returns {undefined}. This function can be overwritten by providing alternative function as part of @@ -887,11 +888,15 @@ changes: * `ALPNProtocols`: {string[]|Buffer[]|Uint8Array[]|Buffer|Uint8Array} An array of strings, `Buffer`s or `Uint8Array`s, or a single `Buffer` or `Uint8Array` containing the supported ALPN protocols. `Buffer`s should have - the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the - first byte is the length of the next protocol name. Passing an array is - usually much simpler, e.g. `['hello', 'world']`. + the format `[len][name][len][name]...` e.g. `'\x08http/1.1\x08http/1.0'`, + where the `len` byte is the length of the next protocol name. Passing an + array is usually much simpler, e.g. `['http/1.1', 'http/1.0']`. + Protocols earlier in the list have higher preference than those later. * `servername`: {string} Server name for the SNI (Server Name Indication) TLS - extension. It must be a host name, and not an IP address. + extension. It is the name of the host being connected to, and must be a host + name, and not an IP address. It can be used by a multi-homed server to + choose the correct certificate to present to the client, see the + `SNICallback` option to [`tls.createServer()`][]. * `checkServerIdentity(servername, cert)` {Function} A callback function to be used (instead of the builtin `tls.checkServerIdentity()` function) when checking the server's hostname (or the provided `servername` when @@ -919,49 +924,24 @@ The `callback` function, if specified, will be added as a listener for the `tls.connect()` returns a [`tls.TLSSocket`][] object. -Here is an example of a client of echo server as described in +The following illustrates a client for the echo server example from [`tls.createServer()`][]: ```js -// This example assumes that you have created an echo server that is -// listening on port 8000. +// Assumes an echo server that is listening on port 8000. const tls = require('tls'); const fs = require('fs'); const options = { - // Necessary only if using the client certificate authentication + // Necessary only if the server requires client certificate authentication. key: fs.readFileSync('client-key.pem'), cert: fs.readFileSync('client-cert.pem'), - // Necessary only if the server uses the self-signed certificate - ca: [ fs.readFileSync('server-cert.pem') ] -}; + // Necessary only if the server uses a self-signed certificate. + ca: [ fs.readFileSync('server-cert.pem') ], -const socket = tls.connect(8000, options, () => { - console.log('client connected', - socket.authorized ? 'authorized' : 'unauthorized'); - process.stdin.pipe(socket); - process.stdin.resume(); -}); -socket.setEncoding('utf8'); -socket.on('data', (data) => { - console.log(data); -}); -socket.on('end', () => { - console.log('client ends'); -}); -``` - -Or - -```js -// This example assumes that you have created an echo server that is -// listening on port 8000. -const tls = require('tls'); -const fs = require('fs'); - -const options = { - pfx: fs.readFileSync('client.pfx') + // Necessary only if the server's cert isn't for "localhost". + checkServerIdentity: () => { return null; }, }; const socket = tls.connect(8000, options, () => { @@ -975,7 +955,7 @@ socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { - console.log('client ends'); + console.log('server ends connection'); }); ``` @@ -1194,10 +1174,10 @@ const options = { key: fs.readFileSync('server-key.pem'), cert: fs.readFileSync('server-cert.pem'), - // This is necessary only if using the client certificate authentication. + // This is necessary only if using client certificate authentication. requestCert: true, - // This is necessary only if the client uses the self-signed certificate. + // This is necessary only if the client uses a self-signed certificate. ca: [ fs.readFileSync('client-cert.pem') ] }; @@ -1213,36 +1193,8 @@ server.listen(8000, () => { }); ``` -Or - -```js -const tls = require('tls'); -const fs = require('fs'); - -const options = { - pfx: fs.readFileSync('server.pfx'), - - // This is necessary only if using the client certificate authentication. - requestCert: true, -}; - -const server = tls.createServer(options, (socket) => { - console.log('server connected', - socket.authorized ? 'authorized' : 'unauthorized'); - socket.write('welcome!\n'); - socket.setEncoding('utf8'); - socket.pipe(socket); -}); -server.listen(8000, () => { - console.log('server bound'); -}); -``` - -This server can be tested by connecting to it using `openssl s_client`: - -```sh -openssl s_client -connect 127.0.0.1:8000 -``` +The server can be tested by connecting to it using the example client from +[`tls.connect()`][]. ## tls.getCiphers() |'; @@ -25043,14 +25186,21 @@ var cdata = ''; var openCloseTag = new RegExp('^(?:' + openTag + '|' + closeTag + ')'); -var tag = new RegExp('^(?:' + - openTag + '|' + - closeTag + '|' + - comment + '|' + - processing + '|' + - declaration + '|' + - cdata + -')'); +var tag = new RegExp( + '^(?:' + + openTag + + '|' + + closeTag + + '|' + + comment + + '|' + + processing + + '|' + + declaration + + '|' + + cdata + + ')' +); var html = { openCloseTag: openCloseTag, @@ -25059,16 +25209,33 @@ var html = { var openCloseTag$1 = html.openCloseTag; -var htmlBlock = blockHTML; - -var C_TAB$8 = '\t'; -var C_SPACE$8 = ' '; -var C_NEWLINE$9 = '\n'; -var C_LT = '<'; - -function blockHTML(eat, value, silent) { +var htmlBlock = blockHtml; + +var tab$9 = '\t'; +var space$9 = ' '; +var lineFeed$10 = '\n'; +var lessThan = '<'; + +var rawOpenExpression = /^<(script|pre|style)(?=(\s|>|$))/i; +var rawCloseExpression = /<\/(script|pre|style)>/i; +var commentOpenExpression = /^/; +var instructionOpenExpression = /^<\?/; +var instructionCloseExpression = /\?>/; +var directiveOpenExpression = /^/; +var cdataOpenExpression = /^/; +var elementCloseExpression = /^$/; +var otherElementOpenExpression = new RegExp(openCloseTag$1.source + '\\s*$'); + +function blockHtml(eat, value, silent) { var self = this; - var blocks = self.options.blocks; + var blocks = self.options.blocks.join('|'); + var elementOpenExpression = new RegExp( + '^|$))', + 'i' + ); var length = value.length; var index = 0; var next; @@ -25080,31 +25247,31 @@ function blockHTML(eat, value, silent) { var subvalue; var sequences = [ - [/^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true], - [/^/, true], - [/^<\?/, /\?>/, true], - [/^/, true], - [/^/, true], - [new RegExp('^|$))', 'i'), /^$/, true], - [new RegExp(openCloseTag$1.source + '\\s*$'), /^$/, false] + [rawOpenExpression, rawCloseExpression, true], + [commentOpenExpression, commentCloseExpression, true], + [instructionOpenExpression, instructionCloseExpression, true], + [directiveOpenExpression, directiveCloseExpression, true], + [cdataOpenExpression, cdataCloseExpression, true], + [elementOpenExpression, elementCloseExpression, true], + [otherElementOpenExpression, elementCloseExpression, false] ]; - /* Eat initial spacing. */ + // Eat initial spacing. while (index < length) { character = value.charAt(index); - if (character !== C_TAB$8 && character !== C_SPACE$8) { - break; + if (character !== tab$9 && character !== space$9) { + break } index++; } - if (value.charAt(index) !== C_LT) { - return; + if (value.charAt(index) !== lessThan) { + return } - next = value.indexOf(C_NEWLINE$9, index + 1); + next = value.indexOf(lineFeed$10, index + 1); next = next === -1 ? length : next; line = value.slice(index, next); offset = -1; @@ -25113,23 +25280,23 @@ function blockHTML(eat, value, silent) { while (++offset < count) { if (sequences[offset][0].test(line)) { sequence = sequences[offset]; - break; + break } } if (!sequence) { - return; + return } if (silent) { - return sequence[2]; + return sequence[2] } index = next; if (!sequence[1].test(line)) { while (index < length) { - next = value.indexOf(C_NEWLINE$9, index + 1); + next = value.indexOf(lineFeed$10, index + 1); next = next === -1 ? length : next; line = value.slice(index + 1, next); @@ -25138,7 +25305,7 @@ function blockHTML(eat, value, silent) { index = next; } - break; + break } index = next; @@ -25147,7 +25314,7 @@ function blockHTML(eat, value, silent) { subvalue = value.slice(0, index); - return eat(subvalue)({type: 'html', value: subvalue}); + return eat(subvalue)({type: 'html', value: subvalue}) } var collapseWhiteSpace = collapse; @@ -25159,24 +25326,24 @@ function collapse(value) { var normalize_1 = normalize$2; -/* Normalize an identifier. Collapses multiple white space - * characters into a single space, and removes casing. */ +// Normalize an identifier. Collapses multiple white space characters into a +// single space, and removes casing. function normalize$2(value) { - return collapseWhiteSpace(value).toLowerCase(); + return collapseWhiteSpace(value).toLowerCase() } var footnoteDefinition_1 = footnoteDefinition; footnoteDefinition.notInList = true; footnoteDefinition.notInBlock = true; -var C_BACKSLASH = '\\'; -var C_NEWLINE$10 = '\n'; -var C_TAB$9 = '\t'; -var C_SPACE$9 = ' '; -var C_BRACKET_OPEN = '['; -var C_BRACKET_CLOSE = ']'; -var C_CARET = '^'; -var C_COLON = ':'; +var backslash$1 = '\\'; +var lineFeed$11 = '\n'; +var tab$10 = '\t'; +var space$10 = ' '; +var leftSquareBracket = '['; +var rightSquareBracket = ']'; +var caret$1 = '^'; +var colon$1 = ':'; var EXPRESSION_INITIAL_TAB = /^( {4}|\t)?/gm; @@ -25197,7 +25364,7 @@ function footnoteDefinition(eat, value, silent) { var exit; if (!self.options.footnotes) { - return; + return } index = 0; @@ -25210,7 +25377,7 @@ function footnoteDefinition(eat, value, silent) { character = value.charAt(index); if (!isWhitespaceCharacter(character)) { - break; + break } subvalue += character; @@ -25218,22 +25385,22 @@ function footnoteDefinition(eat, value, silent) { } if ( - value.charAt(index) !== C_BRACKET_OPEN || - value.charAt(index + 1) !== C_CARET + value.charAt(index) !== leftSquareBracket || + value.charAt(index + 1) !== caret$1 ) { - return; + return } - subvalue += C_BRACKET_OPEN + C_CARET; + subvalue += leftSquareBracket + caret$1; index = subvalue.length; queue = ''; while (index < length) { character = value.charAt(index); - if (character === C_BRACKET_CLOSE) { - break; - } else if (character === C_BACKSLASH) { + if (character === rightSquareBracket) { + break + } else if (character === backslash$1) { queue += character; index++; character = value.charAt(index); @@ -25245,25 +25412,25 @@ function footnoteDefinition(eat, value, silent) { if ( !queue || - value.charAt(index) !== C_BRACKET_CLOSE || - value.charAt(index + 1) !== C_COLON + value.charAt(index) !== rightSquareBracket || + value.charAt(index + 1) !== colon$1 ) { - return; + return } if (silent) { - return true; + return true } - identifier = normalize_1(queue); - subvalue += queue + C_BRACKET_CLOSE + C_COLON; + identifier = queue; + subvalue += queue + rightSquareBracket + colon$1; index = subvalue.length; while (index < length) { character = value.charAt(index); - if (character !== C_TAB$9 && character !== C_SPACE$9) { - break; + if (character !== tab$10 && character !== space$10) { + break } subvalue += character; @@ -25279,15 +25446,15 @@ function footnoteDefinition(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (character === C_NEWLINE$10) { + if (character === lineFeed$11) { subqueue = character; index++; while (index < length) { character = value.charAt(index); - if (character !== C_NEWLINE$10) { - break; + if (character !== lineFeed$11) { + break } subqueue += character; @@ -25300,8 +25467,8 @@ function footnoteDefinition(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (character !== C_SPACE$9) { - break; + if (character !== space$10) { + break } subqueue += character; @@ -25309,7 +25476,7 @@ function footnoteDefinition(eat, value, silent) { } if (subqueue.length === 0) { - break; + break } queue += subqueue; @@ -25326,11 +25493,11 @@ function footnoteDefinition(eat, value, silent) { subvalue += content; - content = content.replace(EXPRESSION_INITIAL_TAB, function (line) { + content = content.replace(EXPRESSION_INITIAL_TAB, function(line) { offsets[currentLine] = (offsets[currentLine] || 0) + line.length; currentLine++; - return ''; + return '' }); add = eat(subvalue); @@ -25341,28 +25508,29 @@ function footnoteDefinition(eat, value, silent) { return add({ type: 'footnoteDefinition', - identifier: identifier, + identifier: normalize_1(identifier), + label: identifier, children: content - }); + }) } var definition_1 = definition; definition.notInList = true; definition.notInBlock = true; -var C_DOUBLE_QUOTE = '"'; -var C_SINGLE_QUOTE = '\''; -var C_BACKSLASH$1 = '\\'; -var C_NEWLINE$11 = '\n'; -var C_TAB$10 = '\t'; -var C_SPACE$10 = ' '; -var C_BRACKET_OPEN$1 = '['; -var C_BRACKET_CLOSE$1 = ']'; -var C_PAREN_OPEN = '('; -var C_PAREN_CLOSE$1 = ')'; -var C_COLON$1 = ':'; -var C_LT$1 = '<'; -var C_GT$1 = '>'; +var quotationMark = '"'; +var apostrophe = "'"; +var backslash$2 = '\\'; +var lineFeed$12 = '\n'; +var tab$11 = '\t'; +var space$11 = ' '; +var leftSquareBracket$1 = '['; +var rightSquareBracket$1 = ']'; +var leftParenthesis = '('; +var rightParenthesis$1 = ')'; +var colon$2 = ':'; +var lessThan$1 = '<'; +var greaterThan$1 = '>'; function definition(eat, value, silent) { var self = this; @@ -25382,8 +25550,8 @@ function definition(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (character !== C_SPACE$10 && character !== C_TAB$10) { - break; + if (character !== space$11 && character !== tab$11) { + break } subvalue += character; @@ -25392,8 +25560,8 @@ function definition(eat, value, silent) { character = value.charAt(index); - if (character !== C_BRACKET_OPEN$1) { - return; + if (character !== leftSquareBracket$1) { + return } index++; @@ -25403,9 +25571,9 @@ function definition(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (character === C_BRACKET_CLOSE$1) { - break; - } else if (character === C_BACKSLASH$1) { + if (character === rightSquareBracket$1) { + break + } else if (character === backslash$2) { queue += character; index++; character = value.charAt(index); @@ -25417,26 +25585,22 @@ function definition(eat, value, silent) { if ( !queue || - value.charAt(index) !== C_BRACKET_CLOSE$1 || - value.charAt(index + 1) !== C_COLON$1 + value.charAt(index) !== rightSquareBracket$1 || + value.charAt(index + 1) !== colon$2 ) { - return; + return } identifier = queue; - subvalue += queue + C_BRACKET_CLOSE$1 + C_COLON$1; + subvalue += queue + rightSquareBracket$1 + colon$2; index = subvalue.length; queue = ''; while (index < length) { character = value.charAt(index); - if ( - character !== C_TAB$10 && - character !== C_SPACE$10 && - character !== C_NEWLINE$11 - ) { - break; + if (character !== tab$11 && character !== space$11 && character !== lineFeed$12) { + break } subvalue += character; @@ -25447,14 +25611,14 @@ function definition(eat, value, silent) { queue = ''; beforeURL = subvalue; - if (character === C_LT$1) { + if (character === lessThan$1) { index++; while (index < length) { character = value.charAt(index); if (!isEnclosedURLCharacter(character)) { - break; + break } queue += character; @@ -25464,11 +25628,11 @@ function definition(eat, value, silent) { character = value.charAt(index); if (character === isEnclosedURLCharacter.delimiter) { - subvalue += C_LT$1 + queue + character; + subvalue += lessThan$1 + queue + character; index++; } else { if (commonmark) { - return; + return } index -= queue.length + 1; @@ -25481,7 +25645,7 @@ function definition(eat, value, silent) { character = value.charAt(index); if (!isUnclosedURLCharacter(character)) { - break; + break } queue += character; @@ -25492,7 +25656,7 @@ function definition(eat, value, silent) { } if (!queue) { - return; + return } url = queue; @@ -25501,12 +25665,8 @@ function definition(eat, value, silent) { while (index < length) { character = value.charAt(index); - if ( - character !== C_TAB$10 && - character !== C_SPACE$10 && - character !== C_NEWLINE$11 - ) { - break; + if (character !== tab$11 && character !== space$11 && character !== lineFeed$12) { + break } queue += character; @@ -25516,12 +25676,12 @@ function definition(eat, value, silent) { character = value.charAt(index); test = null; - if (character === C_DOUBLE_QUOTE) { - test = C_DOUBLE_QUOTE; - } else if (character === C_SINGLE_QUOTE) { - test = C_SINGLE_QUOTE; - } else if (character === C_PAREN_OPEN) { - test = C_PAREN_CLOSE$1; + if (character === quotationMark) { + test = quotationMark; + } else if (character === apostrophe) { + test = apostrophe; + } else if (character === leftParenthesis) { + test = rightParenthesis$1; } if (!test) { @@ -25536,18 +25696,18 @@ function definition(eat, value, silent) { character = value.charAt(index); if (character === test) { - break; + break } - if (character === C_NEWLINE$11) { + if (character === lineFeed$12) { index++; character = value.charAt(index); - if (character === C_NEWLINE$11 || character === test) { - return; + if (character === lineFeed$12 || character === test) { + return } - queue += C_NEWLINE$11; + queue += lineFeed$12; } queue += character; @@ -25557,7 +25717,7 @@ function definition(eat, value, silent) { character = value.charAt(index); if (character !== test) { - return; + return } beforeTitle = subvalue; @@ -25566,14 +25726,14 @@ function definition(eat, value, silent) { title = queue; queue = ''; } else { - return; + return } while (index < length) { character = value.charAt(index); - if (character !== C_TAB$10 && character !== C_SPACE$10) { - break; + if (character !== tab$11 && character !== space$11) { + break } subvalue += character; @@ -25582,13 +25742,13 @@ function definition(eat, value, silent) { character = value.charAt(index); - if (!character || character === C_NEWLINE$11) { + if (!character || character === lineFeed$12) { if (silent) { - return true; + return true } beforeURL = eat(beforeURL).test().end; - url = self.decode.raw(self.unescape(url), beforeURL); + url = self.decode.raw(self.unescape(url), beforeURL, {nonTerminated: false}); if (title) { beforeTitle = eat(beforeTitle).test().end; @@ -25598,46 +25758,50 @@ function definition(eat, value, silent) { return eat(subvalue)({ type: 'definition', identifier: normalize_1(identifier), + label: identifier, title: title || null, url: url - }); + }) } } -/* Check if `character` can be inside an enclosed URI. */ +// Check if `character` can be inside an enclosed URI. function isEnclosedURLCharacter(character) { - return character !== C_GT$1 && - character !== C_BRACKET_OPEN$1 && - character !== C_BRACKET_CLOSE$1; + return ( + character !== greaterThan$1 && + character !== leftSquareBracket$1 && + character !== rightSquareBracket$1 + ) } -isEnclosedURLCharacter.delimiter = C_GT$1; +isEnclosedURLCharacter.delimiter = greaterThan$1; -/* Check if `character` can be inside an unclosed URI. */ +// Check if `character` can be inside an unclosed URI. function isUnclosedURLCharacter(character) { - return character !== C_BRACKET_OPEN$1 && - character !== C_BRACKET_CLOSE$1 && - !isWhitespaceCharacter(character); + return ( + character !== leftSquareBracket$1 && + character !== rightSquareBracket$1 && + !isWhitespaceCharacter(character) + ) } var table_1 = table$1; -var C_BACKSLASH$2 = '\\'; -var C_TICK$1 = '`'; -var C_DASH$3 = '-'; -var C_PIPE = '|'; -var C_COLON$2 = ':'; -var C_SPACE$11 = ' '; -var C_NEWLINE$12 = '\n'; -var C_TAB$11 = '\t'; +var tab$12 = '\t'; +var lineFeed$13 = '\n'; +var space$12 = ' '; +var dash$4 = '-'; +var colon$3 = ':'; +var backslash$3 = '\\'; +var graveAccent$1 = '`'; +var verticalBar = '|'; -var MIN_TABLE_COLUMNS = 1; -var MIN_TABLE_ROWS = 2; +var minColumns = 1; +var minRows = 2; -var TABLE_ALIGN_LEFT = 'left'; -var TABLE_ALIGN_CENTER = 'center'; -var TABLE_ALIGN_RIGHT = 'right'; -var TABLE_ALIGN_NONE = null; +var left = 'left'; +var center = 'center'; +var right = 'right'; function table$1(eat, value, silent) { var self = this; @@ -25666,35 +25830,34 @@ function table$1(eat, value, silent) { var pipeIndex; var first; - /* Exit when not in gfm-mode. */ + // Exit when not in gfm-mode. if (!self.options.gfm) { - return; + return } - /* Get the rows. - * Detecting tables soon is hard, so there are some - * checks for performance here, such as the minimum - * number of rows, and allowed characters in the - * alignment row. */ + // Get the rows. + // Detecting tables soon is hard, so there are some checks for performance + // here, such as the minimum number of rows, and allowed characters in the + // alignment row. index = 0; lineCount = 0; length = value.length + 1; lines = []; while (index < length) { - lineIndex = value.indexOf(C_NEWLINE$12, index); - pipeIndex = value.indexOf(C_PIPE, index + 1); + lineIndex = value.indexOf(lineFeed$13, index); + pipeIndex = value.indexOf(verticalBar, index + 1); if (lineIndex === -1) { lineIndex = value.length; } if (pipeIndex === -1 || pipeIndex > lineIndex) { - if (lineCount < MIN_TABLE_ROWS) { - return; + if (lineCount < minRows) { + return } - break; + break } lines.push(value.slice(index, lineIndex)); @@ -25702,8 +25865,8 @@ function table$1(eat, value, silent) { index = lineIndex + 1; } - /* Parse the alignment row. */ - subvalue = lines.join(C_NEWLINE$12); + // Parse the alignment row. + subvalue = lines.join(lineFeed$13); alignments = lines.splice(1, 1)[0] || []; index = 0; length = alignments.length; @@ -25714,12 +25877,12 @@ function table$1(eat, value, silent) { while (index < length) { character = alignments.charAt(index); - if (character === C_PIPE) { + if (character === verticalBar) { hasDash = null; if (alignment === false) { if (first === false) { - return; + return } } else { align.push(alignment); @@ -25727,19 +25890,19 @@ function table$1(eat, value, silent) { } first = false; - } else if (character === C_DASH$3) { + } else if (character === dash$4) { hasDash = true; - alignment = alignment || TABLE_ALIGN_NONE; - } else if (character === C_COLON$2) { - if (alignment === TABLE_ALIGN_LEFT) { - alignment = TABLE_ALIGN_CENTER; - } else if (hasDash && alignment === TABLE_ALIGN_NONE) { - alignment = TABLE_ALIGN_RIGHT; + alignment = alignment || null; + } else if (character === colon$3) { + if (alignment === left) { + alignment = center; + } else if (hasDash && alignment === null) { + alignment = right; } else { - alignment = TABLE_ALIGN_LEFT; + alignment = left; } } else if (!isWhitespaceCharacter(character)) { - return; + return } index++; @@ -25749,37 +25912,32 @@ function table$1(eat, value, silent) { align.push(alignment); } - /* Exit when without enough columns. */ - if (align.length < MIN_TABLE_COLUMNS) { - return; + // Exit when without enough columns. + if (align.length < minColumns) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - /* Parse the rows. */ + // Parse the rows. position = -1; rows = []; - table = eat(subvalue).reset({ - type: 'table', - align: align, - children: rows - }); + table = eat(subvalue).reset({type: 'table', align: align, children: rows}); while (++position < lineCount) { line = lines[position]; row = {type: 'tableRow', children: []}; - /* Eat a newline character when this is not the - * first row. */ + // Eat a newline character when this is not the first row. if (position) { - eat(C_NEWLINE$12); + eat(lineFeed$13); } - /* Eat the row. */ + // Eat the row. eat(line).reset(row, table); length = line.length + 1; @@ -25793,7 +25951,7 @@ function table$1(eat, value, silent) { while (index < length) { character = line.charAt(index); - if (character === C_TAB$11 || character === C_SPACE$11) { + if (character === tab$12 || character === space$12) { if (cell) { queue += character; } else { @@ -25801,17 +25959,17 @@ function table$1(eat, value, silent) { } index++; - continue; + continue } - if (character === '' || character === C_PIPE) { + if (character === '' || character === verticalBar) { if (preamble) { eat(character); } else { if (character && opening) { queue += character; index++; - continue; + continue } if ((cell || character) && !preamble) { @@ -25829,10 +25987,10 @@ function table$1(eat, value, silent) { now = eat.now(); - eat(subvalue)({ - type: 'tableCell', - children: self.tokenizeInline(cell, now) - }, row); + eat(subvalue)( + {type: 'tableCell', children: self.tokenizeInline(cell, now)}, + row + ); } eat(queue + character); @@ -25848,12 +26006,12 @@ function table$1(eat, value, silent) { cell += character; - if (character === C_BACKSLASH$2 && index !== length - 2) { + if (character === backslash$3 && index !== length - 2) { cell += line.charAt(index + 1); index++; } - if (character === C_TICK$1) { + if (character === graveAccent$1) { count = 1; while (line.charAt(index + 1) === character) { @@ -25874,24 +26032,24 @@ function table$1(eat, value, silent) { index++; } - /* Eat the alignment row. */ + // Eat the alignment row. if (!position) { - eat(C_NEWLINE$12 + alignments); + eat(lineFeed$13 + alignments); } } - return table; + return table } var paragraph_1 = paragraph; -var C_NEWLINE$13 = '\n'; -var C_TAB$12 = '\t'; -var C_SPACE$12 = ' '; +var tab$13 = '\t'; +var lineFeed$14 = '\n'; +var space$13 = ' '; -var TAB_SIZE$1 = 4; +var tabSize$4 = 4; -/* Tokenise paragraph. */ +// Tokenise paragraph. function paragraph(eat, value, silent) { var self = this; var settings = self.options; @@ -25899,7 +26057,7 @@ function paragraph(eat, value, silent) { var gfm = settings.gfm; var tokenizers = self.blockTokenizers; var interruptors = self.interruptParagraph; - var index = value.indexOf(C_NEWLINE$13); + var index = value.indexOf(lineFeed$14); var length = value.length; var position; var subvalue; @@ -25908,19 +26066,18 @@ function paragraph(eat, value, silent) { var now; while (index < length) { - /* Eat everything if there’s no following newline. */ + // Eat everything if there’s no following newline. if (index === -1) { index = length; - break; + break } - /* Stop if the next character is NEWLINE. */ - if (value.charAt(index + 1) === C_NEWLINE$13) { - break; + // Stop if the next character is NEWLINE. + if (value.charAt(index + 1) === lineFeed$14) { + break } - /* In commonmark-mode, following indented lines - * are part of the paragraph. */ + // In commonmark-mode, following indented lines are part of the paragraph. if (commonmark) { size = 0; position = index + 1; @@ -25928,52 +26085,48 @@ function paragraph(eat, value, silent) { while (position < length) { character = value.charAt(position); - if (character === C_TAB$12) { - size = TAB_SIZE$1; - break; - } else if (character === C_SPACE$12) { + if (character === tab$13) { + size = tabSize$4; + break + } else if (character === space$13) { size++; } else { - break; + break } position++; } - if (size >= TAB_SIZE$1) { - index = value.indexOf(C_NEWLINE$13, index + 1); - continue; + if (size >= tabSize$4 && character !== lineFeed$14) { + index = value.indexOf(lineFeed$14, index + 1); + continue } } subvalue = value.slice(index + 1); - /* Check if the following code contains a possible - * block. */ + // Check if the following code contains a possible block. if (interrupt_1(interruptors, tokenizers, self, [eat, subvalue, true])) { - break; + break } - /* Break if the following line starts a list, when - * already in a list, or when in commonmark, or when - * in gfm mode and the bullet is *not* numeric. */ + // Break if the following line starts a list, when already in a list, or + // when in commonmark, or when in gfm mode and the bullet is *not* numeric. if ( tokenizers.list.call(self, eat, subvalue, true) && - ( - self.inList || + (self.inList || commonmark || - (gfm && !isDecimal(trim_1.left(subvalue).charAt(0))) - ) + (gfm && !isDecimal(trim_1.left(subvalue).charAt(0)))) ) { - break; + break } position = index; - index = value.indexOf(C_NEWLINE$13, index + 1); + index = value.indexOf(lineFeed$14, index + 1); if (index !== -1 && trim_1(value.slice(position, index)) === '') { index = position; - break; + break } } @@ -25982,12 +26135,12 @@ function paragraph(eat, value, silent) { if (trim_1(subvalue) === '') { eat(subvalue); - return null; + return null } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } now = eat.now(); @@ -25996,42 +26149,42 @@ function paragraph(eat, value, silent) { return eat(subvalue)({ type: 'paragraph', children: self.tokenizeInline(subvalue, now) - }); + }) } var _escape = locate; function locate(value, fromIndex) { - return value.indexOf('\\', fromIndex); + return value.indexOf('\\', fromIndex) } var _escape$2 = escape; escape.locator = _escape; +var lineFeed$15 = '\n'; +var backslash$4 = '\\'; + function escape(eat, value, silent) { var self = this; var character; var node; - if (value.charAt(0) === '\\') { + if (value.charAt(0) === backslash$4) { character = value.charAt(1); if (self.escape.indexOf(character) !== -1) { /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - if (character === '\n') { + if (character === lineFeed$15) { node = {type: 'break'}; } else { - node = { - type: 'text', - value: character - }; + node = {type: 'text', value: character}; } - return eat('\\' + character)(node); + return eat(backslash$4 + character)(node) } } } @@ -26039,60 +26192,51 @@ function escape(eat, value, silent) { var tag$1 = locate$2; function locate$2(value, fromIndex) { - return value.indexOf('<', fromIndex); + return value.indexOf('<', fromIndex) } var autoLink_1 = autoLink; autoLink.locator = tag$1; autoLink.notInLink = true; -var C_LT$2 = '<'; -var C_GT$2 = '>'; -var C_AT_SIGN = '@'; -var C_SLASH = '/'; -var MAILTO = 'mailto:'; -var MAILTO_LENGTH = MAILTO.length; +var lessThan$2 = '<'; +var greaterThan$2 = '>'; +var atSign = '@'; +var slash = '/'; +var mailto = 'mailto:'; +var mailtoLength = mailto.length; -/* Tokenise a link. */ function autoLink(eat, value, silent) { - var self; - var subvalue; - var length; - var index; - var queue; + var self = this; + var subvalue = ''; + var length = value.length; + var index = 0; + var queue = ''; + var hasAtCharacter = false; + var link = ''; var character; - var hasAtCharacter; - var link; var now; var content; - var tokenize; + var tokenizers; var exit; - if (value.charAt(0) !== C_LT$2) { - return; + if (value.charAt(0) !== lessThan$2) { + return } - self = this; - subvalue = ''; - length = value.length; - index = 0; - queue = ''; - hasAtCharacter = false; - link = ''; - index++; - subvalue = C_LT$2; + subvalue = lessThan$2; while (index < length) { character = value.charAt(index); if ( isWhitespaceCharacter(character) || - character === C_GT$2 || - character === C_AT_SIGN || - (character === ':' && value.charAt(index + 1) === C_SLASH) + character === greaterThan$2 || + character === atSign || + (character === ':' && value.charAt(index + 1) === slash) ) { - break; + break } queue += character; @@ -26100,7 +26244,7 @@ function autoLink(eat, value, silent) { } if (!queue) { - return; + return } link += queue; @@ -26110,25 +26254,22 @@ function autoLink(eat, value, silent) { link += character; index++; - if (character === C_AT_SIGN) { + if (character === atSign) { hasAtCharacter = true; } else { - if ( - character !== ':' || - value.charAt(index + 1) !== C_SLASH - ) { - return; + if (character !== ':' || value.charAt(index + 1) !== slash) { + return } - link += C_SLASH; + link += slash; index++; } while (index < length) { character = value.charAt(index); - if (isWhitespaceCharacter(character) || character === C_GT$2) { - break; + if (isWhitespaceCharacter(character) || character === greaterThan$2) { + break } queue += character; @@ -26137,13 +26278,13 @@ function autoLink(eat, value, silent) { character = value.charAt(index); - if (!queue || character !== C_GT$2) { - return; + if (!queue || character !== greaterThan$2) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } link += queue; @@ -26154,80 +26295,83 @@ function autoLink(eat, value, silent) { now.offset++; if (hasAtCharacter) { - if (link.slice(0, MAILTO_LENGTH).toLowerCase() === MAILTO) { - content = content.substr(MAILTO_LENGTH); - now.column += MAILTO_LENGTH; - now.offset += MAILTO_LENGTH; + if (link.slice(0, mailtoLength).toLowerCase() === mailto) { + content = content.substr(mailtoLength); + now.column += mailtoLength; + now.offset += mailtoLength; } else { - link = MAILTO + link; + link = mailto + link; } } - /* Temporarily remove support for escapes in autolinks. */ - tokenize = self.inlineTokenizers.escape; - self.inlineTokenizers.escape = null; + // Temporarily remove all tokenizers except text in autolinks. + tokenizers = self.inlineTokenizers; + self.inlineTokenizers = {text: tokenizers.text}; + exit = self.enterLink(); content = self.tokenizeInline(content, now); - self.inlineTokenizers.escape = tokenize; + self.inlineTokenizers = tokenizers; exit(); return eat(subvalue)({ type: 'link', title: null, - url: parseEntities_1(link), + url: parseEntities_1(link, {nonTerminated: false}), children: content - }); + }) } var url = locate$4; -var PROTOCOLS = ['https://', 'http://', 'mailto:']; +var protocols = ['https://', 'http://', 'mailto:']; function locate$4(value, fromIndex) { - var length = PROTOCOLS.length; + var length = protocols.length; var index = -1; var min = -1; var position; if (!this.options.gfm) { - return -1; + return -1 } while (++index < length) { - position = value.indexOf(PROTOCOLS[index], fromIndex); + position = value.indexOf(protocols[index], fromIndex); if (position !== -1 && (position < min || min === -1)) { min = position; } } - return min; + return min } var url_1 = url$2; url$2.locator = url; url$2.notInLink = true; -var C_BRACKET_OPEN$2 = '['; -var C_BRACKET_CLOSE$2 = ']'; -var C_PAREN_OPEN$1 = '('; -var C_PAREN_CLOSE$2 = ')'; -var C_LT$3 = '<'; -var C_AT_SIGN$1 = '@'; - -var HTTP_PROTOCOL = 'http://'; -var HTTPS_PROTOCOL = 'https://'; -var MAILTO_PROTOCOL = 'mailto:'; - -var PROTOCOLS$1 = [ - HTTP_PROTOCOL, - HTTPS_PROTOCOL, - MAILTO_PROTOCOL -]; +var quotationMark$1 = '"'; +var apostrophe$1 = "'"; +var leftParenthesis$1 = '('; +var rightParenthesis$2 = ')'; +var comma$1 = ','; +var dot$2 = '.'; +var colon$4 = ':'; +var semicolon = ';'; +var lessThan$3 = '<'; +var atSign$1 = '@'; +var leftSquareBracket$2 = '['; +var rightSquareBracket$2 = ']'; -var PROTOCOLS_LENGTH = PROTOCOLS$1.length; +var http = 'http://'; +var https = 'https://'; +var mailto$1 = 'mailto:'; + +var protocols$1 = [http, https, mailto$1]; + +var protocolsLength = protocols$1.length; function url$2(eat, value, silent) { var self = this; @@ -26242,28 +26386,28 @@ function url$2(eat, value, silent) { var queue; var parenCount; var nextCharacter; + var tokenizers; var exit; if (!self.options.gfm) { - return; + return } subvalue = ''; index = -1; - length = PROTOCOLS_LENGTH; - while (++index < length) { - protocol = PROTOCOLS$1[index]; + while (++index < protocolsLength) { + protocol = protocols$1[index]; match = value.slice(0, protocol.length); if (match.toLowerCase() === protocol) { subvalue = match; - break; + break } } if (!subvalue) { - return; + return } index = subvalue.length; @@ -26274,36 +26418,36 @@ function url$2(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (isWhitespaceCharacter(character) || character === C_LT$3) { - break; + if (isWhitespaceCharacter(character) || character === lessThan$3) { + break } if ( - character === '.' || - character === ',' || - character === ':' || - character === ';' || - character === '"' || - character === '\'' || - character === ')' || - character === ']' + character === dot$2 || + character === comma$1 || + character === colon$4 || + character === semicolon || + character === quotationMark$1 || + character === apostrophe$1 || + character === rightParenthesis$2 || + character === rightSquareBracket$2 ) { nextCharacter = value.charAt(index + 1); if (!nextCharacter || isWhitespaceCharacter(nextCharacter)) { - break; + break } } - if (character === C_PAREN_OPEN$1 || character === C_BRACKET_OPEN$2) { + if (character === leftParenthesis$1 || character === leftSquareBracket$2) { parenCount++; } - if (character === C_PAREN_CLOSE$2 || character === C_BRACKET_CLOSE$2) { + if (character === rightParenthesis$2 || character === rightSquareBracket$2) { parenCount--; if (parenCount < 0) { - break; + break } } @@ -26312,37 +26456,44 @@ function url$2(eat, value, silent) { } if (!queue) { - return; + return } subvalue += queue; content = subvalue; - if (protocol === MAILTO_PROTOCOL) { - position = queue.indexOf(C_AT_SIGN$1); + if (protocol === mailto$1) { + position = queue.indexOf(atSign$1); if (position === -1 || position === length - 1) { - return; + return } - content = content.substr(MAILTO_PROTOCOL.length); + content = content.substr(mailto$1.length); } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } exit = self.enterLink(); + + // Temporarily remove all tokenizers except text in url. + tokenizers = self.inlineTokenizers; + self.inlineTokenizers = {text: tokenizers.text}; + content = self.tokenizeInline(content, eat.now()); + + self.inlineTokenizers = tokenizers; exit(); return eat(subvalue)({ type: 'link', title: null, - url: parseEntities_1(subvalue), + url: parseEntities_1(subvalue, {nonTerminated: false}), children: content - }); + }) } var tag$3 = html.tag; @@ -26350,8 +26501,13 @@ var tag$3 = html.tag; var htmlInline = inlineHTML; inlineHTML.locator = tag$1; -var EXPRESSION_HTML_LINK_OPEN = /^/i; +var lessThan$4 = '<'; +var questionMark = '?'; +var exclamationMark$1 = '!'; +var slash$1 = '/'; + +var htmlLinkOpenExpression = /^/i; function inlineHTML(eat, value, silent) { var self = this; @@ -26359,41 +26515,41 @@ function inlineHTML(eat, value, silent) { var character; var subvalue; - if (value.charAt(0) !== '<' || length < 3) { - return; + if (value.charAt(0) !== lessThan$4 || length < 3) { + return } character = value.charAt(1); if ( !isAlphabetical(character) && - character !== '?' && - character !== '!' && - character !== '/' + character !== questionMark && + character !== exclamationMark$1 && + character !== slash$1 ) { - return; + return } subvalue = value.match(tag$3); if (!subvalue) { - return; + return } /* istanbul ignore if - not used yet. */ if (silent) { - return true; + return true } subvalue = subvalue[0]; - if (!self.inLink && EXPRESSION_HTML_LINK_OPEN.test(subvalue)) { + if (!self.inLink && htmlLinkOpenExpression.test(subvalue)) { self.inLink = true; - } else if (self.inLink && EXPRESSION_HTML_LINK_CLOSE.test(subvalue)) { + } else if (self.inLink && htmlLinkCloseExpression.test(subvalue)) { self.inLink = false; } - return eat(subvalue)({type: 'html', value: subvalue}); + return eat(subvalue)({type: 'html', value: subvalue}) } var link = locate$6; @@ -26403,44 +26559,29 @@ function locate$6(value, fromIndex) { var image = value.indexOf('![', fromIndex); if (image === -1) { - return link; + return link } - /* Link can never be `-1` if an image is found, so we don’t need - * to check for that :) */ - return link < image ? link : image; + // Link can never be `-1` if an image is found, so we don’t need to check + // for that :) + return link < image ? link : image } var link_1 = link$2; link$2.locator = link; -var own$5 = {}.hasOwnProperty; - -var C_BACKSLASH$3 = '\\'; -var C_BRACKET_OPEN$3 = '['; -var C_BRACKET_CLOSE$3 = ']'; -var C_PAREN_OPEN$2 = '('; -var C_PAREN_CLOSE$3 = ')'; -var C_LT$4 = '<'; -var C_GT$3 = '>'; -var C_TICK$2 = '`'; -var C_DOUBLE_QUOTE$1 = '"'; -var C_SINGLE_QUOTE$1 = '\''; - -/* Map of characters, which can be used to mark link - * and image titles. */ -var LINK_MARKERS = {}; - -LINK_MARKERS[C_DOUBLE_QUOTE$1] = C_DOUBLE_QUOTE$1; -LINK_MARKERS[C_SINGLE_QUOTE$1] = C_SINGLE_QUOTE$1; - -/* Map of characters, which can be used to mark link - * and image titles in commonmark-mode. */ -var COMMONMARK_LINK_MARKERS = {}; - -COMMONMARK_LINK_MARKERS[C_DOUBLE_QUOTE$1] = C_DOUBLE_QUOTE$1; -COMMONMARK_LINK_MARKERS[C_SINGLE_QUOTE$1] = C_SINGLE_QUOTE$1; -COMMONMARK_LINK_MARKERS[C_PAREN_OPEN$2] = C_PAREN_CLOSE$3; +var lineFeed$16 = '\n'; +var exclamationMark$2 = '!'; +var quotationMark$2 = '"'; +var apostrophe$2 = "'"; +var leftParenthesis$2 = '('; +var rightParenthesis$3 = ')'; +var lessThan$5 = '<'; +var greaterThan$3 = '>'; +var leftSquareBracket$3 = '['; +var backslash$5 = '\\'; +var rightSquareBracket$3 = ']'; +var graveAccent$2 = '`'; function link$2(eat, value, silent) { var self = this; @@ -26457,7 +26598,6 @@ function link$2(eat, value, silent) { var beforeTitle; var subqueue; var hasMarker; - var markers; var isImage; var content; var marker; @@ -26470,29 +26610,28 @@ function link$2(eat, value, silent) { var exit; var node; - /* Detect whether this is an image. */ - if (character === '!') { + // Detect whether this is an image. + if (character === exclamationMark$2) { isImage = true; subvalue = character; character = value.charAt(++index); } - /* Eat the opening. */ - if (character !== C_BRACKET_OPEN$3) { - return; + // Eat the opening. + if (character !== leftSquareBracket$3) { + return } - /* Exit when this is a link and we’re already inside - * a link. */ + // Exit when this is a link and we’re already inside a link. if (!isImage && self.inLink) { - return; + return } subvalue += character; queue = ''; index++; - /* Eat the content. */ + // Eat the content. length = value.length; now = eat.now(); depth = 0; @@ -26504,11 +26643,11 @@ function link$2(eat, value, silent) { character = value.charAt(index); subqueue = character; - if (character === C_TICK$2) { - /* Inline-code in link content. */ + if (character === graveAccent$2) { + // Inline-code in link content. count = 1; - while (value.charAt(index + 1) === C_TICK$2) { + while (value.charAt(index + 1) === graveAccent$2) { subqueue += character; index++; count++; @@ -26519,28 +26658,25 @@ function link$2(eat, value, silent) { } else if (count >= opening) { opening = 0; } - } else if (character === C_BACKSLASH$3) { - /* Allow brackets to be escaped. */ + } else if (character === backslash$5) { + // Allow brackets to be escaped. index++; subqueue += value.charAt(index); - /* In GFM mode, brackets in code still count. - * In all other modes, they don’t. This empty - * block prevents the next statements are - * entered. */ - } else if ((!opening || gfm) && character === C_BRACKET_OPEN$3) { + } else if ((!opening || gfm) && character === leftSquareBracket$3) { + // In GFM mode, brackets in code still count. In all other modes, + // they don’t. depth++; - } else if ((!opening || gfm) && character === C_BRACKET_CLOSE$3) { + } else if ((!opening || gfm) && character === rightSquareBracket$3) { if (depth) { depth--; } else { - /* Allow white-space between content and - * url in GFM mode. */ + // Allow white-space between content and url in GFM mode. if (!pedantic) { while (index < length) { character = value.charAt(index + 1); if (!isWhitespaceCharacter(character)) { - break; + break } subqueue += character; @@ -26548,15 +26684,15 @@ function link$2(eat, value, silent) { } } - if (value.charAt(index + 1) !== C_PAREN_OPEN$2) { - return; + if (value.charAt(index + 1) !== leftParenthesis$2) { + return } - subqueue += C_PAREN_OPEN$2; + subqueue += leftParenthesis$2; closed = true; index++; - break; + break } } @@ -26565,57 +26701,56 @@ function link$2(eat, value, silent) { index++; } - /* Eat the content closing. */ + // Eat the content closing. if (!closed) { - return; + return } content = queue; subvalue += queue + subqueue; index++; - /* Eat white-space. */ + // Eat white-space. while (index < length) { character = value.charAt(index); if (!isWhitespaceCharacter(character)) { - break; + break } subvalue += character; index++; } - /* Eat the URL. */ + // Eat the URL. character = value.charAt(index); - markers = commonmark ? COMMONMARK_LINK_MARKERS : LINK_MARKERS; queue = ''; beforeURL = subvalue; - if (character === C_LT$4) { + if (character === lessThan$5) { index++; - beforeURL += C_LT$4; + beforeURL += lessThan$5; while (index < length) { character = value.charAt(index); - if (character === C_GT$3) { - break; + if (character === greaterThan$3) { + break } - if (commonmark && character === '\n') { - return; + if (commonmark && character === lineFeed$16) { + return } queue += character; index++; } - if (value.charAt(index) !== C_GT$3) { - return; + if (value.charAt(index) !== greaterThan$3) { + return } - subvalue += C_LT$4 + queue + C_GT$3; + subvalue += lessThan$5 + queue + greaterThan$3; url = queue; index++; } else { @@ -26625,22 +26760,27 @@ function link$2(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (subqueue && own$5.call(markers, character)) { - break; + if ( + subqueue && + (character === quotationMark$2 || + character === apostrophe$2 || + (commonmark && character === leftParenthesis$2)) + ) { + break } if (isWhitespaceCharacter(character)) { if (!pedantic) { - break; + break } subqueue += character; } else { - if (character === C_PAREN_OPEN$2) { + if (character === leftParenthesis$2) { depth++; - } else if (character === C_PAREN_CLOSE$3) { + } else if (character === rightParenthesis$3) { if (depth === 0) { - break; + break } depth--; @@ -26649,8 +26789,8 @@ function link$2(eat, value, silent) { queue += subqueue; subqueue = ''; - if (character === C_BACKSLASH$3) { - queue += C_BACKSLASH$3; + if (character === backslash$5) { + queue += backslash$5; character = value.charAt(++index); } @@ -26665,14 +26805,14 @@ function link$2(eat, value, silent) { index = subvalue.length; } - /* Eat white-space. */ + // Eat white-space. queue = ''; while (index < length) { character = value.charAt(index); if (!isWhitespaceCharacter(character)) { - break; + break } queue += character; @@ -26682,29 +26822,32 @@ function link$2(eat, value, silent) { character = value.charAt(index); subvalue += queue; - /* Eat the title. */ - if (queue && own$5.call(markers, character)) { + // Eat the title. + if ( + queue && + (character === quotationMark$2 || + character === apostrophe$2 || + (commonmark && character === leftParenthesis$2)) + ) { index++; subvalue += character; queue = ''; - marker = markers[character]; + marker = character === leftParenthesis$2 ? rightParenthesis$3 : character; beforeTitle = subvalue; - /* In commonmark-mode, things are pretty easy: the - * marker cannot occur inside the title. - * - * Non-commonmark does, however, support nested - * delimiters. */ + // In commonmark-mode, things are pretty easy: the marker cannot occur + // inside the title. Non-commonmark does, however, support nested + // delimiters. if (commonmark) { while (index < length) { character = value.charAt(index); if (character === marker) { - break; + break } - if (character === C_BACKSLASH$3) { - queue += C_BACKSLASH$3; + if (character === backslash$5) { + queue += backslash$5; character = value.charAt(++index); } @@ -26715,7 +26858,7 @@ function link$2(eat, value, silent) { character = value.charAt(index); if (character !== marker) { - return; + return } title = queue; @@ -26726,7 +26869,7 @@ function link$2(eat, value, silent) { character = value.charAt(index); if (!isWhitespaceCharacter(character)) { - break; + break } subvalue += character; @@ -26747,10 +26890,10 @@ function link$2(eat, value, silent) { hasMarker = true; } else if (!hasMarker) { queue += character; - } else if (character === C_PAREN_CLOSE$3) { + } else if (character === rightParenthesis$3) { subvalue += queue + marker + subqueue; title = queue; - break; + break } else if (isWhitespaceCharacter(character)) { subqueue += character; } else { @@ -26764,18 +26907,20 @@ function link$2(eat, value, silent) { } } - if (value.charAt(index) !== C_PAREN_CLOSE$3) { - return; + if (value.charAt(index) !== rightParenthesis$3) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - subvalue += C_PAREN_CLOSE$3; + subvalue += rightParenthesis$3; - url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end); + url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end, { + nonTerminated: false + }); if (title) { beforeTitle = eat(beforeTitle).test().end; @@ -26796,32 +26941,35 @@ function link$2(eat, value, silent) { exit(); } - return eat(subvalue)(node); + return eat(subvalue)(node) } var reference_1 = reference; reference.locator = link; -var T_LINK = 'link'; -var T_IMAGE = 'image'; -var T_FOOTNOTE = 'footnote'; -var REFERENCE_TYPE_SHORTCUT = 'shortcut'; -var REFERENCE_TYPE_COLLAPSED = 'collapsed'; -var REFERENCE_TYPE_FULL = 'full'; -var C_CARET$1 = '^'; -var C_BACKSLASH$4 = '\\'; -var C_BRACKET_OPEN$4 = '['; -var C_BRACKET_CLOSE$4 = ']'; +var link$3 = 'link'; +var image$1 = 'image'; +var footnote = 'footnote'; +var shortcut = 'shortcut'; +var collapsed = 'collapsed'; +var full = 'full'; +var space$14 = ' '; +var exclamationMark$3 = '!'; +var leftSquareBracket$4 = '['; +var backslash$6 = '\\'; +var rightSquareBracket$4 = ']'; +var caret$2 = '^'; function reference(eat, value, silent) { var self = this; + var commonmark = self.options.commonmark; var character = value.charAt(0); var index = 0; var length = value.length; var subvalue = ''; var intro = ''; - var type = T_LINK; - var referenceType = REFERENCE_TYPE_SHORTCUT; + var type = link$3; + var referenceType = shortcut; var content; var identifier; var now; @@ -26831,51 +26979,53 @@ function reference(eat, value, silent) { var bracketed; var depth; - /* Check whether we’re eating an image. */ - if (character === '!') { - type = T_IMAGE; + // Check whether we’re eating an image. + if (character === exclamationMark$3) { + type = image$1; intro = character; character = value.charAt(++index); } - if (character !== C_BRACKET_OPEN$4) { - return; + if (character !== leftSquareBracket$4) { + return } index++; intro += character; queue = ''; - /* Check whether we’re eating a footnote. */ - if ( - self.options.footnotes && - type === T_LINK && - value.charAt(index) === C_CARET$1 - ) { - intro += C_CARET$1; + // Check whether we’re eating a footnote. + if (self.options.footnotes && value.charAt(index) === caret$2) { + // Exit if `![^` is found, so the `!` will be seen as text after this, + // and we’ll enter this function again when `[^` is found. + if (type === image$1) { + return + } + + intro += caret$2; index++; - type = T_FOOTNOTE; + type = footnote; } - /* Eat the text. */ + // Eat the text. depth = 0; while (index < length) { character = value.charAt(index); - if (character === C_BRACKET_OPEN$4) { + if (character === leftSquareBracket$4) { bracketed = true; depth++; - } else if (character === C_BRACKET_CLOSE$4) { + } else if (character === rightSquareBracket$4) { if (!depth) { - break; + break } depth--; } - if (character === C_BACKSLASH$4) { - queue += C_BACKSLASH$4; + if (character === backslash$6) { + queue += backslash$6; character = value.charAt(++index); } @@ -26887,29 +27037,34 @@ function reference(eat, value, silent) { content = queue; character = value.charAt(index); - if (character !== C_BRACKET_CLOSE$4) { - return; + if (character !== rightSquareBracket$4) { + return } index++; subvalue += character; queue = ''; - while (index < length) { - character = value.charAt(index); + if (!commonmark) { + // The original markdown syntax definition explicitly allows for whitespace + // between the link text and link label; commonmark departs from this, in + // part to improve support for shortcut reference links + while (index < length) { + character = value.charAt(index); - if (!isWhitespaceCharacter(character)) { - break; - } + if (!isWhitespaceCharacter(character)) { + break + } - queue += character; - index++; + queue += character; + index++; + } } character = value.charAt(index); - /* Inline footnotes cannot have an identifier. */ - if (type !== T_FOOTNOTE && character === C_BRACKET_OPEN$4) { + // Inline footnotes cannot have an identifier. + if (type !== footnote && character === leftSquareBracket$4) { identifier = ''; queue += character; index++; @@ -26917,12 +27072,12 @@ function reference(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (character === C_BRACKET_OPEN$4 || character === C_BRACKET_CLOSE$4) { - break; + if (character === leftSquareBracket$4 || character === rightSquareBracket$4) { + break } - if (character === C_BACKSLASH$4) { - identifier += C_BACKSLASH$4; + if (character === backslash$6) { + identifier += backslash$6; character = value.charAt(++index); } @@ -26932,8 +27087,8 @@ function reference(eat, value, silent) { character = value.charAt(index); - if (character === C_BRACKET_CLOSE$4) { - referenceType = identifier ? REFERENCE_TYPE_FULL : REFERENCE_TYPE_COLLAPSED; + if (character === rightSquareBracket$4) { + referenceType = identifier ? full : collapsed; queue += identifier + character; index++; } else { @@ -26944,58 +27099,59 @@ function reference(eat, value, silent) { queue = ''; } else { if (!content) { - return; + return } identifier = content; } - /* Brackets cannot be inside the identifier. */ - if (referenceType !== REFERENCE_TYPE_FULL && bracketed) { - return; + // Brackets cannot be inside the identifier. + if (referenceType !== full && bracketed) { + return } subvalue = intro + subvalue; - if (type === T_LINK && self.inLink) { - return null; + if (type === link$3 && self.inLink) { + return null } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - if (type === T_FOOTNOTE && content.indexOf(' ') !== -1) { + if (type === footnote && content.indexOf(space$14) !== -1) { return eat(subvalue)({ - type: 'footnote', + type: footnote, children: this.tokenizeInline(content, eat.now()) - }); + }) } now = eat.now(); now.column += intro.length; now.offset += intro.length; - identifier = referenceType === REFERENCE_TYPE_FULL ? identifier : content; + identifier = referenceType === full ? identifier : content; node = { type: type + 'Reference', - identifier: normalize_1(identifier) + identifier: normalize_1(identifier), + label: identifier }; - if (type === T_LINK || type === T_IMAGE) { + if (type === link$3 || type === image$1) { node.referenceType = referenceType; } - if (type === T_LINK) { + if (type === link$3) { exit = self.enterLink(); node.children = self.tokenizeInline(content, now); exit(); - } else if (type === T_IMAGE) { + } else if (type === image$1) { node.alt = self.decode.raw(self.unescape(content), now) || null; } - return eat(subvalue)(node); + return eat(subvalue)(node) } var strong = locate$8; @@ -27005,21 +27161,22 @@ function locate$8(value, fromIndex) { var underscore = value.indexOf('__', fromIndex); if (underscore === -1) { - return asterisk; + return asterisk } if (asterisk === -1) { - return underscore; + return underscore } - return underscore < asterisk ? underscore : asterisk; + return underscore < asterisk ? underscore : asterisk } var strong_1 = strong$2; strong$2.locator = strong; -var C_ASTERISK$2 = '*'; -var C_UNDERSCORE$2 = '_'; +var backslash$7 = '\\'; +var asterisk$2 = '*'; +var underscore$2 = '_'; function strong$2(eat, value, silent) { var self = this; @@ -27034,10 +27191,10 @@ function strong$2(eat, value, silent) { var prev; if ( - (character !== C_ASTERISK$2 && character !== C_UNDERSCORE$2) || + (character !== asterisk$2 && character !== underscore$2) || value.charAt(++index) !== character ) { - return; + return } pedantic = self.options.pedantic; @@ -27049,7 +27206,7 @@ function strong$2(eat, value, silent) { character = ''; if (pedantic && isWhitespaceCharacter(value.charAt(index))) { - return; + return } while (index < length) { @@ -27065,12 +27222,12 @@ function strong$2(eat, value, silent) { if (character !== marker) { if (!trim_1(queue)) { - return; + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } now = eat.now(); @@ -27080,11 +27237,11 @@ function strong$2(eat, value, silent) { return eat(subvalue + queue + subvalue)({ type: 'strong', children: self.tokenizeInline(queue, now) - }); + }) } } - if (!pedantic && character === '\\') { + if (!pedantic && character === backslash$7) { queue += character; character = value.charAt(++index); } @@ -27114,21 +27271,22 @@ function locate$10(value, fromIndex) { var underscore = value.indexOf('_', fromIndex); if (underscore === -1) { - return asterisk; + return asterisk } if (asterisk === -1) { - return underscore; + return underscore } - return underscore < asterisk ? underscore : asterisk; + return underscore < asterisk ? underscore : asterisk } var emphasis_1 = emphasis$2; emphasis$2.locator = emphasis; -var C_ASTERISK$3 = '*'; -var C_UNDERSCORE$3 = '_'; +var asterisk$3 = '*'; +var underscore$3 = '_'; +var backslash$8 = '\\'; function emphasis$2(eat, value, silent) { var self = this; @@ -27142,8 +27300,8 @@ function emphasis$2(eat, value, silent) { var length; var prev; - if (character !== C_ASTERISK$3 && character !== C_UNDERSCORE$3) { - return; + if (character !== asterisk$3 && character !== underscore$3) { + return } pedantic = self.options.pedantic; @@ -27155,7 +27313,7 @@ function emphasis$2(eat, value, silent) { character = ''; if (pedantic && isWhitespaceCharacter(value.charAt(index))) { - return; + return } while (index < length) { @@ -27167,17 +27325,17 @@ function emphasis$2(eat, value, silent) { if (character !== marker) { if (!trim_1(queue) || prev === marker) { - return; + return } - if (!pedantic && marker === C_UNDERSCORE$3 && isWordCharacter(character)) { + if (!pedantic && marker === underscore$3 && isWordCharacter(character)) { queue += marker; - continue; + continue } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } now = eat.now(); @@ -27187,13 +27345,13 @@ function emphasis$2(eat, value, silent) { return eat(subvalue + queue + marker)({ type: 'emphasis', children: self.tokenizeInline(queue, now) - }); + }) } queue += marker; } - if (!pedantic && character === '\\') { + if (!pedantic && character === backslash$8) { queue += character; character = value.charAt(++index); } @@ -27206,14 +27364,14 @@ function emphasis$2(eat, value, silent) { var _delete = locate$12; function locate$12(value, fromIndex) { - return value.indexOf('~~', fromIndex); + return value.indexOf('~~', fromIndex) } var _delete$2 = strikethrough; strikethrough.locator = _delete; -var C_TILDE$1 = '~'; -var DOUBLE = '~~'; +var tilde$2 = '~'; +var fence = '~~'; function strikethrough(eat, value, silent) { var self = this; @@ -27227,11 +27385,11 @@ function strikethrough(eat, value, silent) { if ( !self.options.gfm || - value.charAt(0) !== C_TILDE$1 || - value.charAt(1) !== C_TILDE$1 || + value.charAt(0) !== tilde$2 || + value.charAt(1) !== tilde$2 || isWhitespaceCharacter(value.charAt(2)) ) { - return; + return } index = 1; @@ -27244,19 +27402,19 @@ function strikethrough(eat, value, silent) { character = value.charAt(index); if ( - character === C_TILDE$1 && - previous === C_TILDE$1 && + character === tilde$2 && + previous === tilde$2 && (!preceding || !isWhitespaceCharacter(preceding)) ) { /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } - return eat(DOUBLE + subvalue + DOUBLE)({ + return eat(fence + subvalue + fence)({ type: 'delete', children: self.tokenizeInline(subvalue, now) - }); + }) } subvalue += previous; @@ -27268,15 +27426,14 @@ function strikethrough(eat, value, silent) { var codeInline = locate$14; function locate$14(value, fromIndex) { - return value.indexOf('`', fromIndex); + return value.indexOf('`', fromIndex) } var codeInline$2 = inlineCode; inlineCode.locator = codeInline; -var C_TICK$3 = '`'; +var graveAccent$3 = '`'; -/* Tokenise inline code. */ function inlineCode(eat, value, silent) { var length = value.length; var index = 0; @@ -27292,16 +27449,16 @@ function inlineCode(eat, value, silent) { var next; while (index < length) { - if (value.charAt(index) !== C_TICK$3) { - break; + if (value.charAt(index) !== graveAccent$3) { + break } - queue += C_TICK$3; + queue += graveAccent$3; index++; } if (!queue) { - return; + return } subvalue = queue; @@ -27314,7 +27471,7 @@ function inlineCode(eat, value, silent) { character = next; next = value.charAt(index + 1); - if (character === C_TICK$3) { + if (character === graveAccent$3) { count++; tickQueue += character; } else { @@ -27322,11 +27479,11 @@ function inlineCode(eat, value, silent) { queue += character; } - if (count && next !== C_TICK$3) { + if (count && next !== graveAccent$3) { if (count === openingCount) { subvalue += queue + tickQueue; found = true; - break; + break } queue += tickQueue; @@ -27338,7 +27495,7 @@ function inlineCode(eat, value, silent) { if (!found) { if (openingCount % 2 !== 0) { - return; + return } queue = ''; @@ -27346,7 +27503,7 @@ function inlineCode(eat, value, silent) { /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } contentQueue = ''; @@ -27359,7 +27516,7 @@ function inlineCode(eat, value, silent) { if (isWhitespaceCharacter(character)) { subqueue += character; - continue; + continue } if (subqueue) { @@ -27373,10 +27530,7 @@ function inlineCode(eat, value, silent) { contentQueue += character; } - return eat(subvalue)({ - type: 'inlineCode', - value: contentQueue - }); + return eat(subvalue)({type: 'inlineCode', value: contentQueue}) } var _break = locate$16; @@ -27386,19 +27540,21 @@ function locate$16(value, fromIndex) { while (index > fromIndex) { if (value.charAt(index - 1) !== ' ') { - break; + break } index--; } - return index; + return index } var _break$2 = hardBreak; hardBreak.locator = _break; -var MIN_BREAK_LENGTH = 2; +var space$15 = ' '; +var lineFeed$17 = '\n'; +var minBreakLength = 2; function hardBreak(eat, value, silent) { var length = value.length; @@ -27409,23 +27565,23 @@ function hardBreak(eat, value, silent) { while (++index < length) { character = value.charAt(index); - if (character === '\n') { - if (index < MIN_BREAK_LENGTH) { - return; + if (character === lineFeed$17) { + if (index < minBreakLength) { + return } /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } queue += character; - return eat(queue)({type: 'break'}); + return eat(queue)({type: 'break'}) } - if (character !== ' ') { - return; + if (character !== space$15) { + return } queue += character; @@ -27449,7 +27605,7 @@ function text(eat, value, silent) { /* istanbul ignore if - never used (yet) */ if (silent) { - return true; + return true } methods = self.inlineMethods; @@ -27462,7 +27618,7 @@ function text(eat, value, silent) { name = methods[index]; if (name === 'text' || !tokenizers[name]) { - continue; + continue } tokenizer = tokenizers[name].locator; @@ -27481,12 +27637,11 @@ function text(eat, value, silent) { subvalue = value.slice(0, min); now = eat.now(); - self.decode(subvalue, now, function (content, position, source) { - eat(source || content)({ - type: 'text', - value: content - }); - }); + self.decode(subvalue, now, handler); + + function handler(content, position, source) { + eat(source || content)({type: 'text', value: content}); + } } var parser = Parser; @@ -27507,31 +27662,30 @@ function Parser(doc, file) { this.decode = decode$1(this); } -var proto$3 = Parser.prototype; +var proto$5 = Parser.prototype; -/* Expose core. */ -proto$3.setOptions = setOptions_1; -proto$3.parse = parse_1$3; +// Expose core. +proto$5.setOptions = setOptions_1; +proto$5.parse = parse_1$3; -/* Expose `defaults`. */ -proto$3.options = defaults$2; +// Expose `defaults`. +proto$5.options = defaults$2; -/* Enter and exit helpers. */ -proto$3.exitStart = stateToggle('atStart', true); -proto$3.enterList = stateToggle('inList', false); -proto$3.enterLink = stateToggle('inLink', false); -proto$3.enterBlock = stateToggle('inBlock', false); +// Enter and exit helpers. +proto$5.exitStart = stateToggle('atStart', true); +proto$5.enterList = stateToggle('inList', false); +proto$5.enterLink = stateToggle('inLink', false); +proto$5.enterBlock = stateToggle('inBlock', false); -/* Nodes that can interupt a paragraph: - * - * ```markdown - * A paragraph, followed by a thematic break. - * ___ - * ``` - * - * In the above example, the thematic break “interupts” - * the paragraph. */ -proto$3.interruptParagraph = [ +// Nodes that can interupt a paragraph: +// +// ```markdown +// A paragraph, followed by a thematic break. +// ___ +// ``` +// +// In the above example, the thematic break “interupts” the paragraph. +proto$5.interruptParagraph = [ ['thematicBreak'], ['atxHeading'], ['fencedCode'], @@ -27542,32 +27696,31 @@ proto$3.interruptParagraph = [ ['footnote', {commonmark: false}] ]; -/* Nodes that can interupt a list: - * - * ```markdown - * - One - * ___ - * ``` - * - * In the above example, the thematic break “interupts” - * the list. */ -proto$3.interruptList = [ +// Nodes that can interupt a list: +// +// ```markdown +// - One +// ___ +// ``` +// +// In the above example, the thematic break “interupts” the list. +proto$5.interruptList = [ + ['atxHeading', {pedantic: false}], ['fencedCode', {pedantic: false}], ['thematicBreak', {pedantic: false}], ['definition', {commonmark: false}], ['footnote', {commonmark: false}] ]; -/* Nodes that can interupt a blockquote: - * - * ```markdown - * > A paragraph. - * ___ - * ``` - * - * In the above example, the thematic break “interupts” - * the blockquote. */ -proto$3.interruptBlockquote = [ +// Nodes that can interupt a blockquote: +// +// ```markdown +// > A paragraph. +// ___ +// ``` +// +// In the above example, the thematic break “interupts” the blockquote. +proto$5.interruptBlockquote = [ ['indentedCode', {commonmark: true}], ['fencedCode', {commonmark: true}], ['atxHeading', {commonmark: true}], @@ -27579,8 +27732,8 @@ proto$3.interruptBlockquote = [ ['footnote', {commonmark: false}] ]; -/* Handlers. */ -proto$3.blockTokenizers = { +// Handlers. +proto$5.blockTokenizers = { newline: newline_1, indentedCode: codeIndented, fencedCode: codeFenced, @@ -27596,7 +27749,7 @@ proto$3.blockTokenizers = { paragraph: paragraph_1 }; -proto$3.inlineTokenizers = { +proto$5.inlineTokenizers = { escape: _escape$2, autoLink: autoLink_1, url: url_1, @@ -27611,16 +27764,16 @@ proto$3.inlineTokenizers = { text: text_1 }; -/* Expose precedence. */ -proto$3.blockMethods = keys$1(proto$3.blockTokenizers); -proto$3.inlineMethods = keys$1(proto$3.inlineTokenizers); +// Expose precedence. +proto$5.blockMethods = keys$1(proto$5.blockTokenizers); +proto$5.inlineMethods = keys$1(proto$5.inlineTokenizers); -/* Tokenizers. */ -proto$3.tokenizeBlock = tokenizer('block'); -proto$3.tokenizeInline = tokenizer('inline'); -proto$3.tokenizeFactory = tokenizer; +// Tokenizers. +proto$5.tokenizeBlock = tokenizer('block'); +proto$5.tokenizeInline = tokenizer('inline'); +proto$5.tokenizeFactory = tokenizer; -/* Get all keys in `value`. */ +// Get all keys in `value`. function keys$1(value) { var result = []; var key; @@ -27629,55 +27782,55 @@ function keys$1(value) { result.push(key); } - return result; + return result } var remarkParse = parse$9; parse$9.Parser = parser; function parse$9(options) { + var settings = this.data('settings'); var Local = unherit_1(parser); - Local.prototype.options = immutable(Local.prototype.options, this.data('settings'), options); + + Local.prototype.options = immutable(Local.prototype.options, settings, options); + this.Parser = Local; } -var returner_1 = returner; +var identity_1 = identity$1; -function returner(value) { - return value; +function identity$1(value) { + return value } var enterLinkReference = enter; -/* Shortcut and collapsed link references need no escaping - * and encoding during the processing of child nodes (it - * must be implied from identifier). - * - * This toggler turns encoding and escaping off for shortcut - * and collapsed references. - * - * Implies `enterLink`. - */ +// Shortcut and collapsed link references need no escaping and encoding during +// the processing of child nodes (it must be implied from identifier). +// +// This toggler turns encoding and escaping off for shortcut and collapsed +// references. +// +// Implies `enterLink`. function enter(compiler, node) { var encode = compiler.encode; var escape = compiler.escape; - var exit = compiler.enterLink(); + var exitLink = compiler.enterLink(); - if ( - node.referenceType !== 'shortcut' && - node.referenceType !== 'collapsed' - ) { - return exit; + if (node.referenceType !== 'shortcut' && node.referenceType !== 'collapsed') { + return exitLink } - compiler.escape = returner_1; - compiler.encode = returner_1; + compiler.escape = identity_1; + compiler.encode = identity_1; - return function () { + return exit + + function exit() { compiler.encode = encode; compiler.escape = escape; - exit(); - }; + exitLink(); + } } var defaults$5 = { @@ -27704,7 +27857,7 @@ var defaults$5 = { }; function stringLength(value) { - return value.length; + return value.length } const nbsp$2 = " "; @@ -27863,7 +28016,7 @@ const Prime$1 = "″"; const oline$1 = "‾"; const frasl$1 = "⁄"; const weierp$1 = "℘"; -const image$1 = "ℑ"; +const image$2 = "ℑ"; const real$1 = "ℜ"; const trade$1 = "™"; const alefsym$1 = "ℵ"; @@ -27937,7 +28090,7 @@ const Scaron$1 = "Š"; const scaron$1 = "š"; const Yuml$1 = "Ÿ"; const circ$1 = "ˆ"; -const tilde$1 = "˜"; +const tilde$3 = "˜"; const ensp$1 = " "; const emsp$1 = " "; const thinsp$1 = " "; @@ -28116,7 +28269,7 @@ var index$5 = { oline: oline$1, frasl: frasl$1, weierp: weierp$1, - image: image$1, + image: image$2, real: real$1, trade: trade$1, alefsym: alefsym$1, @@ -28190,7 +28343,7 @@ var index$5 = { scaron: scaron$1, Yuml: Yuml$1, circ: circ$1, - tilde: tilde$1, + tilde: tilde$3, ensp: ensp$1, emsp: emsp$1, thinsp: thinsp$1, @@ -28371,7 +28524,7 @@ var characterEntitiesHtml4 = Object.freeze({ oline: oline$1, frasl: frasl$1, weierp: weierp$1, - image: image$1, + image: image$2, real: real$1, trade: trade$1, alefsym: alefsym$1, @@ -28445,7 +28598,7 @@ var characterEntitiesHtml4 = Object.freeze({ scaron: scaron$1, Yuml: Yuml$1, circ: circ$1, - tilde: tilde$1, + tilde: tilde$3, ensp: ensp$1, emsp: emsp$1, thinsp: thinsp$1, @@ -28500,7 +28653,7 @@ var own$6 = {}.hasOwnProperty; var escapes$2 = ['"', "'", '<', '>', '&', '`']; /* Map of characters to names. */ -var characters$1 = construct(); +var characters = construct(); /* Default escapes. */ var defaultEscapes = toExpression(escapes$2); @@ -28563,8 +28716,8 @@ function one$1(char, next, options) { var named; var numeric; - if ((shortest || options.useNamedReferences) && own$6.call(characters$1, char)) { - named = toNamed(characters$1[char], next, omit, options.attribute); + if ((shortest || options.useNamedReferences) && own$6.call(characters, char)) { + named = toNamed(characters[char], next, omit, options.attribute); } if (shortest || !named) { @@ -28627,42 +28780,75 @@ var isAlphanumeric = function (str) { var entityPrefixLength = length; -/* Returns the length of HTML entity that is a prefix of - * the given string (excluding the ampersand), 0 if it - * does not start with an entity. */ +var ampersand = '&'; + +// Returns the length of HTML entity that is a prefix of the given string +// (excluding the ampersand), 0 if it does not start with an entity. function length(value) { var prefix; - /* istanbul ignore if - Currently also tested for at - * implemention, but we keep it here because that’s - * proper. */ - if (value.charAt(0) !== '&') { - return 0; + /* istanbul ignore if - Currently also tested for at implemention, but we + * keep it here because that’s proper. */ + if (value.charAt(0) !== ampersand) { + return 0 } - prefix = value.split('&', 2).join('&'); + prefix = value.split(ampersand, 2).join(ampersand); - return prefix.length - parseEntities_1(prefix).length; + return prefix.length - parseEntities_1(prefix).length } var _escape$4 = factory$5; -var BACKSLASH = '\\'; -var BULLETS = ['*', '-', '+']; -var ALLIGNMENT = [':', '-', ' ', '|']; -var entities$1 = {'<': '<', ':': ':', '&': '&', '|': '|', '~': '~'}; +var tab$14 = '\t'; +var lineFeed$18 = '\n'; +var space$16 = ' '; +var numberSign$1 = '#'; +var ampersand$1 = '&'; +var leftParenthesis$3 = '('; +var rightParenthesis$4 = ')'; +var asterisk$4 = '*'; +var plusSign$1 = '+'; +var dash$5 = '-'; +var dot$3 = '.'; +var colon$5 = ':'; +var lessThan$6 = '<'; +var greaterThan$4 = '>'; +var leftSquareBracket$5 = '['; +var backslash$9 = '\\'; +var rightSquareBracket$5 = ']'; +var underscore$4 = '_'; +var graveAccent$4 = '`'; +var verticalBar$1 = '|'; +var tilde$4 = '~'; +var exclamationMark$4 = '!'; + +var entities$1 = { + '<': '<', + ':': ':', + '&': '&', + '|': '|', + '~': '~' +}; + +var shortcut$1 = 'shortcut'; +var mailto$2 = 'mailto'; +var https$1 = 'https'; +var http$1 = 'http'; + +var blankExpression = /\n\s*$/; -/* Factory to escape characters. */ +// Factory to escape characters. function factory$5(options) { - return escape; + return escape - /* Escape punctuation characters in a node's value. */ + // Escape punctuation characters in a node’s value. function escape(value, node, parent) { var self = this; var gfm = options.gfm; var commonmark = options.commonmark; var pedantic = options.pedantic; - var markers = commonmark ? ['.', ')'] : ['.']; + var markers = commonmark ? [dot$3, rightParenthesis$4] : [dot$3]; var siblings = parent && parent.children; var index = siblings && siblings.indexOf(node); var prev = siblings && siblings[index - 1]; @@ -28680,14 +28866,10 @@ function factory$5(options) { var replace; if (prev) { - afterNewLine = text$1(prev) && /\n\s*$/.test(prev.value); + afterNewLine = text$1(prev) && blankExpression.test(prev.value); } else { - afterNewLine = !parent || parent.type === 'root' || parent.type === 'paragraph'; - } - - function one(character) { - return escapable.indexOf(character) === -1 ? - entities$1[character] : BACKSLASH + character; + afterNewLine = + !parent || parent.type === 'root' || parent.type === 'paragraph'; } while (++position < length) { @@ -28697,35 +28879,36 @@ function factory$5(options) { if (character === '\n') { afterNewLine = true; } else if ( - character === BACKSLASH || - character === '`' || - character === '*' || - character === '[' || - character === '<' || - (character === '&' && entityPrefixLength(value.slice(position)) > 0) || - (character === ']' && self.inLink) || - (gfm && character === '~' && value.charAt(position + 1) === '~') || - (gfm && character === '|' && (self.inTable || alignment(value, position))) || - ( - character === '_' && - /* Delegate leading/trailing underscores - * to the multinode version below. */ + character === backslash$9 || + character === graveAccent$4 || + character === asterisk$4 || + (character === exclamationMark$4 && + value.charAt(position + 1) === leftSquareBracket$5) || + character === leftSquareBracket$5 || + character === lessThan$6 || + (character === ampersand$1 && entityPrefixLength(value.slice(position)) > 0) || + (character === rightSquareBracket$5 && self.inLink) || + (gfm && character === tilde$4 && value.charAt(position + 1) === tilde$4) || + (gfm && + character === verticalBar$1 && + (self.inTable || alignment(value, position))) || + (character === underscore$4 && + // Delegate leading/trailing underscores to the multinode version below. position > 0 && position < length - 1 && - ( - pedantic || - !isAlphanumeric(value.charAt(position - 1)) || - !isAlphanumeric(value.charAt(position + 1)) - ) - ) || - (gfm && !self.inLink && character === ':' && protocol(queue.join(''))) + (pedantic || + !isAlphanumeric(value.charAt(position - 1)) || + !isAlphanumeric(value.charAt(position + 1)))) || + (gfm && !self.inLink && character === colon$5 && protocol(queue.join(''))) ) { replace = true; } else if (afterNewLine) { if ( - character === '>' || - character === '#' || - BULLETS.indexOf(character) !== -1 + character === greaterThan$4 || + character === numberSign$1 || + character === asterisk$4 || + character === dash$5 || + character === plusSign$1 ) { replace = true; } else if (isDecimal(character)) { @@ -28733,7 +28916,7 @@ function factory$5(options) { while (offset < length) { if (!isDecimal(value.charAt(offset))) { - break; + break } offset++; @@ -28742,7 +28925,7 @@ function factory$5(options) { if (markers.indexOf(value.charAt(offset)) !== -1) { next = value.charAt(offset + 1); - if (!next || next === ' ' || next === '\t' || next === '\n') { + if (!next || next === space$16 || next === tab$14 || next === lineFeed$18) { queue.push(value.slice(position, offset)); position = offset; character = value.charAt(position); @@ -28759,135 +28942,157 @@ function factory$5(options) { queue.push(replace ? one(character) : character); } - /* Multi-node versions. */ + // Multi-node versions. if (siblings && text$1(node)) { - /* Check for an opening parentheses after a - * link-reference (which can be joined by - * white-space). */ - if (prev && prev.referenceType === 'shortcut') { + // Check for an opening parentheses after a link-reference (which can be + // joined by white-space). + if (prev && prev.referenceType === shortcut$1) { position = -1; length = escaped.length; while (++position < length) { character = escaped[position]; - if (character === ' ' || character === '\t') { - continue; + if (character === space$16 || character === tab$14) { + continue } - if (character === '(' || character === ':') { + if (character === leftParenthesis$3 || character === colon$5) { escaped[position] = one(character); } - break; + break } - /* If the current node is all spaces / tabs, - * preceded by a shortcut, and followed by - * a text starting with `(`, escape it. */ + // If the current node is all spaces / tabs, preceded by a shortcut, + // and followed by a text starting with `(`, escape it. if ( text$1(next) && position === length && - next.value.charAt(0) === '(' + next.value.charAt(0) === leftParenthesis$3 ) { - escaped.push(BACKSLASH); + escaped.push(backslash$9); } } - /* Ensure non-auto-links are not seen as links. - * This pattern needs to check the preceding - * nodes too. */ + // Ensure non-auto-links are not seen as links. This pattern needs to + // check the preceding nodes too. if ( gfm && !self.inLink && text$1(prev) && - value.charAt(0) === ':' && + value.charAt(0) === colon$5 && protocol(prev.value.slice(-6)) ) { - escaped[0] = one(':'); + escaped[0] = one(colon$5); } - /* Escape ampersand if it would otherwise - * start an entity. */ + // Escape ampersand if it would otherwise start an entity. if ( text$1(next) && - value.charAt(length - 1) === '&' && - entityPrefixLength('&' + next.value) !== 0 + value.charAt(length - 1) === ampersand$1 && + entityPrefixLength(ampersand$1 + next.value) !== 0 + ) { + escaped[escaped.length - 1] = one(ampersand$1); + } + + // Escape exclamation marks immediately followed by links. + if ( + next && + next.type === 'link' && + value.charAt(length - 1) === exclamationMark$4 ) { - escaped[escaped.length - 1] = one('&'); + escaped[escaped.length - 1] = one(exclamationMark$4); } - /* Escape double tildes in GFM. */ + // Escape double tildes in GFM. if ( gfm && text$1(next) && - value.charAt(length - 1) === '~' && - next.value.charAt(0) === '~' + value.charAt(length - 1) === tilde$4 && + next.value.charAt(0) === tilde$4 ) { - escaped.splice(escaped.length - 1, 0, BACKSLASH); + escaped.splice(escaped.length - 1, 0, backslash$9); } - /* Escape underscores, but not mid-word (unless - * in pedantic mode). */ + // Escape underscores, but not mid-word (unless in pedantic mode). wordCharBefore = text$1(prev) && isAlphanumeric(prev.value.slice(-1)); wordCharAfter = text$1(next) && isAlphanumeric(next.value.charAt(0)); if (length === 1) { - if (value === '_' && (pedantic || !wordCharBefore || !wordCharAfter)) { - escaped.unshift(BACKSLASH); + if ( + value === underscore$4 && + (pedantic || !wordCharBefore || !wordCharAfter) + ) { + escaped.unshift(backslash$9); } } else { if ( - value.charAt(0) === '_' && + value.charAt(0) === underscore$4 && (pedantic || !wordCharBefore || !isAlphanumeric(value.charAt(1))) ) { - escaped.unshift(BACKSLASH); + escaped.unshift(backslash$9); } if ( - value.charAt(length - 1) === '_' && - (pedantic || !wordCharAfter || !isAlphanumeric(value.charAt(length - 2))) + value.charAt(length - 1) === underscore$4 && + (pedantic || + !wordCharAfter || + !isAlphanumeric(value.charAt(length - 2))) ) { - escaped.splice(escaped.length - 1, 0, BACKSLASH); + escaped.splice(escaped.length - 1, 0, backslash$9); } } } - return escaped.join(''); + return escaped.join('') + + function one(character) { + return escapable.indexOf(character) === -1 + ? entities$1[character] + : backslash$9 + character + } } } -/* Check if `index` in `value` is inside an alignment row. */ +// Check if `index` in `value` is inside an alignment row. function alignment(value, index) { - var start = value.lastIndexOf('\n', index); - var end = value.indexOf('\n', index); + var start = value.lastIndexOf(lineFeed$18, index); + var end = value.indexOf(lineFeed$18, index); + var char; - start = start === -1 ? -1 : start; end = end === -1 ? value.length : end; while (++start < end) { - if (ALLIGNMENT.indexOf(value.charAt(start)) === -1) { - return false; + char = value.charAt(start); + + if ( + char !== colon$5 && + char !== dash$5 && + char !== space$16 && + char !== verticalBar$1 + ) { + return false } } - return true; + return true } -/* Check if `node` is a text node. */ +// Check if `node` is a text node. function text$1(node) { - return node && node.type === 'text'; + return node && node.type === 'text' } -/* Check if `value` ends in a protocol. */ +// Check if `value` ends in a protocol. function protocol(value) { var val = value.slice(-6).toLowerCase(); - return val === 'mailto' || val.slice(-5) === 'https' || val.slice(-4) === 'http'; + return val === mailto$2 || val.slice(-5) === https$1 || val.slice(-4) === http$1 } var setOptions_1$2 = setOptions$1; -/* Map of applicable enum's. */ +// Map of applicable enums. var maps = { entities: {true: true, false: true, numbers: true, escape: true}, bullet: {'*': true, '-': true, '+': true}, @@ -28898,7 +29103,7 @@ var maps = { fence: {'`': true, '~': true} }; -/* Expose `validate`. */ +// Expose `validate`. var validate = { boolean: validateBoolean, string: validateString, @@ -28906,8 +29111,7 @@ var validate = { function: validateFunction }; -/* Set options. Does not overwrite previously set - * options. */ +// Set options. Does not overwrite previously set options. function setOptions$1(options) { var self = this; var current = self.options; @@ -28919,7 +29123,7 @@ function setOptions$1(options) { } else if (typeof options === 'object') { options = immutable(options); } else { - throw new Error('Invalid value `' + options + '` for setting `options`'); + throw new Error('Invalid value `' + options + '` for setting `options`') } for (key in defaults$5) { @@ -28937,18 +29141,11 @@ function setOptions$1(options) { self.options = options; - return self; -} - -/* Throw an exception with in its `message` `value` - * and `name`. */ -function raise(value, name) { - throw new Error('Invalid value `' + value + '` for setting `' + name + '`'); + return self } -/* Validate a value to be boolean. Defaults to `def`. - * Raises an exception with `context[name]` when not - * a boolean. */ +// Validate a value to be boolean. Defaults to `def`. Raises an exception with +// `context[name]` when not a boolean. function validateBoolean(context, name, def) { var value = context[name]; @@ -28963,9 +29160,8 @@ function validateBoolean(context, name, def) { context[name] = value; } -/* Validate a value to be boolean. Defaults to `def`. - * Raises an exception with `context[name]` when not - * a boolean. */ +// Validate a value to be boolean. Defaults to `def`. Raises an exception with +// `context[name]` when not a boolean. function validateNumber(context, name, def) { var value = context[name]; @@ -28980,9 +29176,8 @@ function validateNumber(context, name, def) { context[name] = value; } -/* Validate a value to be in `map`. Defaults to `def`. - * Raises an exception with `context[name]` when not - * in `map`. */ +// Validate a value to be in `map`. Defaults to `def`. Raises an exception +// with `context[name]` when not in `map`. function validateString(context, name, def, map) { var value = context[name]; @@ -28999,9 +29194,8 @@ function validateString(context, name, def, map) { context[name] = value; } -/* Validate a value to be function. Defaults to `def`. - * Raises an exception with `context[name]` when not - * a function. */ +// Validate a value to be function. Defaults to `def`. Raises an exception +// with `context[name]` when not a function. function validateFunction(context, name, def) { var value = context[name]; @@ -29016,17 +29210,15 @@ function validateFunction(context, name, def) { context[name] = value; } -/* Factory to encode HTML entities. - * Creates a no-operation function when `type` is - * `'false'`, a function which encodes using named - * references when `type` is `'true'`, and a function - * which encodes using numbered references when `type` is - * `'numbers'`. */ +// Factory to encode HTML entities. Creates a no-operation function when +// `type` is `'false'`, a function which encodes using named references when +// `type` is `'true'`, and a function which encodes using numbered references +// when `type` is `'numbers'`. function encodeFactory(type) { var options = {}; if (type === 'false') { - return returner_1; + return identity_1 } if (type === 'true') { @@ -29038,14 +29230,19 @@ function encodeFactory(type) { options.useNamedReferences = true; } - return wrapped; + return wrapped - /* Encode HTML entities using the bound options. */ + // Encode HTML entities using the bound options. function wrapped(value) { - return stringifyEntities(value, options); + return stringifyEntities(value, options) } } +// Throw an exception with in its `message` `value` and `name`. +function raise(value, name) { + throw new Error('Invalid value `' + value + '` for setting `' + name + '`') +} + var mdastUtilCompact = compact; /* Make an MDAST tree compact by merging adjacent text nodes. */ @@ -29106,9 +29303,9 @@ function mergeable$1(node, commonmark) { var compile_1 = compile$2; -/* Stringify the given tree. */ +// Stringify the given tree. function compile$2() { - return this.visit(mdastUtilCompact(this.tree, this.options.commonmark)); + return this.visit(mdastUtilCompact(this.tree, this.options.commonmark)) } var one_1 = one$2; @@ -29117,23 +29314,22 @@ function one$2(node, parent) { var self = this; var visitors = self.visitors; - /* Fail on unknown nodes. */ + // Fail on unknown nodes. if (typeof visitors[node.type] !== 'function') { self.file.fail( new Error( - 'Missing compiler for node of type `' + - node.type + '`: `' + node + '`' + 'Missing compiler for node of type `' + node.type + '`: `' + node + '`' ), node ); } - return visitors[node.type].call(self, node, parent); + return visitors[node.type].call(self, node, parent) } var all_1 = all; -/* Visit all children of `parent`. */ +// Visit all children of `parent`. function all(parent) { var self = this; var children = parent.children; @@ -29145,70 +29341,83 @@ function all(parent) { results[index] = self.visit(children[index], parent); } - return results; + return results } var block_1 = block$1; -/* Stringify a block node with block children (e.g., `root` - * or `blockquote`). - * Knows about code following a list, or adjacent lists - * with similar bullets, and places an extra newline - * between them. */ +var lineFeed$19 = '\n'; + +var blank$1 = lineFeed$19 + lineFeed$19; +var triple = blank$1 + lineFeed$19; +var comment$1 = blank$1 + '' + blank$1; + +// Stringify a block node with block children (e.g., `root` or `blockquote`). +// Knows about code following a list, or adjacent lists with similar bullets, +// and places an extra line feed between them. function block$1(node) { var self = this; + var options = self.options; + var fences = options.fences; + var gap = options.commonmark ? comment$1 : triple; var values = []; var children = node.children; var length = children.length; var index = -1; - var child; var prev; + var child; while (++index < length) { + prev = child; child = children[index]; if (prev) { - /* Duplicate nodes, such as a list - * directly following another list, - * often need multiple new lines. - * - * Additionally, code blocks following a list - * might easily be mistaken for a paragraph - * in the list itself. */ - if (child.type === prev.type && prev.type === 'list') { - values.push(prev.ordered === child.ordered ? '\n\n\n' : '\n\n'); - } else if (prev.type === 'list' && child.type === 'code' && !child.lang) { - values.push('\n\n\n'); + // A list preceding another list that are equally ordered, or a + // list preceding an indented code block, need a gap between them, + // so as not to see them as one list, or content of the list, + // respectively. + // + // In commonmark, only something that breaks both up can do that, + // so we opt for an empty, invisible comment. In other flavours, + // two blank lines are fine. + if ( + prev.type === 'list' && + ((child.type === 'list' && prev.ordered === child.ordered) || + (child.type === 'code' && (!child.lang && !fences))) + ) { + values.push(gap); } else { - values.push('\n\n'); + values.push(blank$1); } } values.push(self.visit(child, node)); - - prev = child; } - return values.join(''); + return values.join('') } var orderedItems_1 = orderedItems; -/* Visit ordered list items. - * - * Starts the list with - * `node.start` and increments each following list item - * bullet by one: - * - * 2. foo - * 3. bar - * - * In `incrementListMarker: false` mode, does not increment - * each marker and stays on `node.start`: - * - * 1. foo - * 1. bar - */ +var lineFeed$20 = '\n'; +var dot$4 = '.'; + +var blank$2 = lineFeed$20 + lineFeed$20; + +// Visit ordered list items. +// +// Starts the list with +// `node.start` and increments each following list item +// bullet by one: +// +// 2. foo +// 3. bar +// +// In `incrementListMarker: false` mode, does not increment +// each marker and stays on `node.start`: +// +// 1. foo +// 1. bar function orderedItems(node) { var self = this; var fn = self.visitors.listItem; @@ -29220,19 +29429,23 @@ function orderedItems(node) { var index = -1; var bullet; + start = start == null ? 1 : start; + while (++index < length) { - bullet = (increment ? start + index : start) + '.'; + bullet = (increment ? start + index : start) + dot$4; values[index] = fn.call(self, children[index], node, index, bullet); } - return values.join('\n'); + return values.join(node.spread ? blank$2 : lineFeed$20) } var unorderedItems_1 = unorderedItems; -/* Visit unordered list items. - * Uses `options.bullet` as each item's bullet. - */ +var lineFeed$21 = '\n'; + +var blank$3 = lineFeed$21 + lineFeed$21; + +// Visit unordered list items. Uses `options.bullet` as each item’s bullet. function unorderedItems(node) { var self = this; var bullet = self.options.bullet; @@ -29246,52 +29459,66 @@ function unorderedItems(node) { values[index] = fn.call(self, children[index], node, index, bullet); } - return values.join('\n'); + return values.join(node.spread ? blank$3 : lineFeed$21) } var root_1 = root; -/* Stringify a root. - * Adds a final newline to ensure valid POSIX files. */ +var lineFeed$22 = '\n'; + +// Stringify a root. +// Adds a final newline to ensure valid POSIX files. */ function root(node) { - return this.block(node) + '\n'; + return this.block(node) + lineFeed$22 } var text_1$2 = text$2; -/* Stringify text. - * Supports named entities in `settings.encode: true` mode: - * - * AT&T - * - * Supports numbered entities in `settings.encode: numbers` - * mode: - * - * AT&T - */ +// Stringify text. +// Supports named entities in `settings.encode: true` mode: +// +// ```markdown +// AT&T +// ``` +// +// Supports numbered entities in `settings.encode: numbers` mode: +// +// ```markdown +// AT&T +// ``` function text$2(node, parent) { - return this.encode(this.escape(node.value, node, parent), node); + return this.encode(this.escape(node.value, node, parent), node) } var heading_1 = heading; -/* Stringify a heading. - * - * In `setext: true` mode and when `depth` is smaller than - * three, creates a setext header: - * - * Foo - * === - * - * Otherwise, an ATX header is generated: - * - * ### Foo - * - * In `closeAtx: true` mode, the header is closed with - * hashes: - * - * ### Foo ### - */ +var lineFeed$23 = '\n'; +var space$17 = ' '; +var numberSign$2 = '#'; +var dash$6 = '-'; +var equalsTo$1 = '='; + +// Stringify a heading. +// +// In `setext: true` mode and when `depth` is smaller than three, creates a +// setext header: +// +// ```markdown +// Foo +// === +// ``` +// +// Otherwise, an ATX header is generated: +// +// ```markdown +// ### Foo +// ``` +// +// In `closeAtx: true` mode, the header is closed with hashes: +// +// ```markdown +// ### Foo ### +// ``` function heading(node) { var self = this; var depth = node.depth; @@ -29301,24 +29528,30 @@ function heading(node) { var prefix; if (setext && depth < 3) { - return content + '\n' + repeatString(depth === 1 ? '=' : '-', content.length); + return ( + content + lineFeed$23 + repeatString(depth === 1 ? equalsTo$1 : dash$6, content.length) + ) } - prefix = repeatString('#', node.depth); + prefix = repeatString(numberSign$2, node.depth); - return prefix + ' ' + content + (closeAtx ? ' ' + prefix : ''); + return prefix + space$17 + content + (closeAtx ? space$17 + prefix : '') } var paragraph_1$2 = paragraph$1; function paragraph$1(node) { - return this.all(node).join(''); + return this.all(node).join('') } var blockquote_1$2 = blockquote$1; +var lineFeed$24 = '\n'; +var space$18 = ' '; +var greaterThan$5 = '>'; + function blockquote$1(node) { - var values = this.block(node).split('\n'); + var values = this.block(node).split(lineFeed$24); var result = []; var length = values.length; var index = -1; @@ -29326,74 +29559,74 @@ function blockquote$1(node) { while (++index < length) { value = values[index]; - result[index] = (value ? ' ' : '') + value; + result[index] = (value ? space$18 : '') + value; } - return '>' + result.join('\n>'); + return greaterThan$5 + result.join(lineFeed$24 + greaterThan$5) } var list_1$2 = list$1; -/* Which method to use based on `list.ordered`. */ -var ORDERED_MAP = { - true: 'visitOrderedItems', - false: 'visitUnorderedItems' -}; - function list$1(node) { - return this[ORDERED_MAP[node.ordered]](node); + var fn = node.ordered ? this.visitOrderedItems : this.visitUnorderedItems; + return fn.call(this, node) } var pad_1 = pad; -var INDENT = 4; - -/* Pad `value` with `level * INDENT` spaces. Respects - * lines. Ignores empty lines. */ -function pad(value, level) { - var index; - var padding; +var lineFeed$25 = '\n'; +var space$19 = ' '; - value = value.split('\n'); +var tabSize$5 = 4; - index = value.length; - padding = repeatString(' ', level * INDENT); +// Pad `value` with `level * tabSize` spaces. Respects lines. Ignores empty +// lines. +function pad(value, level) { + var values = value.split(lineFeed$25); + var index = values.length; + var padding = repeatString(space$19, level * tabSize$5); while (index--) { - if (value[index].length !== 0) { - value[index] = padding + value[index]; + if (values[index].length !== 0) { + values[index] = padding + values[index]; } } - return value.join('\n'); + return values.join(lineFeed$25) } var listItem_1 = listItem$1; -/* Which checkbox to use. */ -var CHECKBOX_MAP = { - undefined: '', - null: '', - true: '[x] ', - false: '[ ] ' -}; +var lineFeed$26 = '\n'; +var space$20 = ' '; +var leftSquareBracket$6 = '['; +var rightSquareBracket$6 = ']'; +var lowercaseX$1 = 'x'; -/* Stringify a list item. - * - * Prefixes the content with a checked checkbox when - * `checked: true`: - * - * [x] foo - * - * Prefixes the content with an unchecked checkbox when - * `checked: false`: - * - * [ ] foo - */ +var ceil = Math.ceil; +var blank$4 = lineFeed$26 + lineFeed$26; + +var tabSize$6 = 4; + +// Stringify a list item. +// +// Prefixes the content with a checked checkbox when `checked: true`: +// +// ```markdown +// [x] foo +// ``` +// +// Prefixes the content with an unchecked checkbox when `checked: false`: +// +// ```markdown +// [ ] foo +// ``` function listItem$1(node, parent, position, bullet) { var self = this; var style = self.options.listItemIndent; - var loose = node.loose; + var marker = bullet || self.options.bullet; + var spread = node.spread == null ? true : node.spread; + var checked = node.checked; var children = node.children; var length = children.length; var values = []; @@ -29406,23 +29639,31 @@ function listItem$1(node, parent, position, bullet) { values[index] = self.visit(children[index], node); } - value = CHECKBOX_MAP[node.checked] + values.join(loose ? '\n\n' : '\n'); + value = values.join(spread ? blank$4 : lineFeed$26); - if (style === '1' || (style === 'mixed' && value.indexOf('\n') === -1)) { - indent = bullet.length + 1; - spacing = ' '; - } else { - indent = Math.ceil((bullet.length + 1) / 4) * 4; - spacing = repeatString(' ', indent - bullet.length); + if (typeof checked === 'boolean') { + // Note: I’d like to be able to only add the space between the check and + // the value, but unfortunately github does not support empty list-items + // with a checkbox :( + value = + leftSquareBracket$6 + + (checked ? lowercaseX$1 : space$20) + + rightSquareBracket$6 + + space$20 + + value; } - value = bullet + spacing + pad_1(value, indent / 4).slice(indent); - - if (loose && parent.children.length - 1 !== position) { - value += '\n'; + if (style === '1' || (style === 'mixed' && value.indexOf(lineFeed$26) === -1)) { + indent = marker.length + 1; + spacing = space$20; + } else { + indent = ceil((marker.length + 1) / tabSize$6) * tabSize$6; + spacing = repeatString(space$20, indent - marker.length); } - return value; + return value + ? marker + spacing + pad_1(value, indent / tabSize$6).slice(indent) + : marker } /* Expose. */ @@ -29464,178 +29705,222 @@ function longestStreak(value, character) { var inlineCode_1 = inlineCode$1; -/* Stringify inline code. - * - * Knows about internal ticks (`\``), and ensures one more - * tick is used to enclose the inline code: - * - * ```foo ``bar`` baz``` - * - * Even knows about inital and final ticks: - * - * `` `foo `` - * `` foo` `` - */ +var space$21 = ' '; +var graveAccent$5 = '`'; + +// Stringify inline code. +// +// Knows about internal ticks (`\``), and ensures one more tick is used to +// enclose the inline code: +// +// ````markdown +// ```foo ``bar`` baz``` +// ```` +// +// Even knows about inital and final ticks: +// +// ``markdown +// `` `foo `` +// `` foo` `` +// ``` function inlineCode$1(node) { var value = node.value; - var ticks = repeatString('`', longestStreak_1(value, '`') + 1); + var ticks = repeatString(graveAccent$5, longestStreak_1(value, graveAccent$5) + 1); var start = ticks; var end = ticks; - if (value.charAt(0) === '`') { - start += ' '; + if (value.charAt(0) === graveAccent$5) { + start += space$21; } - if (value.charAt(value.length - 1) === '`') { - end = ' ' + end; + if (value.charAt(value.length - 1) === graveAccent$5) { + end = space$21 + end; } - return start + value + end; + return start + value + end } var code_1 = code; -var FENCE = /([`~])\1{2}/; +var lineFeed$27 = '\n'; +var space$22 = ' '; -/* Stringify code. - * Creates indented code when: - * - * - No language tag exists; - * - Not in `fences: true` mode; - * - A non-empty value exists. - * - * Otherwise, GFM fenced code is created: - * - * ```js - * foo(); - * ``` - * - * When in ``fence: `~` `` mode, uses tildes as fences: - * - * ~~~js - * foo(); - * ~~~ - * - * Knows about internal fences (Note: GitHub/Kramdown does - * not support this): - * - * ````javascript - * ```markdown - * foo - * ``` - * ```` - */ +// Stringify code. +// Creates indented code when: +// +// - No language tag exists +// - Not in `fences: true` mode +// - A non-empty value exists +// +// Otherwise, GFM fenced code is created: +// +// ````markdown +// ```js +// foo(); +// ``` +// ```` +// +// When in ``fence: `~` `` mode, uses tildes as fences: +// +// ```markdown +// ~~~js +// foo(); +// ~~~ +// ``` +// +// Knows about internal fences: +// +// `````markdown +// ````markdown +// ```javascript +// foo(); +// ``` +// ```` +// ````` function code(node, parent) { var self = this; var value = node.value; var options = self.options; var marker = options.fence; - var language = self.encode(node.lang || '', node); + var info = node.lang || ''; var fence; - /* Without (needed) fences. */ - if (!language && !options.fences && value) { - /* Throw when pedantic, in a list item which - * isn’t compiled using a tab. */ + if (info && node.meta) { + info += space$22 + node.meta; + } + + info = self.encode(self.escape(info, node)); + + // Without (needed) fences. + if (!info && !options.fences && value) { + // Throw when pedantic, in a list item which isn’t compiled using a tab. if ( parent && parent.type === 'listItem' && options.listItemIndent !== 'tab' && options.pedantic ) { - self.file.fail('Cannot indent code properly. See http://git.io/vgFvT', node.position); + self.file.fail( + 'Cannot indent code properly. See https://git.io/fxKR8', + node.position + ); } - return pad_1(value, 1); - } - - fence = longestStreak_1(value, marker) + 1; - - /* Fix GFM / RedCarpet bug, where fence-like characters - * inside fenced code can exit a code-block. - * Yes, even when the outer fence uses different - * characters, or is longer. - * Thus, we can only pad the code to make it work. */ - if (FENCE.test(value)) { - value = pad_1(value, 1); + return pad_1(value, 1) } - fence = repeatString(marker, Math.max(fence, 3)); + fence = repeatString(marker, Math.max(longestStreak_1(value, marker) + 1, 3)); - return fence + language + '\n' + value + '\n' + fence; + return fence + info + lineFeed$27 + value + lineFeed$27 + fence } var html_1 = html$2; function html$2(node) { - return node.value; + return node.value } var thematicBreak$1 = thematic; -/* Stringify a `thematic-break`. - * The character used is configurable through `rule`: (`'_'`) - * - * ___ - * - * The number of repititions is defined through - * `ruleRepetition`: (`6`) - * - * ****** - * - * Whether spaces delimit each character, is configured - * through `ruleSpaces`: (`true`) - * - * * * * - */ +var space$23 = ' '; + +// Stringify a `thematic-break`. +// The character used is configurable through `rule`: (`'_'`): +// +// ```markdown +// ___ +// ``` +// +// The number of repititions is defined through `ruleRepetition` (`6`): +// +// ```markdown +// ****** +// ``` +// +// Whether spaces delimit each character, is configured through `ruleSpaces` +// (`true`): +// ```markdown +// * * * +// ``` function thematic() { var options = this.options; var rule = repeatString(options.rule, options.ruleRepetition); - return options.ruleSpaces ? rule.split('').join(' ') : rule; + return options.ruleSpaces ? rule.split('').join(space$23) : rule } var strong_1$2 = strong$3; -/* Stringify a `strong`. - * - * The marker used is configurable by `strong`, which - * defaults to an asterisk (`'*'`) but also accepts an - * underscore (`'_'`): - * - * __foo__ - */ +// Stringify a `strong`. +// +// The marker used is configurable by `strong`, which defaults to an asterisk +// (`'*'`) but also accepts an underscore (`'_'`): +// +// ```markdown +// __foo__ +// ``` function strong$3(node) { var marker = repeatString(this.options.strong, 2); - return marker + this.all(node).join('') + marker; + return marker + this.all(node).join('') + marker } var emphasis_1$2 = emphasis$3; -/* Stringify an `emphasis`. - * - * The marker used is configurable through `emphasis`, which - * defaults to an underscore (`'_'`) but also accepts an - * asterisk (`'*'`): - * - * *foo* - */ +var underscore$5 = '_'; +var asterisk$5 = '*'; + +// Stringify an `emphasis`. +// +// The marker used is configurable through `emphasis`, which defaults to an +// underscore (`'_'`) but also accepts an asterisk (`'*'`): +// +// ```markdown +// *foo* +// ``` +// +// In `pedantic` mode, text which itself contains an underscore will cause the +// marker to default to an asterisk instead: +// +// ```markdown +// *foo_bar* +// ``` function emphasis$3(node) { var marker = this.options.emphasis; - return marker + this.all(node).join('') + marker; + var content = this.all(node).join(''); + + // When in pedantic mode, prevent using underscore as the marker when there + // are underscores in the content. + if ( + this.options.pedantic && + marker === underscore$5 && + content.indexOf(marker) !== -1 + ) { + marker = asterisk$5; + } + + return marker + content + marker } var _break$4 = lineBreak; -var map$4 = {true: '\\\n', false: ' \n'}; +var backslash$10 = '\\'; +var lineFeed$28 = '\n'; +var space$24 = ' '; + +var commonmark$1 = backslash$10 + lineFeed$28; +var normal = space$24 + space$24 + lineFeed$28; function lineBreak() { - return map$4[this.options.commonmark]; + return this.options.commonmark ? commonmark$1 : normal } var _delete$4 = strikethrough$1; +var tilde$5 = '~'; + +var fence$1 = tilde$5 + tilde$5; + function strikethrough$1(node) { - return '~~' + this.all(node).join('') + '~~'; + return fence$1 + this.all(node).join('') + fence$1 } var ccount_1 = ccount; @@ -29662,59 +29947,82 @@ function ccount(value, character) { var encloseUri = enclose; -var re$3 = /\s/; +var leftParenthesis$4 = '('; +var rightParenthesis$5 = ')'; +var lessThan$7 = '<'; +var greaterThan$6 = '>'; -/* Wrap `url` in angle brackets when needed, or when - * forced. - * In links, images, and definitions, the URL part needs - * to be enclosed when it: - * - * - has a length of `0`; - * - contains white-space; - * - has more or less opening than closing parentheses. - */ +var expression = /\s/; + +// Wrap `url` in angle brackets when needed, or when +// forced. +// In links, images, and definitions, the URL part needs +// to be enclosed when it: +// +// - has a length of `0` +// - contains white-space +// - has more or less opening than closing parentheses function enclose(uri, always) { - if (always || uri.length === 0 || re$3.test(uri) || ccount_1(uri, '(') !== ccount_1(uri, ')')) { - return '<' + uri + '>'; + if ( + always || + uri.length === 0 || + expression.test(uri) || + ccount_1(uri, leftParenthesis$4) !== ccount_1(uri, rightParenthesis$5) + ) { + return lessThan$7 + uri + greaterThan$6 } - return uri; + return uri } var encloseTitle = enclose$1; -/* There is currently no way to support nested delimiters - * across Markdown.pl, CommonMark, and GitHub (RedCarpet). - * The following code supports Markdown.pl and GitHub. - * CommonMark is not supported when mixing double- and - * single quotes inside a title. */ +var quotationMark$3 = '"'; +var apostrophe$3 = "'"; + +// There is currently no way to support nested delimiters across Markdown.pl, +// CommonMark, and GitHub (RedCarpet). The following code supports Markdown.pl +// and GitHub. +// CommonMark is not supported when mixing double- and single quotes inside a +// title. function enclose$1(title) { - var delimiter = title.indexOf('"') === -1 ? '"' : '\''; - return delimiter + title + delimiter; + var delimiter = + title.indexOf(quotationMark$3) === -1 ? quotationMark$3 : apostrophe$3; + return delimiter + title + delimiter } -var link_1$2 = link$3; +var link_1$2 = link$4; -/* Expression for a protocol: - * http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax */ -var PROTOCOL = /^[a-z][a-z+.-]+:\/?/i; +var space$25 = ' '; +var leftSquareBracket$7 = '['; +var rightSquareBracket$7 = ']'; +var leftParenthesis$5 = '('; +var rightParenthesis$6 = ')'; -/* Stringify a link. - * - * When no title exists, the compiled `children` equal - * `url`, and `url` starts with a protocol, an auto - * link is created: - * - * - * - * Otherwise, is smart about enclosing `url` (see - * `encloseURI()`) and `title` (see `encloseTitle()`). - * - * [foo]( 'An "example" e-mail') - * - * Supports named entities in the `url` and `title` when - * in `settings.encode` mode. */ -function link$3(node) { +// Expression for a protocol: +// See . +var protocol$1 = /^[a-z][a-z+.-]+:\/?/i; + +// Stringify a link. +// +// When no title exists, the compiled `children` equal `url`, and `url` starts +// with a protocol, an auto link is created: +// +// ```markdown +// +// ``` +// +// Otherwise, is smart about enclosing `url` (see `encloseURI()`) and `title` +// (see `encloseTitle()`). +// ``` +// +// ```markdown +// [foo]( 'An "example" e-mail') +// ``` +// +// Supports named entities in the `url` and `title` when in `settings.encode` +// mode. +function link$4(node) { var self = this; var content = self.encode(node.url || '', node); var exit = self.enterLink(); @@ -29723,37 +30031,40 @@ function link$3(node) { exit(); - if ( - node.title == null && - PROTOCOL.test(content) && - (escaped === value || escaped === 'mailto:' + value) - ) { - /* Backslash escapes do not work in autolinks, - * so we do not escape. */ - return encloseUri(self.encode(node.url), true); + if (node.title == null && protocol$1.test(content) && escaped === value) { + // Backslash escapes do not work in autolinks, so we do not escape. + return encloseUri(self.encode(node.url), true) } content = encloseUri(content); if (node.title) { - content += ' ' + encloseTitle(self.encode(self.escape(node.title, node), node)); + content += space$25 + encloseTitle(self.encode(self.escape(node.title, node), node)); } - return '[' + value + '](' + content + ')'; + return ( + leftSquareBracket$7 + + value + + rightSquareBracket$7 + + leftParenthesis$5 + + content + + rightParenthesis$6 + ) } var copyIdentifierEncoding = copy$5; -var PUNCTUATION = /[-!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~_]/; +var ampersand$2 = '&'; -/* For shortcut and collapsed reference links, the contents - * is also an identifier, so we need to restore the original - * encoding and escaping that were present in the source - * string. - * - * This function takes the unescaped & unencoded value from - * shortcut's child nodes and the identifier and encodes - * the former according to the latter. */ +var punctuationExppresion = /[-!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~_]/; + +// For shortcut and collapsed reference links, the contents is also an +// identifier, so we need to restore the original encoding and escaping +// that were present in the source string. +// +// This function takes the unescaped & unencoded value from shortcut’s +// child nodes and the identifier and encodes the former according to +// the latter. function copy$5(value, identifier) { var length = value.length; var count = identifier.length; @@ -29763,25 +30074,31 @@ function copy$5(value, identifier) { var start; while (index < length) { - /* Take next non-punctuation characters from `value`. */ + // Take next non-punctuation characters from `value`. start = index; - while (index < length && !PUNCTUATION.test(value.charAt(index))) { + while (index < length && !punctuationExppresion.test(value.charAt(index))) { index += 1; } result.push(value.slice(start, index)); - /* Advance `position` to the next punctuation character. */ - while (position < count && !PUNCTUATION.test(identifier.charAt(position))) { + // Advance `position` to the next punctuation character. + while ( + position < count && + !punctuationExppresion.test(identifier.charAt(position)) + ) { position += 1; } - /* Take next punctuation characters from `identifier`. */ + // Take next punctuation characters from `identifier`. start = position; - while (position < count && PUNCTUATION.test(identifier.charAt(position))) { - if (identifier.charAt(position) === '&') { + while ( + position < count && + punctuationExppresion.test(identifier.charAt(position)) + ) { + if (identifier.charAt(position) === ampersand$2) { position += entityPrefixLength(identifier.slice(position)); } @@ -29790,32 +30107,49 @@ function copy$5(value, identifier) { result.push(identifier.slice(start, position)); - /* Advance `index` to the next non-punctuation character. */ - while (index < length && PUNCTUATION.test(value.charAt(index))) { + // Advance `index` to the next non-punctuation character. + while (index < length && punctuationExppresion.test(value.charAt(index))) { index += 1; } } - return result.join(''); + return result.join('') } var label_1 = label; -/* Stringify a reference label. - * Because link references are easily, mistakingly, - * created (for example, `[foo]`), reference nodes have - * an extra property depicting how it looked in the - * original document, so stringification can cause minimal - * changes. */ +var leftSquareBracket$8 = '['; +var rightSquareBracket$8 = ']'; + +var shortcut$2 = 'shortcut'; +var collapsed$1 = 'collapsed'; + +// Stringify a reference label. +// Because link references are easily, mistakingly, created (for example, +// `[foo]`), reference nodes have an extra property depicting how it looked in +// the original document, so stringification can cause minimal changes. function label(node) { var type = node.referenceType; - var value = type === 'full' ? node.identifier : ''; - return type === 'shortcut' ? value : '[' + value + ']'; + if (type === shortcut$2) { + return '' + } + + return ( + leftSquareBracket$8 + + (type === collapsed$1 ? '' : node.label || node.identifier) + + rightSquareBracket$8 + ) } var linkReference_1 = linkReference; +var leftSquareBracket$9 = '['; +var rightSquareBracket$9 = ']'; + +var shortcut$3 = 'shortcut'; +var collapsed$2 = 'collapsed'; + function linkReference(node) { var self = this; var type = node.referenceType; @@ -29824,51 +30158,82 @@ function linkReference(node) { exit(); - if (type === 'shortcut' || type === 'collapsed') { - value = copyIdentifierEncoding(value, node.identifier); + if (type === shortcut$3 || type === collapsed$2) { + value = copyIdentifierEncoding(value, node.label || node.identifier); } - return '[' + value + ']' + label_1(node); + return leftSquareBracket$9 + value + rightSquareBracket$9 + label_1(node) } var imageReference_1 = imageReference; +var leftSquareBracket$10 = '['; +var rightSquareBracket$10 = ']'; +var exclamationMark$5 = '!'; + function imageReference(node) { - return '![' + (this.encode(node.alt, node) || '') + ']' + label_1(node); + return ( + exclamationMark$5 + + leftSquareBracket$10 + + (this.encode(node.alt, node) || '') + + rightSquareBracket$10 + + label_1(node) + ) } var definition_1$2 = definition$1; -/* Stringify an URL definition. - * - * Is smart about enclosing `url` (see `encloseURI()`) and - * `title` (see `encloseTitle()`). - * - * [foo]: 'An "example" e-mail' - */ +var space$26 = ' '; +var colon$6 = ':'; +var leftSquareBracket$11 = '['; +var rightSquareBracket$11 = ']'; + +// Stringify an URL definition. +// +// Is smart about enclosing `url` (see `encloseURI()`) and `title` (see +// `encloseTitle()`). +// +// ```markdown +// [foo]: 'An "example" e-mail' +// ``` function definition$1(node) { var content = encloseUri(node.url); if (node.title) { - content += ' ' + encloseTitle(node.title); + content += space$26 + encloseTitle(node.title); } - return '[' + node.identifier + ']: ' + content; + return ( + leftSquareBracket$11 + + (node.label || node.identifier) + + rightSquareBracket$11 + + colon$6 + + space$26 + + content + ) } -var image_1 = image$2; +var image_1 = image$3; -/* Stringify an image. - * - * Is smart about enclosing `url` (see `encloseURI()`) and - * `title` (see `encloseTitle()`). - * - * ![foo]( 'My "favourite" icon') - * - * Supports named entities in `url`, `alt`, and `title` - * when in `settings.encode` mode. - */ -function image$2(node) { +var space$27 = ' '; +var leftParenthesis$6 = '('; +var rightParenthesis$7 = ')'; +var leftSquareBracket$12 = '['; +var rightSquareBracket$12 = ']'; +var exclamationMark$6 = '!'; + +// Stringify an image. +// +// Is smart about enclosing `url` (see `encloseURI()`) and `title` (see +// `encloseTitle()`). +// +// ```markdown +// ![foo]( 'My "favourite" icon') +// ``` +// +// Supports named entities in `url`, `alt`, and `title` when in +// `settings.encode` mode. +function image$3(node) { var self = this; var content = encloseUri(self.encode(node.url || '', node)); var exit = self.enterLink(); @@ -29877,31 +30242,72 @@ function image$2(node) { exit(); if (node.title) { - content += ' ' + encloseTitle(self.encode(node.title, node)); + content += space$27 + encloseTitle(self.encode(node.title, node)); } - return '![' + alt + '](' + content + ')'; + return ( + exclamationMark$6 + + leftSquareBracket$12 + + alt + + rightSquareBracket$12 + + leftParenthesis$6 + + content + + rightParenthesis$7 + ) } -var footnote_1 = footnote; +var footnote_1 = footnote$1; -function footnote(node) { - return '[^' + this.all(node).join('') + ']'; +var leftSquareBracket$13 = '['; +var rightSquareBracket$13 = ']'; +var caret$3 = '^'; + +function footnote$1(node) { + return ( + leftSquareBracket$13 + caret$3 + this.all(node).join('') + rightSquareBracket$13 + ) } var footnoteReference_1 = footnoteReference; +var leftSquareBracket$14 = '['; +var rightSquareBracket$14 = ']'; +var caret$4 = '^'; + function footnoteReference(node) { - return '[^' + node.identifier + ']'; + return ( + leftSquareBracket$14 + + caret$4 + + (node.label || node.identifier) + + rightSquareBracket$14 + ) } +var lineFeed$29 = '\n'; +var space$28 = ' '; +var colon$7 = ':'; +var leftSquareBracket$15 = '['; +var rightSquareBracket$15 = ']'; +var caret$5 = '^'; + +var tabSize$7 = 4; +var blank$5 = lineFeed$29 + lineFeed$29; +var indent = repeatString(space$28, tabSize$7); + var footnoteDefinition_1$2 = footnoteDefinition$1; function footnoteDefinition$1(node) { - var id = node.identifier.toLowerCase(); - var content = this.all(node).join('\n\n' + repeatString(' ', 4)); + var content = this.all(node).join(blank$5 + indent); - return '[^' + id + ']: ' + content; + return ( + leftSquareBracket$15 + + caret$5 + + (node.label || node.identifier) + + rightSquareBracket$15 + + colon$7 + + space$28 + + content + ) } /* Expose. */ @@ -29918,7 +30324,7 @@ var CENTER = 'c'; var DOT = '.'; var NULL = ''; -var ALLIGNMENT$1 = [LEFT, RIGHT, CENTER, DOT, NULL]; +var ALLIGNMENT = [LEFT, RIGHT, CENTER, DOT, NULL]; var MIN_CELL_SIZE = 3; /* Characters. */ @@ -30003,7 +30409,7 @@ function markdownTable(table, options) { align = align.charAt(0).toLowerCase(); } - if (ALLIGNMENT$1.indexOf(align) === -1) { + if (ALLIGNMENT.indexOf(align) === -1) { align = NULL; } @@ -30156,26 +30562,28 @@ function dotindex$1(value) { var table_1$2 = table$2; -/* Stringify table. - * - * Creates a fenced table by default, but not in - * `looseTable: true` mode: - * - * Foo | Bar - * :-: | --- - * Baz | Qux - * - * NOTE: Be careful with `looseTable: true` mode, as a - * loose table inside an indented code block on GitHub - * renders as an actual table! - * - * Creates a spaced table by default, but not in - * `spacedTable: false`: - * - * |Foo|Bar| - * |:-:|---| - * |Baz|Qux| - */ +var space$29 = ' '; +var verticalBar$2 = '|'; + +// Stringify table. +// +// Creates a fenced table by default, but not in `looseTable: true` mode: +// +// ```markdown +// Foo | Bar +// :-: | --- +// Baz | Qux +// +// NOTE: Be careful with `looseTable: true` mode, as a loose table inside an +// indented code block on GitHub renders as an actual table! +// +// Creates a spaced table by default, but not in `spacedTable: false`: +// +// ```markdown +// |Foo|Bar| +// |:-:|---| +// |Baz|Qux| +// ``` function table$2(node) { var self = this; var options = self.options; @@ -30200,11 +30608,11 @@ function table$2(node) { start = ''; end = ''; } else if (spaced) { - start = '| '; - end = ' |'; + start = verticalBar$2 + space$29; + end = space$29 + verticalBar$2; } else { - start = '|'; - end = '|'; + start = verticalBar$2; + end = verticalBar$2; } return markdownTable_1(result, { @@ -30213,19 +30621,19 @@ function table$2(node) { start: start, end: end, stringLength: stringLength, - delimiter: spaced ? ' | ' : '|' - }); + delimiter: spaced ? space$29 + verticalBar$2 + space$29 : verticalBar$2 + }) } var tableCell_1 = tableCell; function tableCell(node) { - return this.all(node).join(''); + return this.all(node).join('') } var compiler = Compiler; -/* Construct a new compiler. */ +// Construct a new compiler. function Compiler(tree, file) { this.inLink = false; this.inTable = false; @@ -30235,26 +30643,26 @@ function Compiler(tree, file) { this.setOptions({}); } -var proto$4 = Compiler.prototype; +var proto$6 = Compiler.prototype; -/* Enter and exit helpers. */ -proto$4.enterLink = stateToggle('inLink', false); -proto$4.enterTable = stateToggle('inTable', false); -proto$4.enterLinkReference = enterLinkReference; +// Enter and exit helpers. */ +proto$6.enterLink = stateToggle('inLink', false); +proto$6.enterTable = stateToggle('inTable', false); +proto$6.enterLinkReference = enterLinkReference; -/* Configuration. */ -proto$4.options = defaults$5; -proto$4.setOptions = setOptions_1$2; +// Configuration. +proto$6.options = defaults$5; +proto$6.setOptions = setOptions_1$2; -proto$4.compile = compile_1; -proto$4.visit = one_1; -proto$4.all = all_1; -proto$4.block = block_1; -proto$4.visitOrderedItems = orderedItems_1; -proto$4.visitUnorderedItems = unorderedItems_1; +proto$6.compile = compile_1; +proto$6.visit = one_1; +proto$6.all = all_1; +proto$6.block = block_1; +proto$6.visitOrderedItems = orderedItems_1; +proto$6.visitUnorderedItems = unorderedItems_1; -/* Expose visitors. */ -proto$4.visitors = { +// Expose visitors. +proto$6.visitors = { root: root_1, text: text_1$2, heading: heading_1, @@ -30287,42 +30695,51 @@ stringify$7.Compiler = compiler; function stringify$7(options) { var Local = unherit_1(compiler); - Local.prototype.options = immutable(Local.prototype.options, this.data('settings'), options); + Local.prototype.options = immutable( + Local.prototype.options, + this.data('settings'), + options + ); this.Compiler = Local; } -var remark = unified_1().use(remarkParse).use(remarkStringify).freeze(); +var remark = unified_1() + .use(remarkParse) + .use(remarkStringify) + .freeze(); const name = "remark"; -const version$1 = "8.0.0"; +const version$1 = "10.0.0"; const description = "Markdown processor powered by plugins"; const license = "MIT"; const keywords = ["markdown","abstract","syntax","tree","ast","parse","stringify","process"]; -const dependencies = {"remark-parse":"^4.0.0","remark-stringify":"^4.0.0","unified":"^6.0.0"}; const homepage = "http://remark.js.org"; -const repository = "https://github.com/wooorm/remark/tree/master/packages/remark"; -const bugs = "https://github.com/wooorm/remark/issues"; +const repository = "https://github.com/remarkjs/remark/tree/master/packages/remark"; +const bugs = "https://github.com/remarkjs/remark/issues"; const author = "Titus Wormer (http://wooorm.com)"; const contributors = ["Titus Wormer (http://wooorm.com)"]; const files = ["index.js"]; -const scripts = {}; +const dependencies = {"remark-parse":"^6.0.0","remark-stringify":"^6.0.0","unified":"^7.0.0"}; +const devDependencies = {"tape":"^4.9.1"}; +const scripts = {"test":"tape test.js"}; const xo = false; -const _resolved = "https://registry.npmjs.org/remark/-/remark-8.0.0.tgz"; -const _integrity = "sha512-K0PTsaZvJlXTl9DN6qYlvjTkqSZBFELhROZMrblm2rB+085flN84nz4g/BscKRMqDvhzlK1oQ/xnWQumdeNZYw=="; -const _from = "remark@8.0.0"; +const _resolved = "https://registry.npmjs.org/remark/-/remark-10.0.0.tgz"; +const _integrity = "sha512-0fZvVmd9CgDi1qHGsRTyhpJShw60r3/4OSdRpAx+I7CmE8/Jmt829T9KWHpw2Ygw3chRZ26sMorqb8aIolU9tQ=="; +const _from = "remark@10.0.0"; var _package = { name: name, version: version$1, description: description, license: license, keywords: keywords, - dependencies: dependencies, homepage: homepage, repository: repository, bugs: bugs, author: author, contributors: contributors, files: files, + dependencies: dependencies, + devDependencies: devDependencies, scripts: scripts, xo: xo, _resolved: _resolved, @@ -30336,13 +30753,14 @@ var _package$1 = Object.freeze({ description: description, license: license, keywords: keywords, - dependencies: dependencies, homepage: homepage, repository: repository, bugs: bugs, author: author, contributors: contributors, files: files, + dependencies: dependencies, + devDependencies: devDependencies, scripts: scripts, xo: xo, _resolved: _resolved, @@ -30354,14 +30772,14 @@ var _package$1 = Object.freeze({ const name$1 = "node-lint-md-cli-rollup"; const description$1 = "remark packaged for node markdown linting"; const version$2 = "1.0.0"; -const devDependencies = {"rollup":"^0.55.5","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-json":"^2.3.1","rollup-plugin-node-resolve":"^3.4.0"}; -const dependencies$1 = {"markdown-extensions":"^1.1.0","remark":"^8.0.0","remark-lint":"^6.0.2","remark-preset-lint-node":"^1.1.0","unified-args":"^6.0.0","unified-engine":"^5.1.0"}; +const devDependencies$1 = {"rollup":"^0.55.5","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-json":"^2.3.1","rollup-plugin-node-resolve":"^3.4.0"}; +const dependencies$1 = {"markdown-extensions":"^1.1.0","remark":"^10.0.0","remark-lint":"^6.0.3","remark-preset-lint-node":"^1.2.0","unified-args":"^6.0.0","unified-engine":"^5.1.0"}; const scripts$1 = {"build":"rollup -c","build-node":"npm run build && cp dist/* .."}; var _package$2 = { name: name$1, description: description$1, version: version$2, - devDependencies: devDependencies, + devDependencies: devDependencies$1, dependencies: dependencies$1, scripts: scripts$1 }; @@ -30370,7 +30788,7 @@ var _package$3 = Object.freeze({ name: name$1, description: description$1, version: version$2, - devDependencies: devDependencies, + devDependencies: devDependencies$1, dependencies: dependencies$1, scripts: scripts$1, default: _package$2 @@ -31489,7 +31907,7 @@ var remarkLintFencedCodeFlag = unifiedLintRule('remark-lint:fenced-code-flag', f var start$1 = unistUtilPosition.start; var end$1 = unistUtilPosition.end; -var fence = /^ {0,3}([~`])\1{2,}/; +var fence$2 = /^ {0,3}([~`])\1{2,}/; var reasonInvalid = 'Invalid code-language flag'; var reasonMissing = 'Missing code-language flag'; @@ -31520,7 +31938,7 @@ function fencedCodeFlag(tree, file, pref) { } else { value = contents.slice(start$1(node).offset, end$1(node).offset); - if (!allowEmpty && fence.test(value)) { + if (!allowEmpty && fence$2.test(value)) { file.message(reasonMissing, node); } } @@ -31596,222 +32014,6 @@ function hardBreakSpaces(tree, file) { } } -var mdastUtilToString = toString$5; - -/* Get the text content of a node. If the node itself - * does not expose plain-text fields, `toString` will - * recursivly try its children. */ -function toString$5(node) { - return ( - valueOf$1(node) || - (node.children && node.children.map(toString$5).join('')) || - '' - ) -} - -/* Get the value of `node`. Checks, `value`, - * `alt`, and `title`, in that order. */ -function valueOf$1(node) { - return ( - (node && node.value ? node.value : node.alt ? node.alt : node.title) || '' - ) -} - -var remarkLintNoAutoLinkWithoutProtocol = unifiedLintRule( - 'remark-lint:no-auto-link-without-protocol', - noAutoLinkWithoutProtocol -); - -var start$3 = unistUtilPosition.start; -var end$2 = unistUtilPosition.end; - -/* Protocol expression. See: - * http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax */ -var protocol$1 = /^[a-z][a-z+.-]+:\/?/i; - -var reason$3 = 'All automatic links must start with a protocol'; - -function noAutoLinkWithoutProtocol(tree, file) { - unistUtilVisit(tree, 'link', visitor); - - function visitor(node) { - var children; - - if (!unistUtilGenerated(node)) { - children = node.children; - - if ( - start$3(node).column === start$3(children[0]).column - 1 && - end$2(node).column === end$2(children[children.length - 1]).column + 1 && - !protocol$1.test(mdastUtilToString(node)) - ) { - file.message(reason$3, node); - } - } - } -} - -var remarkLintNoBlockquoteWithoutCaret = unifiedLintRule('remark-lint:no-blockquote-without-caret', noBlockquoteWithoutCaret); - -function noBlockquoteWithoutCaret(ast, file) { - var contents = file.toString(); - var location = vfileLocation(file); - var last = contents.length; - - unistUtilVisit(ast, 'blockquote', visitor); - - function visitor(node) { - var start = unistUtilPosition.start(node).line; - var indent = node.position && node.position.indent; - - if (unistUtilGenerated(node) || !indent || indent.length === 0) { - return; - } - - indent.forEach(eachLine); - - function eachLine(column, n) { - var character; - var line = start + n + 1; - var offset = location.toOffset({ - line: line, - column: column - }) - 1; - - while (++offset < last) { - character = contents.charAt(offset); - - if (character === '>') { - return; - } - - /* istanbul ignore else - just for safety */ - if (character !== ' ' && character !== '\t') { - break; - } - } - - file.message('Missing caret in blockquote', { - line: line, - column: column - }); - } - } -} - -var remarkLintNoDuplicateDefinitions = unifiedLintRule( - 'remark-lint:no-duplicate-definitions', - noDuplicateDefinitions -); - -var reason$4 = 'Do not use definitions with the same identifier'; - -function noDuplicateDefinitions(tree, file) { - var map = {}; - - unistUtilVisit(tree, ['definition', 'footnoteDefinition'], validate); - - function validate(node) { - var identifier; - var duplicate; - - if (!unistUtilGenerated(node)) { - identifier = node.identifier; - duplicate = map[identifier]; - - if (duplicate && duplicate.type) { - file.message( - reason$4 + ' (' + unistUtilStringifyPosition(unistUtilPosition.start(duplicate)) + ')', - node - ); - } - - map[identifier] = node; - } - } -} - -var remarkLintNoFileNameArticles = unifiedLintRule('remark-lint:no-file-name-articles', noFileNameArticles); - -function noFileNameArticles(tree, file) { - var match = file.stem && file.stem.match(/^(the|teh|an?)\b/i); - - if (match) { - file.message('Do not start file names with `' + match[0] + '`'); - } -} - -var remarkLintNoFileNameConsecutiveDashes = unifiedLintRule( - 'remark-lint:no-file-name-consecutive-dashes', - noFileNameConsecutiveDashes -); - -var reason$5 = 'Do not use consecutive dashes in a file name'; - -function noFileNameConsecutiveDashes(tree, file) { - if (file.stem && /-{2,}/.test(file.stem)) { - file.message(reason$5); - } -} - -var remarkLintNoFileNameOuterDashes = unifiedLintRule( - 'remark-lint:no-file-name-outer-dashes', - noFileNameOuterDashes -); - -var reason$6 = 'Do not use initial or final dashes in a file name'; - -function noFileNameOuterDashes(tree, file) { - if (file.stem && /^-|-$/.test(file.stem)) { - file.message(reason$6); - } -} - -var mdastUtilHeadingStyle = style; - -function style(node, relative) { - var last = node.children[node.children.length - 1]; - var depth = node.depth; - var pos = node && node.position && node.position.end; - var final = last && last.position && last.position.end; - - if (!pos) { - return null - } - - /* This can only occur for `'atx'` and `'atx-closed'` - * headings. This might incorrectly match `'atx'` - * headings with lots of trailing white space as an - * `'atx-closed'` heading. */ - if (!last) { - if (pos.column - 1 <= depth * 2) { - return consolidate(depth, relative) - } - - return 'atx-closed' - } - - if (final.line + 1 === pos.line) { - return 'setext' - } - - if (final.column + depth < pos.column) { - return 'atx-closed' - } - - return consolidate(depth, relative) -} - -/* Get the probable style of an atx-heading, depending on - * preferred style. */ -function consolidate(depth, relative) { - return depth < 3 - ? 'atx' - : relative === 'atx' || relative === 'setext' - ? relative - : null -} - const addendum = "addenda"; const aircraft = "aircraft"; const alga = "algae"; @@ -32293,14 +32495,372 @@ module.exports = (word, plural, count) => { }; }); -var remarkLintNoHeadingContentIndent = unifiedLintRule( - 'remark-lint:no-heading-content-indent', - noHeadingContentIndent -); +var remarkLintListItemIndent = unifiedLintRule('remark-lint:list-item-indent', listItemIndent); + +var start$3 = unistUtilPosition.start; + +var styles = {'tab-size': true, mixed: true, space: true}; + +function listItemIndent(tree, file, pref) { + var contents = String(file); + + pref = typeof pref === 'string' ? pref : 'tab-size'; + + if (styles[pref] !== true) { + file.fail( + 'Invalid list-item indent style `' + + pref + + "`: use either `'tab-size'`, `'space'`, or `'mixed'`" + ); + } + + unistUtilVisit(tree, 'list', visitor); + + function visitor(node) { + var spread = node.spread || node.loose; + + if (!unistUtilGenerated(node)) { + node.children.forEach(visitItem); + } + + function visitItem(item) { + var head = item.children[0]; + var final = start$3(head); + var marker; + var bulletSize; + var style; + var diff; + var reason; + + marker = contents + .slice(start$3(item).offset, final.offset) + .replace(/\[[x ]?]\s*$/i, ''); + + bulletSize = marker.trimRight().length; + + style = + pref === 'tab-size' || (pref === 'mixed' && spread) + ? Math.ceil(bulletSize / 4) * 4 + : bulletSize + 1; + + if (marker.length !== style) { + diff = style - marker.length; + + reason = + 'Incorrect list-item indent: ' + + (diff > 0 ? 'add' : 'remove') + + ' ' + + Math.abs(diff) + + ' ' + + plur('space', diff); + + file.message(reason, final); + } + } + } +} + +var remarkLintMaximumLineLength = unifiedLintRule('remark-lint:maximum-line-length', maximumLineLength); var start$4 = unistUtilPosition.start; +var end$2 = unistUtilPosition.end; + +function maximumLineLength(tree, file, pref) { + var style = typeof pref === 'number' && !isNaN(pref) ? pref : 80; + var content = String(file); + var lines = content.split(/\r?\n/); + var length = lines.length; + var index = -1; + var lineLength; + + unistUtilVisit(tree, ['heading', 'table', 'code', 'definition'], ignore); + unistUtilVisit(tree, ['link', 'image', 'inlineCode'], inline); + + /* Iterate over every line, and warn for violating lines. */ + while (++index < length) { + lineLength = lines[index].length; + + if (lineLength > style) { + file.message('Line must be at most ' + style + ' characters', { + line: index + 1, + column: lineLength + 1 + }); + } + } + + /* Finally, whitelist some inline spans, but only if they occur at or after + * the wrap. However, when they do, and there’s white-space after it, they + * are not whitelisted. */ + function inline(node, pos, parent) { + var next = parent.children[pos + 1]; + var initial; + var final; + + /* istanbul ignore if - Nothing to whitelist when generated. */ + if (unistUtilGenerated(node)) { + return + } + + initial = start$4(node); + final = end$2(node); + + /* No whitelisting when starting after the border, or ending before it. */ + if (initial.column > style || final.column < style) { + return + } + + /* No whitelisting when there’s white-space after + * the link. */ + if ( + next && + start$4(next).line === initial.line && + (!next.value || /^(.+?[ \t].+?)/.test(next.value)) + ) { + return + } + + whitelist(initial.line - 1, final.line); + } + + function ignore(node) { + /* istanbul ignore else - Hard to test, as we only run this case on `position: true` */ + if (!unistUtilGenerated(node)) { + whitelist(start$4(node).line - 1, end$2(node).line); + } + } + + /* Whitelist from `initial` to `final`, zero-based. */ + function whitelist(initial, final) { + while (initial < final) { + lines[initial++] = ''; + } + } +} + +var mdastUtilToString = toString$6; + +/* Get the text content of a node. If the node itself + * does not expose plain-text fields, `toString` will + * recursivly try its children. */ +function toString$6(node) { + return ( + valueOf$1(node) || + (node.children && node.children.map(toString$6).join('')) || + '' + ) +} + +/* Get the value of `node`. Checks, `value`, + * `alt`, and `title`, in that order. */ +function valueOf$1(node) { + return ( + (node && node.value ? node.value : node.alt ? node.alt : node.title) || '' + ) +} + +var remarkLintNoAutoLinkWithoutProtocol = unifiedLintRule( + 'remark-lint:no-auto-link-without-protocol', + noAutoLinkWithoutProtocol +); + +var start$5 = unistUtilPosition.start; var end$3 = unistUtilPosition.end; +/* Protocol expression. See: + * http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax */ +var protocol$2 = /^[a-z][a-z+.-]+:\/?/i; + +var reason$3 = 'All automatic links must start with a protocol'; + +function noAutoLinkWithoutProtocol(tree, file) { + unistUtilVisit(tree, 'link', visitor); + + function visitor(node) { + var children; + + if (!unistUtilGenerated(node)) { + children = node.children; + + if ( + start$5(node).column === start$5(children[0]).column - 1 && + end$3(node).column === end$3(children[children.length - 1]).column + 1 && + !protocol$2.test(mdastUtilToString(node)) + ) { + file.message(reason$3, node); + } + } + } +} + +var remarkLintNoBlockquoteWithoutCaret = unifiedLintRule('remark-lint:no-blockquote-without-caret', noBlockquoteWithoutCaret); + +function noBlockquoteWithoutCaret(ast, file) { + var contents = file.toString(); + var location = vfileLocation(file); + var last = contents.length; + + unistUtilVisit(ast, 'blockquote', visitor); + + function visitor(node) { + var start = unistUtilPosition.start(node).line; + var indent = node.position && node.position.indent; + + if (unistUtilGenerated(node) || !indent || indent.length === 0) { + return; + } + + indent.forEach(eachLine); + + function eachLine(column, n) { + var character; + var line = start + n + 1; + var offset = location.toOffset({ + line: line, + column: column + }) - 1; + + while (++offset < last) { + character = contents.charAt(offset); + + if (character === '>') { + return; + } + + /* istanbul ignore else - just for safety */ + if (character !== ' ' && character !== '\t') { + break; + } + } + + file.message('Missing caret in blockquote', { + line: line, + column: column + }); + } + } +} + +var remarkLintNoDuplicateDefinitions = unifiedLintRule( + 'remark-lint:no-duplicate-definitions', + noDuplicateDefinitions +); + +var reason$4 = 'Do not use definitions with the same identifier'; + +function noDuplicateDefinitions(tree, file) { + var map = {}; + + unistUtilVisit(tree, ['definition', 'footnoteDefinition'], validate); + + function validate(node) { + var identifier; + var duplicate; + + if (!unistUtilGenerated(node)) { + identifier = node.identifier; + duplicate = map[identifier]; + + if (duplicate && duplicate.type) { + file.message( + reason$4 + ' (' + unistUtilStringifyPosition(unistUtilPosition.start(duplicate)) + ')', + node + ); + } + + map[identifier] = node; + } + } +} + +var remarkLintNoFileNameArticles = unifiedLintRule('remark-lint:no-file-name-articles', noFileNameArticles); + +function noFileNameArticles(tree, file) { + var match = file.stem && file.stem.match(/^(the|teh|an?)\b/i); + + if (match) { + file.message('Do not start file names with `' + match[0] + '`'); + } +} + +var remarkLintNoFileNameConsecutiveDashes = unifiedLintRule( + 'remark-lint:no-file-name-consecutive-dashes', + noFileNameConsecutiveDashes +); + +var reason$5 = 'Do not use consecutive dashes in a file name'; + +function noFileNameConsecutiveDashes(tree, file) { + if (file.stem && /-{2,}/.test(file.stem)) { + file.message(reason$5); + } +} + +var remarkLintNoFileNameOuterDashes = unifiedLintRule( + 'remark-lint:no-file-name-outer-dashes', + noFileNameOuterDashes +); + +var reason$6 = 'Do not use initial or final dashes in a file name'; + +function noFileNameOuterDashes(tree, file) { + if (file.stem && /^-|-$/.test(file.stem)) { + file.message(reason$6); + } +} + +var mdastUtilHeadingStyle = style; + +function style(node, relative) { + var last = node.children[node.children.length - 1]; + var depth = node.depth; + var pos = node && node.position && node.position.end; + var final = last && last.position && last.position.end; + + if (!pos) { + return null + } + + /* This can only occur for `'atx'` and `'atx-closed'` + * headings. This might incorrectly match `'atx'` + * headings with lots of trailing white space as an + * `'atx-closed'` heading. */ + if (!last) { + if (pos.column - 1 <= depth * 2) { + return consolidate(depth, relative) + } + + return 'atx-closed' + } + + if (final.line + 1 === pos.line) { + return 'setext' + } + + if (final.column + depth < pos.column) { + return 'atx-closed' + } + + return consolidate(depth, relative) +} + +/* Get the probable style of an atx-heading, depending on + * preferred style. */ +function consolidate(depth, relative) { + return depth < 3 + ? 'atx' + : relative === 'atx' || relative === 'setext' + ? relative + : null +} + +var remarkLintNoHeadingContentIndent = unifiedLintRule( + 'remark-lint:no-heading-content-indent', + noHeadingContentIndent +); + +var start$6 = unistUtilPosition.start; +var end$4 = unistUtilPosition.end; + function noHeadingContentIndent(tree, file) { var contents = String(file); @@ -32327,7 +32887,7 @@ function noHeadingContentIndent(tree, file) { type = mdastUtilHeadingStyle(node, 'atx'); if (type === 'atx' || type === 'atx-closed') { - initial = start$4(node); + initial = start$6(node); index = initial.offset; char = contents.charAt(index); @@ -32341,7 +32901,7 @@ function noHeadingContentIndent(tree, file) { } index = depth + (index - initial.offset); - head = start$4(children[0]).column; + head = start$6(children[0]).column; /* Ignore empty headings. */ if (!head) { @@ -32359,7 +32919,7 @@ function noHeadingContentIndent(tree, file) { plur('space', diff) + ' before this heading’s content'; - file.message(reason, start$4(children[0])); + file.message(reason, start$6(children[0])); } } @@ -32367,8 +32927,8 @@ function noHeadingContentIndent(tree, file) { * between their content and the final hashes, * thus, there is no `add x spaces`. */ if (type === 'atx-closed') { - final = end$3(children[children.length - 1]); - diff = end$3(node).column - final.column - 1 - depth; + final = end$4(children[children.length - 1]); + diff = end$4(node).column - final.column - 1 - depth; if (diff) { reason = @@ -32386,7 +32946,7 @@ function noHeadingContentIndent(tree, file) { var remarkLintNoHeadingIndent = unifiedLintRule('remark-lint:no-heading-indent', noHeadingIndent); -var start$5 = unistUtilPosition.start; +var start$7 = unistUtilPosition.start; function noHeadingIndent(tree, file) { var contents = String(file); @@ -32405,7 +32965,7 @@ function noHeadingIndent(tree, file) { return } - initial = start$5(node); + initial = start$7(node); begin = initial.offset; index = begin - 1; @@ -32452,84 +33012,7 @@ function noInlinePadding(tree, file) { } } -var remarkLintMaximumLineLength = unifiedLintRule('remark-lint:maximum-line-length', maximumLineLength); - -var start$6 = unistUtilPosition.start; -var end$4 = unistUtilPosition.end; - -function maximumLineLength(tree, file, pref) { - var style = typeof pref === 'number' && !isNaN(pref) ? pref : 80; - var content = String(file); - var lines = content.split(/\r?\n/); - var length = lines.length; - var index = -1; - var lineLength; - - unistUtilVisit(tree, ['heading', 'table', 'code', 'definition'], ignore); - unistUtilVisit(tree, ['link', 'image', 'inlineCode'], inline); - - /* Iterate over every line, and warn for violating lines. */ - while (++index < length) { - lineLength = lines[index].length; - - if (lineLength > style) { - file.message('Line must be at most ' + style + ' characters', { - line: index + 1, - column: lineLength + 1 - }); - } - } - - /* Finally, whitelist some inline spans, but only if they occur at or after - * the wrap. However, when they do, and there’s white-space after it, they - * are not whitelisted. */ - function inline(node, pos, parent) { - var next = parent.children[pos + 1]; - var initial; - var final; - - /* istanbul ignore if - Nothing to whitelist when generated. */ - if (unistUtilGenerated(node)) { - return - } - - initial = start$6(node); - final = end$4(node); - - /* No whitelisting when starting after the border, or ending before it. */ - if (initial.column > style || final.column < style) { - return - } - - /* No whitelisting when there’s white-space after - * the link. */ - if ( - next && - start$6(next).line === initial.line && - (!next.value || /^(.+?[ \t].+?)/.test(next.value)) - ) { - return - } - - whitelist(initial.line - 1, final.line); - } - - function ignore(node) { - /* istanbul ignore else - Hard to test, as we only run this case on `position: true` */ - if (!unistUtilGenerated(node)) { - whitelist(start$6(node).line - 1, end$4(node).line); - } - } - - /* Whitelist from `initial` to `final`, zero-based. */ - function whitelist(initial, final) { - while (initial < final) { - lines[initial++] = ''; - } - } -} - -var start$7 = unistUtilPosition.start; +var start$8 = unistUtilPosition.start; @@ -32552,7 +33035,7 @@ function noMultipleToplevelHeadings(tree, file, pref) { node ); } else { - duplicate = unistUtilStringifyPosition(start$7(node)); + duplicate = unistUtilStringifyPosition(start$8(node)); } } } @@ -32714,7 +33197,7 @@ var rule$1 = unifiedLintRule; var remarkLintRuleStyle = rule$1('remark-lint:rule-style', ruleStyle); -var start$8 = unistUtilPosition.start; +var start$9 = unistUtilPosition.start; var end$5 = unistUtilPosition.end; function ruleStyle(tree, file, pref) { @@ -32731,7 +33214,7 @@ function ruleStyle(tree, file, pref) { unistUtilVisit(tree, 'thematicBreak', visitor); function visitor(node) { - var initial = start$8(node).offset; + var initial = start$9(node).offset; var final = end$5(node).offset; var rule; @@ -32751,7 +33234,7 @@ function ruleStyle(tree, file, pref) { var remarkLintTablePipes = unifiedLintRule('remark-lint:table-pipes', tablePipes); -var start$9 = unistUtilPosition.start; +var start$10 = unistUtilPosition.start; var end$6 = unistUtilPosition.end; var reasonStart = 'Missing initial pipe in table fence'; @@ -32780,11 +33263,11 @@ function tablePipes(tree, file) { cells = row.children; head = cells[0]; tail = cells[cells.length - 1]; - initial = contents.slice(start$9(row).offset, start$9(head).offset); + initial = contents.slice(start$10(row).offset, start$10(head).offset); final = contents.slice(end$6(tail).offset, end$6(row).offset); if (initial.indexOf('|') === -1) { - file.message(reasonStart, start$9(row)); + file.message(reasonStart, start$10(row)); } if (final.indexOf('|') === -1) { @@ -32850,7 +33333,7 @@ var remarkLintCheckboxCharacterStyle = unifiedLintRule( checkboxCharacterStyle ); -var start$10 = unistUtilPosition.start; +var start$11 = unistUtilPosition.start; var end$7 = unistUtilPosition.end; var checked = {x: true, X: true}; @@ -32896,8 +33379,8 @@ function checkboxCharacterStyle(tree, file, pref) { } type = types[node.checked]; - initial = start$10(node).offset; - final = (node.children.length ? start$10(node.children[0]) : end$7(node)).offset; + initial = start$11(node).offset; + final = (node.children.length ? start$11(node.children[0]) : end$7(node)).offset; /* For a checkbox to be parsed, it must be followed by a white space. */ value = contents @@ -32931,17 +33414,17 @@ function checkboxCharacterStyle(tree, file, pref) { var remarkLintCodeBlockStyle = unifiedLintRule('remark-lint:code-block-style', codeBlockStyle); -var start$11 = unistUtilPosition.start; +var start$12 = unistUtilPosition.start; var end$8 = unistUtilPosition.end; -var styles = {null: true, fenced: true, indented: true}; +var styles$1 = {null: true, fenced: true, indented: true}; function codeBlockStyle(tree, file, pref) { var contents = String(file); pref = typeof pref === 'string' && pref !== 'consistent' ? pref : null; - if (styles[pref] !== true) { + if (styles$1[pref] !== true) { file.fail( 'Invalid code block style `' + pref + @@ -32965,7 +33448,7 @@ function codeBlockStyle(tree, file, pref) { /* Get the style of `node`. */ function check(node) { - var initial = start$11(node).offset; + var initial = start$12(node).offset; var final = end$8(node).offset; if (unistUtilGenerated(node)) { @@ -33041,7 +33524,7 @@ function fileExtension(tree, file, pref) { var remarkLintFirstHeadingLevel = unifiedLintRule('remark-lint:first-heading-level', firstHeadingLevel); -var re$4 = / processor.preprocess(rawText, effectiveFilename)), postprocess: processor && (problemLists => processor.postprocess(problemLists, effectiveFilename)) }); - const stats = calculateStatsPerFile(fixedResult.messages); const result = { @@ -203,7 +220,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor result.source = text; } - return result; + return { result, config }; } /** @@ -213,24 +230,22 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor * @param {Object} configHelper The configuration options for ESLint. * @param {Object} options The CLIEngine options object. * @param {Linter} linter Linter context - * @returns {LintResult} The results for linting on this file. + * @returns {{rules: LintResult, config: Object}} The results for linting on this text and the fully-resolved config for it. * @private */ function processFile(filename, configHelper, options, linter) { - const text = fs.readFileSync(path.resolve(filename), "utf8"), - result = processText( - text, - configHelper, - filename, - options.fix, - options.allowInlineConfig, - options.reportUnusedDisableDirectives, - linter - ); - - return result; - + const text = fs.readFileSync(path.resolve(filename), "utf8"); + + return processText( + text, + configHelper, + filename, + options.fix, + options.allowInlineConfig, + options.reportUnusedDisableDirectives, + linter + ); } /** @@ -272,6 +287,33 @@ function createIgnoreResult(filePath, baseDir) { }; } +/** + * Produces rule warnings (i.e. deprecation) from configured rules + * @param {(Array|Set)} usedRules - Rules configured + * @param {Map} loadedRules - Map of loaded rules + * @returns {Array} Contains rule warnings + * @private + */ +function createRuleDeprecationWarnings(usedRules, loadedRules) { + const usedDeprecatedRules = []; + + usedRules.forEach(name => { + const loadedRule = loadedRules.get(name); + + if (loadedRule && loadedRule.meta && loadedRule.meta.deprecated) { + const deprecatedRule = { ruleId: name }; + const replacedBy = lodash.get(loadedRule, "meta.replacedBy", []); + + if (replacedBy.every(newRule => lodash.isString(newRule))) { + deprecatedRule.replacedBy = replacedBy; + } + + usedDeprecatedRules.push(deprecatedRule); + } + }); + + return usedDeprecatedRules; +} /** * Checks if the given message is an error message. @@ -429,6 +471,33 @@ class CLIEngine { */ this._lintResultCache = new LintResultCache(cacheFile, this.config); } + + // setup special filter for fixes + if (this.options.fix && this.options.fixTypes && this.options.fixTypes.length > 0) { + + debug(`Using fix types ${this.options.fixTypes}`); + + // throw an error if any invalid fix types are found + validateFixTypes(this.options.fixTypes); + + // convert to Set for faster lookup + const fixTypes = new Set(this.options.fixTypes); + + // save original value of options.fix in case it's a function + const originalFix = (typeof this.options.fix === "function") + ? this.options.fix : () => this.options.fix; + + // create a cache of rules (but don't populate until needed) + this._rulesCache = null; + + this.options.fix = lintResult => { + const rule = this._rulesCache.get(lintResult.ruleId); + const matches = rule.meta && fixTypes.has(rule.meta.type); + + return matches && originalFix(lintResult); + }; + } + } getRules() { @@ -511,6 +580,7 @@ class CLIEngine { const startTime = Date.now(); const fileList = globUtils.listFilesToProcess(patterns, options); + const allUsedRules = new Set(); const results = fileList.map(fileInfo => { if (fileInfo.ignored) { return createIgnoreResult(fileInfo.filename, options.cwd); @@ -532,9 +602,20 @@ class CLIEngine { } } + // if there's a cache, populate it + if ("_rulesCache" in this) { + this._rulesCache = this.getRules(); + } + debug(`Processing ${fileInfo.filename}`); - return processFile(fileInfo.filename, configHelper, options, this.linter); + const { result, config } = processFile(fileInfo.filename, configHelper, options, this.linter); + + Object.keys(config.rules) + .filter(ruleId => ConfigOps.getRuleSeverity(config.rules[ruleId])) + .forEach(ruleId => allUsedRules.add(ruleId)); + + return result; }); if (options.cache) { @@ -555,6 +636,8 @@ class CLIEngine { const stats = calculateStatsPerRun(results); + const usedDeprecatedRules = createRuleDeprecationWarnings(allUsedRules, this.getRules()); + debug(`Linting complete in: ${Date.now() - startTime}ms`); return { @@ -562,7 +645,8 @@ class CLIEngine { errorCount: stats.errorCount, warningCount: stats.warningCount, fixableErrorCount: stats.fixableErrorCount, - fixableWarningCount: stats.fixableWarningCount + fixableWarningCount: stats.fixableWarningCount, + usedDeprecatedRules }; } @@ -585,22 +669,34 @@ class CLIEngine { const resolvedFilename = filename && !path.isAbsolute(filename) ? path.resolve(options.cwd, filename) : filename; + let usedDeprecatedRules; if (resolvedFilename && ignoredPaths.contains(resolvedFilename)) { if (warnIgnored) { results.push(createIgnoreResult(resolvedFilename, options.cwd)); } + usedDeprecatedRules = []; } else { - results.push( - processText( - text, - configHelper, - resolvedFilename, - options.fix, - options.allowInlineConfig, - options.reportUnusedDisableDirectives, - this.linter - ) + + // if there's a cache, populate it + if ("_rulesCache" in this) { + this._rulesCache = this.getRules(); + } + + const { result, config } = processText( + text, + configHelper, + resolvedFilename, + options.fix, + options.allowInlineConfig, + options.reportUnusedDisableDirectives, + this.linter + ); + + results.push(result); + usedDeprecatedRules = createRuleDeprecationWarnings( + Object.keys(config.rules).filter(rule => ConfigOps.getRuleSeverity(config.rules[rule])), + this.getRules() ); } @@ -611,7 +707,8 @@ class CLIEngine { errorCount: stats.errorCount, warningCount: stats.warningCount, fixableErrorCount: stats.fixableErrorCount, - fixableWarningCount: stats.fixableWarningCount + fixableWarningCount: stats.fixableWarningCount, + usedDeprecatedRules }; } diff --git a/tools/node_modules/eslint/lib/cli.js b/tools/node_modules/eslint/lib/cli.js index f854015fe9c056..f67eb7274ffa64 100644 --- a/tools/node_modules/eslint/lib/cli.js +++ b/tools/node_modules/eslint/lib/cli.js @@ -64,6 +64,7 @@ function translateOptions(cliOptions) { cacheFile: cliOptions.cacheFile, cacheLocation: cliOptions.cacheLocation, fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true), + fixTypes: cliOptions.fixType, allowInlineConfig: cliOptions.inlineConfig, reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives }; @@ -187,8 +188,12 @@ const cli = { return 2; } - const engine = new CLIEngine(translateOptions(currentOptions)); + if (currentOptions.fixType && !currentOptions.fix && !currentOptions.fixDryRun) { + log.error("The --fix-type option requires either --fix or --fix-dry-run."); + return 2; + } + const engine = new CLIEngine(translateOptions(currentOptions)); const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files); if (currentOptions.fix) { diff --git a/tools/node_modules/eslint/lib/options.js b/tools/node_modules/eslint/lib/options.js index 9265d151d5c592..ee7357a296aa05 100644 --- a/tools/node_modules/eslint/lib/options.js +++ b/tools/node_modules/eslint/lib/options.js @@ -97,6 +97,11 @@ module.exports = optionator({ default: false, description: "Automatically fix problems without saving the changes to the file system" }, + { + option: "fix-type", + type: "Array", + description: "Specify the types of fixes to apply (problem, suggestion, layout)" + }, { heading: "Ignoring files" }, diff --git a/tools/node_modules/eslint/lib/rules/accessor-pairs.js b/tools/node_modules/eslint/lib/rules/accessor-pairs.js index 68607295438594..032e89430571fa 100644 --- a/tools/node_modules/eslint/lib/rules/accessor-pairs.js +++ b/tools/node_modules/eslint/lib/rules/accessor-pairs.js @@ -72,12 +72,15 @@ function isPropertyDescriptor(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce getter and setter pairs in objects", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/accessor-pairs" }, + schema: [{ type: "object", properties: { @@ -90,6 +93,7 @@ module.exports = { }, additionalProperties: false }], + messages: { getter: "Getter is not present.", setter: "Setter is not present." 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 e8f7c502ef493d..a458e69f761687 100644 --- a/tools/node_modules/eslint/lib/rules/array-bracket-newline.js +++ b/tools/node_modules/eslint/lib/rules/array-bracket-newline.js @@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce linebreaks after opening and before closing array brackets", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/array-bracket-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ @@ -42,6 +46,7 @@ module.exports = { ] } ], + messages: { unexpectedOpeningLinebreak: "There should be no linebreak after '['.", unexpectedClosingLinebreak: "There should be no linebreak before ']'.", diff --git a/tools/node_modules/eslint/lib/rules/array-bracket-spacing.js b/tools/node_modules/eslint/lib/rules/array-bracket-spacing.js index f46c3978dfa468..4bead37a12f51e 100644 --- a/tools/node_modules/eslint/lib/rules/array-bracket-spacing.js +++ b/tools/node_modules/eslint/lib/rules/array-bracket-spacing.js @@ -12,13 +12,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing inside array brackets", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/array-bracket-spacing" }, + fixable: "whitespace", + schema: [ { enum: ["always", "never"] @@ -39,6 +43,7 @@ module.exports = { additionalProperties: false } ], + messages: { unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.", unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.", 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 4d374cf22404d4..bfee39b037bc7d 100644 --- a/tools/node_modules/eslint/lib/rules/array-callback-return.js +++ b/tools/node_modules/eslint/lib/rules/array-callback-return.js @@ -141,6 +141,8 @@ function isCallbackOfArrayMethod(node) { module.exports = { meta: { + type: "problem", + docs: { description: "enforce `return` statements in callbacks of array methods", category: "Best Practices", 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 c4caf8c71c0aac..440290917d39b0 100644 --- a/tools/node_modules/eslint/lib/rules/array-element-newline.js +++ b/tools/node_modules/eslint/lib/rules/array-element-newline.js @@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce line breaks after each array element", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/array-element-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ 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 92068c75c42463..c2ce3b59e4f436 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-body-style.js +++ b/tools/node_modules/eslint/lib/rules/arrow-body-style.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require braces around arrow function bodies", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/arrow-parens.js b/tools/node_modules/eslint/lib/rules/arrow-parens.js index 7a6ef6f8bed781..637a0c1f1f13a5 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-parens.js +++ b/tools/node_modules/eslint/lib/rules/arrow-parens.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require parentheses around arrow function arguments", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/arrow-spacing.js b/tools/node_modules/eslint/lib/rules/arrow-spacing.js index a1db18fc910bbc..87d381840a95dc 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-spacing.js +++ b/tools/node_modules/eslint/lib/rules/arrow-spacing.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before and after the arrow in arrow functions", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/block-scoped-var.js b/tools/node_modules/eslint/lib/rules/block-scoped-var.js index 1000fbc83c6557..053cfc334cd11a 100644 --- a/tools/node_modules/eslint/lib/rules/block-scoped-var.js +++ b/tools/node_modules/eslint/lib/rules/block-scoped-var.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the use of variables within the scope they are defined", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/block-spacing.js b/tools/node_modules/eslint/lib/rules/block-spacing.js index 838c2c7016b62f..6496f8596d31b7 100644 --- a/tools/node_modules/eslint/lib/rules/block-spacing.js +++ b/tools/node_modules/eslint/lib/rules/block-spacing.js @@ -13,6 +13,8 @@ const util = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "disallow or enforce spaces inside of blocks after opening block and before closing block", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/brace-style.js b/tools/node_modules/eslint/lib/rules/brace-style.js index 236a01096ab196..d172124d2f48f7 100644 --- a/tools/node_modules/eslint/lib/rules/brace-style.js +++ b/tools/node_modules/eslint/lib/rules/brace-style.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent brace style for blocks", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/callback-return.js b/tools/node_modules/eslint/lib/rules/callback-return.js index f55fed87db0598..c5263cde46b752 100644 --- a/tools/node_modules/eslint/lib/rules/callback-return.js +++ b/tools/node_modules/eslint/lib/rules/callback-return.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `return` statements after callbacks", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/camelcase.js b/tools/node_modules/eslint/lib/rules/camelcase.js index 41040450f94294..8aeb4b5bd0df92 100644 --- a/tools/node_modules/eslint/lib/rules/camelcase.js +++ b/tools/node_modules/eslint/lib/rules/camelcase.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce camelcase naming convention", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/capitalized-comments.js b/tools/node_modules/eslint/lib/rules/capitalized-comments.js index 8fabde287cc9be..86427ba7acc5d0 100644 --- a/tools/node_modules/eslint/lib/rules/capitalized-comments.js +++ b/tools/node_modules/eslint/lib/rules/capitalized-comments.js @@ -108,13 +108,17 @@ function createRegExpForIgnorePatterns(normalizedOptions) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce or disallow capitalization of the first letter of a comment", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/capitalized-comments" }, + fixable: "code", + schema: [ { enum: ["always", "never"] }, { 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 b7d94135bb70dc..a15ab6b89e480f 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 @@ -11,12 +11,15 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce that class methods utilize `this`", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/class-methods-use-this" }, + schema: [{ type: "object", properties: { diff --git a/tools/node_modules/eslint/lib/rules/comma-dangle.js b/tools/node_modules/eslint/lib/rules/comma-dangle.js index 9bc6c3fa8cc7bd..96799b30796349 100644 --- a/tools/node_modules/eslint/lib/rules/comma-dangle.js +++ b/tools/node_modules/eslint/lib/rules/comma-dangle.js @@ -76,13 +76,17 @@ function normalizeOptions(optionValue) { module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow trailing commas", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/comma-dangle" }, + fixable: "code", + schema: { definitions: { value: { diff --git a/tools/node_modules/eslint/lib/rules/comma-spacing.js b/tools/node_modules/eslint/lib/rules/comma-spacing.js index d3f82b3a4b9f14..2db0035b545348 100644 --- a/tools/node_modules/eslint/lib/rules/comma-spacing.js +++ b/tools/node_modules/eslint/lib/rules/comma-spacing.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before and after commas", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/comma-style.js b/tools/node_modules/eslint/lib/rules/comma-style.js index 7f996b344d4c16..2586cf66e9226b 100644 --- a/tools/node_modules/eslint/lib/rules/comma-style.js +++ b/tools/node_modules/eslint/lib/rules/comma-style.js @@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent comma style", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/comma-style" }, + fixable: "code", + schema: [ { enum: ["first", "last"] @@ -37,6 +41,7 @@ module.exports = { additionalProperties: false } ], + messages: { unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.", expectedCommaFirst: "',' should be placed first.", diff --git a/tools/node_modules/eslint/lib/rules/complexity.js b/tools/node_modules/eslint/lib/rules/complexity.js index bc66d303b6340f..af583c02791dd0 100644 --- a/tools/node_modules/eslint/lib/rules/complexity.js +++ b/tools/node_modules/eslint/lib/rules/complexity.js @@ -20,6 +20,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum cyclomatic complexity allowed in a program", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/computed-property-spacing.js b/tools/node_modules/eslint/lib/rules/computed-property-spacing.js index 060b2c5b40d5a2..188d863d0d0f83 100644 --- a/tools/node_modules/eslint/lib/rules/computed-property-spacing.js +++ b/tools/node_modules/eslint/lib/rules/computed-property-spacing.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing inside computed property brackets", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/consistent-return.js b/tools/node_modules/eslint/lib/rules/consistent-return.js index 6185d094fb59c0..ffd7ef20589490 100644 --- a/tools/node_modules/eslint/lib/rules/consistent-return.js +++ b/tools/node_modules/eslint/lib/rules/consistent-return.js @@ -53,6 +53,8 @@ function isClassConstructor(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `return` statements to either always or never specify values", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/consistent-this.js b/tools/node_modules/eslint/lib/rules/consistent-this.js index 5cc3a647dab551..4bdcdfdc10e8f0 100644 --- a/tools/node_modules/eslint/lib/rules/consistent-this.js +++ b/tools/node_modules/eslint/lib/rules/consistent-this.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent naming when capturing the current execution context", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/constructor-super.js b/tools/node_modules/eslint/lib/rules/constructor-super.js index 3cbc2f59f894b4..e4cdb099b3bf52 100644 --- a/tools/node_modules/eslint/lib/rules/constructor-super.js +++ b/tools/node_modules/eslint/lib/rules/constructor-super.js @@ -92,6 +92,8 @@ function isPossibleConstructor(node) { module.exports = { meta: { + type: "problem", + docs: { description: "require `super()` calls in constructors", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/curly.js b/tools/node_modules/eslint/lib/rules/curly.js index ad8da821c1cba4..ee12da71352372 100644 --- a/tools/node_modules/eslint/lib/rules/curly.js +++ b/tools/node_modules/eslint/lib/rules/curly.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent brace style for all control statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/default-case.js b/tools/node_modules/eslint/lib/rules/default-case.js index cf123198f4ae87..3061265ed8ec4f 100644 --- a/tools/node_modules/eslint/lib/rules/default-case.js +++ b/tools/node_modules/eslint/lib/rules/default-case.js @@ -12,6 +12,8 @@ const DEFAULT_COMMENT_PATTERN = /^no default$/i; module.exports = { meta: { + type: "suggestion", + docs: { description: "require `default` cases in `switch` statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/dot-location.js b/tools/node_modules/eslint/lib/rules/dot-location.js index 34d2d4eaab8d78..0eefec2eaffee0 100644 --- a/tools/node_modules/eslint/lib/rules/dot-location.js +++ b/tools/node_modules/eslint/lib/rules/dot-location.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent newlines before and after dots", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/dot-notation.js b/tools/node_modules/eslint/lib/rules/dot-notation.js index a7062df8a5babc..55ccea4ce38f4c 100644 --- a/tools/node_modules/eslint/lib/rules/dot-notation.js +++ b/tools/node_modules/eslint/lib/rules/dot-notation.js @@ -19,6 +19,8 @@ const keywords = require("../util/keywords"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce dot notation whenever possible", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/eol-last.js b/tools/node_modules/eslint/lib/rules/eol-last.js index 3ecf4227399307..84f4d45f176bbc 100644 --- a/tools/node_modules/eslint/lib/rules/eol-last.js +++ b/tools/node_modules/eslint/lib/rules/eol-last.js @@ -16,18 +16,23 @@ const lodash = require("lodash"); module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow newline at the end of files", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/eol-last" }, + fixable: "whitespace", + schema: [ { enum: ["always", "never", "unix", "windows"] } ], + messages: { missing: "Newline required at end of file but not found.", unexpected: "Newline not allowed at end of file." diff --git a/tools/node_modules/eslint/lib/rules/eqeqeq.js b/tools/node_modules/eslint/lib/rules/eqeqeq.js index 2c5e9ae9e4fdad..715c5ce7c027c7 100644 --- a/tools/node_modules/eslint/lib/rules/eqeqeq.js +++ b/tools/node_modules/eslint/lib/rules/eqeqeq.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require the use of `===` and `!==`", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/for-direction.js b/tools/node_modules/eslint/lib/rules/for-direction.js index b93c4c2caa4b66..db079b267935cb 100644 --- a/tools/node_modules/eslint/lib/rules/for-direction.js +++ b/tools/node_modules/eslint/lib/rules/for-direction.js @@ -11,14 +11,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "enforce \"for\" loop update clause moving the counter in the right direction.", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/for-direction" }, + fixable: null, schema: [], + messages: { incorrectDirection: "The update clause in this loop moves the variable in the wrong direction." } 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 9aae3e2517e05b..c49aa9e59f7e9c 100644 --- a/tools/node_modules/eslint/lib/rules/func-call-spacing.js +++ b/tools/node_modules/eslint/lib/rules/func-call-spacing.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow spacing between function identifiers and their invocations", category: "Stylistic Issues", @@ -25,6 +27,7 @@ module.exports = { }, fixable: "whitespace", + schema: { anyOf: [ { @@ -58,6 +61,7 @@ module.exports = { } ] }, + messages: { unexpected: "Unexpected newline between function name and paren.", missing: "Missing space between function name and paren." diff --git a/tools/node_modules/eslint/lib/rules/func-name-matching.js b/tools/node_modules/eslint/lib/rules/func-name-matching.js index 89c07c3514c6b2..f14c998dc7fb90 100644 --- a/tools/node_modules/eslint/lib/rules/func-name-matching.js +++ b/tools/node_modules/eslint/lib/rules/func-name-matching.js @@ -70,6 +70,8 @@ const optionsObject = { module.exports = { meta: { + type: "suggestion", + docs: { description: "require function names to match the name of the variable or property to which they are assigned", category: "Stylistic Issues", @@ -88,6 +90,7 @@ module.exports = { items: [optionsObject] }] }, + messages: { matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`", matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`", diff --git a/tools/node_modules/eslint/lib/rules/func-names.js b/tools/node_modules/eslint/lib/rules/func-names.js index 31f302918116e6..4ccbae0f0cb849 100644 --- a/tools/node_modules/eslint/lib/rules/func-names.js +++ b/tools/node_modules/eslint/lib/rules/func-names.js @@ -26,6 +26,8 @@ function isFunctionName(variable) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow named `function` expressions", category: "Stylistic Issues", @@ -58,6 +60,7 @@ module.exports = { } ] }, + messages: { unnamed: "Unexpected unnamed {{name}}.", named: "Unexpected named {{name}}." diff --git a/tools/node_modules/eslint/lib/rules/func-style.js b/tools/node_modules/eslint/lib/rules/func-style.js index ff48792d29af5d..b7e368cbd2ea08 100644 --- a/tools/node_modules/eslint/lib/rules/func-style.js +++ b/tools/node_modules/eslint/lib/rules/func-style.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the consistent use of either `function` declarations or expressions", category: "Stylistic Issues", @@ -31,6 +33,7 @@ module.exports = { additionalProperties: false } ], + messages: { expression: "Expected a function expression.", declaration: "Expected a function declaration." diff --git a/tools/node_modules/eslint/lib/rules/function-paren-newline.js b/tools/node_modules/eslint/lib/rules/function-paren-newline.js index d78e88038e2030..37256484f4a16e 100644 --- a/tools/node_modules/eslint/lib/rules/function-paren-newline.js +++ b/tools/node_modules/eslint/lib/rules/function-paren-newline.js @@ -16,13 +16,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent line breaks inside function parentheses", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/function-paren-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ @@ -42,6 +46,7 @@ module.exports = { ] } ], + messages: { expectedBefore: "Expected newline before ')'.", expectedAfter: "Expected newline after '('.", diff --git a/tools/node_modules/eslint/lib/rules/generator-star-spacing.js b/tools/node_modules/eslint/lib/rules/generator-star-spacing.js index 97868dd3fa980e..6f860290cec8b6 100644 --- a/tools/node_modules/eslint/lib/rules/generator-star-spacing.js +++ b/tools/node_modules/eslint/lib/rules/generator-star-spacing.js @@ -27,6 +27,8 @@ const OVERRIDE_SCHEMA = { module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing around `*` operators in generator functions", category: "ECMAScript 6", @@ -56,6 +58,7 @@ module.exports = { ] } ], + messages: { missingBefore: "Missing space before *.", missingAfter: "Missing space after *.", diff --git a/tools/node_modules/eslint/lib/rules/getter-return.js b/tools/node_modules/eslint/lib/rules/getter-return.js index 452ba49f595783..dc3d9d6b627e62 100644 --- a/tools/node_modules/eslint/lib/rules/getter-return.js +++ b/tools/node_modules/eslint/lib/rules/getter-return.js @@ -44,13 +44,17 @@ function getId(node) { module.exports = { meta: { + type: "problem", + docs: { description: "enforce `return` statements in getters", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/getter-return" }, + fixable: null, + schema: [ { type: "object", @@ -62,6 +66,7 @@ module.exports = { additionalProperties: false } ], + messages: { expected: "Expected to return a value in {{name}}.", expectedAlways: "Expected {{name}} to always return a value." diff --git a/tools/node_modules/eslint/lib/rules/global-require.js b/tools/node_modules/eslint/lib/rules/global-require.js index a5f5335d01dc12..6576cfb6a1f5ad 100644 --- a/tools/node_modules/eslint/lib/rules/global-require.js +++ b/tools/node_modules/eslint/lib/rules/global-require.js @@ -48,6 +48,8 @@ function isShadowed(scope, node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `require()` calls to be placed at top-level module scope", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/guard-for-in.js b/tools/node_modules/eslint/lib/rules/guard-for-in.js index 0f85e4984aa2cf..6e8452a4844a6e 100644 --- a/tools/node_modules/eslint/lib/rules/guard-for-in.js +++ b/tools/node_modules/eslint/lib/rules/guard-for-in.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `for-in` loops to include an `if` statement", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/handle-callback-err.js b/tools/node_modules/eslint/lib/rules/handle-callback-err.js index f6e6c108ce15c2..c62016d5895dcc 100644 --- a/tools/node_modules/eslint/lib/rules/handle-callback-err.js +++ b/tools/node_modules/eslint/lib/rules/handle-callback-err.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require error handling in callbacks", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/id-blacklist.js b/tools/node_modules/eslint/lib/rules/id-blacklist.js index ba9b5d4b398261..7b8facbabe0868 100644 --- a/tools/node_modules/eslint/lib/rules/id-blacklist.js +++ b/tools/node_modules/eslint/lib/rules/id-blacklist.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified identifiers", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/id-length.js b/tools/node_modules/eslint/lib/rules/id-length.js index eaed26217ddf65..d72eb08876ab37 100644 --- a/tools/node_modules/eslint/lib/rules/id-length.js +++ b/tools/node_modules/eslint/lib/rules/id-length.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce minimum and maximum identifier lengths", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/id-match.js b/tools/node_modules/eslint/lib/rules/id-match.js index 608ef17d11485b..4755c779ca96a0 100644 --- a/tools/node_modules/eslint/lib/rules/id-match.js +++ b/tools/node_modules/eslint/lib/rules/id-match.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require identifiers to match a specified regular expression", category: "Stylistic Issues", @@ -27,6 +29,12 @@ module.exports = { properties: { properties: { type: "boolean" + }, + onlyDeclarations: { + type: "boolean" + }, + ignoreDestructuring: { + type: "boolean" } } } @@ -36,15 +44,25 @@ module.exports = { create(context) { //-------------------------------------------------------------------------- - // Helpers + // Options //-------------------------------------------------------------------------- - const pattern = context.options[0] || "^.+$", regexp = new RegExp(pattern); const options = context.options[1] || {}, properties = !!options.properties, - onlyDeclarations = !!options.onlyDeclarations; + onlyDeclarations = !!options.onlyDeclarations, + ignoreDestructuring = !!options.ignoreDestructuring; + + //-------------------------------------------------------------------------- + // Helpers + //-------------------------------------------------------------------------- + + // contains reported nodes to avoid reporting twice on destructuring with shorthand notation + const reported = new Map(); + const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]); + const DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]); + const IMPORT_TYPES = new Set(["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"]); /** * Checks if a string matches the provided pattern @@ -56,6 +74,26 @@ module.exports = { return !regexp.test(name); } + /** + * Checks if a parent of a node is an ObjectPattern. + * @param {ASTNode} node The node to check. + * @returns {boolean} if the node is inside an ObjectPattern + * @private + */ + function isInsideObjectPattern(node) { + let { parent } = node; + + while (parent) { + if (parent.type === "ObjectPattern") { + return true; + } + + parent = parent.parent; + } + + return false; + } + /** * Verifies if we should report an error or not based on the effective * parent node and the identifier name. @@ -64,9 +102,8 @@ module.exports = { * @returns {boolean} whether an error should be reported or not */ function shouldReport(effectiveParent, name) { - return effectiveParent.type !== "CallExpression" && - effectiveParent.type !== "NewExpression" && - isInvalid(name); + return (!onlyDeclarations || DECLARATION_TYPES.has(effectiveParent.type)) && + !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && isInvalid(name); } /** @@ -76,14 +113,17 @@ module.exports = { * @private */ function report(node) { - context.report({ - node, - message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", - data: { - name: node.name, - pattern - } - }); + if (!reported.has(node)) { + context.report({ + node, + message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", + data: { + name: node.name, + pattern + } + }); + reported.set(node, true); + } } return { @@ -106,36 +146,70 @@ module.exports = { report(node); } - // Report AssignmentExpressions only if they are the left side of the assignment + // Report AssignmentExpressions left side's assigned variable id } else if (effectiveParent.type === "AssignmentExpression" && - (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && - effectiveParent.left.property.name === name)) { + effectiveParent.left.property.name === node.name) { + if (isInvalid(name)) { + report(node); + } + + // Report AssignmentExpressions only if they are the left side of the assignment + } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.right.type !== "MemberExpression") { if (isInvalid(name)) { report(node); } } - } else if (parent.type === "Property") { + /* + * Properties have their own rules, and + * AssignmentPattern nodes can be treated like Properties: + * e.g.: const { no_camelcased = false } = bar; + */ + } else if (parent.type === "Property" || parent.type === "AssignmentPattern") { + + if (parent.parent && parent.parent.type === "ObjectPattern") { + if (parent.shorthand && parent.value.left && isInvalid(name)) { + + report(node); + } + + const assignmentKeyEqualsValue = parent.key.name === parent.value.name; - if (!properties || parent.key.name !== name) { + // prevent checking righthand side of destructured object + if (!assignmentKeyEqualsValue && parent.key === node) { + return; + } + + const valueIsInvalid = parent.value.name && isInvalid(name); + + // ignore destructuring if the option is set, unless a new identifier is created + if (valueIsInvalid && !(assignmentKeyEqualsValue && ignoreDestructuring)) { + report(node); + } + } + + // never check properties or always ignore destructuring + if (!properties || (ignoreDestructuring && isInsideObjectPattern(node))) { return; } - if (shouldReport(effectiveParent, name)) { + // don't check right hand side of AssignmentExpression to prevent duplicate warnings + if (parent.right !== node && shouldReport(effectiveParent, name)) { report(node); } - } else { - const isDeclaration = effectiveParent.type === "FunctionDeclaration" || effectiveParent.type === "VariableDeclarator"; + // Check if it's an import specifier + } else if (IMPORT_TYPES.has(parent.type)) { - if (onlyDeclarations && !isDeclaration) { - return; - } - - if (shouldReport(effectiveParent, name)) { + // Report only if the local imported identifier is invalid + if (parent.local && parent.local.name === node.name && isInvalid(name)) { report(node); } + + // Report anything that is invalid that isn't a CallExpression + } else if (shouldReport(effectiveParent, name)) { + report(node); } } diff --git a/tools/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js b/tools/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js index a7ad1122b50544..cd729f8ad931ee 100644 --- a/tools/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js +++ b/tools/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js @@ -9,13 +9,17 @@ //------------------------------------------------------------------------------ module.exports = { meta: { + type: "layout", + docs: { description: "enforce the location of arrow function bodies", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/implicit-arrow-linebreak" }, + fixable: "whitespace", + schema: [ { enum: ["beside", "below"] diff --git a/tools/node_modules/eslint/lib/rules/indent-legacy.js b/tools/node_modules/eslint/lib/rules/indent-legacy.js index e6dc92163b0bbb..16687b521ed31a 100644 --- a/tools/node_modules/eslint/lib/rules/indent-legacy.js +++ b/tools/node_modules/eslint/lib/rules/indent-legacy.js @@ -21,16 +21,19 @@ const astUtils = require("../util/ast-utils"); /* istanbul ignore next: this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway. */ module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent indentation", category: "Stylistic Issues", recommended: false, - replacedBy: ["indent"], url: "https://eslint.org/docs/rules/indent-legacy" }, deprecated: true, + replacedBy: ["indent"], + fixable: "whitespace", schema: [ diff --git a/tools/node_modules/eslint/lib/rules/indent.js b/tools/node_modules/eslint/lib/rules/indent.js index 940c080a0378d4..dc9fbaf908b815 100644 --- a/tools/node_modules/eslint/lib/rules/indent.js +++ b/tools/node_modules/eslint/lib/rules/indent.js @@ -490,6 +490,8 @@ const ELEMENT_LIST_SCHEMA = { module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent indentation", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/init-declarations.js b/tools/node_modules/eslint/lib/rules/init-declarations.js index 412b96dc0abff9..755090917f909b 100644 --- a/tools/node_modules/eslint/lib/rules/init-declarations.js +++ b/tools/node_modules/eslint/lib/rules/init-declarations.js @@ -44,6 +44,8 @@ function isInitialized(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow initialization in variable declarations", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/jsx-quotes.js b/tools/node_modules/eslint/lib/rules/jsx-quotes.js index 3dd9567d7374e4..603d55330b536c 100644 --- a/tools/node_modules/eslint/lib/rules/jsx-quotes.js +++ b/tools/node_modules/eslint/lib/rules/jsx-quotes.js @@ -38,6 +38,8 @@ const QUOTE_SETTINGS = { module.exports = { meta: { + type: "layout", + docs: { description: "enforce the consistent use of either double or single quotes in JSX attributes", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/key-spacing.js b/tools/node_modules/eslint/lib/rules/key-spacing.js index 75578b2c747c3b..2d1315fde09271 100644 --- a/tools/node_modules/eslint/lib/rules/key-spacing.js +++ b/tools/node_modules/eslint/lib/rules/key-spacing.js @@ -128,6 +128,8 @@ const messages = { module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing between keys and values in object literal properties", category: "Stylistic Issues", @@ -360,10 +362,9 @@ module.exports = { */ function isKeyValueProperty(property) { return !( - property.method || + (property.method || property.shorthand || - property.kind !== "init" || - property.type !== "Property" // Could be "ExperimentalSpreadProperty" or "SpreadElement" + property.kind !== "init" || property.type !== "Property") // Could be "ExperimentalSpreadProperty" or "SpreadElement" ); } diff --git a/tools/node_modules/eslint/lib/rules/keyword-spacing.js b/tools/node_modules/eslint/lib/rules/keyword-spacing.js index 2a66779e7aaad1..66ce2cb34c0e2b 100644 --- a/tools/node_modules/eslint/lib/rules/keyword-spacing.js +++ b/tools/node_modules/eslint/lib/rules/keyword-spacing.js @@ -65,6 +65,8 @@ function isCloseParenOfTemplate(token) { module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before and after keywords", category: "Stylistic Issues", 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 7f45a94b6b5679..7c791d5f2778bd 100644 --- a/tools/node_modules/eslint/lib/rules/line-comment-position.js +++ b/tools/node_modules/eslint/lib/rules/line-comment-position.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce position of line comments", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/linebreak-style.js b/tools/node_modules/eslint/lib/rules/linebreak-style.js index cd432dbcca160c..5345d53f2887f6 100644 --- a/tools/node_modules/eslint/lib/rules/linebreak-style.js +++ b/tools/node_modules/eslint/lib/rules/linebreak-style.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent linebreak style", category: "Stylistic Issues", 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 67fd2032b3ea0d..30175cd3663509 100644 --- a/tools/node_modules/eslint/lib/rules/lines-around-comment.js +++ b/tools/node_modules/eslint/lib/rules/lines-around-comment.js @@ -52,6 +52,8 @@ function getCommentLineNums(comments) { module.exports = { meta: { + type: "layout", + docs: { description: "require empty lines around comments", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/lines-around-directive.js b/tools/node_modules/eslint/lib/rules/lines-around-directive.js index e8d613a41f03af..02bbe13b4fc589 100644 --- a/tools/node_modules/eslint/lib/rules/lines-around-directive.js +++ b/tools/node_modules/eslint/lib/rules/lines-around-directive.js @@ -14,13 +14,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow newlines around directives", category: "Stylistic Issues", recommended: false, - replacedBy: ["padding-line-between-statements"], url: "https://eslint.org/docs/rules/lines-around-directive" }, + schema: [{ oneOf: [ { @@ -41,8 +43,10 @@ module.exports = { } ] }], + fixable: "whitespace", - deprecated: true + deprecated: true, + replacedBy: ["padding-line-between-statements"] }, create(context) { 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 8d4e6dd8c18268..5c1e69277a52f3 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 @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow an empty line between class members", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/max-classes-per-file.js b/tools/node_modules/eslint/lib/rules/max-classes-per-file.js index bf6b4ba31c6c1e..3193a731c94e33 100644 --- a/tools/node_modules/eslint/lib/rules/max-classes-per-file.js +++ b/tools/node_modules/eslint/lib/rules/max-classes-per-file.js @@ -15,18 +15,22 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum number of classes per file", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/max-classes-per-file" }, + schema: [ { type: "integer", minimum: 1 } ], + messages: { maximumExceeded: "Number of classes per file must not exceed {{ max }}" } diff --git a/tools/node_modules/eslint/lib/rules/max-depth.js b/tools/node_modules/eslint/lib/rules/max-depth.js index 368dcfa6681a77..34d58b0d31e10e 100644 --- a/tools/node_modules/eslint/lib/rules/max-depth.js +++ b/tools/node_modules/eslint/lib/rules/max-depth.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum depth that blocks can be nested", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/max-len.js b/tools/node_modules/eslint/lib/rules/max-len.js index 88a388309b2cdf..13dd72160cc879 100644 --- a/tools/node_modules/eslint/lib/rules/max-len.js +++ b/tools/node_modules/eslint/lib/rules/max-len.js @@ -65,6 +65,8 @@ const OPTIONS_OR_INTEGER_SCHEMA = { module.exports = { meta: { + type: "layout", + docs: { description: "enforce a maximum line length", category: "Stylistic Issues", 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 ccf6304e4b27ea..8c64a20bcc34c3 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 @@ -69,6 +69,8 @@ function getCommentLineNumbers(comments) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum number of line of code in a function", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/max-lines.js b/tools/node_modules/eslint/lib/rules/max-lines.js index 7eb959795abea7..730e05ab41cf11 100644 --- a/tools/node_modules/eslint/lib/rules/max-lines.js +++ b/tools/node_modules/eslint/lib/rules/max-lines.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum number of lines per file", category: "Stylistic Issues", 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 8cc80ae7aab41a..d4ecb4e2a5c2c3 100644 --- a/tools/node_modules/eslint/lib/rules/max-nested-callbacks.js +++ b/tools/node_modules/eslint/lib/rules/max-nested-callbacks.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum depth that callbacks can be nested", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/max-params.js b/tools/node_modules/eslint/lib/rules/max-params.js index 4089e8ae899359..f678974acf33d2 100644 --- a/tools/node_modules/eslint/lib/rules/max-params.js +++ b/tools/node_modules/eslint/lib/rules/max-params.js @@ -19,6 +19,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum number of parameters in function definitions", category: "Stylistic Issues", 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 566f04ab53b056..f3fb8e9d5cff3c 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 @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce a maximum number of statements allowed per line", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/max-statements.js b/tools/node_modules/eslint/lib/rules/max-statements.js index 525790df80623e..e32dedad632f3f 100644 --- a/tools/node_modules/eslint/lib/rules/max-statements.js +++ b/tools/node_modules/eslint/lib/rules/max-statements.js @@ -19,6 +19,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a maximum number of statements allowed in function blocks", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/multiline-comment-style.js b/tools/node_modules/eslint/lib/rules/multiline-comment-style.js index 5dd39e00a7723a..73eab7c5741bb6 100644 --- a/tools/node_modules/eslint/lib/rules/multiline-comment-style.js +++ b/tools/node_modules/eslint/lib/rules/multiline-comment-style.js @@ -12,12 +12,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce a particular style for multiline comments", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/multiline-comment-style" }, + fixable: "whitespace", schema: [{ enum: ["starred-block", "separate-lines", "bare-block"] }] }, diff --git a/tools/node_modules/eslint/lib/rules/multiline-ternary.js b/tools/node_modules/eslint/lib/rules/multiline-ternary.js index 6a22a1113c1580..d1d577a4ffaca1 100644 --- a/tools/node_modules/eslint/lib/rules/multiline-ternary.js +++ b/tools/node_modules/eslint/lib/rules/multiline-ternary.js @@ -13,12 +13,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce newlines between operands of ternary expressions", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/multiline-ternary" }, + schema: [ { enum: ["always", "always-multiline", "never"] diff --git a/tools/node_modules/eslint/lib/rules/new-cap.js b/tools/node_modules/eslint/lib/rules/new-cap.js index cc33e3b8175483..834f4605ed2838 100644 --- a/tools/node_modules/eslint/lib/rules/new-cap.js +++ b/tools/node_modules/eslint/lib/rules/new-cap.js @@ -74,6 +74,8 @@ function calculateCapIsNewExceptions(config) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require constructor names to begin with a capital letter", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/new-parens.js b/tools/node_modules/eslint/lib/rules/new-parens.js index fab302000c9c19..0637a8fbca24c7 100644 --- a/tools/node_modules/eslint/lib/rules/new-parens.js +++ b/tools/node_modules/eslint/lib/rules/new-parens.js @@ -21,6 +21,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require parentheses when invoking a constructor with no arguments", category: "Stylistic Issues", @@ -29,7 +31,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/newline-after-var.js b/tools/node_modules/eslint/lib/rules/newline-after-var.js index 62ccb3db29e97e..83fd420d733234 100644 --- a/tools/node_modules/eslint/lib/rules/newline-after-var.js +++ b/tools/node_modules/eslint/lib/rules/newline-after-var.js @@ -18,11 +18,12 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow an empty line after variable declarations", category: "Stylistic Issues", recommended: false, - replacedBy: ["padding-line-between-statements"], url: "https://eslint.org/docs/rules/newline-after-var" }, @@ -34,7 +35,9 @@ module.exports = { fixable: "whitespace", - deprecated: true + deprecated: true, + + replacedBy: ["padding-line-between-statements"] }, create(context) { diff --git a/tools/node_modules/eslint/lib/rules/newline-before-return.js b/tools/node_modules/eslint/lib/rules/newline-before-return.js index 5bc1f7031b057a..2743bf7a8bea34 100644 --- a/tools/node_modules/eslint/lib/rules/newline-before-return.js +++ b/tools/node_modules/eslint/lib/rules/newline-before-return.js @@ -11,16 +11,19 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require an empty line before `return` statements", category: "Stylistic Issues", recommended: false, - replacedBy: ["padding-line-between-statements"], url: "https://eslint.org/docs/rules/newline-before-return" }, + fixable: "whitespace", schema: [], - deprecated: true + deprecated: true, + replacedBy: ["padding-line-between-statements"] }, create(context) { 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 2adcdfe45a6009..9d9931376829a6 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 @@ -14,13 +14,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require a newline after each call in a method chain", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/newline-per-chained-call" }, + fixable: "whitespace", + schema: [{ type: "object", properties: { diff --git a/tools/node_modules/eslint/lib/rules/no-alert.js b/tools/node_modules/eslint/lib/rules/no-alert.js index 1c08460f340b91..21f10b3c399397 100644 --- a/tools/node_modules/eslint/lib/rules/no-alert.js +++ b/tools/node_modules/eslint/lib/rules/no-alert.js @@ -74,6 +74,8 @@ function isGlobalThisReferenceOrGlobalWindow(scope, node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `alert`, `confirm`, and `prompt`", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-array-constructor.js b/tools/node_modules/eslint/lib/rules/no-array-constructor.js index 51676f782119a6..90c6d6bbd59281 100644 --- a/tools/node_modules/eslint/lib/rules/no-array-constructor.js +++ b/tools/node_modules/eslint/lib/rules/no-array-constructor.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `Array` constructors", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-async-promise-executor.js b/tools/node_modules/eslint/lib/rules/no-async-promise-executor.js index 55d489eb6dd586..fc65f539a3e6aa 100644 --- a/tools/node_modules/eslint/lib/rules/no-async-promise-executor.js +++ b/tools/node_modules/eslint/lib/rules/no-async-promise-executor.js @@ -10,12 +10,15 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow using an async function as a Promise executor", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-async-promise-executor" }, + fixable: null, schema: [] }, diff --git a/tools/node_modules/eslint/lib/rules/no-await-in-loop.js b/tools/node_modules/eslint/lib/rules/no-await-in-loop.js index ef0bda90bf95e5..9ca89866a6e114 100644 --- a/tools/node_modules/eslint/lib/rules/no-await-in-loop.js +++ b/tools/node_modules/eslint/lib/rules/no-await-in-loop.js @@ -55,13 +55,17 @@ function isLooped(node, parent) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow `await` inside of loops", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-await-in-loop" }, + schema: [], + messages: { unexpectedAwait: "Unexpected `await` inside a loop." } diff --git a/tools/node_modules/eslint/lib/rules/no-bitwise.js b/tools/node_modules/eslint/lib/rules/no-bitwise.js index 36bbdaf349cfdf..df492937c0b5bb 100644 --- a/tools/node_modules/eslint/lib/rules/no-bitwise.js +++ b/tools/node_modules/eslint/lib/rules/no-bitwise.js @@ -22,6 +22,8 @@ const BITWISE_OPERATORS = [ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow bitwise operators", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-buffer-constructor.js b/tools/node_modules/eslint/lib/rules/no-buffer-constructor.js index 51f78edb1fee62..bf4c8891ad1adf 100644 --- a/tools/node_modules/eslint/lib/rules/no-buffer-constructor.js +++ b/tools/node_modules/eslint/lib/rules/no-buffer-constructor.js @@ -10,13 +10,17 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow use of the `Buffer()` constructor", category: "Node.js and CommonJS", recommended: false, url: "https://eslint.org/docs/rules/no-buffer-constructor" }, + schema: [], + messages: { deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead." } diff --git a/tools/node_modules/eslint/lib/rules/no-caller.js b/tools/node_modules/eslint/lib/rules/no-caller.js index 9756b212ffe5f8..1703ad867dc0a6 100644 --- a/tools/node_modules/eslint/lib/rules/no-caller.js +++ b/tools/node_modules/eslint/lib/rules/no-caller.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `arguments.caller` or `arguments.callee`", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-case-declarations.js b/tools/node_modules/eslint/lib/rules/no-case-declarations.js index c05795200e6679..1d54e221625e70 100644 --- a/tools/node_modules/eslint/lib/rules/no-case-declarations.js +++ b/tools/node_modules/eslint/lib/rules/no-case-declarations.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow lexical declarations in case clauses", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-catch-shadow.js b/tools/node_modules/eslint/lib/rules/no-catch-shadow.js index f749490f31e463..60a0493b3431a8 100644 --- a/tools/node_modules/eslint/lib/rules/no-catch-shadow.js +++ b/tools/node_modules/eslint/lib/rules/no-catch-shadow.js @@ -18,15 +18,18 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `catch` clause parameters from shadowing variables in the outer scope", category: "Variables", recommended: false, - url: "https://eslint.org/docs/rules/no-catch-shadow", - replacedBy: ["no-shadow"] + url: "https://eslint.org/docs/rules/no-catch-shadow" }, - deprecated: true, + replacedBy: ["no-shadow"], + + deprecated: true, schema: [], messages: { diff --git a/tools/node_modules/eslint/lib/rules/no-class-assign.js b/tools/node_modules/eslint/lib/rules/no-class-assign.js index 9b28d40d4a3801..7bc65df1ba6004 100644 --- a/tools/node_modules/eslint/lib/rules/no-class-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-class-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow reassigning class members", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-compare-neg-zero.js b/tools/node_modules/eslint/lib/rules/no-compare-neg-zero.js index 6903bd06544edd..f5c8d5f417b20a 100644 --- a/tools/node_modules/eslint/lib/rules/no-compare-neg-zero.js +++ b/tools/node_modules/eslint/lib/rules/no-compare-neg-zero.js @@ -10,14 +10,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow comparing against -0", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-compare-neg-zero" }, + fixable: null, schema: [], + messages: { unexpected: "Do not use the '{{operator}}' operator to compare against -0." } diff --git a/tools/node_modules/eslint/lib/rules/no-cond-assign.js b/tools/node_modules/eslint/lib/rules/no-cond-assign.js index caf9563e9521bc..aed3e4a7a9b642 100644 --- a/tools/node_modules/eslint/lib/rules/no-cond-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-cond-assign.js @@ -19,6 +19,8 @@ const NODE_DESCRIPTIONS = { module.exports = { meta: { + type: "problem", + docs: { description: "disallow assignment operators in conditional expressions", category: "Possible Errors", 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 503174e9a67eeb..f18ec194530c19 100644 --- a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js +++ b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js @@ -27,6 +27,8 @@ function isConditional(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow arrow functions where they could be confused with comparisons", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-console.js b/tools/node_modules/eslint/lib/rules/no-console.js index 5fb3a159be82d7..d3a2e34475168f 100644 --- a/tools/node_modules/eslint/lib/rules/no-console.js +++ b/tools/node_modules/eslint/lib/rules/no-console.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `console`", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-const-assign.js b/tools/node_modules/eslint/lib/rules/no-const-assign.js index 3188bd34d3b28d..32f8154cc23eae 100644 --- a/tools/node_modules/eslint/lib/rules/no-const-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-const-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow reassigning `const` variables", category: "ECMAScript 6", 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 48b1fbf689f966..88984c36e7f70f 100644 --- a/tools/node_modules/eslint/lib/rules/no-constant-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-constant-condition.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow constant expressions in conditions", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-continue.js b/tools/node_modules/eslint/lib/rules/no-continue.js index 3075b77f9fdebd..96718d17a3db4b 100644 --- a/tools/node_modules/eslint/lib/rules/no-continue.js +++ b/tools/node_modules/eslint/lib/rules/no-continue.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `continue` statements", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-control-regex.js b/tools/node_modules/eslint/lib/rules/no-control-regex.js index 24bb6be6671edd..24e6b197be0b44 100644 --- a/tools/node_modules/eslint/lib/rules/no-control-regex.js +++ b/tools/node_modules/eslint/lib/rules/no-control-regex.js @@ -6,7 +6,7 @@ "use strict"; const RegExpValidator = require("regexpp").RegExpValidator; -const collector = new class { +const collector = new (class { constructor() { this.ecmaVersion = 2018; this._source = ""; @@ -41,7 +41,7 @@ const collector = new class { } return this._controlChars; } -}(); +})(); //------------------------------------------------------------------------------ // Rule Definition @@ -49,6 +49,8 @@ const collector = new class { module.exports = { meta: { + type: "problem", + docs: { description: "disallow control characters in regular expressions", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-debugger.js b/tools/node_modules/eslint/lib/rules/no-debugger.js index 5d63bb7e141e0c..95a28a862151be 100644 --- a/tools/node_modules/eslint/lib/rules/no-debugger.js +++ b/tools/node_modules/eslint/lib/rules/no-debugger.js @@ -11,14 +11,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow the use of `debugger`", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-debugger" }, + fixable: null, schema: [], + messages: { unexpected: "Unexpected 'debugger' statement." } diff --git a/tools/node_modules/eslint/lib/rules/no-delete-var.js b/tools/node_modules/eslint/lib/rules/no-delete-var.js index f54a396ec2d552..aeab951d75ff82 100644 --- a/tools/node_modules/eslint/lib/rules/no-delete-var.js +++ b/tools/node_modules/eslint/lib/rules/no-delete-var.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow deleting variables", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-div-regex.js b/tools/node_modules/eslint/lib/rules/no-div-regex.js index c050249fd6ef6c..408e006528b584 100644 --- a/tools/node_modules/eslint/lib/rules/no-div-regex.js +++ b/tools/node_modules/eslint/lib/rules/no-div-regex.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow division operators explicitly at the beginning of regular expressions", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-dupe-args.js b/tools/node_modules/eslint/lib/rules/no-dupe-args.js index e5a7f4154e72bf..4e42336ae3dc34 100644 --- a/tools/node_modules/eslint/lib/rules/no-dupe-args.js +++ b/tools/node_modules/eslint/lib/rules/no-dupe-args.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate arguments in `function` definitions", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js b/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js index d0fc35973608df..97f63a2896282b 100644 --- a/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js +++ b/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate class members", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-dupe-keys.js b/tools/node_modules/eslint/lib/rules/no-dupe-keys.js index 31493bd048d0a8..9b9c02f5efc9a1 100644 --- a/tools/node_modules/eslint/lib/rules/no-dupe-keys.js +++ b/tools/node_modules/eslint/lib/rules/no-dupe-keys.js @@ -84,6 +84,8 @@ class ObjectInfo { module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate keys in object literals", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-duplicate-case.js b/tools/node_modules/eslint/lib/rules/no-duplicate-case.js index 128b1fc1b1cf8e..93c8548f91ad75 100644 --- a/tools/node_modules/eslint/lib/rules/no-duplicate-case.js +++ b/tools/node_modules/eslint/lib/rules/no-duplicate-case.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate case labels", category: "Possible Errors", 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 32071da15fd2cf..1d5bdfdc1a2631 100644 --- a/tools/node_modules/eslint/lib/rules/no-duplicate-imports.js +++ b/tools/node_modules/eslint/lib/rules/no-duplicate-imports.js @@ -101,6 +101,8 @@ function handleExports(context, importsInFile, exportsInFile) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow duplicate module imports", category: "ECMAScript 6", 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 1000fa807ac1f2..eebdec76e0e7d4 100644 --- a/tools/node_modules/eslint/lib/rules/no-else-return.js +++ b/tools/node_modules/eslint/lib/rules/no-else-return.js @@ -18,6 +18,8 @@ const FixTracker = require("../util/fix-tracker"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `else` blocks after `return` statements in `if` statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-empty-character-class.js b/tools/node_modules/eslint/lib/rules/no-empty-character-class.js index e3f06b069a8661..6d2fb3c50186b2 100644 --- a/tools/node_modules/eslint/lib/rules/no-empty-character-class.js +++ b/tools/node_modules/eslint/lib/rules/no-empty-character-class.js @@ -29,6 +29,8 @@ const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+])*\/[gimuys]*$/; module.exports = { meta: { + type: "problem", + docs: { description: "disallow empty character classes in regular expressions", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-empty-function.js b/tools/node_modules/eslint/lib/rules/no-empty-function.js index c8039314ab0075..a443796e4e2861 100644 --- a/tools/node_modules/eslint/lib/rules/no-empty-function.js +++ b/tools/node_modules/eslint/lib/rules/no-empty-function.js @@ -90,6 +90,8 @@ function getKind(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow empty functions", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-empty-pattern.js b/tools/node_modules/eslint/lib/rules/no-empty-pattern.js index 939710560fab0a..9f34bfde92e2e9 100644 --- a/tools/node_modules/eslint/lib/rules/no-empty-pattern.js +++ b/tools/node_modules/eslint/lib/rules/no-empty-pattern.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow empty destructuring patterns", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-empty.js b/tools/node_modules/eslint/lib/rules/no-empty.js index 2f4c258a26fd32..9d72969e67eb6f 100644 --- a/tools/node_modules/eslint/lib/rules/no-empty.js +++ b/tools/node_modules/eslint/lib/rules/no-empty.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow empty block statements", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-eq-null.js b/tools/node_modules/eslint/lib/rules/no-eq-null.js index eadd16de37f39c..b8dead96d2514c 100644 --- a/tools/node_modules/eslint/lib/rules/no-eq-null.js +++ b/tools/node_modules/eslint/lib/rules/no-eq-null.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `null` comparisons without type-checking operators", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-eval.js b/tools/node_modules/eslint/lib/rules/no-eval.js index c3ea87d466d7e6..39d91e776e9c79 100644 --- a/tools/node_modules/eslint/lib/rules/no-eval.js +++ b/tools/node_modules/eslint/lib/rules/no-eval.js @@ -76,6 +76,8 @@ function isMember(node, name) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `eval()`", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-ex-assign.js b/tools/node_modules/eslint/lib/rules/no-ex-assign.js index 1c7beccf89e08e..4cc179a6e8f00f 100644 --- a/tools/node_modules/eslint/lib/rules/no-ex-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-ex-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow reassigning exceptions in `catch` clauses", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-extend-native.js b/tools/node_modules/eslint/lib/rules/no-extend-native.js index a1bf49f1325eff..13895f0d06bb1b 100644 --- a/tools/node_modules/eslint/lib/rules/no-extend-native.js +++ b/tools/node_modules/eslint/lib/rules/no-extend-native.js @@ -24,6 +24,8 @@ const propertyDefinitionMethods = new Set(["defineProperty", "defineProperties"] module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow extending native types", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-extra-bind.js b/tools/node_modules/eslint/lib/rules/no-extra-bind.js index 6d6cad13e97deb..abbe1868e89837 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-bind.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-bind.js @@ -22,6 +22,8 @@ const SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpre module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary calls to `.bind()`", category: "Best Practices", @@ -30,7 +32,6 @@ module.exports = { }, schema: [], - fixable: "code", messages: { diff --git a/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js b/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js index 5eac6b53fe4f19..615603177a5a76 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary boolean casts", category: "Possible Errors", @@ -25,7 +27,6 @@ module.exports = { }, schema: [], - fixable: "code", messages: { diff --git a/tools/node_modules/eslint/lib/rules/no-extra-label.js b/tools/node_modules/eslint/lib/rules/no-extra-label.js index 9310e90f71e7a9..f8acf7b2834fde 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-label.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-label.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary labels", category: "Best Practices", @@ -25,7 +27,6 @@ module.exports = { }, schema: [], - fixable: "code", messages: { 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 47c58946cf18e1..3a21b69580b820 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-parens.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-parens.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils.js"); module.exports = { meta: { + type: "layout", + docs: { description: "disallow unnecessary parentheses", category: "Possible Errors", @@ -382,8 +384,7 @@ module.exports = { * Allow extra parens around a new expression if * there are intervening parentheses. */ - callee.type === "MemberExpression" && - doesMemberExpressionContainCallExpression(callee) + (callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee)) ) ) { report(node.callee); @@ -574,15 +575,13 @@ module.exports = { * If `let` is the only thing on the left side of the loop, it's the loop variable: `for ((let) of foo);` * Removing it will cause a syntax error, because it will be parsed as the start of a VariableDeclarator. */ - firstLeftToken.range[1] === node.left.range[1] || - - /* + (firstLeftToken.range[1] === node.left.range[1] || /* * If `let` is followed by a `[` token, it's a property access on the `let` value: `for ((let[foo]) of bar);` * Removing it will cause the property access to be parsed as a destructuring declaration of `foo` instead. */ astUtils.isOpeningBracketToken( sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken) - ) + )) ) ) { tokensToIgnore.add(firstLeftToken); diff --git a/tools/node_modules/eslint/lib/rules/no-extra-semi.js b/tools/node_modules/eslint/lib/rules/no-extra-semi.js index 4d40b5e1538123..d87a181672f851 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-semi.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-semi.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary semicolons", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-fallthrough.js b/tools/node_modules/eslint/lib/rules/no-fallthrough.js index ce4f91ad9643ce..b7fa221050dd94 100644 --- a/tools/node_modules/eslint/lib/rules/no-fallthrough.js +++ b/tools/node_modules/eslint/lib/rules/no-fallthrough.js @@ -55,6 +55,8 @@ function hasBlankLinesBetween(node, token) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow fallthrough of `case` statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-floating-decimal.js b/tools/node_modules/eslint/lib/rules/no-floating-decimal.js index a62846cc10ff95..c835d6a545fa8e 100644 --- a/tools/node_modules/eslint/lib/rules/no-floating-decimal.js +++ b/tools/node_modules/eslint/lib/rules/no-floating-decimal.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow leading or trailing decimal points in numeric literals", category: "Best Practices", @@ -25,7 +27,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/no-func-assign.js b/tools/node_modules/eslint/lib/rules/no-func-assign.js index 029f6a9d7d15c3..ae96ab01f43057 100644 --- a/tools/node_modules/eslint/lib/rules/no-func-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-func-assign.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow reassigning `function` declarations", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-global-assign.js b/tools/node_modules/eslint/lib/rules/no-global-assign.js index 3397bdbe0009fc..73f36b25e4763e 100644 --- a/tools/node_modules/eslint/lib/rules/no-global-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-global-assign.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignments to native objects or read-only global variables", category: "Best Practices", 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 3bfe3f0d3a2c3f..826d9398cab56e 100644 --- a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js +++ b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js @@ -152,6 +152,8 @@ function getNonEmptyOperand(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow shorthand type conversions", category: "Best Practices", @@ -160,6 +162,7 @@ module.exports = { }, fixable: "code", + schema: [{ type: "object", properties: { diff --git a/tools/node_modules/eslint/lib/rules/no-implicit-globals.js b/tools/node_modules/eslint/lib/rules/no-implicit-globals.js index c4717b6a374e86..2eea2b28463250 100644 --- a/tools/node_modules/eslint/lib/rules/no-implicit-globals.js +++ b/tools/node_modules/eslint/lib/rules/no-implicit-globals.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow variable and `function` declarations in the global scope", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-implied-eval.js b/tools/node_modules/eslint/lib/rules/no-implied-eval.js index de294bc8858f94..d31b5dfee8041f 100644 --- a/tools/node_modules/eslint/lib/rules/no-implied-eval.js +++ b/tools/node_modules/eslint/lib/rules/no-implied-eval.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `eval()`-like methods", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-inline-comments.js b/tools/node_modules/eslint/lib/rules/no-inline-comments.js index 2fb21909229c11..c282d16e75411a 100644 --- a/tools/node_modules/eslint/lib/rules/no-inline-comments.js +++ b/tools/node_modules/eslint/lib/rules/no-inline-comments.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow inline comments after code", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-inner-declarations.js b/tools/node_modules/eslint/lib/rules/no-inner-declarations.js index 032c0a0f096788..60508d3e864eda 100644 --- a/tools/node_modules/eslint/lib/rules/no-inner-declarations.js +++ b/tools/node_modules/eslint/lib/rules/no-inner-declarations.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow variable or `function` declarations in nested blocks", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js index 7169e0ca77054c..74659001fdb9ce 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js @@ -19,6 +19,8 @@ const undefined1 = void 0; module.exports = { meta: { + type: "problem", + docs: { description: "disallow invalid regular expression strings in `RegExp` constructors", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-invalid-this.js b/tools/node_modules/eslint/lib/rules/no-invalid-this.js index 480deebc14cded..e9be4445260bdb 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-this.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-this.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `this` keywords outside of classes or class-like objects", category: "Best Practices", 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 de6934c635ac33..7920ebdc564857 100644 --- a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js @@ -27,6 +27,8 @@ const LINE_BREAK = astUtils.createGlobalLinebreakMatcher(); module.exports = { meta: { + type: "problem", + docs: { description: "disallow irregular whitespace outside of strings and comments", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-iterator.js b/tools/node_modules/eslint/lib/rules/no-iterator.js index ca12fcda477639..82319a3fb1dfb6 100644 --- a/tools/node_modules/eslint/lib/rules/no-iterator.js +++ b/tools/node_modules/eslint/lib/rules/no-iterator.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of the `__iterator__` property", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-label-var.js b/tools/node_modules/eslint/lib/rules/no-label-var.js index 3f5aba4fc1e326..fdba2defc350c6 100644 --- a/tools/node_modules/eslint/lib/rules/no-label-var.js +++ b/tools/node_modules/eslint/lib/rules/no-label-var.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow labels that share a name with a variable", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-labels.js b/tools/node_modules/eslint/lib/rules/no-labels.js index bd6ec57a350e0f..34db20725b0af3 100644 --- a/tools/node_modules/eslint/lib/rules/no-labels.js +++ b/tools/node_modules/eslint/lib/rules/no-labels.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow labeled statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-lone-blocks.js b/tools/node_modules/eslint/lib/rules/no-lone-blocks.js index 5e22aacf00f8a6..6b51795863b379 100644 --- a/tools/node_modules/eslint/lib/rules/no-lone-blocks.js +++ b/tools/node_modules/eslint/lib/rules/no-lone-blocks.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary nested blocks", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-lonely-if.js b/tools/node_modules/eslint/lib/rules/no-lonely-if.js index 3ecc41e8cf6e22..4bbb5399ff9519 100644 --- a/tools/node_modules/eslint/lib/rules/no-lonely-if.js +++ b/tools/node_modules/eslint/lib/rules/no-lonely-if.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `if` statements as the only statement in `else` blocks", category: "Stylistic Issues", @@ -18,7 +20,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/no-loop-func.js b/tools/node_modules/eslint/lib/rules/no-loop-func.js index d103cb5335083f..e6063806a5dec2 100644 --- a/tools/node_modules/eslint/lib/rules/no-loop-func.js +++ b/tools/node_modules/eslint/lib/rules/no-loop-func.js @@ -154,6 +154,8 @@ function isSafe(loopNode, reference) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `function` declarations and expressions inside loop statements", category: "Best Practices", 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 b70ca82675089d..84c08dfb08e717 100644 --- a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js +++ b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow magic numbers", category: "Best Practices", @@ -40,6 +42,7 @@ module.exports = { }, additionalProperties: false }], + messages: { useConst: "Number constants declarations must use 'const'.", noMagic: "No magic number: {{raw}}." diff --git a/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js b/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js index e410efed9c943b..4fa650ed52725a 100644 --- a/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js +++ b/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js @@ -101,13 +101,17 @@ const kinds = Object.keys(hasCharacterSequence); module.exports = { meta: { + type: "problem", + docs: { description: "disallow characters which are made with multiple code points in character class syntax", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/no-misleading-character-class" }, + schema: [], + messages: { surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.", combiningClass: "Unexpected combined character in character class.", 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 d4ead20062dda8..22ed65f5b1f0fd 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js @@ -71,12 +71,15 @@ function includesBothInAGroup(groups, left, right) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow mixed binary operators", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/no-mixed-operators" }, + schema: [ { type: "object", 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 1058f3a511e120..438ac668a805af 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-requires.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-requires.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `require` calls to be mixed with regular variable declarations", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js b/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js index 7cb4b4ceeaea38..1fc0b6074b8fd7 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "disallow mixed spaces and tabs for indentation", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-multi-assign.js b/tools/node_modules/eslint/lib/rules/no-multi-assign.js index ca3f778ac6fd87..8524a1a571ef9e 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-assign.js @@ -12,12 +12,15 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow use of chained assignment expressions", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/no-multi-assign" }, + schema: [] }, 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 41bcd4fb61193f..f1792c31ed7e7e 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-spaces.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "disallow multiple spaces", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-multi-str.js b/tools/node_modules/eslint/lib/rules/no-multi-str.js index ee0aaaa4c0c6e6..844842392df7d3 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-str.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-str.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow multiline strings", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js b/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js index a111786a30829f..f945cfeffe2b07 100644 --- a/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +++ b/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "disallow multiple empty lines", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-native-reassign.js b/tools/node_modules/eslint/lib/rules/no-native-reassign.js index b1064b0bb36661..9ecfb4da7cbee9 100644 --- a/tools/node_modules/eslint/lib/rules/no-native-reassign.js +++ b/tools/node_modules/eslint/lib/rules/no-native-reassign.js @@ -12,16 +12,19 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignments to native objects or read-only global variables", category: "Best Practices", recommended: false, - replacedBy: ["no-global-assign"], url: "https://eslint.org/docs/rules/no-native-reassign" }, deprecated: true, + replacedBy: ["no-global-assign"], + schema: [ { type: "object", diff --git a/tools/node_modules/eslint/lib/rules/no-negated-condition.js b/tools/node_modules/eslint/lib/rules/no-negated-condition.js index 254dcb5c23c7e9..e55a8287487de3 100644 --- a/tools/node_modules/eslint/lib/rules/no-negated-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-negated-condition.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow negated conditions", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js b/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js index 7f08814c941ffd..0084ad1570bb00 100644 --- a/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js +++ b/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js @@ -12,15 +12,18 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow negating the left operand in `in` expressions", category: "Possible Errors", recommended: false, - replacedBy: ["no-unsafe-negation"], url: "https://eslint.org/docs/rules/no-negated-in-lhs" }, - deprecated: true, + replacedBy: ["no-unsafe-negation"], + + deprecated: true, schema: [] }, diff --git a/tools/node_modules/eslint/lib/rules/no-nested-ternary.js b/tools/node_modules/eslint/lib/rules/no-nested-ternary.js index 15e72f20d1cb7f..87a11e87962a8f 100644 --- a/tools/node_modules/eslint/lib/rules/no-nested-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-nested-ternary.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow nested ternary expressions", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-new-func.js b/tools/node_modules/eslint/lib/rules/no-new-func.js index 8ee327baa1c445..23e92f7bf3030c 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-func.js +++ b/tools/node_modules/eslint/lib/rules/no-new-func.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with the `Function` object", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-new-object.js b/tools/node_modules/eslint/lib/rules/no-new-object.js index 3f68cbc1b51b29..f5cc28664f4e1c 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-object.js +++ b/tools/node_modules/eslint/lib/rules/no-new-object.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `Object` constructors", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-new-require.js b/tools/node_modules/eslint/lib/rules/no-new-require.js index f74daa7569c984..1eae0659430fbd 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-require.js +++ b/tools/node_modules/eslint/lib/rules/no-new-require.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with calls to `require`", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-new-symbol.js b/tools/node_modules/eslint/lib/rules/no-new-symbol.js index a537268e38dc1d..ccf757ed6a0cee 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-symbol.js +++ b/tools/node_modules/eslint/lib/rules/no-new-symbol.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow `new` operators with the `Symbol` object", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-new-wrappers.js b/tools/node_modules/eslint/lib/rules/no-new-wrappers.js index e8d516212b67aa..ae2aeec0341243 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-wrappers.js +++ b/tools/node_modules/eslint/lib/rules/no-new-wrappers.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators with the `String`, `Number`, and `Boolean` objects", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-new.js b/tools/node_modules/eslint/lib/rules/no-new.js index f9121bc18f656a..2e0702597eade3 100644 --- a/tools/node_modules/eslint/lib/rules/no-new.js +++ b/tools/node_modules/eslint/lib/rules/no-new.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `new` operators outside of assignments or comparisons", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-obj-calls.js b/tools/node_modules/eslint/lib/rules/no-obj-calls.js index 320343cb2c01e6..92492b7a26ed79 100644 --- a/tools/node_modules/eslint/lib/rules/no-obj-calls.js +++ b/tools/node_modules/eslint/lib/rules/no-obj-calls.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow calling global object properties as functions", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-octal-escape.js b/tools/node_modules/eslint/lib/rules/no-octal-escape.js index e9509b87f821ec..fc073b14033410 100644 --- a/tools/node_modules/eslint/lib/rules/no-octal-escape.js +++ b/tools/node_modules/eslint/lib/rules/no-octal-escape.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow octal escape sequences in string literals", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-octal.js b/tools/node_modules/eslint/lib/rules/no-octal.js index d782c23a39b719..db1fa40aa5df0a 100644 --- a/tools/node_modules/eslint/lib/rules/no-octal.js +++ b/tools/node_modules/eslint/lib/rules/no-octal.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow octal literals", category: "Best Practices", 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 be1a559178a973..243bb6412cff22 100644 --- a/tools/node_modules/eslint/lib/rules/no-param-reassign.js +++ b/tools/node_modules/eslint/lib/rules/no-param-reassign.js @@ -12,6 +12,8 @@ const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Progra module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow reassigning `function` parameters", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-path-concat.js b/tools/node_modules/eslint/lib/rules/no-path-concat.js index 1dee7bda1117a6..dad56a4f56a9d0 100644 --- a/tools/node_modules/eslint/lib/rules/no-path-concat.js +++ b/tools/node_modules/eslint/lib/rules/no-path-concat.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow string concatenation with `__dirname` and `__filename`", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-plusplus.js b/tools/node_modules/eslint/lib/rules/no-plusplus.js index f754b3672194cd..4c854de1a06ff7 100644 --- a/tools/node_modules/eslint/lib/rules/no-plusplus.js +++ b/tools/node_modules/eslint/lib/rules/no-plusplus.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the unary operators `++` and `--`", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-process-env.js b/tools/node_modules/eslint/lib/rules/no-process-env.js index 71b27ffd72069b..a66d9709b09b4f 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-env.js +++ b/tools/node_modules/eslint/lib/rules/no-process-env.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `process.env`", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-process-exit.js b/tools/node_modules/eslint/lib/rules/no-process-exit.js index 2d22d7fd96a120..fcfc6b2af59d0e 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-exit.js +++ b/tools/node_modules/eslint/lib/rules/no-process-exit.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `process.exit()`", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-proto.js b/tools/node_modules/eslint/lib/rules/no-proto.js index e37c6c22e628b8..80b9650941696d 100644 --- a/tools/node_modules/eslint/lib/rules/no-proto.js +++ b/tools/node_modules/eslint/lib/rules/no-proto.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of the `__proto__` property", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js b/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js index f52847f44d4b0e..171395306725eb 100644 --- a/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js +++ b/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow calling some `Object.prototype` methods directly on objects", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-redeclare.js b/tools/node_modules/eslint/lib/rules/no-redeclare.js index 79ab21137ecf93..e88436d7c57b73 100644 --- a/tools/node_modules/eslint/lib/rules/no-redeclare.js +++ b/tools/node_modules/eslint/lib/rules/no-redeclare.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow variable redeclaration", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js index 089e06028655ed..d0f7293d20eef1 100644 --- a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow multiple spaces in regular expressions", category: "Possible Errors", @@ -21,7 +23,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-globals.js b/tools/node_modules/eslint/lib/rules/no-restricted-globals.js index 72b02c032aa823..1a2629a8ec95e8 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-globals.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-globals.js @@ -17,6 +17,8 @@ const DEFAULT_MESSAGE_TEMPLATE = "Unexpected use of '{{name}}'.", module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified global variables", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-imports.js b/tools/node_modules/eslint/lib/rules/no-restricted-imports.js index fdebb8ca3ada0c..b8fcca1aaf8b6f 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-imports.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-imports.js @@ -53,6 +53,8 @@ const arrayOfStringsOrObjects = { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified modules when loaded by `import`", category: "ECMAScript 6", @@ -234,31 +236,47 @@ module.exports = { return restrictedPatterns.length > 0 && restrictedPatternsMatcher.ignores(importSource); } - return { - ImportDeclaration(node) { - const importSource = node.source.value.trim(); - const importNames = node.specifiers.reduce((set, specifier) => { - if (specifier.type === "ImportDefaultSpecifier") { - set.add("default"); - } else if (specifier.type === "ImportNamespaceSpecifier") { - set.add("*"); - } else { - set.add(specifier.imported.name); - } - return set; - }, new Set()); - - if (isRestrictedForEverythingImported(importSource, importNames)) { - reportPathForEverythingImported(importSource, node); + /** + * Checks a node to see if any problems should be reported. + * @param {ASTNode} node The node to check. + * @returns {void} + * @private + */ + function checkNode(node) { + const importSource = node.source.value.trim(); + const importNames = node.specifiers ? node.specifiers.reduce((set, specifier) => { + if (specifier.type === "ImportDefaultSpecifier") { + set.add("default"); + } else if (specifier.type === "ImportNamespaceSpecifier") { + set.add("*"); + } else if (specifier.imported) { + set.add(specifier.imported.name); + } else if (specifier.local) { + set.add(specifier.local.name); } + return set; + }, new Set()) : new Set(); - if (isRestrictedPath(importSource, importNames)) { - reportPath(node); - } - if (isRestrictedPattern(importSource)) { - reportPathForPatterns(node); - } + if (isRestrictedForEverythingImported(importSource, importNames)) { + reportPathForEverythingImported(importSource, node); + } + + if (isRestrictedPath(importSource, importNames)) { + reportPath(node); + } + if (isRestrictedPattern(importSource)) { + reportPathForPatterns(node); } + } + + return { + ImportDeclaration: checkNode, + ExportNamedDeclaration(node) { + if (node.source) { + checkNode(node); + } + }, + ExportAllDeclaration: checkNode }; } }; diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js index d63d2ce4f45881..ef8748a7d04baf 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js @@ -47,6 +47,8 @@ const arrayOfStringsOrObjects = { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified modules when loaded by `require`", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-properties.js b/tools/node_modules/eslint/lib/rules/no-restricted-properties.js index c0f1cfb6d3834e..eede6ad1c161dd 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-properties.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-properties.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow certain properties on certain objects", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js b/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js index c472d9432e69d7..74eea1478911aa 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified syntax", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-return-assign.js b/tools/node_modules/eslint/lib/rules/no-return-assign.js index 519f9e0d039dac..b3c39ea2b8c4b2 100644 --- a/tools/node_modules/eslint/lib/rules/no-return-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-return-assign.js @@ -22,6 +22,8 @@ const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionE module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow assignment operators in `return` statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-return-await.js b/tools/node_modules/eslint/lib/rules/no-return-await.js index 5f531a18310c1b..24cb45ee5a7e52 100644 --- a/tools/node_modules/eslint/lib/rules/no-return-await.js +++ b/tools/node_modules/eslint/lib/rules/no-return-await.js @@ -14,6 +14,8 @@ const message = "Redundant use of `await` on a return value."; module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary `return await`", category: "Best Practices", @@ -22,7 +24,9 @@ module.exports = { url: "https://eslint.org/docs/rules/no-return-await" }, + fixable: null, + schema: [ ] }, diff --git a/tools/node_modules/eslint/lib/rules/no-script-url.js b/tools/node_modules/eslint/lib/rules/no-script-url.js index ba74dafb8e274d..40e9bfe8b27544 100644 --- a/tools/node_modules/eslint/lib/rules/no-script-url.js +++ b/tools/node_modules/eslint/lib/rules/no-script-url.js @@ -13,6 +13,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `javascript:` urls", category: "Best Practices", 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 87d1f2ff4f76de..d493855efe9c68 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-self-assign.js @@ -165,6 +165,8 @@ function eachSelfAssignment(left, right, props, report) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow assignments where both sides are exactly the same", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-self-compare.js b/tools/node_modules/eslint/lib/rules/no-self-compare.js index 6ebc3870feb6b7..8986240ec5c842 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-compare.js +++ b/tools/node_modules/eslint/lib/rules/no-self-compare.js @@ -12,6 +12,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow comparisons where both sides are exactly the same", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-sequences.js b/tools/node_modules/eslint/lib/rules/no-sequences.js index e74943d81095d4..2570912f348e91 100644 --- a/tools/node_modules/eslint/lib/rules/no-sequences.js +++ b/tools/node_modules/eslint/lib/rules/no-sequences.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow comma operators", category: "Best Practices", 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 70052f56f2d2ed..9bdd50868042c3 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 @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow identifiers from shadowing restricted names", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-shadow.js b/tools/node_modules/eslint/lib/rules/no-shadow.js index 955fc05e582030..f910230d6a27f3 100644 --- a/tools/node_modules/eslint/lib/rules/no-shadow.js +++ b/tools/node_modules/eslint/lib/rules/no-shadow.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow variable declarations from shadowing variables declared in the outer scope", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-spaced-func.js b/tools/node_modules/eslint/lib/rules/no-spaced-func.js index 42d1e4b243a4d0..8535881f435e48 100644 --- a/tools/node_modules/eslint/lib/rules/no-spaced-func.js +++ b/tools/node_modules/eslint/lib/rules/no-spaced-func.js @@ -12,16 +12,19 @@ module.exports = { meta: { + type: "layout", + docs: { description: "disallow spacing between function identifiers and their applications (deprecated)", category: "Stylistic Issues", recommended: false, - replacedBy: ["func-call-spacing"], url: "https://eslint.org/docs/rules/no-spaced-func" }, deprecated: true, + replacedBy: ["func-call-spacing"], + fixable: "whitespace", schema: [] }, diff --git a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js index 1cc6f7ccba9569..985109c36b267d 100644 --- a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js +++ b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow sparse arrays", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-sync.js b/tools/node_modules/eslint/lib/rules/no-sync.js index eb7b787d38c35a..a0096e3d04313f 100644 --- a/tools/node_modules/eslint/lib/rules/no-sync.js +++ b/tools/node_modules/eslint/lib/rules/no-sync.js @@ -13,6 +13,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow synchronous methods", category: "Node.js and CommonJS", diff --git a/tools/node_modules/eslint/lib/rules/no-tabs.js b/tools/node_modules/eslint/lib/rules/no-tabs.js index c22a94da38bee1..0002f5592900c1 100644 --- a/tools/node_modules/eslint/lib/rules/no-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-tabs.js @@ -18,6 +18,8 @@ const anyNonWhitespaceRegex = /\S/; module.exports = { meta: { + type: "layout", + docs: { description: "disallow all tabs", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js index ed74fcc6f7f16c..c286ec69000d60 100644 --- a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js +++ b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "disallow template literal placeholder syntax in regular strings", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-ternary.js b/tools/node_modules/eslint/lib/rules/no-ternary.js index 4dcc8db069e991..890f2abfa0c59a 100644 --- a/tools/node_modules/eslint/lib/rules/no-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-ternary.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow ternary operators", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-this-before-super.js b/tools/node_modules/eslint/lib/rules/no-this-before-super.js index 8a489879eddf31..93fb094e9bc139 100644 --- a/tools/node_modules/eslint/lib/rules/no-this-before-super.js +++ b/tools/node_modules/eslint/lib/rules/no-this-before-super.js @@ -36,6 +36,8 @@ function isConstructorFunction(node) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow `this`/`super` before calling `super()` in constructors", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-throw-literal.js b/tools/node_modules/eslint/lib/rules/no-throw-literal.js index 301354b6b2c909..c4a6b86bfb4cc9 100644 --- a/tools/node_modules/eslint/lib/rules/no-throw-literal.js +++ b/tools/node_modules/eslint/lib/rules/no-throw-literal.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow throwing literals as exceptions", category: "Best Practices", 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 cca7af2aac322b..18f0340ef011c7 100644 --- a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "disallow trailing whitespace at the end of lines", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-undef-init.js b/tools/node_modules/eslint/lib/rules/no-undef-init.js index f00b05d4ff0d2e..67f3944d47e7f4 100644 --- a/tools/node_modules/eslint/lib/rules/no-undef-init.js +++ b/tools/node_modules/eslint/lib/rules/no-undef-init.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow initializing variables to `undefined`", category: "Variables", @@ -21,7 +23,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/no-undef.js b/tools/node_modules/eslint/lib/rules/no-undef.js index c8347d50d1aa15..f923644eca114e 100644 --- a/tools/node_modules/eslint/lib/rules/no-undef.js +++ b/tools/node_modules/eslint/lib/rules/no-undef.js @@ -25,6 +25,8 @@ function hasTypeOfOperator(node) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow the use of undeclared variables unless mentioned in `/*global */` comments", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-undefined.js b/tools/node_modules/eslint/lib/rules/no-undefined.js index 8491ab5d54035e..b92f6700637c30 100644 --- a/tools/node_modules/eslint/lib/rules/no-undefined.js +++ b/tools/node_modules/eslint/lib/rules/no-undefined.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow the use of `undefined` as an identifier", category: "Variables", 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 c76488a94313c4..926803b992d98a 100644 --- a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js +++ b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow dangling underscores in identifiers", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js b/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js index 181a00b2d0d4fa..3bed96fc77d069 100644 --- a/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js +++ b/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow confusing multiline expressions", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js b/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js index fecd8ba5cca285..95898c5f19d814 100644 --- a/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js @@ -165,6 +165,8 @@ function updateModifiedFlag(conditions, modifiers) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow unmodified loop conditions", category: "Best Practices", 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 6b58b018da0ec2..3a7dd5fad7db19 100644 --- a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js @@ -24,6 +24,8 @@ const OPERATOR_INVERSES = { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow ternary operators when simpler alternatives exist", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-unreachable.js b/tools/node_modules/eslint/lib/rules/no-unreachable.js index 80d246307c31ea..8ea2583f7cb251 100644 --- a/tools/node_modules/eslint/lib/rules/no-unreachable.js +++ b/tools/node_modules/eslint/lib/rules/no-unreachable.js @@ -101,6 +101,8 @@ class ConsecutiveRange { module.exports = { meta: { + type: "problem", + docs: { description: "disallow unreachable code after `return`, `throw`, `continue`, and `break` statements", category: "Possible Errors", @@ -180,7 +182,6 @@ module.exports = { ContinueStatement: reportIfUnreachable, DebuggerStatement: reportIfUnreachable, DoWhileStatement: reportIfUnreachable, - EmptyStatement: reportIfUnreachable, ExpressionStatement: reportIfUnreachable, ForInStatement: reportIfUnreachable, ForOfStatement: reportIfUnreachable, diff --git a/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js b/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js index 1ebdd2e3775da3..ab612ae6526f66 100644 --- a/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js +++ b/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js @@ -20,6 +20,8 @@ const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaratio module.exports = { meta: { + type: "problem", + docs: { description: "disallow control flow statements in `finally` blocks", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/no-unsafe-negation.js b/tools/node_modules/eslint/lib/rules/no-unsafe-negation.js index b04f80106c64af..3a0402eb0d5d34 100644 --- a/tools/node_modules/eslint/lib/rules/no-unsafe-negation.js +++ b/tools/node_modules/eslint/lib/rules/no-unsafe-negation.js @@ -41,12 +41,15 @@ function isNegation(node) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow negating the left operand of relational operators", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-unsafe-negation" }, + schema: [], fixable: "code" }, 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 fedfac17d1fb15..854298b411978b 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unused expressions", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-unused-labels.js b/tools/node_modules/eslint/lib/rules/no-unused-labels.js index 3e1dcb6601fece..c9e097df458ba4 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-labels.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-labels.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unused labels", category: "Best Practices", @@ -19,7 +21,6 @@ module.exports = { }, schema: [], - fixable: "code" }, 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 6f36813aca57a5..e76e3251038c00 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-vars.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-vars.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow unused variables", category: "Variables", @@ -223,6 +225,32 @@ module.exports = { return false; } + /** + * Gets a list of function definitions for a specified variable. + * @param {Variable} variable - eslint-scope variable object. + * @returns {ASTNode[]} Function nodes. + * @private + */ + function getFunctionDefinitions(variable) { + const functionDefinitions = []; + + variable.defs.forEach(def => { + const { type, node } = def; + + // FunctionDeclarations + if (type === "FunctionName") { + functionDefinitions.push(node); + } + + // FunctionExpressions + if (type === "Variable" && node.init && + (node.init.type === "FunctionExpression" || node.init.type === "ArrowFunctionExpression")) { + functionDefinitions.push(node.init); + } + }); + return functionDefinitions; + } + /** * Checks the position of given nodes. * @@ -372,22 +400,18 @@ module.exports = { return ref.isRead() && ( // self update. e.g. `a += 1`, `a++` - ( - parent.type === "AssignmentExpression" && + (// in RHS of an assignment for itself. e.g. `a = a + 1` + (( + parent.type === "AssignmentExpression" && granpa.type === "ExpressionStatement" && parent.left === id - ) || + ) || ( parent.type === "UpdateExpression" && granpa.type === "ExpressionStatement" - ) || - - // in RHS of an assignment for itself. e.g. `a = a + 1` - ( - rhsNode && - isInside(id, rhsNode) && - !isInsideOfStorableFunction(id, rhsNode) - ) + ) || rhsNode && + isInside(id, rhsNode) && + !isInsideOfStorableFunction(id, rhsNode))) ); } @@ -435,7 +459,7 @@ module.exports = { * @private */ function isUsedVariable(variable) { - const functionNodes = variable.defs.filter(def => def.type === "FunctionName").map(def => def.node), + const functionNodes = getFunctionDefinitions(variable), isFunctionDefinition = functionNodes.length > 0; let rhsNode = null; 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 64d82570279233..500cd3a4103672 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 @@ -136,6 +136,8 @@ function isInInitializer(variable, reference) { module.exports = { meta: { + type: "problem", + docs: { description: "disallow the use of variables before they are defined", category: "Variables", diff --git a/tools/node_modules/eslint/lib/rules/no-useless-call.js b/tools/node_modules/eslint/lib/rules/no-useless-call.js index 0778b374f4f612..74e8bec08bcf3b 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-call.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-call.js @@ -49,6 +49,8 @@ function isValidThisArg(expectedThis, thisArg, sourceCode) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary calls to `.call()` and `.apply()`", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js b/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js index 189f50853c8dd1..ef1f856f3efc5a 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js @@ -18,6 +18,8 @@ const MESSAGE_UNNECESSARY_COMPUTED = "Unnecessarily computed property [{{propert module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary computed property keys in object literals", category: "ECMAScript 6", @@ -26,7 +28,6 @@ module.exports = { }, schema: [], - fixable: "code" }, create(context) { diff --git a/tools/node_modules/eslint/lib/rules/no-useless-concat.js b/tools/node_modules/eslint/lib/rules/no-useless-concat.js index e8e36aa1c1a8b2..df310119032979 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-concat.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-concat.js @@ -66,6 +66,8 @@ function getRight(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary concatenation of literals or template literals", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-useless-constructor.js b/tools/node_modules/eslint/lib/rules/no-useless-constructor.js index 59e40bef8f4b66..c10376450eb5b5 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-constructor.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-constructor.js @@ -142,6 +142,8 @@ function isRedundantSuperCall(body, ctorParams) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary constructors", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-useless-escape.js b/tools/node_modules/eslint/lib/rules/no-useless-escape.js index 7f4b87ed92cfab..c3c0421cc0c5b2 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-escape.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-escape.js @@ -79,6 +79,8 @@ function parseRegExp(regExpText) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow unnecessary escape characters", category: "Best Practices", 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 83a03deb63022a..337f875b4564d8 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-rename.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-rename.js @@ -11,13 +11,17 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow renaming import, export, and destructured assignments to the same name", category: "ECMAScript 6", recommended: false, url: "https://eslint.org/docs/rules/no-useless-rename" }, + fixable: "code", + schema: [ { type: "object", diff --git a/tools/node_modules/eslint/lib/rules/no-useless-return.js b/tools/node_modules/eslint/lib/rules/no-useless-return.js index b5b8ebc32a1e85..bb11b4b3619c8e 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-return.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-return.js @@ -66,12 +66,15 @@ function isInFinally(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow redundant return statements", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/no-useless-return" }, + fixable: "code", schema: [] }, diff --git a/tools/node_modules/eslint/lib/rules/no-var.js b/tools/node_modules/eslint/lib/rules/no-var.js index 2c32a023dc9a81..edaed98f62e9d3 100644 --- a/tools/node_modules/eslint/lib/rules/no-var.js +++ b/tools/node_modules/eslint/lib/rules/no-var.js @@ -180,6 +180,8 @@ function hasReferenceInTDZ(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `let` or `const` instead of `var`", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/no-void.js b/tools/node_modules/eslint/lib/rules/no-void.js index 1d3d887da66873..d2b5d2f9631dff 100644 --- a/tools/node_modules/eslint/lib/rules/no-void.js +++ b/tools/node_modules/eslint/lib/rules/no-void.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `void` operators", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-warning-comments.js b/tools/node_modules/eslint/lib/rules/no-warning-comments.js index 5ff76e3a391138..9ea39b490f824d 100644 --- a/tools/node_modules/eslint/lib/rules/no-warning-comments.js +++ b/tools/node_modules/eslint/lib/rules/no-warning-comments.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow specified warning terms in comments", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js b/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js index 4b71a9ec17d99c..1ecc51db67c030 100644 --- a/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js +++ b/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "disallow whitespace before properties", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/no-with.js b/tools/node_modules/eslint/lib/rules/no-with.js index d72dcdfb21e4d6..ecdf22c7d91d6a 100644 --- a/tools/node_modules/eslint/lib/rules/no-with.js +++ b/tools/node_modules/eslint/lib/rules/no-with.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `with` statements", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js b/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js index e447ef886b3c03..01763cea92f381 100644 --- a/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +++ b/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js @@ -12,13 +12,17 @@ const POSITION_SCHEMA = { enum: ["beside", "below", "any"] }; module.exports = { meta: { + type: "layout", + docs: { description: "enforce the location of single-line statements", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/nonblock-statement-body-position" }, + fixable: "whitespace", + schema: [ POSITION_SCHEMA, { 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 494e78cff4aacb..c460ea56bc3128 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-newline.js @@ -134,13 +134,17 @@ function areLineBreaksRequired(node, options, first, last) { module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent line breaks inside braces", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/object-curly-newline" }, + fixable: "whitespace", + schema: [ { oneOf: [ diff --git a/tools/node_modules/eslint/lib/rules/object-curly-spacing.js b/tools/node_modules/eslint/lib/rules/object-curly-spacing.js index e7c847a6a9546e..bde4f14253eeec 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-spacing.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-spacing.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing inside braces", category: "Stylistic Issues", 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 65baf0a95e37a7..3e2c0171577594 100644 --- a/tools/node_modules/eslint/lib/rules/object-property-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-property-newline.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "enforce placing object properties on separate lines", category: "Stylistic Issues", @@ -38,8 +40,7 @@ module.exports = { create(context) { const allowSameLine = context.options[0] && ( - Boolean(context.options[0].allowAllPropertiesOnSameLine) || - Boolean(context.options[0].allowMultiplePropertiesPerLine) // Deprecated + (Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(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 21f039f8b6ed3a..ff6a51a4d1762a 100644 --- a/tools/node_modules/eslint/lib/rules/object-shorthand.js +++ b/tools/node_modules/eslint/lib/rules/object-shorthand.js @@ -24,6 +24,8 @@ const astUtils = require("../util/ast-utils"); //------------------------------------------------------------------------------ module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow method and property shorthand syntax for object literals", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js b/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js index e17529b6bed487..e7e40d66c0ced4 100644 --- a/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +++ b/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow newlines around variable declarations", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/one-var.js b/tools/node_modules/eslint/lib/rules/one-var.js index 3efd0f27f7f301..44f05fb700a0d6 100644 --- a/tools/node_modules/eslint/lib/rules/one-var.js +++ b/tools/node_modules/eslint/lib/rules/one-var.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce variables to be declared either together or separately in functions", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/operator-assignment.js b/tools/node_modules/eslint/lib/rules/operator-assignment.js index 8e4b7025edab06..8bb01737dd62cd 100644 --- a/tools/node_modules/eslint/lib/rules/operator-assignment.js +++ b/tools/node_modules/eslint/lib/rules/operator-assignment.js @@ -89,6 +89,8 @@ function canBeFixed(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow assignment operator shorthand where possible", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/operator-linebreak.js b/tools/node_modules/eslint/lib/rules/operator-linebreak.js index be2709a1bdaae6..cd6e996b1b10bd 100644 --- a/tools/node_modules/eslint/lib/rules/operator-linebreak.js +++ b/tools/node_modules/eslint/lib/rules/operator-linebreak.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent linebreak style for operators", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/padded-blocks.js b/tools/node_modules/eslint/lib/rules/padded-blocks.js index 370d47bccff458..7c0b56ba7f8553 100644 --- a/tools/node_modules/eslint/lib/rules/padded-blocks.js +++ b/tools/node_modules/eslint/lib/rules/padded-blocks.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow padding within blocks", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js b/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js index 4af85fef015aad..3e55a2516d0156 100644 --- a/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js +++ b/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js @@ -400,13 +400,17 @@ const StatementTypes = { module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow padding lines between statements", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/padding-line-between-statements" }, + fixable: "whitespace", + schema: { definitions: { paddingType: { 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 1bc140b101bc06..b4bbf33f296ab8 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js +++ b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js @@ -132,6 +132,8 @@ function hasDuplicateParams(paramsList) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require using arrow functions for callbacks", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/prefer-const.js b/tools/node_modules/eslint/lib/rules/prefer-const.js index 8b3bc5e0e436d3..a40ad353950df0 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-const.js +++ b/tools/node_modules/eslint/lib/rules/prefer-const.js @@ -330,6 +330,8 @@ function findUp(node, type, shouldStop) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require `const` declarations for variables that are never reassigned after declared", category: "ECMAScript 6", @@ -357,6 +359,8 @@ module.exports = { const shouldMatchAnyDestructuredVariable = options.destructuring !== "all"; const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true; const variables = []; + let reportCount = 0; + let name = ""; /** * Reports given identifier nodes if all of the nodes should be declared @@ -377,14 +381,41 @@ module.exports = { if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) { const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement")); - const shouldFix = varDeclParent && + const isVarDecParentNull = varDeclParent === null; + + if (!isVarDecParentNull && varDeclParent.declarations.length > 0) { + const firstDeclaration = varDeclParent.declarations[0]; + + if (firstDeclaration.init) { + const firstDecParent = firstDeclaration.init.parent; + + /* + * First we check the declaration type and then depending on + * if the type is a "VariableDeclarator" or its an "ObjectPattern" + * we compare the name from the first identifier, if the names are different + * we assign the new name and reset the count of reportCount and nodeCount in + * order to check each block for the number of reported errors and base our fix + * based on comparing nodes.length and nodesToReport.length. + */ + + if (firstDecParent.type === "VariableDeclarator") { + + if (firstDecParent.id.name !== name) { + name = firstDecParent.id.name; + reportCount = 0; + } + + if (firstDecParent.id.type === "ObjectPattern") { + if (firstDecParent.init.name !== name) { + name = firstDecParent.init.name; + reportCount = 0; + } + } + } + } + } - /* - * If there are multiple variable declarations, like {let a = 1, b = 2}, then - * do not attempt to fix if one of the declarations should be `const`. It's - * too hard to know how the developer would want to automatically resolve the issue. - */ - varDeclParent.declarations.length === 1 && + let shouldFix = varDeclParent && // Don't do a fix unless the variable is initialized (or it's in a for-in or for-of loop) (varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || varDeclParent.declarations[0].init) && @@ -396,6 +427,21 @@ module.exports = { */ nodesToReport.length === nodes.length; + if (!isVarDecParentNull && varDeclParent.declarations && varDeclParent.declarations.length !== 1) { + + if (varDeclParent && varDeclParent.declarations && varDeclParent.declarations.length >= 1) { + + /* + * Add nodesToReport.length to a count, then comparing the count to the length + * of the declarations in the current block. + */ + + reportCount += nodesToReport.length; + + shouldFix = shouldFix && (reportCount === varDeclParent.declarations.length); + } + } + nodesToReport.forEach(node => { context.report({ node, diff --git a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js index 112ea64613c6da..119fae560895e7 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js +++ b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js @@ -10,12 +10,15 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require destructuring from arrays and/or objects", category: "ECMAScript 6", recommended: false, url: "https://eslint.org/docs/rules/prefer-destructuring" }, + schema: [ { diff --git a/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js b/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js index 051a91c81cb446..ca7358aa013bda 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js +++ b/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js @@ -38,6 +38,8 @@ function isParseInt(calleeNode) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals", category: "ECMAScript 6", @@ -46,7 +48,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js index 8e54de2496a44f..a8dac696be0b70 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js @@ -212,6 +212,8 @@ function defineFixer(node, sourceCode) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.", @@ -219,8 +221,10 @@ module.exports = { recommended: false, url: "https://eslint.org/docs/rules/prefer-object-spread" }, + schema: [], fixable: "code", + messages: { useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`", useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`" 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 e3d298a743caec..0db5ae874cfd9f 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 @@ -12,13 +12,17 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require using Error objects as Promise rejection reasons", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/prefer-promise-reject-errors" }, + fixable: null, + schema: [ { type: "object", diff --git a/tools/node_modules/eslint/lib/rules/prefer-reflect.js b/tools/node_modules/eslint/lib/rules/prefer-reflect.js index 765163e0eb3a14..796bbdf05fd446 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-reflect.js +++ b/tools/node_modules/eslint/lib/rules/prefer-reflect.js @@ -11,16 +11,19 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `Reflect` methods where applicable", category: "ECMAScript 6", recommended: false, - replacedBy: [], url: "https://eslint.org/docs/rules/prefer-reflect" }, deprecated: true, + replacedBy: [], + schema: [ { type: "object", diff --git a/tools/node_modules/eslint/lib/rules/prefer-rest-params.js b/tools/node_modules/eslint/lib/rules/prefer-rest-params.js index 133456e4d176cf..95a562c4a2f4de 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-rest-params.js +++ b/tools/node_modules/eslint/lib/rules/prefer-rest-params.js @@ -62,6 +62,8 @@ function isNotNormalMemberAccess(reference) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require rest parameters instead of `arguments`", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/prefer-spread.js b/tools/node_modules/eslint/lib/rules/prefer-spread.js index 9bf69c80f7b900..790fd3b82aab41 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-spread.js @@ -49,6 +49,8 @@ function isValidThisArg(expectedThis, thisArg, context) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require spread operators instead of `.apply()`", category: "ECMAScript 6", @@ -57,7 +59,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/prefer-template.js b/tools/node_modules/eslint/lib/rules/prefer-template.js index 0471d61caef9f8..386674a92ef9c3 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-template.js +++ b/tools/node_modules/eslint/lib/rules/prefer-template.js @@ -141,6 +141,8 @@ function endsWithTemplateCurly(node) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require template literals instead of string concatenation", category: "ECMAScript 6", @@ -149,7 +151,6 @@ module.exports = { }, schema: [], - fixable: "code" }, diff --git a/tools/node_modules/eslint/lib/rules/quote-props.js b/tools/node_modules/eslint/lib/rules/quote-props.js index 36739494da4058..7184bd34d35fd1 100644 --- a/tools/node_modules/eslint/lib/rules/quote-props.js +++ b/tools/node_modules/eslint/lib/rules/quote-props.js @@ -17,6 +17,8 @@ const espree = require("espree"), module.exports = { meta: { + type: "suggestion", + docs: { description: "require quotes around object literal property names", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/quotes.js b/tools/node_modules/eslint/lib/rules/quotes.js index 8dd61c3e3718b6..e0db17fcb7c45f 100644 --- a/tools/node_modules/eslint/lib/rules/quotes.js +++ b/tools/node_modules/eslint/lib/rules/quotes.js @@ -76,6 +76,8 @@ const AVOID_ESCAPE = "avoid-escape"; module.exports = { meta: { + type: "layout", + docs: { description: "enforce the consistent use of either backticks, double, or single quotes", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/radix.js b/tools/node_modules/eslint/lib/rules/radix.js index f71220beb4e5c6..5d3805d0a70679 100644 --- a/tools/node_modules/eslint/lib/rules/radix.js +++ b/tools/node_modules/eslint/lib/rules/radix.js @@ -78,6 +78,8 @@ function isDefaultRadix(radix) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the consistent use of the radix argument when using `parseInt()`", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js index c6cf0d74774002..e8dbe17b88dcd8 100644 --- a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js +++ b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js @@ -12,14 +12,18 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "problem", + docs: { description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`", category: "Possible Errors", recommended: false, url: "https://eslint.org/docs/rules/require-atomic-updates" }, + fixable: null, schema: [], + messages: { nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`." } diff --git a/tools/node_modules/eslint/lib/rules/require-await.js b/tools/node_modules/eslint/lib/rules/require-await.js index de39f372fd62ef..5e614c50251fed 100644 --- a/tools/node_modules/eslint/lib/rules/require-await.js +++ b/tools/node_modules/eslint/lib/rules/require-await.js @@ -31,12 +31,15 @@ function capitalizeFirstLetter(text) { module.exports = { meta: { + type: "suggestion", + docs: { description: "disallow async functions which have no `await` expression", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/require-await" }, + schema: [] }, diff --git a/tools/node_modules/eslint/lib/rules/require-jsdoc.js b/tools/node_modules/eslint/lib/rules/require-jsdoc.js index 91b90b7d10a381..949314993b64fb 100644 --- a/tools/node_modules/eslint/lib/rules/require-jsdoc.js +++ b/tools/node_modules/eslint/lib/rules/require-jsdoc.js @@ -6,6 +6,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require JSDoc comments", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/require-unicode-regexp.js b/tools/node_modules/eslint/lib/rules/require-unicode-regexp.js index 55ca4ff89a66b6..880405e9a25dbf 100644 --- a/tools/node_modules/eslint/lib/rules/require-unicode-regexp.js +++ b/tools/node_modules/eslint/lib/rules/require-unicode-regexp.js @@ -22,15 +22,19 @@ const { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce the use of `u` flag on RegExp", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/require-unicode-regexp" }, + messages: { requireUFlag: "Use the 'u' flag." }, + schema: [] }, diff --git a/tools/node_modules/eslint/lib/rules/require-yield.js b/tools/node_modules/eslint/lib/rules/require-yield.js index 83a29876f0912a..7bb7cf9a872bd8 100644 --- a/tools/node_modules/eslint/lib/rules/require-yield.js +++ b/tools/node_modules/eslint/lib/rules/require-yield.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require generator functions to contain `yield`", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js index e87d881298bac2..04539395ef4ec1 100644 --- a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js +++ b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js @@ -11,13 +11,17 @@ module.exports = { meta: { + type: "layout", + docs: { description: "enforce spacing between rest and spread operators and their expressions", category: "ECMAScript 6", recommended: false, url: "https://eslint.org/docs/rules/rest-spread-spacing" }, + fixable: "whitespace", + schema: [ { enum: ["always", "never"] diff --git a/tools/node_modules/eslint/lib/rules/semi-spacing.js b/tools/node_modules/eslint/lib/rules/semi-spacing.js index 75b53055a69bde..56ae687d8560a0 100644 --- a/tools/node_modules/eslint/lib/rules/semi-spacing.js +++ b/tools/node_modules/eslint/lib/rules/semi-spacing.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before and after semicolons", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/semi-style.js b/tools/node_modules/eslint/lib/rules/semi-style.js index 34899bb5444abc..dd76b68f82beac 100644 --- a/tools/node_modules/eslint/lib/rules/semi-style.js +++ b/tools/node_modules/eslint/lib/rules/semi-style.js @@ -65,12 +65,15 @@ function isLastChild(node) { module.exports = { meta: { + type: "layout", + docs: { description: "enforce location of semicolons", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/semi-style" }, + schema: [{ enum: ["last", "first"] }], fixable: "whitespace" }, diff --git a/tools/node_modules/eslint/lib/rules/semi.js b/tools/node_modules/eslint/lib/rules/semi.js index 129d106414defc..e8f4c959d4c7df 100644 --- a/tools/node_modules/eslint/lib/rules/semi.js +++ b/tools/node_modules/eslint/lib/rules/semi.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow semicolons instead of ASI", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/sort-imports.js b/tools/node_modules/eslint/lib/rules/sort-imports.js index 8735be5d307144..76997cc73d894b 100644 --- a/tools/node_modules/eslint/lib/rules/sort-imports.js +++ b/tools/node_modules/eslint/lib/rules/sort-imports.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce sorted import declarations within modules", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/sort-keys.js b/tools/node_modules/eslint/lib/rules/sort-keys.js index 6e538f73291179..0668e617d3c785 100644 --- a/tools/node_modules/eslint/lib/rules/sort-keys.js +++ b/tools/node_modules/eslint/lib/rules/sort-keys.js @@ -73,12 +73,15 @@ const isValidOrders = { module.exports = { meta: { + type: "suggestion", + docs: { description: "require object keys to be sorted", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/sort-keys" }, + schema: [ { enum: ["asc", "desc"] diff --git a/tools/node_modules/eslint/lib/rules/sort-vars.js b/tools/node_modules/eslint/lib/rules/sort-vars.js index 334deb0657f3ef..b6a2c86779c095 100644 --- a/tools/node_modules/eslint/lib/rules/sort-vars.js +++ b/tools/node_modules/eslint/lib/rules/sort-vars.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require variables within the same declaration block to be sorted", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/space-before-blocks.js b/tools/node_modules/eslint/lib/rules/space-before-blocks.js index 4f22ae6b65382d..872338effc29b3 100644 --- a/tools/node_modules/eslint/lib/rules/space-before-blocks.js +++ b/tools/node_modules/eslint/lib/rules/space-before-blocks.js @@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before blocks", category: "Stylistic Issues", @@ -32,13 +34,13 @@ module.exports = { type: "object", properties: { keywords: { - enum: ["always", "never"] + enum: ["always", "never", "off"] }, functions: { - enum: ["always", "never"] + enum: ["always", "never", "off"] }, classes: { - enum: ["always", "never"] + enum: ["always", "never", "off"] } }, additionalProperties: false @@ -51,18 +53,27 @@ module.exports = { create(context) { const config = context.options[0], sourceCode = context.getSourceCode(); - let checkFunctions = true, - checkKeywords = true, - checkClasses = true; + let alwaysFunctions = true, + alwaysKeywords = true, + alwaysClasses = true, + neverFunctions = false, + neverKeywords = false, + neverClasses = false; if (typeof config === "object") { - checkFunctions = config.functions !== "never"; - checkKeywords = config.keywords !== "never"; - checkClasses = config.classes !== "never"; + alwaysFunctions = config.functions === "always"; + alwaysKeywords = config.keywords === "always"; + alwaysClasses = config.classes === "always"; + neverFunctions = config.functions === "never"; + neverKeywords = config.keywords === "never"; + neverClasses = config.classes === "never"; } else if (config === "never") { - checkFunctions = false; - checkKeywords = false; - checkClasses = false; + alwaysFunctions = false; + alwaysKeywords = false; + alwaysClasses = false; + neverFunctions = true; + neverKeywords = true; + neverClasses = true; } /** @@ -88,35 +99,35 @@ module.exports = { const hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node); const parent = context.getAncestors().pop(); let requireSpace; + let requireNoSpace; if (parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration") { - requireSpace = checkFunctions; + requireSpace = alwaysFunctions; + requireNoSpace = neverFunctions; } else if (node.type === "ClassBody") { - requireSpace = checkClasses; + requireSpace = alwaysClasses; + requireNoSpace = neverClasses; } else { - requireSpace = checkKeywords; + requireSpace = alwaysKeywords; + requireNoSpace = neverKeywords; } - if (requireSpace) { - if (!hasSpace) { - context.report({ - node, - message: "Missing space before opening brace.", - fix(fixer) { - return fixer.insertTextBefore(node, " "); - } - }); - } - } else { - if (hasSpace) { - context.report({ - node, - message: "Unexpected space before opening brace.", - fix(fixer) { - return fixer.removeRange([precedingToken.range[1], node.range[0]]); - } - }); - } + if (requireSpace && !hasSpace) { + context.report({ + node, + message: "Missing space before opening brace.", + fix(fixer) { + return fixer.insertTextBefore(node, " "); + } + }); + } else if (requireNoSpace && hasSpace) { + context.report({ + node, + message: "Unexpected space before opening brace.", + fix(fixer) { + return fixer.removeRange([precedingToken.range[1], node.range[0]]); + } + }); } } } 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 81697d64f1f1f8..64ba72bf9ead29 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 @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before `function` definition opening parenthesis", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/space-in-parens.js b/tools/node_modules/eslint/lib/rules/space-in-parens.js index aa1374380342a5..88f4f0b50e150d 100644 --- a/tools/node_modules/eslint/lib/rules/space-in-parens.js +++ b/tools/node_modules/eslint/lib/rules/space-in-parens.js @@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing inside parentheses", category: "Stylistic Issues", 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 17b49cc1184ca1..45b76795eae14e 100644 --- a/tools/node_modules/eslint/lib/rules/space-infix-ops.js +++ b/tools/node_modules/eslint/lib/rules/space-infix-ops.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require spacing around infix operators", category: "Stylistic Issues", 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 5032b46c3b05c8..b56fa4f2fac396 100644 --- a/tools/node_modules/eslint/lib/rules/space-unary-ops.js +++ b/tools/node_modules/eslint/lib/rules/space-unary-ops.js @@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce consistent spacing before or after unary operators", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/spaced-comment.js b/tools/node_modules/eslint/lib/rules/spaced-comment.js index 6fbe2aac790ff4..d4c86d27cf8fc7 100644 --- a/tools/node_modules/eslint/lib/rules/spaced-comment.js +++ b/tools/node_modules/eslint/lib/rules/spaced-comment.js @@ -151,6 +151,8 @@ function createNeverStylePattern(markers) { module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce consistent spacing after the `//` or `/*` in a comment", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/strict.js b/tools/node_modules/eslint/lib/rules/strict.js index 8b5757738de09c..bec1baf4653961 100644 --- a/tools/node_modules/eslint/lib/rules/strict.js +++ b/tools/node_modules/eslint/lib/rules/strict.js @@ -80,6 +80,8 @@ function isSimpleParameterList(params) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow strict mode directives", category: "Strict Mode", 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 23dfff6133d3a6..e94b3292106ddf 100644 --- a/tools/node_modules/eslint/lib/rules/switch-colon-spacing.js +++ b/tools/node_modules/eslint/lib/rules/switch-colon-spacing.js @@ -17,12 +17,15 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "enforce spacing around colons of switch statements", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/switch-colon-spacing" }, + schema: [ { type: "object", @@ -33,6 +36,7 @@ module.exports = { additionalProperties: false } ], + fixable: "whitespace" }, diff --git a/tools/node_modules/eslint/lib/rules/symbol-description.js b/tools/node_modules/eslint/lib/rules/symbol-description.js index 271012b5429d48..7bb4e2dec699d4 100644 --- a/tools/node_modules/eslint/lib/rules/symbol-description.js +++ b/tools/node_modules/eslint/lib/rules/symbol-description.js @@ -18,6 +18,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "suggestion", + docs: { description: "require symbol descriptions", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/template-curly-spacing.js b/tools/node_modules/eslint/lib/rules/template-curly-spacing.js index 6702d730cd37e8..ea801cbe5d2ea9 100644 --- a/tools/node_modules/eslint/lib/rules/template-curly-spacing.js +++ b/tools/node_modules/eslint/lib/rules/template-curly-spacing.js @@ -24,6 +24,8 @@ const CLOSE_PAREN = /^\}/; module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow spacing around embedded expressions of template strings", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/template-tag-spacing.js b/tools/node_modules/eslint/lib/rules/template-tag-spacing.js index aee7ac108be16c..f258cde3d88e09 100644 --- a/tools/node_modules/eslint/lib/rules/template-tag-spacing.js +++ b/tools/node_modules/eslint/lib/rules/template-tag-spacing.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow spacing between template tags and their literals", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/unicode-bom.js b/tools/node_modules/eslint/lib/rules/unicode-bom.js index 03b2d5ae68e463..20f48e22b3c6b2 100644 --- a/tools/node_modules/eslint/lib/rules/unicode-bom.js +++ b/tools/node_modules/eslint/lib/rules/unicode-bom.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow Unicode byte order mark (BOM)", category: "Stylistic Issues", diff --git a/tools/node_modules/eslint/lib/rules/use-isnan.js b/tools/node_modules/eslint/lib/rules/use-isnan.js index 5bad5b3c6ddb5b..343ca0454441e4 100644 --- a/tools/node_modules/eslint/lib/rules/use-isnan.js +++ b/tools/node_modules/eslint/lib/rules/use-isnan.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "require calls to `isNaN()` when checking for `NaN`", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/valid-jsdoc.js b/tools/node_modules/eslint/lib/rules/valid-jsdoc.js index 42d66a8a79b518..b434491bfad873 100644 --- a/tools/node_modules/eslint/lib/rules/valid-jsdoc.js +++ b/tools/node_modules/eslint/lib/rules/valid-jsdoc.js @@ -16,6 +16,8 @@ const doctrine = require("doctrine"); module.exports = { meta: { + type: "suggestion", + docs: { description: "enforce valid JSDoc comments", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/valid-typeof.js b/tools/node_modules/eslint/lib/rules/valid-typeof.js index ac4e74f20ba6c5..e3245e8f306ca9 100644 --- a/tools/node_modules/eslint/lib/rules/valid-typeof.js +++ b/tools/node_modules/eslint/lib/rules/valid-typeof.js @@ -10,6 +10,8 @@ module.exports = { meta: { + type: "problem", + docs: { description: "enforce comparing `typeof` expressions against valid strings", category: "Possible Errors", diff --git a/tools/node_modules/eslint/lib/rules/vars-on-top.js b/tools/node_modules/eslint/lib/rules/vars-on-top.js index 0489aa61fcc232..d69c223388f05f 100644 --- a/tools/node_modules/eslint/lib/rules/vars-on-top.js +++ b/tools/node_modules/eslint/lib/rules/vars-on-top.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "suggestion", + docs: { description: "require `var` declarations be placed at the top of their containing scope", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/wrap-iife.js b/tools/node_modules/eslint/lib/rules/wrap-iife.js index d006d30a0042fb..ce272235b4f035 100644 --- a/tools/node_modules/eslint/lib/rules/wrap-iife.js +++ b/tools/node_modules/eslint/lib/rules/wrap-iife.js @@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils"); module.exports = { meta: { + type: "layout", + docs: { description: "require parentheses around immediate `function` invocations", category: "Best Practices", diff --git a/tools/node_modules/eslint/lib/rules/wrap-regex.js b/tools/node_modules/eslint/lib/rules/wrap-regex.js index 1816e0e9e64e19..4ecbcecbbeb0b3 100644 --- a/tools/node_modules/eslint/lib/rules/wrap-regex.js +++ b/tools/node_modules/eslint/lib/rules/wrap-regex.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require parenthesis around regex literals", category: "Stylistic Issues", @@ -19,8 +21,8 @@ module.exports = { }, schema: [], - fixable: "code", + messages: { requireParens: "Wrap the regexp literal in parens to disambiguate the slash." } 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 33a37f0d991577..e7712a51dbf7e7 100644 --- a/tools/node_modules/eslint/lib/rules/yield-star-spacing.js +++ b/tools/node_modules/eslint/lib/rules/yield-star-spacing.js @@ -11,6 +11,8 @@ module.exports = { meta: { + type: "layout", + docs: { description: "require or disallow spacing around the `*` in `yield*` expressions", category: "ECMAScript 6", diff --git a/tools/node_modules/eslint/lib/rules/yoda.js b/tools/node_modules/eslint/lib/rules/yoda.js index 35368dd4df9780..8789c001ef933e 100644 --- a/tools/node_modules/eslint/lib/rules/yoda.js +++ b/tools/node_modules/eslint/lib/rules/yoda.js @@ -152,6 +152,8 @@ function same(a, b) { module.exports = { meta: { + type: "suggestion", + docs: { description: "require or disallow \"Yoda\" conditions", category: "Best Practices", 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 922ff0c9fc9c1b..9f2447cff5cb7e 100644 --- a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js @@ -445,6 +445,8 @@ var SCOPE_ASYNC = 4; var SCOPE_GENERATOR = 8; var SCOPE_ARROW = 16; var SCOPE_SIMPLE_CATCH = 32; +var SCOPE_SUPER = 64; +var SCOPE_DIRECT_SUPER = 128; function functionFlags(async, generator) { return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0) @@ -540,7 +542,7 @@ var Parser = function Parser(options, input, startPos) { this.regexpState = null; }; -var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true } }; +var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true } }; Parser.prototype.parse = function parse () { var node = this.options.program || this.startNode(); @@ -551,6 +553,11 @@ Parser.prototype.parse = function parse () { prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }; prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }; +prototypeAccessors.allowSuper.get = function () { return (this.currentThisScope().flags & SCOPE_SUPER) > 0 }; +prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }; + +// Switch to a getter for 7.0.0. +Parser.prototype.inNonArrowFunction = function inNonArrowFunction () { return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0 }; Parser.extend = function extend () { var plugins = [], len = arguments.length; @@ -1266,7 +1273,7 @@ pp$1.parseClass = function(node, isStatement) { classBody.body = []; this.expect(types.braceL); while (!this.eat(types.braceR)) { - var element = this$1.parseClassElement(); + var element = this$1.parseClassElement(node.superClass !== null); if (element) { classBody.body.push(element); if (element.type === "MethodDefinition" && element.kind === "constructor") { @@ -1279,7 +1286,7 @@ pp$1.parseClass = function(node, isStatement) { return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") }; -pp$1.parseClassElement = function() { +pp$1.parseClassElement = function(constructorAllowsSuper) { var this$1 = this; if (this.eat(types.semi)) { return null } @@ -1315,16 +1322,18 @@ pp$1.parseClassElement = function() { } if (!method.key) { this.parsePropertyName(method); } var key = method.key; + var allowsDirectSuper = false; if (!method.computed && !method.static && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) { if (method.kind !== "method") { this.raise(key.start, "Constructor can't have get/set modifier"); } if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); } if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); } method.kind = "constructor"; + allowsDirectSuper = constructorAllowsSuper; } else if (method.static && key.type === "Identifier" && key.name === "prototype") { this.raise(key.start, "Classes may not have a static property named prototype"); } - this.parseClassMethod(method, isGenerator, isAsync); + this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper); if (method.kind === "get" && method.value.params.length !== 0) { this.raiseRecoverable(method.value.start, "getter should have no params"); } if (method.kind === "set" && method.value.params.length !== 1) @@ -1334,8 +1343,8 @@ pp$1.parseClassElement = function() { return method }; -pp$1.parseClassMethod = function(method, isGenerator, isAsync) { - method.value = this.parseMethod(isGenerator, isAsync); +pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) { + method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper); return this.finishNode(method, "MethodDefinition") }; @@ -2122,13 +2131,19 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { // or `{}`. pp$3.parseExprAtom = function(refDestructuringErrors) { + // If a division operator appears in an expression position, the + // tokenizer got confused, and we force it to read a regexp instead. + if (this.type === types.slash) { this.readRegexp(); } + var node, canBeArrow = this.potentialArrowAt === this.start; switch (this.type) { case types._super: - if (!this.inFunction) - { this.raise(this.start, "'super' outside of function or class"); } + if (!this.allowSuper) + { this.raise(this.start, "'super' keyword outside a method"); } node = this.startNode(); this.next(); + if (this.type === types.parenL && !this.allowDirectSuper) + { this.raise(node.start, "super() call outside constructor of a subclass"); } // The `super` keyword can appear at below: // SuperProperty: // super [ Expression ] @@ -2524,7 +2539,7 @@ pp$3.initFunction = function(node) { // Parse object or class method. -pp$3.parseMethod = function(isGenerator, isAsync) { +pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) { var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos; this.initFunction(node); @@ -2535,7 +2550,7 @@ pp$3.parseMethod = function(isGenerator, isAsync) { this.yieldPos = 0; this.awaitPos = 0; - this.enterScope(functionFlags(isAsync, node.generator)); + 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); @@ -2823,12 +2838,14 @@ pp$5.currentVarScope = function() { } }; -pp$5.inNonArrowFunction = function() { +// Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`. +pp$5.currentThisScope = function() { var this$1 = this; - for (var i = this.scopeStack.length - 1; i >= 0; i--) - { if (this$1.scopeStack[i].flags & SCOPE_FUNCTION && !(this$1.scopeStack[i].flags & SCOPE_ARROW)) { return true } } - return false + for (var i = this.scopeStack.length - 1;; i--) { + var scope = this$1.scopeStack[i]; + if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope } + } }; var Node = function Node(parser, pos, loc) { @@ -2924,7 +2941,7 @@ pp$7.braceIsBlock = function(prevType) { { return true } if (prevType === types.braceL) { return parent === types$1.b_stat } - if (prevType === types._var || prevType === types.name) + if (prevType === types._var || prevType === types._const || prevType === types.name) { return false } return !this.exprAllowed }; @@ -2986,6 +3003,7 @@ types.incDec.updateContext = function() { types._function.updateContext = types._class.updateContext = function(prevType) { if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && + !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) { this.context.push(types$1.f_expr); } else @@ -5257,7 +5275,7 @@ pp$8.readWord = function() { // // [walk]: util/walk.js -var version = "6.0.2"; +var version = "6.0.4"; // 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 57c8681c2eac8e..9cd41ec074e110 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 // th 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\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} 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\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 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}\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() {\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 if (nextCh === 91 || nextCh === 123) return true // '{' and '['\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()) {\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 if ((context && (this.strict || context !== \"if\")) && 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)\n if (node.body.type === \"ClassDeclaration\" ||\n node.body.type === \"VariableDeclaration\" && node.body.kind !== \"var\" ||\n node.body.type === \"FunctionDeclaration\" && (this.strict || node.body.generator || node.body.async))\n this.raiseRecoverable(node.body.start, \"Invalid labeled declaration\")\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 this.exitScope()\n node.body = this.parseStatement(\"for\")\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 this.exitScope()\n node.body = this.parseStatement(\"for\")\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 decl.id = this.parseBindingAtom(kind)\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 node.generator = this.eat(tt.star)\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 this.checkLVal(node.id, this.inModule && !this.inFunction ? 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 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()\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 return this.finishNode(node, isStatement ? \"ClassDeclaration\" : \"ClassExpression\")\n}\n\npp.parseClassElement = function() {\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 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 } 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)\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) {\n method.value = this.parseMethod(isGenerator, isAsync)\n return this.finishNode(method, \"MethodDefinition\")\n}\n\npp.parseClassId = function(node, isStatement) {\n node.id = this.type === tt.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null\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)\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, 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()\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 let node, canBeArrow = this.potentialArrowAt === this.start\n switch (this.type) {\n case tt._super:\n if (!this.inFunction)\n this.raise(this.start, \"'super' outside of function or class\")\n node = this.startNode()\n this.next()\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) {\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))\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() {\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()\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_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 }\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\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.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 redeclared = scope.lexical.indexOf(name) > -1\n scope.var.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) redeclared = true\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\npp.inNonArrowFunction = function() {\n for (let i = this.scopeStack.length - 1; i >= 0; i--)\n if (this.scopeStack[i].flags & SCOPE_FUNCTION && !(this.scopeStack[i].flags & SCOPE_ARROW)) return true\n return false\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.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.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 // ` - - - -Implementation of function.prototype.bind - -## Example - -I mainly do this for unit tests I run on phantomjs. -PhantomJS does not have Function.prototype.bind :( - -```js -Function.prototype.bind = require("function-bind") -``` - -## Installation - -`npm install function-bind` - -## Contributors - - - Raynos - -## MIT Licenced - - [travis-svg]: https://travis-ci.org/Raynos/function-bind.svg - [travis-url]: https://travis-ci.org/Raynos/function-bind - [npm-badge-svg]: https://badge.fury.io/js/function-bind.svg - [npm-url]: https://npmjs.org/package/function-bind - [5]: https://coveralls.io/repos/Raynos/function-bind/badge.png - [6]: https://coveralls.io/r/Raynos/function-bind - [7]: https://gemnasium.com/Raynos/function-bind.png - [8]: https://gemnasium.com/Raynos/function-bind - [deps-svg]: https://david-dm.org/Raynos/function-bind.svg - [deps-url]: https://david-dm.org/Raynos/function-bind - [dev-deps-svg]: https://david-dm.org/Raynos/function-bind/dev-status.svg - [dev-deps-url]: https://david-dm.org/Raynos/function-bind#info=devDependencies - [11]: https://ci.testling.com/Raynos/function-bind.png - [12]: https://ci.testling.com/Raynos/function-bind diff --git a/tools/node_modules/eslint/node_modules/function-bind/implementation.js b/tools/node_modules/eslint/node_modules/function-bind/implementation.js deleted file mode 100644 index cc4daec1b080a1..00000000000000 --- a/tools/node_modules/eslint/node_modules/function-bind/implementation.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -/* eslint no-invalid-this: 1 */ - -var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; -var slice = Array.prototype.slice; -var toStr = Object.prototype.toString; -var funcType = '[object Function]'; - -module.exports = function bind(that) { - var target = this; - if (typeof target !== 'function' || toStr.call(target) !== funcType) { - throw new TypeError(ERROR_MESSAGE + target); - } - var args = slice.call(arguments, 1); - - var bound; - var binder = function () { - if (this instanceof bound) { - var result = target.apply( - this, - args.concat(slice.call(arguments)) - ); - if (Object(result) === result) { - return result; - } - return this; - } else { - return target.apply( - that, - args.concat(slice.call(arguments)) - ); - } - }; - - var boundLength = Math.max(0, target.length - args.length); - var boundArgs = []; - for (var i = 0; i < boundLength; i++) { - boundArgs.push('$' + i); - } - - bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder); - - if (target.prototype) { - var Empty = function Empty() {}; - Empty.prototype = target.prototype; - bound.prototype = new Empty(); - Empty.prototype = null; - } - - return bound; -}; diff --git a/tools/node_modules/eslint/node_modules/function-bind/index.js b/tools/node_modules/eslint/node_modules/function-bind/index.js deleted file mode 100644 index 3bb6b9609889f8..00000000000000 --- a/tools/node_modules/eslint/node_modules/function-bind/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var implementation = require('./implementation'); - -module.exports = Function.prototype.bind || implementation; diff --git a/tools/node_modules/eslint/node_modules/function-bind/package.json b/tools/node_modules/eslint/node_modules/function-bind/package.json deleted file mode 100644 index 6574255758b8bc..00000000000000 --- a/tools/node_modules/eslint/node_modules/function-bind/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "author": { - "name": "Raynos", - "email": "raynos2@gmail.com" - }, - "bugs": { - "url": "https://github.com/Raynos/function-bind/issues", - "email": "raynos2@gmail.com" - }, - "bundleDependencies": false, - "contributors": [ - { - "name": "Raynos" - }, - { - "name": "Jordan Harband", - "url": "https://github.com/ljharb" - } - ], - "dependencies": {}, - "deprecated": false, - "description": "Implementation of Function.prototype.bind", - "devDependencies": { - "@ljharb/eslint-config": "^12.2.1", - "covert": "^1.1.0", - "eslint": "^4.5.0", - "jscs": "^3.0.7", - "tape": "^4.8.0" - }, - "homepage": "https://github.com/Raynos/function-bind", - "keywords": [ - "function", - "bind", - "shim", - "es5" - ], - "license": "MIT", - "main": "index", - "name": "function-bind", - "repository": { - "type": "git", - "url": "git://github.com/Raynos/function-bind.git" - }, - "scripts": { - "coverage": "covert test/*.js", - "eslint": "eslint *.js */*.js", - "jscs": "jscs *.js */*.js", - "lint": "npm run jscs && npm run eslint", - "posttest": "npm run coverage -- --quiet", - "pretest": "npm run lint", - "test": "npm run tests-only", - "tests-only": "node test" - }, - "testling": { - "files": "test/index.js", - "browsers": [ - "ie/8..latest", - "firefox/16..latest", - "firefox/nightly", - "chrome/22..latest", - "chrome/canary", - "opera/12..latest", - "opera/next", - "safari/5.1..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2..latest" - ] - }, - "version": "1.1.1" -} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/globby/index.js b/tools/node_modules/eslint/node_modules/globby/index.js index 39da9f64d1ee42..587a0fdd1cc0fb 100644 --- a/tools/node_modules/eslint/node_modules/globby/index.js +++ b/tools/node_modules/eslint/node_modules/globby/index.js @@ -3,7 +3,6 @@ var Promise = require('pinkie-promise'); var arrayUnion = require('array-union'); var objectAssign = require('object-assign'); var glob = require('glob'); -var arrify = require('arrify'); var pify = require('pify'); var globP = pify(glob, Promise).bind(glob); @@ -12,10 +11,22 @@ function isNegative(pattern) { return pattern[0] === '!'; } +function isString(value) { + return typeof value === 'string'; +} + +function assertPatternsInput(patterns) { + if (!patterns.every(isString)) { + throw new TypeError('patterns must be a string or an array of strings'); + } +} + function generateGlobTasks(patterns, opts) { + patterns = [].concat(patterns); + assertPatternsInput(patterns); + var globTasks = []; - patterns = arrify(patterns); opts = objectAssign({ cache: Object.create(null), statCache: Object.create(null), @@ -45,7 +56,13 @@ function generateGlobTasks(patterns, opts) { } module.exports = function (patterns, opts) { - var globTasks = generateGlobTasks(patterns, opts); + var globTasks; + + try { + globTasks = generateGlobTasks(patterns, opts); + } catch (err) { + return Promise.reject(err); + } return Promise.all(globTasks.map(function (task) { return globP(task.pattern, task.opts); @@ -63,3 +80,9 @@ module.exports.sync = function (patterns, opts) { }; module.exports.generateGlobTasks = generateGlobTasks; + +module.exports.hasMagic = function (patterns, opts) { + return [].concat(patterns).some(function (pattern) { + return glob.hasMagic(pattern, opts); + }); +}; diff --git a/tools/node_modules/eslint/node_modules/globby/node_modules/pify/index.js b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/index.js new file mode 100644 index 00000000000000..7c720ebee88727 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/index.js @@ -0,0 +1,68 @@ +'use strict'; + +var processFn = function (fn, P, opts) { + return function () { + var that = this; + var args = new Array(arguments.length); + + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + + return new P(function (resolve, reject) { + args.push(function (err, result) { + if (err) { + reject(err); + } else if (opts.multiArgs) { + var results = new Array(arguments.length - 1); + + for (var i = 1; i < arguments.length; i++) { + results[i - 1] = arguments[i]; + } + + resolve(results); + } else { + resolve(result); + } + }); + + fn.apply(that, args); + }); + }; +}; + +var pify = module.exports = function (obj, P, opts) { + if (typeof P !== 'function') { + opts = P; + P = Promise; + } + + opts = opts || {}; + opts.exclude = opts.exclude || [/.+Sync$/]; + + var filter = function (key) { + var match = function (pattern) { + return typeof pattern === 'string' ? key === pattern : pattern.test(key); + }; + + return opts.include ? opts.include.some(match) : !opts.exclude.some(match); + }; + + var ret = typeof obj === 'function' ? function () { + if (opts.excludeMain) { + return obj.apply(this, arguments); + } + + return processFn(obj, P, opts).apply(this, arguments); + } : {}; + + return Object.keys(obj).reduce(function (ret, key) { + var x = obj[key]; + + ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x; + + return ret; + }, ret); +}; + +pify.all = pify; diff --git a/tools/node_modules/eslint/node_modules/arrify/license b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/license similarity index 100% rename from tools/node_modules/eslint/node_modules/arrify/license rename to tools/node_modules/eslint/node_modules/globby/node_modules/pify/license diff --git a/tools/node_modules/eslint/node_modules/globby/node_modules/pify/package.json b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/package.json new file mode 100644 index 00000000000000..40780115cf1d0a --- /dev/null +++ b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/package.json @@ -0,0 +1,57 @@ +{ + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/pify/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Promisify a callback-style function", + "devDependencies": { + "ava": "*", + "pinkie-promise": "^1.0.0", + "v8-natives": "0.0.2", + "xo": "*" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/pify#readme", + "keywords": [ + "promise", + "promises", + "promisify", + "denodify", + "denodeify", + "callback", + "cb", + "node", + "then", + "thenify", + "convert", + "transform", + "wrap", + "wrapper", + "bind", + "to", + "async", + "es2015" + ], + "license": "MIT", + "name": "pify", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/pify.git" + }, + "scripts": { + "optimization-test": "node --allow-natives-syntax optimization-test.js", + "test": "xo && ava && npm run optimization-test" + }, + "version": "2.3.0" +} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/globby/node_modules/pify/readme.md b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/readme.md new file mode 100644 index 00000000000000..97aeeb628b0897 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/globby/node_modules/pify/readme.md @@ -0,0 +1,119 @@ +# pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) + +> Promisify a callback-style function + + +## Install + +``` +$ npm install --save pify +``` + + +## Usage + +```js +const fs = require('fs'); +const pify = require('pify'); + +// promisify a single function + +pify(fs.readFile)('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); + +// or promisify all methods in a module + +pify(fs).readFile('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); +``` + + +## API + +### pify(input, [promiseModule], [options]) + +Returns a promise wrapped version of the supplied function or module. + +#### input + +Type: `function`, `object` + +Callback-style function or module whose methods you want to promisify. + +#### promiseModule + +Type: `function` + +Custom promise module to use instead of the native one. + +Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. + +#### options + +##### multiArgs + +Type: `boolean` +Default: `false` + +By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. + +```js +const request = require('request'); +const pify = require('pify'); + +pify(request, {multiArgs: true})('https://sindresorhus.com').then(result => { + const [httpResponse, body] = result; +}); +``` + +##### include + +Type: `array` of (`string`|`regex`) + +Methods in a module to promisify. Remaining methods will be left untouched. + +##### exclude + +Type: `array` of (`string`|`regex`) +Default: `[/.+Sync$/]` + +Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default. + +##### excludeMain + +Type: `boolean` +Default: `false` + +By default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module. + +```js +const pify = require('pify'); + +function fn() { + return true; +} + +fn.method = (data, callback) => { + setImmediate(() => { + callback(data, null); + }); +}; + +// promisify methods but not fn() +const promiseFn = pify(fn, {excludeMain: true}); + +if (promiseFn()) { + promiseFn.method('hi').then(data => { + console.log(data); + }); +} +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/eslint/node_modules/globby/package.json b/tools/node_modules/eslint/node_modules/globby/package.json index 34b15123bb0008..fad7fc179674cb 100644 --- a/tools/node_modules/eslint/node_modules/globby/package.json +++ b/tools/node_modules/eslint/node_modules/globby/package.json @@ -10,7 +10,6 @@ "bundleDependencies": false, "dependencies": { "array-union": "^1.0.1", - "arrify": "^1.0.0", "glob": "^7.0.3", "object-assign": "^4.0.1", "pify": "^2.0.0", @@ -20,11 +19,11 @@ "description": "Extends `glob` with support for multiple patterns and exposes a Promise API", "devDependencies": { "ava": "*", - "glob-stream": "github:wearefractal/glob-stream#master", + "glob-stream": "github:gulpjs/glob-stream#master", "globby": "github:sindresorhus/globby#master", "matcha": "^0.7.0", "rimraf": "^2.2.8", - "xo": "*" + "xo": "^0.16.0" }, "engines": { "node": ">=0.10.0" @@ -72,8 +71,8 @@ "url": "git+https://github.com/sindresorhus/globby.git" }, "scripts": { - "bench": "npm update globby glob-stream && matcha bench.js", + "bench": "npm update glob-stream && matcha bench.js", "test": "xo && ava" }, - "version": "5.0.0" + "version": "6.1.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/globby/readme.md b/tools/node_modules/eslint/node_modules/globby/readme.md index aad991d020b1b5..e10a48868f9e29 100644 --- a/tools/node_modules/eslint/node_modules/globby/readme.md +++ b/tools/node_modules/eslint/node_modules/globby/readme.md @@ -42,11 +42,17 @@ Returns an array of matching paths. Returns an array of objects in the format `{ pattern: string, opts: Object }`, which can be passed as arguments to [`node-glob`](https://github.com/isaacs/node-glob). This is useful for other globbing-related packages. -Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, create a new tasks list to ensure that file system changes are taken in consideration. +Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration. + +### globby.hasMagic(patterns, [options]) + +Returns a `boolean` of whether there are any special glob characters in the `patterns`. + +Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set. #### patterns -Type: `string`, `Array` +Type: `string` `Array` See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage). diff --git a/tools/node_modules/eslint/node_modules/graceful-fs/fs.js b/tools/node_modules/eslint/node_modules/graceful-fs/clone.js similarity index 88% rename from tools/node_modules/eslint/node_modules/graceful-fs/fs.js rename to tools/node_modules/eslint/node_modules/graceful-fs/clone.js index 8ad4a383965b7b..028356c96ed536 100644 --- a/tools/node_modules/eslint/node_modules/graceful-fs/fs.js +++ b/tools/node_modules/eslint/node_modules/graceful-fs/clone.js @@ -1,8 +1,6 @@ 'use strict' -var fs = require('fs') - -module.exports = clone(fs) +module.exports = clone function clone (obj) { if (obj === null || typeof obj !== 'object') diff --git a/tools/node_modules/eslint/node_modules/graceful-fs/graceful-fs.js b/tools/node_modules/eslint/node_modules/graceful-fs/graceful-fs.js index 33b30d2e986eba..ac206757e63c5a 100644 --- a/tools/node_modules/eslint/node_modules/graceful-fs/graceful-fs.js +++ b/tools/node_modules/eslint/node_modules/graceful-fs/graceful-fs.js @@ -1,6 +1,8 @@ var fs = require('fs') var polyfills = require('./polyfills.js') var legacy = require('./legacy-streams.js') +var clone = require('./clone.js') + var queue = [] var util = require('util') @@ -24,17 +26,17 @@ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) { }) } -module.exports = patch(require('./fs.js')) -if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) { - module.exports = patch(fs) +module.exports = patch(clone(fs)) +if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) { + module.exports = patch(fs) + fs.__patched = true; } // Always patch fs.close/closeSync, because we want to // retry() whenever a close happens *anywhere* in the program. // This is essential when multiple graceful-fs instances are // in play at the same time. -module.exports.close = -fs.close = (function (fs$close) { return function (fd, cb) { +module.exports.close = (function (fs$close) { return function (fd, cb) { return fs$close.call(fs, fd, function (err) { if (!err) retry() @@ -44,8 +46,7 @@ fs.close = (function (fs$close) { return function (fd, cb) { }) }})(fs.close) -module.exports.closeSync = -fs.closeSync = (function (fs$closeSync) { return function (fd) { +module.exports.closeSync = (function (fs$closeSync) { return function (fd) { // Note that graceful-fs also retries when fs.closeSync() fails. // Looks like a bug to me, although it's probably a harmless one. var rval = fs$closeSync.apply(fs, arguments) @@ -53,6 +54,17 @@ fs.closeSync = (function (fs$closeSync) { return function (fd) { return rval }})(fs.closeSync) +// Only patch fs once, otherwise we'll run into a memory leak if +// graceful-fs is loaded multiple times, such as in test environments that +// reset the loaded modules between tests. +// We look for the string `graceful-fs` from the comment above. This +// way we are not adding any extra properties and it will detect if older +// versions of graceful-fs are installed. +if (!/\bgraceful-fs\b/.test(fs.closeSync.toString())) { + fs.closeSync = module.exports.closeSync; + fs.close = module.exports.close; +} + function patch (fs) { // Everything that references the open() function needs to be in here polyfills(fs) @@ -144,6 +156,7 @@ function patch (fs) { if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) enqueue([go$readdir, [args]]) + else { if (typeof cb === 'function') cb.apply(this, arguments) @@ -163,12 +176,16 @@ function patch (fs) { } var fs$ReadStream = fs.ReadStream - ReadStream.prototype = Object.create(fs$ReadStream.prototype) - ReadStream.prototype.open = ReadStream$open + if (fs$ReadStream) { + ReadStream.prototype = Object.create(fs$ReadStream.prototype) + ReadStream.prototype.open = ReadStream$open + } var fs$WriteStream = fs.WriteStream - WriteStream.prototype = Object.create(fs$WriteStream.prototype) - WriteStream.prototype.open = WriteStream$open + if (fs$WriteStream) { + WriteStream.prototype = Object.create(fs$WriteStream.prototype) + WriteStream.prototype.open = WriteStream$open + } fs.ReadStream = ReadStream fs.WriteStream = WriteStream diff --git a/tools/node_modules/eslint/node_modules/graceful-fs/package.json b/tools/node_modules/eslint/node_modules/graceful-fs/package.json index ea35fce0aa2359..b585bfe22fd54f 100644 --- a/tools/node_modules/eslint/node_modules/graceful-fs/package.json +++ b/tools/node_modules/eslint/node_modules/graceful-fs/package.json @@ -6,21 +6,20 @@ "deprecated": false, "description": "A drop-in replacement for fs, making various improvements.", "devDependencies": { + "import-fresh": "^2.0.0", "mkdirp": "^0.5.0", "rimraf": "^2.2.8", - "tap": "^5.4.2" + "tap": "^12.0.1" }, "directories": { "test": "test" }, - "engines": { - "node": ">=0.4.0" - }, "files": [ "fs.js", "graceful-fs.js", "legacy-streams.js", - "polyfills.js" + "polyfills.js", + "clone.js" ], "homepage": "https://github.com/isaacs/node-graceful-fs#readme", "keywords": [ @@ -47,7 +46,10 @@ "url": "git+https://github.com/isaacs/node-graceful-fs.git" }, "scripts": { + "postpublish": "git push origin --all; git push origin --tags", + "postversion": "npm publish", + "preversion": "npm test", "test": "node test.js | tap -" }, - "version": "4.1.11" + "version": "4.1.15" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/graceful-fs/polyfills.js b/tools/node_modules/eslint/node_modules/graceful-fs/polyfills.js index 4c6aca78a3dc8b..b964ed0806ceeb 100644 --- a/tools/node_modules/eslint/node_modules/graceful-fs/polyfills.js +++ b/tools/node_modules/eslint/node_modules/graceful-fs/polyfills.js @@ -1,4 +1,3 @@ -var fs = require('./fs.js') var constants = require('constants') var origCwd = process.cwd @@ -145,73 +144,36 @@ function patch (fs) { } } }})(fs.readSync) -} - -function patchLchmod (fs) { - fs.lchmod = function (path, mode, callback) { - fs.open( path - , constants.O_WRONLY | constants.O_SYMLINK - , mode - , function (err, fd) { - if (err) { - if (callback) callback(err) - return - } - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - fs.fchmod(fd, mode, function (err) { - fs.close(fd, function(err2) { - if (callback) callback(err || err2) - }) - }) - }) - } - - fs.lchmodSync = function (path, mode) { - var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) - - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - var threw = true - var ret - try { - ret = fs.fchmodSync(fd, mode) - threw = false - } finally { - if (threw) { - try { - fs.closeSync(fd) - } catch (er) {} - } else { - fs.closeSync(fd) - } - } - return ret - } -} -function patchLutimes (fs) { - if (constants.hasOwnProperty("O_SYMLINK")) { - fs.lutimes = function (path, at, mt, cb) { - fs.open(path, constants.O_SYMLINK, function (er, fd) { - if (er) { - if (cb) cb(er) + function patchLchmod (fs) { + fs.lchmod = function (path, mode, callback) { + fs.open( path + , constants.O_WRONLY | constants.O_SYMLINK + , mode + , function (err, fd) { + if (err) { + if (callback) callback(err) return } - fs.futimes(fd, at, mt, function (er) { - fs.close(fd, function (er2) { - if (cb) cb(er || er2) + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + fs.fchmod(fd, mode, function (err) { + fs.close(fd, function(err2) { + if (callback) callback(err || err2) }) }) }) } - fs.lutimesSync = function (path, at, mt) { - var fd = fs.openSync(path, constants.O_SYMLINK) - var ret + fs.lchmodSync = function (path, mode) { + var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) + + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. var threw = true + var ret try { - ret = fs.futimesSync(fd, at, mt) + ret = fs.fchmodSync(fd, mode) threw = false } finally { if (threw) { @@ -224,107 +186,144 @@ function patchLutimes (fs) { } return ret } + } + + function patchLutimes (fs) { + if (constants.hasOwnProperty("O_SYMLINK")) { + fs.lutimes = function (path, at, mt, cb) { + fs.open(path, constants.O_SYMLINK, function (er, fd) { + if (er) { + if (cb) cb(er) + return + } + fs.futimes(fd, at, mt, function (er) { + fs.close(fd, function (er2) { + if (cb) cb(er || er2) + }) + }) + }) + } + + fs.lutimesSync = function (path, at, mt) { + var fd = fs.openSync(path, constants.O_SYMLINK) + var ret + var threw = true + try { + ret = fs.futimesSync(fd, at, mt) + threw = false + } finally { + if (threw) { + try { + fs.closeSync(fd) + } catch (er) {} + } else { + fs.closeSync(fd) + } + } + return ret + } - } else { - fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) } - fs.lutimesSync = function () {} + } else { + fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) } + fs.lutimesSync = function () {} + } } -} -function chmodFix (orig) { - if (!orig) return orig - return function (target, mode, cb) { - return orig.call(fs, target, mode, function (er) { - if (chownErOk(er)) er = null - if (cb) cb.apply(this, arguments) - }) + function chmodFix (orig) { + if (!orig) return orig + return function (target, mode, cb) { + return orig.call(fs, target, mode, function (er) { + if (chownErOk(er)) er = null + if (cb) cb.apply(this, arguments) + }) + } } -} -function chmodFixSync (orig) { - if (!orig) return orig - return function (target, mode) { - try { - return orig.call(fs, target, mode) - } catch (er) { - if (!chownErOk(er)) throw er + function chmodFixSync (orig) { + if (!orig) return orig + return function (target, mode) { + try { + return orig.call(fs, target, mode) + } catch (er) { + if (!chownErOk(er)) throw er + } } } -} -function chownFix (orig) { - if (!orig) return orig - return function (target, uid, gid, cb) { - return orig.call(fs, target, uid, gid, function (er) { - if (chownErOk(er)) er = null - if (cb) cb.apply(this, arguments) - }) + function chownFix (orig) { + if (!orig) return orig + return function (target, uid, gid, cb) { + return orig.call(fs, target, uid, gid, function (er) { + if (chownErOk(er)) er = null + if (cb) cb.apply(this, arguments) + }) + } } -} -function chownFixSync (orig) { - if (!orig) return orig - return function (target, uid, gid) { - try { - return orig.call(fs, target, uid, gid) - } catch (er) { - if (!chownErOk(er)) throw er + function chownFixSync (orig) { + if (!orig) return orig + return function (target, uid, gid) { + try { + return orig.call(fs, target, uid, gid) + } catch (er) { + if (!chownErOk(er)) throw er + } } } -} -function statFix (orig) { - if (!orig) return orig - // Older versions of Node erroneously returned signed integers for - // uid + gid. - return function (target, cb) { - return orig.call(fs, target, function (er, stats) { - if (!stats) return cb.apply(this, arguments) + function statFix (orig) { + if (!orig) return orig + // Older versions of Node erroneously returned signed integers for + // uid + gid. + return function (target, cb) { + return orig.call(fs, target, function (er, stats) { + if (!stats) return cb.apply(this, arguments) + if (stats.uid < 0) stats.uid += 0x100000000 + if (stats.gid < 0) stats.gid += 0x100000000 + if (cb) cb.apply(this, arguments) + }) + } + } + + function statFixSync (orig) { + if (!orig) return orig + // Older versions of Node erroneously returned signed integers for + // uid + gid. + return function (target) { + var stats = orig.call(fs, target) if (stats.uid < 0) stats.uid += 0x100000000 if (stats.gid < 0) stats.gid += 0x100000000 - if (cb) cb.apply(this, arguments) - }) + return stats; + } } -} -function statFixSync (orig) { - if (!orig) return orig - // Older versions of Node erroneously returned signed integers for - // uid + gid. - return function (target) { - var stats = orig.call(fs, target) - if (stats.uid < 0) stats.uid += 0x100000000 - if (stats.gid < 0) stats.gid += 0x100000000 - return stats; - } -} + // ENOSYS means that the fs doesn't support the op. Just ignore + // that, because it doesn't matter. + // + // if there's no getuid, or if getuid() is something other + // than 0, and the error is EINVAL or EPERM, then just ignore + // it. + // + // This specific case is a silent failure in cp, install, tar, + // and most other unix tools that manage permissions. + // + // When running as root, or if other types of errors are + // encountered, then it's strict. + function chownErOk (er) { + if (!er) + return true -// ENOSYS means that the fs doesn't support the op. Just ignore -// that, because it doesn't matter. -// -// if there's no getuid, or if getuid() is something other -// than 0, and the error is EINVAL or EPERM, then just ignore -// it. -// -// This specific case is a silent failure in cp, install, tar, -// and most other unix tools that manage permissions. -// -// When running as root, or if other types of errors are -// encountered, then it's strict. -function chownErOk (er) { - if (!er) - return true - - if (er.code === "ENOSYS") - return true - - var nonroot = !process.getuid || process.getuid() !== 0 - if (nonroot) { - if (er.code === "EINVAL" || er.code === "EPERM") + if (er.code === "ENOSYS") return true - } - return false + var nonroot = !process.getuid || process.getuid() !== 0 + if (nonroot) { + if (er.code === "EINVAL" || er.code === "EPERM") + return true + } + + return false + } } diff --git a/tools/node_modules/eslint/node_modules/has/LICENSE-MIT b/tools/node_modules/eslint/node_modules/has/LICENSE-MIT deleted file mode 100644 index ae7014d385df3d..00000000000000 --- a/tools/node_modules/eslint/node_modules/has/LICENSE-MIT +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2013 Thiago de Arruda - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/node_modules/eslint/node_modules/has/README.md b/tools/node_modules/eslint/node_modules/has/README.md deleted file mode 100644 index 635e3a4baab00b..00000000000000 --- a/tools/node_modules/eslint/node_modules/has/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# has - -> Object.prototype.hasOwnProperty.call shortcut - -## Installation - -```sh -npm install --save has -``` - -## Usage - -```js -var has = require('has'); - -has({}, 'hasOwnProperty'); // false -has(Object.prototype, 'hasOwnProperty'); // true -``` diff --git a/tools/node_modules/eslint/node_modules/has/package.json b/tools/node_modules/eslint/node_modules/has/package.json deleted file mode 100644 index 4b061b0e838104..00000000000000 --- a/tools/node_modules/eslint/node_modules/has/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "author": { - "name": "Thiago de Arruda", - "email": "tpadilha84@gmail.com" - }, - "bugs": { - "url": "https://github.com/tarruda/has/issues" - }, - "bundleDependencies": false, - "contributors": [ - { - "name": "Jordan Harband", - "email": "ljharb@gmail.com", - "url": "http://ljharb.codes" - } - ], - "dependencies": { - "function-bind": "^1.1.1" - }, - "deprecated": false, - "description": "Object.prototype.hasOwnProperty.call shortcut", - "devDependencies": { - "@ljharb/eslint-config": "^12.2.1", - "eslint": "^4.19.1", - "tape": "^4.9.0" - }, - "engines": { - "node": ">= 0.4.0" - }, - "homepage": "https://github.com/tarruda/has", - "license": "MIT", - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/tarruda/has/blob/master/LICENSE-MIT" - } - ], - "main": "./src", - "name": "has", - "repository": { - "type": "git", - "url": "git://github.com/tarruda/has.git" - }, - "scripts": { - "lint": "eslint .", - "pretest": "npm run lint", - "test": "tape test" - }, - "version": "1.0.3" -} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/has/src/index.js b/tools/node_modules/eslint/node_modules/has/src/index.js deleted file mode 100644 index dd92dd9094edb0..00000000000000 --- a/tools/node_modules/eslint/node_modules/has/src/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var bind = require('function-bind'); - -module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty); diff --git a/tools/node_modules/eslint/node_modules/p-map/index.js b/tools/node_modules/eslint/node_modules/p-map/index.js new file mode 100644 index 00000000000000..f91477e1f5b3f3 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/p-map/index.js @@ -0,0 +1,67 @@ +'use strict'; +module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => { + opts = Object.assign({ + concurrency: Infinity + }, opts); + + if (typeof mapper !== 'function') { + throw new TypeError('Mapper function is required'); + } + + const concurrency = opts.concurrency; + + if (!(typeof concurrency === 'number' && concurrency >= 1)) { + throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${concurrency}\` (${typeof concurrency})`); + } + + const ret = []; + const iterator = iterable[Symbol.iterator](); + let isRejected = false; + let iterableDone = false; + let resolvingCount = 0; + let currentIdx = 0; + + const next = () => { + if (isRejected) { + return; + } + + const nextItem = iterator.next(); + const i = currentIdx; + currentIdx++; + + if (nextItem.done) { + iterableDone = true; + + if (resolvingCount === 0) { + resolve(ret); + } + + return; + } + + resolvingCount++; + + Promise.resolve(nextItem.value) + .then(el => mapper(el, i)) + .then( + val => { + ret[i] = val; + resolvingCount--; + next(); + }, + err => { + isRejected = true; + reject(err); + } + ); + }; + + for (let i = 0; i < concurrency; i++) { + next(); + + if (iterableDone) { + break; + } + } +}); diff --git a/tools/node_modules/eslint/node_modules/p-map/license b/tools/node_modules/eslint/node_modules/p-map/license new file mode 100644 index 00000000000000..e7af2f77107d73 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/p-map/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/node_modules/eslint/node_modules/p-map/package.json b/tools/node_modules/eslint/node_modules/p-map/package.json new file mode 100644 index 00000000000000..455e05c8bf2ebf --- /dev/null +++ b/tools/node_modules/eslint/node_modules/p-map/package.json @@ -0,0 +1,56 @@ +{ + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/p-map/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Map over promises concurrently", + "devDependencies": { + "ava": "*", + "delay": "^2.0.0", + "in-range": "^1.0.0", + "random-int": "^1.0.0", + "time-span": "^2.0.0", + "xo": "*" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/p-map#readme", + "keywords": [ + "promise", + "map", + "resolved", + "wait", + "collection", + "iterable", + "iterator", + "race", + "fulfilled", + "async", + "await", + "promises", + "concurrently", + "concurrency", + "parallel", + "bluebird" + ], + "license": "MIT", + "name": "p-map", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/p-map.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.2.0" +} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/p-map/readme.md b/tools/node_modules/eslint/node_modules/p-map/readme.md new file mode 100644 index 00000000000000..7727581a0e578c --- /dev/null +++ b/tools/node_modules/eslint/node_modules/p-map/readme.md @@ -0,0 +1,81 @@ +# p-map [![Build Status](https://travis-ci.org/sindresorhus/p-map.svg?branch=master)](https://travis-ci.org/sindresorhus/p-map) + +> Map over promises concurrently + +Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently. + + +## Install + +``` +$ npm install p-map +``` + + +## Usage + +```js +const pMap = require('p-map'); +const got = require('got'); + +const sites = [ + getWebsiteFromUsername('sindresorhus'), //=> Promise + 'ava.li', + 'todomvc.com', + 'github.com' +]; + +const mapper = el => got.head(el).then(res => res.requestUrl); + +pMap(sites, mapper, {concurrency: 2}).then(result => { + console.log(result); + //=> ['http://sindresorhus.com/', 'http://ava.li/', 'http://todomvc.com/', 'http://github.com/'] +}); +``` + + +## API + +### pMap(input, mapper, [options]) + +Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order. + +#### input + +Type: `Iterable` + +Iterated over concurrently in the `mapper` function. + +#### mapper(element, index) + +Type: `Function` + +Expected to return a `Promise` or value. + +#### options + +Type: `Object` + +##### concurrency + +Type: `number`
+Default: `Infinity`
+Minimum: `1` + +Number of concurrently pending promises returned by `mapper`. + + +## Related + +- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency +- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently +- [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently +- [p-props](https://github.com/sindresorhus/p-props) - Like `Promise.all()` but for `Map` and `Object` +- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially +- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control +- [More…](https://github.com/sindresorhus/promise-fun) + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/tools/node_modules/eslint/node_modules/pify/index.js b/tools/node_modules/eslint/node_modules/pify/index.js index 7c720ebee88727..1dee43ad08f62b 100644 --- a/tools/node_modules/eslint/node_modules/pify/index.js +++ b/tools/node_modules/eslint/node_modules/pify/index.js @@ -1,68 +1,84 @@ 'use strict'; -var processFn = function (fn, P, opts) { - return function () { - var that = this; - var args = new Array(arguments.length); +const processFn = (fn, opts) => function () { + const P = opts.promiseModule; + const args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } + for (let i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } - return new P(function (resolve, reject) { + return new P((resolve, reject) => { + if (opts.errorFirst) { args.push(function (err, result) { - if (err) { - reject(err); - } else if (opts.multiArgs) { - var results = new Array(arguments.length - 1); + if (opts.multiArgs) { + const results = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) { + for (let i = 1; i < arguments.length; i++) { results[i - 1] = arguments[i]; } - resolve(results); + if (err) { + results.unshift(err); + reject(results); + } else { + resolve(results); + } + } else if (err) { + reject(err); } else { resolve(result); } }); + } else { + args.push(function (result) { + if (opts.multiArgs) { + const results = new Array(arguments.length - 1); - fn.apply(that, args); - }); - }; -}; + for (let i = 0; i < arguments.length; i++) { + results[i] = arguments[i]; + } -var pify = module.exports = function (obj, P, opts) { - if (typeof P !== 'function') { - opts = P; - P = Promise; - } + resolve(results); + } else { + resolve(result); + } + }); + } - opts = opts || {}; - opts.exclude = opts.exclude || [/.+Sync$/]; + fn.apply(this, args); + }); +}; - var filter = function (key) { - var match = function (pattern) { - return typeof pattern === 'string' ? key === pattern : pattern.test(key); - }; +module.exports = (obj, opts) => { + opts = Object.assign({ + exclude: [/.+(Sync|Stream)$/], + errorFirst: true, + promiseModule: Promise + }, opts); + const filter = key => { + const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key); return opts.include ? opts.include.some(match) : !opts.exclude.some(match); }; - var ret = typeof obj === 'function' ? function () { - if (opts.excludeMain) { - return obj.apply(this, arguments); - } - - return processFn(obj, P, opts).apply(this, arguments); - } : {}; + let ret; + if (typeof obj === 'function') { + ret = function () { + if (opts.excludeMain) { + return obj.apply(this, arguments); + } - return Object.keys(obj).reduce(function (ret, key) { - var x = obj[key]; + return processFn(obj, opts).apply(this, arguments); + }; + } else { + ret = Object.create(Object.getPrototypeOf(obj)); + } - ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x; + for (const key in obj) { // eslint-disable-line guard-for-in + const x = obj[key]; + ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x; + } - return ret; - }, ret); + return ret; }; - -pify.all = pify; diff --git a/tools/node_modules/eslint/node_modules/pify/license b/tools/node_modules/eslint/node_modules/pify/license index 654d0bfe943437..e7af2f77107d73 100644 --- a/tools/node_modules/eslint/node_modules/pify/license +++ b/tools/node_modules/eslint/node_modules/pify/license @@ -1,21 +1,9 @@ -The MIT License (MIT) +MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/node_modules/eslint/node_modules/pify/package.json b/tools/node_modules/eslint/node_modules/pify/package.json index 40780115cf1d0a..37d6bd41a0aeb6 100644 --- a/tools/node_modules/eslint/node_modules/pify/package.json +++ b/tools/node_modules/eslint/node_modules/pify/package.json @@ -12,12 +12,12 @@ "description": "Promisify a callback-style function", "devDependencies": { "ava": "*", - "pinkie-promise": "^1.0.0", - "v8-natives": "0.0.2", + "pinkie-promise": "^2.0.0", + "v8-natives": "^1.0.0", "xo": "*" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" }, "files": [ "index.js" @@ -27,6 +27,7 @@ "promise", "promises", "promisify", + "all", "denodify", "denodeify", "callback", @@ -41,7 +42,9 @@ "bind", "to", "async", - "es2015" + "await", + "es2015", + "bluebird" ], "license": "MIT", "name": "pify", @@ -53,5 +56,5 @@ "optimization-test": "node --allow-natives-syntax optimization-test.js", "test": "xo && ava && npm run optimization-test" }, - "version": "2.3.0" + "version": "3.0.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/pify/readme.md b/tools/node_modules/eslint/node_modules/pify/readme.md index c79ca8bf643927..376ca4e59d74c4 100644 --- a/tools/node_modules/eslint/node_modules/pify/readme.md +++ b/tools/node_modules/eslint/node_modules/pify/readme.md @@ -16,15 +16,13 @@ $ npm install --save pify const fs = require('fs'); const pify = require('pify'); -// promisify a single function - +// Promisify a single function pify(fs.readFile)('package.json', 'utf8').then(data => { console.log(JSON.parse(data).name); //=> 'pify' }); -// or promisify all methods in a module - +// Promisify all methods in a module pify(fs).readFile('package.json', 'utf8').then(data => { console.log(JSON.parse(data).name); //=> 'pify' @@ -34,32 +32,24 @@ pify(fs).readFile('package.json', 'utf8').then(data => { ## API -### pify(input, [promiseModule], [options]) +### pify(input, [options]) -Returns a promise wrapped version of the supplied function or module. +Returns a `Promise` wrapped version of the supplied function or module. #### input -Type: `function`, `object` +Type: `Function` `Object` Callback-style function or module whose methods you want to promisify. -#### promiseModule - -Type: `function` - -Custom promise module to use instead of the native one. - -Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. - #### options ##### multiArgs -Type: `boolean` +Type: `boolean`
Default: `false` -By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. +By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. This also applies to rejections, where it returns an array of all the callback arguments, including the error. ```js const request = require('request'); @@ -72,23 +62,23 @@ pify(request, {multiArgs: true})('https://sindresorhus.com').then(result => { ##### include -Type: `array` of (`string`|`regex`) +Type: `string[]` `RegExp[]` Methods in a module to promisify. Remaining methods will be left untouched. ##### exclude -Type: `array` of (`string`|`regex`) -Default: `[/.+Sync$/]` +Type: `string[]` `RegExp[]`
+Default: `[/.+(Sync|Stream)$/]` Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default. ##### excludeMain -Type: `boolean` +Type: `boolean`
Default: `false` -By default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module. +If given module is a function itself, it will be promisified. Turn this option on if you want to promisify only methods of the module. ```js const pify = require('pify'); @@ -99,11 +89,11 @@ function fn() { fn.method = (data, callback) => { setImmediate(() => { - callback(data, null); + callback(null, data); }); }; -// promisify methods but not fn() +// Promisify methods but not `fn()` const promiseFn = pify(fn, {excludeMain: true}); if (promiseFn()) { @@ -113,7 +103,29 @@ if (promiseFn()) { } ``` +##### errorFirst + +Type: `boolean`
+Default: `true` + +Whether the callback has an error as the first argument. You'll want to set this to `false` if you're dealing with an API that doesn't have an error as the first argument, like `fs.exists()`, some browser APIs, Chrome Extension APIs, etc. + +##### promiseModule + +Type: `Function` + +Custom promise module to use instead of the native one. + +Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. + + +## Related + +- [p-event](https://github.com/sindresorhus/p-event) - Promisify an event by waiting for it to be emitted +- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently +- [More…](https://github.com/sindresorhus/promise-fun) + ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/decode.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/decode.js index 75116385eed36c..fd45b729d069e1 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/decode.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/decode.js @@ -1,13 +1,6 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:decode - * @fileoverview Decode entities. - */ - 'use strict'; +var xtend = require('xtend'); var entities = require('parse-entities'); module.exports = factory; @@ -62,10 +55,10 @@ function factory(ctx) { } /* Decode `value` (at `position`) into a string. */ - function decodeRaw(value, position) { - return entities(value, { + function decodeRaw(value, position, options) { + return entities(value, xtend(options, { position: normalize(position), warning: handleWarning - }); + })); } } diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/defaults.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/defaults.js index ccb3fabd485901..37846f3930a35a 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/defaults.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/defaults.js @@ -1,21 +1,10 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:defaults - * @fileoverview Default options for `parse`. - */ - 'use strict'; -/* Expose. */ module.exports = { position: true, gfm: true, - yaml: true, commonmark: false, footnotes: false, pedantic: false, - blocks: require('./block-elements'), - breaks: false + blocks: require('./block-elements.json') }; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/break.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/break.js index b5550e10076605..295bdc9855126e 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/break.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/break.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:break - * @fileoverview Locate a break. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/code-inline.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/code-inline.js index 010e74dcec4b00..981c81698254fe 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/code-inline.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/code-inline.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:code-inline - * @fileoverview Locate inline code. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/delete.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/delete.js index 1a892e1be7716e..d208aef2fff386 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/delete.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/delete.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:delete - * @fileoverview Locate strikethrough. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/emphasis.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/emphasis.js index 270daad0f9e00c..6a1f24227d05bb 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/emphasis.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/emphasis.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:emphasis - * @fileoverview Locate italics / emphasis. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/escape.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/escape.js index 45f9b449a7873c..f6c63715827ef3 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/escape.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/escape.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:escape - * @fileoverview Locate an escape. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/link.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/link.js index dab2a3c54f1774..0f16fd8016bd36 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/link.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/link.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:link - * @fileoverview Locate a link. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/strong.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/strong.js index 717259f36eae22..da1cac0a499f2e 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/strong.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/strong.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:strong - * @fileoverview Locate bold / strong / importance. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/tag.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/tag.js index 56e2d49e564587..3c5534268abe1d 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/tag.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/tag.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:tag - * @fileoverview Locate a tag. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/url.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/url.js index 53b239241c104a..59b63e2563693e 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/url.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/locate/url.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:locate:url - * @fileoverview Locate a URL. - */ - 'use strict'; module.exports = locate; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js index 53a50b181e67d4..5a8d8119556792 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/parse.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:parse - * @fileoverview Parse the document - */ - 'use strict'; var xtend = require('xtend'); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/parser.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/parser.js index 8fe982b661c41c..9291109f16f3ec 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/parser.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/parser.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse - * @fileoverview Markdown parser. - */ - 'use strict'; var xtend = require('xtend'); @@ -17,7 +9,6 @@ var tokenizer = require('./tokenizer'); module.exports = Parser; -/* Construct a new parser. */ function Parser(doc, file) { this.file = file; this.offset = {}; @@ -34,7 +25,6 @@ function Parser(doc, file) { this.decode = decode(this); } -/* Prototype. */ var proto = Parser.prototype; /* Expose core. */ @@ -80,6 +70,7 @@ proto.interruptParagraph = [ * In the above example, the thematic break “interupts” * the list. */ proto.interruptList = [ + ['atxHeading', {pedantic: false}], ['fencedCode', {pedantic: false}], ['thematicBreak', {pedantic: false}], ['definition', {commonmark: false}], @@ -109,7 +100,6 @@ proto.interruptBlockquote = [ /* Handlers. */ proto.blockTokenizers = { - yamlFrontMatter: require('./tokenize/yaml'), newline: require('./tokenize/newline'), indentedCode: require('./tokenize/code-indented'), fencedCode: require('./tokenize/code-fenced'), diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/set-options.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/set-options.js index 3f9abad7c49a06..c55f7f32f31def 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/set-options.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/set-options.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse - * @fileoverview Markdown parser. - */ - 'use strict'; var xtend = require('xtend'); @@ -14,7 +6,6 @@ var defaults = require('./defaults'); module.exports = setOptions; -/* Set options. */ function setOptions(options) { var self = this; var current = self.options; @@ -43,10 +34,7 @@ function setOptions(options) { (key !== 'blocks' && typeof value !== 'boolean') || (key === 'blocks' && typeof value !== 'object') ) { - throw new Error( - 'Invalid value `' + value + '` ' + - 'for setting `options.' + key + '`' - ); + throw new Error('Invalid value `' + value + '` for setting `options.' + key + '`'); } options[key] = value; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/auto-link.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/auto-link.js index 3861b48a14aead..c945a2c1f88f58 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/auto-link.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/auto-link.js @@ -1,13 +1,6 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:auto-link - * @fileoverview Tokenise an auto-link. - */ - 'use strict'; +var whitespace = require('is-whitespace-character'); var decode = require('parse-entities'); var locate = require('../locate/tag'); @@ -34,7 +27,7 @@ function autoLink(eat, value, silent) { var link; var now; var content; - var tokenize; + var tokenizers; var exit; if (value.charAt(0) !== C_LT) { @@ -56,7 +49,7 @@ function autoLink(eat, value, silent) { character = value.charAt(index); if ( - character === ' ' || + whitespace(character) || character === C_GT || character === C_AT_SIGN || (character === ':' && value.charAt(index + 1) === C_SLASH) @@ -96,7 +89,7 @@ function autoLink(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (character === ' ' || character === C_GT) { + if (whitespace(character) || character === C_GT) { break; } @@ -132,20 +125,21 @@ function autoLink(eat, value, silent) { } } - /* Temporarily remove support for escapes in autolinks. */ - tokenize = self.inlineTokenizers.escape; - self.inlineTokenizers.escape = null; + /* Temporarily remove all tokenizers except text in autolinks. */ + tokenizers = self.inlineTokenizers; + self.inlineTokenizers = {text: tokenizers.text}; + exit = self.enterLink(); content = self.tokenizeInline(content, now); - self.inlineTokenizers.escape = tokenize; + self.inlineTokenizers = tokenizers; exit(); return eat(subvalue)({ type: 'link', title: null, - url: decode(link), + url: decode(link, {nonTerminated: false}), children: content }); } diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/blockquote.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/blockquote.js index 764e0aa010392c..bd700d6a6c8276 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/blockquote.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/blockquote.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:blockquote - * @fileoverview Tokenise blockquote. - */ - 'use strict'; var trim = require('trim'); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/break.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/break.js index 6d2d0dcff9552b..eb531342bfebcb 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/break.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/break.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:break - * @fileoverview Tokenise a break. - */ - 'use strict'; var locate = require('../locate/break'); @@ -15,10 +7,7 @@ hardBreak.locator = locate; var MIN_BREAK_LENGTH = 2; -/* Tokenise a break. */ function hardBreak(eat, value, silent) { - var self = this; - var breaks = self.options.breaks; var length = value.length; var index = -1; var queue = ''; @@ -28,7 +17,7 @@ function hardBreak(eat, value, silent) { character = value.charAt(index); if (character === '\n') { - if (!breaks && index < MIN_BREAK_LENGTH) { + if (index < MIN_BREAK_LENGTH) { return; } diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-fenced.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-fenced.js index f2577405b26587..65f2bc73273ab3 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-fenced.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-fenced.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:code-fenced - * @fileoverview Tokenise fenced code. - */ - 'use strict'; var trim = require('trim-trailing-lines'); @@ -21,7 +13,6 @@ var C_TICK = '`'; var MIN_FENCE_COUNT = 3; var CODE_INDENT_COUNT = 4; -/* Tokenise fenced code. */ function fencedCode(eat, value, silent) { var self = this; var settings = self.options; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-indented.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-indented.js index 50c581fe26e2e4..c73849d9ad8bf2 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-indented.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-indented.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:code-indented - * @fileoverview Tokenise indented code. - */ - 'use strict'; var repeat = require('repeat-string'); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-inline.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-inline.js index 9157412753ad1a..c0a496b49255ba 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-inline.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/code-inline.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:code-inline - * @fileoverview Tokenise inline code. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/definition.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/definition.js index 3f7345a2c901c8..1cce274cfbdd71 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/definition.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/definition.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:definition - * @fileoverview Tokenise a definition. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); @@ -29,7 +21,6 @@ var C_COLON = ':'; var C_LT = '<'; var C_GT = '>'; -/* Tokenise a definition. */ function definition(eat, value, silent) { var self = this; var commonmark = self.options.commonmark; @@ -254,7 +245,7 @@ function definition(eat, value, silent) { } beforeURL = eat(beforeURL).test().end; - url = self.decode.raw(self.unescape(url), beforeURL); + url = self.decode.raw(self.unescape(url), beforeURL, {nonTerminated: false}); if (title) { beforeTitle = eat(beforeTitle).test().end; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/delete.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/delete.js index 60ae9c4936c61f..ca7c68a8c5c1be 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/delete.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/delete.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:delete - * @fileoverview Tokenise strikethrough. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); @@ -17,7 +9,6 @@ strikethrough.locator = locate; var C_TILDE = '~'; var DOUBLE = '~~'; -/* Tokenise strikethrough. */ function strikethrough(eat, value, silent) { var self = this; var character = ''; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/emphasis.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/emphasis.js index 46249369224bc5..b2c87b4497de38 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/emphasis.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/emphasis.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:emphasis - * @fileoverview Tokenise emphasis. - */ - 'use strict'; var trim = require('trim'); @@ -19,7 +11,6 @@ emphasis.locator = locate; var C_ASTERISK = '*'; var C_UNDERSCORE = '_'; -/* Tokenise emphasis. */ function emphasis(eat, value, silent) { var self = this; var index = 0; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/escape.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/escape.js index 3e41a4cec5e6ea..d6f99bcc10381d 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/escape.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/escape.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:escape - * @fileoverview Tokenise an escape. - */ - 'use strict'; var locate = require('../locate/escape'); @@ -13,7 +5,6 @@ var locate = require('../locate/escape'); module.exports = escape; escape.locator = locate; -/* Tokenise an escape. */ function escape(eat, value, silent) { var self = this; var character; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/footnote-definition.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/footnote-definition.js index 3537ccb6115017..f48ff9bb7eb187 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/footnote-definition.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/footnote-definition.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:footnote-definition - * @fileoverview Tokenise footnote definition. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); @@ -26,7 +18,6 @@ var C_COLON = ':'; var EXPRESSION_INITIAL_TAB = /^( {4}|\t)?/gm; -/* Tokenise a footnote definition. */ function footnoteDefinition(eat, value, silent) { var self = this; var offsets = self.offset; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js index e5fdedc537ad0b..aafeabb54910f6 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-atx.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:heading-atx - * @fileoverview Tokenise an ATX-style heading. - */ - 'use strict'; module.exports = atxHeading; @@ -17,7 +9,6 @@ var C_HASH = '#'; var MAX_ATX_COUNT = 6; -/* Tokenise an ATX-style heading. */ function atxHeading(eat, value, silent) { var self = this; var settings = self.options; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-setext.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-setext.js index db8bbcfb73c2c9..96c6130da744e1 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-setext.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/heading-setext.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:heading-setext - * @fileoverview Tokenise an setext-style heading. - */ - 'use strict'; module.exports = setextHeading; @@ -25,7 +17,6 @@ var SETEXT_MARKERS = {}; SETEXT_MARKERS[C_EQUALS] = 1; SETEXT_MARKERS[C_DASH] = 2; -/* Tokenise an setext-style heading. */ function setextHeading(eat, value, silent) { var self = this; var now = eat.now(); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-block.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-block.js index dc861b53c3a37b..6e81eb290a3993 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-block.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-block.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:html-block - * @fileoverview Tokenise block HTML. - */ - 'use strict'; var openCloseTag = require('../util/html').openCloseTag; @@ -17,7 +9,6 @@ var C_SPACE = ' '; var C_NEWLINE = '\n'; var C_LT = '<'; -/* Tokenise block HTML. */ function blockHTML(eat, value, silent) { var self = this; var blocks = self.options.blocks; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-inline.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-inline.js index d8c0b9ab21829a..c204e962b15ae8 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-inline.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/html-inline.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:html-inline - * @fileoverview Tokenise inline HTML. - */ - 'use strict'; var alphabetical = require('is-alphabetical'); @@ -18,7 +10,6 @@ inlineHTML.locator = locate; var EXPRESSION_HTML_LINK_OPEN = /^/i; -/* Tokenise inline HTML. */ function inlineHTML(eat, value, silent) { var self = this; var length = value.length; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/link.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/link.js index fb11c5099054df..3ef5e1ba312d75 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/link.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/link.js @@ -1,20 +1,13 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:link - * @fileoverview Tokenise a link. - */ - 'use strict'; -var has = require('has'); var whitespace = require('is-whitespace-character'); var locate = require('../locate/link'); module.exports = link; link.locator = locate; +var own = {}.hasOwnProperty; + var C_BACKSLASH = '\\'; var C_BRACKET_OPEN = '['; var C_BRACKET_CLOSE = ']'; @@ -41,12 +34,12 @@ COMMONMARK_LINK_MARKERS[C_DOUBLE_QUOTE] = C_DOUBLE_QUOTE; COMMONMARK_LINK_MARKERS[C_SINGLE_QUOTE] = C_SINGLE_QUOTE; COMMONMARK_LINK_MARKERS[C_PAREN_OPEN] = C_PAREN_CLOSE; -/* Tokenise a link. */ function link(eat, value, silent) { var self = this; var subvalue = ''; var index = 0; var character = value.charAt(0); + var pedantic = self.options.pedantic; var commonmark = self.options.commonmark; var gfm = self.options.gfm; var closed; @@ -134,7 +127,7 @@ function link(eat, value, silent) { } else { /* Allow white-space between content and * url in GFM mode. */ - if (gfm) { + if (!pedantic) { while (index < length) { character = value.charAt(index + 1); @@ -224,12 +217,12 @@ function link(eat, value, silent) { while (index < length) { character = value.charAt(index); - if (subqueue && has(markers, character)) { + if (subqueue && own.call(markers, character)) { break; } if (whitespace(character)) { - if (commonmark) { + if (!pedantic) { break; } @@ -282,7 +275,7 @@ function link(eat, value, silent) { subvalue += queue; /* Eat the title. */ - if (queue && has(markers, character)) { + if (queue && own.call(markers, character)) { index++; subvalue += character; queue = ''; @@ -374,7 +367,7 @@ function link(eat, value, silent) { subvalue += C_PAREN_CLOSE; - url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end); + url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end, {nonTerminated: false}); if (title) { beforeTitle = eat(beforeTitle).test().end; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/list.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/list.js index da8002e574196c..9164c8167f8dc1 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/list.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/list.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:list - * @fileoverview Tokenise a list. - */ - 'use strict'; /* eslint-disable max-params */ @@ -58,7 +50,6 @@ var LIST_ORDERED_COMMONMARK_MARKERS = {}; LIST_ORDERED_COMMONMARK_MARKERS[C_DOT] = true; LIST_ORDERED_COMMONMARK_MARKERS[C_PAREN_CLOSE] = true; -/* Tokenise a list. */ function list(eat, value, silent) { var self = this; var commonmark = self.options.commonmark; @@ -371,17 +362,6 @@ function list(eat, value, silent) { return node; } -/** - * Create a list-item node. - * - * @example - * listItem('- _foo_', now()); - * - * @param {Object} ctx - Parser. - * @param {Object} value - List-item. - * @param {Object} position - List-item location. - * @return {Object} - `listItem` node. - */ function listItem(ctx, value, position) { var offsets = ctx.offset; var fn = ctx.options.pedantic ? pedanticListItem : normalListItem; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/newline.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/newline.js index f710e0ef976603..6008670cc5e742 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/newline.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/newline.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:newline - * @fileoverview Tokenise a newline. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/paragraph.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/paragraph.js index 7d064522ffecbd..1492a027e78237 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/paragraph.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/paragraph.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:paragraph - * @fileoverview Tokenise a paragraph. - */ - 'use strict'; var trim = require('trim'); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/reference.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/reference.js index 1fa150d9e6b958..50713f1ccfc8fa 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/reference.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/reference.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:reference - * @fileoverview Tokenise a reference. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); @@ -26,7 +18,6 @@ var C_BACKSLASH = '\\'; var C_BRACKET_OPEN = '['; var C_BRACKET_CLOSE = ']'; -/* Tokenise a reference. */ function reference(eat, value, silent) { var self = this; var character = value.charAt(0); @@ -61,11 +52,13 @@ function reference(eat, value, silent) { queue = ''; /* Check whether we’re eating a footnote. */ - if ( - self.options.footnotes && - type === T_LINK && - value.charAt(index) === C_CARET - ) { + if (self.options.footnotes && value.charAt(index) === C_CARET) { + /* Exit if `![^` is found, so the `!` will be seen as text after this, + * and we’ll enter this function again when `[^` is found. */ + if (type === T_IMAGE) { + return; + } + intro += C_CARET; index++; type = T_FOOTNOTE; @@ -122,7 +115,8 @@ function reference(eat, value, silent) { character = value.charAt(index); - if (character === C_BRACKET_OPEN) { + /* Inline footnotes cannot have an identifier. */ + if (type !== T_FOOTNOTE && character === C_BRACKET_OPEN) { identifier = ''; queue += character; index++; @@ -168,13 +162,6 @@ function reference(eat, value, silent) { return; } - /* Inline footnotes cannot have an identifier. */ - if (type === T_FOOTNOTE && referenceType !== REFERENCE_TYPE_SHORTCUT) { - type = T_LINK; - intro = C_BRACKET_OPEN + C_CARET; - content = C_CARET + content; - } - subvalue = intro + subvalue; if (type === T_LINK && self.inLink) { diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/strong.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/strong.js index 765993fa0bd4b3..12d5785bc64a74 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/strong.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/strong.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:strong - * @fileoverview Tokenise strong. - */ - 'use strict'; var trim = require('trim'); @@ -18,7 +10,6 @@ strong.locator = locate; var C_ASTERISK = '*'; var C_UNDERSCORE = '_'; -/* Tokenise strong. */ function strong(eat, value, silent) { var self = this; var index = 0; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/table.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/table.js index c440067e1011d7..ce93b1d22f0f31 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/table.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/table.js @@ -1,17 +1,8 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:table - * @fileoverview Tokenise a table. - */ - 'use strict'; var whitespace = require('is-whitespace-character'); module.exports = table; -table.notInList = true; var C_BACKSLASH = '\\'; var C_TICK = '`'; @@ -30,7 +21,6 @@ var TABLE_ALIGN_CENTER = 'center'; var TABLE_ALIGN_RIGHT = 'right'; var TABLE_ALIGN_NONE = null; -/* Tokenise a table. */ function table(eat, value, silent) { var self = this; var index; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/text.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/text.js index ef6d3f2879d46e..4aedfa90d5d9b8 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/text.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/text.js @@ -1,16 +1,7 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:text - * @fileoverview Tokenise text. - */ - 'use strict'; module.exports = text; -/* Tokenise text. */ function text(eat, value, silent) { var self = this; var methods; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/thematic-break.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/thematic-break.js index a580d09fe09c0b..2391e3f592cb25 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/thematic-break.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/thematic-break.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:thematic-break - * @fileoverview Tokenise a thematic break. - */ - 'use strict'; module.exports = thematicBreak; @@ -19,7 +11,6 @@ var C_DASH = '-'; var THEMATIC_BREAK_MARKER_COUNT = 3; -/* Tokenise a thematic break. */ function thematicBreak(eat, value, silent) { var index = -1; var length = value.length + 1; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/url.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/url.js index fd2debd32f35fe..297940bf4ab922 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/url.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/url.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:url - * @fileoverview Tokenise a URL. - */ - 'use strict'; var decode = require('parse-entities'); @@ -35,7 +27,6 @@ var PROTOCOLS = [ var PROTOCOLS_LENGTH = PROTOCOLS.length; -/* Tokenise a URL. */ function url(eat, value, silent) { var self = this; var subvalue; @@ -147,7 +138,7 @@ function url(eat, value, silent) { return eat(subvalue)({ type: 'link', title: null, - url: decode(subvalue), + url: decode(subvalue, {nonTerminated: false}), children: content }); } diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/yaml.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/yaml.js deleted file mode 100644 index 78dec31a0f9eb8..00000000000000 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenize/yaml.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenize:yaml - * @fileoverview Tokenise YAML. - */ - -'use strict'; - -module.exports = yaml; -yaml.onlyAtStart = true; - -var FENCE = '---'; -var C_DASH = '-'; -var C_NEWLINE = '\n'; - -/* Tokenise YAML. */ -function yaml(eat, value, silent) { - var self = this; - var subvalue; - var content; - var index; - var length; - var character; - var queue; - - if ( - !self.options.yaml || - value.charAt(0) !== C_DASH || - value.charAt(1) !== C_DASH || - value.charAt(2) !== C_DASH || - value.charAt(3) !== C_NEWLINE - ) { - return; - } - - subvalue = FENCE + C_NEWLINE; - content = ''; - queue = ''; - index = 3; - length = value.length; - - while (++index < length) { - character = value.charAt(index); - - if ( - character === C_DASH && - (queue || !content) && - value.charAt(index + 1) === C_DASH && - value.charAt(index + 2) === C_DASH - ) { - /* istanbul ignore if - never used (yet) */ - if (silent) { - return true; - } - - subvalue += queue + FENCE; - - return eat(subvalue)({ - type: 'yaml', - value: content - }); - } - - if (character === C_NEWLINE) { - queue += character; - } else { - subvalue += queue + character; - content += queue + character; - queue = ''; - } - } -} diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenizer.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenizer.js index aefe551fc37993..498ef22ad949af 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenizer.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/tokenizer.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:tokenizer - * @fileoverview Markdown tokenizer. - */ - 'use strict'; module.exports = factory; @@ -101,7 +93,7 @@ function factory(type) { if ( method && - (!method.onlyAtStart || self.atStart) && + /* istanbul ignore next */ (!method.onlyAtStart || self.atStart) && (!method.notInList || !self.inList) && (!method.notInBlock || !self.inBlock) && (!method.notInLink || !self.inLink) @@ -128,15 +120,8 @@ function factory(type) { return tokens; - /** - * Update line, column, and offset based on - * `value`. - * - * @example - * updatePosition('foo'); - * - * @param {string} subvalue - Subvalue to eat. - */ + /* Update line, column, and offset based on + * `value`. */ function updatePosition(subvalue) { var lastIndex = -1; var index = subvalue.indexOf('\n'); @@ -162,23 +147,14 @@ function factory(type) { } } - /** - * Get offset. Called before the first character is - * eaten to retrieve the range's offsets. - * - * @return {Function} - `done`, to be called when - * the last character is eaten. - */ + /* Get offset. Called before the first character is + * eaten to retrieve the range's offsets. */ function getOffset() { var indentation = []; var pos = line + 1; - /** - * Done. Called when the last character is - * eaten to retrieve the range’s offsets. - * - * @return {Array.} - Offset. - */ + /* Done. Called when the last character is + * eaten to retrieve the range’s offsets. */ return function () { var last = line + 1; @@ -192,14 +168,7 @@ function factory(type) { }; } - /** - * Get the current position. - * - * @example - * position = now(); // {line: 1, column: 1, offset: 0} - * - * @return {Object} - Current Position. - */ + /* Get the current position. */ function now() { var pos = {line: line, column: column}; @@ -208,41 +177,15 @@ function factory(type) { return pos; } - /** - * Store position information for a node. - * - * @example - * start = now(); - * updatePosition('foo'); - * location = new Position(start); - * // { - * // start: {line: 1, column: 1, offset: 0}, - * // end: {line: 1, column: 3, offset: 2} - * // } - * - * @param {Object} start - Starting position. - */ + /* Store position information for a node. */ function Position(start) { this.start = start; this.end = now(); } - /** - * Throw when a value is incorrectly eaten. + /* Throw when a value is incorrectly eaten. * This shouldn’t happen but will throw on new, - * incorrect rules. - * - * @example - * // When the current value is set to `foo bar`. - * validateEat('foo'); - * eat('foo'); - * - * validateEat('bar'); - * // throws, because the space is not eaten. - * - * @param {string} subvalue - Value to be eaten. - * @throws {Error} - When `subvalue` cannot be eaten. - */ + * incorrect rules. */ function validateEat(subvalue) { /* istanbul ignore if */ if (value.substring(0, subvalue.length) !== subvalue) { @@ -257,39 +200,13 @@ function factory(type) { } } - /** - * Mark position and patch `node.position`. - * - * @example - * var update = position(); - * updatePosition('foo'); - * update({}); - * // { - * // position: { - * // start: {line: 1, column: 1, offset: 0}, - * // end: {line: 1, column: 3, offset: 2} - * // } - * // } - * - * @returns {Function} - Updater. - */ + /* Mark position and patch `node.position`. */ function position() { var before = now(); return update; - /** - * Add the position to a node. - * - * @example - * update({type: 'text', value: 'foo'}); - * - * @param {Node} node - Node to attach position - * on. - * @param {Array} [indent] - Indentation for - * `node`. - * @return {Node} - `node`. - */ + /* Add the position to a node. */ function update(node, indent) { var prev = node.position; var start = prev ? prev.start : before; @@ -327,19 +244,8 @@ function factory(type) { } } - /** - * Add `node` to `parent`s children or to `tokens`. - * Performs merges where possible. - * - * @example - * add({}); - * - * add({}, {children: []}); - * - * @param {Object} node - Node to add. - * @param {Object} [parent] - Parent to insert into. - * @return {Object} - Added or merged into node. - */ + /* Add `node` to `parent`s children or to `tokens`. + * Performs merges where possible. */ function add(node, parent) { var children = parent ? parent.children : tokens; var prev = children[children.length - 1]; @@ -365,18 +271,8 @@ function factory(type) { return node; } - /** - * Remove `subvalue` from `value`. - * `subvalue` must be at the start of `value`. - * - * @example - * eat('foo')({type: 'text', value: 'foo'}); - * - * @param {string} subvalue - Removed from `value`, - * and passed to `updatePosition`. - * @return {Function} - Wrapper around `add`, which - * also adds `position` to node. - */ + /* Remove `subvalue` from `value`. + * `subvalue` must be at the start of `value`. */ function eat(subvalue) { var indent = getOffset(); var pos = position(); @@ -396,31 +292,19 @@ function factory(type) { return apply; - /** - * Add the given arguments, add `position` to - * the returned node, and return the node. - * - * @param {Object} node - Node to add. - * @param {Object} [parent] - Node to insert into. - * @return {Node} - Added node. - */ + /* Add the given arguments, add `position` to + * the returned node, and return the node. */ function apply(node, parent) { return pos(add(pos(node), parent), indent); } - /** - * Functions just like apply, but resets the + /* Functions just like apply, but resets the * content: the line and column are reversed, * and the eaten value is re-added. - * * This is useful for nodes with a single * type of content, such as lists and tables. - * * See `apply` above for what parameters are - * expected. - * - * @return {Node} - Added node. - */ + * expected. */ function reset() { var node = apply.apply(null, arguments); @@ -431,12 +315,8 @@ function factory(type) { return node; } - /** - * Test the position, after eating, and reverse - * to a not-eaten state. - * - * @return {Position} - Position after eating `subvalue`. - */ + /* Test the position, after eating, and reverse + * to a not-eaten state. */ function test() { var result = pos({}); diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/unescape.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/unescape.js index dc83486126112c..321900e7eacd73 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/unescape.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/unescape.js @@ -1,14 +1,5 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:unescape - * @fileoverview Unescape escapes. - */ - 'use strict'; -/* Expose. */ module.exports = factory; /* Factory to de-escape a value, based on a list at `key` diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/get-indentation.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/get-indentation.js index eebd40c94ac26b..3e09e1411ed67c 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/get-indentation.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/get-indentation.js @@ -1,26 +1,12 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:util:get-indentation - * @fileoverview Get indentation. - */ - 'use strict'; -/* Expose. */ module.exports = indentation; /* Map of characters, and their column length, * which can be used as indentation. */ var characters = {' ': 1, '\t': 4}; -/** - * Gets indentation information for a line. - * - * @param {string} value - Indented line. - * @return {Object} - Indetation information. - */ +/* Gets indentation information for a line. */ function indentation(value) { var index = 0; var indent = 0; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/html.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/html.js index 234ba342e1d3fa..5f211f13f8f534 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/html.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/html.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:util:html - * @fileoverview HTML regexes. - */ - 'use strict'; var attributeName = '[a-zA-Z_:][a-zA-Z0-9:._-]*'; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/interrupt.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/interrupt.js index b8dc2305501db1..e3178ab45c60df 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/interrupt.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/interrupt.js @@ -1,11 +1,3 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:util:get-indentation - * @fileoverview Get indentation. - */ - 'use strict'; module.exports = interrupt; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/normalize.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/normalize.js index 3602a18f788317..846ceeecac5ade 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/normalize.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/normalize.js @@ -1,29 +1,11 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:util:normalize - * @fileoverview Normalize an identifier. - */ - 'use strict'; -/* Dependencies. */ var collapseWhiteSpace = require('collapse-white-space'); -/* Expose. */ module.exports = normalize; -/** - * Normalize an identifier. Collapses multiple white space - * characters into a single space, and removes casing. - * - * @example - * normalizeIdentifier('FOO\t bar'); // 'foo bar' - * - * @param {string} value - Content to normalize. - * @return {string} - Normalized content. - */ +/* Normalize an identifier. Collapses multiple white space + * characters into a single space, and removes casing. */ function normalize(value) { return collapseWhiteSpace(value).toLowerCase(); } diff --git a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/remove-indentation.js b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/remove-indentation.js index d56db0bad4b735..20f18be74087eb 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/lib/util/remove-indentation.js +++ b/tools/node_modules/eslint/node_modules/remark-parse/lib/util/remove-indentation.js @@ -1,42 +1,18 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module remark:parse:util:remove-indentation - * @fileoverview Remove indentation. - */ - 'use strict'; -/* Dependencies. */ var trim = require('trim'); var repeat = require('repeat-string'); var getIndent = require('./get-indentation'); -/* Expose. */ module.exports = indentation; -/* Characters. */ var C_SPACE = ' '; var C_NEWLINE = '\n'; var C_TAB = '\t'; -/** - * Remove the minimum indent from every line in `value`. +/* Remove the minimum indent from every line in `value`. * Supports both tab, spaced, and mixed indentation (as - * well as possible). - * - * @example - * removeIndentation(' foo'); // 'foo' - * removeIndentation(' foo', 2); // ' foo' - * removeIndentation('\tfoo', 2); // ' foo' - * removeIndentation(' foo\n bar'); // ' foo\n bar' - * - * @param {string} value - Value to trim. - * @param {number?} [maximum] - Maximum indentation - * to remove. - * @return {string} - Unindented `value`. - */ + * well as possible). */ function indentation(value, maximum) { var values = value.split(C_NEWLINE); var position = values.length + 1; diff --git a/tools/node_modules/eslint/node_modules/remark-parse/package.json b/tools/node_modules/eslint/node_modules/remark-parse/package.json index fcecf978cd74e0..b47866c95b256b 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/package.json +++ b/tools/node_modules/eslint/node_modules/remark-parse/package.json @@ -5,7 +5,7 @@ "url": "http://wooorm.com" }, "bugs": { - "url": "https://github.com/wooorm/remark/issues" + "url": "https://github.com/remarkjs/remark/issues" }, "bundleDependencies": false, "contributors": [ @@ -21,13 +21,12 @@ ], "dependencies": { "collapse-white-space": "^1.0.2", - "has": "^1.0.1", "is-alphabetical": "^1.0.0", "is-decimal": "^1.0.0", "is-whitespace-character": "^1.0.0", "is-word-character": "^1.0.0", "markdown-escapes": "^1.0.0", - "parse-entities": "^1.0.2", + "parse-entities": "^1.1.0", "repeat-string": "^1.5.4", "state-toggle": "^1.0.0", "trim": "0.0.1", @@ -56,8 +55,8 @@ "name": "remark-parse", "repository": { "type": "git", - "url": "https://github.com/wooorm/remark/tree/master/packages/remark-parse" + "url": "https://github.com/remarkjs/remark/tree/master/packages/remark-parse" }, - "version": "3.0.1", + "version": "5.0.0", "xo": false } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/remark-parse/readme.md b/tools/node_modules/eslint/node_modules/remark-parse/readme.md index 53426f41eee224..ecaa6c093c0ab2 100644 --- a/tools/node_modules/eslint/node_modules/remark-parse/readme.md +++ b/tools/node_modules/eslint/node_modules/remark-parse/readme.md @@ -33,7 +33,7 @@ process.stdin ## Table of Contents * [API](#api) - * [processor.use(parse)](#processoruseparse) + * [processor.use(parse\[, options\])](#processoruseparse-options) * [parse.Parser](#parseparser) * [Extending the Parser](#extending-the-parser) * [Parser#blockTokenizers](#parserblocktokenizers) @@ -46,29 +46,19 @@ process.stdin * [add(node\[, parent\])](#addnode-parent) * [add.test()](#addtest) * [add.reset(node\[, parent\])](#addresetnode-parent) + * [Turning off a tokenizer](#turning-off-a-tokenizer) * [License](#license) ## API -### `processor.use(parse)` +### `processor.use(parse[, options])` Configure the `processor` to read markdown as input and process an [**MDAST**][mdast] syntax tree. -#### `options` +##### `options` -Options are passed later through [`processor.parse()`][parse], -[`processor.process()`][process], or [`processor.pipe()`][pipe]. -The following settings are supported: - -* [`gfm`][options-gfm] (`boolean`, default: `true`) -* [`yaml`][options-yaml] (`boolean`, default: `true`) -* [`commonmark`][options-commonmark] (`boolean`, default: `false`) -* [`footnotes`][options-footnotes] (`boolean`, default: `false`) -* [`pedantic`][options-pedantic] (`boolean`, default: `false`) -* [`breaks`][options-breaks] (`boolean`, default: `false`) -* [`blocks`][options-blocks] (`Array.`, default: list of block HTML - elements) +Options are passed directly, or passed later through [`processor.data()`][data]. ##### `options.gfm` @@ -76,7 +66,7 @@ The following settings are supported: hello ~~hi~~ world ``` -GFM mode (default: `true`) turns on: +GFM mode (`boolean`, default: `true`) turns on: * [Fenced code blocks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) * [Autolinking of URLs](https://help.github.com/articles/github-flavored-markdown/#url-autolinking) @@ -84,19 +74,6 @@ GFM mode (default: `true`) turns on: * [Task lists](https://help.github.com/articles/writing-on-github/#task-lists) * [Tables](https://help.github.com/articles/github-flavored-markdown/#tables) -##### `options.yaml` - -```md ---- -title: YAML is Cool ---- - -# YAML is Cool -``` - -YAML mode (default: `true`) enables raw YAML front matter to be detected -at the top. - ##### `options.commonmark` ```md @@ -104,7 +81,7 @@ This is a paragraph and this is also part of the preceding paragraph. ``` -CommonMark mode (default: `false`) allows: +CommonMark mode (`boolean`, default: `false`) allows: * Empty lines to split blockquotes * Parentheses (`(` and `)`) around for link and image titles @@ -136,20 +113,10 @@ And something else[^1]. * ...and a list ``` -Footnotes mode (default: `false`) enables reference footnotes and inline -footnotes. Both are wrapped in square brackets and preceded by a caret +Footnotes mode (`boolean`, default: `false`) enables reference footnotes and +inline footnotes. Both are wrapped in square brackets and preceded by a caret (`^`), and can be referenced from inside other footnotes. -##### `options.breaks` - -```md -This is a -paragraph. -``` - -Breaks mode (default: `false`) exposes newline characters inside -paragraphs as breaks. - ##### `options.blocks` ```md @@ -157,8 +124,8 @@ paragraphs as breaks. ``` -Blocks (default: a list of HTML block elements) exposes -let’s users define block-level HTML elements. +Blocks (`Array.`, default: list of [block HTML elements][blocks]) +exposes let’s users define block-level HTML elements. ##### `options.pedantic` @@ -166,7 +133,7 @@ let’s users define block-level HTML elements. Check out some_file_name.txt ``` -Pedantic mode (default: `false`) turns on: +Pedantic mode (`boolean`, default: `false`) turns on: * Emphasis (`_alpha_`) and importance (`__bravo__`) with underscores in words @@ -187,11 +154,11 @@ the desired output. Sometimes, mainly when introducing new syntactic entities with a certain level of precedence, interfacing with the parser is necessary. -If this plug-in is used, it adds a [`Parser`][parser] constructor to -the `processor`. Other plug-ins can add tokenizers to the parser’s -prototype to change how markdown is parsed. +If the `remark-parse` plugin is used, it adds a [`Parser`][parser] constructor +to the `processor`. Other plugins can add tokenizers to the parser’s prototype +to change how markdown is parsed. -The below plug-in adds a [tokenizer][] for at-mentions. +The below plugin adds a [tokenizer][] for at-mentions. ```js module.exports = mentions; @@ -215,22 +182,63 @@ An object mapping tokenizer names to [tokenizer][]s. These tokenizers (for example: `fencedCode`, `table`, and `paragraph`) eat from the start of a value to a line ending. +See `#blockMethods` below for a list of methods that are included by +default. + ### `Parser#blockMethods` Array of `blockTokenizers` names (`string`) specifying the order in which they run. + + +* `newline` +* `indentedCode` +* `fencedCode` +* `blockquote` +* `atxHeading` +* `thematicBreak` +* `list` +* `setextHeading` +* `html` +* `footnote` +* `definition` +* `table` +* `paragraph` + + + ### `Parser#inlineTokenizers` An object mapping tokenizer names to [tokenizer][]s. These tokenizers (for example: `url`, `reference`, and `emphasis`) eat from the start of a value. To increase performance, they depend on [locator][]s. +See `#inlineMethods` below for a list of methods that are included by +default. + ### `Parser#inlineMethods` Array of `inlineTokenizers` names (`string`) specifying the order in which they run. + + +* `escape` +* `autoLink` +* `url` +* `html` +* `link` +* `reference` +* `strong` +* `emphasis` +* `deletion` +* `code` +* `break` +* `text` + + + ### `function tokenizer(eat, value, silent)` ```js @@ -379,63 +387,58 @@ for list items The given `node`. +### Turning off a tokenizer + +In rare situations, you may want to turn off a tokenizer to avoid parsing +that syntactic feature. This can be done by deleting the tokenizer from +your Parser’s `blockTokenizers` (or `blockMethods`) or `inlineTokenizers` +(or `inlineMethods`). + +The following example turns off indented code blocks: + +```js +delete remarkParse.Parser.prototype.blockTokenizers.indentedCode; +``` + ## License [MIT][license] © [Titus Wormer][author] -[build-badge]: https://img.shields.io/travis/wooorm/remark.svg +[build-badge]: https://img.shields.io/travis/remarkjs/remark.svg -[build-status]: https://travis-ci.org/wooorm/remark +[build-status]: https://travis-ci.org/remarkjs/remark -[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/remark.svg +[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark.svg -[coverage-status]: https://codecov.io/github/wooorm/remark +[coverage-status]: https://codecov.io/github/remarkjs/remark -[chat-badge]: https://img.shields.io/gitter/room/wooorm/remark.svg +[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg -[chat]: https://gitter.im/wooorm/remark +[chat]: https://gitter.im/remarkjs/Lobby -[license]: https://github.com/wooorm/remark/blob/master/LICENSE +[license]: https://github.com/remarkjs/remark/blob/master/LICENSE [author]: http://wooorm.com [npm]: https://docs.npmjs.com/cli/install -[unified]: https://github.com/wooorm/unified - -[parse]: https://github.com/wooorm/unified#processorparsefilevalue-options +[unified]: https://github.com/unifiedjs/unified -[process]: https://github.com/wooorm/unified#processorprocessfilevalue-options-done +[data]: https://github.com/unifiedjs/unified#processordatakey-value -[pipe]: https://github.com/wooorm/unified#processorpipestream-options +[processor]: https://github.com/unifiedjs/remark/blob/master/packages/remark -[processor]: https://github.com/wooorm/remark/blob/master/packages/remark - -[mdast]: https://github.com/wooorm/mdast +[mdast]: https://github.com/syntax-tree/mdast [escapes]: http://spec.commonmark.org/0.25/#backslash-escapes -[node]: https://github.com/wooorm/unist#node - -[location]: https://github.com/wooorm/unist#location - -[options-gfm]: #optionsgfm - -[options-yaml]: #optionsyaml - -[options-commonmark]: #optionscommonmark +[node]: https://github.com/syntax-tree/unist#node -[options-footnotes]: #optionsfootnotes +[location]: https://github.com/syntax-tree/unist#location -[options-pedantic]: #optionspedantic - -[options-breaks]: #optionsbreaks - -[options-blocks]: #optionsblocks - -[parser]: https://github.com/wooorm/unified#processorparser +[parser]: https://github.com/unifiedjs/unified#processorparser [extend]: #extending-the-parser @@ -446,3 +449,5 @@ The given `node`. [eat]: #eatsubvalue [add]: #addnode-parent + +[blocks]: https://github.com/remarkjs/remark/blob/master/packages/remark-parse/lib/block-elements.json diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 7b47dbd691f1ce..f35659fc8a1c23 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -17,7 +17,7 @@ "cross-spawn": "^6.0.5", "debug": "^4.0.1", "doctrine": "^2.1.0", - "eslint-plugin-markdown": "^1.0.0-beta.8", + "eslint-plugin-markdown": "^1.0.0-rc.1", "eslint-scope": "^4.0.0", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", @@ -66,8 +66,8 @@ "coveralls": "^3.0.1", "dateformat": "^3.0.3", "ejs": "^2.6.1", - "eslint-plugin-eslint-plugin": "^1.2.0", - "eslint-plugin-node": "^7.0.1", + "eslint-plugin-eslint-plugin": "^1.4.1", + "eslint-plugin-node": "^8.0.0", "eslint-plugin-rulesdir": "^0.1.0", "eslint-release": "^1.0.0", "eslint-rule-composer": "^0.3.0", @@ -135,5 +135,5 @@ "publish-release": "node Makefile.js publishRelease", "test": "node Makefile.js test" }, - "version": "5.8.0" + "version": "5.9.0" } \ No newline at end of file diff --git a/tools/test.py b/tools/test.py index cd361196653043..67b8cb917e0db6 100755 --- a/tools/test.py +++ b/tools/test.py @@ -907,6 +907,7 @@ def __init__(self, workspace, buildspace, verbose, vm, args, expect_fail, self.repeat = repeat self.abort_on_timeout = abort_on_timeout self.v8_enable_inspector = True + self.node_has_crypto = True def GetVm(self, arch, mode): if arch == 'none': @@ -1498,6 +1499,7 @@ def PrintCrashed(code): IGNORED_SUITES = [ 'addons', 'addons-napi', + 'benchmark', 'doctool', 'internet', 'pummel', @@ -1631,9 +1633,14 @@ def Main(): # We want to skip the inspector tests if node was built without the inspector. has_inspector = Execute([vm, - "-p", "process.config.variables.v8_enable_inspector"], context) - if has_inspector.stdout.rstrip() == "0": - context.v8_enable_inspector = False + '-p', 'process.config.variables.v8_enable_inspector'], context) + if has_inspector.stdout.rstrip() == '0': + context.v8_enable_inspector = False + + has_crypto = Execute([vm, + '-p', 'process.versions.openssl'], context) + if has_crypto.stdout.rstrip() == 'undefined': + context.node_has_crypto = False if options.cat: visited = set() diff --git a/vcbuild.bat b/vcbuild.bat index 8627dcb296fba7..81dd6087882d32 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -85,6 +85,7 @@ if /i "%1"=="build-addons" set build_addons=1&goto arg-ok if /i "%1"=="build-addons-napi" set build_addons_napi=1&goto arg-ok if /i "%1"=="test-addons" set test_args=%test_args% addons&set build_addons=1&goto arg-ok if /i "%1"=="test-addons-napi" set test_args=%test_args% addons-napi&set build_addons_napi=1&goto arg-ok +if /i "%1"=="test-benchmark" set test_args=%test_args% benchmark&goto arg-ok if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok if /i "%1"=="test-tick-processor" set test_args=%test_args% tick-processor&goto arg-ok @@ -632,7 +633,7 @@ del .used_configure_flags goto exit :help -echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [ltcg] [nopch] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm] +echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-benchmark/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [ltcg] [nopch] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm] echo Examples: echo vcbuild.bat : builds release build echo vcbuild.bat debug : builds debug build