diff --git a/.eslintrc.js b/.eslintrc.js index 14c53277a19a47..8279dfc9c4ab41 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -59,7 +59,7 @@ module.exports = { ], rules: { // ESLint built-in rules - // http://eslint.org/docs/rules + // https://eslint.org/docs/rules/ 'accessor-pairs': 'error', 'array-callback-return': 'error', 'arrow-parens': ['error', 'always'], @@ -129,6 +129,7 @@ module.exports = { 'no-dupe-else-if': 'error', 'no-duplicate-case': 'error', 'no-duplicate-imports': 'error', + 'no-else-return': ['error', { allowElseIf: true }], 'no-empty-character-class': 'error', 'no-ex-assign': 'error', 'no-extra-boolean-cast': 'error', diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000000000..6fb4f7dc493b6a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,76 @@ +# Node.js Project Codeowners + +# 1. Codeowners must always be teams, never individuals +# 2. Each codeowner team should contain at least one TSC member +# 3. PRs touching any code with a codeowner must be signed off by at least one +# person on the code owner team. + +./.github/CODEOWNERS @nodejs/tsc + +# net + +# ./deps/cares @nodejs/net +# ./doc/api/dns.md @nodejs/net +# ./doc/api/dgram.md @nodejs/net +# ./doc/api/net.md @nodejs/net +# ./lib/dgram.js @nodejs/net +# ./lib/dns.js @nodejs/net +# ./lib/net.js @nodejs/net @nodejs/quic +# ./lib/internal/dgram.js @nodejs/net +# ./lib/internal/dns/* @nodejs/net +# ./lib/internal/net.js @nodejs/net +# ./lib/internal/socket_list.js @nodejs/net +# ./lib/internal/js_stream_socket.js @nodejs/net +# ./src/cares_wrap.h @nodejs/net +# ./src/connect_wrap.* @nodejs/net +# ./src/connection_wrap.* @nodejs/net +# ./src/node_sockaddr* @nodejs/net +# ./src/tcp_wrap.* @nodejs/net +# ./src/udp_wrap.* @nodejs/net + +# tls/crypto + +# ./lib/internal/crypto/* @nodejs/crypto +# ./lib/internal/tls.js @nodejs/crypto @nodejs/net +# ./lib/crypto.js @nodejs/crypto +# ./lib/tls.js @nodejs/crypto @nodejs/net +# ./src/node_crypto* @nodejs/crypto +# ./src/node_crypto_common* @nodejs/crypto @nodejs/quic + +# http + +# ./deps/llhttp/* @nodejs/http @nodejs/net +# ./doc/api/http.md @nodejs/http @nodejs/net +# ./doc/api/http2.md @nodejs/http @nodejs/net +# ./lib/_http_* @nodejs/http @nodejs/net +# ./lib/http.js @nodejs/http @nodejs/net +# ./lib/https.js @nodejs/crypto @nodejs/net @nodejs/http +# ./src/node_http_common* @nodejs/http @nodejs/http2 @nodejs/quic @nodejs/net +# ./src/node_http_parser.cc @nodejs/http @nodejs/net + +# http2 + +# ./deps/nghttp2/* @nodejs/http2 @nodejs/net +# ./doc/api/http2.md @nodejs/http2 @nodejs/net +# ./lib/http2.js @nodejs/http2 @nodejs/net +# ./lib/internal/http2/* @nodejs/http2 @nodejs/net +# ./src/node_http2* @nodejs/http2 @nodejs/net +# ./src/node_mem* @nodejs/http2 + +# quic + +./deps/ngtcp2/* @nodejs/quic +./deps/nghttp3/* @nodejs/quic +./doc/api/quic.md @nodejs/quic +./lib/internal/quic/* @nodejs/quic +./src/node_bob* @nodejs/quic +./src/quic/* @nodejs/quic + +# modules + +# ./doc/api/modules.md @nodejs/modules +# ./doc/api/esm.md @nodejs/modules +# ./lib/module.js @nodejs/modules +# ./lib/internal/modules/* @nodejs/modules +# ./lib/internal/bootstrap/loaders.js @nodejs/modules +# ./src/module_wrap* @nodejs/modules @nodejs/vm diff --git a/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md new file mode 100644 index 00000000000000..544c9d5f47b0f5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md @@ -0,0 +1,34 @@ +--- +name: Report a flaky test +about: Report a flaky test in our CI +labels: "CI / flaky test" + +--- + + + +* **Test**: +* **Platform**: +* **Console Output:** +``` +REPLACE ME +``` +* **Build Links**: diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md index 1a086bd2cc59a7..48ad8a90cb77c5 100644 --- a/.github/SUPPORT.md +++ b/.github/SUPPORT.md @@ -17,7 +17,7 @@ resources: * [Questions tagged 'node.js' on Stack Overflow](https://stackoverflow.com/questions/tagged/node.js) * [#node.js channel on chat.freenode.net](https://webchat.freenode.net?channels=node.js&uio=d4) * [Node.js Slack Community](https://node-js.slack.com/) - * To register: [nodeslackers.com](http://www.nodeslackers.com/) + * To register: [nodeslackers.com](https://www.nodeslackers.com/) GitHub issues are for tracking enhancements and bugs, not general support. diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 9b4ebca75c86ca..4453db5c751c7f 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v1 with: - PYTHON_VERSION: ${{ env.PYTHON_VERSION }} + python-version: ${{ env.PYTHON_VERSION }} - name: Environment Information run: npx envinfo - name: Lint C/C++ files @@ -64,7 +64,7 @@ jobs: - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v1 with: - PYTHON_VERSION: ${{ env.PYTHON_VERSION }} + python-version: ${{ env.PYTHON_VERSION }} - name: Environment Information run: npx envinfo - name: Lint Python diff --git a/BUILDING.md b/BUILDING.md index d0a3813b5794d0..37b79a02570ed9 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -225,7 +225,7 @@ Consult previous versions of this document for older versions of Node.js: The Node.js project uses Python as part of its build process and has historically only been Python 2 compatible. -Python 2 will reach its _end-of-life_ at the end of 2019 at which point the +Python 2 will reach its _End-of-Life_ at the end of 2019 at which point the interpreter will cease receiving updates. See for more information. @@ -691,7 +691,7 @@ that works for both your host and target environments. ### Build with a specific ICU You can find other ICU releases at -[the ICU homepage](http://icu-project.org/download). +[the ICU homepage](http://site.icu-project.org/download). Download the file named something like `icu4c-**##.#**-src.tgz` (or `.zip`). @@ -722,7 +722,7 @@ $ ./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz #### Windows First unpack latest ICU to `deps/icu` -[icu4c-**##.#**-src.tgz](http://icu-project.org/download) (or `.zip`) +[icu4c-**##.#**-src.tgz](http://site.icu-project.org/download) (or `.zip`) as `deps/icu` (You'll have: `deps/icu/source/...`) ```console diff --git a/CHANGELOG.md b/CHANGELOG.md index 54d2e7b88f2e39..ac4bb4cb8d272f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. -12.18.2
+12.18.3
+12.18.2
12.18.1
12.18.0
12.17.0
diff --git a/LICENSE b/LICENSE index 6b30de0fa9dec5..a42e1d52038bb0 100644 --- a/LICENSE +++ b/LICENSE @@ -1471,6 +1471,39 @@ The externally maintained libraries used by Node.js are: THE POSSIBILITY OF SUCH DAMAGE. """ +- highlight.js, located at doc/api_assets/highlight.pack.js, is licensed as follows: + """ + BSD 3-Clause License + + Copyright (c) 2006, Ivan Sagalaev. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + """ + - node-heapdump, located at src/heap_utils.cc, is licensed as follows: """ ISC License diff --git a/Makefile b/Makefile index 2c0b1d42fd7568..32a8a6c2dca732 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ GNUMAKEFLAGS += --no-print-directory GCOV ?= gcov PWD = $(CURDIR) BUILD_WITH ?= make +FIND ?= find ifdef JOBS PARALLEL_ARGS = -j $(JOBS) @@ -97,13 +98,12 @@ help: ## Print help for targets with comments. # and recreated which can break the addons build when running test-ci # See comments on the build-addons target for some more info ifeq ($(BUILD_WITH), make) -$(NODE_EXE): config.gypi out/Makefile - $(MAKE) -C out BUILDTYPE=Release V=$(V) - if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi - -$(NODE_G_EXE): config.gypi out/Makefile - $(MAKE) -C out BUILDTYPE=Debug V=$(V) - if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi +$(NODE_EXE): build_type:=Release +$(NODE_G_EXE): build_type:=Debug +$(NODE_EXE) $(NODE_G_EXE): config.gypi out/Makefile + $(MAKE) -C out BUILDTYPE=${build_type} V=$(V) + if [ ! -r $@ -o ! -L $@ ]; then \ + ln -fs out/${build_type}/$(NODE_EXE) $@; fi else ifeq ($(BUILD_WITH), ninja) ifeq ($(V),1) @@ -168,7 +168,7 @@ uninstall: ## Uninstalls node from $PREFIX (default=/usr/local). clean: ## Remove build artifacts. $(RM) -r out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) \ out/$(BUILDTYPE)/node.exp - @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs $(RM) -r; fi + @if [ -d out ]; then $(FIND) out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs $(RM) -r; fi $(RM) -r node_modules @if [ -d deps/icu ]; then echo deleting deps/icu; $(RM) -r deps/icu; fi $(RM) test.tap @@ -733,7 +733,7 @@ out/doc/api/assets: # If it's not a source tarball, we need to copy assets from doc/api_assets out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets - @cp $< $@ + @cp $< $@ ; $(RM) out/doc/api/assets/README.md run-npm-ci = $(PWD)/$(NPM) ci @@ -768,6 +768,11 @@ out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.js docopen: $(apidocs_html) @$(PYTHON) -mwebbrowser file://$(PWD)/out/doc/api/all.html +.PHONY: docserve +docserve: $(apidocs_html) + @$(PYTHON) -mwebbrowser http://localhost:8000/all.html + @$(PYTHON) -m http.server -d $(PWD)/out/doc/api + .PHONY: docclean docclean: $(RM) -r out/doc @@ -1195,7 +1200,7 @@ LINT_MD_NEWER = -newer tools/.mdlintstamp endif LINT_MD_TARGETS = doc src lib benchmark test tools/doc tools/icu $(wildcard *.md) -LINT_MD_FILES = $(shell find $(LINT_MD_TARGETS) -type f \ +LINT_MD_FILES = $(shell $(FIND) $(LINT_MD_TARGETS) -type f \ ! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \ $(LINT_MD_NEWER)) run-lint-md = tools/lint-md.js -q -f --no-stdout $(LINT_MD_FILES) @@ -1316,13 +1321,13 @@ else CPPLINT_QUIET = --quiet endif .PHONY: lint-cpp -# Lints the C++ code with cpplint.py and check-imports.py. +# Lints the C++ code with cpplint.py and checkimports.py. lint-cpp: tools/.cpplintstamp tools/.cpplintstamp: $(LINT_CPP_FILES) @echo "Running C++ linter..." @$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) $? - @$(PYTHON) tools/check-imports.py + @$(PYTHON) tools/checkimports.py $? @touch $@ .PHONY: lint-addon-docs @@ -1372,7 +1377,7 @@ CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+ # Related CI job: node-test-linter lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs @if ! ( grep -IEqrs "$(CONFLICT_RE)" benchmark deps doc lib src test tools ) \ - && ! ( find . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \ + && ! ( $(FIND) . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \ exit 0 ; \ else \ echo "" >&2 ; \ diff --git a/README.md b/README.md index af3a57ccaac992..fda0fc98ea2340 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ For information about the governance of the Node.js project, see ### TSC (Technical Steering Committee) + * [addaleax](https://github.com/addaleax) - **Anna Henningsen** <anna@addaleax.net> (she/her) * [apapirovski](https://github.com/apapirovski) - @@ -545,6 +546,7 @@ For information about the governance of the Node.js project, see **Vse Mozhet Byt** <vsemozhetbyt@gmail.com> (he/him) * [whitlockjc](https://github.com/whitlockjc) - **Jeremy Whitlock** <jwhitlock@apache.org> + Collaborators follow the [Collaborator Guide](./doc/guides/collaborator-guide.md) in maintaining the Node.js project. @@ -572,7 +574,7 @@ Primary GPG keys for Node.js Releasers (some Releasers sign with subkeys): To import the full set of trusted release keys: -```shell +```bash 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 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 @@ -608,6 +610,6 @@ Other keys used to sign some previous releases: [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md [Contributing to the project]: CONTRIBUTING.md [Node.js Website]: https://nodejs.org/ -[OpenJS Foundation]: http://openjs.foundation/ +[OpenJS Foundation]: https://openjsf.org/ [Working Groups]: https://github.com/nodejs/TSC/blob/master/WORKING_GROUPS.md [Strategic Initiatives]: https://github.com/nodejs/TSC/blob/master/Strategic-Initiatives.md diff --git a/benchmark/async_hooks/async-resource-vs-destroy.js b/benchmark/async_hooks/async-resource-vs-destroy.js index 52e5e543a6a08d..09898bbe52f939 100644 --- a/benchmark/async_hooks/async-resource-vs-destroy.js +++ b/benchmark/async_hooks/async-resource-vs-destroy.js @@ -138,6 +138,7 @@ function getServeAwait(getCLS, setCLS) { setCLS(Math.random()); await sleep(10); await read(__filename); + if (res.destroyed) return; res.setHeader('content-type', 'application/json'); res.end(JSON.stringify({ cls: getCLS() })); }; @@ -148,6 +149,7 @@ function getServeCallbacks(getCLS, setCLS) { setCLS(Math.random()); setTimeout(() => { readFile(__filename, () => { + if (res.destroyed) return; res.setHeader('content-type', 'application/json'); res.end(JSON.stringify({ cls: getCLS() })); }); diff --git a/benchmark/es/spread-assign.js b/benchmark/es/spread-assign.js index 970512aa6b93d4..c34bb93e762d12 100644 --- a/benchmark/es/spread-assign.js +++ b/benchmark/es/spread-assign.js @@ -15,7 +15,7 @@ function main({ n, context, count, rest, method }) { for (let n = 0; n < count; n++) src[`p${n}`] = n; - let obj; // eslint-disable-line no-unused-vars + let obj; switch (method) { case '_extend': @@ -33,7 +33,7 @@ function main({ n, context, count, rest, method }) { case 'spread': bench.start(); for (let i = 0; i < n; i++) - obj = { ...src }; + obj = { ...src }; // eslint-disable-line no-unused-vars bench.end(n); break; default: diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js index ae5b4abbb99c02..284debdfa09ad8 100644 --- a/benchmark/es/spread-bench.js +++ b/benchmark/es/spread-bench.js @@ -16,11 +16,10 @@ function makeTest(count, rest) { return function test(...args) { assert.strictEqual(count, args.length); }; - } else { - return function test() { - assert.strictEqual(count, arguments.length); - }; } + return function test() { + assert.strictEqual(count, arguments.length); + }; } function main({ n, context, count, rest, method }) { diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js index ef0a23a02928ef..dafaf9122efc86 100644 --- a/benchmark/http/http_server_for_chunky_client.js +++ b/benchmark/http/http_server_for_chunky_client.js @@ -10,7 +10,9 @@ process.env.PIPE_NAME = PIPE; tmpdir.refresh(); -const server = http.createServer((req, res) => { +// For Node.js versions below v13.3.0 this benchmark will require +// the flag --max-http-header-size 64000 in order to work properly +const server = http.createServer({ maxHeaderSize: 64000 }, (req, res) => { const headers = { 'content-type': 'text/plain', 'content-length': '2' @@ -28,7 +30,11 @@ const child = fork( `${__dirname}/_chunky_http_client.js`, process.argv.slice(2) ); -child.on('message', common.sendResult); +child.on('message', (data) => { + if (data.type === 'report') { + common.sendResult(data); + } +}); child.on('close', (code) => { server.close(); assert.strictEqual(code, 0); diff --git a/benchmark/querystring/querystring-stringify.js b/benchmark/querystring/querystring-stringify.js index be81f67fa826d7..d1b724fcf2c14d 100644 --- a/benchmark/querystring/querystring-stringify.js +++ b/benchmark/querystring/querystring-stringify.js @@ -3,7 +3,7 @@ const common = require('../common.js'); const querystring = require('querystring'); const bench = common.createBenchmark(main, { - type: ['noencode', 'encodemany', 'encodelast', 'array'], + type: ['noencode', 'encodemany', 'encodelast', 'array', 'multiprimitives'], n: [1e6], }); @@ -28,7 +28,12 @@ function main({ type, n }) { foo: [], baz: ['bar'], xyzzy: ['bar', 'quux', 'thud'] - } + }, + multiprimitives: { + foo: false, + bar: -13.37, + baz: '', + }, }; const input = inputs[type]; diff --git a/benchmark/scatter.js b/benchmark/scatter.js index ecbf8e0041c837..858169d7d68c3b 100644 --- a/benchmark/scatter.js +++ b/benchmark/scatter.js @@ -30,9 +30,8 @@ let printHeader = true; function csvEncodeValue(value) { if (typeof value === 'number') { return value.toString(); - } else { - return `"${value.replace(/"/g, '""')}"`; } + return `"${value.replace(/"/g, '""')}"`; } (function recursive(i) { diff --git a/configure.py b/configure.py index 0e72ed24ccecbe..b67ad1f06f4e43 100755 --- a/configure.py +++ b/configure.py @@ -164,6 +164,11 @@ "e.g. /root/x/y.js will be referenced via require('root/x/y'). " "Can be used multiple times") +parser.add_option('--openssl-default-cipher-list', + action='store', + dest='openssl_default_cipher_list', + help='Use the specified cipher list as the default cipher list') + parser.add_option("--openssl-no-asm", action="store_true", dest="openssl_no_asm", @@ -635,6 +640,14 @@ default=False, help='compile V8 with debug checks and runtime debugging features enabled') +parser.add_option('--v8-lite-mode', + action='store_true', + dest='v8_lite_mode', + default=False, + help='compile V8 in lite mode for constrained environments (lowers V8 '+ + 'memory footprint, but also implies no just-in-time compilation ' + + 'support, thus much slower execution)') + parser.add_option('--node-builtin-modules-path', action='store', dest='node_builtin_modules_path', @@ -781,7 +794,7 @@ def get_nasm_version(asm): def get_llvm_version(cc): return get_version_helper( - cc, r"(^(?:FreeBSD )?clang version|based on LLVM) ([0-9]+\.[0-9]+)") + cc, r"(^(?:.+ )?clang version|based on LLVM) ([0-9]+\.[0-9]+)") def get_xcode_version(cc): return get_version_helper( @@ -988,12 +1001,14 @@ def configure_arm(o): o['variables']['arm_fpu'] = options.arm_fpu or arm_fpu -def configure_mips(o): +def configure_mips(o, target_arch): can_use_fpu_instructions = (options.mips_float_abi != 'soft') o['variables']['v8_can_use_fpu_instructions'] = b(can_use_fpu_instructions) o['variables']['v8_use_mips_abi_hardfloat'] = b(can_use_fpu_instructions) o['variables']['mips_arch_variant'] = options.mips_arch_variant o['variables']['mips_fpu_mode'] = options.mips_fpu_mode + host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big' + o['variables']['v8_host_byteorder'] = host_byteorder def gcc_version_ge(version_checked): @@ -1049,7 +1064,7 @@ def configure_node(o): if target_arch == 'arm': configure_arm(o) elif target_arch in ('mips', 'mipsel', 'mips64el'): - configure_mips(o) + configure_mips(o, target_arch) if flavor == 'aix': o['variables']['node_target_type'] = 'static_library' @@ -1231,6 +1246,7 @@ def configure_library(lib, output, pkgname=None): def configure_v8(o): + o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs. o['variables']['v8_optimized_debug'] = 0 if options.v8_non_optimized_debug else 1 @@ -1277,6 +1293,8 @@ def without_ssl_error(option): without_ssl_error('--openssl-no-asm') if options.openssl_fips: without_ssl_error('--openssl-fips') + if options.openssl_default_cipher_list: + without_ssl_error('--openssl-default-cipher-list') return if options.use_openssl_ca_store: @@ -1286,6 +1304,9 @@ def without_ssl_error(option): variables['node_without_node_options'] = b(options.without_node_options) if options.without_node_options: o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS'] + if options.openssl_default_cipher_list: + variables['openssl_default_cipher_list'] = \ + options.openssl_default_cipher_list if not options.shared_openssl and not options.openssl_no_asm: is_x86 = 'x64' in variables['target_arch'] or 'ia32' in variables['target_arch'] @@ -1744,6 +1765,10 @@ def make_bin_override(): if options.use_ninja: config['BUILD_WITH'] = 'ninja' +# On Windows there is another find.exe in C:\Windows\System32 +if sys.platform == 'win32': + config['FIND'] = '/usr/bin/find' + config_lines = ['='.join((k,v)) for k,v in config.items()] # Add a blank string to get a blank line at the end. config_lines += [''] diff --git a/deps/node-inspect/.github/workflows/ci.yml b/deps/node-inspect/.github/workflows/ci.yml new file mode 100644 index 00000000000000..968316a34779a5 --- /dev/null +++ b/deps/node-inspect/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Node CI + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: + # See https://github.com/nodejs/node-inspect/pull/78 + # - 10.x + - 12.x + - 13.x + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm test + env: + CI: true diff --git a/deps/node-inspect/lib/_inspect.js b/deps/node-inspect/lib/_inspect.js index 4d931f7a2bc664..aac278db0a891e 100644 --- a/deps/node-inspect/lib/_inspect.js +++ b/deps/node-inspect/lib/_inspect.js @@ -30,15 +30,15 @@ const runAsStandalone = typeof __dirname !== 'undefined'; const [ InspectClient, createRepl ] = runAsStandalone ? // This copy of node-inspect is on-disk, relative paths make sense. - [ - require('./internal/inspect_client'), - require('./internal/inspect_repl') - ] : + [ + require('./internal/inspect_client'), + require('./internal/inspect_repl') + ] : // This copy of node-inspect is built into the node executable. - [ - require('node-inspect/lib/internal/inspect_client'), - require('node-inspect/lib/internal/inspect_repl') - ]; + [ + require('node-inspect/lib/internal/inspect_client'), + require('node-inspect/lib/internal/inspect_repl') + ]; const debuglog = util.debuglog('inspect'); @@ -49,8 +49,8 @@ class StartupError extends Error { } } -function portIsFree(host, port, timeout = 2000) { - if (port === 0) return Promise.resolve(); // Binding to a random port. +function portIsFree(host, port, timeout = 9999) { + if (port === 0) return Promise.resolve(); // Binding to a random port. const retryDelay = 150; let didTimeOut = false; @@ -96,9 +96,9 @@ function runScript(script, scriptArgs, inspectHost, inspectPort, childPrint) { return new Promise((resolve) => { const needDebugBrk = process.version.match(/^v(6|7)\./); const args = (needDebugBrk ? - ['--inspect', `--debug-brk=${inspectPort}`] : - [`--inspect-brk=${inspectPort}`]) - .concat([script], scriptArgs); + ['--inspect', `--debug-brk=${inspectPort}`] : + [`--inspect-brk=${inspectPort}`]) + .concat([script], scriptArgs); const child = spawn(process.execPath, args); child.stdout.setEncoding('utf8'); child.stderr.setEncoding('utf8'); @@ -154,11 +154,11 @@ class NodeInspector { if (options.script) { this._runScript = runScript.bind(null, - options.script, - options.scriptArgs, - options.host, - options.port, - this.childPrint.bind(this)); + options.script, + options.scriptArgs, + options.host, + options.port, + this.childPrint.bind(this)); } else { this._runScript = () => Promise.resolve([null, options.port, options.host]); @@ -333,8 +333,8 @@ function parseArgv([target, ...args]) { } function startInspect(argv = process.argv.slice(2), - stdin = process.stdin, - stdout = process.stdout) { + stdin = process.stdin, + stdout = process.stdout) { /* eslint-disable no-console */ if (argv.length < 1) { const invokedAs = runAsStandalone ? diff --git a/deps/node-inspect/lib/internal/inspect_repl.js b/deps/node-inspect/lib/internal/inspect_repl.js index d9d3f89f03a408..bfbedf66a71b79 100644 --- a/deps/node-inspect/lib/internal/inspect_repl.js +++ b/deps/node-inspect/lib/internal/inspect_repl.js @@ -85,9 +85,16 @@ function extractFunctionName(description) { return fnNameMatch ? `: ${fnNameMatch[1]}` : ''; } -const NATIVES = process.binding('natives'); +const PUBLIC_BUILTINS = require('module').builtinModules; +const NATIVES = PUBLIC_BUILTINS ? process.binding('natives') : {}; function isNativeUrl(url) { - return url.replace('.js', '') in NATIVES || url === 'bootstrap_node.js'; + url = url.replace(/\.js$/, ''); + if (PUBLIC_BUILTINS) { + if (url.startsWith('internal/') || PUBLIC_BUILTINS.includes(url)) + return true; + } + + return url in NATIVES || url === 'bootstrap_node'; } function getRelativePath(filenameOrURL) { @@ -775,6 +782,14 @@ function createRepl(inspector) { } Debugger.on('paused', ({ callFrames, reason /* , hitBreakpoints */ }) => { + if (process.env.NODE_INSPECT_RESUME_ON_START === '1' && + reason === 'Break on start') { + debuglog('Paused on start, but NODE_INSPECT_RESUME_ON_START' + + ' environment variable is set to 1, resuming'); + inspector.client.callMethod('Debugger.resume'); + return; + } + // Save execution context's data currentBacktrace = Backtrace.from(callFrames); selectedFrame = currentBacktrace[0]; diff --git a/deps/node-inspect/package.json b/deps/node-inspect/package.json index c64582703cc6d9..925fb03f21a53d 100644 --- a/deps/node-inspect/package.json +++ b/deps/node-inspect/package.json @@ -1,6 +1,6 @@ { "name": "node-inspect", - "version": "1.11.6", + "version": "2.0.0", "description": "Node Inspect", "license": "MIT", "main": "lib/_inspect.js", @@ -27,7 +27,7 @@ }, "dependencies": {}, "devDependencies": { - "eslint": "^3.10.2", + "eslint": "^6.8.0", "nlm": "^3.0.0", "tap": "^10.7.0" }, diff --git a/deps/node-inspect/test/cli/address.test.js b/deps/node-inspect/test/cli/address.test.js new file mode 100644 index 00000000000000..1dbe4f37b42175 --- /dev/null +++ b/deps/node-inspect/test/cli/address.test.js @@ -0,0 +1,71 @@ +'use strict'; +const { spawn } = require('child_process'); +const Path = require('path'); +const { test } = require('tap'); + +const startCLI = require('./start-cli'); + +// NOTE(oyyd): We might want to import this regexp from "lib/_inspect.js"? +const kDebuggerMsgReg = /Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\//; + +function launchTarget(...args) { + const childProc = spawn(process.execPath, args); + return new Promise((resolve, reject) => { + const onExit = () => { + reject(new Error('Child process exits unexpectly')); + }; + childProc.on('exit', onExit); + childProc.stderr.setEncoding('utf8'); + childProc.stderr.on('data', (data) => { + const ret = kDebuggerMsgReg.exec(data); + childProc.removeListener('exit', onExit); + if (ret) { + resolve({ + childProc, + host: ret[1], + port: ret[2], + }); + } + }); + }); +} + +// process.debugPort is our proxy for "the version of node used to run this +// test suite doesn't support SIGUSR1 for enabling --inspect for a process". +const defaultsToOldProtocol = process.debugPort === 5858; + +test('examples/alive.js', { skip: defaultsToOldProtocol }, (t) => { + const script = Path.join('examples', 'alive.js'); + let cli = null; + let target = null; + + function cleanup(error) { + if (cli) { + cli.quit(); + cli = null; + } + if (target) { + target.kill(); + target = null; + } + if (error) throw error; + } + + return launchTarget('--inspect=0', script) + .then(({ childProc, host, port }) => { + target = childProc; + cli = startCLI([`${host || '127.0.0.1'}:${port}`]); + return cli.waitForPrompt(); + }) + .then(() => cli.command('sb("alive.js", 3)')) + .then(() => cli.waitFor(/break/)) + .then(() => cli.waitForPrompt()) + .then(() => { + t.match( + cli.output, + '> 3 ++x;', + 'marks the 3rd line'); + }) + .then(() => cleanup()) + .then(null, cleanup); +}); diff --git a/deps/node-inspect/test/cli/invalid-args.test.js b/deps/node-inspect/test/cli/invalid-args.test.js index c1aaeb6a9ce750..86428a3ec27030 100644 --- a/deps/node-inspect/test/cli/invalid-args.test.js +++ b/deps/node-inspect/test/cli/invalid-args.test.js @@ -27,7 +27,7 @@ test('launch w/ invalid host:port', (t) => { }); }); -test('launch w/ unavailable port', async (t) => { +test('launch w/ unavailable port', async(t) => { const blocker = createServer((socket) => socket.end()); const port = await new Promise((resolve, reject) => { blocker.on('error', reject); diff --git a/deps/node-inspect/test/cli/launch.test.js b/deps/node-inspect/test/cli/launch.test.js index 087a46c54bb8c6..c4ff3d855a82bc 100644 --- a/deps/node-inspect/test/cli/launch.test.js +++ b/deps/node-inspect/test/cli/launch.test.js @@ -174,3 +174,23 @@ test('run after quit / restart', (t) => { .then(() => cli.quit()) .then(null, onFatal); }); + +test('auto-resume on start if the environment variable is defined', (t) => { + const script = Path.join('examples', 'break.js'); + + const cli = startCLI([script], [], { + env: { NODE_INSPECT_RESUME_ON_START: '1' } + }); + + return cli.waitForInitialBreak() + .then(() => { + t.match( + cli.breakInfo, + { filename: script, line: 10 }, + 'skips to the first breakpoint'); + }) + .then(() => cli.quit()) + .then((code) => { + t.equal(code, 0, 'exits with success'); + }); +}); diff --git a/deps/node-inspect/test/cli/start-cli.js b/deps/node-inspect/test/cli/start-cli.js index e2fa5fe47c9ebe..32c666c7647c68 100644 --- a/deps/node-inspect/test/cli/start-cli.js +++ b/deps/node-inspect/test/cli/start-cli.js @@ -8,8 +8,8 @@ tap.test('startCLI', (t) => t.end()); const CLI = process.env.USE_EMBEDDED_NODE_INSPECT === '1' ? - 'inspect' : - require.resolve('../../cli.js'); + 'inspect' : + require.resolve('../../cli.js'); const BREAK_MESSAGE = new RegExp('(?:' + [ 'assert', 'break', 'break on start', 'debugCommand', @@ -20,8 +20,8 @@ function isPreBreak(output) { return /Break on start/.test(output) && /1 \(function \(exports/.test(output); } -function startCLI(args, flags = []) { - const child = spawn(process.execPath, [...flags, CLI, ...args]); +function startCLI(args, flags = [], spawnOpts = {}) { + const child = spawn(process.execPath, [...flags, CLI, ...args], spawnOpts); let isFirstStdoutChunk = true; const outputBuffer = []; diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS index 08cade33b6ff10..313dba9e161f89 100644 --- a/deps/npm/AUTHORS +++ b/deps/npm/AUTHORS @@ -695,3 +695,7 @@ Jarda Snajdr Naix Geng <1308363651@qq.com> Dylan Treisman mum-never-proud +Peter Fich +Maxwell Gerber +Sean Poulter +vanishcode diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md index bae7de70605601..85230c8e185636 100644 --- a/deps/npm/CHANGELOG.md +++ b/deps/npm/CHANGELOG.md @@ -1,3 +1,25 @@ +## 6.14.6 (2020-07-07) + +### BUG FIXES +* [`a9857b8f6`](https://github.com/npm/cli/commit/a9857b8f6869451ff058789c4631fadfde5bbcbc) chore: remove auth info from logs ([@claudiahdz](https://github.com/claudiahdz)) +* [`b7ad77598`](https://github.com/npm/cli/commit/b7ad77598112908d60195d0fbc472b3c84275fd5) [#1416](https://github.com/npm/cli/pull/1416) fix: wrong `npm doctor` command result ([@vanishcode](https://github.com/vanishcode)) + +### DEPENDENCIES +* [`94eca6377`](https://github.com/npm/cli/commit/94eca637756376b949edfb697e179a1fdcc231ee) `npm-registry-fetch@4.0.5` ([@claudiahdz](https://github.com/claudiahdz)) +* [`c49b6ae28`](https://github.com/npm/cli/commit/c49b6ae28791ff7184288be16654f97168aa9705) [#1418](https://github.com/npm/cli/pull/1418) `spdx-license-ids@3.0.5` ([@kemitchell](https://github.com/kemitchell)) + +### DOCUMENTATION +* [`2e052984b`](https://github.com/npm/cli/commit/2e052984b08c09115ed75387fb2c961631d85d77) + [#1459](https://github.com/npm/cli/pull/1459) + chore(docs): fixed links to cli commands ([@claudiahdz](https://github.com/claudiahdz)) +* [`0ca3509ca`](https://github.com/npm/cli/commit/0ca3509ca940865392daeeabb39192f7d5af9f5e) + [#1283](https://github.com/npm/cli/pull/1283) Update npm-link.md ([@peterfich](https://github.com/peterfich)) +* [`3dd429e9a`](https://github.com/npm/cli/commit/3dd429e9aad760ce2ff9e522b34ebfebd85b460c) + [#1377](https://github.com/npm/cli/pull/1377) + Add note about dropped `*` filenames ([@maxwellgerber](https://github.com/maxwellgerber)) +* [`9a2e2e797`](https://github.com/npm/cli/commit/9a2e2e797e5c91e7f4f261583a1906e2c440cc2f) + [#1429](https://github.com/npm/cli/pull/1429) Fix typo ([@seanpoulter](https://github.com/seanpoulter)) + ## 6.14.5 (2020-05-01) ### BUG FIXES diff --git a/deps/npm/bin/npm-cli.js b/deps/npm/bin/npm-cli.js index 93eddc7a3c892b..c0d9be00433d48 100755 --- a/deps/npm/bin/npm-cli.js +++ b/deps/npm/bin/npm-cli.js @@ -28,6 +28,7 @@ var npm = require('../lib/npm.js') var npmconf = require('../lib/config/core.js') var errorHandler = require('../lib/utils/error-handler.js') + var replaceInfo = require('../lib/utils/replace-info.js') var configDefs = npmconf.defs var shorthands = configDefs.shorthands @@ -40,7 +41,8 @@ process.argv.splice(1, 1, 'npm', '-g') } - log.verbose('cli', process.argv) + var args = replaceInfo(process.argv) + log.verbose('cli', args) var conf = nopt(types, shorthands) npm.argv = conf.argv.remain diff --git a/deps/npm/docs/content/cli-commands/npm-access.md b/deps/npm/docs/content/cli-commands/npm-access.md index f4088fe8855139..0fbce9c0759d12 100644 --- a/deps/npm/docs/content/cli-commands/npm-access.md +++ b/deps/npm/docs/content/cli-commands/npm-access.md @@ -87,7 +87,7 @@ Management of teams and team memberships is done with the `npm team` command. ### See Also * [`libnpmaccess`](https://npm.im/libnpmaccess) -* [npm team](/cli-commands/team) -* [npm publish](/cli-commands/publish) -* [npm config](/cli-commands/config) +* [npm team](/cli-commands/npm-team) +* [npm publish](/cli-commands/npm-publish) +* [npm config](/cli-commands/npm-config) * [npm registry](/using-npm/registry) diff --git a/deps/npm/docs/content/cli-commands/npm-adduser.md b/deps/npm/docs/content/cli-commands/npm-adduser.md index ec61cdd39acbad..2df35e45fc550e 100644 --- a/deps/npm/docs/content/cli-commands/npm-adduser.md +++ b/deps/npm/docs/content/cli-commands/npm-adduser.md @@ -89,7 +89,7 @@ username/password entry in legacy npm. ### See Also * [npm registry](/using-npm/registry) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) -* [npm owner](/cli-commands/owner) -* [npm whoami](/cli-commands/whoami) +* [npm owner](/cli-commands/npm-owner) +* [npm whoami](/cli-commands/npm-whoami) diff --git a/deps/npm/docs/content/cli-commands/npm-audit.md b/deps/npm/docs/content/cli-commands/npm-audit.md index 8b944e94cc12e2..0aba874f96df8d 100644 --- a/deps/npm/docs/content/cli-commands/npm-audit.md +++ b/deps/npm/docs/content/cli-commands/npm-audit.md @@ -131,6 +131,6 @@ configuration setting. ### See Also -* [npm install](/cli-commands/install) +* [npm install](/cli-commands/npm-install) * [package-locks](/configuring-npm/package-locks) * [config](/using-npm/config) diff --git a/deps/npm/docs/content/cli-commands/npm-bin.md b/deps/npm/docs/content/cli-commands/npm-bin.md index eb0912ae48a92a..6c7ce0eee54e21 100644 --- a/deps/npm/docs/content/cli-commands/npm-bin.md +++ b/deps/npm/docs/content/cli-commands/npm-bin.md @@ -19,8 +19,8 @@ Print the folder where npm will install executables. ### See Also -* [npm prefix](/cli-commands/prefix) -* [npm root](/cli-commands/root) +* [npm prefix](/cli-commands/npm-prefix) +* [npm root](/cli-commands/npm-root) * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-bugs.md b/deps/npm/docs/content/cli-commands/npm-bugs.md index 6e59f2bd1a05e0..dcc9c358df14d8 100644 --- a/deps/npm/docs/content/cli-commands/npm-bugs.md +++ b/deps/npm/docs/content/cli-commands/npm-bugs.md @@ -41,10 +41,10 @@ The base URL of the npm package registry. ### See Also -* [npm docs](/cli-commands/docs) -* [npm view](/cli-commands/view) -* [npm publish](/cli-commands/publish) +* [npm docs](/cli-commands/npm-docs) +* [npm view](/cli-commands/npm-view) +* [npm publish](/cli-commands/npm-publish) * [npm registry](/using-npm/registry) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) * [package.json](/configuring-npm/package-json) diff --git a/deps/npm/docs/content/cli-commands/npm-build.md b/deps/npm/docs/content/cli-commands/npm-build.md index eca5397d9c77d5..b657129787663d 100644 --- a/deps/npm/docs/content/cli-commands/npm-build.md +++ b/deps/npm/docs/content/cli-commands/npm-build.md @@ -28,7 +28,7 @@ directly, run: ### See Also -* [npm install](/cli-commands/install) -* [npm link](/cli-commands/link) +* [npm install](/cli-commands/npm-install) +* [npm link](/cli-commands/npm-link) * [npm scripts](/using-npm/scripts) * [package.json](/configuring-npm/package-json) diff --git a/deps/npm/docs/content/cli-commands/npm-bundle.md b/deps/npm/docs/content/cli-commands/npm-bundle.md index c4fdc5e6bb0e64..76417ac8b0b0c7 100644 --- a/deps/npm/docs/content/cli-commands/npm-bundle.md +++ b/deps/npm/docs/content/cli-commands/npm-bundle.md @@ -18,4 +18,4 @@ Just use `npm install` now to do what `npm bundle` used to do. ### See Also -* [npm install](/cli-commands/install) +* [npm install](/cli-commands/npm-install) diff --git a/deps/npm/docs/content/cli-commands/npm-cache.md b/deps/npm/docs/content/cli-commands/npm-cache.md index 4d19749b80f2d9..ed31a320421b0c 100644 --- a/deps/npm/docs/content/cli-commands/npm-cache.md +++ b/deps/npm/docs/content/cli-commands/npm-cache.md @@ -82,10 +82,10 @@ The root cache folder. ### See Also * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) -* [npm install](/cli-commands/install) -* [npm publish](/cli-commands/publish) -* [npm pack](/cli-commands/pack) +* [npm install](/cli-commands/npm-install) +* [npm publish](/cli-commands/npm-publish) +* [npm pack](/cli-commands/npm-pack) * https://npm.im/cacache * https://npm.im/pacote diff --git a/deps/npm/docs/content/cli-commands/npm-ci.md b/deps/npm/docs/content/cli-commands/npm-ci.md index b5b6447a485f8f..357ba16cf6ade1 100644 --- a/deps/npm/docs/content/cli-commands/npm-ci.md +++ b/deps/npm/docs/content/cli-commands/npm-ci.md @@ -45,7 +45,7 @@ cache: ### Description -This command is similar to [`npm install`](/cli-commands/install), except it's meant to be used in +This command is similar to [`npm install`](/cli-commands/npm-install), except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies. It can be significantly faster than a regular npm @@ -63,5 +63,5 @@ In short, the main differences between using `npm install` and `npm ci` are: ### See Also -* [npm install](/cli-commands/install) +* [npm install](/cli-commands/npm-install) * [package-locks](/configuring-npm/package-locks) diff --git a/deps/npm/docs/content/cli-commands/npm-config.md b/deps/npm/docs/content/cli-commands/npm-config.md index 68d403746fc103..c2f2033b066d29 100644 --- a/deps/npm/docs/content/cli-commands/npm-config.md +++ b/deps/npm/docs/content/cli-commands/npm-config.md @@ -79,7 +79,7 @@ global config. ### See Also * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [package.json](/configuring-npm/package-json) * [npmrc](/configuring-npm/npmrc) * [npm](/cli-commands/npm) diff --git a/deps/npm/docs/content/cli-commands/npm-dedupe.md b/deps/npm/docs/content/cli-commands/npm-dedupe.md index a146885a044086..e15a12ba7c18a3 100644 --- a/deps/npm/docs/content/cli-commands/npm-dedupe.md +++ b/deps/npm/docs/content/cli-commands/npm-dedupe.md @@ -62,6 +62,6 @@ result in new modules being installed. ### See Also -* [npm ls](/cli-commands/ls) -* [npm update](/cli-commands/update) -* [npm install](/cli-commands/install) +* [npm ls](/cli-commands/npm-ls) +* [npm update](/cli-commands/npm-update) +* [npm install](/cli-commands/npm-install) diff --git a/deps/npm/docs/content/cli-commands/npm-deprecate.md b/deps/npm/docs/content/cli-commands/npm-deprecate.md index 252c0e70370791..d2d9613f653c6c 100644 --- a/deps/npm/docs/content/cli-commands/npm-deprecate.md +++ b/deps/npm/docs/content/cli-commands/npm-deprecate.md @@ -32,5 +32,5 @@ format an empty string. ### See Also -* [npm publish](/cli-commands/publish) +* [npm publish](/cli-commands/npm-publish) * [npm registry](/using-npm/registry) diff --git a/deps/npm/docs/content/cli-commands/npm-dist-tag.md b/deps/npm/docs/content/cli-commands/npm-dist-tag.md index 4f7fcb9f58f1ba..c7921c7f739d72 100644 --- a/deps/npm/docs/content/cli-commands/npm-dist-tag.md +++ b/deps/npm/docs/content/cli-commands/npm-dist-tag.md @@ -92,9 +92,9 @@ begin with a number or the letter `v`. ### See Also -* [npm publish](/cli-commands/publish) -* [npm install](/cli-commands/install) -* [npm dedupe](/cli-commands/dedupe) +* [npm publish](/cli-commands/npm-publish) +* [npm install](/cli-commands/npm-install) +* [npm dedupe](/cli-commands/npm-dedupe) * [npm registry](/using-npm/registry) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-docs.md b/deps/npm/docs/content/cli-commands/npm-docs.md index f157e200dc514f..46f5cd0d900a47 100644 --- a/deps/npm/docs/content/cli-commands/npm-docs.md +++ b/deps/npm/docs/content/cli-commands/npm-docs.md @@ -44,9 +44,9 @@ The base URL of the npm package registry. ### See Also -* [npm view](/cli-commands/view) -* [npm publish](/cli-commands/publish) +* [npm view](/cli-commands/npm-view) +* [npm publish](/cli-commands/npm-publish) * [npm registry](/using-npm/registry) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) * [package.json](/configuring-npm/package-json) diff --git a/deps/npm/docs/content/cli-commands/npm-doctor.md b/deps/npm/docs/content/cli-commands/npm-doctor.md index 60a57ea4765a26..7cec349e5a8145 100644 --- a/deps/npm/docs/content/cli-commands/npm-doctor.md +++ b/deps/npm/docs/content/cli-commands/npm-doctor.md @@ -106,6 +106,6 @@ cache, you should probably run `npm cache clean` and reset the cache. ### See Also -* [npm bugs](/cli-commands/bugs) -* [npm help](/cli-commands/help) -* [npm ping](/cli-commands/ping) +* [npm bugs](/cli-commands/npm-bugs) +* [npm help](/cli-commands/npm-help) +* [npm ping](/cli-commands/npm-ping) diff --git a/deps/npm/docs/content/cli-commands/npm-edit.md b/deps/npm/docs/content/cli-commands/npm-edit.md index d4b9bbb819b94f..94b6a087fa102f 100644 --- a/deps/npm/docs/content/cli-commands/npm-edit.md +++ b/deps/npm/docs/content/cli-commands/npm-edit.md @@ -41,7 +41,7 @@ The command to run for `npm edit` or `npm config edit`. ### See Also * [npm folders](/configuring-npm/folders) -* [npm explore](/cli-commands/explore) -* [npm install](/cli-commands/install) -* [npm config](/cli-commands/config) +* [npm explore](/cli-commands/npm-explore) +* [npm install](/cli-commands/npm-install) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-explore.md b/deps/npm/docs/content/cli-commands/npm-explore.md index dfa4d9c0737412..8ded96d40984fe 100644 --- a/deps/npm/docs/content/cli-commands/npm-explore.md +++ b/deps/npm/docs/content/cli-commands/npm-explore.md @@ -44,7 +44,7 @@ The shell to run for the `npm explore` command. ### See Also * [npm folders](/configuring-npm/folders) -* [npm edit](/cli-commands/edit) -* [npm rebuild](/cli-commands/rebuild) -* [npm build](/cli-commands/build) -* [npm install](/cli-commands/install) +* [npm edit](/cli-commands/npm-edit) +* [npm rebuild](/cli-commands/npm-rebuild) +* [npm build](/cli-commands/npm-build) +* [npm install](/cli-commands/npm-install) diff --git a/deps/npm/docs/content/cli-commands/npm-fund.md b/deps/npm/docs/content/cli-commands/npm-fund.md index 73910ff7c07bde..5a751eec466871 100644 --- a/deps/npm/docs/content/cli-commands/npm-fund.md +++ b/deps/npm/docs/content/cli-commands/npm-fund.md @@ -61,8 +61,8 @@ If there are multiple funding sources, which 1-indexed source URL to open. ## See Also -* [npm docs](/cli-commands/docs) -* [npm config](/cli-commands/config) -* [npm install](/cli-commands/install) -* [npm ls](/cli-commands/ls) +* [npm docs](/cli-commands/npm-docs) +* [npm config](/cli-commands/npm-config) +* [npm install](/cli-commands/npm-install) +* [npm ls](/cli-commands/npm-ls) diff --git a/deps/npm/docs/content/cli-commands/npm-help-search.md b/deps/npm/docs/content/cli-commands/npm-help-search.md index 96781856551383..69d005cb160ed7 100644 --- a/deps/npm/docs/content/cli-commands/npm-help-search.md +++ b/deps/npm/docs/content/cli-commands/npm-help-search.md @@ -40,4 +40,4 @@ If false, then help-search will just list out the help topics found. ### See Also * [npm](/cli-commands/npm) -* [npm help](/cli-commands/help) +* [npm help](/cli-commands/npm-help) diff --git a/deps/npm/docs/content/cli-commands/npm-help.md b/deps/npm/docs/content/cli-commands/npm-help.md index 358010c05ece33..c47676ffcac1d3 100644 --- a/deps/npm/docs/content/cli-commands/npm-help.md +++ b/deps/npm/docs/content/cli-commands/npm-help.md @@ -38,7 +38,7 @@ Set to `"browser"` to view html help content in the default web browser. * [npm](/cli-commands/npm) * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) * [package.json](/configuring-npm/package-json) -* [npm help-search](/cli-commands/help-search) +* [npm help-search](/cli-commands/npm-help-search) diff --git a/deps/npm/docs/content/cli-commands/npm-init.md b/deps/npm/docs/content/cli-commands/npm-init.md index 32b7f823019910..73ad74b23ea998 100644 --- a/deps/npm/docs/content/cli-commands/npm-init.md +++ b/deps/npm/docs/content/cli-commands/npm-init.md @@ -70,5 +70,5 @@ will create a scoped package. * * [package.json](/configuring-npm/package-json) -* [npm version](/cli-commands/version) +* [npm version](/cli-commands/npm-version) * [npm scope](/using-npm/scope) diff --git a/deps/npm/docs/content/cli-commands/npm-install-ci-test.md b/deps/npm/docs/content/cli-commands/npm-install-ci-test.md index 09d738c79fbed5..98e40f4b27a77d 100644 --- a/deps/npm/docs/content/cli-commands/npm-install-ci-test.md +++ b/deps/npm/docs/content/cli-commands/npm-install-ci-test.md @@ -22,5 +22,5 @@ This command runs an `npm ci` followed immediately by an `npm test`. ### See Also -* [npm ci](/cli-commands/ci) -* [npm test](/cli-commands/test) +* [npm ci](/cli-commands/npm-ci) +* [npm test](/cli-commands/npm-test) diff --git a/deps/npm/docs/content/cli-commands/npm-install-test.md b/deps/npm/docs/content/cli-commands/npm-install-test.md index 58b8844b4fcfff..b86a5199117c4a 100644 --- a/deps/npm/docs/content/cli-commands/npm-install-test.md +++ b/deps/npm/docs/content/cli-commands/npm-install-test.md @@ -31,5 +31,5 @@ takes exactly the same arguments as `npm install`. ### See Also -* [npm install](/cli-commands/install) -* [npm test](/cli-commands/test) +* [npm install](/cli-commands/npm-install) +* [npm test](/cli-commands/npm-test) diff --git a/deps/npm/docs/content/cli-commands/npm-install.md b/deps/npm/docs/content/cli-commands/npm-install.md index be196fa825546b..8e661bf643f394 100644 --- a/deps/npm/docs/content/cli-commands/npm-install.md +++ b/deps/npm/docs/content/cli-commands/npm-install.md @@ -32,7 +32,7 @@ common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional] [-E|--save-exa This command installs a package, and any packages that it depends on. If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven by that, with an `npm-shrinkwrap.json` taking precedence if both -files exist. See [package-lock.json](/configuring-npm/package-lock-json) and [`npm shrinkwrap`](/cli-commands/shrinkwrap). +files exist. See [package-lock.json](/configuring-npm/package-lock-json) and [`npm shrinkwrap`](/cli-commands/npm-shrinkwrap). A `package` is: @@ -40,7 +40,7 @@ A `package` is: * b) a gzipped tarball containing (a) * c) a url that resolves to (b) * d) a `@` that is published on the registry (see [`registry`](/using-npm/registry)) with (c) -* e) a `@` (see [`npm dist-tag`](/cli-commands/dist-tag)) that points to (d) +* e) a `@` (see [`npm dist-tag`](/cli-commands/npm-dist-tag)) that points to (d) * f) a `` that has a "latest" tag satisfying (e) * g) a `` that resolves to (a) @@ -503,17 +503,17 @@ affects a real use-case, it will be investigated. ### See Also * [npm folders](/configuring-npm/folders) -* [npm update](/cli-commands/update) -* [npm audit](/cli-commands/audit) -* [npm fund](/cli-commands/fund) -* [npm link](/cli-commands/link) -* [npm rebuild](/cli-commands/rebuild) +* [npm update](/cli-commands/npm-update) +* [npm audit](/cli-commands/npm-audit) +* [npm fund](/cli-commands/npm-fund) +* [npm link](/cli-commands/npm-link) +* [npm rebuild](/cli-commands/npm-rebuild) * [npm scripts](/using-npm/scripts) -* [npm build](/cli-commands/build) -* [npm config](/cli-commands/config) +* [npm build](/cli-commands/npm-build) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) * [npm registry](/using-npm/registry) -* [npm dist-tag](/cli-commands/dist-tag) -* [npm uninstall](/cli-commands/uninstall) -* [npm shrinkwrap](/cli-commands/shrinkwrap) +* [npm dist-tag](/cli-commands/npm-dist-tag) +* [npm uninstall](/cli-commands/npm-uninstall) +* [npm shrinkwrap](/cli-commands/npm-shrinkwrap) * [package.json](/configuring-npm/package-json) diff --git a/deps/npm/docs/content/cli-commands/npm-link.md b/deps/npm/docs/content/cli-commands/npm-link.md index 3f513868dfebd6..b0e97be5578e9f 100644 --- a/deps/npm/docs/content/cli-commands/npm-link.md +++ b/deps/npm/docs/content/cli-commands/npm-link.md @@ -86,7 +86,7 @@ npm link @myorg/privatepackage * [npm developers](/using-npm/developers) * [package.json](/configuring-npm/package-json) -* [npm- nstall](/cli-commands/install) +* [npm install](/cli-commands/npm-install) * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-logout.md b/deps/npm/docs/content/cli-commands/npm-logout.md index 5fb7100e8ef7d0..ca7d86f2d1960e 100644 --- a/deps/npm/docs/content/cli-commands/npm-logout.md +++ b/deps/npm/docs/content/cli-commands/npm-logout.md @@ -48,7 +48,7 @@ npm logout --scope=@myco ### See Also -* [npm adduser](/cli-commands/adduser) +* [npm adduser](/cli-commands/npm-adduser) * [npm registry](/using-npm/registry) -* [npm config](/cli-commands/config) -* [npm whoami](/cli-commands/whoami) +* [npm config](/cli-commands/npm-config) +* [npm whoami](/cli-commands/npm-whoami) diff --git a/deps/npm/docs/content/cli-commands/npm-ls.md b/deps/npm/docs/content/cli-commands/npm-ls.md index 797f15a50d8494..64a399155ff601 100644 --- a/deps/npm/docs/content/cli-commands/npm-ls.md +++ b/deps/npm/docs/content/cli-commands/npm-ls.md @@ -119,11 +119,11 @@ Set it to false in order to use all-ansi output. ### See Also -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) * [npm folders](/configuring-npm/folders) -* [npm install](/cli-commands/install) -* [npm link](/cli-commands/link) -* [npm prune](/cli-commands/prune) -* [npm outdated](/cli-commands/outdated) -* [npm update](/cli-commands/update) +* [npm install](/cli-commands/npm-install) +* [npm link](/cli-commands/npm-link) +* [npm prune](/cli-commands/npm-prune) +* [npm outdated](/cli-commands/npm-outdated) +* [npm update](/cli-commands/npm-update) diff --git a/deps/npm/docs/content/cli-commands/npm-outdated.md b/deps/npm/docs/content/cli-commands/npm-outdated.md index 3dae28c465f4e6..c7934109dca370 100644 --- a/deps/npm/docs/content/cli-commands/npm-outdated.md +++ b/deps/npm/docs/content/cli-commands/npm-outdated.md @@ -118,7 +118,7 @@ Max depth for checking dependency tree. ### See Also -* [npm update](/cli-commands/update) -* [npm dist-tag](/cli-commands/dist-tag) +* [npm update](/cli-commands/npm-update) +* [npm dist-tag](/cli-commands/npm-dist-tag) * [npm registry](/using-npm/registry) * [npm folders](/configuring-npm/folders) diff --git a/deps/npm/docs/content/cli-commands/npm-owner.md b/deps/npm/docs/content/cli-commands/npm-owner.md index 7088cdaf5cb396..bc2fbc82fb280e 100644 --- a/deps/npm/docs/content/cli-commands/npm-owner.md +++ b/deps/npm/docs/content/cli-commands/npm-owner.md @@ -41,7 +41,7 @@ with `--otp`. ### See Also -* [npm publish](/cli-commands/publish) +* [npm publish](/cli-commands/npm-publish) * [npm registry](/using-npm/registry) -* [npm adduser](/cli-commands/adduser) +* [npm adduser](/cli-commands/npm-adduser) * [npm disputes](/using-npm/disputes) diff --git a/deps/npm/docs/content/cli-commands/npm-pack.md b/deps/npm/docs/content/cli-commands/npm-pack.md index d4774ff3716710..acf18559c14e00 100644 --- a/deps/npm/docs/content/cli-commands/npm-pack.md +++ b/deps/npm/docs/content/cli-commands/npm-pack.md @@ -32,7 +32,7 @@ actually packing anything. Reports on what would have gone into the tarball. ### See Also -* [npm cache](/cli-commands/cache) -* [npm publish](/cli-commands/publish) -* [npm config](/cli-commands/config) +* [npm cache](/cli-commands/npm-cache) +* [npm publish](/cli-commands/npm-publish) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-ping.md b/deps/npm/docs/content/cli-commands/npm-ping.md index 8f765501ac9f33..93d18b57f840b0 100644 --- a/deps/npm/docs/content/cli-commands/npm-ping.md +++ b/deps/npm/docs/content/cli-commands/npm-ping.md @@ -29,5 +29,5 @@ Ping error: {*Detail about error} ### See Also -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-prefix.md b/deps/npm/docs/content/cli-commands/npm-prefix.md index c6b1f7441bcd65..b82fec663a147d 100644 --- a/deps/npm/docs/content/cli-commands/npm-prefix.md +++ b/deps/npm/docs/content/cli-commands/npm-prefix.md @@ -21,12 +21,12 @@ to contain a `package.json` file or `node_modules` directory, unless `-g` is also specified. If `-g` is specified, this will be the value of the global prefix. See -[`npm config`](/cli-commands/config) for more detail. +[`npm config`](/cli-commands/npm-config) for more detail. ### See Also -* [npm root](/cli-commands/root) -* [npm bin](/cli-commands/bin) +* [npm root](/cli-commands/npm-root) +* [npm bin](/cli-commands/npm-bin) * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-profile.md b/deps/npm/docs/content/cli-commands/npm-profile.md index 7cc38e2c9c3fe3..9fe82cd2d3a952 100644 --- a/deps/npm/docs/content/cli-commands/npm-profile.md +++ b/deps/npm/docs/content/cli-commands/npm-profile.md @@ -79,4 +79,4 @@ available on non npmjs.com registries. ### See Also -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) diff --git a/deps/npm/docs/content/cli-commands/npm-prune.md b/deps/npm/docs/content/cli-commands/npm-prune.md index 586c2e7024642b..c6b61e62f828a2 100644 --- a/deps/npm/docs/content/cli-commands/npm-prune.md +++ b/deps/npm/docs/content/cli-commands/npm-prune.md @@ -41,6 +41,6 @@ and it's up to you to run `npm prune` from time-to-time to remove them. ### See Also -* [npm uninstall](/cli-commands/uninstall) +* [npm uninstall](/cli-commands/npm-uninstall) * [npm folders](/configuring-npm/folders) -* [npm ls](/cli-commands/ls) +* [npm ls](/cli-commands/npm-ls) diff --git a/deps/npm/docs/content/cli-commands/npm-publish.md b/deps/npm/docs/content/cli-commands/npm-publish.md index 199377fa0df32d..44c36e0b7ac6cc 100644 --- a/deps/npm/docs/content/cli-commands/npm-publish.md +++ b/deps/npm/docs/content/cli-commands/npm-publish.md @@ -60,13 +60,13 @@ the specified registry. Once a package is published with a given name and version, that specific name and version combination can never be used again, even if -it is removed with [`npm unpublish`](/cli-commands/unpublish). +it is removed with [`npm unpublish`](/cli-commands/npm-unpublish). As of `npm@5`, both a sha1sum and an integrity field with a sha512sum of the tarball will be submitted to the registry during publication. Subsequent installs will use the strongest supported algorithm to verify downloads. -Similar to `--dry-run` see [`npm pack`](/cli-commands/pack), which figures out the files to be +Similar to `--dry-run` see [`npm pack`](/cli-commands/npm-pack), which figures out the files to be included and packs them into a tarball to be uploaded to the registry. ### See Also diff --git a/deps/npm/docs/content/cli-commands/npm-rebuild.md b/deps/npm/docs/content/cli-commands/npm-rebuild.md index 9503d6aae84263..414b9ca55a1932 100644 --- a/deps/npm/docs/content/cli-commands/npm-rebuild.md +++ b/deps/npm/docs/content/cli-commands/npm-rebuild.md @@ -22,5 +22,5 @@ This command runs the `npm build` command on the matched folders. This is usefu ### See Also -* [npm build](/cli-commands/build) -* [npm install](/cli-commands/install) +* [npm build](/cli-commands/npm-build) +* [npm install](/cli-commands/npm-install) diff --git a/deps/npm/docs/content/cli-commands/npm-repo.md b/deps/npm/docs/content/cli-commands/npm-repo.md index 48021d9af5d912..ad41ea571253fd 100644 --- a/deps/npm/docs/content/cli-commands/npm-repo.md +++ b/deps/npm/docs/content/cli-commands/npm-repo.md @@ -32,5 +32,5 @@ The browser that is called by the `npm repo` command to open websites. ### See Also -* [npm docs](/cli-commands/docs) -* [npm config](/cli-commands/config) +* [npm docs](/cli-commands/npm-docs) +* [npm config](/cli-commands/npm-config) diff --git a/deps/npm/docs/content/cli-commands/npm-restart.md b/deps/npm/docs/content/cli-commands/npm-restart.md index 663b8f45066084..d6d388b224ab1f 100644 --- a/deps/npm/docs/content/cli-commands/npm-restart.md +++ b/deps/npm/docs/content/cli-commands/npm-restart.md @@ -41,9 +41,9 @@ behavior will be accompanied by an increase in major version number ### See Also -* [npm run-script](/cli-commands/run-script) +* [npm run-script](/cli-commands/npm-run-script) * [npm scripts](/using-npm/scripts) -* [npm test](/cli-commands/test) -* [npm start](/cli-commands/start) -* [npm stop](/cli-commands/stop) -* [npm restart](/cli-commands/restart) \ No newline at end of file +* [npm test](/cli-commands/npm-test) +* [npm start](/cli-commands/npm-start) +* [npm stop](/cli-commands/npm-stop) +* [npm restart](/cli-commands/npm-restart) \ No newline at end of file diff --git a/deps/npm/docs/content/cli-commands/npm-root.md b/deps/npm/docs/content/cli-commands/npm-root.md index fce4490de78eac..2b27878af4c6dc 100644 --- a/deps/npm/docs/content/cli-commands/npm-root.md +++ b/deps/npm/docs/content/cli-commands/npm-root.md @@ -19,8 +19,8 @@ Print the effective `node_modules` folder to standard out. ### See Also -* [npm prefix](/cli-commands/prefix) -* [npm bin](/cli-commands/bin) +* [npm prefix](/cli-commands/npm-prefix) +* [npm bin](/cli-commands/npm-bin) * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-run-script.md b/deps/npm/docs/content/cli-commands/npm-run-script.md index 1ee381e00f2f1e..51def74c3c4c33 100644 --- a/deps/npm/docs/content/cli-commands/npm-run-script.md +++ b/deps/npm/docs/content/cli-commands/npm-run-script.md @@ -90,8 +90,8 @@ without breaking the execution chain. ### See Also * [npm scripts](/using-npm/scripts) -* [npm test](/cli-commands/test) -* [npm start](/cli-commands/start) -* [npm restart](/cli-commands/restart) -* [npm stop](/cli-commands/stop) -* [npm config](/cli-commands/config) +* [npm test](/cli-commands/npm-test) +* [npm start](/cli-commands/npm-start) +* [npm restart](/cli-commands/npm-restart) +* [npm stop](/cli-commands/npm-stop) +* [npm config](/cli-commands/npm-config) diff --git a/deps/npm/docs/content/cli-commands/npm-search.md b/deps/npm/docs/content/cli-commands/npm-search.md index c65e489cba27c8..e066106faf71f4 100644 --- a/deps/npm/docs/content/cli-commands/npm-search.md +++ b/deps/npm/docs/content/cli-commands/npm-search.md @@ -109,6 +109,6 @@ setting. ### See Also * [npm registry](/using-npm/registry) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) -* [npm view](/cli-commands/view) +* [npm view](/cli-commands/npm-view) diff --git a/deps/npm/docs/content/cli-commands/npm-shrinkwrap.md b/deps/npm/docs/content/cli-commands/npm-shrinkwrap.md index a22aed88e125fe..342fb001675ab3 100644 --- a/deps/npm/docs/content/cli-commands/npm-shrinkwrap.md +++ b/deps/npm/docs/content/cli-commands/npm-shrinkwrap.md @@ -24,11 +24,11 @@ of package locks in npm, see [package-locks](/configuring-npm/package-locks). ### See Also -* [npm install](/cli-commands/install) -* [npm run-script](/cli-commands/run-script) +* [npm install](/cli-commands/npm-install) +* [npm run-script](/cli-commands/npm-run-script) * [npm scripts](/using-npm/scripts) * [package.js](/configuring-npm/package-json) * [package-locks](/configuring-npm/package-locks) * [package-lock.json](/configuring-npm/package-lock-json) * [shrinkwrap.json](/configuring-npm/shrinkwrap-json) -* [npm ls](/cli-commands/ls) +* [npm ls](/cli-commands/npm-ls) diff --git a/deps/npm/docs/content/cli-commands/npm-star.md b/deps/npm/docs/content/cli-commands/npm-star.md index 440d15d05c652e..1912e9c654bc28 100644 --- a/deps/npm/docs/content/cli-commands/npm-star.md +++ b/deps/npm/docs/content/cli-commands/npm-star.md @@ -26,6 +26,6 @@ It's a boolean thing. Starring repeatedly has no additional effect. ### See Also -* [npm view](/cli-commands/view) -* [npm whoami](/cli-commands/whoami) -* [npm adduser](/cli-commands/adduser) +* [npm view](/cli-commands/npm-view) +* [npm whoami](/cli-commands/npm-whoami) +* [npm adduser](/cli-commands/npm-adduser) diff --git a/deps/npm/docs/content/cli-commands/npm-stars.md b/deps/npm/docs/content/cli-commands/npm-stars.md index 87b1664ef8595d..475547bb4b7f2f 100644 --- a/deps/npm/docs/content/cli-commands/npm-stars.md +++ b/deps/npm/docs/content/cli-commands/npm-stars.md @@ -23,7 +23,7 @@ you will most certainly enjoy this command. ### See Also -* [npm star](/cli-commands/star) -* [npm view](/cli-commands/view) -* [npm whoami](/cli-commands/whoami) -* [npm adduser](/cli-commands/adduser) +* [npm star](/cli-commands/npm-star) +* [npm view](/cli-commands/npm-view) +* [npm whoami](/cli-commands/npm-whoami) +* [npm adduser](/cli-commands/npm-adduser) diff --git a/deps/npm/docs/content/cli-commands/npm-start.md b/deps/npm/docs/content/cli-commands/npm-start.md index 70221c9926a5d8..839528257b6d95 100644 --- a/deps/npm/docs/content/cli-commands/npm-start.md +++ b/deps/npm/docs/content/cli-commands/npm-start.md @@ -21,12 +21,12 @@ its `"scripts"` object. If no `"start"` property is specified on the `"scripts"` object, it will run `node server.js`. As of [`npm@2.0.0`](https://blog.npmjs.org/post/98131109725/npm-2-0-0), you can -use custom arguments when executing scripts. Refer to [`npm run-script`](/cli-commands/run-script) for more details. +use custom arguments when executing scripts. Refer to [`npm run-script`](/cli-commands/npm-run-script) for more details. ### See Also -* [npm run-script](/cli-commands/run-script) +* [npm run-script](/cli-commands/npm-run-script) * [npm scripts](/using-npm/scripts) -* [npm test](/cli-commands/test) -* [npm restart](/cli-commands/restart) -* [npm stop](/cli-commands/stop) +* [npm test](/cli-commands/npm-test) +* [npm restart](/cli-commands/npm-restart) +* [npm stop](/cli-commands/npm-stop) diff --git a/deps/npm/docs/content/cli-commands/npm-stop.md b/deps/npm/docs/content/cli-commands/npm-stop.md index 889f04ec41e3e2..da759047cb19a5 100644 --- a/deps/npm/docs/content/cli-commands/npm-stop.md +++ b/deps/npm/docs/content/cli-commands/npm-stop.md @@ -20,8 +20,8 @@ This runs a package's "stop" script, if one was provided. ### See Also -* [npm run-script](/cli-commands/run-script) +* [npm run-script](/cli-commands/npm-run-script) * [npm scripts](/using-npm/scripts) -* [npm test](/cli-commands/test) -* [npm start](/cli-commands/start) -* [npm restart](/cli-commands/restart) +* [npm test](/cli-commands/npm-test) +* [npm start](/cli-commands/npm-start) +* [npm restart](/cli-commands/npm-restart) diff --git a/deps/npm/docs/content/cli-commands/npm-team.md b/deps/npm/docs/content/cli-commands/npm-team.md index 53e084d47d14a3..0d5782f0e04b4f 100644 --- a/deps/npm/docs/content/cli-commands/npm-team.md +++ b/deps/npm/docs/content/cli-commands/npm-team.md @@ -62,5 +62,5 @@ use the `npm access` command to grant or revoke the appropriate permissions. ### See Also -* [npm access](/cli-commands/access) +* [npm access](/cli-commands/npm-access) * [npm registry](/using-npm/registry) diff --git a/deps/npm/docs/content/cli-commands/npm-test.md b/deps/npm/docs/content/cli-commands/npm-test.md index 11900fd2fbf5e1..99c027e3e057af 100644 --- a/deps/npm/docs/content/cli-commands/npm-test.md +++ b/deps/npm/docs/content/cli-commands/npm-test.md @@ -22,8 +22,8 @@ This runs a package's "test" script, if one was provided. ### See Also -* [npm run-script](/cli-commands/run-script) +* [npm run-script](/cli-commands/npm-run-script) * [npm scripts](/using-npm/scripts) -* [npm start](/cli-commands/start) -* [npm restart](/cli-commands/restart) -* [npm stop](/cli-commands/stop) +* [npm start](/cli-commands/npm-start) +* [npm restart](/cli-commands/npm-restart) +* [npm stop](/cli-commands/npm-stop) diff --git a/deps/npm/docs/content/cli-commands/npm-uninstall.md b/deps/npm/docs/content/cli-commands/npm-uninstall.md index 2b994ba6180b65..96fdc4ebe05ba9 100644 --- a/deps/npm/docs/content/cli-commands/npm-uninstall.md +++ b/deps/npm/docs/content/cli-commands/npm-uninstall.md @@ -57,8 +57,8 @@ npm uninstall lodash --no-save ### See Also -* [npm prune](/cli-commands/prune) -* [npm install](/cli-commands/install) +* [npm prune](/cli-commands/npm-prune) +* [npm install](/cli-commands/npm-install) * [npm folders](/configuring-npm/folders) -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [npmrc](/configuring-npm/npmrc) diff --git a/deps/npm/docs/content/cli-commands/npm-unpublish.md b/deps/npm/docs/content/cli-commands/npm-unpublish.md index 9b918ed432c306..bc4a9bd1930079 100644 --- a/deps/npm/docs/content/cli-commands/npm-unpublish.md +++ b/deps/npm/docs/content/cli-commands/npm-unpublish.md @@ -43,8 +43,8 @@ To learn more about how unpublish is treated on the npm registry, see our ### See also -* [npm team](/cli-commands/team) -* [npm access](/cli-commands/access) +* [npm team](/cli-commands/npm-team) +* [npm access](/cli-commands/npm-access) * [npm scope](/using-npm/scope) diff --git a/deps/npm/docs/content/using-npm/registry.md b/deps/npm/docs/content/using-npm/registry.md index 44d0594132929f..cd6a2e4d71eebc 100644 --- a/deps/npm/docs/content/using-npm/registry.md +++ b/deps/npm/docs/content/using-npm/registry.md @@ -33,7 +33,7 @@ available at . The registry URL used is determined by the scope of the package (see [`scope`](/using-npm/scope). If no scope is specified, the default registry is used, which is -supplied by the `registry` config parameter. See [`npm config`](/cli-commands/config), +supplied by the `registry` config parameter. See [`npm config`](/cli-commands/npm-config), [`npmrc`](/configuring-npm/npmrc), and [`config`](/using-npm/config) for more on managing npm's configuration. ### Does npm send any information about me back to the registry? @@ -100,7 +100,7 @@ Yes, head over to ### See also -* [npm config](/cli-commands/config) +* [npm config](/cli-commands/npm-config) * [config](/using-npm/config) * [npmrc](/configuring-npm/npmrc) * [npm developers](/using-npm/developers) diff --git a/deps/npm/docs/content/using-npm/removal.md b/deps/npm/docs/content/using-npm/removal.md index 20f353dc3475d8..7c836846732403 100644 --- a/deps/npm/docs/content/using-npm/removal.md +++ b/deps/npm/docs/content/using-npm/removal.md @@ -66,5 +66,5 @@ find /usr/local/{lib/node,bin} -exec grep -l npm \{\} \; ; ### See also -* [npm uninstall](/cli-commands/uninstall) -* [npm prune](/cli-commands/prune) +* [npm uninstall](/cli-commands/npm-uninstall) +* [npm prune](/cli-commands/npm-prune) diff --git a/deps/npm/docs/content/using-npm/scope.md b/deps/npm/docs/content/using-npm/scope.md index 81c55060ff601e..2cbc108f0db92c 100644 --- a/deps/npm/docs/content/using-npm/scope.md +++ b/deps/npm/docs/content/using-npm/scope.md @@ -55,7 +55,7 @@ Or in `package.json`: ``` Note that if the `@` symbol is omitted, in either case, npm will instead attempt to -install from GitHub; see [`npm install`](/cli-commands/install). +install from GitHub; see [`npm install`](/cli-commands/npm-install). ### Requiring scoped packages @@ -125,7 +125,7 @@ that registry instead. ### See also -* [npm install](/cli-commands/install) -* [npm publish](/cli-commands/publish) -* [npm access](/cli-commands/access) +* [npm install](/cli-commands/npm-install) +* [npm publish](/cli-commands/npm-publish) +* [npm access](/cli-commands/npm-access) * [npm registry](/using-npm/registry) diff --git a/deps/npm/docs/content/using-npm/scripts.md b/deps/npm/docs/content/using-npm/scripts.md index befedd0724aa56..87b65010f0e6e7 100644 --- a/deps/npm/docs/content/using-npm/scripts.md +++ b/deps/npm/docs/content/using-npm/scripts.md @@ -78,7 +78,7 @@ The advantage of doing these things at `prepublish` time is that they can be don ### Life Cycle Operation Order -#### [`npm publish`](/cli-commands/publish) +#### [`npm publish`](/cli-commands/npm-publish) * `prepublishOnly` * `prepare` @@ -86,12 +86,12 @@ The advantage of doing these things at `prepublish` time is that they can be don * `publish` * `postpublish` -#### [`npm pack`](/cli-commands/pack) +#### [`npm pack`](/cli-commands/npm-pack) * `prepack` * `postpack` -#### [`npm install`](/cli-commands/install) +#### [`npm install`](/cli-commands/npm-install) * `preinstall` * `install` @@ -102,7 +102,7 @@ Also triggers * `prepublish` (when on local) * `prepare` (when on local) -#### [`npm start`](/cli-commands/start) +#### [`npm start`](/cli-commands/npm-start) `npm run start` has an `npm start` shorthand. @@ -304,7 +304,7 @@ above. ### See Also -* [npm run-script](/cli-commands/run-script) +* [npm run-script](/cli-commands/npm-run-script) * [package.json](/configuring-npm/package-json) * [npm developers](/using-npm/developers) -* [npm install](/cli-commands/install) +* [npm install](/cli-commands/npm-install) diff --git a/deps/npm/docs/public/cli-commands/npm-access/index.html b/deps/npm/docs/public/cli-commands/npm-access/index.html index 63df3a3728374c..2088d14aa48344 100644 --- a/deps/npm/docs/public/cli-commands/npm-access/index.html +++ b/deps/npm/docs/public/cli-commands/npm-access/index.html @@ -74,7 +74,7 @@ } } }) -

npm access

+

npm access

Set access level on published packages

Synopsis

npm access public [<package>]
@@ -137,9 +137,9 @@ 

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-adduser/index.html b/deps/npm/docs/public/cli-commands/npm-adduser/index.html index ada805d205847f..9a510fbdc9e0a6 100644 --- a/deps/npm/docs/public/cli-commands/npm-adduser/index.html +++ b/deps/npm/docs/public/cli-commands/npm-adduser/index.html @@ -74,7 +74,7 @@ } } }) -

+

section: cli-commands title: npm-adduser description: Set access level on published packages

@@ -132,10 +132,10 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-audit/index.html b/deps/npm/docs/public/cli-commands/npm-audit/index.html index 78afd583ec1937..cc6e8b20ab54f0 100644 --- a/deps/npm/docs/public/cli-commands/npm-audit/index.html +++ b/deps/npm/docs/public/cli-commands/npm-audit/index.html @@ -74,7 +74,7 @@ } } }) -

npm audit

+

npm audit

Run a security audit

Synopsis

npm audit [--json|--parseable|--audit-level=(low|moderate|high|critical)]
@@ -155,7 +155,7 @@ 

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-bin/index.html b/deps/npm/docs/public/cli-commands/npm-bin/index.html index ba6fd6ea4d2aea..b41e26a87282e9 100644 --- a/deps/npm/docs/public/cli-commands/npm-bin/index.html +++ b/deps/npm/docs/public/cli-commands/npm-bin/index.html @@ -74,7 +74,7 @@ } } }) -

npm bin

+

npm bin

Display npm bin folder

Synopsis

npm bin [-g|--global]
@@ -82,10 +82,10 @@

Print the folder where npm will install executables.

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-bugs/index.html b/deps/npm/docs/public/cli-commands/npm-bugs/index.html index b93cd6604c1ba8..d8746297f7d09c 100644 --- a/deps/npm/docs/public/cli-commands/npm-bugs/index.html +++ b/deps/npm/docs/public/cli-commands/npm-bugs/index.html @@ -74,7 +74,7 @@ } } }) -

npm bugs

+

npm bugs

Bugs for a package in a web browser maybe

Synopsis

npm bugs [<pkgname>]
@@ -100,11 +100,11 @@ 

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-build/index.html b/deps/npm/docs/public/cli-commands/npm-build/index.html index b0e8aeaa7b788a..88b6dc62eb11e3 100644 --- a/deps/npm/docs/public/cli-commands/npm-build/index.html +++ b/deps/npm/docs/public/cli-commands/npm-build/index.html @@ -74,7 +74,7 @@ } } }) -

npm build

+

npm build

Build a package

Synopsis

npm build [<package-folder>]
@@ -89,8 +89,8 @@

    npm run-script build

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-bundle/index.html b/deps/npm/docs/public/cli-commands/npm-bundle/index.html index 2be5194916c775..ec7ccad93575e4 100644 --- a/deps/npm/docs/public/cli-commands/npm-bundle/index.html +++ b/deps/npm/docs/public/cli-commands/npm-bundle/index.html @@ -74,7 +74,7 @@ } } }) -

npm bundle

+

npm bundle

REMOVED

Description

The npm bundle command has been removed in 1.0, for the simple reason @@ -83,7 +83,7 @@

Just use npm install now to do what npm bundle used to do.

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-cache/index.html b/deps/npm/docs/public/cli-commands/npm-cache/index.html index 481cc9e44c585a..f12d72477cecc9 100644 --- a/deps/npm/docs/public/cli-commands/npm-cache/index.html +++ b/deps/npm/docs/public/cli-commands/npm-cache/index.html @@ -74,7 +74,7 @@ } } }) -

npm cache

+

npm cache

Manipulates packages cache

Synopsis

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-ci/index.html b/deps/npm/docs/public/cli-commands/npm-ci/index.html index 5b671a8a751d5e..73494a2414237a 100644 --- a/deps/npm/docs/public/cli-commands/npm-ci/index.html +++ b/deps/npm/docs/public/cli-commands/npm-ci/index.html @@ -74,7 +74,7 @@ } } }) -

npm ci

+

npm ci

Install a project with a clean slate

Synopsis

npm ci
@@ -96,7 +96,7 @@

"$HOME/.npm"

Description

-

This command is similar to npm install, except it's meant to be used in +

This command is similar to npm install, except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies. It can be significantly faster than a regular npm @@ -113,7 +113,7 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-completion/index.html b/deps/npm/docs/public/cli-commands/npm-completion/index.html index 8ffddbecb65d23..44def5512c9609 100644 --- a/deps/npm/docs/public/cli-commands/npm-completion/index.html +++ b/deps/npm/docs/public/cli-commands/npm-completion/index.html @@ -74,7 +74,7 @@ } } }) -

npm completion

+

npm completion

Tab Completion for npm

Synopsis

source <(npm completion)
@@ -104,4 +104,4 @@

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-config/index.html b/deps/npm/docs/public/cli-commands/npm-config/index.html index 7d6227d2d9db79..0e41b818e61205 100644 --- a/deps/npm/docs/public/cli-commands/npm-config/index.html +++ b/deps/npm/docs/public/cli-commands/npm-config/index.html @@ -74,7 +74,7 @@ } } }) -

npm config

+

npm config

Manage the npm configuration files

Synopsis

npm config set <key> <value> [-g|--global]
@@ -117,7 +117,7 @@ 

See Also

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-dedupe/index.html b/deps/npm/docs/public/cli-commands/npm-dedupe/index.html index 88d4bddb6f8468..98e3e7b24d7ac8 100644 --- a/deps/npm/docs/public/cli-commands/npm-dedupe/index.html +++ b/deps/npm/docs/public/cli-commands/npm-dedupe/index.html @@ -74,7 +74,7 @@ } } }) -

npm dedupe

+

npm dedupe

Reduce duplication

Synopsis

npm dedupe
@@ -111,9 +111,9 @@ 

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-deprecate/index.html b/deps/npm/docs/public/cli-commands/npm-deprecate/index.html index 1bb22d2979f39f..7e7f8eebb795b6 100644 --- a/deps/npm/docs/public/cli-commands/npm-deprecate/index.html +++ b/deps/npm/docs/public/cli-commands/npm-deprecate/index.html @@ -74,7 +74,7 @@ } } }) -

npm deprecate

+

npm deprecate

Deprecate a version of a package

Synopsis

npm deprecate <pkg>[@<version>] <message>
@@ -91,7 +91,7 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html b/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html index 4201cb3f3c74f4..99be58532a39a7 100644 --- a/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html +++ b/deps/npm/docs/public/cli-commands/npm-dist-tag/index.html @@ -74,7 +74,7 @@ } } }) -

+

section: cli-commands title: npm-dist-tag description: Modify package distribution tags

@@ -136,11 +136,11 @@

v.

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-docs/index.html b/deps/npm/docs/public/cli-commands/npm-docs/index.html index b5dedd56d12a68..a6b000989321c5 100644 --- a/deps/npm/docs/public/cli-commands/npm-docs/index.html +++ b/deps/npm/docs/public/cli-commands/npm-docs/index.html @@ -74,7 +74,7 @@ } } }) -

npm docs

+

npm docs

Docs for a package in a web browser maybe

Synopsis

npm docs [<pkgname> [<pkgname> ...]]
@@ -102,10 +102,10 @@ 

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-doctor/index.html b/deps/npm/docs/public/cli-commands/npm-doctor/index.html index a38eb67e3d21a6..9dbe85beb39fc6 100644 --- a/deps/npm/docs/public/cli-commands/npm-doctor/index.html +++ b/deps/npm/docs/public/cli-commands/npm-doctor/index.html @@ -74,7 +74,7 @@ } } }) -

npm doctor

+

npm doctor

Check your environments

Synopsis

npm doctor
@@ -153,9 +153,9 @@

npm cache clean and reset the cache.

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-edit/index.html b/deps/npm/docs/public/cli-commands/npm-edit/index.html index d0a8bf18f0ffda..3611c6797dc19f 100644 --- a/deps/npm/docs/public/cli-commands/npm-edit/index.html +++ b/deps/npm/docs/public/cli-commands/npm-edit/index.html @@ -74,7 +74,7 @@ } } }) -

npm edit

+

npm edit

Edit an installed package

Synopsis

npm edit <pkg>[/<subpkg>...]
@@ -99,9 +99,9 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-explore/index.html b/deps/npm/docs/public/cli-commands/npm-explore/index.html index 91374a0fac95cd..0af32ce1958ac3 100644 --- a/deps/npm/docs/public/cli-commands/npm-explore/index.html +++ b/deps/npm/docs/public/cli-commands/npm-explore/index.html @@ -74,7 +74,7 @@ } } }) -

+

section: cli-commands title: npm-explore description: Browse an installed package

@@ -103,10 +103,10 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-fund/index.html b/deps/npm/docs/public/cli-commands/npm-fund/index.html index 3d160d633ac550..9ec2766e846ae3 100644 --- a/deps/npm/docs/public/cli-commands/npm-fund/index.html +++ b/deps/npm/docs/public/cli-commands/npm-fund/index.html @@ -74,7 +74,7 @@ } } }) -

npm fund

+

npm fund

Retrieve funding information

Synopsis

    npm fund [<pkg>]
@@ -117,10 +117,10 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-help-search/index.html b/deps/npm/docs/public/cli-commands/npm-help-search/index.html index e9cc5ffc7ef4d6..1fe08bdb605b8f 100644 --- a/deps/npm/docs/public/cli-commands/npm-help-search/index.html +++ b/deps/npm/docs/public/cli-commands/npm-help-search/index.html @@ -74,7 +74,7 @@ } } }) -

npm help-search

+

npm help-search

Search npm help documentation

Synopsis

npm help-search <text>
@@ -97,7 +97,7 @@

See Also

👀 Found a typo? Let us know!

The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

\ No newline at end of file +
\ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-help/index.html b/deps/npm/docs/public/cli-commands/npm-help/index.html index 0a8ab53f2a4828..1d3e10e9dcaf08 100644 --- a/deps/npm/docs/public/cli-commands/npm-help/index.html +++ b/deps/npm/docs/public/cli-commands/npm-help/index.html @@ -74,7 +74,7 @@ } } }) -

npm help

+

npm help

Get help on npm

Synopsis

npm help <term> [<terms..>]
@@ -96,10 +96,10 @@

npm
  • npm folders
  • -
  • npm config
  • +
  • npm config
  • npmrc
  • package.json
  • -
  • npm help-search
  • +
  • npm help-search
  • 👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-hook/index.html b/deps/npm/docs/public/cli-commands/npm-hook/index.html index d60bcddbb96af5..b132e67eaa914a 100644 --- a/deps/npm/docs/public/cli-commands/npm-hook/index.html +++ b/deps/npm/docs/public/cli-commands/npm-hook/index.html @@ -74,7 +74,7 @@ } } }) -

    npm hook

    +

    npm hook

    Manage registry hooks

    Synopsis

    npm hook ls [pkg]
    @@ -119,4 +119,4 @@ 

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-init/index.html b/deps/npm/docs/public/cli-commands/npm-init/index.html index 9b51a55ff46419..a17f9bdac61075 100644 --- a/deps/npm/docs/public/cli-commands/npm-init/index.html +++ b/deps/npm/docs/public/cli-commands/npm-init/index.html @@ -74,7 +74,7 @@ } } }) -

    npm init

    +

    npm init

    create a package.json file

    Synopsis

    npm init [--force|-f|--yes|-y|--scope]
    @@ -117,7 +117,7 @@ 

    https://github.com/isaacs/init-package-json
  • package.json
  • -
  • npm version
  • +
  • npm version
  • npm scope
  • 👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html b/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html index ca152fa1cd238f..510d59aeb6f986 100644 --- a/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html +++ b/deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html @@ -74,7 +74,7 @@ } } }) -

    npm install-ci-test

    +

    npm install-ci-test

    Install a project with a clean slate and run tests

    Synopsis

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-install-test/index.html b/deps/npm/docs/public/cli-commands/npm-install-test/index.html index 368eb1929d46f3..3dc480e0f9a58f 100644 --- a/deps/npm/docs/public/cli-commands/npm-install-test/index.html +++ b/deps/npm/docs/public/cli-commands/npm-install-test/index.html @@ -74,7 +74,7 @@ } } }) -

    npm install-test

    +

    npm install-test

    Install package(s) and run tests

    Synopsis

    npm install-test (with no args, in package dir)
    @@ -93,8 +93,8 @@ 

    npm install.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-install/index.html b/deps/npm/docs/public/cli-commands/npm-install/index.html index 8e8b3fd7ff4b74..503b02e58bbd9d 100644 --- a/deps/npm/docs/public/cli-commands/npm-install/index.html +++ b/deps/npm/docs/public/cli-commands/npm-install/index.html @@ -74,7 +74,7 @@ } } }) -

    npm install

    +

    npm install

    Install a package

    Synopsis

    npm install (with no args, in package dir)
    @@ -95,14 +95,14 @@ 

    This command installs a package, and any packages that it depends on. If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven by that, with an npm-shrinkwrap.json taking precedence if both -files exist. See package-lock.json and npm shrinkwrap.

    +files exist. See package-lock.json and npm shrinkwrap.

    A package is:

    • a) a folder containing a program described by a package.json file
    • b) a gzipped tarball containing (a)
    • c) a url that resolves to (b)
    • d) a <name>@<version> that is published on the registry (see registry) with (c)
    • -
    • e) a <name>@<tag> (see npm dist-tag) that points to (d)
    • +
    • e) a <name>@<tag> (see npm dist-tag) that points to (d)
    • f) a <name> that has a "latest" tag satisfying (e)
    • g) a <git remote url> that resolves to (a)
    @@ -447,19 +447,19 @@

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-link/index.html b/deps/npm/docs/public/cli-commands/npm-link/index.html index c19007eb504fe0..407d16777f9e8e 100644 --- a/deps/npm/docs/public/cli-commands/npm-link/index.html +++ b/deps/npm/docs/public/cli-commands/npm-link/index.html @@ -74,7 +74,7 @@ } } }) -

    npm link

    +

    npm link

    Synopsis

    npm link (in package dir)
    @@ -123,9 +123,9 @@ 

    npm developers
  • package.json
  • -
  • npm- nstall
  • +
  • npm install
  • npm folders
  • -
  • npm config
  • +
  • npm config
  • npmrc
  • 👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-logout/index.html b/deps/npm/docs/public/cli-commands/npm-logout/index.html index 6a357ee4d358ea..0c91eae6ce1b13 100644 --- a/deps/npm/docs/public/cli-commands/npm-logout/index.html +++ b/deps/npm/docs/public/cli-commands/npm-logout/index.html @@ -74,7 +74,7 @@ } } }) -

    npm logout

    +

    npm logout

    Log out of the registry

    Synopsis

    npm logout [--registry=<url>] [--scope=<@scope>]
    @@ -98,10 +98,10 @@

    npm logout --scope=@myco

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-ls/index.html b/deps/npm/docs/public/cli-commands/npm-ls/index.html index e879abe100bc1f..55905a20608257 100644 --- a/deps/npm/docs/public/cli-commands/npm-ls/index.html +++ b/deps/npm/docs/public/cli-commands/npm-ls/index.html @@ -74,7 +74,7 @@ } } }) -

    npm ls

    +

    npm ls

    List installed packages

    Synopsis

    npm ls [[<@scope>/]<pkg> ...]
    @@ -87,7 +87,7 @@ 

    also show the paths to the specified packages. For example, running npm ls promzard in npm's source tree will show:

    -

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-org/index.html b/deps/npm/docs/public/cli-commands/npm-org/index.html index 456c231887b571..c0d4e3c73f05ab 100644 --- a/deps/npm/docs/public/cli-commands/npm-org/index.html +++ b/deps/npm/docs/public/cli-commands/npm-org/index.html @@ -74,7 +74,7 @@ } } }) -

    npm org

    +

    npm org

    Manage orgs

    Synopsis

    npm org set <orgname> <username> [developer | admin | owner]
    @@ -107,4 +107,4 @@ 

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-outdated/index.html b/deps/npm/docs/public/cli-commands/npm-outdated/index.html index 8fe29cc37003c2..1ee0e6f43e96d0 100644 --- a/deps/npm/docs/public/cli-commands/npm-outdated/index.html +++ b/deps/npm/docs/public/cli-commands/npm-outdated/index.html @@ -74,7 +74,7 @@ } } }) -

    npm outdated

    +

    npm outdated

    Check for outdated packages

    Synopsis

    npm outdated [[<@scope>/]<pkg> ...]
    @@ -167,8 +167,8 @@

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-owner/index.html b/deps/npm/docs/public/cli-commands/npm-owner/index.html index 64784997a926d9..e642382b8aa700 100644 --- a/deps/npm/docs/public/cli-commands/npm-owner/index.html +++ b/deps/npm/docs/public/cli-commands/npm-owner/index.html @@ -74,7 +74,7 @@ } } }) -

    npm owner

    +

    npm owner

    Manage package owners

    Synopsis

    npm owner add <user> [<@scope>/]<pkg>
    @@ -103,9 +103,9 @@ 

    --otp.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-pack/index.html b/deps/npm/docs/public/cli-commands/npm-pack/index.html index f07ac85d9e5b00..fb38a2f659c21e 100644 --- a/deps/npm/docs/public/cli-commands/npm-pack/index.html +++ b/deps/npm/docs/public/cli-commands/npm-pack/index.html @@ -74,7 +74,7 @@ } } }) -

    npm pack

    +

    npm pack

    Create a tarball from a package

    Synopsis

    npm pack [[<@scope>/]<pkg>...] [--dry-run]
    @@ -91,9 +91,9 @@

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-ping/index.html b/deps/npm/docs/public/cli-commands/npm-ping/index.html index b6d0f2b6be43d4..6550262d06af95 100644 --- a/deps/npm/docs/public/cli-commands/npm-ping/index.html +++ b/deps/npm/docs/public/cli-commands/npm-ping/index.html @@ -74,7 +74,7 @@ } } }) -

    npm ping

    +

    npm ping

    Ping npm registry

    Synopsis

    npm ping [--registry <registry>]
    @@ -86,7 +86,7 @@

    Ping error: {*Detail about error}

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-prefix/index.html b/deps/npm/docs/public/cli-commands/npm-prefix/index.html index 4f7aea9576a868..1feda5ab9e2e8c 100644 --- a/deps/npm/docs/public/cli-commands/npm-prefix/index.html +++ b/deps/npm/docs/public/cli-commands/npm-prefix/index.html @@ -74,7 +74,7 @@ } } }) -

    npm prefix

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-profile/index.html b/deps/npm/docs/public/cli-commands/npm-profile/index.html index dfef3141e6ca16..9f7eea56ed3327 100644 --- a/deps/npm/docs/public/cli-commands/npm-profile/index.html +++ b/deps/npm/docs/public/cli-commands/npm-profile/index.html @@ -74,7 +74,7 @@ } } }) -

    npm profile

    +

    npm profile

    Change settings on your registry profile

    Synopsis

    npm profile get [--json|--parseable] [<property>]
    @@ -140,7 +140,7 @@ 

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-prune/index.html b/deps/npm/docs/public/cli-commands/npm-prune/index.html index 2b6ae9f754aa6e..5d6d3657ac150c 100644 --- a/deps/npm/docs/public/cli-commands/npm-prune/index.html +++ b/deps/npm/docs/public/cli-commands/npm-prune/index.html @@ -74,7 +74,7 @@ } } }) -

    npm prune

    +

    npm prune

    Remove extraneous packages

    Synopsis

    npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
    @@ -98,9 +98,9 @@

    npm prune from time-to-time to remove them.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-publish/index.html b/deps/npm/docs/public/cli-commands/npm-publish/index.html index f5ddb1f7b6f8bc..2d6539b00266e4 100644 --- a/deps/npm/docs/public/cli-commands/npm-publish/index.html +++ b/deps/npm/docs/public/cli-commands/npm-publish/index.html @@ -74,7 +74,7 @@ } } }) -

    npm publish

    +

    npm publish

    Publish a package

    Synopsis

    npm publish [<tarball>|<folder>] [--tag <tag>] [--access <public|restricted>] [--otp otpcode] [--dry-run]
    @@ -117,11 +117,11 @@ 

    Once a package is published with a given name and version, that specific name and version combination can never be used again, even if -it is removed with npm unpublish.

    +it is removed with npm unpublish.

    As of npm@5, both a sha1sum and an integrity field with a sha512sum of the tarball will be submitted to the registry during publication. Subsequent installs will use the strongest supported algorithm to verify downloads.

    -

    Similar to --dry-run see npm pack, which figures out the files to be +

    Similar to --dry-run see npm pack, which figures out the files to be included and packs them into a tarball to be uploaded to the registry.

    See Also

      @@ -140,4 +140,4 @@

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-rebuild/index.html b/deps/npm/docs/public/cli-commands/npm-rebuild/index.html index 667eb2d96b7906..21ce5153e2dea7 100644 --- a/deps/npm/docs/public/cli-commands/npm-rebuild/index.html +++ b/deps/npm/docs/public/cli-commands/npm-rebuild/index.html @@ -74,7 +74,7 @@ } } }) -

    npm rebuild

    +

    npm rebuild

    Rebuild a package

    Synopsis

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-repo/index.html b/deps/npm/docs/public/cli-commands/npm-repo/index.html index da85949c143802..2b1ab88a192642 100644 --- a/deps/npm/docs/public/cli-commands/npm-repo/index.html +++ b/deps/npm/docs/public/cli-commands/npm-repo/index.html @@ -74,7 +74,7 @@ } } }) -

    npm repo

    +

    npm repo

    Open package repository page in the browser

    Synopsis

    npm repo [<pkg>]
    @@ -92,8 +92,8 @@

    npm repo command to open websites.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-restart/index.html b/deps/npm/docs/public/cli-commands/npm-restart/index.html index cde0b9bf741e12..786125b6a9739c 100644 --- a/deps/npm/docs/public/cli-commands/npm-restart/index.html +++ b/deps/npm/docs/public/cli-commands/npm-restart/index.html @@ -74,7 +74,7 @@ } } }) -

    npm restart

    +

    npm restart

    Restart a package

    Synopsis

    npm restart [-- <args>]
    @@ -100,12 +100,12 @@

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-root/index.html b/deps/npm/docs/public/cli-commands/npm-root/index.html index 1018371d5e8844..f89cdc22492b01 100644 --- a/deps/npm/docs/public/cli-commands/npm-root/index.html +++ b/deps/npm/docs/public/cli-commands/npm-root/index.html @@ -74,7 +74,7 @@ } } }) -

    npm root

    +

    npm root

    Display npm root

    Synopsis

    npm root [-g]
    @@ -82,10 +82,10 @@

    Print the effective node_modules folder to standard out.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-run-script/index.html b/deps/npm/docs/public/cli-commands/npm-run-script/index.html index 3d4e3fed8109d5..4f41911b29bb6f 100644 --- a/deps/npm/docs/public/cli-commands/npm-run-script/index.html +++ b/deps/npm/docs/public/cli-commands/npm-run-script/index.html @@ -74,7 +74,7 @@ } } }) -

    npm run-script

    +

    npm run-script

    Run arbitrary package scripts

    Synopsis

    npm run-script <command> [--silent] [-- <args>...]
    @@ -131,11 +131,11 @@ 

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-search/index.html b/deps/npm/docs/public/cli-commands/npm-search/index.html index 77968fc78a5796..29e55995fb9668 100644 --- a/deps/npm/docs/public/cli-commands/npm-search/index.html +++ b/deps/npm/docs/public/cli-commands/npm-search/index.html @@ -74,7 +74,7 @@ } } }) -

    npm search

    +

    npm search

    Search for packages

    Synopsis

    npm search [-l|--long] [--json] [--parseable] [--no-description] [search terms ...]
    @@ -158,9 +158,9 @@ 

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html b/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html index 7ac4b1117182d4..036d9202fffc5d 100644 --- a/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html +++ b/deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html @@ -74,7 +74,7 @@ } } }) -

    npm shrinkwrap

    +

    npm shrinkwrap

    Lock down dependency versions for publication

    Synopsis

    npm shrinkwrap
    @@ -86,14 +86,14 @@

    package-locks.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-star/index.html b/deps/npm/docs/public/cli-commands/npm-star/index.html index 5186681c685a79..ce866055c27fe8 100644 --- a/deps/npm/docs/public/cli-commands/npm-star/index.html +++ b/deps/npm/docs/public/cli-commands/npm-star/index.html @@ -74,7 +74,7 @@ } } }) -

    npm star

    +

    npm star

    Mark your favorite packages

    Synopsis

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-stars/index.html b/deps/npm/docs/public/cli-commands/npm-stars/index.html index 9edac6d450dd9e..e4b8d1b4002195 100644 --- a/deps/npm/docs/public/cli-commands/npm-stars/index.html +++ b/deps/npm/docs/public/cli-commands/npm-stars/index.html @@ -74,7 +74,7 @@ } } }) -

    npm stars

    +

    npm stars

    View packages marked as favorites

    Synopsis

    npm stars [<user>]
    @@ -85,10 +85,10 @@

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-start/index.html b/deps/npm/docs/public/cli-commands/npm-start/index.html index f16afcecd2b119..d6c4fde8bf4522 100644 --- a/deps/npm/docs/public/cli-commands/npm-start/index.html +++ b/deps/npm/docs/public/cli-commands/npm-start/index.html @@ -74,7 +74,7 @@ } } }) -

    npm start

    +

    npm start

    Start a package

    Synopsis

    npm start [-- <args>]
    @@ -83,14 +83,14 @@

    "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server.js.

    As of npm@2.0.0, you can -use custom arguments when executing scripts. Refer to npm run-script for more details.

    +use custom arguments when executing scripts. Refer to npm run-script for more details.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-stop/index.html b/deps/npm/docs/public/cli-commands/npm-stop/index.html index 07ba9067e27357..b32ea8f0b4f57b 100644 --- a/deps/npm/docs/public/cli-commands/npm-stop/index.html +++ b/deps/npm/docs/public/cli-commands/npm-stop/index.html @@ -74,7 +74,7 @@ } } }) -

    npm stop

    +

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-team/index.html b/deps/npm/docs/public/cli-commands/npm-team/index.html index c8776ba911df1a..f00e13b980a107 100644 --- a/deps/npm/docs/public/cli-commands/npm-team/index.html +++ b/deps/npm/docs/public/cli-commands/npm-team/index.html @@ -74,7 +74,7 @@ } } }) -

    npm team

    +

    npm team

    Manage organization teams and team memberships

    Synopsis

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-test/index.html b/deps/npm/docs/public/cli-commands/npm-test/index.html index 4b7638d884244c..25fd1f5c52c9b4 100644 --- a/deps/npm/docs/public/cli-commands/npm-test/index.html +++ b/deps/npm/docs/public/cli-commands/npm-test/index.html @@ -74,7 +74,7 @@ } } }) -

    npm test

    +

    npm test

    Test a package

    Synopsis

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-token/index.html b/deps/npm/docs/public/cli-commands/npm-token/index.html index 4ee8f7539b1e4e..19debc1b6eaff3 100644 --- a/deps/npm/docs/public/cli-commands/npm-token/index.html +++ b/deps/npm/docs/public/cli-commands/npm-token/index.html @@ -74,7 +74,7 @@ } } }) -

    npm token

    +

    npm token

    Manage your authentication tokens

    Synopsis

      npm token list [--json|--parseable]
    @@ -133,4 +133,4 @@ 

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-uninstall/index.html b/deps/npm/docs/public/cli-commands/npm-uninstall/index.html index 8bc3b7a03ee84d..dcd2c090a839f3 100644 --- a/deps/npm/docs/public/cli-commands/npm-uninstall/index.html +++ b/deps/npm/docs/public/cli-commands/npm-uninstall/index.html @@ -74,7 +74,7 @@ } } }) -

    npm uninstall

    +

    npm uninstall

    Remove a package

    Synopsis

    npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|-D|--save-dev|-O|--save-optional|--no-save]
    @@ -106,10 +106,10 @@ 

    npm uninstall lodash --no-save

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-unpublish/index.html b/deps/npm/docs/public/cli-commands/npm-unpublish/index.html index e04fc20823049c..182342856bdc63 100644 --- a/deps/npm/docs/public/cli-commands/npm-unpublish/index.html +++ b/deps/npm/docs/public/cli-commands/npm-unpublish/index.html @@ -74,7 +74,7 @@ } } }) -

    npm unpublish

    +

    npm unpublish

    Remove a package from the registry

    Synopsis

    Unpublishing a single version of a package

    @@ -94,11 +94,11 @@

    To learn more about how unpublish is treated on the npm registry, see our unpublish policies.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-update/index.html b/deps/npm/docs/public/cli-commands/npm-update/index.html index 094b12d0f5f3ad..7a4fc2c1eee844 100644 --- a/deps/npm/docs/public/cli-commands/npm-update/index.html +++ b/deps/npm/docs/public/cli-commands/npm-update/index.html @@ -74,7 +74,7 @@ } } }) -

    npm update

    +

    npm update

    Update a package

    Synopsis

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-version/index.html b/deps/npm/docs/public/cli-commands/npm-version/index.html index 9260a0a6b2e161..2acdb5c565c579 100644 --- a/deps/npm/docs/public/cli-commands/npm-version/index.html +++ b/deps/npm/docs/public/cli-commands/npm-version/index.html @@ -74,7 +74,7 @@ } } }) -

    npm version

    +

    npm version

    Bump a package version

    Synopsis

    npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
    @@ -167,8 +167,8 @@ 

    Note that you must have a default GPG key set up in your git config for this to work properly.

    See Also

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-view/index.html b/deps/npm/docs/public/cli-commands/npm-view/index.html index 66bf9750c71cb8..8fcf6998ac5131 100644 --- a/deps/npm/docs/public/cli-commands/npm-view/index.html +++ b/deps/npm/docs/public/cli-commands/npm-view/index.html @@ -74,7 +74,7 @@ } } }) -

    npm view

    +

    npm view

    View registry info

    Synopsis

    npm view [<@scope>/]<name>[@<version>] [<field>[.<subfield>]...]
    @@ -133,11 +133,11 @@ 

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm-whoami/index.html b/deps/npm/docs/public/cli-commands/npm-whoami/index.html index 7f25283a705b61..20af217b049175 100644 --- a/deps/npm/docs/public/cli-commands/npm-whoami/index.html +++ b/deps/npm/docs/public/cli-commands/npm-whoami/index.html @@ -74,7 +74,7 @@ } } }) -

    npm whoami

    +

    npm whoami

    Display npm username

    Synopsis

    npm whoami [--registry <registry>]
    @@ -82,9 +82,9 @@

    Print the username config to standard output.

    See Also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/cli-commands/npm/index.html b/deps/npm/docs/public/cli-commands/npm/index.html index d6c68a00732949..1dd1fd8f503345 100644 --- a/deps/npm/docs/public/cli-commands/npm/index.html +++ b/deps/npm/docs/public/cli-commands/npm/index.html @@ -74,12 +74,12 @@ } } }) -

    npm

    +

    npm

    javascript package manager

    Synopsis

    npm <command> [args]

    Version

    -

    6.14.5

    +

    6.14.6

    Description

    npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency @@ -211,4 +211,4 @@

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/folders/index.html b/deps/npm/docs/public/configuring-npm/folders/index.html index 3a7b2078ced93a..20597ce2934420 100644 --- a/deps/npm/docs/public/configuring-npm/folders/index.html +++ b/deps/npm/docs/public/configuring-npm/folders/index.html @@ -74,7 +74,7 @@ } } }) -

    folders

    +

    folders

    Folder Structures Used by npm

    Description

    npm puts various things on your computer. That's its job.

    @@ -122,7 +122,7 @@

    Cache

    -

    See npm cache. Cache files are stored in ~/.npm on Posix, or +

    See npm cache. Cache files are stored in ~/.npm on Posix, or %AppData%/npm-cache on Windows.

    This is controlled by the cache configuration param.

    Temp Files

    @@ -226,13 +226,13 @@

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/install/index.html b/deps/npm/docs/public/configuring-npm/install/index.html index 5587e72e588736..cdcfdaac5e4489 100644 --- a/deps/npm/docs/public/configuring-npm/install/index.html +++ b/deps/npm/docs/public/configuring-npm/install/index.html @@ -74,7 +74,7 @@ } } }) -

    install

    +

    install

    Download and Install npm

    Description

    To publish and install packages to and from the public npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

    @@ -123,4 +123,4 @@

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/npmrc/index.html b/deps/npm/docs/public/configuring-npm/npmrc/index.html index b654a7f6aaf390..2f95c53ba049ec 100644 --- a/deps/npm/docs/public/configuring-npm/npmrc/index.html +++ b/deps/npm/docs/public/configuring-npm/npmrc/index.html @@ -74,7 +74,7 @@ } } }) -

    npmrc

    +

    npmrc

    The npm config files

    Description

    npm gets its config settings from the command line, environment @@ -134,7 +134,7 @@

    See also

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/package-json/index.html b/deps/npm/docs/public/configuring-npm/package-json/index.html index 2edfaff524cf63..7c7ef3e7b2fb15 100644 --- a/deps/npm/docs/public/configuring-npm/package-json/index.html +++ b/deps/npm/docs/public/configuring-npm/package-json/index.html @@ -74,7 +74,7 @@ } } }) -

    package.json

    +

    package.json

    Specifics of npm's package.json handling

    Description

    This document is all you need to know about what's required in your package.json @@ -263,15 +263,13 @@

    .hg
  • .lock-wscript
  • .wafpickle-N
  • -
  • .*.swp
  • .DS_Store
  • -
  • ._*
  • npm-debug.log
  • .npmrc
  • node_modules
  • config.gypi
  • -
  • *.orig
  • package-lock.json (use shrinkwrap instead)
  • +
  • All files containing a * character (incompatible with Windows)
  • main

    The main field is a module ID that is the primary entry point to your program. @@ -440,7 +438,7 @@

    range1 || range2 Passes if either range1 or range2 are satisfied.
  • git... See 'Git URLs as Dependencies' below
  • user/repo See 'GitHub URLs' below
  • -
  • tag A specific version tagged and published as tag See npm dist-tag
  • +
  • tag A specific version tagged and published as tag See npm dist-tag
  • path/path/path See Local Paths below
  • For example, these are all valid:

    @@ -699,13 +697,13 @@

    SEE ALSO

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/package-lock-json/index.html b/deps/npm/docs/public/configuring-npm/package-lock-json/index.html index fe061fbb6ad16f..4658bf4faba7e0 100644 --- a/deps/npm/docs/public/configuring-npm/package-lock-json/index.html +++ b/deps/npm/docs/public/configuring-npm/package-lock-json/index.html @@ -74,7 +74,7 @@ } } }) -

    package-lock.json

    +

    package-lock.json

    A manifestation of the manifest

    Description

    package-lock.json is automatically generated for any operations where npm @@ -174,11 +174,11 @@

    The dependencies of this dependency, exactly as at the top level.

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/package-locks/index.html b/deps/npm/docs/public/configuring-npm/package-locks/index.html index b2e311e1addb33..c7bfeb4daa476e 100644 --- a/deps/npm/docs/public/configuring-npm/package-locks/index.html +++ b/deps/npm/docs/public/configuring-npm/package-locks/index.html @@ -74,10 +74,10 @@ } } }) -

    package-locks

    +

    package-locks

    An explanation of npm lockfiles

    Description

    -

    Conceptually, the "input" to npm install is a package.json, while its +

    Conceptually, the "input" to npm install is a package.json, while its "output" is a fully-formed node_modules tree: a representation of the dependencies you declared. In an ideal world, npm would work like a pure function: the same package.json should produce the exact same node_modules @@ -206,7 +206,7 @@

    package.json
  • package-lock.json
  • shrinkwrap.json
  • -
  • npm shrinkwrap
  • +
  • npm shrinkwrap
  • 👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html b/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html index 7219fb663eadce..4e7f28f0550415 100644 --- a/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html +++ b/deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html @@ -74,10 +74,10 @@ } } }) -

    npm shrinkwrap.json

    +

    npm shrinkwrap.json

    A publishable lockfile

    Description

    -

    npm-shrinkwrap.json is a file created by npm shrinkwrap. It is identical to +

    npm-shrinkwrap.json is a file created by npm shrinkwrap. It is identical to package-lock.json, with one major caveat: Unlike package-lock.json, npm-shrinkwrap.json may be included when publishing a package.

    The recommended use-case for npm-shrinkwrap.json is applications deployed @@ -91,10 +91,10 @@

    package-lock.json.

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/index.html b/deps/npm/docs/public/index.html index 21fae68bfdbd5b..af748547064c90 100644 --- a/deps/npm/docs/public/index.html +++ b/deps/npm/docs/public/index.html @@ -128,4 +128,4 @@ } } }) -
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!

    The current stable version of npm is available on GitHub.

    To upgrade, run: npm install npm@latest -g

    \ No newline at end of file +
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!
    npm cli _
    The intelligent package manager for the Node Javascript Platform. Install stuff and get coding!

    The current stable version of npm is available on GitHub.

    To upgrade, run: npm install npm@latest -g

    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/config/index.html b/deps/npm/docs/public/using-npm/config/index.html index cc245172bb399c..6c888f75147774 100644 --- a/deps/npm/docs/public/using-npm/config/index.html +++ b/deps/npm/docs/public/using-npm/config/index.html @@ -74,7 +74,7 @@ } } }) -

    config

    +

    config

    More than you probably want to know about npm configuration

    Description

    npm gets its configuration values from the following sources, sorted by priority:

    @@ -207,7 +207,7 @@

    npm install runs to the default registry and all registries configured for scopes. See the documentation -for npm audit for details on what is submitted.

    +for npm audit for details on what is submitted.

    audit-level

    -

    The location of npm's cache directory. See npm cache

    +

    The location of npm's cache directory. See npm cache

    cache-lock-stale

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/developers/index.html b/deps/npm/docs/public/using-npm/developers/index.html index c6d6c506bac13a..7c2222013b53b5 100644 --- a/deps/npm/docs/public/using-npm/developers/index.html +++ b/deps/npm/docs/public/using-npm/developers/index.html @@ -74,7 +74,7 @@ } } }) -

    developers

    +

    developers

    Developer Guide

    Description

    So, you've decided to use npm to develop (and maybe publish/deploy) @@ -259,4 +259,4 @@

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/disputes/index.html b/deps/npm/docs/public/using-npm/disputes/index.html index 93a92cd27028e4..4d5212db60f0a6 100644 --- a/deps/npm/docs/public/using-npm/disputes/index.html +++ b/deps/npm/docs/public/using-npm/disputes/index.html @@ -74,7 +74,7 @@ } } }) -

    disputes

    +

    disputes

    Handling Module Name Disputes

    This document describes the steps that you should take to resolve module name disputes with other npm publishers. It also describes special steps you should @@ -184,7 +184,7 @@

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/orgs/index.html b/deps/npm/docs/public/using-npm/orgs/index.html index 0a6fa3f2b7ebe3..56ab196954ae77 100644 --- a/deps/npm/docs/public/using-npm/orgs/index.html +++ b/deps/npm/docs/public/using-npm/orgs/index.html @@ -74,7 +74,7 @@ } } }) -

    orgs

    +

    orgs

    Working with Teams & Orgs

    Description

    There are three levels of org users:

    @@ -88,8 +88,8 @@

    The developer will be able to access packages based on the teams they are on. Access is either read-write or read-only.

    There are two main commands:

      -
    1. npm team see npm team for more details
    2. -
    3. npm access see npm access for more details
    4. +
    5. npm team see npm team for more details
    6. +
    7. npm access see npm access for more details

    Team Admins create teams

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/registry/index.html b/deps/npm/docs/public/using-npm/registry/index.html index 8bc4e9bde235ae..01878b663e3ef8 100644 --- a/deps/npm/docs/public/using-npm/registry/index.html +++ b/deps/npm/docs/public/using-npm/registry/index.html @@ -74,7 +74,7 @@ } } }) -

    registry

    +

    registry

    The JavaScript Package Registry

    Description

    To resolve packages by name and version, npm talks to a registry website @@ -95,7 +95,7 @@

    https://github.com/npm/npm-registry-couchapp.

    The registry URL used is determined by the scope of the package (see scope. If no scope is specified, the default registry is used, which is -supplied by the registry config parameter. See npm config, +supplied by the registry config parameter. See npm config, npmrc, and config for more on managing npm's configuration.

    Does npm send any information about me back to the registry?

    Yes.

    @@ -144,7 +144,7 @@

    https://www.npmjs.com/

    See also

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/removal/index.html b/deps/npm/docs/public/using-npm/removal/index.html index cc5fff6d64ce9d..0940caa467e23a 100644 --- a/deps/npm/docs/public/using-npm/removal/index.html +++ b/deps/npm/docs/public/using-npm/removal/index.html @@ -74,7 +74,7 @@ } } }) -

    removal

    +

    removal

    Cleaning the Slate

    Synopsis

    So sad to see you go.

    @@ -107,8 +107,8 @@

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/scope/index.html b/deps/npm/docs/public/using-npm/scope/index.html index 362b542d13bd5b..910986ab952ae8 100644 --- a/deps/npm/docs/public/using-npm/scope/index.html +++ b/deps/npm/docs/public/using-npm/scope/index.html @@ -74,7 +74,7 @@ } } }) -

    scope

    +

    scope

    Scoped packages

    Description

    All npm packages have a name. Some package names also have a scope. A scope @@ -106,7 +106,7 @@

    "@myorg/mypackage": "^1.3.0" }

    Note that if the @ symbol is omitted, in either case, npm will instead attempt to -install from GitHub; see npm install.

    +install from GitHub; see npm install.

    Requiring scoped packages

    Because scoped packages are installed into a scope folder, you have to include the name of the scope when requiring them in your code, e.g.

    @@ -148,9 +148,9 @@

    See also

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/scripts/index.html b/deps/npm/docs/public/using-npm/scripts/index.html index 4609d564041492..7cf37ff1d7d03c 100644 --- a/deps/npm/docs/public/using-npm/scripts/index.html +++ b/deps/npm/docs/public/using-npm/scripts/index.html @@ -74,7 +74,7 @@ } } }) -

    scripts

    +

    scripts

    How npm handles the "scripts" field

    Description

    The "scripts" property of of your package.json file supports a number of built-in scripts and their preset life cycle events as well as arbitrary scripts. These all can be executed by running npm run-script <stage> or npm run <stage> for short. Pre and post commands with matching names will be run for those as well (e.g. premyscript, myscript, postmyscript). Scripts from dependencies can be run with npm explore <pkg> -- npm run <stage>.

    @@ -138,7 +138,7 @@

    Life Cycle Operation Order

    -

    npm publish

    +

    npm publish

    -

    npm pack

    +

    npm pack

    • prepack
    • postpack
    -

    npm install

    +

    npm install

    -

    npm start

    +

    npm start

    npm run start has an npm start shorthand.

    👀 Found a typo? Let us know!

    The current stable version of npm is here. To upgrade, run: npm install npm@latest -g

    To report bugs or submit feature requests for the docs, please post here. Submit npm issues here.

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/docs/public/using-npm/semver/index.html b/deps/npm/docs/public/using-npm/semver/index.html index fd6017acf9e29e..7232ebb75efcfa 100644 --- a/deps/npm/docs/public/using-npm/semver/index.html +++ b/deps/npm/docs/public/using-npm/semver/index.html @@ -74,7 +74,7 @@ } } }) -

    semver(7) -- The semantic versioner for npm

    +

    semver(7) -- The semantic versioner for npm

    Install

    npm install --save semver

    Usage

    @@ -435,4 +435,4 @@

    \ No newline at end of file +
    \ No newline at end of file diff --git a/deps/npm/lib/doctor/check-ping.js b/deps/npm/lib/doctor/check-ping.js index 58f14fe69e1e0e..d8eac459fd69be 100644 --- a/deps/npm/lib/doctor/check-ping.js +++ b/deps/npm/lib/doctor/check-ping.js @@ -6,7 +6,7 @@ function checkPing (cb) { tracker.info('checkPing', 'Pinging registry') ping({}, true, (err, pong) => { if (err && err.code && err.code.match(/^E\d{3}$/)) { - return cb(null, [err.code.substr(1)]) + return cb(null, [err.code.substr(1), 'failed']) } else { cb(null, [200, 'ok']) } diff --git a/deps/npm/lib/fetch-package-metadata.js b/deps/npm/lib/fetch-package-metadata.js index c4f46f513fed28..ebb378647b86bd 100644 --- a/deps/npm/lib/fetch-package-metadata.js +++ b/deps/npm/lib/fetch-package-metadata.js @@ -3,6 +3,7 @@ const deprCheck = require('./utils/depr-check') const path = require('path') const log = require('npmlog') +const pacote = require('pacote') const readPackageTree = require('read-package-tree') const rimraf = require('rimraf') const validate = require('aproba') @@ -11,15 +12,17 @@ const npm = require('./npm') let npmConfig const npmlog = require('npmlog') const limit = require('call-limit') -const tempFilename = require('./utils/temp-filename') -const pacote = require('pacote') +const tempFilename = require('./utils/temp-filename.js') +const replaceInfo = require('./utils/replace-info.js') const isWindows = require('./utils/is-windows.js') function andLogAndFinish (spec, tracker, done) { validate('SOF|SZF|OOF|OZF', [spec, tracker, done]) return (er, pkg) => { if (er) { - log.silly('fetchPackageMetaData', 'error for ' + String(spec), er.message) + er.message = replaceInfo(er.message) + var spc = replaceInfo(String(spec)) + log.silly('fetchPackageMetaData', 'error for ' + spc, er.message) if (tracker) tracker.finish() } return done(er, pkg) diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js index 3e6f176ef8206b..902ad7af9b328e 100644 --- a/deps/npm/lib/utils/error-handler.js +++ b/deps/npm/lib/utils/error-handler.js @@ -12,6 +12,7 @@ var exitCode = 0 var rollbacks = npm.rollbacks var chain = require('slide').chain var errorMessage = require('./error-message.js') +var replaceInfo = require('./replace-info.js') var stopMetrics = require('./metrics.js').stop const cacheFile = require('./cache-file.js') @@ -175,14 +176,16 @@ function errorHandler (er) { ].forEach(function (k) { var v = er[k] if (!v) return + v = replaceInfo(v) log.verbose(k, v) }) log.verbose('cwd', process.cwd()) var os = require('os') + var args = replaceInfo(process.argv) log.verbose('', os.type() + ' ' + os.release()) - log.verbose('argv', process.argv.map(JSON.stringify).join(' ')) + log.verbose('argv', args.map(JSON.stringify).join(' ')) log.verbose('node', process.version) log.verbose('npm ', 'v' + npm.version) diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js index 3faa78f3089146..78ccdeeb533d62 100644 --- a/deps/npm/lib/utils/error-message.js +++ b/deps/npm/lib/utils/error-message.js @@ -3,12 +3,17 @@ var npm = require('../npm.js') var util = require('util') var nameValidator = require('validate-npm-package-name') var npmlog = require('npmlog') +var replaceInfo = require('./replace-info.js') module.exports = errorMessage function errorMessage (er) { var short = [] var detail = [] + + er.message = replaceInfo(er.message) + er.stack = replaceInfo(er.stack) + switch (er.code) { case 'ENOAUDIT': short.push(['audit', er.message]) diff --git a/deps/npm/lib/utils/replace-info.js b/deps/npm/lib/utils/replace-info.js new file mode 100644 index 00000000000000..a613a3755fab04 --- /dev/null +++ b/deps/npm/lib/utils/replace-info.js @@ -0,0 +1,22 @@ +const URL = require('url') + +// replaces auth info in an array +// of arguments or in a strings +function replaceInfo (arg) { + const isArray = Array.isArray(arg) + const isString = typeof arg === 'string' + + if (!isArray && !isString) return arg + + const args = isString ? arg.split(' ') : arg + const info = args.map(arg => { + try { + const url = new URL(arg) + return url.password === '' ? arg : arg.replace(url.password, '***') + } catch (e) { return arg } + }) + + return isString ? info.join(' ') : info +} + +module.exports = replaceInfo diff --git a/deps/npm/man/man1/npm-README.1 b/deps/npm/man/man1/npm-README.1 index f9f3511f7c364c..d6480c26a4a2e4 100644 --- a/deps/npm/man/man1/npm-README.1 +++ b/deps/npm/man/man1/npm-README.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "May 2020" "" "" +.TH "NPM" "1" "July 2020" "" "" .SH "NAME" \fBnpm\fR \- a JavaScript package manager .P diff --git a/deps/npm/man/man1/npm-access.1 b/deps/npm/man/man1/npm-access.1 index 583bbc0a252990..512a69ad4df4af 100644 --- a/deps/npm/man/man1/npm-access.1 +++ b/deps/npm/man/man1/npm-access.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ACCESS" "1" "May 2020" "" "" +.TH "NPM\-ACCESS" "1" "July 2020" "" "" .SH "NAME" \fBnpm-access\fR \- Set access level on published packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-adduser.1 b/deps/npm/man/man1/npm-adduser.1 index db0e7e078dbcae..48451071c47b44 100644 --- a/deps/npm/man/man1/npm-adduser.1 +++ b/deps/npm/man/man1/npm-adduser.1 @@ -3,7 +3,7 @@ section: cli\-commands title: npm\-adduser .SH description: Set access level on published packages -.TH "NPM\-ADDUSER" "1" "May 2020" "" "" +.TH "NPM\-ADDUSER" "1" "July 2020" "" "" .SH "NAME" \fBnpm-adduser\fR \- Add a registry user account .SS Synopsis diff --git a/deps/npm/man/man1/npm-audit.1 b/deps/npm/man/man1/npm-audit.1 index db60498e2a210a..ad63338952fed1 100644 --- a/deps/npm/man/man1/npm-audit.1 +++ b/deps/npm/man/man1/npm-audit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-AUDIT" "1" "May 2020" "" "" +.TH "NPM\-AUDIT" "1" "July 2020" "" "" .SH "NAME" \fBnpm-audit\fR \- Run a security audit .SS Synopsis diff --git a/deps/npm/man/man1/npm-bin.1 b/deps/npm/man/man1/npm-bin.1 index ffc64299daa1f7..4a044ada095fce 100644 --- a/deps/npm/man/man1/npm-bin.1 +++ b/deps/npm/man/man1/npm-bin.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BIN" "1" "May 2020" "" "" +.TH "NPM\-BIN" "1" "July 2020" "" "" .SH "NAME" \fBnpm-bin\fR \- Display npm bin folder .SS Synopsis diff --git a/deps/npm/man/man1/npm-bugs.1 b/deps/npm/man/man1/npm-bugs.1 index 967d15b73c5f6c..5cf62be9faa91d 100644 --- a/deps/npm/man/man1/npm-bugs.1 +++ b/deps/npm/man/man1/npm-bugs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUGS" "1" "May 2020" "" "" +.TH "NPM\-BUGS" "1" "July 2020" "" "" .SH "NAME" \fBnpm-bugs\fR \- Bugs for a package in a web browser maybe .SS Synopsis diff --git a/deps/npm/man/man1/npm-build.1 b/deps/npm/man/man1/npm-build.1 index 5c1f2c802e1546..9cbfe4f84c942f 100644 --- a/deps/npm/man/man1/npm-build.1 +++ b/deps/npm/man/man1/npm-build.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUILD" "1" "May 2020" "" "" +.TH "NPM\-BUILD" "1" "July 2020" "" "" .SH "NAME" \fBnpm-build\fR \- Build a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-bundle.1 b/deps/npm/man/man1/npm-bundle.1 index 9b3b69753e8755..e210978abcf0dc 100644 --- a/deps/npm/man/man1/npm-bundle.1 +++ b/deps/npm/man/man1/npm-bundle.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUNDLE" "1" "May 2020" "" "" +.TH "NPM\-BUNDLE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-bundle\fR \- REMOVED .SS Description diff --git a/deps/npm/man/man1/npm-cache.1 b/deps/npm/man/man1/npm-cache.1 index 201c7790106964..8abbf7250ac2e6 100644 --- a/deps/npm/man/man1/npm-cache.1 +++ b/deps/npm/man/man1/npm-cache.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CACHE" "1" "May 2020" "" "" +.TH "NPM\-CACHE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-cache\fR \- Manipulates packages cache .SS Synopsis diff --git a/deps/npm/man/man1/npm-ci.1 b/deps/npm/man/man1/npm-ci.1 index 807e94b067ad47..720092272a7e87 100644 --- a/deps/npm/man/man1/npm-ci.1 +++ b/deps/npm/man/man1/npm-ci.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CI" "1" "May 2020" "" "" +.TH "NPM\-CI" "1" "July 2020" "" "" .SH "NAME" \fBnpm-ci\fR \- Install a project with a clean slate .SS Synopsis diff --git a/deps/npm/man/man1/npm-completion.1 b/deps/npm/man/man1/npm-completion.1 index 44e041d1032545..f8b341da6f5798 100644 --- a/deps/npm/man/man1/npm-completion.1 +++ b/deps/npm/man/man1/npm-completion.1 @@ -1,4 +1,4 @@ -.TH "NPM\-COMPLETION" "1" "May 2020" "" "" +.TH "NPM\-COMPLETION" "1" "July 2020" "" "" .SH "NAME" \fBnpm-completion\fR \- Tab Completion for npm .SS Synopsis diff --git a/deps/npm/man/man1/npm-config.1 b/deps/npm/man/man1/npm-config.1 index 71016d0ef10dd3..0b1ce2d0bdfa65 100644 --- a/deps/npm/man/man1/npm-config.1 +++ b/deps/npm/man/man1/npm-config.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CONFIG" "1" "May 2020" "" "" +.TH "NPM\-CONFIG" "1" "July 2020" "" "" .SH "NAME" \fBnpm-config\fR \- Manage the npm configuration files .SS Synopsis diff --git a/deps/npm/man/man1/npm-dedupe.1 b/deps/npm/man/man1/npm-dedupe.1 index 3e41436455d37e..e92c4869b61d61 100644 --- a/deps/npm/man/man1/npm-dedupe.1 +++ b/deps/npm/man/man1/npm-dedupe.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEDUPE" "1" "May 2020" "" "" +.TH "NPM\-DEDUPE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-dedupe\fR \- Reduce duplication .SS Synopsis diff --git a/deps/npm/man/man1/npm-deprecate.1 b/deps/npm/man/man1/npm-deprecate.1 index aa14c873cc1a6f..43c4019b66d973 100644 --- a/deps/npm/man/man1/npm-deprecate.1 +++ b/deps/npm/man/man1/npm-deprecate.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEPRECATE" "1" "May 2020" "" "" +.TH "NPM\-DEPRECATE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-deprecate\fR \- Deprecate a version of a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-dist-tag.1 b/deps/npm/man/man1/npm-dist-tag.1 index dae13ae00f086f..b702b46e6be65d 100644 --- a/deps/npm/man/man1/npm-dist-tag.1 +++ b/deps/npm/man/man1/npm-dist-tag.1 @@ -3,7 +3,7 @@ section: cli\-commands title: npm\-dist\-tag .SH description: Modify package distribution tags -.TH "NPM\-DIST\-TAG" "1" "May 2020" "" "" +.TH "NPM\-DIST\-TAG" "1" "July 2020" "" "" .SH "NAME" \fBnpm-dist-tag\fR \- Modify package distribution tags .SS Synopsis diff --git a/deps/npm/man/man1/npm-docs.1 b/deps/npm/man/man1/npm-docs.1 index 8b6a846a9b71ff..3bb4dbbfc7958e 100644 --- a/deps/npm/man/man1/npm-docs.1 +++ b/deps/npm/man/man1/npm-docs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCS" "1" "May 2020" "" "" +.TH "NPM\-DOCS" "1" "July 2020" "" "" .SH "NAME" \fBnpm-docs\fR \- Docs for a package in a web browser maybe .SS Synopsis diff --git a/deps/npm/man/man1/npm-doctor.1 b/deps/npm/man/man1/npm-doctor.1 index 188c80ac79ff7b..3ab5c8d94cf8b6 100644 --- a/deps/npm/man/man1/npm-doctor.1 +++ b/deps/npm/man/man1/npm-doctor.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCTOR" "1" "May 2020" "" "" +.TH "NPM\-DOCTOR" "1" "July 2020" "" "" .SH "NAME" \fBnpm-doctor\fR \- Check your environments .SS Synopsis diff --git a/deps/npm/man/man1/npm-edit.1 b/deps/npm/man/man1/npm-edit.1 index 828825f8cb97ff..843447cf89c454 100644 --- a/deps/npm/man/man1/npm-edit.1 +++ b/deps/npm/man/man1/npm-edit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EDIT" "1" "May 2020" "" "" +.TH "NPM\-EDIT" "1" "July 2020" "" "" .SH "NAME" \fBnpm-edit\fR \- Edit an installed package .SS Synopsis diff --git a/deps/npm/man/man1/npm-explore.1 b/deps/npm/man/man1/npm-explore.1 index 5859ed053ff71b..f57ce725d610bc 100644 --- a/deps/npm/man/man1/npm-explore.1 +++ b/deps/npm/man/man1/npm-explore.1 @@ -3,7 +3,7 @@ section: cli\-commands title: npm\-explore .SH description: Browse an installed package -.TH "NPM\-EXPLORE" "1" "May 2020" "" "" +.TH "NPM\-EXPLORE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-explore\fR \- Browse an installed package .SS Synopsis diff --git a/deps/npm/man/man1/npm-fund.1 b/deps/npm/man/man1/npm-fund.1 index acb459d745e9bb..cffe3070ba32e4 100644 --- a/deps/npm/man/man1/npm-fund.1 +++ b/deps/npm/man/man1/npm-fund.1 @@ -1,4 +1,4 @@ -.TH "NPM\-FUND" "1" "May 2020" "" "" +.TH "NPM\-FUND" "1" "July 2020" "" "" .SH "NAME" \fBnpm-fund\fR \- Retrieve funding information .SS Synopsis diff --git a/deps/npm/man/man1/npm-help-search.1 b/deps/npm/man/man1/npm-help-search.1 index 72c18bd5e6c54b..5219d10affc086 100644 --- a/deps/npm/man/man1/npm-help-search.1 +++ b/deps/npm/man/man1/npm-help-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP\-SEARCH" "1" "May 2020" "" "" +.TH "NPM\-HELP\-SEARCH" "1" "July 2020" "" "" .SH "NAME" \fBnpm-help-search\fR \- Search npm help documentation .SS Synopsis diff --git a/deps/npm/man/man1/npm-help.1 b/deps/npm/man/man1/npm-help.1 index 1aa3d6ddaea9da..95834ea0241300 100644 --- a/deps/npm/man/man1/npm-help.1 +++ b/deps/npm/man/man1/npm-help.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP" "1" "May 2020" "" "" +.TH "NPM\-HELP" "1" "July 2020" "" "" .SH "NAME" \fBnpm-help\fR \- Get help on npm .SS Synopsis diff --git a/deps/npm/man/man1/npm-hook.1 b/deps/npm/man/man1/npm-hook.1 index 9d6d0a04616aa6..7ebd261618e350 100644 --- a/deps/npm/man/man1/npm-hook.1 +++ b/deps/npm/man/man1/npm-hook.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HOOK" "1" "May 2020" "" "" +.TH "NPM\-HOOK" "1" "July 2020" "" "" .SH "NAME" \fBnpm-hook\fR \- Manage registry hooks .SS Synopsis diff --git a/deps/npm/man/man1/npm-init.1 b/deps/npm/man/man1/npm-init.1 index f33cede27f8d5d..45a47c8c024a6a 100644 --- a/deps/npm/man/man1/npm-init.1 +++ b/deps/npm/man/man1/npm-init.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INIT" "1" "May 2020" "" "" +.TH "NPM\-INIT" "1" "July 2020" "" "" .SH "NAME" \fBnpm-init\fR \- create a package\.json file .SS Synopsis diff --git a/deps/npm/man/man1/npm-install-ci-test.1 b/deps/npm/man/man1/npm-install-ci-test.1 index ed5559db37bad3..e212b5e7529b2f 100644 --- a/deps/npm/man/man1/npm-install-ci-test.1 +++ b/deps/npm/man/man1/npm-install-ci-test.1 @@ -1,4 +1,4 @@ -.TH "NPM" "" "May 2020" "" "" +.TH "NPM" "" "July 2020" "" "" .SH "NAME" \fBnpm\fR .SS Synopsis diff --git a/deps/npm/man/man1/npm-install-test.1 b/deps/npm/man/man1/npm-install-test.1 index 6d65529eab00b1..1396995fa2398a 100644 --- a/deps/npm/man/man1/npm-install-test.1 +++ b/deps/npm/man/man1/npm-install-test.1 @@ -1,4 +1,4 @@ -.TH "NPM" "" "May 2020" "" "" +.TH "NPM" "" "July 2020" "" "" .SH "NAME" \fBnpm\fR .SS Synopsis diff --git a/deps/npm/man/man1/npm-install.1 b/deps/npm/man/man1/npm-install.1 index 152becd7eaae61..7b489b13b1d53c 100644 --- a/deps/npm/man/man1/npm-install.1 +++ b/deps/npm/man/man1/npm-install.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INSTALL" "1" "May 2020" "" "" +.TH "NPM\-INSTALL" "1" "July 2020" "" "" .SH "NAME" \fBnpm-install\fR \- Install a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-link.1 b/deps/npm/man/man1/npm-link.1 index 84df5b7e446fb1..9c0266bbe72fbc 100644 --- a/deps/npm/man/man1/npm-link.1 +++ b/deps/npm/man/man1/npm-link.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LINK" "1" "May 2020" "" "" +.TH "NPM\-LINK" "1" "July 2020" "" "" .SH "NAME" \fBnpm-link\fR \- Symlink a package folder .SS Synopsis @@ -90,7 +90,7 @@ npm help developers .IP \(bu 2 npm help package\.json .IP \(bu 2 -npm help npm\- nstall +npm help install .IP \(bu 2 npm help folders .IP \(bu 2 diff --git a/deps/npm/man/man1/npm-logout.1 b/deps/npm/man/man1/npm-logout.1 index 3a46bcc3af5c71..ca1aa64c3e8c35 100644 --- a/deps/npm/man/man1/npm-logout.1 +++ b/deps/npm/man/man1/npm-logout.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LOGOUT" "1" "May 2020" "" "" +.TH "NPM\-LOGOUT" "1" "July 2020" "" "" .SH "NAME" \fBnpm-logout\fR \- Log out of the registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index 5e024fadb2f3ba..2d5ffc138e66e2 100644 --- a/deps/npm/man/man1/npm-ls.1 +++ b/deps/npm/man/man1/npm-ls.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LS" "1" "May 2020" "" "" +.TH "NPM\-LS" "1" "July 2020" "" "" .SH "NAME" \fBnpm-ls\fR \- List installed packages .SS Synopsis @@ -22,7 +22,7 @@ For example, running \fBnpm ls promzard\fP in npm's source tree will show: .P .RS 2 .nf - npm@6\.14\.5 /path/to/npm + npm@6\.14\.6 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-org.1 b/deps/npm/man/man1/npm-org.1 index cc343314f75c3c..56218e8c4cf14b 100644 --- a/deps/npm/man/man1/npm-org.1 +++ b/deps/npm/man/man1/npm-org.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ORG" "1" "May 2020" "" "" +.TH "NPM\-ORG" "1" "July 2020" "" "" .SH "NAME" \fBnpm-org\fR \- Manage orgs .SS Synopsis diff --git a/deps/npm/man/man1/npm-outdated.1 b/deps/npm/man/man1/npm-outdated.1 index d353c5f340a66c..58d50dac8e52a3 100644 --- a/deps/npm/man/man1/npm-outdated.1 +++ b/deps/npm/man/man1/npm-outdated.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OUTDATED" "1" "May 2020" "" "" +.TH "NPM\-OUTDATED" "1" "July 2020" "" "" .SH "NAME" \fBnpm-outdated\fR \- Check for outdated packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-owner.1 b/deps/npm/man/man1/npm-owner.1 index 34917c9b88340c..349ce09e101b85 100644 --- a/deps/npm/man/man1/npm-owner.1 +++ b/deps/npm/man/man1/npm-owner.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OWNER" "1" "May 2020" "" "" +.TH "NPM\-OWNER" "1" "July 2020" "" "" .SH "NAME" \fBnpm-owner\fR \- Manage package owners .SS Synopsis diff --git a/deps/npm/man/man1/npm-pack.1 b/deps/npm/man/man1/npm-pack.1 index c9163675ec45d0..0e3feb8d618277 100644 --- a/deps/npm/man/man1/npm-pack.1 +++ b/deps/npm/man/man1/npm-pack.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PACK" "1" "May 2020" "" "" +.TH "NPM\-PACK" "1" "July 2020" "" "" .SH "NAME" \fBnpm-pack\fR \- Create a tarball from a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-ping.1 b/deps/npm/man/man1/npm-ping.1 index 0558082b0c4fbd..2ce13ffb3eef19 100644 --- a/deps/npm/man/man1/npm-ping.1 +++ b/deps/npm/man/man1/npm-ping.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PING" "1" "May 2020" "" "" +.TH "NPM\-PING" "1" "July 2020" "" "" .SH "NAME" \fBnpm-ping\fR \- Ping npm registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-prefix.1 b/deps/npm/man/man1/npm-prefix.1 index 3483ad3708e43d..d0bd54abf261c4 100644 --- a/deps/npm/man/man1/npm-prefix.1 +++ b/deps/npm/man/man1/npm-prefix.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PREFIX" "1" "May 2020" "" "" +.TH "NPM\-PREFIX" "1" "July 2020" "" "" .SH "NAME" \fBnpm-prefix\fR \- Display prefix .SS Synopsis diff --git a/deps/npm/man/man1/npm-profile.1 b/deps/npm/man/man1/npm-profile.1 index d1580469207b15..f512fc44dd1dae 100644 --- a/deps/npm/man/man1/npm-profile.1 +++ b/deps/npm/man/man1/npm-profile.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PROFILE" "1" "May 2020" "" "" +.TH "NPM\-PROFILE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-profile\fR \- Change settings on your registry profile .SS Synopsis diff --git a/deps/npm/man/man1/npm-prune.1 b/deps/npm/man/man1/npm-prune.1 index 95d8e15984e1f9..211f20356a7fce 100644 --- a/deps/npm/man/man1/npm-prune.1 +++ b/deps/npm/man/man1/npm-prune.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PRUNE" "1" "May 2020" "" "" +.TH "NPM\-PRUNE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-prune\fR \- Remove extraneous packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-publish.1 b/deps/npm/man/man1/npm-publish.1 index d4ad6b01fb340d..de4307c87b50e5 100644 --- a/deps/npm/man/man1/npm-publish.1 +++ b/deps/npm/man/man1/npm-publish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PUBLISH" "1" "May 2020" "" "" +.TH "NPM\-PUBLISH" "1" "July 2020" "" "" .SH "NAME" \fBnpm-publish\fR \- Publish a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-rebuild.1 b/deps/npm/man/man1/npm-rebuild.1 index 41df28b52e6d01..9dda4956ac0f29 100644 --- a/deps/npm/man/man1/npm-rebuild.1 +++ b/deps/npm/man/man1/npm-rebuild.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REBUILD" "1" "May 2020" "" "" +.TH "NPM\-REBUILD" "1" "July 2020" "" "" .SH "NAME" \fBnpm-rebuild\fR \- Rebuild a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-repo.1 b/deps/npm/man/man1/npm-repo.1 index 360080640b59f9..e1b384383b5efb 100644 --- a/deps/npm/man/man1/npm-repo.1 +++ b/deps/npm/man/man1/npm-repo.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REPO" "1" "May 2020" "" "" +.TH "NPM\-REPO" "1" "July 2020" "" "" .SH "NAME" \fBnpm-repo\fR \- Open package repository page in the browser .SS Synopsis diff --git a/deps/npm/man/man1/npm-restart.1 b/deps/npm/man/man1/npm-restart.1 index 6c72553de428d2..0eb4ab0635cdf3 100644 --- a/deps/npm/man/man1/npm-restart.1 +++ b/deps/npm/man/man1/npm-restart.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RESTART" "1" "May 2020" "" "" +.TH "NPM\-RESTART" "1" "July 2020" "" "" .SH "NAME" \fBnpm-restart\fR \- Restart a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-root.1 b/deps/npm/man/man1/npm-root.1 index 93ff1323e3f0ce..650dfa31f06029 100644 --- a/deps/npm/man/man1/npm-root.1 +++ b/deps/npm/man/man1/npm-root.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ROOT" "1" "May 2020" "" "" +.TH "NPM\-ROOT" "1" "July 2020" "" "" .SH "NAME" \fBnpm-root\fR \- Display npm root .SS Synopsis diff --git a/deps/npm/man/man1/npm-run-script.1 b/deps/npm/man/man1/npm-run-script.1 index 4e38d392d63792..1553522d3627cb 100644 --- a/deps/npm/man/man1/npm-run-script.1 +++ b/deps/npm/man/man1/npm-run-script.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RUN\-SCRIPT" "1" "May 2020" "" "" +.TH "NPM\-RUN\-SCRIPT" "1" "July 2020" "" "" .SH "NAME" \fBnpm-run-script\fR \- Run arbitrary package scripts .SS Synopsis diff --git a/deps/npm/man/man1/npm-search.1 b/deps/npm/man/man1/npm-search.1 index e2406f92252aae..a02bf37151e5d4 100644 --- a/deps/npm/man/man1/npm-search.1 +++ b/deps/npm/man/man1/npm-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SEARCH" "1" "May 2020" "" "" +.TH "NPM\-SEARCH" "1" "July 2020" "" "" .SH "NAME" \fBnpm-search\fR \- Search for packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-shrinkwrap.1 b/deps/npm/man/man1/npm-shrinkwrap.1 index 4f4b95715cff88..8d3dfd93c5a3b6 100644 --- a/deps/npm/man/man1/npm-shrinkwrap.1 +++ b/deps/npm/man/man1/npm-shrinkwrap.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP" "1" "May 2020" "" "" +.TH "NPM\-SHRINKWRAP" "1" "July 2020" "" "" .SH "NAME" \fBnpm-shrinkwrap\fR \- Lock down dependency versions for publication .SS Synopsis diff --git a/deps/npm/man/man1/npm-star.1 b/deps/npm/man/man1/npm-star.1 index 023f409b75c006..13218af050a4c2 100644 --- a/deps/npm/man/man1/npm-star.1 +++ b/deps/npm/man/man1/npm-star.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STAR" "1" "May 2020" "" "" +.TH "NPM\-STAR" "1" "July 2020" "" "" .SH "NAME" \fBnpm-star\fR \- Mark your favorite packages .SS Synopsis diff --git a/deps/npm/man/man1/npm-stars.1 b/deps/npm/man/man1/npm-stars.1 index b2e851319715b0..018b26402d7f91 100644 --- a/deps/npm/man/man1/npm-stars.1 +++ b/deps/npm/man/man1/npm-stars.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STARS" "1" "May 2020" "" "" +.TH "NPM\-STARS" "1" "July 2020" "" "" .SH "NAME" \fBnpm-stars\fR \- View packages marked as favorites .SS Synopsis diff --git a/deps/npm/man/man1/npm-start.1 b/deps/npm/man/man1/npm-start.1 index b64ec8b17533fe..68165e7251bc41 100644 --- a/deps/npm/man/man1/npm-start.1 +++ b/deps/npm/man/man1/npm-start.1 @@ -1,4 +1,4 @@ -.TH "NPM\-START" "1" "May 2020" "" "" +.TH "NPM\-START" "1" "July 2020" "" "" .SH "NAME" \fBnpm-start\fR \- Start a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-stop.1 b/deps/npm/man/man1/npm-stop.1 index 1e23c9385f6c0d..451bfec3661066 100644 --- a/deps/npm/man/man1/npm-stop.1 +++ b/deps/npm/man/man1/npm-stop.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STOP" "1" "May 2020" "" "" +.TH "NPM\-STOP" "1" "July 2020" "" "" .SH "NAME" \fBnpm-stop\fR \- Stop a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-team.1 b/deps/npm/man/man1/npm-team.1 index 2419f372b3d10b..c6c762d1f904b1 100644 --- a/deps/npm/man/man1/npm-team.1 +++ b/deps/npm/man/man1/npm-team.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEAM" "1" "May 2020" "" "" +.TH "NPM\-TEAM" "1" "July 2020" "" "" .SH "NAME" \fBnpm-team\fR \- Manage organization teams and team memberships .SS Synopsis diff --git a/deps/npm/man/man1/npm-test.1 b/deps/npm/man/man1/npm-test.1 index b046fa0376d56f..462a56f4198c99 100644 --- a/deps/npm/man/man1/npm-test.1 +++ b/deps/npm/man/man1/npm-test.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEST" "1" "May 2020" "" "" +.TH "NPM\-TEST" "1" "July 2020" "" "" .SH "NAME" \fBnpm-test\fR \- Test a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-token.1 b/deps/npm/man/man1/npm-token.1 index 0a7555c14ec4f4..54f653b7790240 100644 --- a/deps/npm/man/man1/npm-token.1 +++ b/deps/npm/man/man1/npm-token.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TOKEN" "1" "May 2020" "" "" +.TH "NPM\-TOKEN" "1" "July 2020" "" "" .SH "NAME" \fBnpm-token\fR \- Manage your authentication tokens .SS Synopsis diff --git a/deps/npm/man/man1/npm-uninstall.1 b/deps/npm/man/man1/npm-uninstall.1 index 37ed8caf734e38..2464df632544ad 100644 --- a/deps/npm/man/man1/npm-uninstall.1 +++ b/deps/npm/man/man1/npm-uninstall.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNINSTALL" "1" "May 2020" "" "" +.TH "NPM\-UNINSTALL" "1" "July 2020" "" "" .SH "NAME" \fBnpm-uninstall\fR \- Remove a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-unpublish.1 b/deps/npm/man/man1/npm-unpublish.1 index e776bb047f00dd..156cda6122235b 100644 --- a/deps/npm/man/man1/npm-unpublish.1 +++ b/deps/npm/man/man1/npm-unpublish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNPUBLISH" "1" "May 2020" "" "" +.TH "NPM\-UNPUBLISH" "1" "July 2020" "" "" .SH "NAME" \fBnpm-unpublish\fR \- Remove a package from the registry .SS Synopsis diff --git a/deps/npm/man/man1/npm-update.1 b/deps/npm/man/man1/npm-update.1 index 2006a973c2040e..ef431f2e4351a0 100644 --- a/deps/npm/man/man1/npm-update.1 +++ b/deps/npm/man/man1/npm-update.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UPDATE" "1" "May 2020" "" "" +.TH "NPM\-UPDATE" "1" "July 2020" "" "" .SH "NAME" \fBnpm-update\fR \- Update a package .SS Synopsis diff --git a/deps/npm/man/man1/npm-version.1 b/deps/npm/man/man1/npm-version.1 index 57cd4e9f6ff14c..d2fb0733f134e8 100644 --- a/deps/npm/man/man1/npm-version.1 +++ b/deps/npm/man/man1/npm-version.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VERSION" "1" "May 2020" "" "" +.TH "NPM\-VERSION" "1" "July 2020" "" "" .SH "NAME" \fBnpm-version\fR \- Bump a package version .SS Synopsis diff --git a/deps/npm/man/man1/npm-view.1 b/deps/npm/man/man1/npm-view.1 index a0b97326a48c76..11fad52c8c67c2 100644 --- a/deps/npm/man/man1/npm-view.1 +++ b/deps/npm/man/man1/npm-view.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VIEW" "1" "May 2020" "" "" +.TH "NPM\-VIEW" "1" "July 2020" "" "" .SH "NAME" \fBnpm-view\fR \- View registry info .SS Synopsis diff --git a/deps/npm/man/man1/npm-whoami.1 b/deps/npm/man/man1/npm-whoami.1 index 08dc425b269aeb..5360efecd8c124 100644 --- a/deps/npm/man/man1/npm-whoami.1 +++ b/deps/npm/man/man1/npm-whoami.1 @@ -1,4 +1,4 @@ -.TH "NPM\-WHOAMI" "1" "May 2020" "" "" +.TH "NPM\-WHOAMI" "1" "July 2020" "" "" .SH "NAME" \fBnpm-whoami\fR \- Display npm username .SS Synopsis diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index fc2e735cc44d66..d8b8bef621c09c 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "May 2020" "" "" +.TH "NPM" "1" "July 2020" "" "" .SH "NAME" \fBnpm\fR \- javascript package manager .SS Synopsis @@ -10,7 +10,7 @@ npm [args] .RE .SS Version .P -6\.14\.5 +6\.14\.6 .SS Description .P npm is the package manager for the Node JavaScript platform\. It puts diff --git a/deps/npm/man/man5/folders.5 b/deps/npm/man/man5/folders.5 index 06fcc5032448ca..f2c8dff898774d 100644 --- a/deps/npm/man/man5/folders.5 +++ b/deps/npm/man/man5/folders.5 @@ -1,4 +1,4 @@ -.TH "FOLDERS" "5" "May 2020" "" "" +.TH "FOLDERS" "5" "July 2020" "" "" .SH "NAME" \fBfolders\fR \- Folder Structures Used by npm .SS Description diff --git a/deps/npm/man/man5/install.5 b/deps/npm/man/man5/install.5 index 08b410eddca817..bc95d0251efbe6 100644 --- a/deps/npm/man/man5/install.5 +++ b/deps/npm/man/man5/install.5 @@ -1,4 +1,4 @@ -.TH "INSTALL" "5" "May 2020" "" "" +.TH "INSTALL" "5" "July 2020" "" "" .SH "NAME" \fBinstall\fR \- Download and Install npm .SS Description diff --git a/deps/npm/man/man5/npmrc.5 b/deps/npm/man/man5/npmrc.5 index ed5483983f300a..d934d925a07674 100644 --- a/deps/npm/man/man5/npmrc.5 +++ b/deps/npm/man/man5/npmrc.5 @@ -1,4 +1,4 @@ -.TH "NPMRC" "5" "May 2020" "" "" +.TH "NPMRC" "5" "July 2020" "" "" .SH "NAME" \fBnpmrc\fR \- The npm config files .SS Description diff --git a/deps/npm/man/man5/package-json.5 b/deps/npm/man/man5/package-json.5 index 7ebe2dcf4a4918..5e80b634bd18e3 100644 --- a/deps/npm/man/man5/package-json.5 +++ b/deps/npm/man/man5/package-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\.JSON" "5" "May 2020" "" "" +.TH "PACKAGE\.JSON" "5" "July 2020" "" "" .SH "NAME" \fBpackage.json\fR \- Specifics of npm's package\.json handling .SS Description @@ -308,12 +308,8 @@ Conversely, some files are always ignored: .IP \(bu 2 \fB\|\.wafpickle\-N\fP .IP \(bu 2 -\fB\|\.*\.swp\fP -.IP \(bu 2 \fB\|\.DS_Store\fP .IP \(bu 2 -\fB\|\._*\fP -.IP \(bu 2 \fBnpm\-debug\.log\fP .IP \(bu 2 \fB\|\.npmrc\fP @@ -322,9 +318,9 @@ Conversely, some files are always ignored: .IP \(bu 2 \fBconfig\.gypi\fP .IP \(bu 2 -\fB*\.orig\fP -.IP \(bu 2 \fBpackage\-lock\.json\fP (use shrinkwrap instead) +.IP \(bu 2 +All files containing a \fB*\fP character (incompatible with Windows) .RE .SS main diff --git a/deps/npm/man/man5/package-lock-json.5 b/deps/npm/man/man5/package-lock-json.5 index 5db9bea393f475..360d1d1d90a09c 100644 --- a/deps/npm/man/man5/package-lock-json.5 +++ b/deps/npm/man/man5/package-lock-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\-LOCK\.JSON" "5" "May 2020" "" "" +.TH "PACKAGE\-LOCK\.JSON" "5" "July 2020" "" "" .SH "NAME" \fBpackage-lock.json\fR \- A manifestation of the manifest .SS Description diff --git a/deps/npm/man/man5/package-locks.5 b/deps/npm/man/man5/package-locks.5 index f7856325abbbe7..f3d60b323d80cd 100644 --- a/deps/npm/man/man5/package-locks.5 +++ b/deps/npm/man/man5/package-locks.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\-LOCKS" "5" "May 2020" "" "" +.TH "PACKAGE\-LOCKS" "5" "July 2020" "" "" .SH "NAME" \fBpackage-locks\fR \- An explanation of npm lockfiles .SS Description diff --git a/deps/npm/man/man5/shrinkwrap-json.5 b/deps/npm/man/man5/shrinkwrap-json.5 index 227c7e87611217..83db8b8b59d028 100644 --- a/deps/npm/man/man5/shrinkwrap-json.5 +++ b/deps/npm/man/man5/shrinkwrap-json.5 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP\.JSON" "5" "May 2020" "" "" +.TH "NPM\-SHRINKWRAP\.JSON" "5" "July 2020" "" "" .SH "NAME" \fBnpm-shrinkwrap.json\fR \- A publishable lockfile .SS Description diff --git a/deps/npm/man/man7/config.7 b/deps/npm/man/man7/config.7 index db95234d49e24b..6319a913412f61 100644 --- a/deps/npm/man/man7/config.7 +++ b/deps/npm/man/man7/config.7 @@ -1,4 +1,4 @@ -.TH "CONFIG" "7" "May 2020" "" "" +.TH "CONFIG" "7" "July 2020" "" "" .SH "NAME" \fBconfig\fR \- More than you probably want to know about npm configuration .SS Description @@ -598,7 +598,7 @@ Type: Boolean .RE .P When "true" displays the message at the end of each \fBnpm install\fP -aknowledging the number of dependencies looking for funding\. +acknowledging the number of dependencies looking for funding\. See npm help \fBfund\fP for details\. .SS git .RS 0 diff --git a/deps/npm/man/man7/developers.7 b/deps/npm/man/man7/developers.7 index 942ce4b431a448..aeba674943092f 100644 --- a/deps/npm/man/man7/developers.7 +++ b/deps/npm/man/man7/developers.7 @@ -1,4 +1,4 @@ -.TH "DEVELOPERS" "7" "May 2020" "" "" +.TH "DEVELOPERS" "7" "July 2020" "" "" .SH "NAME" \fBdevelopers\fR \- Developer Guide .SS Description diff --git a/deps/npm/man/man7/disputes.7 b/deps/npm/man/man7/disputes.7 index 4c5a73a2e57771..e34955dc3861d0 100644 --- a/deps/npm/man/man7/disputes.7 +++ b/deps/npm/man/man7/disputes.7 @@ -1,4 +1,4 @@ -.TH "DISPUTES" "7" "May 2020" "" "" +.TH "DISPUTES" "7" "July 2020" "" "" .SH "NAME" \fBdisputes\fR \- Handling Module Name Disputes .P diff --git a/deps/npm/man/man7/orgs.7 b/deps/npm/man/man7/orgs.7 index b32c26c19cb3a0..da999a2ef5994e 100644 --- a/deps/npm/man/man7/orgs.7 +++ b/deps/npm/man/man7/orgs.7 @@ -1,4 +1,4 @@ -.TH "ORGS" "7" "May 2020" "" "" +.TH "ORGS" "7" "July 2020" "" "" .SH "NAME" \fBorgs\fR \- Working with Teams & Orgs .SS Description diff --git a/deps/npm/man/man7/registry.7 b/deps/npm/man/man7/registry.7 index 5de9a3e0968093..2a3f371224d1cb 100644 --- a/deps/npm/man/man7/registry.7 +++ b/deps/npm/man/man7/registry.7 @@ -1,4 +1,4 @@ -.TH "REGISTRY" "7" "May 2020" "" "" +.TH "REGISTRY" "7" "July 2020" "" "" .SH "NAME" \fBregistry\fR \- The JavaScript Package Registry .SS Description diff --git a/deps/npm/man/man7/removal.7 b/deps/npm/man/man7/removal.7 index 254a685ad2c24d..d04a5a975a378e 100644 --- a/deps/npm/man/man7/removal.7 +++ b/deps/npm/man/man7/removal.7 @@ -1,4 +1,4 @@ -.TH "REMOVAL" "7" "May 2020" "" "" +.TH "REMOVAL" "7" "July 2020" "" "" .SH "NAME" \fBremoval\fR \- Cleaning the Slate .SS Synopsis diff --git a/deps/npm/man/man7/scope.7 b/deps/npm/man/man7/scope.7 index 680125cf6d5c54..793e3d3e7ffa5d 100644 --- a/deps/npm/man/man7/scope.7 +++ b/deps/npm/man/man7/scope.7 @@ -1,4 +1,4 @@ -.TH "SCOPE" "7" "May 2020" "" "" +.TH "SCOPE" "7" "July 2020" "" "" .SH "NAME" \fBscope\fR \- Scoped packages .SS Description diff --git a/deps/npm/man/man7/scripts.7 b/deps/npm/man/man7/scripts.7 index f507049bc186fb..8c92a706428de6 100644 --- a/deps/npm/man/man7/scripts.7 +++ b/deps/npm/man/man7/scripts.7 @@ -1,4 +1,4 @@ -.TH "SCRIPTS" "7" "May 2020" "" "" +.TH "SCRIPTS" "7" "July 2020" "" "" .SH "NAME" \fBscripts\fR \- How npm handles the "scripts" field .SS Description diff --git a/deps/npm/man/man7/semver.7 b/deps/npm/man/man7/semver.7 index 7e8df25a356581..80b13a15dc8e21 100644 --- a/deps/npm/man/man7/semver.7 +++ b/deps/npm/man/man7/semver.7 @@ -1,4 +1,4 @@ -.TH "SEMVER" "7" "May 2020" "" "" +.TH "SEMVER" "7" "July 2020" "" "" .SH "NAME" \fBsemver\fR \- The semantic versioner for npm .SH Install diff --git a/deps/npm/node_modules/npm-registry-fetch/CHANGELOG.md b/deps/npm/node_modules/npm-registry-fetch/CHANGELOG.md index 75b74eec60144d..0340ab46e7acd5 100644 --- a/deps/npm/node_modules/npm-registry-fetch/CHANGELOG.md +++ b/deps/npm/node_modules/npm-registry-fetch/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [4.0.5](https://github.com/npm/registry-fetch/compare/v4.0.4...v4.0.5) (2020-06-30) + + + ## [4.0.4](https://github.com/npm/registry-fetch/compare/v4.0.3...v4.0.4) (2020-04-28) diff --git a/deps/npm/node_modules/npm-registry-fetch/check-response.js b/deps/npm/node_modules/npm-registry-fetch/check-response.js index 14058239ba3f5d..55139c93aff8d3 100644 --- a/deps/npm/node_modules/npm-registry-fetch/check-response.js +++ b/deps/npm/node_modules/npm-registry-fetch/check-response.js @@ -29,9 +29,19 @@ function logRequest (method, res, startTime, opts) { const attempt = res.headers.get('x-fetch-attempts') const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : '' const cacheStr = res.headers.get('x-local-cache') ? ' (from cache)' : '' + + let urlStr + try { + const URL = require('url') + const url = new URL(res.url) + urlStr = res.url.replace(url.password, '***') + } catch (er) { + urlStr = res.url + } + opts.log.http( 'fetch', - `${method.toUpperCase()} ${res.status} ${res.url} ${elapsedTime}ms${attemptStr}${cacheStr}` + `${method.toUpperCase()} ${res.status} ${urlStr} ${elapsedTime}ms${attemptStr}${cacheStr}` ) } diff --git a/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/README.md b/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/README.md index 356e3519302cfa..e9a81afd0406f0 100644 --- a/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/README.md +++ b/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/README.md @@ -22,8 +22,6 @@ npm install safe-buffer ``` -[Get supported safe-buffer with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-safe-buffer?utm_source=npm-safe-buffer&utm_medium=referral&utm_campaign=readme) - ## usage The goal of this package is to provide a safe replacement for the node.js `Buffer`. diff --git a/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/index.js b/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/index.js index 054c8d30ddafb4..f8d3ec98852f44 100644 --- a/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/index.js +++ b/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/index.js @@ -1,3 +1,4 @@ +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer diff --git a/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/package.json b/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/package.json index 576c453b23322b..5062922aecfe7c 100644 --- a/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/package.json +++ b/deps/npm/node_modules/npm-registry-fetch/node_modules/safe-buffer/package.json @@ -1,8 +1,8 @@ { "_from": "safe-buffer@^5.2.0", - "_id": "safe-buffer@5.2.0", + "_id": "safe-buffer@5.2.1", "_inBundle": false, - "_integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "_integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "_location": "/npm-registry-fetch/safe-buffer", "_phantomChildren": {}, "_requested": { @@ -18,14 +18,14 @@ "_requiredBy": [ "/npm-registry-fetch" ], - "_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "_shasum": "b74daec49b1148f88c64b68d49b1e815c1f2f519", + "_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "_shasum": "1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6", "_spec": "safe-buffer@^5.2.0", - "_where": "/Users/mperrotte/npminc/cli/node_modules/npm-registry-fetch", + "_where": "/Users/claudiahdz/npm/cli/node_modules/npm-registry-fetch", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", - "url": "http://feross.org" + "url": "https://feross.org" }, "bugs": { "url": "https://github.com/feross/safe-buffer/issues" @@ -35,8 +35,22 @@ "description": "Safer Node.js Buffer API", "devDependencies": { "standard": "*", - "tape": "^4.0.0" + "tape": "^5.0.0" }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "homepage": "https://github.com/feross/safe-buffer", "keywords": [ "buffer", @@ -58,5 +72,5 @@ "test": "standard && tape test/*.js" }, "types": "index.d.ts", - "version": "5.2.0" + "version": "5.2.1" } diff --git a/deps/npm/node_modules/npm-registry-fetch/package.json b/deps/npm/node_modules/npm-registry-fetch/package.json index c1582514e36e1e..8959c4c558a4d6 100644 --- a/deps/npm/node_modules/npm-registry-fetch/package.json +++ b/deps/npm/node_modules/npm-registry-fetch/package.json @@ -1,19 +1,19 @@ { - "_from": "npm-registry-fetch@4.0.4", - "_id": "npm-registry-fetch@4.0.4", + "_from": "npm-registry-fetch@4.0.5", + "_id": "npm-registry-fetch@4.0.5", "_inBundle": false, - "_integrity": "sha512-6jb34hX/iYNQebqWUHtU8YF6Cjb1H6ouTFPClYsyiW6lpFkljTpdeftm53rRojtja1rKAvKNIIiTS5Sjpw4wsA==", + "_integrity": "sha512-yQ0/U4fYpCCqmueB2g8sc+89ckQ3eXpmU4+Yi2j5o/r0WkKvE2+Y0tK3DEILAtn2UaQTkjTHxIXe2/CSdit+/Q==", "_location": "/npm-registry-fetch", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "npm-registry-fetch@4.0.4", + "raw": "npm-registry-fetch@4.0.5", "name": "npm-registry-fetch", "escapedName": "npm-registry-fetch", - "rawSpec": "4.0.4", + "rawSpec": "4.0.5", "saveSpec": null, - "fetchSpec": "4.0.4" + "fetchSpec": "4.0.5" }, "_requiredBy": [ "#USER", @@ -28,10 +28,10 @@ "/npm-profile", "/pacote" ], - "_resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-4.0.4.tgz", - "_shasum": "2da1ecf3f43d419d96abf313664291a4623d3ea5", - "_spec": "npm-registry-fetch@4.0.4", - "_where": "/Users/ruyadorno/Documents/workspace/cli", + "_resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-4.0.5.tgz", + "_shasum": "cb87cf7f25bfb048d6c3ee19d115bebf93ea5bfa", + "_spec": "npm-registry-fetch@4.0.5", + "_where": "/Users/claudiahdz/npm/cli", "author": { "name": "Kat Marchán", "email": "kzm@sykosomatic.org" @@ -102,5 +102,5 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "4.0.4" + "version": "4.0.5" } diff --git a/deps/npm/node_modules/spdx-license-ids/README.md b/deps/npm/node_modules/spdx-license-ids/README.md index c7b5b5f3208456..699514d1a28aa5 100644 --- a/deps/npm/node_modules/spdx-license-ids/README.md +++ b/deps/npm/node_modules/spdx-license-ids/README.md @@ -1,13 +1,13 @@ # spdx-license-ids -[![npm version](https://img.shields.io/npm/v/spdx-license-ids.svg)](https://www.npmjs.org/package/spdx-license-ids) -[![Build Status](https://travis-ci.org/shinnn/spdx-license-ids.svg?branch=master)](https://travis-ci.org/shinnn/spdx-license-ids) +[![npm version](https://img.shields.io/npm/v/spdx-license-ids.svg)](https://www.npmjs.com/package/spdx-license-ids) +[![Github Actions](https://action-badges.now.sh/shinnn/spdx-license-ids)](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/results/shinnn/spdx-license-ids) A list of [SPDX license](https://spdx.org/licenses/) identifiers ## Installation -[Download JSON directly](https://raw.githubusercontent.com/shinnn/spdx-license-ids/master/index.json), or [use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm): +[Download JSON directly](https://raw.githubusercontent.com/shinnn/spdx-license-ids/master/index.json), or [use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/): ``` npm install spdx-license-ids @@ -17,13 +17,13 @@ npm install spdx-license-ids ### require('spdx-license-ids') -Type: `>` +Type: `string[]` All license IDs except for the currently deprecated ones. ```javascript const ids = require('spdx-license-ids'); -//=> ['0BSD', 'AAL', 'Abstyles', 'Adobe-2006', 'Adobe-Glyph', 'ADSL', 'AFL-1.1', 'AFL-1.2', ...] +//=> ['0BSD', 'AAL', 'ADSL', 'AFL-1.1', 'AFL-1.2', 'AFL-2.0', 'AFL-2.1', 'AFL-3.0', 'AGPL-1.0-only', ...] ids.includes('BSD-3-Clause'); //=> true ids.includes('CC-BY-1.0'); //=> true @@ -33,13 +33,13 @@ ids.includes('GPL-3.0'); //=> false ### require('spdx-license-ids/deprecated') -Type: `>` +Type: `string[]` Deprecated license IDs. ```javascript const deprecatedIds = require('spdx-license-ids/deprecated'); -//=> ['AGPL-1.0', 'AGPL-3.0', 'eCos-2.0', 'GFDL-1.1', 'GFDL-1.2', 'GFDL-1.3', 'GPL-1.0', ...] +//=> ['AGPL-1.0', 'AGPL-3.0', 'GFDL-1.1', 'GFDL-1.2', 'GFDL-1.3', 'GPL-1.0', 'GPL-2.0', ...] deprecatedIds.includes('BSD-3-Clause'); //=> false deprecatedIds.includes('CC-BY-1.0'); //=> false diff --git a/deps/npm/node_modules/spdx-license-ids/index.json b/deps/npm/node_modules/spdx-license-ids/index.json index ed06199127e0ce..5283c78dc77c31 100644 --- a/deps/npm/node_modules/spdx-license-ids/index.json +++ b/deps/npm/node_modules/spdx-license-ids/index.json @@ -45,6 +45,7 @@ "BSD-3-Clause-No-Nuclear-License", "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause-No-Nuclear-Warranty", + "BSD-3-Clause-Open-MPI", "BSD-4-Clause", "BSD-4-Clause-UC", "BSD-Protection", @@ -55,6 +56,7 @@ "Beerware", "BitTorrent-1.0", "BitTorrent-1.1", + "BlueOak-1.0.0", "Borceux", "CATOSL-1.1", "CC-BY-1.0", @@ -87,6 +89,7 @@ "CC-BY-SA-2.5", "CC-BY-SA-3.0", "CC-BY-SA-4.0", + "CC-PDDC", "CC0-1.0", "CDDL-1.0", "CDDL-1.1", @@ -98,6 +101,8 @@ "CECILL-2.1", "CECILL-B", "CECILL-C", + "CERN-OHL-1.1", + "CERN-OHL-1.2", "CNRI-Jython", "CNRI-Python", "CNRI-Python-GPL-Compatible", @@ -152,6 +157,7 @@ "Glide", "Glulxe", "HPND", + "HPND-sell-variant", "HaskellReport", "IBM-pibs", "ICU", @@ -165,6 +171,7 @@ "Intel", "Intel-ACPI", "Interbase-1.0", + "JPNIC", "JSON", "JasPer-2.0", "LAL-1.2", @@ -265,6 +272,7 @@ "PDDL-1.0", "PHP-3.0", "PHP-3.01", + "Parity-6.0.0", "Plexus", "PostgreSQL", "Python-2.0", @@ -283,12 +291,15 @@ "SGI-B-1.0", "SGI-B-1.1", "SGI-B-2.0", + "SHL-0.5", + "SHL-0.51", "SISSL", "SISSL-1.2", "SMLNJ", "SMPPL", "SNIA", "SPL-1.0", + "SSPL-1.0", "SWL", "Saxpath", "Sendmail", @@ -299,6 +310,7 @@ "Spencer-94", "Spencer-99", "SugarCRM-1.1.3", + "TAPR-OHL-1.0", "TCL", "TCP-wrappers", "TMate", @@ -335,6 +347,7 @@ "Zimbra-1.3", "Zimbra-1.4", "Zlib", + "blessing", "bzip2-1.0.5", "bzip2-1.0.6", "copyleft-next-0.3.0", @@ -346,6 +359,7 @@ "gSOAP-1.3b", "gnuplot", "iMatix", + "libpng-2.0", "libtiff", "mpich2", "psfrag", diff --git a/deps/npm/node_modules/spdx-license-ids/package.json b/deps/npm/node_modules/spdx-license-ids/package.json index 84fd02c3d6022d..45cc6c3041aa71 100644 --- a/deps/npm/node_modules/spdx-license-ids/package.json +++ b/deps/npm/node_modules/spdx-license-ids/package.json @@ -1,19 +1,19 @@ { - "_from": "spdx-license-ids@3.0.3", - "_id": "spdx-license-ids@3.0.3", + "_from": "spdx-license-ids@3.0.5", + "_id": "spdx-license-ids@3.0.5", "_inBundle": false, - "_integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", + "_integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "_location": "/spdx-license-ids", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "spdx-license-ids@3.0.3", + "raw": "spdx-license-ids@3.0.5", "name": "spdx-license-ids", "escapedName": "spdx-license-ids", - "rawSpec": "3.0.3", + "rawSpec": "3.0.5", "saveSpec": null, - "fetchSpec": "3.0.3" + "fetchSpec": "3.0.5" }, "_requiredBy": [ "#USER", @@ -21,10 +21,10 @@ "/spdx-correct", "/spdx-expression-parse" ], - "_resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", - "_shasum": "81c0ce8f21474756148bbb5f3bfc0f36bf15d76e", - "_spec": "spdx-license-ids@3.0.3", - "_where": "/Users/zkat/Documents/code/work/npm", + "_resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "_shasum": "3694b5804567a458d3c8045842a6358632f62654", + "_spec": "spdx-license-ids@3.0.5", + "_where": "/home/kyle/cli", "author": { "name": "Shinnosuke Watanabe", "url": "https://github.com/shinnn" @@ -73,5 +73,5 @@ "pretest": "eslint .", "test": "node test.js" }, - "version": "3.0.3" + "version": "3.0.5" } diff --git a/deps/npm/package.json b/deps/npm/package.json index bfbed9ea0bab43..ea8deeb01e5ca8 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "6.14.5", + "version": "6.14.6", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -104,7 +104,7 @@ "npm-packlist": "^1.4.8", "npm-pick-manifest": "^3.0.2", "npm-profile": "^4.0.4", - "npm-registry-fetch": "^4.0.4", + "npm-registry-fetch": "^4.0.5", "npm-user-validate": "~1.0.0", "npmlog": "~4.1.2", "once": "~1.4.0", diff --git a/deps/npm/test/fixtures/config/userconfig-with-gc b/deps/npm/test/fixtures/config/userconfig-with-gc deleted file mode 100644 index 866f78dab61ce5..00000000000000 --- a/deps/npm/test/fixtures/config/userconfig-with-gc +++ /dev/null @@ -1,23 +0,0 @@ -globalconfig = /Users/ruyadorno/Documents/workspace/cli/test/fixtures/config/globalconfig -email = i@izs.me -env-thing = ${random_env_var} -init.author.name = Isaac Z. Schlueter -init.author.email = i@izs.me -init.author.url = http://blog.izs.me/ -init.version = 1.2.3 -npm:publishtest = true -_npmjs.org:couch = https://admin:password@localhost:5984/registry -npm-www:nocache = 1 -nodedir = /Users/isaacs/dev/js/node-v0.8 -sign-git-tag = true -message = v%s -strict-ssl = false -tmp = ~/.tmp -_auth = dXNlcm5hbWU6cGFzc3dvcmQ= - -[_token] -AuthSession = yabba-dabba-doodle -version = 1 -expires = 1345001053415 -path = / -httponly = true diff --git a/deps/npm/test/tap/doctor-ping-registry-404.js b/deps/npm/test/tap/doctor-ping-registry-404.js new file mode 100644 index 00000000000000..00a772a7c0dac3 --- /dev/null +++ b/deps/npm/test/tap/doctor-ping-registry-404.js @@ -0,0 +1,108 @@ +'use strict' +/* eslint-disable camelcase */ +const common = require('../common-tap.js') +const http = require('http') +const mr = require('npm-registry-mock') +const npm = require('../../lib/npm.js') +const path = require('path') +const Tacks = require('tacks') +const t = require('tap') +const which = require('which') + +const Dir = Tacks.Dir +const File = Tacks.File + +const ROOT = common.pkg +const CACHE = common.cache +const TMP = path.join(ROOT, 'tmp') +const PREFIX = path.join(ROOT, 'global-prefix') +const PKG = path.join(ROOT, 'pkg') + +let server, nodeServer +let node_url + +t.teardown(() => { + if (server) { + server.close() + } + if (nodeServer) { + nodeServer.close() + } +}) + +t.test('setup', (t) => { + const port = common.port + 2 + nodeServer = http.createServer(function (q, s) { + s.end(JSON.stringify([{ lts: true, version: '0.0.0' }])) + }) + nodeServer.listen(port, () => { + node_url = 'http://localhost:' + port + mr({ port: common.port }, (err, s) => { + t.ifError(err, 'registry mocked successfully') + server = s + server.get('/-/ping?write=true').reply(404) + server.get('/npm').reply( + 200, + JSON.stringify({ + name: 'npm', + 'dist-tags': { latest: '0.0.0' }, + versions: { + '0.0.0': { + name: 'npm', + version: '0.0.0', + _shrinkwrap: null, + _hasShrinkwrap: false, + dist: { + shasum: 'deadbeef', + tarball: 'https://reg.eh/npm-0.0.0.tgz' + } + } + } + }) + ) + const fixture = new Tacks( + Dir({ + [path.basename(PKG)]: Dir({ + 'package.json': File({ name: 'npm', version: '0.0.0' }) + }), + [path.basename(PREFIX)]: Dir({}) + }) + ) + fixture.create(ROOT) + npm.load( + { + registry: common.registry, + loglevel: 'silent', + cache: CACHE, + tmp: TMP, + prefix: PREFIX + }, + (err) => { + t.ifError(err, 'npm loaded successfully') + t.pass('all set up') + t.done() + } + ) + }) + }) +}) + +t.test('npm doctor ping returns 404 (or any other error)', function (t) { + npm.commands.doctor({ 'node-url': node_url }, true, function (e, list) { + t.ifError(e, 'npm loaded successfully') + t.same(list.length, 9, 'list should have 9 prop') + t.same(list[0][1], 'failed', 'npm ping') + t.same(list[1][1], 'v' + npm.version, 'npm -v') + t.same(list[2][1], process.version, 'node -v') + t.same(list[3][1], common.registry + '/', 'npm config get registry') + t.same(list[5][1], 'ok', 'Perms check on cached files') + t.same(list[6][1], 'ok', 'Perms check on global node_modules') + t.same(list[7][1], 'ok', 'Perms check on local node_modules') + t.match(list[8][1], /^verified \d+ tarballs?$/, 'Cache verified') + which('git', function (e, resolvedPath) { + t.ifError(e, 'git command is installed') + t.same(list[4][1], resolvedPath, 'which git') + t.done() + }) + }) +}) diff --git a/deps/uvwasi/src/poll_oneoff.c b/deps/uvwasi/src/poll_oneoff.c index 97b8ef332da71f..a4b1c3c84282fa 100644 --- a/deps/uvwasi/src/poll_oneoff.c +++ b/deps/uvwasi/src/poll_oneoff.c @@ -114,6 +114,8 @@ uvwasi_errno_t uvwasi__poll_oneoff_state_cleanup( for (i = 0; i < state->handle_cnt; i++) uv_close((uv_handle_t*) &state->poll_handles[i], NULL); + uv_run(&state->loop, UV_RUN_NOWAIT); + state->max_fds = 0; state->fdevent_cnt = 0; state->handle_cnt = 0; diff --git a/doc/api/addons.md b/doc/api/addons.md index ffbecb02d8ff4d..9a2b6d1a536359 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -1,4 +1,4 @@ -# C++ Addons +# C++ addons @@ -15,7 +15,7 @@ Refer to [C/C++ Addons with N-API](n-api.html) for more information on N-API. When not using N-API, implementing Addons is complicated, involving knowledge of several components and APIs: -* V8: the C++ library Node.js currently uses to provide the +* V8: the C++ library Node.js uses to provide the JavaScript implementation. V8 provides the mechanisms for creating objects, calling functions, etc. V8's API is documented mostly in the `v8.h` header file (`deps/v8/include/v8.h` in the Node.js source @@ -157,11 +157,11 @@ The context-aware addon can be structured to avoid global static data by performing the following steps: * Define a class which will hold per-addon-instance data and which has a static member of the form - ```C++ - static void DeleteInstance(void* data) { - // Cast `data` to an instance of the class and delete it. - } - ``` + ```cpp + static void DeleteInstance(void* data) { + // Cast `data` to an instance of the class and delete it. + } + ``` * Heap-allocate an instance of this class in the addon initializer. This can be accomplished using the `new` keyword. * Call `node::AddEnvironmentCleanupHook()`, passing it the above-created @@ -245,7 +245,7 @@ In order to support [`Worker`][] threads, addons need to clean up any resources they may have allocated when such a thread exists. This can be achieved through the usage of the `AddEnvironmentCleanupHook()` function: -```c++ +```cpp void AddEnvironmentCleanupHook(v8::Isolate* isolate, void (*fun)(void* arg), void* arg); @@ -395,7 +395,7 @@ only the symbols exported by Node.js will be available. source image. Using this option, the Addon will have access to the full set of dependencies. -### Loading Addons using `require()` +### Loading addons using `require()` The filename extension of the compiled Addon binary is `.node` (as opposed to `.dll` or `.so`). The [`require()`][require] function is written to look for @@ -410,7 +410,7 @@ there is a file `addon.js` in the same directory as the binary `addon.node`, then [`require('addon')`][require] will give precedence to the `addon.js` file and load it instead. -## Native Abstractions for Node.js +## Native abstractions for Node.js Each of the examples illustrated in this document make direct use of the Node.js and V8 APIs for implementing Addons. The V8 API can, and has, changed @@ -418,7 +418,7 @@ dramatically from one V8 release to the next (and one major Node.js release to the next). With each change, Addons may need to be updated and recompiled in order to continue functioning. The Node.js release schedule is designed to minimize the frequency and impact of such changes but there is little that -Node.js can do currently to ensure stability of the V8 APIs. +Node.js can do to ensure stability of the V8 APIs. The [Native Abstractions for Node.js][] (or `nan`) provide a set of tools that Addon developers are recommended to use to keep compatibility between past and diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 034879316aae06..d7182f43f45288 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -1,4 +1,4 @@ -# Async Hooks +# Async hooks @@ -127,7 +127,7 @@ class MyAddedCallbacks extends MyAsyncCallbacks { const asyncHook = async_hooks.createHook(new MyAddedCallbacks()); ``` -##### Error Handling +##### Error handling If any `AsyncHook` callbacks throw, the application will print the stack trace and exit. The exit path does follow that of an uncaught exception, but @@ -201,7 +201,7 @@ be called again until enabled. For API consistency `disable()` also returns the `AsyncHook` instance. -#### Hook Callbacks +#### Hook callbacks Key events in the lifetime of asynchronous events have been categorized into four areas: instantiation, before/after the callback is called, and when the @@ -512,7 +512,7 @@ createHook({ } }).enable(); -const server = createServer(function(req, res) { +const server = createServer((req, res) => { executionAsyncResource()[sym] = { state: req.url }; setTimeout(function() { res.end(JSON.stringify(executionAsyncResource()[sym])); @@ -631,7 +631,7 @@ only on chained promises. That means promises not created by `then()`/`catch()` will not have the `before` and `after` callbacks fired on them. For more details see the details of the V8 [PromiseHooks][] API. -## JavaScript Embedder API +## JavaScript embedder API Library developers that handle their own asynchronous resources performing tasks like I/O, connection pooling, or managing callback queues may use the @@ -867,6 +867,31 @@ for (let i = 0; i < 10; i++) { } ``` +### Integrating `AsyncResource` with `EventEmitter` + +Event listeners triggered by an [`EventEmitter`][] may be run in a different +execution context than the one that was active when `eventEmitter.on()` was +called. + +The following example shows how to use the `AsyncResource` class to properly +associate an event listener with the correct execution context. The same +approach can be applied to a [`Stream`][] or a similar event-driven class. + +```js +const { createServer } = require('http'); +const { AsyncResource, executionAsyncId } = require('async_hooks'); + +const server = createServer((req, res) => { + const asyncResource = new AsyncResource('request'); + // The listener will always run in the execution context of `asyncResource`. + req.on('close', asyncResource.runInAsyncScope.bind(asyncResource, () => { + // Prints: true + console.log(asyncResource.asyncId() === executionAsyncId()); + })); + res.end(); +}).listen(3000); +``` + ## Class: `AsyncLocalStorage` * `object` {Object} An object supporting `Symbol.toPrimitive` or `valueOf()`. -* `offsetOrEncoding` {integer|string} A byte-offset or encoding, depending on - the value returned either by `object.valueOf()` or - `object[Symbol.toPrimitive]()`. -* `length` {integer} A length, depending on the value returned either by - `object.valueOf()` or `object[Symbol.toPrimitive]()`. +* `offsetOrEncoding` {integer|string} A byte-offset or encoding. +* `length` {integer} A length. For objects whose `valueOf()` function returns a value not strictly equal to `object`, returns `Buffer.from(object.valueOf(), offsetOrEncoding, length)`. @@ -672,7 +669,7 @@ const buf = Buffer.from(new String('this is a test')); ``` For objects that support `Symbol.toPrimitive`, returns -`Buffer.from(object[Symbol.toPrimitive](), offsetOrEncoding, length)`. +`Buffer.from(object[Symbol.toPrimitive]('string'), offsetOrEncoding)`. ```js class Foo { @@ -2635,7 +2632,7 @@ deprecated: v6.0.0 See [`Buffer.allocUnsafeSlow()`][]. -## Buffer Constants +## Buffer constants @@ -2703,7 +2700,7 @@ it allows injection of numbers where a naively written application that does not validate its input sufficiently might expect to always receive a string. Before Node.js 8.0.0, the 100 byte buffer might contain arbitrary pre-existing in-memory data, so may be used to expose in-memory -secrets to a remote attacker. Since Node.js 8.0.0, exposure of memory cannot +secrets to a remote attacker. Since Node.js 8.0.0, exposure of memory cannot occur because the data is zero-filled. However, other attacks are still possible, such as causing very large buffers to be allocated by the server, leading to performance degradation or crashing on memory exhaustion. diff --git a/doc/api/child_process.md b/doc/api/child_process.md index d5812c3975486b..f09768573e3142 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1,4 +1,4 @@ -# Child Process +# Child process @@ -70,7 +70,7 @@ For certain use cases, such as automating shell scripts, the the synchronous methods can have significant impact on performance due to stalling the event loop while spawned processes complete. -## Asynchronous Process Creation +## Asynchronous process creation The [`child_process.spawn()`][], [`child_process.fork()`][], [`child_process.exec()`][], and [`child_process.execFile()`][] methods all follow the idiomatic asynchronous @@ -153,7 +153,7 @@ changes: * `env` {Object} Environment key-value pairs. **Default:** `process.env`. * `encoding` {string} **Default:** `'utf8'` * `shell` {string} Shell to execute the command with. See - [Shell Requirements][] and [Default Windows Shell][]. **Default:** + [Shell requirements][] and [Default Windows shell][]. **Default:** `'/bin/sh'` on Unix, `process.env.ComSpec` on Windows. * `timeout` {number} **Default:** `0` * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or @@ -270,8 +270,8 @@ changes: done on Windows. Ignored on Unix. **Default:** `false`. * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different - shell can be specified as a string. See [Shell Requirements][] and - [Default Windows Shell][]. **Default:** `false` (no shell). + shell can be specified as a string. See [Shell requirements][] and + [Default Windows shell][]. **Default:** `false` (no shell). * `callback` {Function} Called with the output when process terminates. * `error` {Error} * `stdout` {string|Buffer} @@ -347,13 +347,13 @@ changes: * `detached` {boolean} Prepare child to run independently of its parent process. Specific behavior depends on the platform, see [`options.detached`][]). - * `env` {Object} Environment key-value pairs. **Default:** `process.env`. + * `env` {Object} Environment key-value pairs. **Default:** `process.env`. * `execPath` {string} Executable used to create the child process. * `execArgv` {string[]} List of string arguments passed to the executable. **Default:** `process.execArgv`. * `serialization` {string} Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. - See [Advanced Serialization][] for more details. **Default:** `'json'`. + See [Advanced serialization][] for more details. **Default:** `'json'`. * `silent` {boolean} If `true`, stdin, stdout, and stderr of the child will be piped to the parent, otherwise they will be inherited from the parent, see the `'pipe'` and `'inherit'` options for [`child_process.spawn()`][]'s @@ -430,11 +430,11 @@ changes: * `gid` {number} Sets the group identity of the process (see setgid(2)). * `serialization` {string} Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. - See [Advanced Serialization][] for more details. **Default:** `'json'`. + See [Advanced serialization][] for more details. **Default:** `'json'`. * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different - shell can be specified as a string. See [Shell Requirements][] and - [Default Windows Shell][]. **Default:** `false` (no shell). + shell can be specified as a string. See [Shell requirements][] and + [Default Windows shell][]. **Default:** `false` (no shell). * `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to `true` automatically when `shell` is specified and is CMD. **Default:** `false`. @@ -695,7 +695,7 @@ see [V8 issue 7381](https://bugs.chromium.org/p/v8/issues/detail?id=7381). See also: [`child_process.exec()`][] and [`child_process.fork()`][]. -## Synchronous Process Creation +## Synchronous process creation The [`child_process.spawnSync()`][], [`child_process.execSync()`][], and [`child_process.execFileSync()`][] methods are synchronous and will block the @@ -735,7 +735,7 @@ changes: * `stdio` {string|Array} Child's stdio configuration. `stderr` by default will be output to the parent process' stderr unless `stdio` is specified. **Default:** `'pipe'`. - * `env` {Object} Environment key-value pairs. **Default:** `process.env`. + * `env` {Object} Environment key-value pairs. **Default:** `process.env`. * `uid` {number} Sets the user identity of the process (see setuid(2)). * `gid` {number} Sets the group identity of the process (see setgid(2)). * `timeout` {number} In milliseconds the maximum amount of time the process @@ -751,8 +751,8 @@ changes: normally be created on Windows systems. **Default:** `false`. * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different - shell can be specified as a string. See [Shell Requirements][] and - [Default Windows Shell][]. **Default:** `false` (no shell). + shell can be specified as a string. See [Shell requirements][] and + [Default Windows shell][]. **Default:** `false` (no shell). * Returns: {Buffer|string} The stdout from the command. The `child_process.execFileSync()` method is generally identical to @@ -800,7 +800,7 @@ changes: **Default:** `'pipe'`. * `env` {Object} Environment key-value pairs. **Default:** `process.env`. * `shell` {string} Shell to execute the command with. See - [Shell Requirements][] and [Default Windows Shell][]. **Default:** + [Shell requirements][] and [Default Windows shell][]. **Default:** `'/bin/sh'` on Unix, `process.env.ComSpec` on Windows. * `uid` {number} Sets the user identity of the process. (See setuid(2)). * `gid` {number} Sets the group identity of the process. (See setgid(2)). @@ -865,7 +865,7 @@ changes: * `argv0` {string} Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` if not specified. * `stdio` {string|Array} Child's stdio configuration. - * `env` {Object} Environment key-value pairs. **Default:** `process.env`. + * `env` {Object} Environment key-value pairs. **Default:** `process.env`. * `uid` {number} Sets the user identity of the process (see setuid(2)). * `gid` {number} Sets the group identity of the process (see setgid(2)). * `timeout` {number} In milliseconds the maximum amount of time the process @@ -880,8 +880,8 @@ changes: **Default:** `'buffer'`. * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different - shell can be specified as a string. See [Shell Requirements][] and - [Default Windows Shell][]. **Default:** `false` (no shell). + shell can be specified as a string. See [Shell requirements][] and + [Default Windows shell][]. **Default:** `false` (no shell). * `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to `true` automatically when `shell` is specified and is CMD. **Default:** `false`. @@ -1021,7 +1021,7 @@ message might not be the same as what is originally sent. If the `serialization` option was set to `'advanced'` used when spawning the child process, the `message` argument can contain data that JSON is not able to represent. -See [Advanced Serialization][] for more details. +See [Advanced serialization][] for more details. ### `subprocess.channel` @@ -1553,7 +1553,7 @@ Therefore, this feature requires opting in by setting the `serialization` option to `'advanced'` when calling [`child_process.spawn()`][] or [`child_process.fork()`][]. -[Advanced Serialization]: #child_process_advanced_serialization +[Advanced serialization]: #child_process_advanced_serialization [`'disconnect'`]: process.html#process_event_disconnect [`'error'`]: #child_process_event_error [`'exit'`]: #child_process_event_exit @@ -1586,8 +1586,8 @@ or [`child_process.fork()`][]. [`subprocess.stdio`]: #child_process_subprocess_stdio [`subprocess.stdout`]: #child_process_subprocess_stdout [`util.promisify()`]: util.html#util_util_promisify_original -[Default Windows Shell]: #child_process_default_windows_shell +[Default Windows shell]: #child_process_default_windows_shell [HTML structured clone algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[Shell Requirements]: #child_process_shell_requirements +[Shell requirements]: #child_process_shell_requirements [synchronous counterparts]: #child_process_synchronous_process_creation [v8.serdes]: v8.html#v8_serialization_api diff --git a/doc/api/cli.md b/doc/api/cli.md index 5dd5ae404b4cec..27ab46d5553ac5 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1,4 +1,4 @@ -# Command Line Options +# Command line options @@ -160,7 +160,7 @@ added: v12.12.0 > Stability: 1 - Experimental -Enable experimental Source Map V3 support for stack traces. +Enable experimental Source Map v3 support for stack traces. Currently, overriding `Error.prepareStackTrace` is ignored when the `--enable-source-maps` flag is set. @@ -241,6 +241,13 @@ Enable experimental WebAssembly System Interface (WASI) support. added: v12.3.0 --> +### `--force-context-aware` + + +Disable loading native addons that are not [context-aware][]. + Enable experimental WebAssembly module support. ### `--force-fips` @@ -495,13 +502,6 @@ added: v6.0.0 Silence all process warnings (including deprecations). -### `--force-context-aware` - - -Disable loading native addons that are not [context-aware][]. - ### `--openssl-config=file` @@ -415,13 +415,13 @@ if (cluster.isMaster) { } ``` -### `worker.kill([signal='SIGTERM'])` +### `worker.kill([signal])` * `signal` {string} Name of the kill signal to send to the worker - process. + process. **Default**: `'SIGTERM'` This function will kill the worker. In the master, it does this by disconnecting the `worker.process`, and once disconnected, killing with `signal`. In the @@ -751,7 +751,7 @@ changes: `undefined` (inherits from parent process). * `serialization` {string} Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. - See [Advanced Serialization for `child_process`][] for more details. + See [Advanced serialization for `child_process`][] for more details. **Default:** `false`. * `silent` {boolean} Whether or not to send output to parent's stdio. **Default:** `false`. @@ -881,5 +881,5 @@ socket.on('data', (id) => { [`process` event: `'message'`]: process.html#process_event_message [`server.close()`]: net.html#net_event_close [`worker.exitedAfterDisconnect`]: #cluster_worker_exitedafterdisconnect -[Advanced Serialization for `child_process`]: child_process.html#child_process_advanced_serialization +[Advanced serialization for `child_process`]: child_process.html#child_process_advanced_serialization [Child Process module]: child_process.html#child_process_child_process_fork_modulepath_args_options diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 6d6d75e3335778..3076bdaa5e5028 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1577,7 +1577,7 @@ added: v6.3.0 * Returns: {Object} An object containing commonly used constants for crypto and security related operations. The specific constants currently defined are - described in [Crypto Constants][]. + described in [Crypto constants][]. ### `crypto.DEFAULT_ENCODING` @@ -6,7 +6,7 @@ -The `dgram` module provides an implementation of UDP Datagram sockets. +The `dgram` module provides an implementation of UDP datagram sockets. ```js const dgram = require('dgram'); @@ -550,7 +550,7 @@ also use explicit scope in addresses, so only packets sent to a multicast address without specifying an explicit scope are affected by the most recent successful use of this call. -#### Examples: IPv6 Outgoing Multicast Interface +#### Example: IPv6 outgoing multicast interface On most systems, where scope format uses the interface name: @@ -572,7 +572,7 @@ socket.bind(1234, () => { }); ``` -#### Example: IPv4 Outgoing Multicast Interface +#### Example: IPv4 outgoing multicast interface All systems use an IP of the host on the desired physical interface: ```js @@ -583,7 +583,7 @@ socket.bind(1234, () => { }); ``` -#### Call Results +#### Call results A call on a socket that is not ready to send or no longer open may throw a *Not running* [`Error`][]. diff --git a/doc/api/dns.md b/doc/api/dns.md index 4467b53b94b8f4..3ab77f7c057b21 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -10,9 +10,8 @@ addresses of host names. Although named for the [Domain Name System (DNS)][], it does not always use the DNS protocol for lookups. [`dns.lookup()`][] uses the operating system facilities to perform name resolution. It may not need to perform any network -communication. Developers looking to perform name resolution in the same way -that other applications on the same operating system behave should use -[`dns.lookup()`][]. +communication. To perform name resolution the way other applications on the same +system do, use [`dns.lookup()`][]. ```js const dns = require('dns'); @@ -26,9 +25,8 @@ dns.lookup('example.org', (err, address, family) => { All other functions in the `dns` module connect to an actual DNS server to perform name resolution. They will always use the network to perform DNS queries. These functions do not use the same set of configuration files used by -[`dns.lookup()`][] (e.g. `/etc/hosts`). These functions should be used by -developers who do not want to use the underlying operating system's -facilities for name resolution, and instead want to always perform DNS queries. +[`dns.lookup()`][] (e.g. `/etc/hosts`). Use these functions to always perform +DNS queries, bypassing other name-resolution facilities. ```js const dns = require('dns'); @@ -92,6 +90,22 @@ The following methods from the `dns` module are available: * [`resolver.reverse()`][`dns.reverse()`] * [`resolver.setServers()`][`dns.setServers()`] +### `Resolver([options])` + + +Create a new resolver. + +* `options` {Object} + * `timeout` {integer} Query timeout in milliseconds, or `-1` to use the + default timeout. + ### `resolver.cancel()` @@ -12,7 +12,7 @@ Node.js is a JavaScript runtime built on the [V8 JavaScript engine][]. Report errors in this documentation in [the issue tracker][]. See [the contributing guide][] for directions on how to submit pull requests. -## Stability Index +## Stability index @@ -43,7 +43,7 @@ Bugs or behavior changes may surprise end users when Experimental API modifications occur. To avoid surprises, use of an Experimental feature may need a command-line flag. Experimental features may also emit a [warning][]. -## JSON Output +## JSON output diff --git a/doc/api/domain.md b/doc/api/domain.md index fa3aef66b98241..b9219fbb4d714e 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -30,7 +30,7 @@ will be notified, rather than losing the context of the error in the `process.on('uncaughtException')` handler, or causing the program to exit immediately with an error code. -## Warning: Don't Ignore Errors! +## Warning: Don't ignore errors! @@ -199,7 +199,7 @@ are added to it. * `error.domainThrown` A boolean indicating whether the error was thrown, emitted, or passed to a bound callback function. -## Implicit Binding +## Implicit binding @@ -225,7 +225,7 @@ Implicit binding routes thrown errors and `'error'` events to the `Domain`. Implicit binding only takes care of thrown errors and `'error'` events. -## Explicit Binding +## Explicit binding @@ -432,9 +432,9 @@ d.run(() => { In this example, the `d.on('error')` handler will be triggered, rather than crashing the program. -## Domains and Promises +## Domains and promises -As of Node.js 8.0.0, the handlers of Promises are run inside the domain in +As of Node.js 8.0.0, the handlers of promises are run inside the domain in which the call to `.then()` or `.catch()` itself was made: ```js @@ -472,7 +472,7 @@ d2.run(() => { ``` Domains will not interfere with the error handling mechanisms for -Promises. In other words, no `'error'` event will be emitted for unhandled +promises. In other words, no `'error'` event will be emitted for unhandled `Promise` rejections. [`Error`]: errors.html#errors_class_error diff --git a/doc/api/errors.md b/doc/api/errors.md index 51239ab0b224b4..672f8d20b2fb94 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -16,11 +16,11 @@ errors: Node.js detects an exceptional logic violation that should never occur. These are raised typically by the `assert` module. -All JavaScript and System errors raised by Node.js inherit from, or are +All JavaScript and system errors raised by Node.js inherit from, or are instances of, the standard JavaScript {Error} class and are guaranteed to provide *at least* the properties available on that class. -## Error Propagation and Interception +## Error propagation and interception @@ -186,7 +186,7 @@ circumstance of why the error occurred. `Error` objects capture a "stack trace" detailing the point in the code at which the `Error` was instantiated, and may provide a text description of the error. -All errors generated by Node.js, including all System and JavaScript errors, +All errors generated by Node.js, including all system and JavaScript errors, will either be instances of, or inherit from, the `Error` class. ### `new Error(message)` @@ -258,7 +258,7 @@ not capture any frames. The `error.code` property is a string label that identifies the kind of error. `error.code` is the most stable way to identify an error. It will only change between major versions of Node.js. In contrast, `error.message` strings may -change between any versions of Node.js. See [Node.js Error Codes][] for details +change between any versions of Node.js. See [Node.js error codes][] for details about specific codes. ### `error.message` @@ -285,7 +285,7 @@ console.error(err.message); The `error.stack` property is a string describing the point in the code at which the `Error` was instantiated. -```txt +```console Error: Things keep happening! at /home/gbusey/file.js:525:2 at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21) @@ -495,7 +495,7 @@ If present, `error.port` is the network connection port that is not available. The `error.syscall` property is a string describing the [syscall][] that failed. -### Common System Errors +### Common system errors This is a list of system errors commonly-encountered when writing a Node.js program. For a comprehensive list, see the [`errno`(3) man page][]. @@ -572,7 +572,7 @@ require('url').parse(() => { }); Node.js will generate and throw `TypeError` instances *immediately* as a form of argument validation. -## Exceptions vs. Errors +## Exceptions vs. errors @@ -586,7 +586,7 @@ Some exceptions are *unrecoverable* at the JavaScript layer. Such exceptions will *always* cause the Node.js process to crash. Examples include `assert()` checks or `abort()` calls in the C++ layer. -## OpenSSL Errors +## OpenSSL errors Errors originating in `crypto` or `tls` are of class `Error`, and in addition to the standard `.code` and `.message` properties, may have some additional @@ -610,7 +610,7 @@ The OpenSSL library the error originates in. A human-readable string describing the reason for the error. -## Node.js Error Codes +## Node.js error codes ### `ERR_AMBIGUOUS_ARGUMENT` @@ -1209,6 +1209,13 @@ time. The `--input-type` flag was used to attempt to execute a file. This flag can only be used with input via `--eval`, `--print` or `STDIN`. + +### `ERR_INSPECTOR_ALREADY_ACTIVATED` + +While using the `inspector` module, an attempt was made to activate the +inspector when it already started to listen on a port. Use `inspector.close()` +before activating it on a different address. + ### `ERR_INSPECTOR_ALREADY_CONNECTED` @@ -2183,7 +2190,7 @@ changes: A module file could not be resolved while attempting a [`require()`][] or `import` operation. -## Legacy Node.js Error Codes +## Legacy Node.js error codes > Stability: 0 - Deprecated. These error codes are either inconsistent, or have > been removed. @@ -2562,7 +2569,7 @@ such as `process.stdout.on('data')`. [`zlib`]: zlib.html [ES Module]: esm.html [ICU]: intl.html#intl_internationalization_support -[Node.js Error Codes]: #nodejs-error-codes +[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 diff --git a/doc/api/esm.md b/doc/api/esm.md index faa62b1fb87f1e..d5c1a66bccc0c3 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1,4 +1,4 @@ -# ECMAScript Modules +# ECMAScript modules @@ -94,7 +94,7 @@ until the root of the volume is reached. } ``` -```sh +```bash # In same folder as above package.json node my-app.js # Runs as ES module ``` @@ -121,7 +121,7 @@ files in the package should be interpreted. Regardless of the value of the `"type"` field, `.mjs` files are always treated as ES modules and `.cjs` files are always treated as CommonJS. -### Package Scope and File Extensions +### Package scope and file extensions A folder containing a `package.json` file, and all subfolders below that folder down until the next folder containing another `package.json`, is considered a @@ -184,7 +184,7 @@ Strings passed in as an argument to `--eval` or `--print` (or `-e` or `-p`), or piped to `node` via `STDIN`, will be treated as ES modules when the `--input-type=module` flag is set. -```sh +```bash node --input-type=module --eval "import { sep } from 'path'; console.log(sep);" echo "import { sep } from 'path'; console.log(sep);" | node --input-type=module @@ -196,7 +196,7 @@ unspecified. ## Packages -### Package Entry Points +### Package entry points In a package’s `package.json` file, two fields can define entry points for a package: `"main"` and `"exports"`. The `"main"` field is supported in all @@ -216,7 +216,7 @@ CommonJS; `"main"` will be overridden by `"exports"` if it exists. As such fallback for legacy versions of Node.js that do not support the `"exports"` field. -[Conditional Exports][] can be used within `"exports"` to define different +[Conditional exports][] can be used within `"exports"` to define different package entry points per environment, including whether the package is referenced via `require` or via `import`. For more information about supporting both CommonJS and ES Modules in a single package please consult @@ -274,7 +274,7 @@ will encapsulation be lost but module consumers will be unable to `import feature from 'my-mod/feature'` as they will need to provide the full path `import feature from 'my-mod/feature/index.js`. -#### Main Entry Point Export +#### Main entry point export To set the main entry point for a package, it is advisable to define both `"exports"` and `"main"` in the package’s `package.json` file: @@ -298,7 +298,7 @@ package. It is not a strong encapsulation since a direct require of any absolute subpath of the package such as `require('/path/to/node_modules/pkg/subpath.js')` will still load `subpath.js`. -#### Subpath Exports +#### Subpath exports When using the `"exports"` field, custom subpaths can be defined along with the main entry point by treating the main entry point as the @@ -355,7 +355,7 @@ module inside the subfolder. Any modules which are not public should be moved to another folder to retain the encapsulation benefits of exports. -#### Package Exports Fallbacks +#### Package exports fallbacks For possible new specifier support in future, array fallbacks are supported for all invalid specifiers: @@ -372,7 +372,7 @@ supported for all invalid specifiers: Since `"not:valid"` is not a valid specifier, `"./submodule.js"` is used instead as the fallback, as if it were the only target. -#### Exports Sugar +#### Exports sugar If the `"."` export is the only export, the `"exports"` field provides sugar for this case being the direct `"exports"` field value. @@ -398,7 +398,7 @@ can be written: } ``` -#### Conditional Exports +#### Conditional exports Conditional exports provide a way to map to different paths depending on certain conditions. They are supported for both CommonJS and ES module imports. @@ -536,7 +536,7 @@ and in a CommonJS one. For example, this code will also work: const { something } = require('a-package/foo'); // Loads from ./foo.js. ``` -### Dual CommonJS/ES Module Packages +### Dual CommonJS/ES module packages Prior to the introduction of support for ES modules in Node.js, it was a common pattern for package authors to include both CommonJS and ES module JavaScript @@ -549,12 +549,12 @@ ignores) the top-level `"module"` field. Node.js can now run ES module entry points, and a package can contain both CommonJS and ES module entry points (either via separate specifiers such as `'pkg'` and `'pkg/es-module'`, or both at the same specifier via [Conditional -Exports][]). Unlike in the scenario where `"module"` is only used by bundlers, +exports][]). Unlike in the scenario where `"module"` is only used by bundlers, or ES module files are transpiled into CommonJS on the fly before evaluation by Node.js, the files referenced by the ES module entry point are evaluated as ES modules. -#### Dual Package Hazard +#### Dual package hazard When an application is using a package that provides both CommonJS and ES module sources, there is a risk of certain bugs if both versions of the package get @@ -577,7 +577,7 @@ all-CommonJS or all-ES module environments, respectively, and therefore is surprising to users. It also differs from the behavior users are familiar with when using transpilation via tools like [Babel][] or [`esm`][]. -#### Writing Dual Packages While Avoiding or Minimizing Hazards +#### Writing dual packages while avoiding or minimizing hazards First, the hazard described in the previous section occurs when a package contains both CommonJS and ES module sources and both sources are provided for @@ -607,11 +607,11 @@ following conditions: browsers. 1. The hazards described in the previous section are avoided or minimized. -##### Approach #1: Use an ES Module Wrapper +##### Approach #1: Use an ES module wrapper Write the package in CommonJS or transpile ES module sources into CommonJS, and create an ES module wrapper file that defines the named exports. Using -[Conditional Exports][], the ES module wrapper is used for `import` and the +[Conditional exports][], the ES module wrapper is used for `import` and the CommonJS entry point for `require`. @@ -689,7 +689,7 @@ stateless): } ``` -##### Approach #2: Isolate State +##### Approach #2: Isolate state A `package.json` file can define the separate CommonJS and ES module entry points directly: @@ -859,7 +859,7 @@ property: * `url` {string} The absolute `file:` URL of the module. -## Differences Between ES Modules and CommonJS +## Differences between ES modules and CommonJS ### Mandatory file extensions @@ -955,7 +955,7 @@ To include an ES module into CommonJS, use [`import()`][]. ### `import` statements An `import` statement can reference an ES module or a CommonJS module. Other -file types such as JSON or Native modules are not supported. For those, use +file types such as JSON or native modules are not supported. For those, use [`module.createRequire()`][]. `import` statements are permitted only in ES modules. For similar functionality @@ -991,9 +991,9 @@ It is also possible to [Dynamic `import()`][] is supported in both CommonJS and ES modules. It can be used to include ES module files from CommonJS code. -## CommonJS, JSON, and Native Modules +## CommonJS, JSON, and native modules -CommonJS, JSON, and Native modules can be used with +CommonJS, JSON, and native modules can be used with [`module.createRequire()`][]. ```js @@ -1043,7 +1043,7 @@ syncBuiltinESMExports(); fs.readFileSync === readFileSync; ``` -## Experimental JSON Modules +## Experimental JSON modules Currently importing JSON modules are only supported in the `commonjs` mode and are loaded using the CJS loader. [WHATWG JSON modules specification][] are @@ -1073,7 +1073,7 @@ node index.mjs # fails node --experimental-json-modules index.mjs # works ``` -## Experimental Wasm Modules +## Experimental Wasm modules Importing Web Assembly modules is supported under the `--experimental-wasm-modules` flag, allowing any `.wasm` files to be @@ -1097,7 +1097,7 @@ node --experimental-wasm-modules index.mjs would provide the exports interface for the instantiation of `module.wasm`. -## Experimental Loaders +## Experimental loaders **Note: This API is currently being redesigned and will still change.** @@ -1122,11 +1122,11 @@ and parent URL. The module specifier is the string in an `import` statement or this one, or `undefined` if this is the main entry point for the application. The `conditions` property on the `context` is an array of conditions for -[Conditional Exports][] that apply to this resolution request. They can be used +[Conditional exports][] that apply to this resolution request. They can be used for looking up conditional mappings elsewhere or to modify the list when calling the default resolution logic. -The [current set of Node.js default conditions][Conditional Exports] will always +The [current set of Node.js default conditions][Conditional exports] will always be in the `context.conditions` list passed to the hook. If the hook wants to ensure Node.js-compatible resolution logic, all items from this default condition list **must** be passed through to the `defaultResolve` function. @@ -1134,25 +1134,26 @@ condition list **must** be passed through to the `defaultResolve` function. ```js /** * @param {string} specifier - * @param {object} context - * @param {string} context.parentURL - * @param {string[]} context.conditions - * @param {function} defaultResolve - * @returns {object} response - * @returns {string} response.url + * @param {{ + * parentURL: !(string | undefined), + * conditions: !(Array), + * }} context + * @param {Function} defaultResolve + * @returns {!(Promise<{ url: string }>)} */ export async function resolve(specifier, context, defaultResolve) { const { parentURL = null } = context; - if (someCondition) { + if (Math.random() > 0.5) { // Some condition. // For some or all specifiers, do some custom logic for resolving. - // Always return an object of the form {url: } + // Always return an object of the form {url: }. return { - url: (parentURL) ? - new URL(specifier, parentURL).href : new URL(specifier).href + url: parentURL ? + new URL(specifier, parentURL).href : + new URL(specifier).href, }; } - if (anotherCondition) { - // When calling the defaultResolve, the arguments can be modified. In this + if (Math.random() < 0.5) { // Another condition. + // When calling `defaultResolve`, the arguments can be modified. In this // case it's adding another value for matching conditional exports. return defaultResolve(specifier, { ...context, @@ -1170,32 +1171,42 @@ export async function resolve(specifier, context, defaultResolve) { > signature may change. Do not rely on the API described below. The `getFormat` hook provides a way to define a custom method of determining how -a URL should be interpreted. This can be one of the following: +a URL should be interpreted. The `format` returned also affects what the +acceptable forms of source values are for a module when parsing. This can be one +of the following: + +| `format` | Description | Acceptable Types For `source` Returned by `getSource` or `transformSource` | +| --- | --- | --- | +| `'builtin'` | Load a Node.js builtin module | Not applicable | +| `'commonjs'` | Load a Node.js CommonJS module | Not applicable | +| `'dynamic'` | Use a [dynamic instantiate hook][] | Not applicable | +| `'json'` | Load a JSON file | { [ArrayBuffer][], [string][], [TypedArray][] } | +| `'module'` | Load an ES module | { [ArrayBuffer][], [string][], [TypedArray][] } | +| `'wasm'` | Load a WebAssembly module | { [ArrayBuffer][], [string][], [TypedArray][] } | + +Note: These types all correspond to classes defined in ECMAScript. + +* The specific [ArrayBuffer][] object is a [SharedArrayBuffer][]. +* The specific [string][] object is not the class constructor, but an instance. +* The specific [TypedArray][] object is a [Uint8Array][]. -| `format` | Description | -| --- | --- | -| `'builtin'` | Load a Node.js builtin module | -| `'commonjs'` | Load a Node.js CommonJS module | -| `'dynamic'` | Use a [dynamic instantiate hook][] | -| `'json'` | Load a JSON file | -| `'module'` | Load a standard JavaScript module (ES module) | -| `'wasm'` | Load a WebAssembly module | +Note: If the source value of a text-based format (i.e., `'json'`, `'module'`) is +not a string, it will be converted to a string using [`util.TextDecoder`][]. ```js /** * @param {string} url - * @param {object} context (currently empty) - * @param {function} defaultGetFormat - * @returns {object} response - * @returns {string} response.format + * @param {Object} context (currently empty) + * @param {Function} defaultGetFormat + * @returns {Promise<{ format: string }>} */ export async function getFormat(url, context, defaultGetFormat) { - if (someCondition) { + if (Math.random() > 0.5) { // Some condition. // For some or all URLs, do some custom logic for determining format. // Always return an object of the form {format: }, where the // format is one of the strings in the table above. return { - format: 'module' + format: 'module', }; } // Defer to Node.js for all other URLs. @@ -1215,19 +1226,17 @@ potentially avoid reading files from disk. ```js /** * @param {string} url - * @param {object} context - * @param {string} context.format - * @param {function} defaultGetSource - * @returns {object} response - * @returns {string|buffer} response.source + * @param {{ format: string }} context + * @param {Function} defaultGetSource + * @returns {Promise<{ source: !(SharedArrayBuffer | string | Uint8Array) }>} */ export async function getSource(url, context, defaultGetSource) { const { format } = context; - if (someCondition) { + if (Math.random() > 0.5) { // Some condition. // For some or all URLs, do some custom logic for retrieving the source. // Always return an object of the form {source: }. return { - source: '...' + source: '...', }; } // Defer to Node.js for all other URLs. @@ -1254,28 +1263,25 @@ unknown-to-Node.js file extensions. See the [transpiler loader example][] below. ```js /** - * @param {string|buffer} source - * @param {object} context - * @param {string} context.url - * @param {string} context.format - * @param {function} defaultTransformSource - * @returns {object} response - * @returns {string|buffer} response.source + * @param {!(SharedArrayBuffer | string | Uint8Array)} source + * @param {{ + * url: string, + * format: string, + * }} context + * @param {Function} defaultTransformSource + * @returns {Promise<{ source: !(SharedArrayBuffer | string | Uint8Array) }>} */ -export async function transformSource(source, - context, - defaultTransformSource) { +export async function transformSource(source, context, defaultTransformSource) { const { url, format } = context; - if (someCondition) { + if (Math.random() > 0.5) { // Some condition. // For some or all URLs, do some custom logic for modifying the source. // Always return an object of the form {source: }. return { - source: '...' + source: '...', }; } // Defer to Node.js for all other sources. - return defaultTransformSource( - source, context, defaultTransformSource); + return defaultTransformSource(source, context, defaultTransformSource); } ``` @@ -1517,7 +1523,7 @@ loaded from disk but before Node.js executes it; and so on for any `.coffee`, `.litcoffee` or `.coffee.md` files referenced via `import` statements of any loaded file. -## Resolution Algorithm +## Resolution algorithm ### Features @@ -1530,7 +1536,7 @@ The resolver has the following properties: * No folder mains * Bare specifier package resolution lookup through node_modules -### Resolver Algorithm +### Resolver algorithm The algorithm to load an ES module specifier is given through the **ESM_RESOLVE** method below. It returns the resolved URL for a @@ -1802,7 +1808,7 @@ success! [Babel]: https://babeljs.io/ [CommonJS]: modules.html -[Conditional Exports]: #esm_conditional_exports +[Conditional exports]: #esm_conditional_exports [Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports [ECMAScript-modules implementation]: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md [ES Module Integration Proposal for Web Assembly]: https://github.com/webassembly/esm-integration @@ -1819,6 +1825,12 @@ success! [`module.createRequire()`]: modules.html#modules_module_createrequire_filename [`module.syncBuiltinESMExports()`]: modules.html#modules_module_syncbuiltinesmexports [`transformSource` hook]: #esm_code_transformsource_code_hook +[ArrayBuffer]: http://www.ecma-international.org/ecma-262/6.0/#sec-arraybuffer-constructor +[SharedArrayBuffer]: https://tc39.es/ecma262/#sec-sharedarraybuffer-constructor +[string]: http://www.ecma-international.org/ecma-262/6.0/#sec-string-constructor +[TypedArray]: http://www.ecma-international.org/ecma-262/6.0/#sec-typedarray-objects +[Uint8Array]: http://www.ecma-international.org/ecma-262/6.0/#sec-uint8array +[`util.TextDecoder`]: util.html#util_class_util_textdecoder [dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook [import an ES or CommonJS module for its side effects only]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only [special scheme]: https://url.spec.whatwg.org/#special-scheme diff --git a/doc/api/events.md b/doc/api/events.md index 0a18091fdf7804..309b124b87bc20 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -74,7 +74,7 @@ myEmitter.on('event', (a, b) => { myEmitter.emit('event', 'a', 'b'); ``` -## Asynchronous vs. Synchronous +## Asynchronous vs. synchronous The `EventEmitter` calls all listeners synchronously in the order in which they were registered. This ensures the proper sequencing of @@ -167,7 +167,7 @@ myEmitter.emit('error', new Error('whoops!')); // Still throws and crashes Node.js ``` -## Capture Rejections of Promises +## Capture rejections of promises > Stability: 1 - captureRejections is experimental. diff --git a/doc/api/fs.md b/doc/api/fs.md index d446c56a64d81e..f477138bbdc01c 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1,4 +1,4 @@ -# File System +# File system @@ -242,7 +242,7 @@ fs.readFileSync(new URL('file:///C:/path/%5c')); \ or / characters */ ``` -## File Descriptors +## File descriptors On POSIX systems, for every process, the kernel maintains a table of currently open files and resources. Each open file is assigned a simple numeric @@ -277,14 +277,14 @@ at any given time so it is critical to close the descriptor when operations are completed. Failure to do so will result in a memory leak that will eventually cause an application to crash. -## Threadpool Usage +## Threadpool usage All file system APIs except `fs.FSWatcher()` and those that are explicitly synchronous use libuv's threadpool, which can have surprising and negative performance implications for some applications. See the [`UV_THREADPOOL_SIZE`][] documentation for more information. -## Class `fs.Dir` +## Class: `fs.Dir` @@ -962,7 +962,7 @@ added: v0.11.13 The timestamp indicating the creation time of this file. -### Stat Time Values +### Stat time values The `atimeMs`, `mtimeMs`, `ctimeMs`, `birthtimeMs` properties are numeric values that hold the corresponding times in milliseconds. Their @@ -1087,7 +1087,7 @@ changes: Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility -checks to be performed. Check [File Access Constants][] for possible values +checks to be performed. Check [File access constants][] for possible values of `mode`. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`). @@ -1229,7 +1229,7 @@ changes: Synchronously tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the -accessibility checks to be performed. Check [File Access Constants][] for +accessibility checks to be performed. Check [File access constants][] for possible values of `mode`. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`). @@ -1555,7 +1555,7 @@ through any other `fs` operation may lead to undefined behavior. Returns an object containing commonly used constants for file system operations. The specific constants currently defined are described in -[FS Constants][]. +[FS constants][]. ## `fs.copyFile(src, dest[, flags], callback)` @@ -4175,12 +4178,12 @@ It is unsafe to use `fs.writeFile()` multiple times on the same file without waiting for the callback. For this scenario, [`fs.createWriteStream()`][] is recommended. -### Using `fs.writeFile()` with File Descriptors +### Using `fs.writeFile()` with file descriptors When `file` is a file descriptor, the behavior is almost identical to directly calling `fs.write()` like: -```javascript +```js fs.write(fd, Buffer.from(data, options.encoding), callback); ``` @@ -4197,7 +4200,7 @@ before and/or after the newly written data. For example, if `fs.writeFile()` is called twice in a row, first to write the string `'Hello'`, then to write the string `', World'`, the file would contain `'Hello, World'`, and might contain some of the file's original data (depending -on the size of the original file, and the position of the file descriptor). If +on the size of the original file, and the position of the file descriptor). If a file name had been used instead of a descriptor, the file would be guaranteed to contain only `', World'`. @@ -4325,7 +4328,7 @@ The `fs.promises` API provides an alternative set of asynchronous file system methods that return `Promise` objects rather than using callbacks. The API is accessible via `require('fs').promises`. -### class: `FileHandle` +### Class: `FileHandle` @@ -4751,7 +4754,7 @@ added: v10.0.0 Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility -checks to be performed. Check [File Access Constants][] for possible values +checks to be performed. Check [File access constants][] for possible values of `mode`. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`). @@ -5315,7 +5318,7 @@ Any specified `FileHandle` has to support writing. It is unsafe to use `fsPromises.writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected). -## FS Constants +## FS constants The following constants are exported by `fs.constants`. @@ -5339,7 +5342,7 @@ fs.open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => { }); ``` -### File Access Constants +### File access constants The following constants are meant for use with [`fs.access()`][]. @@ -5371,7 +5374,7 @@ The following constants are meant for use with [`fs.access()`][]. -### File Copy Constants +### File copy constants The following constants are meant for use with [`fs.copyFile()`][]. @@ -5399,7 +5402,7 @@ The following constants are meant for use with [`fs.copyFile()`][]. -### File Open Constants +### File open constants The following constants are meant for use with `fs.open()`. @@ -5493,7 +5496,7 @@ The following constants are meant for use with `fs.open()`. -### File Type Constants +### File type constants The following constants are meant for use with the [`fs.Stats`][] object's `mode` property for determining a file's type. @@ -5537,7 +5540,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's -### File Mode Constants +### File mode constants The following constants are meant for use with the [`fs.Stats`][] object's `mode` property for determining the access permissions for a file. @@ -5597,7 +5600,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's -## File System Flags +## File system flags The following flags are available wherever the `flag` option takes a string. @@ -5743,8 +5746,8 @@ the file contents. [`util.promisify()`]: util.html#util_util_promisify_original [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 +[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 diff --git a/doc/api/globals.md b/doc/api/globals.md index 7e6129e9038aa2..4e2e362bcdeb5b 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -1,4 +1,4 @@ -# Global Objects +# Global objects diff --git a/doc/api/http.md b/doc/api/http.md index e9180a7d375d94..57b5d53a1db0ef 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1983,7 +1983,7 @@ added: v0.1.90 Request URL string. This contains only the URL that is present in the actual HTTP request. If the request is: -```txt +```http GET /status?name=ryan HTTP/1.1\r\n Accept: text/plain\r\n \r\n diff --git a/doc/api/http2.md b/doc/api/http2.md index 4199f857f31087..40a107f7be2d6c 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -119,7 +119,7 @@ User code will not create `Http2Session` instances directly. Server-side new HTTP/2 connection is received. Client-side `Http2Session` instances are created using the `http2.connect()` method. -#### `Http2Session` and Sockets +#### `Http2Session` and sockets Every `Http2Session` instance is associated with exactly one [`net.Socket`][] or [`tls.TLSSocket`][] when it is created. When either the `Socket` or the @@ -1991,7 +1991,9 @@ changes: queued to be sent, and unacknowledged `PING` and `SETTINGS` frames are all counted towards the current limit. **Default:** `10`. * `maxHeaderListPairs` {number} Sets the maximum number of header entries. - The minimum value is `4`. **Default:** `128`. + This is similar to [`http.Server#maxHeadersCount`][] or + [`http.ClientRequest#maxHeadersCount`][]. The minimum value is `4`. + **Default:** `128`. * `maxOutstandingPings` {number} Sets the maximum number of outstanding, unacknowledged pings. **Default:** `10`. * `maxSendHeaderBlockLength` {number} Sets the maximum allowed size for a @@ -2127,7 +2129,9 @@ changes: queued to be sent, and unacknowledged `PING` and `SETTINGS` frames are all counted towards the current limit. **Default:** `10`. * `maxHeaderListPairs` {number} Sets the maximum number of header entries. - The minimum value is `4`. **Default:** `128`. + This is similar to [`http.Server#maxHeadersCount`][] or + [`http.ClientRequest#maxHeadersCount`][]. The minimum value is `4`. + **Default:** `128`. * `maxOutstandingPings` {number} Sets the maximum number of outstanding, unacknowledged pings. **Default:** `10`. * `maxSendHeaderBlockLength` {number} Sets the maximum allowed size for a @@ -2241,7 +2245,9 @@ changes: queued to be sent, and unacknowledged `PING` and `SETTINGS` frames are all counted towards the current limit. **Default:** `10`. * `maxHeaderListPairs` {number} Sets the maximum number of header entries. - The minimum value is `1`. **Default:** `128`. + This is similar to [`http.Server#maxHeadersCount`][] or + [`http.ClientRequest#maxHeadersCount`][]. The minimum value is `1`. + **Default:** `128`. * `maxOutstandingPings` {number} Sets the maximum number of outstanding, unacknowledged pings. **Default:** `10`. * `maxReservedRemoteStreams` {number} Sets the maximum number of reserved push @@ -2308,7 +2314,7 @@ client.close(); added: v8.4.0 --> -#### Error Codes for `RST_STREAM` and `GOAWAY` +#### Error codes for `RST_STREAM` and `GOAWAY` | Value | Name | Constant | @@ -2374,7 +2380,7 @@ added: v8.4.0 Returns a [HTTP/2 Settings Object][] containing the deserialized settings from the given `Buffer` as generated by `http2.getPackedSettings()`. -### Headers Object +### Headers object Headers are represented as own-properties on JavaScript objects. The property keys will be serialized to lower-case. Property values should be strings (if @@ -2422,7 +2428,7 @@ server.on('stream', (stream, headers) => { }); ``` -### Settings Object +### Settings object -* [About these Docs](documentation.html) -* [Usage & Example](synopsis.html) +* [About these docs](documentation.html) +* [Usage and example](synopsis.html)
    -* [Assertion Testing](assert.html) -* [Async Hooks](async_hooks.html) +* [Assertion testing](assert.html) +* [Async hooks](async_hooks.html) * [Buffer](buffer.html) -* [C++ Addons](addons.html) -* [C/C++ Addons with N-API](n-api.html) -* [Child Processes](child_process.html) +* [C++ addons](addons.html) +* [C/C++ addons with N-API](n-api.html) +* [Child processes](child_process.html) * [Cluster](cluster.html) -* [Command Line Options](cli.html) +* [Command line options](cli.html) * [Console](console.html) * [Crypto](crypto.html) * [Debugger](debugger.html) * [Deprecated APIs](deprecations.html) * [DNS](dns.html) * [Domain](domain.html) -* [ECMAScript Modules](esm.html) +* [ECMAScript modules](esm.html) * [Errors](errors.html) * [Events](events.html) -* [File System](fs.html) +* [File system](fs.html) * [Globals](globals.html) * [HTTP](http.html) * [HTTP/2](http2.html) @@ -38,29 +38,29 @@ * [Net](net.html) * [OS](os.html) * [Path](path.html) -* [Performance Hooks](perf_hooks.html) +* [Performance hooks](perf_hooks.html) * [Policies](policy.html) * [Process](process.html) * [Punycode](punycode.html) -* [Query Strings](querystring.html) +* [Query strings](querystring.html) * [Readline](readline.html) * [REPL](repl.html) * [Report](report.html) * [Stream](stream.html) -* [String Decoder](string_decoder.html) +* [String decoder](string_decoder.html) * [Timers](timers.html) * [TLS/SSL](tls.html) -* [Trace Events](tracing.html) +* [Trace events](tracing.html) * [TTY](tty.html) -* [UDP/Datagram](dgram.html) +* [UDP/datagram](dgram.html) * [URL](url.html) * [Utilities](util.html) * [V8](v8.html) * [VM](vm.html) * [WASI](wasi.html) -* [Worker Threads](worker_threads.html) +* [Worker threads](worker_threads.html) * [Zlib](zlib.html)
    -* [GitHub Repo & Issue Tracker](https://github.com/nodejs/node) +* [Code repository and issue tracker](https://github.com/nodejs/node) diff --git a/doc/api/inspector.md b/doc/api/inspector.md index fb1e362bc25a1c..eeab3799cec325 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -188,7 +188,7 @@ to the run-time events. Apart from the debugger, various V8 Profilers are available through the DevTools protocol. -### CPU Profiler +### CPU profiler Here's an example showing how to use the [CPU Profiler][]: @@ -213,7 +213,7 @@ session.post('Profiler.enable', () => { }); ``` -### Heap Profiler +### Heap profiler Here's an example showing how to use the [Heap Profiler][]: diff --git a/doc/api/intl.md b/doc/api/intl.md index be30e4e2528607..31f2dd95e7584a 100644 --- a/doc/api/intl.md +++ b/doc/api/intl.md @@ -1,4 +1,4 @@ -# Internationalization Support +# Internationalization support @@ -119,13 +119,13 @@ through either: * The [`NODE_ICU_DATA`][] environment variable: - ```shell + ```bash env NODE_ICU_DATA=/some/directory node ``` * The [`--icu-data-dir`][] CLI parameter: - ```shell + ```bash node --icu-data-dir=/some/directory ``` diff --git a/doc/api/modules.md b/doc/api/modules.md index 1b5f9a2b708777..7cb5de8c4589e2 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -78,7 +78,7 @@ Because `module` provides a `filename` property (normally equivalent to `__filename`), the entry point of the current application can be obtained by checking `require.main.filename`. -## Addenda: Package Manager Tips +## Addenda: Package manager tips @@ -139,7 +139,7 @@ Attempting to do so will throw [an error][]. The `.mjs` extension is reserved for [ECMAScript Modules][] which cannot be loaded via `require()`. See [ECMAScript Modules][] for more details. -## All Together... +## All together... @@ -149,7 +149,7 @@ the `require.resolve()` function. Putting together all of the above, here is the high-level algorithm in pseudocode of what `require()` does: -```txt +```text require(X) from module at path Y 1. If X is a core module, a. return the core module @@ -165,15 +165,15 @@ require(X) from module at path Y 6. THROW "not found" LOAD_AS_FILE(X) -1. If X is a file, load X as its file extension format. STOP -2. If X.js is a file, load X.js as JavaScript text. STOP -3. If X.json is a file, parse X.json to a JavaScript Object. STOP -4. If X.node is a file, load X.node as binary addon. STOP +1. If X is a file, load X as its file extension format. STOP +2. If X.js is a file, load X.js as JavaScript text. STOP +3. If X.json is a file, parse X.json to a JavaScript Object. STOP +4. If X.node is a file, load X.node as binary addon. STOP LOAD_INDEX(X) -1. If X/index.js is a file, load X/index.js as JavaScript text. STOP +1. If X/index.js is a file, load X/index.js as JavaScript text. STOP 2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP -3. If X/index.node is a file, load X/index.node as binary addon. STOP +3. If X/index.node is a file, load X/index.node as binary addon. STOP LOAD_AS_DIRECTORY(X) 1. If X/package.json is a file, @@ -208,9 +208,9 @@ LOAD_SELF_REFERENCE(X, START) 1. Find the closest package scope to START. 2. If no scope was found, return. 3. If the `package.json` has no "exports", return. -4. If the name in `package.json` isn't a prefix of X, throw "not found". -5. Otherwise, load the remainder of X relative to this package as if it - was loaded via `LOAD_NODE_MODULES` with a name in `package.json`. +4. If the name in `package.json` is a prefix of X, then + a. Load the remainder of X relative to this package as if it was + loaded via `LOAD_NODE_MODULES` with a name in `package.json`. LOAD_PACKAGE_EXPORTS(DIR, X) 1. Try to interpret X as a combination of name and subpath where the name @@ -234,7 +234,7 @@ LOAD_PACKAGE_EXPORTS(DIR, X) a. LOAD_AS_FILE(RESOLVED) b. LOAD_AS_DIRECTORY(RESOLVED) 12. Otherwise - a. If RESOLVED is a file, load it as its file extension format. STOP + a. If RESOLVED is a file, load it as its file extension format. STOP 13. Throw "not found" ``` @@ -254,7 +254,7 @@ allowing transitive dependencies to be loaded even when they would cause cycles. To have a module execute code multiple times, export a function, and call that function. -### Module Caching Caveats +### Module caching caveats @@ -269,7 +269,7 @@ them as different modules and will reload the file multiple times. For example, `require('./foo')` and `require('./FOO')` return two different objects, irrespective of whether or not `./foo` and `./FOO` are the same file. -## Core Modules +## Core modules @@ -347,7 +347,7 @@ in main, a.done = true, b.done = true Careful planning is required to allow cyclic module dependencies to work correctly within an application. -## File Modules +## File modules @@ -373,7 +373,7 @@ either be a core module or is loaded from a `node_modules` folder. If the given path does not exist, `require()` will throw an [`Error`][] with its `code` property set to `'MODULE_NOT_FOUND'`. -## Folders as Modules +## Folders as modules @@ -409,11 +409,11 @@ example, then `require('./some-library')` would attempt to load: If these attempts fail, then Node.js will report the entire module as missing with the default error: -```txt +```console Error: Cannot find module 'some-library' ``` -## Loading from `node_modules` Folders +## Loading from `node_modules` folders @@ -680,7 +680,7 @@ In `entry.js` script: console.log(require.main); ``` -```sh +```bash node entry.js ``` @@ -737,7 +737,7 @@ Returns an array containing the paths searched during resolution of `request` or `null` if the `request` string references a core module, for example `http` or `fs`. -## The `module` Object +## The `module` object @@ -935,7 +935,7 @@ Since `require()` returns the `module.exports`, and the `module` is typically *only* available within a specific module's code, it must be explicitly exported in order to be used. -## The `Module` Object +## The `Module` object @@ -1083,7 +1083,7 @@ added: v12.17.0 Creates a new `sourceMap` instance. -`payload` is an object with keys matching the [Source Map V3 format][]: +`payload` is an object with keys matching the [Source map v3 format][]: * `file`: {string} * `version`: {number} @@ -1134,4 +1134,4 @@ consists of the following keys: [`NODE_V8_COVERAGE=dir`]: cli.html#cli_node_v8_coverage_dir [`Error.prepareStackTrace(error, trace)`]: https://v8.dev/docs/stack-trace-api#customizing-stack-traces [`SourceMap`]: modules.html#modules_class_module_sourcemap -[Source Map V3 format]: https://sourcemaps.info/spec.html#h.mofvlxcwqzej +[Source map v3 format]: https://sourcemaps.info/spec.html#h.mofvlxcwqzej diff --git a/doc/api/n-api.md b/doc/api/n-api.md index e2689bd71a6491..23262c853fcf41 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -31,7 +31,7 @@ properties: `napi_value`. * In case of an error status code, additional information can be obtained using `napi_get_last_error_info`. More information can be found in the error - handling section [Error Handling][]. + handling section [Error handling][]. The N-API is a C API that ensures ABI stability across Node.js versions and different compiler levels. A C++ API can be easier to use. @@ -45,12 +45,12 @@ following `node-addon-api` code. The first section shows the `node-addon-api` code and the second section shows what actually gets used in the addon. -```C++ +```cpp Object obj = Object::New(env); obj["foo"] = String::New(env, "bar"); ``` -```C++ +```cpp napi_status status; napi_value object, string; status = napi_create_object(env, &object); @@ -78,7 +78,7 @@ it still gets the benefits of the ABI stability provided by the C API. When using `node-addon-api` instead of the C APIs, start with the API [docs][] for `node-addon-api`. -## Implications of ABI Stability +## Implications of ABI stability Although N-API provides an ABI stability guarantee, other parts of Node.js do not, and any external libraries used from the addon may not. In particular, @@ -87,7 +87,7 @@ versions: * the Node.js C++ APIs available via any of - ```C++ + ```cpp #include #include #include @@ -96,20 +96,20 @@ versions: * the libuv APIs which are also included with Node.js and available via - ```C++ + ```cpp #include ``` * the V8 API available via - ```C++ + ```cpp #include ``` Thus, for an addon to remain ABI-compatible across Node.js major versions, it must make use exclusively of N-API by restricting itself to using -```C +```c #include ``` @@ -196,7 +196,7 @@ GitHub projects using CMake.js. #### prebuildify -[prebuildify][] is tool based on node-gyp. The advantage of prebuildify is +[prebuildify][] is a tool based on node-gyp. The advantage of prebuildify is that the built binaries are bundled with the native module when it's uploaded to npm. The binaries are downloaded from npm and are immediately available to the module user when the native module is installed. @@ -206,7 +206,7 @@ available to the module user when the native module is installed. In order to use the N-API functions, include the file [`node_api.h`][] which is located in the src directory in the node development tree: -```C +```c #include ``` @@ -214,7 +214,7 @@ This will opt into the default `NAPI_VERSION` for the given release of Node.js. In order to ensure compatibility with specific versions of N-API, the version can be specified explicitly when including the header: -```C +```c #define NAPI_VERSION 3 #include ``` @@ -225,7 +225,7 @@ the specified (and earlier) versions. Some of the N-API surface is considered experimental and requires explicit opt-in to access those APIs: -```C +```c #define NAPI_EXPERIMENTAL #include ``` @@ -233,7 +233,7 @@ opt-in to access those APIs: In this case the entire API surface, including any experimental APIs, will be available to the module code. -## N-API Version Matrix +## N-API version matrix N-API versions are additive and versioned independently from Node.js. Version 4 is an extension to version 3 in that it has all of the APIs @@ -272,7 +272,7 @@ N-API or any implementation of N-API outside of Node.js. to the addon and which instantiates the addon by calling into `addon.c` when the addon is loaded into a Node.js environment. -```C +```c // addon.h #ifndef _ADDON_H_ #define _ADDON_H_ @@ -281,7 +281,7 @@ napi_value create_addon(napi_env env); #endif // _ADDON_H_ ``` -```C +```c // addon.c #include "addon.h" @@ -330,7 +330,7 @@ napi_value create_addon(napi_env env) { } ``` -```C +```c // addon_node.c #include #include "addon.h" @@ -343,7 +343,7 @@ NAPI_MODULE_INIT() { } ``` -## Environment Life Cycle APIs +## Environment life cycle APIs > Stability: 1 - Experimental @@ -378,7 +378,7 @@ added: v12.8.0 napiVersion: 6 --> -```C +```c napi_status napi_set_instance_data(napi_env env, void* data, napi_finalize finalize_cb, @@ -406,7 +406,7 @@ added: v12.8.0 napiVersion: 6 --> -```C +```c napi_status napi_get_instance_data(napi_env env, void** data); ``` @@ -421,7 +421,7 @@ This API retrieves data that was previously associated with the currently running Agent via `napi_set_instance_data()`. If no data is set, the call will succeed and `data` will be set to `NULL`. -## Basic N-API Data Types +## Basic N-API data types N-API exposes the following fundamental datatypes as abstractions that are consumed by the various APIs. These APIs should be treated as opaque, @@ -435,7 +435,7 @@ napiVersion: 1 Integral status code indicating the success or failure of a N-API call. Currently, the following status codes are supported. -```C +```c typedef enum { napi_ok, napi_invalid_arg, @@ -470,7 +470,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c typedef struct { const char* error_message; void* engine_reserved; @@ -487,7 +487,7 @@ typedef struct { not implemented for any VM. * `error_code`: The N-API status code that originated with the last error. -See the [Error Handling][] section for additional information. +See the [Error handling][] section for additional information. ### napi_env @@ -528,7 +528,7 @@ the thread-safe function is to be closed immediately (`napi_tsfn_abort`) or merely released (`napi_tsfn_release`) and thus available for subsequent use via `napi_acquire_threadsafe_function()` and `napi_call_threadsafe_function()`. -```C +```c typedef enum { napi_tsfn_release, napi_tsfn_abort @@ -545,14 +545,14 @@ A value to be given to `napi_call_threadsafe_function()` to indicate whether the call should block whenever the queue associated with the thread-safe function is full. -```C +```c typedef enum { napi_tsfn_nonblocking, napi_tsfn_blocking } napi_threadsafe_function_call_mode; ``` -### N-API Memory Management types +### N-API memory management types #### napi_handle_scope This is an abstraction used to control and modify the lifetime of objects @@ -570,7 +570,7 @@ using [`napi_close_handle_scope`][]. Closing the scope can indicate to the GC that all `napi_value`s created during the lifetime of the handle scope are no longer referenced from the current stack frame. -For more details, review the [Object Lifetime Management][]. +For more details, review the [Object lifetime management][]. #### napi_escapable_handle_scope -```C +```c typedef struct napi_extended_error_info { const char* error_message; void* engine_reserved; @@ -773,7 +773,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_last_error_info(napi_env env, const napi_extended_error_info** result); @@ -883,7 +883,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_throw(napi_env env, napi_value error); ``` @@ -900,7 +900,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_throw_error(napi_env env, const char* code, const char* msg); @@ -920,7 +920,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, const char* code, const char* msg); @@ -940,7 +940,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, const char* code, const char* msg); @@ -960,7 +960,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_is_error(napi_env env, napi_value value, bool* result); @@ -981,7 +981,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_create_error(napi_env env, napi_value code, napi_value msg, @@ -1005,7 +1005,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_create_type_error(napi_env env, napi_value code, napi_value msg, @@ -1029,7 +1029,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_create_range_error(napi_env env, napi_value code, napi_value msg, @@ -1053,7 +1053,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_and_clear_last_exception(napi_env env, napi_value* result); ``` @@ -1071,7 +1071,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_is_exception_pending(napi_env env, bool* result); ``` @@ -1088,7 +1088,7 @@ added: v9.10.0 napiVersion: 3 --> -```C +```c napi_status napi_fatal_exception(napi_env env, napi_value err); ``` @@ -1098,7 +1098,7 @@ napi_status napi_fatal_exception(napi_env env, napi_value err); Trigger an `'uncaughtException'` in JavaScript. Useful if an async callback throws an exception with no way to recover. -### Fatal Errors +### Fatal errors In the event of an unrecoverable error in a native module, a fatal error can be thrown to immediately terminate the process. @@ -1109,7 +1109,7 @@ added: v8.2.0 napiVersion: 1 --> -```C +```c NAPI_NO_RETURN void napi_fatal_error(const char* location, size_t location_len, const char* message, @@ -1127,7 +1127,7 @@ The function call does not return, the process will be terminated. This API can be called even if there is a pending JavaScript exception. -## Object Lifetime management +## Object lifetime management As N-API calls are made, handles to objects in the heap for the underlying VM may be returned as `napi_values`. These handles must hold the @@ -1151,7 +1151,7 @@ It is often necessary to make the lifespan of handles shorter than the lifespan of a native method. For example, consider a native method that has a loop which iterates through the elements in a large array: -```C +```c for (int i = 0; i < 1000000; i++) { napi_value result; napi_status status = napi_get_element(env, object, i, &result); @@ -1183,7 +1183,7 @@ Taking the earlier example, adding calls to [`napi_open_handle_scope`][] and [`napi_close_handle_scope`][] would ensure that at most a single handle is valid throughout the execution of the loop: -```C +```c for (int i = 0; i < 1000000; i++) { napi_handle_scope scope; napi_status status = napi_open_handle_scope(env, &scope); @@ -1223,7 +1223,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, napi_handle_scope* result); ``` @@ -1241,7 +1241,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, napi_handle_scope scope); ``` @@ -1262,7 +1262,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_open_escapable_handle_scope(napi_env env, napi_handle_scope* result); @@ -1282,7 +1282,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_close_escapable_handle_scope(napi_env env, napi_handle_scope scope); @@ -1304,7 +1304,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_escape_handle(napi_env env, napi_escapable_handle_scope scope, napi_value escapee, @@ -1371,7 +1371,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_create_reference(napi_env env, napi_value value, uint32_t initial_refcount, @@ -1395,7 +1395,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_delete_reference(napi_env env, napi_ref ref); ``` @@ -1414,7 +1414,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_reference_ref(napi_env env, napi_ref ref, uint32_t* result); @@ -1435,7 +1435,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_reference_unref(napi_env env, napi_ref ref, uint32_t* result); @@ -1456,7 +1456,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_get_reference_value(napi_env env, napi_ref ref, napi_value* result); @@ -1492,7 +1492,7 @@ added: v10.2.0 napiVersion: 3 --> -```C +```c NODE_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env, void (*fun)(void* arg), void* arg); @@ -1519,7 +1519,7 @@ added: v10.2.0 napiVersion: 3 --> -```C +```c NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env, void (*fun)(void* arg), void* arg); @@ -1537,14 +1537,14 @@ N-API modules are registered in a manner similar to other modules except that instead of using the `NODE_MODULE` macro the following is used: -```C +```c NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) ``` The next difference is the signature for the `Init` method. For a N-API module it is as follows: -```C +```c napi_value Init(napi_env env, napi_value exports); ``` @@ -1557,7 +1557,7 @@ specify anything as the `exports` property of the module. To add the method `hello` as a function so that it can be called as a method provided by the addon: -```C +```c napi_value Init(napi_env env, napi_value exports) { napi_status status; napi_property_descriptor desc = @@ -1570,7 +1570,7 @@ napi_value Init(napi_env env, napi_value exports) { To set a function to be returned by the `require()` for the addon: -```C +```c napi_value Init(napi_env env, napi_value exports) { napi_value method; napi_status status; @@ -1581,9 +1581,9 @@ napi_value Init(napi_env env, napi_value exports) { ``` To define a class so that new instances can be created (often used with -[Object Wrap][]): +[Object wrap][]): -```C +```c // NOTE: partial example, not all referenced code is included napi_value Init(napi_env env, napi_value exports) { napi_status status; @@ -1611,7 +1611,7 @@ napi_value Init(napi_env env, napi_value exports) { If the module will be loaded multiple times during the lifetime of the Node.js process, use the `NAPI_MODULE_INIT` macro to initialize the module: -```C +```c NAPI_MODULE_INIT() { napi_value answer; napi_status result; @@ -1638,12 +1638,12 @@ The variables `env` and `exports` will be available inside the function body following the macro invocation. For more details on setting properties on objects, see the section on -[Working with JavaScript Properties][]. +[Working with JavaScript properties][]. For more details on building addon modules in general, refer to the existing API. -## Working with JavaScript Values +## Working with JavaScript values N-API exposes a set of APIs to create all types of JavaScript values. Some of these types are documented under [Section 6][] of the [ECMAScript Language Specification][]. @@ -1668,7 +1668,7 @@ added: v12.17.0 napiVersion: 6 --> -```C +```c typedef enum { napi_key_include_prototypes, napi_key_own_only @@ -1689,7 +1689,7 @@ added: v12.17.0 napiVersion: 6 --> -```C +```c typedef enum { napi_key_all_properties = 0, napi_key_writable = 1, @@ -1708,7 +1708,7 @@ added: v12.17.0 napiVersion: 6 --> -```C +```c typedef enum { napi_key_keep_numbers, napi_key_numbers_to_strings @@ -1721,7 +1721,7 @@ indices. #### napi_valuetype -```C +```c typedef enum { // ES6 types (corresponds to typeof) napi_undefined, @@ -1747,7 +1747,7 @@ object such that no properties can be set on it, and no prototype. #### napi_typedarray_type -```C +```c typedef enum { napi_int8_array, napi_uint8_array, @@ -1767,14 +1767,14 @@ This represents the underlying binary scalar datatype of the `TypedArray`. Elements of this enum correspond to [Section 22.2][] of the [ECMAScript Language Specification][]. -### Object Creation Functions +### Object creation functions #### napi_create_array -```C +```c napi_status napi_create_array(napi_env env, napi_value* result) ``` @@ -1793,7 +1793,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_array_with_length(napi_env env, size_t length, napi_value* result) @@ -1822,7 +1822,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_arraybuffer(napi_env env, size_t byte_length, void** data, @@ -1855,7 +1855,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_buffer(napi_env env, size_t size, void** data, @@ -1878,7 +1878,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_buffer_copy(napi_env env, size_t length, const void* data, @@ -1905,7 +1905,7 @@ added: v11.11.0 napiVersion: 5 --> -```C +```c napi_status napi_create_date(napi_env env, double time, napi_value* result); @@ -1931,7 +1931,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_external(napi_env env, void* data, napi_finalize finalize_cb, @@ -1971,7 +1971,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_external_arraybuffer(napi_env env, void* external_data, @@ -2015,7 +2015,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_external_buffer(napi_env env, size_t length, void* data, @@ -2056,7 +2056,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_object(napi_env env, napi_value* result) ``` @@ -2077,7 +2077,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_symbol(napi_env env, napi_value description, napi_value* result) @@ -2101,7 +2101,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_typedarray(napi_env env, napi_typedarray_type type, size_t length, @@ -2138,7 +2138,7 @@ added: v8.3.0 napiVersion: 1 --> -```C +```c napi_status napi_create_dataview(napi_env env, size_t byte_length, napi_value arraybuffer, @@ -2173,7 +2173,7 @@ added: v8.4.0 napiVersion: 1 --> -```C +```c napi_status napi_create_int32(napi_env env, int32_t value, napi_value* result) ``` @@ -2195,7 +2195,7 @@ added: v8.4.0 napiVersion: 1 --> -```C +```c napi_status napi_create_uint32(napi_env env, uint32_t value, napi_value* result) ``` @@ -2217,7 +2217,7 @@ added: v8.4.0 napiVersion: 1 --> -```C +```c napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result) ``` @@ -2242,7 +2242,7 @@ added: v8.4.0 napiVersion: 1 --> -```C +```c napi_status napi_create_double(napi_env env, double value, napi_value* result) ``` @@ -2264,7 +2264,7 @@ added: v10.7.0 napiVersion: 6 --> -```C +```c napi_status napi_create_bigint_int64(napi_env env, int64_t value, napi_value* result); @@ -2284,7 +2284,7 @@ added: v10.7.0 napiVersion: 6 --> -```C +```c napi_status napi_create_bigint_uint64(napi_env env, uint64_t value, napi_value* result); @@ -2304,7 +2304,7 @@ added: v10.7.0 napiVersion: 6 --> -```C +```c napi_status napi_create_bigint_words(napi_env env, int sign_bit, size_t word_count, @@ -2333,7 +2333,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_string_latin1(napi_env env, const char* str, size_t length, @@ -2360,7 +2360,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_string_utf16(napi_env env, const char16_t* str, size_t length, @@ -2387,7 +2387,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_string_utf8(napi_env env, const char* str, size_t length, @@ -2415,7 +2415,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_array_length(napi_env env, napi_value value, uint32_t* result) @@ -2439,7 +2439,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_arraybuffer_info(napi_env env, napi_value arraybuffer, void** data, @@ -2471,7 +2471,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_buffer_info(napi_env env, napi_value value, void** data, @@ -2498,7 +2498,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_prototype(napi_env env, napi_value object, napi_value* result) @@ -2518,7 +2518,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_typedarray_info(napi_env env, napi_value typedarray, napi_typedarray_type* type, @@ -2557,7 +2557,7 @@ added: v8.3.0 napiVersion: 1 --> -```C +```c napi_status napi_get_dataview_info(napi_env env, napi_value dataview, size_t* byte_length, @@ -2586,7 +2586,7 @@ added: v11.11.0 napiVersion: 5 --> -```C +```c napi_status napi_get_date_value(napi_env env, napi_value value, double* result) @@ -2612,7 +2612,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_bool(napi_env env, napi_value value, bool* result) ``` @@ -2633,7 +2633,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_double(napi_env env, napi_value value, double* result) @@ -2656,7 +2656,7 @@ added: v10.7.0 napiVersion: 6 --> -```C +```c napi_status napi_get_value_bigint_int64(napi_env env, napi_value value, int64_t* result, @@ -2682,7 +2682,7 @@ added: v10.7.0 napiVersion: 6 --> -```C +```c napi_status napi_get_value_bigint_uint64(napi_env env, napi_value value, uint64_t* result, @@ -2708,7 +2708,7 @@ added: v10.7.0 napiVersion: 6 --> -```C +```c napi_status napi_get_value_bigint_words(napi_env env, napi_value value, int* sign_bit, @@ -2737,7 +2737,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_external(napi_env env, napi_value value, void** result) @@ -2759,7 +2759,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_int32(napi_env env, napi_value value, int32_t* result) @@ -2789,7 +2789,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_int64(napi_env env, napi_value value, int64_t* result) @@ -2818,7 +2818,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_string_latin1(napi_env env, napi_value value, char* buf, @@ -2847,7 +2847,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_string_utf8(napi_env env, napi_value value, char* buf, @@ -2875,7 +2875,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_string_utf16(napi_env env, napi_value value, char16_t* buf, @@ -2903,7 +2903,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_value_uint32(napi_env env, napi_value value, uint32_t* result) @@ -2927,7 +2927,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_boolean(napi_env env, bool value, napi_value* result) ``` @@ -2947,7 +2947,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_global(napi_env env, napi_value* result) ``` @@ -2964,7 +2964,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_null(napi_env env, napi_value* result) ``` @@ -2981,7 +2981,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_undefined(napi_env env, napi_value* result) ``` @@ -2992,7 +2992,7 @@ Returns `napi_ok` if the API succeeded. This API returns the Undefined object. -## Working with JavaScript Values and Abstract Operations +## Working with JavaScript values and abstract operations N-API exposes a set of APIs to perform some abstract operations on JavaScript values. Some of these operations are documented under [Section 7][] @@ -3011,7 +3011,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_coerce_to_bool(napi_env env, napi_value value, napi_value* result) @@ -3033,7 +3033,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_coerce_to_number(napi_env env, napi_value value, napi_value* result) @@ -3055,7 +3055,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_coerce_to_object(napi_env env, napi_value value, napi_value* result) @@ -3077,7 +3077,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_coerce_to_string(napi_env env, napi_value value, napi_value* result) @@ -3099,7 +3099,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_typeof(napi_env env, napi_value value, napi_valuetype* result) ``` @@ -3123,7 +3123,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_instanceof(napi_env env, napi_value object, napi_value constructor, @@ -3148,7 +3148,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_is_array(napi_env env, napi_value value, bool* result) ``` @@ -3167,7 +3167,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_is_arraybuffer(napi_env env, napi_value value, bool* result) ``` @@ -3185,7 +3185,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) ``` @@ -3204,7 +3204,7 @@ added: v11.11.0 napiVersion: 5 --> -```C +```c napi_status napi_is_date(napi_env env, napi_value value, bool* result) ``` @@ -3223,7 +3223,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_is_error(napi_env env, napi_value value, bool* result) ``` @@ -3241,7 +3241,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_is_typedarray(napi_env env, napi_value value, bool* result) ``` @@ -3259,7 +3259,7 @@ added: v8.3.0 napiVersion: 1 --> -```C +```c napi_status napi_is_dataview(napi_env env, napi_value value, bool* result) ``` @@ -3277,7 +3277,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_strict_equals(napi_env env, napi_value lhs, napi_value rhs, @@ -3301,7 +3301,7 @@ added: v12.16.0 > Stability: 1 - Experimental -```C +```c napi_status napi_detach_arraybuffer(napi_env env, napi_value arraybuffer) ``` @@ -3327,7 +3327,7 @@ added: v12.16.0 > Stability: 1 - Experimental -```C +```c napi_status napi_is_detached_arraybuffer(napi_env env, napi_value arraybuffer, bool* result) @@ -3345,7 +3345,7 @@ This API represents the invocation of the `ArrayBuffer` `IsDetachedBuffer` operation as defined in [Section 24.1.1.2][] of the ECMAScript Language Specification. -## Working with JavaScript Properties +## Working with JavaScript properties N-API exposes a set of APIs to get and set properties on JavaScript objects. Some of these types are documented under [Section 7][] of the @@ -3378,7 +3378,7 @@ obj.myProp = 123; The equivalent can be done using N-API values with the following snippet: -```C +```c napi_status status = napi_generic_failure; // const obj = {} @@ -3405,7 +3405,7 @@ arr[123] = 'hello'; The equivalent can be done using N-API values with the following snippet: -```C +```c napi_status status = napi_generic_failure; // const arr = []; @@ -3432,7 +3432,7 @@ const value = arr[123]; The following is the approximate equivalent of the N-API counterpart: -```C +```c napi_status status = napi_generic_failure; // const arr = [] @@ -3458,7 +3458,7 @@ Object.defineProperties(obj, { The following is the approximate equivalent of the N-API counterpart: -```C +```c napi_status status = napi_status_generic_failure; // const obj = {}; @@ -3488,7 +3488,7 @@ if (status != napi_ok) return status; ### Structures #### napi_property_attributes -```C +```c typedef enum { napi_default = 0, napi_writable = 1 << 0, @@ -3519,7 +3519,7 @@ They can be one or more of the following bitflags: #### napi_property_descriptor -```C +```c typedef struct { // One of utf8name or name should be NULL. const char* utf8name; @@ -3570,7 +3570,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_property_names(napi_env env, napi_value object, napi_value* result); @@ -3595,7 +3595,7 @@ added: v12.17.0 napiVersion: 6 --> -```C +```c napi_get_all_property_names(napi_env env, napi_value object, napi_key_collection_mode key_mode, @@ -3625,7 +3625,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_set_property(napi_env env, napi_value object, napi_value key, @@ -3647,7 +3647,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_property(napi_env env, napi_value object, napi_value key, @@ -3669,7 +3669,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_has_property(napi_env env, napi_value object, napi_value key, @@ -3691,7 +3691,7 @@ added: v8.2.0 napiVersion: 1 --> -```C +```c napi_status napi_delete_property(napi_env env, napi_value object, napi_value key, @@ -3714,7 +3714,7 @@ added: v8.2.0 napiVersion: 1 --> -```C +```c napi_status napi_has_own_property(napi_env env, napi_value object, napi_value key, @@ -3738,7 +3738,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_set_named_property(napi_env env, napi_value object, const char* utf8Name, @@ -3761,7 +3761,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_named_property(napi_env env, napi_value object, const char* utf8Name, @@ -3784,7 +3784,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_has_named_property(napi_env env, napi_value object, const char* utf8Name, @@ -3807,7 +3807,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_set_element(napi_env env, napi_value object, uint32_t index, @@ -3829,7 +3829,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_element(napi_env env, napi_value object, uint32_t index, @@ -3851,7 +3851,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_has_element(napi_env env, napi_value object, uint32_t index, @@ -3874,7 +3874,7 @@ added: v8.2.0 napiVersion: 1 --> -```C +```c napi_status napi_delete_element(napi_env env, napi_value object, uint32_t index, @@ -3897,7 +3897,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_define_properties(napi_env env, napi_value object, size_t property_count, @@ -3918,7 +3918,7 @@ this API will set the properties on the object one at a time, as defined by `DefineOwnProperty()` (described in [Section 9.1.6][] of the ECMA-262 specification). -## Working with JavaScript Functions +## Working with JavaScript functions N-API provides a set of APIs that allow JavaScript code to call back into native code. N-API APIs that support calling back @@ -3948,7 +3948,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_call_function(napi_env env, napi_value recv, napi_value func, @@ -3984,7 +3984,7 @@ function AddTwo(num) { Then, the above function can be invoked from a native add-on using the following code: -```C +```c // Get the function named "AddTwo" on the global object napi_value global, add_two, arg; napi_status status = napi_get_global(env, &global); @@ -4017,7 +4017,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_create_function(napi_env env, const char* utf8name, size_t length, @@ -4052,7 +4052,7 @@ In order to expose a function as part of the add-on's module exports, set the newly created function on the exports object. A sample module might look as follows: -```C +```c napi_value SayHello(napi_env env, napi_callback_info info) { printf("Hello\n"); return NULL; @@ -4098,7 +4098,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_cb_info(napi_env env, napi_callback_info cbinfo, size_t* argc, @@ -4130,7 +4130,7 @@ added: v8.6.0 napiVersion: 1 --> -```C +```c napi_status napi_get_new_target(napi_env env, napi_callback_info cbinfo, napi_value* result) @@ -4151,7 +4151,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_new_instance(napi_env env, napi_value cons, size_t argc, @@ -4183,7 +4183,7 @@ const value = new MyObject(arg); The following can be approximated in N-API using the following snippet: -```C +```c // Get the constructor function MyObject napi_value global, constructor, arg, value; napi_status status = napi_get_global(env, &global); @@ -4205,7 +4205,7 @@ status = napi_new_instance(env, constructor, argc, argv, &value); Returns `napi_ok` if the API succeeded. -## Object Wrap +## Object wrap N-API offers a way to "wrap" C++ classes and instances so that the class constructor and methods can be called from JavaScript. @@ -4226,7 +4226,7 @@ called on a class prototype and a function called on an instance of a class. A common pattern used to address this problem is to save a persistent reference to the class constructor for later `instanceof` checks. -```C +```c napi_value MyClass_constructor = NULL; status = napi_get_reference_value(env, MyClass::es_constructor, &MyClass_constructor); assert(napi_ok == status); @@ -4248,7 +4248,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_define_class(napi_env env, const char* utf8name, size_t length, @@ -4313,7 +4313,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_wrap(napi_env env, napi_value js_object, void* native_object, @@ -4370,7 +4370,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_unwrap(napi_env env, napi_value js_object, void** result); @@ -4397,7 +4397,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c napi_status napi_remove_wrap(napi_env env, napi_value js_object, void** result); @@ -4421,7 +4421,7 @@ added: v8.0.0 napiVersion: 5 --> -```C +```c napi_status napi_add_finalizer(napi_env env, napi_value js_object, void* native_object, @@ -4459,7 +4459,7 @@ invocation. If it is deleted before then, then the finalize callback may never be invoked. Therefore, when obtaining a reference a finalize callback is also required in order to enable correct disposal of the reference. -## Simple Asynchronous Operations +## Simple asynchronous operations Addon modules often need to leverage async helpers from libuv as part of their implementation. This allows them to schedule work to be executed asynchronously @@ -4486,7 +4486,7 @@ it will likely execute JavaScript. These functions implement the following interfaces: -```C +```c typedef void (*napi_async_execute_callback)(napi_env env, void* data); typedef void (*napi_async_complete_callback)(napi_env env, @@ -4501,7 +4501,7 @@ addon-provided `void*` data that was passed into the Once created the async worker can be queued for execution using the [`napi_queue_async_work`][] function: -```C +```c napi_status napi_queue_async_work(napi_env env, napi_async_work work); ``` @@ -4524,7 +4524,7 @@ changes: description: Added `async_resource` and `async_resource_name` parameters. --> -```C +```c napi_status napi_create_async_work(napi_env env, napi_value async_resource, napi_value async_resource_name, @@ -4569,7 +4569,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_delete_async_work(napi_env env, napi_async_work work); ``` @@ -4589,7 +4589,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_queue_async_work(napi_env env, napi_async_work work); ``` @@ -4609,7 +4609,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_cancel_async_work(napi_env env, napi_async_work work); ``` @@ -4628,7 +4628,7 @@ callback invocation, even if it has been successfully cancelled. This API can be called even if there is a pending JavaScript exception. -## Custom Asynchronous Operations +## Custom asynchronous operations The simple asynchronous work APIs above may not be appropriate for every scenario. When using any other asynchronous mechanism, the following APIs @@ -4641,7 +4641,7 @@ added: v8.6.0 napiVersion: 1 --> -```C +```c napi_status napi_async_init(napi_env env, napi_value async_resource, napi_value async_resource_name, @@ -4669,7 +4669,7 @@ added: v8.6.0 napiVersion: 1 --> -```C +```c napi_status napi_async_destroy(napi_env env, napi_async_context async_context); ``` @@ -4690,7 +4690,7 @@ changes: description: Added `async_context` parameter. --> -```C +```c NAPI_EXTERN napi_status napi_make_callback(napi_env env, napi_async_context async_context, napi_value recv, @@ -4728,13 +4728,16 @@ is sufficient and appropriate. Use of the `napi_make_callback` function may be required when implementing custom async behavior that does not use `napi_create_async_work`. +Any `process.nextTick`s or Promises scheduled on the microtask queue by +JavaScript during the callback are ran before returning back to C/C++. + ### napi_open_callback_scope -```C +```c NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env, napi_value resource_object, napi_async_context context, @@ -4761,7 +4764,7 @@ added: v9.6.0 napiVersion: 3 --> -```C +```c NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, napi_callback_scope scope) ``` @@ -4771,7 +4774,7 @@ NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, This API can be called even if there is a pending JavaScript exception. -## Version Management +## Version management ### napi_get_node_version -```C +```c typedef struct { uint32_t major; uint32_t minor; @@ -4808,7 +4811,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_version(napi_env env, uint32_t* result); ``` @@ -4832,7 +4835,7 @@ support it: * If the function is not available, provide an alternate implementation that does not use the function. -## Memory Management +## Memory management ### napi_adjust_external_memory -```C +```c NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env, int64_t change_in_bytes, int64_t* result); @@ -4921,7 +4924,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c napi_status napi_create_promise(napi_env env, napi_deferred* deferred, napi_value* promise); @@ -4943,7 +4946,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c napi_status napi_resolve_deferred(napi_env env, napi_deferred deferred, napi_value resolution); @@ -4968,7 +4971,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c napi_status napi_reject_deferred(napi_env env, napi_deferred deferred, napi_value rejection); @@ -4993,7 +4996,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c napi_status napi_is_promise(napi_env env, napi_value value, bool* is_promise); @@ -5015,7 +5018,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_run_script(napi_env env, napi_value script, napi_value* result); @@ -5051,7 +5054,7 @@ added: napiVersion: 2 --> -```C +```c NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env, struct uv_loop_s** loop); ``` @@ -5059,7 +5062,7 @@ NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env, * `[in] env`: The environment that the API is invoked under. * `[out] loop`: The current libuv loop instance. -## Asynchronous Thread-safe Function Calls +## Asynchronous thread-safe function calls JavaScript functions can normally only be called from a native addon's main thread. If an addon creates additional threads, then N-API functions that @@ -5092,7 +5095,9 @@ The `context` given during the call to `napi_create_threadsafe_function()` can be retrieved from any thread with a call to `napi_get_threadsafe_function_context()`. -`napi_call_threadsafe_function()` can then be used for initiating a call into +### Calling a thread-safe function + +`napi_call_threadsafe_function()` can be used for initiating a call into JavaScript. `napi_call_threadsafe_function()` accepts a parameter which controls whether the API behaves blockingly. If set to `napi_tsfn_nonblocking`, the API behaves non-blockingly, returning `napi_queue_full` if the queue was full, @@ -5120,6 +5125,8 @@ Node.js process exits while there is a thread-safe function still active. It is not necessary to call into JavaScript via `napi_make_callback()` because N-API runs `call_js_cb` in a context appropriate for callbacks. +### Reference counting of thread-safe functions + Threads can be added to and removed from a `napi_threadsafe_function` object during its existence. Thus, in addition to specifying an initial number of threads upon creation, `napi_acquire_threadsafe_function` can be called to @@ -5139,7 +5146,10 @@ reason, do not make use of a thread-safe function after receiving a return value of `napi_closing` in response to a call to `napi_call_threadsafe_function`. Data associated with the `napi_threadsafe_function` can be freed in its `napi_finalize` callback which -was passed to `napi_create_threadsafe_function()`. +was passed to `napi_create_threadsafe_function()`. The parameter +`initial_thread_count` of `napi_create_threadsafe_function` marks the initial +number of aquisitions of the thread-safe functions, instead of calling +`napi_acquire_threadsafe_function` multiple times at creation. Once the number of threads making use of a `napi_threadsafe_function` reaches zero, no further threads can start making use of it by calling @@ -5159,6 +5169,8 @@ of `napi_closing` from `napi_call_threadsafe_function()` a thread must make no further use of the thread-safe function because it is no longer guaranteed to be allocated.** +### Deciding whether to keep the process running + Similarly to libuv handles, thread-safe functions can be "referenced" and "unreferenced". A "referenced" thread-safe function will cause the event loop on the thread on which it is created to remain alive until the thread-safe function @@ -5166,6 +5178,10 @@ is destroyed. In contrast, an "unreferenced" thread-safe function will not prevent the event loop from exiting. The APIs `napi_ref_threadsafe_function` and `napi_unref_threadsafe_function` exist for this purpose. +Neither does `napi_unref_threadsafe_function` mark the thread-safe functions as +able to be destroyed nor does `napi_ref_threadsafe_function` prevent it from +being destroyed. + ### napi_create_threadsafe_function -```C +```c NAPI_EXTERN napi_status napi_create_threadsafe_function(napi_env env, napi_value func, @@ -5201,8 +5217,9 @@ napi_create_threadsafe_function(napi_env env, the kind of resource that is being provided for diagnostic information exposed by the `async_hooks` API. * `[in] max_queue_size`: Maximum size of the queue. `0` for no limit. -* `[in] initial_thread_count`: The initial number of threads, including the main - thread, which will be making use of this function. +* `[in] initial_thread_count`: The initial number of acquisitions, i.e. the + initial number of threads, including the main thread, which will be making use + of this function. * `[in] thread_finalize_data`: Optional data to be passed to `thread_finalize_cb`. * `[in] thread_finalize_cb`: Optional function to call when the `napi_threadsafe_function` is being destroyed. @@ -5221,7 +5238,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_get_threadsafe_function_context(napi_threadsafe_function func, void** result); @@ -5239,7 +5256,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_call_threadsafe_function(napi_threadsafe_function func, void* data, @@ -5267,7 +5284,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_acquire_threadsafe_function(napi_threadsafe_function func); ``` @@ -5289,7 +5306,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_release_threadsafe_function(napi_threadsafe_function func, napi_threadsafe_function_release_mode mode); @@ -5318,7 +5335,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); ``` @@ -5330,6 +5347,11 @@ This API is used to indicate that the event loop running on the main thread should not exit until `func` has been destroyed. Similar to [`uv_ref`][] it is also idempotent. +Neither does `napi_unref_threadsafe_function` mark the thread-safe functions as +able to be destroyed nor does `napi_ref_threadsafe_function` prevent it from +being destroyed. `napi_acquire_threadsafe_function` and +`napi_release_threadsafe_function` are available for that purpose. + This API may only be called from the main thread. ### napi_unref_threadsafe_function @@ -5339,7 +5361,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); ``` @@ -5359,14 +5381,14 @@ This API may only be called from the main thread. [CMake.js]: https://github.com/cmake-js/cmake-js [CMake]: https://cmake.org [ECMAScript Language Specification]: https://tc39.github.io/ecma262/ -[Error Handling]: #n_api_error_handling +[Error handling]: #n_api_error_handling [GCC]: https://gcc.gnu.org [GYP]: https://gyp.gsrc.io [GitHub releases]: https://help.github.com/en/github/administering-a-repository/about-releases [LLVM]: https://llvm.org [Native Abstractions for Node.js]: https://github.com/nodejs/nan -[Object Lifetime Management]: #n_api_object_lifetime_management -[Object Wrap]: #n_api_object_wrap +[Object lifetime management]: #n_api_object_lifetime_management +[Object wrap]: #n_api_object_wrap [Section 12.10.4]: https://tc39.github.io/ecma262/#sec-instanceofoperator [Section 12.5.5]: https://tc39.github.io/ecma262/#sec-typeof-operator [Section 19.2]: https://tc39.github.io/ecma262/#sec-function-objects @@ -5396,7 +5418,7 @@ This API may only be called from the main thread. [Section 24.1.1.2]: https://tc39.es/ecma262/#sec-isdetachedbuffer [Travis CI]: https://travis-ci.org [Visual Studio]: https://visualstudio.microsoft.com -[Working with JavaScript Properties]: #n_api_working_with_javascript_properties +[Working with JavaScript properties]: #n_api_working_with_javascript_properties [Xcode]: https://developer.apple.com/xcode/ [`Number.MAX_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.max_safe_integer [`Number.MIN_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.min_safe_integer diff --git a/doc/api/net.md b/doc/api/net.md index b801be156192cf..2b427b3de77139 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -15,7 +15,7 @@ It can be accessed using: const net = require('net'); ``` -## IPC Support +## IPC support The `net` module supports IPC with named pipes on Windows, and Unix domain sockets on other operating systems. @@ -721,7 +721,7 @@ added: v6.1.0 If `true`, [`socket.connect(options[, connectListener])`][`socket.connect(options)`] was called and has not yet finished. It will stay `true` until the socket becomes -connected, then it is set to `false` and the `'connect'` event is emitted. Note +connected, then it is set to `false` and the `'connect'` event is emitted. Note that the [`socket.connect(options[, connectListener])`][`socket.connect(options)`] callback is a listener for the `'connect'` event. diff --git a/doc/api/os.md b/doc/api/os.md index b6e502f3b5b5f7..0cf85c5f96430f 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -45,7 +45,7 @@ added: v6.3.0 Contains commonly used operating system-specific constants for error codes, process signals, and so on. The specific constants defined are described in -[OS Constants](#os_os_constants_1). +[OS constants](#os_os_constants_1). ## `os.cpus()` @@ -1252,7 +1252,7 @@ The following process scheduling constants are exported by -### libuv Constants +### libuv constants diff --git a/doc/api/path.md b/doc/api/path.md index 945c1a0394ca46..8349bce252a56b 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -73,7 +73,7 @@ changes: * `ext` {string} An optional file extension * Returns: {string} -The `path.basename()` methods returns the last portion of a `path`, similar to +The `path.basename()` method returns the last portion of a `path`, similar to the Unix `basename` command. Trailing directory separators are ignored, see [`path.sep`][]. diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 9b98415362e1f9..c91d83a966f0f9 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -1,4 +1,4 @@ -# Performance Measurement APIs +# Performance measurement APIs diff --git a/doc/api/policy.md b/doc/api/policy.md index 35ea48b40b410e..05918500fcac21 100644 --- a/doc/api/policy.md +++ b/doc/api/policy.md @@ -31,7 +31,7 @@ when loading modules. Once this has been set, all modules must conform to a policy manifest file passed to the flag: -```sh +```bash node --experimental-policy=policy.json app.js ``` @@ -43,13 +43,13 @@ the policy file itself may be provided via `--policy-integrity`. This allows running `node` and asserting the policy file contents even if the file is changed on disk. -```sh +```bash node --experimental-policy=policy.json --policy-integrity="sha384-SggXRQHwCG8g+DktYYzxkXRIkTiEYWBHqev0xnpCxYlqMBufKZHAHQM3/boDaI/0" app.js ``` ## Features -### Error Behavior +### Error behavior When a policy check fails, Node.js by default will throw an error. It is possible to change the error behavior to one of a few possibilities @@ -73,7 +73,7 @@ available to change the behavior: } ``` -### Integrity Checks +### Integrity checks Policy files must use integrity checks with Subresource Integrity strings compatible with the browser @@ -115,7 +115,7 @@ body for the resource which can be useful for local development. It is not recommended in production since it would allow unexpected alteration of resources to be considered valid. -### Dependency Redirection +### Dependency redirection An application may need to ship patched versions of modules or to prevent modules from allowing all modules access to all other modules. Redirection @@ -164,7 +164,7 @@ module to load any specifier without redirection. This can be useful for local development and may have some valid usage in production, but should be used only with care after auditing a module to ensure its behavior is valid. -#### Example: Patched Dependency +#### Example: Patched dependency Redirected dependencies can provide attenuated or modified functionality as fits the application. For example, log data about timing of function durations by diff --git a/doc/api/process.md b/doc/api/process.md index c9222bb3fbe0bc..2fb0b77f7df702 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -12,7 +12,7 @@ accessed using `require()`: const process = require('process'); ``` -## Process Events +## Process events The `process` object is an instance of [`EventEmitter`][]. @@ -122,7 +122,7 @@ not be the same as what is originally sent. If the `serialization` option was set to `advanced` used when spawning the process, the `message` argument can contain data that JSON is not able to represent. -See [Advanced Serialization for `child_process`][] for more details. +See [Advanced serialization for `child_process`][] for more details. ### Event: `'multipleResolves'` @@ -553,7 +554,7 @@ environment variable. `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides `Set.prototype.has` to recognize several different possible flag -representations. `process.allowedNodeEnvironmentFlags.has()` will +representations. `process.allowedNodeEnvironmentFlags.has()` will return `true` in the following cases: * Flags may omit leading single (`-`) or double (`--`) dashes; e.g., @@ -2485,7 +2486,7 @@ Will generate an object similar to: unicode: '11.0' } ``` -## Exit Codes +## Exit codes Node.js will normally exit with a `0` status code when no more async operations are pending. The following status codes are used in other @@ -2535,6 +2536,7 @@ cases: [`'exit'`]: #process_event_exit [`'message'`]: child_process.html#child_process_event_message [`'uncaughtException'`]: #process_event_uncaughtexception +[`--unhandled-rejections`]: cli.html#cli_unhandled_rejections_mode [`Buffer`]: buffer.html [`ChildProcess.disconnect()`]: child_process.html#child_process_subprocess_disconnect [`ChildProcess.send()`]: child_process.html#child_process_subprocess_send_message_sendhandle_options_callback @@ -2565,7 +2567,7 @@ cases: [`require.resolve()`]: modules.html#modules_require_resolve_request_options [`subprocess.kill()`]: child_process.html#child_process_subprocess_kill_signal [`v8.setFlagsFromString()`]: v8.html#v8_v8_setflagsfromstring_flags -[Advanced Serialization for `child_process`]: child_process.html#child_process_advanced_serialization +[Advanced serialization for `child_process`]: child_process.html#child_process_advanced_serialization [Android building]: https://github.com/nodejs/node/blob/master/BUILDING.md#androidandroid-based-devices-eg-firefox-os [Child Process]: child_process.html [Cluster]: cluster.html diff --git a/doc/api/querystring.md b/doc/api/querystring.md index c7fafd23d955b8..0797e3ee220d53 100644 --- a/doc/api/querystring.md +++ b/doc/api/querystring.md @@ -1,4 +1,4 @@ -# Query String +# Query string diff --git a/doc/api/readline.md b/doc/api/readline.md index bd0f544def6fe1..c3b79d4646709d 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -361,7 +361,7 @@ The current input data being processed by node. This can be used when collecting input from a TTY stream to retrieve the current value that has been processed thus far, prior to the `line` event -being emitted. Once the `line` event has been emitted, this property will +being emitted. Once the `line` event has been emitted, this property will be an empty string. Be aware that modifying the value during the instance runtime may have @@ -395,7 +395,7 @@ added: v0.1.98 The cursor position relative to `rl.line`. This will track where the current cursor lands in the input string, when -reading input from a TTY stream. The position of cursor determines the +reading input from a TTY stream. The position of cursor determines the portion of the input string that will be modified as input is processed, as well as the column where the terminal caret will be rendered. @@ -409,7 +409,7 @@ added: v12.16.0 * `cols` {number} the screen column the cursor currently lands on Returns the real position of the cursor in relation to the input -prompt + string. Long input (wrapping) strings, as well as multiple +prompt + string. Long input (wrapping) strings, as well as multiple line prompts are included in the calculations. ## `readline.clearLine(stream, dir[, callback])` @@ -525,7 +525,7 @@ the best compatibility if it defines an `output.columns` property and emits a `'resize'` event on the `output` if or when the columns ever change ([`process.stdout`][] does this automatically when it is a TTY). -### Use of the `completer` Function +### Use of the `completer` function The `completer` function takes the current line entered by the user as an argument, and returns an `Array` with 2 entries: @@ -650,7 +650,7 @@ rl.on('line', (line) => { }); ``` -## Example: Read File Stream Line-by-Line +## Example: Read file stream line-by-Line A common use case for `readline` is to consume an input file one line at a time. The easiest way to do so is leveraging the [`fs.ReadStream`][] API as @@ -739,7 +739,7 @@ const { createInterface } = require('readline'); - + @@ -813,7 +813,7 @@ const { createInterface } = require('readline'); + backspace + work on Linux, Mac and Windows diff --git a/doc/api/repl.md b/doc/api/repl.md index 50845785cf9c71..c8420720fdc566 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -12,7 +12,7 @@ It can be accessed using: const repl = require('repl'); ``` -## Design and Features +## Design and features The `repl` module exports the [`repl.REPLServer`][] class. While running, instances of [`repl.REPLServer`][] will accept individual lines of user input, @@ -28,7 +28,7 @@ recovery, and customizable evaluation functions. Terminals that do not support ANSI styles and Emacs-style line editing automatically fall back to a limited feature set. -### Commands and Special Keys +### Commands and special keys The following special commands are supported by all REPL instances: @@ -36,7 +36,7 @@ The following special commands are supported by all REPL instances: the `.break` command (or pressing the `-C` key combination) will abort further input or processing of that expression. * `.clear`: Resets the REPL `context` to an empty object and clears any - multi-line expression currently being input. + multi-line expression being input. * `.exit`: Close the I/O stream, causing the REPL to exit. * `.help`: Show this list of special commands. * `.save`: Save the current REPL session to a file: @@ -72,14 +72,14 @@ The following key combinations in the REPL have these special effects: For key bindings related to the reverse-i-search, see [`reverse-i-search`][]. For all other key bindings, see [TTY keybindings][]. -### Default Evaluation +### Default evaluation By default, all instances of [`repl.REPLServer`][] use an evaluation function that evaluates JavaScript expressions and provides access to Node.js built-in modules. This default behavior can be overridden by passing in an alternative evaluation function when the [`repl.REPLServer`][] instance is created. -#### JavaScript Expressions +#### JavaScript expressions The default evaluator supports direct evaluation of JavaScript expressions: @@ -96,7 +96,7 @@ Unless otherwise scoped within blocks or functions, variables declared either implicitly or using the `const`, `let`, or `var` keywords are declared at the global scope. -#### Global and Local Scope +#### Global and local scope The default evaluator provides access to any variables that exist in the global scope. It is possible to expose a variable to the REPL explicitly by assigning @@ -132,7 +132,7 @@ Object.defineProperty(r.context, 'm', { }); ``` -#### Accessing Core Node.js Modules +#### Accessing core Node.js modules The default evaluator will automatically load Node.js core modules into the REPL environment when used. For instance, unless otherwise declared as a @@ -143,7 +143,7 @@ global or scoped variable, the input `fs` will be evaluated on-demand as > fs.createReadStream('./some/file'); ``` -#### Global Uncaught Exceptions +#### Global uncaught exceptions @@ -504,7 +504,7 @@ containing `libuv` handle information and an OS platform information section showing CPU and memory usage and system limits. An example report can be triggered using the Node.js REPL: -```raw +```console $ node > process.report.writeReport(); Writing Node.js report to file: report.20181126.091102.8480.0.001.json @@ -578,7 +578,7 @@ NODE_OPTIONS="--report-uncaught-exception \ Specific API documentation can be found under [`process API documentation`][] section. -## Interaction with Workers +## Interaction with workers @@ -120,8 +120,8 @@ that implements an HTTP server: const http = require('http'); const server = http.createServer((req, res) => { - // `req` is an http.IncomingMessage, which is a Readable Stream. - // `res` is an http.ServerResponse, which is a Writable Stream. + // `req` is an http.IncomingMessage, which is a readable stream. + // `res` is an http.ServerResponse, which is a writable stream. let body = ''; // Get the data as utf8 strings. @@ -176,9 +176,9 @@ are not required to implement the stream interfaces directly and will generally have no reason to call `require('stream')`. Developers wishing to implement new types of streams should refer to the -section [API for Stream Implementers][]. +section [API for stream implementers][]. -### Writable Streams +### Writable streams Writable streams are an abstraction for a *destination* to which data is written. @@ -576,7 +576,7 @@ changes: not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any JavaScript value other than `null`. -* `encoding` {string} The encoding, if `chunk` is a string +* `encoding` {string} The encoding, if `chunk` is a string. **Default:** `'utf8'` * `callback` {Function} Callback for when this chunk of data is flushed * Returns: {boolean} `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write @@ -634,7 +634,7 @@ write('hello', () => { A `Writable` stream in object mode will always ignore the `encoding` argument. -### Readable Streams +### Readable streams Readable streams are an abstraction for a *source* from which data is consumed. @@ -653,7 +653,7 @@ Examples of `Readable` streams include: All [`Readable`][] streams implement the interface defined by the `stream.Readable` class. -#### Two Reading Modes +#### Two reading modes `Readable` streams effectively operate in one of two modes: flowing and paused. These modes are separate from [object mode][object-mode]. @@ -704,7 +704,7 @@ stop flowing, and the data to be consumed via removed, then the stream will start flowing again if there is a [`'data'`][] event handler. -#### Three States +#### Three states The "two modes" of operation for a `Readable` stream are a simplified abstraction for the more complicated internal state management that is happening @@ -747,7 +747,7 @@ pass.resume(); // Must be called to make stream emit 'data'. While `readable.readableFlowing` is `false`, data may be accumulating within the stream's internal buffer. -#### Choose One API Style +#### Choose one API style The `Readable` stream API evolved across multiple Node.js versions and provides multiple methods of consuming stream data. In general, developers should choose @@ -881,7 +881,7 @@ The `'readable'` event is emitted when there is data available to be read from the stream. In some cases, attaching a listener for the `'readable'` event will cause some amount of data to be read into an internal buffer. -```javascript +```js const readable = getReadableStreamSomehow(); readable.on('readable', function() { // There is some data to read now. @@ -1164,7 +1164,7 @@ added: v9.4.0 * {boolean} This property reflects the current state of a `Readable` stream as described -in the [Stream Three States][] section. +in the [Three states][] section. ##### `readable.readableHighWaterMark` @@ -1701,7 +1701,7 @@ on the type of stream being created, as detailed in the chart below: The implementation code for a stream should *never* call the "public" methods of a stream that are intended for use by consumers (as described in the -[API for Stream Consumers][] section). Doing so may lead to adverse side effects +[API for stream consumers][] section). Doing so may lead to adverse side effects in application code consuming the stream. Avoid overriding public methods such as `write()`, `end()`, `cork()`, @@ -1711,7 +1711,7 @@ Doing so can break current and future stream invariants leading to behavior and/or compatibility issues with other streams, stream utilities, and user expectations. -### Simplified Construction +### Simplified construction @@ -1731,7 +1731,7 @@ const myWritable = new Writable({ }); ``` -### Implementing a Writable Stream +### Implementing a writable stream The `stream.Writable` class is extended to implement a [`Writable`][] stream. @@ -1761,7 +1761,7 @@ changes: specified in the [`stream.write()`][stream-write] call) before passing them to [`stream._write()`][stream-_write]. Other types of data are not converted (i.e. `Buffer`s are not decoded into `string`s). Setting to - false will prevent `string`s from being converted. **Default:** `true`. + false will prevent `string`s from being converted. **Default:** `true`. * `defaultEncoding` {string} The default encoding that is used when no encoding is specified as an argument to [`stream.write()`][stream-write]. **Default:** `'utf8'`. @@ -1810,7 +1810,7 @@ function MyWritable(options) { util.inherits(MyWritable, Writable); ``` -Or, using the Simplified Constructor approach: +Or, using the simplified constructor approach: ```js const { Writable } = require('stream'); @@ -1926,7 +1926,7 @@ This optional function will be called before the stream closes, delaying the `'finish'` event until `callback` is called. This is useful to close resources or write buffered data before a stream ends. -#### Errors While Writing +#### Errors while writing Errors occurring during the processing of the [`writable._write()`][], [`writable._writev()`][] and [`writable._final()`][] methods must be propagated @@ -1951,7 +1951,7 @@ const myWritable = new Writable({ }); ``` -#### An Example Writable Stream +#### An example writable stream The following illustrates a rather simplistic (and somewhat pointless) custom `Writable` stream implementation. While this specific `Writable` stream instance @@ -1972,7 +1972,7 @@ class MyWritable extends Writable { } ``` -#### Decoding buffers in a Writable Stream +#### Decoding buffers in a writable stream Decoding buffers is a common task, for instance, when using transformers whose input is a string. This is not a trivial process when using multi-byte @@ -2012,12 +2012,12 @@ w.end(euro[1]); console.log(w.data); // currency: € ``` -### Implementing a Readable Stream +### Implementing a readable stream The `stream.Readable` class is extended to implement a [`Readable`][] stream. Custom `Readable` streams *must* call the `new stream.Readable([options])` -constructor and implement the `readable._read()` method. +constructor and implement the [`readable._read()`][] method. #### `new stream.Readable([options])` @@ -2258,7 +2258,7 @@ class Counter extends Readable { } ``` -### Implementing a Duplex Stream +### Implementing a duplex stream A [`Duplex`][] stream is one that implements both [`Readable`][] and [`Writable`][], such as a TCP socket connection. @@ -2273,7 +2273,7 @@ both base classes due to overriding [`Symbol.hasInstance`][] on `stream.Writable`. Custom `Duplex` streams *must* call the `new stream.Duplex([options])` -constructor and implement *both* the `readable._read()` and +constructor and implement *both* the [`readable._read()`][] and `writable._write()` methods. #### `new stream.Duplex(options)` @@ -2325,7 +2325,7 @@ function MyDuplex(options) { util.inherits(MyDuplex, Duplex); ``` -Or, using the Simplified Constructor approach: +Or, using the simplified constructor approach: ```js const { Duplex } = require('stream'); @@ -2340,7 +2340,7 @@ const myDuplex = new Duplex({ }); ``` -#### An Example Duplex Stream +#### An example duplex stream The following illustrates a simple example of a `Duplex` stream that wraps a hypothetical lower-level source object to which data can be written, and @@ -2380,7 +2380,7 @@ The most important aspect of a `Duplex` stream is that the `Readable` and `Writable` sides operate independently of one another despite co-existing within a single object instance. -#### Object Mode Duplex Streams +#### Object mode duplex streams For `Duplex` streams, `objectMode` can be set exclusively for either the `Readable` or `Writable` side using the `readableObjectMode` and @@ -2421,7 +2421,7 @@ myTransform.write(100); // Prints: 64 ``` -### Implementing a Transform Stream +### Implementing a transform stream A [`Transform`][] stream is a [`Duplex`][] stream where the output is computed in some way from the input. Examples include [zlib][] streams or [crypto][] @@ -2436,10 +2436,10 @@ larger than its input. The `stream.Transform` class is extended to implement a [`Transform`][] stream. The `stream.Transform` class prototypically inherits from `stream.Duplex` and -implements its own versions of the `writable._write()` and `readable._read()` -methods. Custom `Transform` implementations *must* implement the -[`transform._transform()`][stream-_transform] method and *may* also implement -the [`transform._flush()`][stream-_flush] method. +implements its own versions of the `writable._write()` and +[`readable._read()`][] methods. Custom `Transform` implementations *must* +implement the [`transform._transform()`][stream-_transform] method and *may* +also implement the [`transform._flush()`][stream-_flush] method. Care must be taken when using `Transform` streams in that data written to the stream can cause the `Writable` side of the stream to become paused if the @@ -2480,7 +2480,7 @@ function MyTransform(options) { util.inherits(MyTransform, Transform); ``` -Or, using the Simplified Constructor approach: +Or, using the simplified constructor approach: ```js const { Transform } = require('stream'); @@ -2590,11 +2590,11 @@ stream that simply passes the input bytes across to the output. Its purpose is primarily for examples and testing, but there are some use cases where `stream.PassThrough` is useful as a building block for novel sorts of streams. -## Additional Notes +## Additional notes -### Streams Compatibility with Async Generators and Async Iterators +### Streams compatibility with async generators and async iterators With the support of async generators and iterators in JavaScript, async generators are effectively a first-class language-level stream construct at @@ -2603,7 +2603,7 @@ this point. Some common interop cases of using Node.js streams with async generators and async iterators are provided below. -#### Consuming Readable Streams with Async Iterators +#### Consuming readable streams with async iterators ```js (async function() { @@ -2616,9 +2616,9 @@ and async iterators are provided below. Async iterators register a permanent error handler on the stream to prevent any unhandled post-destroy errors. -#### Creating Readable Streams with Async Generators +#### Creating readable streams with async generators -We can construct a Node.js Readable Stream from an asynchronous generator +We can construct a Node.js readable stream from an asynchronous generator using the `Readable.from()` utility method: ```js @@ -2637,7 +2637,7 @@ readable.on('data', (chunk) => { }); ``` -#### Piping to Writable Streams from Async Iterators +#### Piping to writable streams from async iterators In the scenario of writing to a writable stream from an async iterator, ensure the correct handling of backpressure and errors. @@ -2718,7 +2718,7 @@ const writable = fs.createWriteStream('./file'); -### Compatibility with Older Node.js Versions +### Compatibility with older Node.js versions @@ -2859,8 +2859,8 @@ contain multi-byte characters. [`writable.uncork()`]: #stream_writable_uncork [`writable.writableFinished`]: #stream_writable_writablefinished [`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 +[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 [HTTP requests, on the client]: http.html#http_class_http_clientrequest [HTTP responses, on the server]: http.html#http_class_http_serverresponse @@ -2888,7 +2888,7 @@ contain multi-byte characters. [stream-resume]: #stream_readable_resume [stream-uncork]: #stream_writable_uncork [stream-write]: #stream_writable_write_chunk_encoding_callback -[Stream Three States]: #stream_three_states +[Three states]: #stream_three_states [writable-_destroy]: #stream_writable_destroy_err_callback [writable-destroy]: #stream_writable_destroy_error [writable-new]: #stream_constructor_new_stream_writable_options diff --git a/doc/api/string_decoder.md b/doc/api/string_decoder.md index 54fcc876c9a9e9..5cd6121d50ddb9 100644 --- a/doc/api/string_decoder.md +++ b/doc/api/string_decoder.md @@ -1,4 +1,4 @@ -# String Decoder +# String decoder diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index c296ffb0fa43c7..8ae933a499a16c 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -1,4 +1,4 @@ -# Usage & Example +# Usage and example ## Usage diff --git a/doc/api/timers.md b/doc/api/timers.md index a312022791f54b..8b080b16ffb70e 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -123,7 +123,7 @@ Calling `timeout.unref()` creates an internal timer that will wake the Node.js event loop. Creating too many of these can adversely impact performance of the Node.js application. -## Scheduling Timers +## Scheduling timers A timer in Node.js is an internal construct that calls a given function after a certain period of time. When a timer's function is called varies depending on @@ -226,7 +226,7 @@ setTimeoutPromise(40, 'foobar').then((value) => { }); ``` -## Cancelling Timers +## Cancelling timers The [`setImmediate()`][], [`setInterval()`][], and [`setTimeout()`][] methods each return objects that represent the scheduled timers. These can be used to diff --git a/doc/api/tls.md b/doc/api/tls.md index 04f5e23d3902ae..41f99c91c852b0 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -12,7 +12,7 @@ The module can be accessed using: const tls = require('tls'); ``` -## TLS/SSL Concepts +## TLS/SSL concepts The TLS/SSL is a public/private key infrastructure (PKI). For most common cases, each client and server must have a *private key*. @@ -21,7 +21,7 @@ Private keys can be generated in multiple ways. The example below illustrates use of the OpenSSL command-line interface to generate a 2048-bit RSA private key: -```sh +```bash openssl genrsa -out ryans-key.pem 2048 ``` @@ -35,7 +35,7 @@ step to obtaining a certificate is to create a *Certificate Signing Request* The OpenSSL command-line interface can be used to generate a CSR for a private key: -```sh +```bash openssl req -new -sha256 -key ryans-key.pem -out ryans-csr.pem ``` @@ -45,14 +45,14 @@ Authority for signing or used to generate a self-signed certificate. Creating a self-signed certificate using the OpenSSL command-line interface is illustrated in the example below: -```sh +```bash openssl x509 -req -in ryans-csr.pem -signkey ryans-key.pem -out ryans-cert.pem ``` Once the certificate is generated, it can be used to generate a `.pfx` or `.p12` file: -```sh +```bash openssl pkcs12 -export -in ryans-cert.pem -inkey ryans-key.pem \ -certfile ca-cert.pem -out ryans.pfx ``` @@ -64,11 +64,11 @@ Where: * `certfile`: is a concatenation of all Certificate Authority (CA) certs into a single file, e.g. `cat ca1-cert.pem ca2-cert.pem > ca-cert.pem` -### Perfect Forward Secrecy +### Perfect forward secrecy -The term "[Forward Secrecy][]" or "Perfect Forward Secrecy" describes a feature +The term _[forward secrecy][]_ or _perfect forward secrecy_ describes a feature of key-agreement (i.e., key-exchange) methods. That is, the server and client keys are used to negotiate new temporary keys that are used specifically and only for the current communication session. Practically, this means that even @@ -76,11 +76,11 @@ if the server's private key is compromised, communication can only be decrypted by eavesdroppers if the attacker manages to obtain the key-pair specifically generated for the session. -Perfect Forward Secrecy is achieved by randomly generating a key pair for +Perfect forward secrecy is achieved by randomly generating a key pair for key-agreement on every TLS/SSL handshake (in contrast to using the same key for all sessions). Methods implementing this technique are called "ephemeral". -Currently two methods are commonly used to achieve Perfect Forward Secrecy (note +Currently two methods are commonly used to achieve perfect forward secrecy (note the character "E" appended to the traditional abbreviations): * [DHE][]: An ephemeral version of the Diffie Hellman key-agreement protocol. @@ -90,21 +90,21 @@ the character "E" appended to the traditional abbreviations): Ephemeral methods may have some performance drawbacks, because key generation is expensive. -To use Perfect Forward Secrecy using `DHE` with the `tls` module, it is required +To use perfect forward secrecy using `DHE` with the `tls` module, it is required to generate Diffie-Hellman parameters and specify them with the `dhparam` option to [`tls.createSecureContext()`][]. The following illustrates the use of the OpenSSL command-line interface to generate such parameters: -```sh +```bash openssl dhparam -outform PEM -out dhparam.pem 2048 ``` -If using Perfect Forward Secrecy using `ECDHE`, Diffie-Hellman parameters are +If using perfect forward secrecy using `ECDHE`, Diffie-Hellman parameters are not required and a default ECDHE curve will be used. The `ecdhCurve` property can be used when creating a TLS Server to specify the list of names of supported curves to use, see [`tls.createServer()`][] for more info. -Perfect Forward Secrecy was optional up to TLSv1.2, but it is not optional for +Perfect forward secrecy was optional up to TLSv1.2, but it is not optional for TLSv1.3, because all TLSv1.3 cipher suites use ECDHE. ### ALPN and SNI @@ -175,13 +175,15 @@ understanding of the implications and risks. TLSv1.3 does not support renegotiation. -### Session Resumption +### Session resumption Establishing a TLS session can be relatively slow. The process can be sped up by saving and later reusing the session state. There are several mechanisms to do so, discussed here from oldest to newest (and preferred). -***Session Identifiers*** Servers generate a unique ID for new connections and +#### Session identifiers + +Servers generate a unique ID for new connections and send it to the client. Clients and servers save the session state. When reconnecting, clients send the ID of their saved session state and if the server also has the state for that ID, it can agree to use it. Otherwise, the server @@ -200,7 +202,9 @@ reuse sessions. To reuse sessions across load balancers or cluster workers, servers must use a shared session cache (such as Redis) in their session handlers. -***Session Tickets*** The servers encrypt the entire session state and send it +#### Session tickets + +The servers encrypt the entire session state and send it to the client as a "ticket". When reconnecting, the state is sent to the server in the initial connection. This mechanism avoids the need for server-side session cache. If the server doesn't use the ticket, for any reason (failure @@ -250,7 +254,7 @@ failures, it is easy to not notice unnecessarily poor TLS performance. The OpenSSL CLI can be used to verify that servers are resuming sessions. Use the `-reconnect` option to `openssl s_client`, for example: -```sh +```console $ openssl s_client -connect localhost:443 -reconnect ``` @@ -267,35 +271,38 @@ Subsequent connections should say "Reused", for example: Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256 ``` -## Modifying the Default TLS Cipher suite - -Node.js is built with a default suite of enabled and disabled TLS ciphers. -Currently, the default cipher suite is: - -```txt -TLS_AES_256_GCM_SHA384: -TLS_CHACHA20_POLY1305_SHA256: -TLS_AES_128_GCM_SHA256: -ECDHE-RSA-AES128-GCM-SHA256: -ECDHE-ECDSA-AES128-GCM-SHA256: -ECDHE-RSA-AES256-GCM-SHA384: -ECDHE-ECDSA-AES256-GCM-SHA384: -DHE-RSA-AES128-GCM-SHA256: -ECDHE-RSA-AES128-SHA256: -DHE-RSA-AES128-SHA256: -ECDHE-RSA-AES256-SHA384: -DHE-RSA-AES256-SHA384: -ECDHE-RSA-AES256-SHA256: -DHE-RSA-AES256-SHA256: -HIGH: -!aNULL: -!eNULL: -!EXPORT: -!DES: -!RC4: -!MD5: -!PSK: -!SRP: +## Modifying the default TLS cipher suite + +Node.js is built with a default suite of enabled and disabled TLS ciphers. This +default cipher list can be configured when building Node.js to allow +distributions to provide their own default list. + +The following command can be used to show the default cipher suite: +```console +node -p crypto.constants.defaultCoreCipherList | tr ':' '\n' +TLS_AES_256_GCM_SHA384 +TLS_CHACHA20_POLY1305_SHA256 +TLS_AES_128_GCM_SHA256 +ECDHE-RSA-AES128-GCM-SHA256 +ECDHE-ECDSA-AES128-GCM-SHA256 +ECDHE-RSA-AES256-GCM-SHA384 +ECDHE-ECDSA-AES256-GCM-SHA384 +DHE-RSA-AES128-GCM-SHA256 +ECDHE-RSA-AES128-SHA256 +DHE-RSA-AES128-SHA256 +ECDHE-RSA-AES256-SHA384 +DHE-RSA-AES256-SHA384 +ECDHE-RSA-AES256-SHA256 +DHE-RSA-AES256-SHA256 +HIGH +!aNULL +!eNULL +!EXPORT +!DES +!RC4 +!MD5 +!PSK +!SRP !CAMELLIA ``` @@ -304,10 +311,10 @@ line switch (directly, or via the [`NODE_OPTIONS`][] environment variable). For instance, the following makes `ECDHE-RSA-AES128-GCM-SHA256:!RC4` the default TLS cipher suite: -```sh -node --tls-cipher-list="ECDHE-RSA-AES128-GCM-SHA256:!RC4" server.js +```bash +node --tls-cipher-list='ECDHE-RSA-AES128-GCM-SHA256:!RC4' server.js -export NODE_OPTIONS=--tls-cipher-list="ECDHE-RSA-AES128-GCM-SHA256:!RC4" +export NODE_OPTIONS=--tls-cipher-list='ECDHE-RSA-AES128-GCM-SHA256:!RC4' node server.js ``` @@ -318,9 +325,9 @@ in [`tls.createServer()`][], [`tls.connect()`][], and when creating new The ciphers list can contain a mixture of TLSv1.3 cipher suite names, the ones that start with `'TLS_'`, and specifications for TLSv1.2 and below cipher -suites. The TLSv1.2 ciphers support a legacy specification format, consult +suites. The TLSv1.2 ciphers support a legacy specification format, consult the OpenSSL [cipher list format][] documentation for details, but those -specifications do *not* apply to TLSv1.3 ciphers. The TLSv1.3 suites can only +specifications do *not* apply to TLSv1.3 ciphers. The TLSv1.3 suites can only be enabled by including their full name in the cipher list. They cannot, for example, be enabled or disabled by using the legacy TLSv1.2 `'EECDH'` or `'!EECDH'` specification. @@ -337,8 +344,8 @@ of an application. The `--tls-cipher-list` switch and `ciphers` option should by used only if absolutely necessary. The default cipher suite prefers GCM ciphers for [Chrome's 'modern -cryptography' setting][] and also prefers ECDHE and DHE ciphers for Perfect -Forward Secrecy, while offering *some* backward compatibility. +cryptography' setting][] and also prefers ECDHE and DHE ciphers for perfect +forward secrecy, while offering *some* backward compatibility. 128 bit AES is preferred over 192 and 256 bit AES in light of [specific attacks affecting larger AES key sizes][]. @@ -761,12 +768,12 @@ On the client, the `session` can be provided to the `session` option of See [Session Resumption][] for more information. For TLSv1.2 and below, [`tls.TLSSocket.getSession()`][] can be called once -the handshake is complete. For TLSv1.3, only ticket-based resumption is allowed +the handshake is complete. For TLSv1.3, only ticket-based resumption is allowed by the protocol, multiple tickets are sent, and the tickets aren't sent until after the handshake completes. So it is necessary to wait for the -`'session'` event to get a resumable session. Applications +`'session'` event to get a resumable session. Applications should use the `'session'` event instead of `getSession()` to ensure -they will work for all TLS versions. Applications that only expect to +they will work for all TLS versions. Applications that only expect to get or use one session should listen for this event only once: ```js @@ -895,7 +902,7 @@ added: v5.0.0 * Returns: {Object} Returns an object representing the type, name, and size of parameter of -an ephemeral key exchange in [Perfect Forward Secrecy][] on a client +an ephemeral key exchange in [perfect forward secrecy][] on a client connection. It returns an empty object when the key exchange is not ephemeral. As this is only supported on a client socket; `null` is returned if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The @@ -937,7 +944,7 @@ If the full certificate chain was requested, each certificate will include an `issuerCertificate` property containing an object representing its issuer's certificate. -#### Certificate Object +#### Certificate object > Stability: 1 - Experimental -Trace Event provides a mechanism to centralize tracing information generated by -V8, Node.js core, and userspace code. +The `trace_events` module provides a mechanism to centralize tracing information +generated by V8, Node.js core, and userspace code. Tracing can be enabled with the `--trace-event-categories` command-line flag or by using the `trace_events` module. The `--trace-event-categories` flag @@ -36,7 +36,7 @@ The available categories are: By default the `node`, `node.async_hooks`, and `v8` categories are enabled. -```txt +```bash node --trace-event-categories v8,node,node.async_hooks server.js ``` @@ -45,10 +45,10 @@ flag to enable trace events. This requirement has been removed. However, the `--trace-events-enabled` flag *may* still be used and will enable the `node`, `node.async_hooks`, and `v8` trace event categories by default. -```txt +```bash node --trace-events-enabled -// is equivalent to +# is equivalent to node --trace-event-categories v8,node,node.async_hooks ``` @@ -74,7 +74,7 @@ The logging file is by default called `node_trace.${rotation}.log`, where be specified with `--trace-event-file-pattern` that accepts a template string that supports `${rotation}` and `${pid}`: -```txt +```bash node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js ``` diff --git a/doc/api/tty.md b/doc/api/tty.md index 0c2f963750fd1f..cd6ff1a7310db6 100644 --- a/doc/api/tty.md +++ b/doc/api/tty.md @@ -19,7 +19,7 @@ default be instances of `tty.WriteStream`. The preferred method of determining whether Node.js is being run within a TTY context is to check that the value of the `process.stdout.isTTY` property is `true`: -```sh +```console $ node -p -e "Boolean(process.stdout.isTTY)" true $ node -p -e "Boolean(process.stdout.isTTY)" | cat diff --git a/doc/api/url.md b/doc/api/url.md index 3da8adbe8568d2..38f5c496c199e1 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -11,7 +11,7 @@ accessed using: const url = require('url'); ``` -## URL Strings and URL Objects +## URL strings and URL objects A URL string is a structured string containing multiple meaningful components. When parsed, a URL object is returned containing properties for each of these @@ -29,7 +29,7 @@ properties of a WHATWG `URL` object. WHATWG URL's `origin` property includes `protocol` and `host`, but not `username` or `password`. -```txt +```text ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ href │ ├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤ @@ -406,7 +406,7 @@ console.log(myURL.href); Invalid URL protocol values assigned to the `protocol` property are ignored. -##### Special Schemes +##### Special schemes The [WHATWG URL Standard][] considers a handful of URL protocol schemes to be _special_ in terms of how they are parsed and serialized. When a URL is @@ -999,8 +999,8 @@ pathToFileURL(__filename); // Correct: file:///C:/... (Windows) new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1 pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX) -new URL('/some/path%.js', 'file:'); // Incorrect: file:///some/path% -pathToFileURL('/some/path%.js'); // Correct: file:///some/path%25 (POSIX) +new URL('/some/path%.c', 'file:'); // Incorrect: file:///some/path%.c +pathToFileURL('/some/path%.c'); // Correct: file:///some/path%25.c (POSIX) ``` ## Legacy URL API @@ -1276,7 +1276,7 @@ url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' ``` -## Percent-Encoding in URLs +## Percent-encoding in URLs URLs are permitted to only contain a certain range of characters. Any character falling outside of that range must be encoded. How such characters are encoded, @@ -1288,7 +1288,7 @@ located within the structure of the URL. Within the Legacy API, spaces (`' '`) and the following characters will be automatically escaped in the properties of URL objects: -```txt +```text < > " ` \r \n \t { } | \ ^ ' ``` diff --git a/doc/api/util.md b/doc/api/util.md index ab2e94ef60ee84..85a4a5782e1952 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -42,7 +42,7 @@ callbackFunction((err, ret) => { Will print: -```txt +```text hello world ``` @@ -93,7 +93,7 @@ debuglog('hello from foo [%d]', 123); If this program is run with `NODE_DEBUG=foo` in the environment, then it will output something like: -```txt +```console FOO 3245: hello from foo [123] ``` @@ -112,7 +112,7 @@ debuglog('hi there, it\'s foo-bar [%d]', 2333); if it is run with `NODE_DEBUG=foo*` in the environment, then it will output something like: -```txt +```console FOO-BAR 3257: hi there, it's foo-bar [2333] ``` @@ -243,8 +243,7 @@ corresponding argument. Supported specifiers are: * `%O`: `Object`. A string representation of an object with generic JavaScript object formatting. Similar to `util.inspect()` without options. This will show the full object not including non-enumerable properties and proxies. -* `%c`: `CSS`. This specifier is currently ignored, and will skip any CSS - passed in. +* `%c`: `CSS`. This specifier is ignored and will skip any CSS passed in. * `%%`: single percent sign (`'%'`). This does not consume an argument. * Returns: {string} The formatted string @@ -752,7 +751,7 @@ ignored, if not supported. * `bgCyanBright` * `bgWhiteBright` -### Custom inspection functions on Objects +### Custom inspection functions on objects @@ -1041,7 +1040,7 @@ while (buffer = getNextChunkSomehow()) { string += decoder.decode(); // end-of-stream ``` -### WHATWG Supported Encodings +### WHATWG supported encodings Per the [WHATWG Encoding Standard][], the encodings supported by the `TextDecoder` API are outlined in the tables below. For each encoding, @@ -1067,7 +1066,7 @@ with ICU and using the full ICU data (see [Internationalization][]). | `'utf-16le'` | `'utf-16'` | | `'utf-16be'` | | -#### Encodings Requiring Full ICU Data +#### Encodings requiring full ICU data | Encoding | Aliases | | ----------------- | -------------------------------- | @@ -1263,7 +1262,7 @@ added: v10.0.0 * Returns: {boolean} Returns `true` if the value is an instance of one of the [`ArrayBuffer`][] -views, such as typed array objects or [`DataView`][]. Equivalent to +views, such as typed array objects or [`DataView`][]. Equivalent to [`ArrayBuffer.isView()`][]. ```js @@ -2420,7 +2419,7 @@ util.log('Timestamped message.'); [`util.types.isNativeError()`]: #util_util_types_isnativeerror_value [`util.types.isSharedArrayBuffer()`]: #util_util_types_issharedarraybuffer_value [Common System Errors]: errors.html#errors_common_system_errors -[Custom inspection functions on Objects]: #util_custom_inspection_functions_on_objects +[Custom inspection functions on objects]: #util_custom_inspection_functions_on_objects [Custom promisified functions]: #util_custom_promisified_functions [Customizing `util.inspect` colors]: #util_customizing_util_inspect_colors [Internationalization]: intl.html diff --git a/doc/api/v8.md b/doc/api/v8.md index 97ca7e0a2b3138..374ba06dafe830 100644 --- a/doc/api/v8.md +++ b/doc/api/v8.md @@ -231,7 +231,7 @@ DevTools. The JSON schema is undocumented and specific to the V8 engine, and may change from one version of V8 to the next. A heap snapshot is specific to a single V8 isolate. When using -[Worker Threads][], a heap snapshot generated from the main thread will +[worker threads][], a heap snapshot generated from the main thread will not contain any information about the workers, and vice versa. ```js @@ -519,4 +519,4 @@ A subclass of [`Deserializer`][] corresponding to the format written by [`vm.Script`]: vm.html#vm_constructor_new_vm_script_code_options [HTML structured clone algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm [V8]: https://developers.google.com/v8/ -[Worker Threads]: worker_threads.html +[worker threads]: worker_threads.html diff --git a/doc/api/vm.md b/doc/api/vm.md index 34f57a8fb9b9c0..d1eccc3580c92a 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -1,4 +1,4 @@ -# VM (Executing JavaScript) +# VM (executing JavaScript) @@ -318,7 +318,7 @@ linking, and evaluation. These three steps are illustrated in the following example. This implementation lies at a lower level than the [ECMAScript Module -loader][]. There is also currently no way to interact with the Loader, though +loader][]. There is also no way to interact with the Loader yet, though support is planned. ```js @@ -1081,7 +1081,7 @@ local scope, so the value `localVar` is changed. In this way `vm.runInThisContext()` is much like an [indirect `eval()` call][], e.g. `(0,eval)('code')`. -## Example: Running an HTTP Server within a VM +## Example: Running an HTTP server within a VM When using either [`script.runInThisContext()`][] or [`vm.runInThisContext()`][], the code is executed within the current V8 global @@ -1131,7 +1131,7 @@ within which it can operate. The process of creating the V8 Context and associating it with the `contextObject` is what this document refers to as "contextifying" the object. -## Timeout limitations when using `process.nextTick()`, Promises, and `queueMicrotask()` +## Timeout limitations when using `process.nextTick()`, promises, and `queueMicrotask()` Because of the internal mechanics of how the `process.nextTick()` queue and the microtask queue that underlies Promises are implemented within V8 and diff --git a/doc/api/wasi.md b/doc/api/wasi.md index 23c2182fff8ffd..95e212e3c2974b 100644 --- a/doc/api/wasi.md +++ b/doc/api/wasi.md @@ -22,15 +22,54 @@ const wasi = new WASI({ const importObject = { wasi_snapshot_preview1: wasi.wasiImport }; (async () => { - const wasm = await WebAssembly.compile(fs.readFileSync('./binary.wasm')); + const wasm = await WebAssembly.compile(fs.readFileSync('./demo.wasm')); const instance = await WebAssembly.instantiate(wasm, importObject); wasi.start(instance); })(); ``` +To run the above example, create a new WebAssembly text format file named +`demo.wat`: + +```text +(module + ;; Import the required fd_write WASI function which will write the given io vectors to stdout + ;; The function signature for fd_write is: + ;; (File Descriptor, *iovs, iovs_len, nwritten) -> Returns number of bytes written + (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) + + (memory 1) + (export "memory" (memory 0)) + + ;; Write 'hello world\n' to memory at an offset of 8 bytes + ;; Note the trailing newline which is required for the text to appear + (data (i32.const 8) "hello world\n") + + (func $main (export "_start") + ;; Creating a new io vector within linear memory + (i32.store (i32.const 0) (i32.const 8)) ;; iov.iov_base - This is a pointer to the start of the 'hello world\n' string + (i32.store (i32.const 4) (i32.const 12)) ;; iov.iov_len - The length of the 'hello world\n' string + + (call $fd_write + (i32.const 1) ;; file_descriptor - 1 for stdout + (i32.const 0) ;; *iovs - The pointer to the iov array, which is stored at memory location 0 + (i32.const 1) ;; iovs_len - We're printing 1 string stored in an iov - so one. + (i32.const 20) ;; nwritten - A place in memory to store the number of bytes written + ) + drop ;; Discard the number of bytes written from the top of the stack + ) +) +``` + +Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm` + +```console +$ wat2wasm demo.wat +``` + The `--experimental-wasi-unstable-preview1` and `--experimental-wasm-bigint` -CLI arguments are needed for the previous example to run. +CLI arguments are needed for this example to run. ## Class: `WASI` diff --git a/doc/api/zlib.md b/doc/api/zlib.md index 195c874f8decbc..1abd3f93e9581b 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -93,7 +93,7 @@ do_unzip(buffer) }); ``` -## Threadpool Usage and Performance Considerations +## Threadpool usage and performance considerations All `zlib` APIs, except those that are explicitly synchronous, use the Node.js internal threadpool. This can lead to surprising effects and performance @@ -133,7 +133,7 @@ message. The examples given below are drastically simplified to show the basic concept. Using `zlib` encoding can be expensive, and the results ought to be cached. -See [Memory Usage Tuning][] for more information on the speed/memory/compression +See [Memory usage tuning][] for more information on the speed/memory/compression tradeoffs involved in `zlib` usage. ```js @@ -252,7 +252,7 @@ possible to determine whether the input ended prematurely or lacks the integrity checks, making it necessary to manually check that the decompressed result is valid. -## Memory Usage Tuning +## Memory usage tuning @@ -814,7 +814,7 @@ added: v0.5.8 Creates and returns a new [`Unzip`][] object. -## Convenience Methods +## Convenience methods @@ -1154,7 +1154,7 @@ Decompress a chunk of data with [`Unzip`][]. [`stream.Transform`]: stream.html#stream_class_stream_transform [`zlib.bytesWritten`]: #zlib_zlib_byteswritten [Brotli parameters]: #zlib_brotli_constants -[Memory Usage Tuning]: #zlib_memory_usage_tuning +[Memory usage tuning]: #zlib_memory_usage_tuning [RFC 7932]: https://www.rfc-editor.org/rfc/rfc7932.txt [Streams API]: stream.md [zlib documentation]: https://zlib.net/manual.html#Constants diff --git a/doc/api_assets/README.md b/doc/api_assets/README.md new file mode 100644 index 00000000000000..58799cf12fcb88 --- /dev/null +++ b/doc/api_assets/README.md @@ -0,0 +1,27 @@ +# API Reference Document Assets + +## highlight.pack.js + +_Generated by [highlightjs.org/download][] on 2020-05-16._ + +Grammars included in the custom bundle: + +* Bash +* C +* C++ +* CoffeeScript +* JavaScript +* JSON +* Markdown +* Plaintext +* Shell Session + +## hljs.css + +The syntax theme for code snippets in API reference documents. + +## style.css + +The main stylesheet for API reference documents. + +[highlightjs.org/download]: https://highlightjs.org/download/ diff --git a/doc/api_assets/highlight.pack.js b/doc/api_assets/highlight.pack.js new file mode 100644 index 00000000000000..a493e16d3a7238 --- /dev/null +++ b/doc/api_assets/highlight.pack.js @@ -0,0 +1,6 @@ +/* + Highlight.js 10.0.3 (a4b1bd2d) + License: BSD-3-Clause + Copyright (c) 2006-2020, Ivan Sagalaev +*/ +var hljs=function(){"use strict";function e(n){Object.freeze(n);var t="function"==typeof n;return Object.getOwnPropertyNames(n).forEach((function(r){!n.hasOwnProperty(r)||null===n[r]||"object"!=typeof n[r]&&"function"!=typeof n[r]||t&&("caller"===r||"callee"===r||"arguments"===r)||Object.isFrozen(n[r])||e(n[r])})),n}function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach((function(e){for(n in e)t[n]=e[n]})),t}function r(e){return e.nodeName.toLowerCase()}var a=Object.freeze({__proto__:null,escapeHTML:n,inherit:t,nodeStream:function(e){var n=[];return function e(t,a){for(var i=t.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=e(i,a),r(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n},mergeStreams:function(e,t,a){var i=0,s="",o=[];function l(){return e.length&&t.length?e[0].offset!==t[0].offset?e[0].offset"}function u(e){s+=""}function d(e){("start"===e.event?c:u)(e.node)}for(;e.length||t.length;){var g=l();if(s+=n(a.substring(i,g[0].offset)),i=g[0].offset,g===e){o.reverse().forEach(u);do{d(g.splice(0,1)[0]),g=l()}while(g===e&&g.length&&g[0].offset===i);o.reverse().forEach(c)}else"start"===g[0].event?o.push(g[0].node):o.pop(),d(g.splice(0,1)[0])}return s+n(a.substr(i))}});const i="",s=e=>!!e.kind;class o{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=n(e)}openNode(e){if(!s(e))return;let n=e.kind;e.sublanguage||(n=`${this.classPrefix}${n}`),this.span(n)}closeNode(e){s(e)&&(this.buffer+=i)}span(e){this.buffer+=``}value(){return this.buffer}}class l{constructor(){this.rootNode={children:[]},this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let n={kind:e,children:[]};this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(n=>this._walk(e,n)),e.closeNode(n)),e}static _collapse(e){e.children&&(e.children.every(e=>"string"==typeof e)?(e.text=e.children.join(""),delete e.children):e.children.forEach(e=>{"string"!=typeof e&&l._collapse(e)}))}}class c extends l{constructor(e){super(),this.options=e}addKeyword(e,n){""!==e&&(this.openNode(n),this.addText(e),this.closeNode())}addText(e){""!==e&&this.add(e)}addSublanguage(e,n){let t=e.root;t.kind=n,t.sublanguage=!0,this.add(t)}toHTML(){return new o(this,this.options).value()}finalize(){}}function u(e){return e&&e.source||e}const d="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",g={begin:"\\\\[\\s\\S]",relevance:0},h={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[g]},f={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[g]},p={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},m=function(e,n,r){var a=t({className:"comment",begin:e,end:n,contains:[]},r||{});return a.contains.push(p),a.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|XXX):",relevance:0}),a},b=m("//","$"),v=m("/\\*","\\*/"),x=m("#","$");var _=Object.freeze({__proto__:null,IDENT_RE:"[a-zA-Z]\\w*",UNDERSCORE_IDENT_RE:"[a-zA-Z_]\\w*",NUMBER_RE:"\\b\\d+(\\.\\d+)?",C_NUMBER_RE:d,BINARY_NUMBER_RE:"\\b(0b[01]+)",RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",BACKSLASH_ESCAPE:g,APOS_STRING_MODE:h,QUOTE_STRING_MODE:f,PHRASAL_WORDS_MODE:p,COMMENT:m,C_LINE_COMMENT_MODE:b,C_BLOCK_COMMENT_MODE:v,HASH_COMMENT_MODE:x,NUMBER_MODE:{className:"number",begin:"\\b\\d+(\\.\\d+)?",relevance:0},C_NUMBER_MODE:{className:"number",begin:d,relevance:0},BINARY_NUMBER_MODE:{className:"number",begin:"\\b(0b[01]+)",relevance:0},CSS_NUMBER_MODE:{className:"number",begin:"\\b\\d+(\\.\\d+)?(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},REGEXP_MODE:{begin:/(?=\/[^\/\n]*\/)/,contains:[{className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[g,{begin:/\[/,end:/\]/,relevance:0,contains:[g]}]}]},TITLE_MODE:{className:"title",begin:"[a-zA-Z]\\w*",relevance:0},UNDERSCORE_TITLE_MODE:{className:"title",begin:"[a-zA-Z_]\\w*",relevance:0},METHOD_GUARD:{begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0}}),E="of and for in not or if then".split(" ");function R(e,n){return n?+n:(t=e,E.includes(t.toLowerCase())?0:1);var t}const N=n,w=t,{nodeStream:y,mergeStreams:O}=a;return function(n){var r=[],a={},i={},s=[],o=!0,l=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,d="Could not find the language '{}', did you forget to load/include a language module?",g={noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0,__emitter:c};function h(e){return g.noHighlightRe.test(e)}function f(e,n,t,r){var a={code:n,language:e};T("before:highlight",a);var i=a.result?a.result:p(a.language,a.code,t,r);return i.code=a.code,T("after:highlight",i),i}function p(e,n,r,i){var s=n;function l(e,n){var t=v.case_insensitive?n[0].toLowerCase():n[0];return e.keywords.hasOwnProperty(t)&&e.keywords[t]}function c(){null!=_.subLanguage?function(){if(""!==k){var e="string"==typeof _.subLanguage;if(!e||a[_.subLanguage]){var n=e?p(_.subLanguage,k,!0,E[_.subLanguage]):m(k,_.subLanguage.length?_.subLanguage:void 0);_.relevance>0&&(T+=n.relevance),e&&(E[_.subLanguage]=n.top),w.addSublanguage(n.emitter,n.language)}else w.addText(k)}}():function(){var e,n,t,r;if(_.keywords){for(n=0,_.lexemesRe.lastIndex=0,t=_.lexemesRe.exec(k),r="";t;){r+=k.substring(n,t.index);var a=null;(e=l(_,t))?(w.addText(r),r="",T+=e[1],a=e[0],w.addKeyword(t[0],a)):r+=t[0],n=_.lexemesRe.lastIndex,t=_.lexemesRe.exec(k)}r+=k.substr(n),w.addText(r)}else w.addText(k)}(),k=""}function h(e){e.className&&w.openNode(e.className),_=Object.create(e,{parent:{value:_}})}var f={};function b(n,t){var a,i=t&&t[0];if(k+=n,null==i)return c(),0;if("begin"==f.type&&"end"==t.type&&f.index==t.index&&""===i){if(k+=s.slice(t.index,t.index+1),!o)throw(a=Error("0 width match regex")).languageName=e,a.badRule=f.rule,a;return 1}if(f=t,"begin"===t.type)return function(e){var n=e[0],t=e.rule;return t.__onBegin&&(t.__onBegin(e)||{}).ignoreMatch?function(e){return 0===_.matcher.regexIndex?(k+=e[0],1):(B=!0,0)}(n):(t&&t.endSameAsBegin&&(t.endRe=RegExp(n.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")),t.skip?k+=n:(t.excludeBegin&&(k+=n),c(),t.returnBegin||t.excludeBegin||(k=n)),h(t),t.returnBegin?0:n.length)}(t);if("illegal"===t.type&&!r)throw(a=Error('Illegal lexeme "'+i+'" for mode "'+(_.className||"")+'"')).mode=_,a;if("end"===t.type){var l=function(e){var n=e[0],t=s.substr(e.index),r=function e(n,t){if(function(e,n){var t=e&&e.exec(n);return t&&0===t.index}(n.endRe,t)){for(;n.endsParent&&n.parent;)n=n.parent;return n}if(n.endsWithParent)return e(n.parent,t)}(_,t);if(r){var a=_;a.skip?k+=n:(a.returnEnd||a.excludeEnd||(k+=n),c(),a.excludeEnd&&(k=n));do{_.className&&w.closeNode(),_.skip||_.subLanguage||(T+=_.relevance),_=_.parent}while(_!==r.parent);return r.starts&&(r.endSameAsBegin&&(r.starts.endRe=r.endRe),h(r.starts)),a.returnEnd?0:n.length}}(t);if(null!=l)return l}if("illegal"===t.type&&""===i)return 1;if(A>1e5&&A>3*t.index)throw Error("potential infinite loop, way more iterations than matches");return k+=i,i.length}var v=M(e);if(!v)throw console.error(d.replace("{}",e)),Error('Unknown language: "'+e+'"');!function(e){function n(n,t){return RegExp(u(n),"m"+(e.case_insensitive?"i":"")+(t?"g":""))}class r{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=function(e){return RegExp(e.toString()+"|").exec("").length-1}(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=n(function(e,n){for(var t=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,r=0,a="",i=0;i0&&(a+="|"),a+="(";o.length>0;){var l=t.exec(o);if(null==l){a+=o;break}a+=o.substring(0,l.index),o=o.substring(l.index+l[0].length),"\\"==l[0][0]&&l[1]?a+="\\"+(+l[1]+s):(a+=l[0],"("==l[0]&&r++)}a+=")"}return a}(e),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let n=this.matcherRe.exec(e);if(!n)return null;let t=n.findIndex((e,n)=>n>0&&null!=e),r=this.matchIndexes[t];return Object.assign(n,r)}}class a{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let n=new r;return this.rules.slice(e).forEach(([e,t])=>n.addRule(e,t)),n.compile(),this.multiRegexes[e]=n,n}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){let n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;let t=n.exec(e);return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&(this.regexIndex=0)),t}}function i(e){let n=e.input[e.index-1],t=e.input[e.index+e[0].length];if("."===n||"."===t)return{ignoreMatch:!0}}if(e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");!function r(s,o){s.compiled||(s.compiled=!0,s.__onBegin=null,s.keywords=s.keywords||s.beginKeywords,s.keywords&&(s.keywords=function(e,n){var t={};return"string"==typeof e?r("keyword",e):Object.keys(e).forEach((function(n){r(n,e[n])})),t;function r(e,r){n&&(r=r.toLowerCase()),r.split(" ").forEach((function(n){var r=n.split("|");t[r[0]]=[e,R(r[0],r[1])]}))}}(s.keywords,e.case_insensitive)),s.lexemesRe=n(s.lexemes||/\w+/,!0),o&&(s.beginKeywords&&(s.begin="\\b("+s.beginKeywords.split(" ").join("|")+")(?=\\b|\\s)",s.__onBegin=i),s.begin||(s.begin=/\B|\b/),s.beginRe=n(s.begin),s.endSameAsBegin&&(s.end=s.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(s.endRe=n(s.end)),s.terminator_end=u(s.end)||"",s.endsWithParent&&o.terminator_end&&(s.terminator_end+=(s.end?"|":"")+o.terminator_end)),s.illegal&&(s.illegalRe=n(s.illegal)),null==s.relevance&&(s.relevance=1),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cached_variants&&(e.cached_variants=e.variants.map((function(n){return t(e,{variants:null},n)}))),e.cached_variants?e.cached_variants:function e(n){return!!n&&(n.endsWithParent||e(n.starts))}(e)?t(e,{starts:e.starts?t(e.starts):null}):Object.isFrozen(e)?t(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){r(e,s)})),s.starts&&r(s.starts,o),s.matcher=function(e){let n=new a;return e.contains.forEach(e=>n.addRule(e.begin,{rule:e,type:"begin"})),e.terminator_end&&n.addRule(e.terminator_end,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(s))}(e)}(v);var x,_=i||v,E={},w=new g.__emitter(g);!function(){for(var e=[],n=_;n!==v;n=n.parent)n.className&&e.unshift(n.className);e.forEach(e=>w.openNode(e))}();var y,O,k="",T=0,L=0,A=0,B=!1;try{for(_.matcher.considerAll();A++,B?B=!1:(_.matcher.lastIndex=L,_.matcher.considerAll()),y=_.matcher.exec(s);)O=b(s.substring(L,y.index),y),L=y.index+O;return b(s.substr(L)),w.closeAllNodes(),w.finalize(),x=w.toHTML(),{relevance:T,value:x,language:e,illegal:!1,emitter:w,top:_}}catch(n){if(n.message&&n.message.includes("Illegal"))return{illegal:!0,illegalBy:{msg:n.message,context:s.slice(L-100,L+100),mode:n.mode},sofar:x,relevance:0,value:N(s),emitter:w};if(o)return{relevance:0,value:N(s),emitter:w,language:e,top:_,errorRaised:n};throw n}}function m(e,n){n=n||g.languages||Object.keys(a);var t=function(e){const n={relevance:0,emitter:new g.__emitter(g),value:N(e),illegal:!1,top:E};return n.emitter.addText(e),n}(e),r=t;return n.filter(M).filter(k).forEach((function(n){var a=p(n,e,!1);a.language=n,a.relevance>r.relevance&&(r=a),a.relevance>t.relevance&&(r=t,t=a)})),r.language&&(t.second_best=r),t}function b(e){return g.tabReplace||g.useBR?e.replace(l,(function(e,n){return g.useBR&&"\n"===e?"
    ":g.tabReplace?n.replace(/\t/g,g.tabReplace):""})):e}function v(e){var n,t,r,a,s,o=function(e){var n,t=e.className+" ";if(t+=e.parentNode?e.parentNode.className:"",n=g.languageDetectRe.exec(t)){var r=M(n[1]);return r||(console.warn(d.replace("{}",n[1])),console.warn("Falling back to no-highlight mode for this block.",e)),r?n[1]:"no-highlight"}return t.split(/\s+/).find(e=>h(e)||M(e))}(e);h(o)||(T("before:highlightBlock",{block:e,language:o}),g.useBR?(n=document.createElement("div")).innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n"):n=e,s=n.textContent,r=o?f(o,s,!0):m(s),(t=y(n)).length&&((a=document.createElement("div")).innerHTML=r.value,r.value=O(t,y(a),s)),r.value=b(r.value),T("after:highlightBlock",{block:e,result:r}),e.innerHTML=r.value,e.className=function(e,n,t){var r=n?i[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),e.includes(r)||a.push(r),a.join(" ").trim()}(e.className,o,r.language),e.result={language:r.language,re:r.relevance},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.relevance}))}function x(){if(!x.called){x.called=!0;var e=document.querySelectorAll("pre code");r.forEach.call(e,v)}}const E={disableAutodetect:!0,name:"Plain text"};function M(e){return e=(e||"").toLowerCase(),a[e]||a[i[e]]}function k(e){var n=M(e);return n&&!n.disableAutodetect}function T(e,n){var t=e;s.forEach((function(e){e[t]&&e[t](n)}))}Object.assign(n,{highlight:f,highlightAuto:m,fixMarkup:b,highlightBlock:v,configure:function(e){g=w(g,e)},initHighlighting:x,initHighlightingOnLoad:function(){window.addEventListener("DOMContentLoaded",x,!1)},registerLanguage:function(e,t){var r;try{r=t(n)}catch(n){if(console.error("Language definition for '{}' could not be registered.".replace("{}",e)),!o)throw n;console.error(n),r=E}r.name||(r.name=e),a[e]=r,r.rawDefinition=t.bind(null,n),r.aliases&&r.aliases.forEach((function(n){i[n]=e}))},listLanguages:function(){return Object.keys(a)},getLanguage:M,requireLanguage:function(e){var n=M(e);if(n)return n;throw Error("The '{}' language is required, but not loaded.".replace("{}",e))},autoDetection:k,inherit:w,addPlugin:function(e,n){s.push(e)}}),n.debugMode=function(){o=!1},n.safeMode=function(){o=!0},n.versionString="10.0.3";for(const n in _)"object"==typeof _[n]&&e(_[n]);return Object.assign(n,_),n}({})}();"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);hljs.registerLanguage("json",function(){"use strict";return function(n){var e={literal:"true false null"},i=[n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE],t=[n.QUOTE_STRING_MODE,n.C_NUMBER_MODE],a={end:",",endsWithParent:!0,excludeEnd:!0,contains:t,keywords:e},l={begin:"{",end:"}",contains:[{className:"attr",begin:/"/,end:/"/,contains:[n.BACKSLASH_ESCAPE],illegal:"\\n"},n.inherit(a,{begin:/:/})].concat(i),illegal:"\\S"},s={begin:"\\[",end:"\\]",contains:[n.inherit(a)],illegal:"\\S"};return t.push(l,s),i.forEach((function(n){t.push(n)})),{name:"JSON",contains:t,keywords:e,illegal:"\\S"}}}());hljs.registerLanguage("xml",function(){"use strict";return function(e){var n={className:"symbol",begin:"&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;"},a={begin:"\\s",contains:[{className:"meta-keyword",begin:"#?[a-z_][a-z1-9_-]+",illegal:"\\n"}]},s=e.inherit(a,{begin:"\\(",end:"\\)"}),t=e.inherit(e.APOS_STRING_MODE,{className:"meta-string"}),i=e.inherit(e.QUOTE_STRING_MODE,{className:"meta-string"}),c={endsWithParent:!0,illegal:/`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,contains:[{className:"meta",begin:"",relevance:10,contains:[a,i,t,s,{begin:"\\[",end:"\\]",contains:[{className:"meta",begin:"",contains:[a,s,i,t]}]}]},e.COMMENT("\x3c!--","--\x3e",{relevance:10}),{begin:"<\\!\\[CDATA\\[",end:"\\]\\]>",relevance:10},n,{className:"meta",begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag",begin:")",end:">",keywords:{name:"style"},contains:[c],starts:{end:"",returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:")",end:">",keywords:{name:"script"},contains:[c],starts:{end:"<\/script>",returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:"",contains:[{className:"name",begin:/[^\/><\s]+/,relevance:0},c]}]}}}());hljs.registerLanguage("markdown",function(){"use strict";return function(n){const e={begin:"<",end:">",subLanguage:"xml",relevance:0},a={begin:"\\[.+?\\][\\(\\[].*?[\\)\\]]",returnBegin:!0,contains:[{className:"string",begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0,relevance:0},{className:"link",begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}],relevance:10},i={className:"strong",contains:[],variants:[{begin:/_{2}/,end:/_{2}/},{begin:/\*{2}/,end:/\*{2}/}]},s={className:"emphasis",contains:[],variants:[{begin:/\*(?!\*)/,end:/\*/},{begin:/_(?!_)/,end:/_/,relevance:0}]};i.contains.push(s),s.contains.push(i);var c=[e,a];return i.contains=i.contains.concat(c),s.contains=s.contains.concat(c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:c=c.concat(i,s)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:c}]}]},e,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i,s,{className:"quote",begin:"^>\\s+",contains:c,end:"$"},{className:"code",variants:[{begin:"(`{3,})(.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})(.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},a,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}}}());hljs.registerLanguage("bash",function(){"use strict";return function(e){const s={};Object.assign(s,{className:"variable",variants:[{begin:/\$[\w\d#@][\w\d_]*/},{begin:/\$\{/,end:/\}/,contains:[{begin:/:-/,contains:[s]}]}]});const n={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},t={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,n]};n.contains.push(t);const a={begin:/\$\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,s]};return{name:"Bash",aliases:["sh","zsh"],lexemes:/\b-?[a-z\._]+\b/,keywords:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},contains:[{className:"meta",begin:/^#![^\n]+sh\s*$/,relevance:10},{className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},a,e.HASH_COMMENT_MODE,t,{className:"",begin:/\\"/},{className:"string",begin:/'/,end:/'/},s]}}}());hljs.registerLanguage("shell",function(){"use strict";return function(s){return{name:"Shell Session",aliases:["console"],contains:[{className:"meta",begin:"^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]",starts:{end:"$",subLanguage:"bash"}}]}}}());hljs.registerLanguage("c-like",function(){"use strict";return function(e){function t(e){return"(?:"+e+")?"}var n="(decltype\\(auto\\)|"+t("[a-zA-Z_]\\w*::")+"[a-zA-Z_]\\w*"+t("<.*?>")+")",r={className:"keyword",begin:"\\b[a-z\\d_]*_t\\b"},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},{begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\((?:.|\n)*?\)\1"/}]},s={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},i={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{"meta-keyword":"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"meta-string"}),{className:"meta-string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},c={className:"title",begin:t("[a-zA-Z_]\\w*::")+e.IDENT_RE,relevance:0},o=t("[a-zA-Z_]\\w*::")+e.IDENT_RE+"\\s*\\(",l={keyword:"int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid wchar_t short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignas alignof constexpr consteval constinit decltype concept co_await co_return co_yield requires noexcept static_assert thread_local restrict final override atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary",literal:"true false nullptr NULL"},d=[r,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,a],_={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:l,contains:d.concat([{begin:/\(/,end:/\)/,keywords:l,contains:d.concat(["self"]),relevance:0}]),relevance:0},u={className:"function",begin:"("+n+"[\\*&\\s]+)+"+o,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:l,illegal:/[^\w\s\*&:<>]/,contains:[{begin:"decltype\\(auto\\)",keywords:l,relevance:0},{begin:o,returnBegin:!0,contains:[c],relevance:0},{className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,r,{begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:["self",e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,r]}]},r,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,i]};return{aliases:["c","cc","h","c++","h++","hpp","hh","hxx","cxx"],keywords:l,disableAutodetect:!0,illegal:"",keywords:l,contains:["self",r]},{begin:e.IDENT_RE+"::",keywords:l},{className:"class",beginKeywords:"class struct",end:/[{;:]/,contains:[{begin://,contains:["self"]},e.TITLE_MODE]}]),exports:{preprocessor:i,strings:a,keywords:l}}}}());hljs.registerLanguage("cpp",function(){"use strict";return function(e){var t=e.getLanguage("c-like").rawDefinition();return t.disableAutodetect=!1,t.name="C++",t.aliases=["cc","c++","h++","hpp","hh","hxx","cxx"],t}}());hljs.registerLanguage("coffeescript",function(){"use strict";return function(e){var n={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super yield import export from as default await then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},i="[A-Za-z$_][0-9A-Za-z$_]*",s={className:"subst",begin:/#\{/,end:/}/,keywords:n},a=[e.BINARY_NUMBER_MODE,e.inherit(e.C_NUMBER_MODE,{starts:{end:"(\\s*/)?",relevance:0}}),{className:"string",variants:[{begin:/'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE]},{begin:/'/,end:/'/,contains:[e.BACKSLASH_ESCAPE]},{begin:/"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,s]},{begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s]}]},{className:"regexp",variants:[{begin:"///",end:"///",contains:[s,e.HASH_COMMENT_MODE]},{begin:"//[gim]{0,3}(?=\\W)",relevance:0},{begin:/\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/}]},{begin:"@"+i},{subLanguage:"javascript",excludeBegin:!0,excludeEnd:!0,variants:[{begin:"```",end:"```"},{begin:"`",end:"`"}]}];s.contains=a;var t=e.inherit(e.TITLE_MODE,{begin:i}),r={className:"params",begin:"\\([^\\(]",returnBegin:!0,contains:[{begin:/\(/,end:/\)/,keywords:n,contains:["self"].concat(a)}]};return{name:"CoffeeScript",aliases:["coffee","cson","iced"],keywords:n,illegal:/\/\*/,contains:a.concat([e.COMMENT("###","###"),e.HASH_COMMENT_MODE,{className:"function",begin:"^\\s*"+i+"\\s*=\\s*(\\(.*\\))?\\s*\\B[-=]>",end:"[-=]>",returnBegin:!0,contains:[t,r]},{begin:/[:\(,=]\s*/,relevance:0,contains:[{className:"function",begin:"(\\(.*\\))?\\s*\\B[-=]>",end:"[-=]>",returnBegin:!0,contains:[r]}]},{className:"class",beginKeywords:"class",end:"$",illegal:/[:="\[\]]/,contains:[{beginKeywords:"extends",endsWithParent:!0,illegal:/[:="\[\]]/,contains:[t]},t]},{begin:i+":",end:":",returnBegin:!0,returnEnd:!0,relevance:0}])}}}());hljs.registerLanguage("javascript",function(){"use strict";return function(e){var n={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/},a="[A-Za-z$_][0-9A-Za-z$_]*",s={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},r={className:"number",variants:[{begin:"\\b(0[bB][01]+)n?"},{begin:"\\b(0[oO][0-7]+)n?"},{begin:e.C_NUMBER_RE+"n?"}],relevance:0},i={className:"subst",begin:"\\$\\{",end:"\\}",keywords:s,contains:[]},t={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,i],subLanguage:"xml"}},c={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,i],subLanguage:"css"}},o={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,i]};i.contains=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,t,c,o,r,e.REGEXP_MODE];var l=i.contains.concat([e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]),d={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,contains:l};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:s,contains:[{className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},{className:"meta",begin:/^#!/,end:/$/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,t,c,o,e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+",contains:[{className:"type",begin:"\\{",end:"\\}",relevance:0},{className:"variable",begin:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,r,{begin:/[{,\n]\s*/,relevance:0,contains:[{begin:a+"\\s*:",returnBegin:!0,relevance:0,contains:[{className:"attr",begin:a,relevance:0}]}]},{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.REGEXP_MODE,{className:"function",begin:"(\\(.*?\\)|"+a+")\\s*=>",returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:a},{begin:/\(\s*\)/},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:l}]}]},{begin:/,/,relevance:0},{className:"",begin:/\s/,end:/\s*/,skip:!0},{variants:[{begin:"<>",end:""},{begin:n.begin,end:n.end}],subLanguage:"xml",contains:[{begin:n.begin,end:n.end,skip:!0,contains:["self"]}]}],relevance:0},{className:"function",beginKeywords:"function",end:/\{/,excludeEnd:!0,contains:[e.inherit(e.TITLE_MODE,{begin:a}),d],illegal:/\[|%/},{begin:/\$[(.]/},e.METHOD_GUARD,{className:"class",beginKeywords:"class",end:/[{;=]/,excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"extends"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"constructor",end:/\{/,excludeEnd:!0},{begin:"(get|set)\\s+(?="+a+"\\()",end:/{/,keywords:"get set",contains:[e.inherit(e.TITLE_MODE,{begin:a}),{begin:/\(\)/},d]}],illegal:/#(?!!)/}}}());hljs.registerLanguage("c",function(){"use strict";return function(e){var n=e.getLanguage("c-like").rawDefinition();return n.name="C",n.aliases=["c","h"],n}}());hljs.registerLanguage("plaintext",function(){"use strict";return function(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}}()); \ No newline at end of file diff --git a/doc/api_assets/hljs.css b/doc/api_assets/hljs.css new file mode 100644 index 00000000000000..de798089557c55 --- /dev/null +++ b/doc/api_assets/hljs.css @@ -0,0 +1,29 @@ +.hljs { + font-weight: normal; + font-style: normal; +} + +.hljs-symbol { + color: #333; +} + +.hljs-keyword { + color: #338; +} + +.hljs-string, +.hljs-regexp, +.hljs-number { + color: #E54305; +} + +.hljs-doctag { + color: #040404; +} + +.hljs-doctag .hljs-type, +.hljs-doctag .hljs-variable, +.hljs-comment { + color: #666; + font-weight: lighter; +} diff --git a/doc/api_assets/sh.css b/doc/api_assets/sh.css deleted file mode 100644 index 234de111f42501..00000000000000 --- a/doc/api_assets/sh.css +++ /dev/null @@ -1,25 +0,0 @@ -.sh_sourceCode { - font-weight: normal; - font-style: normal; -} - -.sh_sourceCode .sh_symbol, -.sh_sourceCode .sh_cbracket { - color: #333; -} - -.sh_sourceCode .sh_keyword { - color: #338; -} - -.sh_sourceCode .sh_string, -.sh_sourceCode .sh_regexp, -.sh_sourceCode .sh_number, -.sh_sourceCode .sh_specialchar { - color: #E54305; -} - -.sh_sourceCode .sh_comment { - color: #666; - font-weight: lighter; -} diff --git a/doc/api_assets/sh_javascript.min.js b/doc/api_assets/sh_javascript.min.js deleted file mode 100644 index d12482ced20918..00000000000000 --- a/doc/api_assets/sh_javascript.min.js +++ /dev/null @@ -1 +0,0 @@ -if(!this.sh_languages){this.sh_languages={}}sh_languages.javascript=[[[/\/\/\//g,"sh_comment",1],[/\/\//g,"sh_comment",7],[/\/\*\*/g,"sh_comment",8],[/\/\*/g,"sh_comment",9],[/\b(?:abstract|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|final|finally|for|function|goto|if|implements|in|instanceof|interface|native|new|null|private|protected|prototype|public|return|static|super|switch|synchronized|throw|throws|this|transient|true|try|typeof|var|volatile|while|with)\b/g,"sh_keyword",-1],[/(\+\+|--|\)|\])(\s*)(\/=?(?![*\/]))/g,["sh_symbol","sh_normal","sh_symbol"],-1],[/(0x[A-Fa-f0-9]+|(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?)(\s*)(\/(?![*\/]))/g,["sh_number","sh_normal","sh_symbol"],-1],[/([A-Za-z$_][A-Za-z0-9$_]*\s*)(\/=?(?![*\/]))/g,["sh_normal","sh_symbol"],-1],[/\/(?:\\.|[^*\\\/])(?:\\.|[^\\\/])*\/[gim]*/g,"sh_regexp",-1],[/\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,"sh_number",-1],[/"/g,"sh_string",10],[/'/g,"sh_string",11],[/~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|\/|\?|&|<|>|\|/g,"sh_symbol",-1],[/\{|\}/g,"sh_cbracket",-1],[/\b(?:Math|Infinity|NaN|undefined|arguments)\b/g,"sh_predef_var",-1],[/\b(?:Array|Boolean|Date|Error|EvalError|Function|Number|Object|RangeError|ReferenceError|RegExp|String|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt)\b/g,"sh_predef_func",-1],[/(?:[A-Za-z]|_)[A-Za-z0-9_]*(?=[ \t]*\()/g,"sh_function",-1]],[[/$/g,null,-2],[/(?:?)|(?:?)/g,"sh_url",-1],[/<\?xml/g,"sh_preproc",2,1],[//g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g,"sh_keyword",6,1],[/&(?:[A-Za-z0-9]+);/g,"sh_preproc",-1],[/<(?:\/)?[A-Za-z][A-Za-z0-9]*(?:\/)?>/g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z][A-Za-z0-9]*/g,"sh_keyword",6,1],[/@[A-Za-z]+/g,"sh_type",-1],[/(?:TODO|FIXME|BUG)(?:[:]?)/g,"sh_todo",-1]],[[/\?>/g,"sh_preproc",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",3]],[[/\\(?:\\|")/g,null,-1],[/"/g,"sh_string",-2]],[[/>/g,"sh_preproc",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",3]],[[/-->/g,"sh_comment",-2],[/ * NOT OK: It is important to note that, in all cases, the return value will be a string regardless. +* For headings, use sentence case, not title case. + + * OK: _## Everybody to the limit_ + * NOT OK: _## Everybody To The Limit_ +* When referring to a version of Node.js in prose, use _Node.js_ and the version + number. Do not prefix the version number with _v_ in prose. This is to avoid + confusion about whether _V8_ refers to Node.js 8.x or the V8 JavaScript + engine. + * OK: _Node.js 14.x_, _Node.js 14.3.1_ + * NOT OK: _Node.js v14_ See also API documentation structure overview in [doctools README][]. +[info string]: https://github.github.com/gfm/#info-string +[language]: https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md [Javascript type]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Data_structures_and_types [serial commas]: https://en.wikipedia.org/wiki/Serial_comma [plugin]: https://editorconfig.org/#download [doctools README]: ../../tools/doc/README.md +[`remark-preset-lint-node`]: https://github.com/nodejs/remark-preset-lint-node diff --git a/doc/guides/investigating_native_memory_leak.md b/doc/guides/investigating_native_memory_leak.md index 366cc2917f6a4c..f0a156286e3e5f 100644 --- a/doc/guides/investigating_native_memory_leak.md +++ b/doc/guides/investigating_native_memory_leak.md @@ -103,7 +103,7 @@ example leak based on the "Hello world" addon from In this example, a loop which allocates ~1MB of memory and never frees it has been added: -```C++ +```cpp void* malloc_holder = nullptr; napi_value Method(napi_env env, napi_callback_info info) { napi_status status; @@ -366,7 +366,7 @@ line number: This new output shows us exactly where the leak is occurring in the file `hello.cc`: -```C++ +```cpp 6 void* malloc_holder = nullptr; 7 napi_value Method(napi_env env, napi_callback_info info) { 8 napi_status status; diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md index f8a2c1aa305b0e..867bb433be8087 100644 --- a/doc/guides/maintaining-V8.md +++ b/doc/guides/maintaining-V8.md @@ -324,7 +324,7 @@ that Node.js may be floating (or else cause a merge conflict). The rough outline of the process is: -```shell +```bash # Assuming your fork of Node.js is checked out in $NODE_DIR # and you want to update the Node.js master branch. # Find the current (OLD) version in @@ -363,7 +363,7 @@ above. A better strategy is to To audit for floating patches: -```shell +```bash git log --oneline deps/v8 ``` @@ -371,7 +371,7 @@ To replace the copy of V8 in Node.js, use the [`git-node`][] tool. For example, if you want to replace the copy of V8 in Node.js with the branch-head for V8 5.1 branch: -```shell +```bash cd $NODE_DIR git node v8 major --branch=5.1-lkgr ``` diff --git a/doc/guides/maintaining-openssl.md b/doc/guides/maintaining-openssl.md index 6a584f46024171..34deb05523b15c 100644 --- a/doc/guides/maintaining-openssl.md +++ b/doc/guides/maintaining-openssl.md @@ -10,7 +10,7 @@ This document describes how to update `deps/openssl/`. ## 0. Check Requirements -```sh +```console % perl -v This is perl 5, version 22, subversion 1 (v5.22.1) built for @@ -30,7 +30,7 @@ NASM version 2.11.08 Get a new source from and extract all files into `deps/openssl/openssl`. Then add all files and commit them. -```sh +```console % cd deps/openssl/ % rm -rf openssl % tar zxf ~/tmp/openssl-1.1.0h.tar.gz @@ -57,7 +57,7 @@ This updates all sources in deps/openssl/openssl by: Use `make` to regenerate all platform dependent files in `deps/openssl/config/archs/`: -```sh +```console % make -C deps/openssl/config ``` @@ -66,7 +66,7 @@ Use `make` to regenerate all platform dependent files in Check diffs to ensure updates are right. Even if there are no updates in openssl sources, `buildinf.h` files will be updated because they have timestamp data in them. -```sh +```console % git diff -- deps/openssl ``` @@ -81,7 +81,7 @@ please ask @shigeki for details. Update all architecture dependent files. Do not forget to git add or remove files if they are changed before committing: -```sh +```console % git add deps/openssl/config/archs % git add deps/openssl/openssl/include/crypto/bn_conf.h % git add deps/openssl/openssl/include/crypto/dso_conf.h diff --git a/doc/guides/maintaining-root-certs.md b/doc/guides/maintaining-root-certs.md index d26bdad943a50a..e14e2d8eca0756 100644 --- a/doc/guides/maintaining-root-certs.md +++ b/doc/guides/maintaining-root-certs.md @@ -30,7 +30,7 @@ the nodejs/node repository. Update the tag in the commands below, and run: - ```shell + ```bash cd tools/ ./mk-ca-bundle.pl -v 2>_before curl -O https://hg.mozilla.org/projects/nss/raw-file/NSS_3_41_RTM/lib/ckfw/builtins/certdata.txt @@ -57,7 +57,7 @@ the nodejs/node repository. Run the command below: - ```shell + ```bash ./mk-ca-bundle.pl -v 2>_after ``` @@ -65,7 +65,7 @@ the nodejs/node repository. Determine what changes were made by diffing the before and after files: - ```shell + ```console % diff _before _after 11d10 < Parsing: Visa eCommerce Root diff --git a/doc/guides/maintaining-zlib.md b/doc/guides/maintaining-zlib.md index f60ba4614962ba..cdf5e2c17d6d95 100644 --- a/doc/guides/maintaining-zlib.md +++ b/doc/guides/maintaining-zlib.md @@ -6,7 +6,7 @@ performance improvements not currently available in standard zlib. ## Updating zlib Update zlib: -```shell +```bash git clone https://chromium.googlesource.com/chromium/src/third_party/zlib cp deps/zlib/zlib.gyp deps/zlib/win32/zlib.def deps rm -rf deps/zlib zlib/.git diff --git a/doc/guides/node-postmortem-support.md b/doc/guides/node-postmortem-support.md index 5845f2a84feb78..21d317204911cf 100644 --- a/doc/guides/node-postmortem-support.md +++ b/doc/guides/node-postmortem-support.md @@ -35,7 +35,7 @@ For example, if we want to add a constant with the offset for `sizeof(req_)` depends on the type of T, which means the class definition should be like this: -```c++ +```cpp template class ReqWrap : public AsyncWrap { private: @@ -49,7 +49,7 @@ class ReqWrap : public AsyncWrap { instead of: -```c++ +```cpp template class ReqWrap : public AsyncWrap { private: diff --git a/doc/guides/onboarding-extras.md b/doc/guides/onboarding-extras.md index 26060a48022221..91ed05d9d3658e 100644 --- a/doc/guides/onboarding-extras.md +++ b/doc/guides/onboarding-extras.md @@ -37,7 +37,7 @@ request. * A breaking change helper ([full source](https://gist.github.com/chrisdickinson/ba532fa0e4e243fb7b44)): - ```sh + ```bash SHOW=$(git show-ref -d $(git describe --abbrev=0) | tail -n1 | awk '{print $1}') git checkout $(git show -s --pretty='%T' $SHOW) -- test make -j4 test diff --git a/doc/guides/releases.md b/doc/guides/releases.md index 68f4d0b8bacc6f..d4f2a2ac962771 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -283,7 +283,7 @@ in the release branch (e.g. a release for Node.js v4 would be added to the The new entry should take the following form: -```md +```markdown ## YYYY-MM-DD, Version x.y.z (Release Type), @releaser @@ -344,7 +344,7 @@ The `CHANGELOG.md`, `doc/changelogs/CHANGELOG_Vx.md`, `src/node_version.h`, and `REPLACEME` changes should be the final commit that will be tagged for the release. When committing these to git, use the following message format: -```txt +```text YYYY-MM-DD, Version x.y.z (Release Type) Notable changes: @@ -357,7 +357,7 @@ For security releases, begin the commit message with the phrase [distribution indexer](https://github.com/nodejs/nodejs-dist-indexer) to identify it as such: -```txt +```text YYYY-MM-DD, Version x.y.z (Release Type) This is a security release. @@ -493,7 +493,7 @@ $ git secure-tag -sm "YYYY-MM-DD Node.js vx.y.z ( @@ -576,7 +576,7 @@ same GPG key!** Use `tools/release.sh` to promote and sign the build. Before doing this, you'll need to ensure you've loaded the correct ssh key, or you'll see the following: -```sh +```console # Checking for releases ... Enter passphrase for key '/Users//.ssh/id_rsa': dist@direct.nodejs.org's password: @@ -584,14 +584,14 @@ dist@direct.nodejs.org's password: The key can be loaded either with `ssh-add`: -```sh +```console # Substitute node_id_rsa with whatever you've named the key $ ssh-add ~/.ssh/node_id_rsa ``` or at runtime with: -```sh +```console # Substitute node_id_rsa with whatever you've named the key $ ./tools/release.sh -i ~/.ssh/node_id_rsa ``` diff --git a/doc/guides/writing-and-running-benchmarks.md b/doc/guides/writing-and-running-benchmarks.md index eca55bf4edf2ea..5f630ccc1f805d 100644 --- a/doc/guides/writing-and-running-benchmarks.md +++ b/doc/guides/writing-and-running-benchmarks.md @@ -59,7 +59,7 @@ package managers or download it from . The R packages `ggplot2` and `plyr` are also used and can be installed using the R REPL. -```R +```console $ R install.packages("ggplot2") install.packages("plyr") @@ -71,7 +71,7 @@ selected first, specify a mirror by adding in the repo parameter. If we used the "" mirror, it could look something like this: -```R +```r install.packages("ggplot2", repo="http://cran.us.r-project.org") ``` diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md index 385e3813fdbd69..e441d934113e75 100644 --- a/doc/guides/writing-tests.md +++ b/doc/guides/writing-tests.md @@ -29,7 +29,7 @@ For example, look for `test-streams` when writing a test for `lib/streams.js`. Let's analyze this basic test from the Node.js test suite: -```javascript +```js 'use strict'; // 1 const common = require('../common'); // 2 const fixtures = require('../common/fixtures'); // 3 @@ -57,7 +57,7 @@ server.listen(0, () => { // 14 ### **Lines 1-3** -```javascript +```js 'use strict'; const common = require('../common'); const fixtures = require('../common/fixtures'); @@ -78,13 +78,13 @@ the test leaks variables into the global space. In situations where a test uses no functions or other properties exported by `common`, include it without assigning it to an identifier: -```javascript +```js require('../common'); ``` ### **Lines 5-6** -```javascript +```js // This test ensures that the http-parser can handle UTF-8 characters // in the http header. ``` @@ -94,7 +94,7 @@ designed to test. ### **Lines 8-9** -```javascript +```js const assert = require('assert'); const http = require('http'); ``` @@ -136,7 +136,7 @@ In the event a test needs a timer, consider using the `common.platformTimeout()` method. It allows setting specific timeouts depending on the platform: -```javascript +```js const timer = setTimeout(fail, common.platformTimeout(4000)); ``` @@ -155,7 +155,7 @@ One interesting case is `common.mustCall`. The use of `common.mustCall` may avoid the use of extra variables and the corresponding assertions. Let's explain this with a real test from the test suite. -```javascript +```js 'use strict'; require('../common'); const assert = require('assert'); @@ -189,7 +189,7 @@ const server = http.createServer((req, res) => { This test could be greatly simplified by using `common.mustCall` like this: -```javascript +```js 'use strict'; const common = require('../common'); const http = require('http'); @@ -216,7 +216,7 @@ provides a simple countdown mechanism for tests that require a particular action to be taken after a given number of completed tasks (for instance, shutting down an HTTP server after a specific number of requests). -```javascript +```js const Countdown = require('../common/countdown'); const countdown = new Countdown(2, () => { @@ -237,7 +237,7 @@ hence, the test fail - in the case of an `unhandledRejection` event. It is possible to disable it with `common.disableCrashOnUnhandledRejection()` if needed. -```javascript +```js const common = require('../common'); const assert = require('assert'); const fs = require('fs').promises; @@ -257,7 +257,7 @@ test followed by the flags. For example, to allow a test to require some of the `internal/*` modules, add the `--expose-internals` flag. A test that would require `internal/freelist` could start like this: -```javascript +```js 'use strict'; // Flags: --expose-internals @@ -356,7 +356,7 @@ The unit test should be placed in `test/cctest` and be named with the prefix `test` followed by the name of unit being tested. For example, the code below would be placed in `test/cctest/test_env.cc`: -```c++ +```cpp #include "gtest/gtest.h" #include "node_test_fixture.h" #include "env.h" diff --git a/doc/template.html b/doc/template.html index eeb54ee5fdd371..2f330a41718af2 100644 --- a/doc/template.html +++ b/doc/template.html @@ -6,7 +6,7 @@ __SECTION__ | Node.js __VERSION__ Documentation - + @@ -51,8 +51,7 @@

    Table of Contents

    - - - + + diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 0592218e5705a7..97cc264c8ff804 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -23,6 +23,8 @@ rules: message: "Use `const { Error } = primordials;` instead of the global." - name: Float32Array message: "Use `const { Float32Array } = primordials;` instead of the global." + - name: Int16Array + message: "Use `const { Int16Array } = primordials;` instead of the global." - name: JSON message: "Use `const { JSON } = primordials;` instead of the global." - name: Map diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js index 5bccb61afceff9..e58bd6ddae213b 100644 --- a/lib/_http_incoming.js +++ b/lib/_http_incoming.js @@ -239,9 +239,8 @@ function matchKnownFields(field, lowercased) { } if (lowercased) { return '\u0000' + field; - } else { - return matchKnownFields(field.toLowerCase(), true); } + return matchKnownFields(field.toLowerCase(), true); } // Add the given (field, value) pair to the message // diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 3f56b95b702e16..36908dddf6a7bf 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -20,8 +20,8 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. // a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from +// Since JS doesn't have multiple prototype inheritance, this class +// prototypically inherits from Readable, and then parasitically from // Writable. 'use strict'; diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 669521e9a568d4..49981b47e04aa8 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -365,8 +365,7 @@ function howMuchToRead(n, state) { // Only flow one buffer at a time if (state.flowing && state.length) return state.buffer.first().length; - else - return state.length; + return state.length; } if (n <= state.length) return n; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index ff3deac0ae9f10..2a596b67329098 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -1518,12 +1518,11 @@ function onConnectSecure() { if (options.rejectUnauthorized) { this.destroy(verifyError); return; - } else { - debug('client emit secureConnect. rejectUnauthorized: %s, ' + - 'authorizationError: %s', options.rejectUnauthorized, - this.authorizationError); - this.emit('secureConnect'); } + debug('client emit secureConnect. rejectUnauthorized: %s, ' + + 'authorizationError: %s', options.rejectUnauthorized, + this.authorizationError); + this.emit('secureConnect'); } else { this.authorized = true; debug('client emit secureConnect. authorized:', this.authorized); diff --git a/lib/buffer.js b/lib/buffer.js index a818f41a26ed5b..991c601072c585 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -544,7 +544,6 @@ Buffer.isEncoding = function isEncoding(encoding) { Buffer[kIsEncodingSymbol] = Buffer.isEncoding; Buffer.concat = function concat(list, length) { - let i; if (!ArrayIsArray(list)) { throw new ERR_INVALID_ARG_TYPE('list', 'Array', list); } @@ -554,7 +553,7 @@ Buffer.concat = function concat(list, length) { if (length === undefined) { length = 0; - for (i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { if (list[i].length) { length += list[i].length; } @@ -565,7 +564,7 @@ Buffer.concat = function concat(list, length) { const buffer = Buffer.allocUnsafe(length); let pos = 0; - for (i = 0; i < list.length; i++) { + for (let i = 0; i < list.length; i++) { const buf = list[i]; if (!isUint8Array(buf)) { // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE. diff --git a/lib/dns.js b/lib/dns.js index 4243a05e179b88..92b70c73effbf2 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -261,9 +261,8 @@ function resolve(hostname, rrtype, callback) { if (typeof resolver === 'function') { return resolver.call(this, hostname, callback); - } else { - throw new ERR_INVALID_OPT_VALUE('rrtype', rrtype); } + throw new ERR_INVALID_OPT_VALUE('rrtype', rrtype); } function defaultResolverSetServers(servers) { diff --git a/lib/domain.js b/lib/domain.js index 29232a90de08ab..9659dcde855c93 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -42,6 +42,7 @@ const { ERR_UNHANDLED_ERROR } = require('internal/errors').codes; const { createHook } = require('async_hooks'); +const { useDomainTrampoline } = require('internal/async_hooks'); // TODO(addaleax): Use a non-internal solution for this. const kWeak = Symbol('kWeak'); @@ -145,7 +146,7 @@ function topLevelDomainCallback(cb, ...args) { // another one. The stack is each entered domain. const stack = []; exports._stack = stack; -internalBinding('domain').enable(topLevelDomainCallback); +useDomainTrampoline(topLevelDomainCallback); function updateExceptionCapture() { if (stack.every((domain) => domain.listenerCount('error') === 0)) { diff --git a/lib/events.js b/lib/events.js index b138979e138fdf..fc2f969ea37ef6 100644 --- a/lib/events.js +++ b/lib/events.js @@ -577,9 +577,8 @@ EventEmitter.prototype.rawListeners = function rawListeners(type) { EventEmitter.listenerCount = function(emitter, type) { if (typeof emitter.listenerCount === 'function') { return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); } + return listenerCount.call(emitter, type); }; EventEmitter.prototype.listenerCount = listenerCount; diff --git a/lib/fs.js b/lib/fs.js index 4a19e3b6033711..9b70b237ef00e1 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -27,6 +27,7 @@ const { Map, MathMax, + Number, NumberIsSafeInteger, ObjectCreate, ObjectDefineProperties, @@ -174,7 +175,10 @@ const isFd = isUint32; function isFileType(stats, fileType) { // Use stats array directly to avoid creating an fs.Stats instance just for // our internal use. - return (stats[1/* mode */] & S_IFMT) === fileType; + let mode = stats[1]; + if (typeof mode === 'bigint') + mode = Number(mode); + return (mode & S_IFMT) === fileType; } function access(path, mode, callback) { @@ -584,6 +588,9 @@ function readv(fd, buffers, position, callback) { return binding.readBuffers(fd, buffers, position, req); } +ObjectDefineProperty(readv, internalUtil.customPromisifyArgs, + { value: ['bytesRead', 'buffers'], enumerable: false }); + function readvSync(fd, buffers, position) { validateInt32(fd, 'fd', 0); validateBufferArray(buffers); @@ -1508,9 +1515,8 @@ function encodeRealpathResult(result, options) { const asBuffer = Buffer.from(result); if (options.encoding === 'buffer') { return asBuffer; - } else { - return asBuffer.toString(options.encoding); } + return asBuffer.toString(options.encoding); } // Finds the next portion of a (partial) path, up to the next path delimiter @@ -1611,7 +1617,7 @@ function realpathSync(p, options) { const baseLong = pathModule.toNamespacedPath(base); const ctx = { path: base }; - const stats = binding.lstat(baseLong, false, undefined, ctx); + const stats = binding.lstat(baseLong, true, undefined, ctx); handleErrorFromBinding(ctx); if (!isFileType(stats, S_IFLNK)) { @@ -1744,7 +1750,7 @@ function realpath(p, options, callback) { return process.nextTick(LOOP); } - return fs.lstat(base, gotStat); + return fs.lstat(base, { bigint: true }, gotStat); } function gotStat(err, stats) { diff --git a/lib/inspector.js b/lib/inspector.js index 269f95dbd27a12..60640bc1fb6456 100644 --- a/lib/inspector.js +++ b/lib/inspector.js @@ -8,6 +8,7 @@ const { } = primordials; const { + ERR_INSPECTOR_ALREADY_ACTIVATED, ERR_INSPECTOR_ALREADY_CONNECTED, ERR_INSPECTOR_CLOSED, ERR_INSPECTOR_COMMAND, @@ -33,6 +34,7 @@ const { MainThreadConnection, open, url, + isEnabled, waitForDebugger } = internalBinding('inspector'); @@ -131,6 +133,9 @@ class Session extends EventEmitter { } function inspectorOpen(port, host, wait) { + if (isEnabled()) { + throw new ERR_INSPECTOR_ALREADY_ACTIVATED(); + } open(port, host); if (wait) waitForDebugger(); diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 62ced406bfc1e2..d98014c368202c 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -1,13 +1,16 @@ 'use strict'; const { + ArrayPrototypeUnshift, Error, FunctionPrototypeBind, ObjectDefineProperty, + ReflectApply, Symbol, } = primordials; const async_wrap = internalBinding('async_wrap'); +const { setCallbackTrampoline } = async_wrap; /* async_hook_fields is a Uint32Array wrapping the uint32_t array of * Environment::AsyncHooks::fields_[]. Each index tracks the number of active * hooks for each type. @@ -38,11 +41,11 @@ const { async_id_fields, execution_async_resources } = async_wrap; -// Store the pair executionAsyncId and triggerAsyncId in a std::stack on -// Environment::AsyncHooks::async_ids_stack_ tracks the resource responsible for -// the current execution stack. This is unwound as each resource exits. In the -// case of a fatal exception this stack is emptied after calling each hook's -// after() callback. +// Store the pair executionAsyncId and triggerAsyncId in a AliasedFloat64Array +// in Environment::AsyncHooks::async_ids_stack_ which tracks the resource +// responsible for the current execution stack. This is unwound as each resource +// exits. In the case of a fatal exception this stack is emptied after calling +// each hook's after() callback. const { pushAsyncContext: pushAsyncContext_, popAsyncContext: popAsyncContext_ @@ -100,6 +103,31 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative'); const emitPromiseResolveNative = emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative'); +let domain_cb; +function useDomainTrampoline(fn) { + domain_cb = fn; +} + +function callbackTrampoline(asyncId, cb, ...args) { + if (asyncId !== 0 && hasHooks(kBefore)) + emitBeforeNative(asyncId); + + let result; + if (asyncId === 0 && typeof domain_cb === 'function') { + ArrayPrototypeUnshift(args, cb); + result = ReflectApply(domain_cb, this, args); + } else { + result = ReflectApply(cb, this, args); + } + + if (asyncId !== 0 && hasHooks(kAfter)) + emitAfterNative(asyncId); + + return result; +} + +setCallbackTrampoline(callbackTrampoline); + const topLevelResource = {}; function executionAsyncResource() { @@ -475,6 +503,7 @@ module.exports = { emitAfter: emitAfterScript, emitDestroy: emitDestroyScript, registerDestroyHook, + useDomainTrampoline, nativeHooks: { init: emitInitNative, before: emitBeforeNative, diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 167f5528de9975..a2af66f4b8521c 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -40,13 +40,19 @@ const { const { isTypedArray, isSet, isMap, isSetIterator, isMapIterator, } = require('internal/util/types'); +const { + CHAR_LOWERCASE_B, + CHAR_LOWERCASE_E, + CHAR_LOWERCASE_N, + CHAR_UPPERCASE_C, +} = require('internal/constants'); const kCounts = Symbol('counts'); const kTraceConsoleCategory = 'node,node.console'; -const kTraceCount = 'C'.charCodeAt(0); -const kTraceBegin = 'b'.charCodeAt(0); -const kTraceEnd = 'e'.charCodeAt(0); -const kTraceInstant = 'n'.charCodeAt(0); +const kTraceCount = CHAR_UPPERCASE_C; +const kTraceBegin = CHAR_LOWERCASE_B; +const kTraceEnd = CHAR_LOWERCASE_E; +const kTraceInstant = CHAR_LOWERCASE_N; const kMaxGroupIndentation = 1000; @@ -131,6 +137,9 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) { // the prototype so that users extending the Console can override them // from the prototype chain of the subclass. this[key] = this[key].bind(this); + ObjectDefineProperty(this[key], 'name', { + value: key + }); } this[kBindStreamsEager](stdout, stderr); @@ -150,68 +159,156 @@ ObjectDefineProperty(Console, SymbolHasInstance, { } }); -// Eager version for the Console constructor -Console.prototype[kBindStreamsEager] = function(stdout, stderr) { - ObjectDefineProperties(this, { - '_stdout': { ...consolePropAttributes, value: stdout }, - '_stderr': { ...consolePropAttributes, value: stderr } - }); -}; +const kColorInspectOptions = { colors: true }; +const kNoColorInspectOptions = {}; -// Lazily load the stdout and stderr from an object so we don't -// create the stdio streams when they are not even accessed -Console.prototype[kBindStreamsLazy] = function(object) { - let stdout; - let stderr; - ObjectDefineProperties(this, { - '_stdout': { - enumerable: false, - configurable: true, - get() { - if (!stdout) stdout = object.stdout; - return stdout; - }, - set(value) { stdout = value; } - }, - '_stderr': { - enumerable: false, - configurable: true, - get() { - if (!stderr) { stderr = object.stderr; } - return stderr; - }, - set(value) { stderr = value; } +ObjectDefineProperties(Console.prototype, { + [kBindStreamsEager]: { + ...consolePropAttributes, + // Eager version for the Console constructor + value: function(stdout, stderr) { + ObjectDefineProperties(this, { + '_stdout': { ...consolePropAttributes, value: stdout }, + '_stderr': { ...consolePropAttributes, value: stderr } + }); } - }); -}; + }, + [kBindStreamsLazy]: { + ...consolePropAttributes, + // Lazily load the stdout and stderr from an object so we don't + // create the stdio streams when they are not even accessed + value: function(object) { + let stdout; + let stderr; + ObjectDefineProperties(this, { + '_stdout': { + enumerable: false, + configurable: true, + get() { + if (!stdout) stdout = object.stdout; + return stdout; + }, + set(value) { stdout = value; } + }, + '_stderr': { + enumerable: false, + configurable: true, + get() { + if (!stderr) { stderr = object.stderr; } + return stderr; + }, + set(value) { stderr = value; } + } + }); + } + }, + [kBindProperties]: { + ...consolePropAttributes, + value: function(ignoreErrors, colorMode, groupIndentation = 2) { + ObjectDefineProperties(this, { + '_stdoutErrorHandler': { + ...consolePropAttributes, + value: createWriteErrorHandler(this, kUseStdout) + }, + '_stderrErrorHandler': { + ...consolePropAttributes, + value: createWriteErrorHandler(this, kUseStderr) + }, + '_ignoreErrors': { + ...consolePropAttributes, + value: Boolean(ignoreErrors) + }, + '_times': { ...consolePropAttributes, value: new Map() }, + // Corresponds to https://console.spec.whatwg.org/#count-map + [kCounts]: { ...consolePropAttributes, value: new Map() }, + [kColorMode]: { ...consolePropAttributes, value: colorMode }, + [kIsConsole]: { ...consolePropAttributes, value: true }, + [kGroupIndent]: { ...consolePropAttributes, value: '' }, + [kGroupIndentationWidth]: { + ...consolePropAttributes, + value: groupIndentation + }, + }); + } + }, + [kWriteToConsole]: { + ...consolePropAttributes, + value: function(streamSymbol, string) { + const ignoreErrors = this._ignoreErrors; + const groupIndent = this[kGroupIndent]; + + const useStdout = streamSymbol === kUseStdout; + const stream = useStdout ? this._stdout : this._stderr; + const errorHandler = useStdout ? + this._stdoutErrorHandler : this._stderrErrorHandler; + + if (groupIndent.length !== 0) { + if (string.includes('\n')) { + string = string.replace(/\n/g, `\n${groupIndent}`); + } + string = groupIndent + string; + } + string += '\n'; + + if (ignoreErrors === false) return stream.write(string); + + // There may be an error occurring synchronously (e.g. for files or TTYs + // on POSIX systems) or asynchronously (e.g. pipes on POSIX systems), so + // handle both situations. + try { + // Add and later remove a noop error handler to catch synchronous + // errors. + if (stream.listenerCount('error') === 0) + stream.once('error', noop); + + stream.write(string, errorHandler); + } catch (e) { + // Console is a debugging utility, so it swallowing errors is not + // desirable even in edge cases such as low stack space. + if (isStackOverflowError(e)) + throw e; + // Sorry, there's no proper way to pass along the error here. + } finally { + stream.removeListener('error', noop); + } + } + }, + [kGetInspectOptions]: { + ...consolePropAttributes, + value: function(stream) { + let color = this[kColorMode]; + if (color === 'auto') { + color = stream.isTTY && ( + typeof stream.getColorDepth === 'function' ? + stream.getColorDepth() > 2 : true); + } -Console.prototype[kBindProperties] = function(ignoreErrors, colorMode, - groupIndentation = 2) { - ObjectDefineProperties(this, { - '_stdoutErrorHandler': { - ...consolePropAttributes, - value: createWriteErrorHandler(this, kUseStdout) - }, - '_stderrErrorHandler': { - ...consolePropAttributes, - value: createWriteErrorHandler(this, kUseStderr) - }, - '_ignoreErrors': { - ...consolePropAttributes, - value: Boolean(ignoreErrors) - }, - '_times': { ...consolePropAttributes, value: new Map() }, - // Corresponds to https://console.spec.whatwg.org/#count-map - [kCounts]: { ...consolePropAttributes, value: new Map() }, - [kColorMode]: { ...consolePropAttributes, value: colorMode }, - [kIsConsole]: { ...consolePropAttributes, value: true }, - [kGroupIndent]: { ...consolePropAttributes, value: '' }, - [kGroupIndentationWidth]: { - ...consolePropAttributes, - value: groupIndentation - }, - }); -}; + const options = optionsMap.get(this); + if (options) { + if (options.colors === undefined) { + options.colors = color; + } + return options; + } + + return color ? kColorInspectOptions : kNoColorInspectOptions; + } + }, + [kFormatForStdout]: { + ...consolePropAttributes, + value: function(args) { + const opts = this[kGetInspectOptions](this._stdout); + return formatWithOptions(opts, ...args); + } + }, + [kFormatForStderr]: { + ...consolePropAttributes, + value: function(args) { + const opts = this[kGetInspectOptions](this._stderr); + return formatWithOptions(opts, ...args); + } + }, +}); // Make a function that can serve as the callback passed to `stream.write()`. function createWriteErrorHandler(instance, streamSymbol) { @@ -234,76 +331,6 @@ function createWriteErrorHandler(instance, streamSymbol) { }; } -Console.prototype[kWriteToConsole] = function(streamSymbol, string) { - const ignoreErrors = this._ignoreErrors; - const groupIndent = this[kGroupIndent]; - - const useStdout = streamSymbol === kUseStdout; - const stream = useStdout ? this._stdout : this._stderr; - const errorHandler = useStdout ? - this._stdoutErrorHandler : this._stderrErrorHandler; - - if (groupIndent.length !== 0) { - if (string.includes('\n')) { - string = string.replace(/\n/g, `\n${groupIndent}`); - } - string = groupIndent + string; - } - string += '\n'; - - if (ignoreErrors === false) return stream.write(string); - - // There may be an error occurring synchronously (e.g. for files or TTYs - // on POSIX systems) or asynchronously (e.g. pipes on POSIX systems), so - // handle both situations. - try { - // Add and later remove a noop error handler to catch synchronous errors. - if (stream.listenerCount('error') === 0) - stream.once('error', noop); - - stream.write(string, errorHandler); - } catch (e) { - // Console is a debugging utility, so it swallowing errors is not desirable - // even in edge cases such as low stack space. - if (isStackOverflowError(e)) - throw e; - // Sorry, there's no proper way to pass along the error here. - } finally { - stream.removeListener('error', noop); - } -}; - -const kColorInspectOptions = { colors: true }; -const kNoColorInspectOptions = {}; -Console.prototype[kGetInspectOptions] = function(stream) { - let color = this[kColorMode]; - if (color === 'auto') { - color = stream.isTTY && ( - typeof stream.getColorDepth === 'function' ? - stream.getColorDepth() > 2 : true); - } - - const options = optionsMap.get(this); - if (options) { - if (options.colors === undefined) { - options.colors = color; - } - return options; - } - - return color ? kColorInspectOptions : kNoColorInspectOptions; -}; - -Console.prototype[kFormatForStdout] = function(args) { - const opts = this[kGetInspectOptions](this._stdout); - return formatWithOptions(opts, ...args); -}; - -Console.prototype[kFormatForStderr] = function(args) { - const opts = this[kGetInspectOptions](this._stderr); - return formatWithOptions(opts, ...args); -}; - const consoleMethods = { log(...args) { this[kWriteToConsole](kUseStdout, this[kFormatForStdout](args)); @@ -487,7 +514,7 @@ const consoleMethods = { if (setIter) tabularData = previewEntries(tabularData); - const setlike = setIter || (mapIter && !isKeyValue) || isSet(tabularData); + const setlike = setIter || mapIter || isSet(tabularData); if (setlike) { const values = []; let length = 0; diff --git a/lib/internal/console/global.js b/lib/internal/console/global.js index 6a1dc3806fdb0b..1c615c78451510 100644 --- a/lib/internal/console/global.js +++ b/lib/internal/console/global.js @@ -36,7 +36,9 @@ for (const prop of ReflectOwnKeys(Console.prototype)) { if (prop === 'constructor') { continue; } const desc = ReflectGetOwnPropertyDescriptor(Console.prototype, prop); if (typeof desc.value === 'function') { // fix the receiver + const name = desc.value.name; desc.value = desc.value.bind(globalConsole); + ReflectDefineProperty(desc.value, 'name', { value: name }); } ReflectDefineProperty(globalConsole, prop, desc); } diff --git a/lib/internal/constants.js b/lib/internal/constants.js index dfa30bea306e65..bf539a9f37d134 100644 --- a/lib/internal/constants.js +++ b/lib/internal/constants.js @@ -8,6 +8,10 @@ module.exports = { CHAR_LOWERCASE_A: 97, /* a */ CHAR_UPPERCASE_Z: 90, /* Z */ CHAR_LOWERCASE_Z: 122, /* z */ + CHAR_UPPERCASE_C: 67, /* C */ + CHAR_LOWERCASE_B: 98, /* b */ + CHAR_LOWERCASE_E: 101, /* e */ + CHAR_LOWERCASE_N: 110, /* n */ // Non-alphabetic chars. CHAR_DOT: 46, /* . */ diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js index 087cef014f0fb1..bfb30dda3fd752 100644 --- a/lib/internal/crypto/keys.js +++ b/lib/internal/crypto/keys.js @@ -268,23 +268,22 @@ function prepareAsymmetricKey(key, ctx) { // Either PEM or DER using PKCS#1 or SPKI. if (!isStringOrBuffer(data)) { throw new ERR_INVALID_ARG_TYPE( - 'key', + 'key.key', ['string', 'Buffer', 'TypedArray', 'DataView', ...(ctx !== kCreatePrivate ? ['KeyObject'] : [])], - key); + data); } const isPublic = (ctx === kConsumePrivate || ctx === kCreatePrivate) ? false : undefined; return { data, ...parseKeyEncoding(key, undefined, isPublic) }; - } else { - throw new ERR_INVALID_ARG_TYPE( - 'key', - ['string', 'Buffer', 'TypedArray', 'DataView', - ...(ctx !== kCreatePrivate ? ['KeyObject'] : [])], - key - ); } + throw new ERR_INVALID_ARG_TYPE( + 'key', + ['string', 'Buffer', 'TypedArray', 'DataView', + ...(ctx !== kCreatePrivate ? ['KeyObject'] : [])], + key + ); } function preparePrivateKey(key) { @@ -301,13 +300,12 @@ function prepareSecretKey(key, bufferOnly = false) { if (key.type !== 'secret') throw new ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE(key.type, 'secret'); return key[kHandle]; - } else { - throw new ERR_INVALID_ARG_TYPE( - 'key', - ['Buffer', 'TypedArray', 'DataView', - ...(bufferOnly ? [] : ['string', 'KeyObject'])], - key); } + throw new ERR_INVALID_ARG_TYPE( + 'key', + ['Buffer', 'TypedArray', 'DataView', + ...(bufferOnly ? [] : ['string', 'KeyObject'])], + key); } return key; } diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js index 27930ce1acf793..415ea8ac85e45d 100644 --- a/lib/internal/crypto/sig.js +++ b/lib/internal/crypto/sig.js @@ -70,8 +70,7 @@ function getDSASignatureEncoding(options) { return kSigEncDER; else if (dsaEncoding === 'ieee-p1363') return kSigEncP1363; - else - throw new ERR_INVALID_OPT_VALUE('dsaEncoding', dsaEncoding); + throw new ERR_INVALID_OPT_VALUE('dsaEncoding', dsaEncoding); } return kSigEncDER; @@ -82,9 +81,8 @@ function getIntOption(name, options) { if (value !== undefined) { if (value === value >> 0) { return value; - } else { - throw new ERR_INVALID_OPT_VALUE(name, value); } + throw new ERR_INVALID_OPT_VALUE(name, value); } return undefined; } diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 6ade8854964c2e..16cd97e06ac5ca 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -10,6 +10,7 @@ const { bindDefaultResolver, Resolver: CallbackResolver, validateHints, + validateTimeout, emitInvalidHostnameWarning, } = require('internal/dns/utils'); const { codes, dnsException } = require('internal/errors'); @@ -67,11 +68,7 @@ function createLookupPromise(family, hostname, all, hints, verbatim) { return new Promise((resolve, reject) => { if (!hostname) { emitInvalidHostnameWarning(hostname); - if (all) - resolve([]); - else - resolve({ address: null, family: family === 6 ? 6 : 4 }); - + resolve(all ? [] : { address: null, family: family === 6 ? 6 : 4 }); return; } @@ -79,11 +76,7 @@ function createLookupPromise(family, hostname, all, hints, verbatim) { if (matchedFamily !== 0) { const result = { address: hostname, family: matchedFamily }; - if (all) - resolve([result]); - else - resolve(result); - + resolve(all ? [result] : result); return; } @@ -216,8 +209,9 @@ const resolveMap = ObjectCreate(null); // Resolver instances correspond 1:1 to c-ares channels. class Resolver { - constructor() { - this._handle = new ChannelWrap(); + constructor(options = undefined) { + const timeout = validateTimeout(options); + this._handle = new ChannelWrap(timeout); } } diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 93aa529a733a89..6642a4f090bf67 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -6,6 +6,7 @@ const { const errors = require('internal/errors'); const { isIP } = require('internal/net'); +const { validateInt32 } = require('internal/validators'); const { ChannelWrap, strerror, @@ -23,10 +24,17 @@ const { ERR_INVALID_OPT_VALUE } = errors.codes; +function validateTimeout(options) { + const { timeout = -1 } = { ...options }; + validateInt32(timeout, 'options.timeout', -1, 2 ** 31 - 1); + return timeout; +} + // Resolver instances correspond 1:1 to c-ares channels. class Resolver { - constructor() { - this._handle = new ChannelWrap(); + constructor(options = undefined) { + const timeout = validateTimeout(options); + this._handle = new ChannelWrap(timeout); } cancel() { @@ -162,6 +170,7 @@ module.exports = { getDefaultResolver, setDefaultResolver, validateHints, + validateTimeout, Resolver, emitInvalidHostnameWarning, }; diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 1e987cefb156df..a3d99a79c6340c 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -16,6 +16,7 @@ const { JSONStringify, Map, MathAbs, + MathMax, NumberIsInteger, ObjectDefineProperty, ObjectKeys, @@ -695,7 +696,11 @@ const fatalExceptionStackEnhancers = { require('internal/tty').hasColors()) || defaultColors); try { - return inspect(error, { colors }); + return inspect(error, { + colors, + customInspect: false, + depth: MathMax(inspect.defaultOptions.depth, 5) + }); } catch { return originalStack; } @@ -932,6 +937,10 @@ E('ERR_INCOMPATIBLE_OPTION_PAIR', 'Option "%s" cannot be used in combination with option "%s"', TypeError); E('ERR_INPUT_TYPE_NOT_ALLOWED', '--input-type can only be used with string ' + 'input via --eval, --print, or STDIN', Error); +E('ERR_INSPECTOR_ALREADY_ACTIVATED', + 'Inspector is already activated. Close it with inspector.close() ' + + 'before activating it again.', + Error); E('ERR_INSPECTOR_ALREADY_CONNECTED', '%s is already connected', Error); E('ERR_INSPECTOR_CLOSED', 'Session was closed', Error); E('ERR_INSPECTOR_COMMAND', 'Inspector error %d: %s', Error); @@ -1097,10 +1106,9 @@ E('ERR_INVALID_MODULE_SPECIFIER', (pkgPath, subpath, base = undefined) => { assert(subpath !== '.'); return `Package subpath '${subpath}' is not a valid module request for ` + `the "exports" resolution of ${pkgPath}${sep}package.json`; - } else { - return `Package subpath '${subpath}' is not a valid module request for ` + - `the "exports" resolution of ${pkgPath} imported from ${base}`; } + return `Package subpath '${subpath}' is not a valid module request for ` + + `the "exports" resolution of ${pkgPath} imported from ${base}`; }, TypeError); E('ERR_INVALID_OPT_VALUE', (name, value) => `The value "${String(value)}" is invalid for option "${name}"`, @@ -1111,8 +1119,7 @@ E('ERR_INVALID_OPT_VALUE_ENCODING', E('ERR_INVALID_PACKAGE_CONFIG', (path, message, hasMessage = true) => { if (hasMessage) return `Invalid package config ${path}${sep}package.json, ${message}`; - else - return `Invalid JSON in ${path} imported from ${message}`; + return `Invalid JSON in ${path} imported from ${message}`; }, Error); E('ERR_INVALID_PACKAGE_TARGET', (pkgPath, key, subpath, target, base = undefined) => { @@ -1123,11 +1130,10 @@ E('ERR_INVALID_PACKAGE_TARGET', return `Invalid "exports" target ${JSONStringify(target)} defined ` + `for '${subpath}' in the package config ${pkgPath} imported from ` + `${base}.${relError ? '; targets must start with "./"' : ''}`; - } else { - return `Invalid "exports" main target ${target} defined in the ` + - `package config ${pkgPath} imported from ${base}${relError ? - '; targets must start with "./"' : ''}`; } + return `Invalid "exports" main target ${target} defined in the ` + + `package config ${pkgPath} imported from ${base}${relError ? + '; targets must start with "./"' : ''}`; } else if (key === '.') { return `Invalid "exports" main target ${JSONStringify(target)} defined ` + `in the package config ${pkgPath}${sep}package.json${relError ? @@ -1137,11 +1143,10 @@ E('ERR_INVALID_PACKAGE_TARGET', StringPrototypeSlice(key, 0, -subpath.length || key.length)}' in the ` + `package config ${pkgPath}${sep}package.json; ` + 'targets must start with "./"'; - } else { - return `Invalid "exports" target ${JSONStringify(target)} defined for '${ - StringPrototypeSlice(key, 0, -subpath.length || key.length)}' in the ` + - `package config ${pkgPath}${sep}package.json`; } + return `Invalid "exports" target ${JSONStringify(target)} defined for '${ + StringPrototypeSlice(key, 0, -subpath.length || key.length)}' in the ` + + `package config ${pkgPath}${sep}package.json`; }, Error); E('ERR_INVALID_PERFORMANCE_MARK', 'The "%s" performance mark has not been set', Error); @@ -1296,10 +1301,9 @@ E('ERR_PACKAGE_PATH_NOT_EXPORTED', (pkgPath, subpath, base = undefined) => { } else if (base === undefined) { return `Package subpath '${subpath}' is not defined by "exports" in ${ pkgPath}${sep}package.json`; - } else { - return `Package subpath '${subpath}' is not defined by "exports" in ${ - pkgPath} imported from ${base}`; } + return `Package subpath '${subpath}' is not defined by "exports" in ${ + pkgPath} imported from ${base}`; }, Error); E('ERR_REQUIRE_ESM', (filename, parentPath = null, packageJsonPath = null) => { diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index d653724474f314..31eaeef2846216 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -305,7 +305,8 @@ async function rename(oldPath, newPath) { } async function truncate(path, len = 0) { - return ftruncate(await open(path, 'r+'), len); + const fd = await open(path, 'r+'); + return ftruncate(fd, len).finally(fd.close.bind(fd)); } async function ftruncate(handle, len = 0) { diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 343e09d7bc271b..c5cbe9640723d7 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -3,8 +3,6 @@ const { Array, MathMin, - NumberIsInteger, - NumberIsSafeInteger, ObjectDefineProperty, ObjectSetPrototypeOf, Symbol, @@ -15,7 +13,7 @@ const { ERR_OUT_OF_RANGE, ERR_STREAM_DESTROYED } = require('internal/errors').codes; -const { validateNumber } = require('internal/validators'); +const { validateInteger } = require('internal/validators'); const fs = require('fs'); const { Buffer } = require('buffer'); const { @@ -46,19 +44,6 @@ function allocNewPool(poolSize) { pool.used = 0; } -// Check the `this.start` and `this.end` of stream. -function checkPosition(pos, name) { - if (!NumberIsSafeInteger(pos)) { - validateNumber(pos, name); - if (!NumberIsInteger(pos)) - throw new ERR_OUT_OF_RANGE(name, 'an integer', pos); - throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos); - } - if (pos < 0) { - throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos); - } -} - function roundUpToMultipleOf8(n) { return (n + 7) & ~7; // Align to 8 byte boundary. } @@ -111,7 +96,7 @@ function ReadStream(path, options) { this[kIsPerformingIO] = false; if (this.start !== undefined) { - checkPosition(this.start, 'start'); + validateInteger(this.start, 'start', 0); this.pos = this.start; } @@ -119,7 +104,7 @@ function ReadStream(path, options) { if (this.end === undefined) { this.end = Infinity; } else if (this.end !== Infinity) { - checkPosition(this.end, 'end'); + validateInteger(this.end, 'end', 0); if (this.start !== undefined && this.start > this.end) { throw new ERR_OUT_OF_RANGE( @@ -339,7 +324,7 @@ function WriteStream(path, options) { this[kIsPerformingIO] = false; if (this.start !== undefined) { - checkPosition(this.start, 'start'); + validateInteger(this.start, 'start', 0); this.pos = this.start; } @@ -467,9 +452,8 @@ WriteStream.prototype.close = function(cb) { if (this.closed) { process.nextTick(cb); return; - } else { - this.on('close', cb); } + this.on('close', cb); } // If we are not autoClosing, we should call diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 6f096336f20e10..ed4e9bb66ad79f 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -144,6 +144,31 @@ function copyObject(source) { return target; } +const bufferSep = Buffer.from(pathModule.sep); + +function join(path, name) { + if ((typeof path === 'string' || isUint8Array(path)) && + name === undefined) { + return path; + } + + if (typeof path === 'string' && isUint8Array(name)) { + const pathBuffer = Buffer.from(pathModule.join(path, pathModule.sep)); + return Buffer.concat([pathBuffer, name]); + } + + if (typeof path === 'string' && typeof name === 'string') { + return pathModule.join(path, name); + } + + if (isUint8Array(path) && isUint8Array(name)) { + return Buffer.concat([path, bufferSep, name]); + } + + throw new ERR_INVALID_ARG_TYPE( + 'path', ['string', 'Buffer'], path); +} + function getDirents(path, [names, types], callback) { let i; if (typeof callback === 'function') { @@ -156,7 +181,14 @@ function getDirents(path, [names, types], callback) { const name = names[i]; const idx = i; toFinish++; - lazyLoadFs().lstat(pathModule.join(path, name), (err, stats) => { + let filepath; + try { + filepath = join(path, name); + } catch (err) { + callback(err); + return; + } + lazyLoadFs().lstat(filepath, (err, stats) => { if (err) { callback(err); return; @@ -185,7 +217,14 @@ function getDirents(path, [names, types], callback) { function getDirent(path, name, type, callback) { if (typeof callback === 'function') { if (type === UV_DIRENT_UNKNOWN) { - lazyLoadFs().lstat(pathModule.join(path, name), (err, stats) => { + let filepath; + try { + filepath = join(path, name); + } catch (err) { + callback(err); + return; + } + lazyLoadFs().lstat(filepath, (err, stats) => { if (err) { callback(err); return; @@ -196,7 +235,7 @@ function getDirent(path, name, type, callback) { callback(null, new Dirent(name, type)); } } else if (type === UV_DIRENT_UNKNOWN) { - const stats = lazyLoadFs().lstatSync(pathModule.join(path, name)); + const stats = lazyLoadFs().lstatSync(join(path, name)); return new DirentFromStats(name, stats); } else { return new Dirent(name, type); @@ -267,15 +306,20 @@ function preprocessSymlinkDestination(path, type, linkPath) { if (!isWindows) { // No preprocessing is needed on Unix. return path; - } else if (type === 'junction') { + } + if (type === 'junction') { // Junctions paths need to be absolute and \\?\-prefixed. // A relative target is relative to the link's parent directory. path = pathModule.resolve(linkPath, '..', path); return pathModule.toNamespacedPath(path); - } else { - // Windows symlinks don't tolerate forward slashes. - return ('' + path).replace(/\//g, '\\'); } + + if (pathModule.isAbsolute(path)) { + // If the path is absolute, use the \\?\-prefix to enable long filenames + return pathModule.toNamespacedPath(path); + } + // Windows symlinks don't tolerate forward slashes. + return ('' + path).replace(/\//g, '\\'); } // Constructor for file stats. diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 9c49d52b5d37d7..3f86262e737a3f 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -519,6 +519,18 @@ class Http2ServerResponse extends Stream { return this[kStream].writableCorked; } + get writableHighWaterMark() { + return this[kStream].writableHighWaterMark; + } + + get writableFinished() { + return this[kStream].writableFinished; + } + + get writableLength() { + return this[kStream].writableLength; + } + set statusCode(code) { code |= 0; if (code >= 100 && code < 200) @@ -555,7 +567,8 @@ class Http2ServerResponse extends Stream { } getHeaders() { - return { ...this[kHeaders] }; + const headers = ObjectCreate(null); + return ObjectAssign(headers, this[kHeaders]); } hasHeader(name) { @@ -685,11 +698,6 @@ class Http2ServerResponse extends Stream { const stream = this[kStream]; const state = this[kState]; - if ((state.closed || state.ending) && - state.headRequest === stream.headRequest) { - return this; - } - if (typeof chunk === 'function') { cb = chunk; chunk = null; @@ -698,6 +706,14 @@ class Http2ServerResponse extends Stream { encoding = 'utf8'; } + if ((state.closed || state.ending) && + state.headRequest === stream.headRequest) { + if (typeof cb === 'function') { + process.nextTick(cb); + } + return this; + } + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 1031e6dc42474b..2116bc82a158fe 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -1449,27 +1449,7 @@ class Http2Session extends EventEmitter { } _onTimeout() { - // If the session is destroyed, this should never actually be invoked, - // but just in case... - if (this.destroyed) - return; - // This checks whether a write is currently in progress and also whether - // that write is actually sending data across the write. The kHandle - // stored `chunksSentSinceLastWrite` is only updated when a timeout event - // happens, meaning that if a write is ongoing it should never equal the - // newly fetched, updated value. - if (this[kState].writeQueueSize > 0) { - const handle = this[kHandle]; - const chunksSentSinceLastWrite = handle !== undefined ? - handle.chunksSentSinceLastWrite : null; - if (chunksSentSinceLastWrite !== null && - chunksSentSinceLastWrite !== handle.updateChunksSent()) { - this[kUpdateTimer](); - return; - } - } - - this.emit('timeout'); + callTimeout(this); } ref() { @@ -1894,25 +1874,7 @@ class Http2Stream extends Duplex { } _onTimeout() { - if (this.destroyed) - return; - // This checks whether a write is currently in progress and also whether - // that write is actually sending data across the write. The kHandle - // stored `chunksSentSinceLastWrite` is only updated when a timeout event - // happens, meaning that if a write is ongoing it should never equal the - // newly fetched, updated value. - if (this[kState].writeQueueSize > 0) { - const handle = this[kSession][kHandle]; - const chunksSentSinceLastWrite = handle !== undefined ? - handle.chunksSentSinceLastWrite : null; - if (chunksSentSinceLastWrite !== null && - chunksSentSinceLastWrite !== handle.updateChunksSent()) { - this[kUpdateTimer](); - return; - } - } - - this.emit('timeout'); + callTimeout(this, kSession); } // True if the HEADERS frame has been sent @@ -2190,6 +2152,30 @@ class Http2Stream extends Duplex { } } +function callTimeout(self, kSession) { + // If the session is destroyed, this should never actually be invoked, + // but just in case... + if (self.destroyed) + return; + // This checks whether a write is currently in progress and also whether + // that write is actually sending data across the write. The kHandle + // stored `chunksSentSinceLastWrite` is only updated when a timeout event + // happens, meaning that if a write is ongoing it should never equal the + // newly fetched, updated value. + if (self[kState].writeQueueSize > 0) { + const handle = kSession ? self[kSession][kHandle] : self[kHandle]; + const chunksSentSinceLastWrite = handle !== undefined ? + handle.chunksSentSinceLastWrite : null; + if (chunksSentSinceLastWrite !== null && + chunksSentSinceLastWrite !== handle.updateChunksSent()) { + self[kUpdateTimer](); + return; + } + } + + self.emit('timeout'); +} + function callStreamClose(stream) { stream.close(); } diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index 56ccd9df5e9b53..0c68c5eab21cf8 100644 --- a/lib/internal/main/worker_thread.js +++ b/lib/internal/main/worker_thread.js @@ -92,6 +92,7 @@ if (process.env.NODE_CHANNEL_FD) { port.on('message', (message) => { if (message.type === LOAD_SCRIPT) { + port.unref(); const { argv, cwdCounter, @@ -140,7 +141,6 @@ port.on('message', (message) => { debug(`[${threadId}] starts worker script ${filename} ` + `(eval = ${eval}) at cwd = ${process.cwd()}`); - port.unref(); port.postMessage({ type: UP_AND_RUNNING }); if (doEval) { const { evalScript } = require('internal/process/execution'); @@ -162,8 +162,9 @@ port.on('message', (message) => { CJSLoader.Module.runMain(filename); } } else if (message.type === STDIO_PAYLOAD) { - const { stream, chunk, encoding } = message; - process[stream].push(chunk, encoding); + const { stream, chunks } = message; + for (const { chunk, encoding } of chunks) + process[stream].push(chunk, encoding); } else { assert( message.type === STDIO_WANTS_MORE_DATA, diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index fc42eb033c923f..98668573db651a 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -55,10 +55,8 @@ const assert = require('internal/assert'); const fs = require('fs'); const internalFS = require('internal/fs/utils'); const path = require('path'); -const { - internalModuleReadJSON, - internalModuleStat -} = internalBinding('fs'); +const { internalModuleStat } = internalBinding('fs'); +const packageJsonReader = require('internal/modules/package_json_reader'); const { safeGetenv } = internalBinding('credentials'); const { makeRequireFunction, @@ -248,7 +246,8 @@ function readPackage(requestPath) { const existing = packageJsonCache.get(jsonPath); if (existing !== undefined) return existing; - const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath)); + const result = packageJsonReader.read(path.toNamespacedPath(jsonPath)); + const json = result.containsKeys === false ? '{}' : result.string; if (json === undefined) { packageJsonCache.set(jsonPath, false); return false; diff --git a/lib/internal/modules/esm/get_source.js b/lib/internal/modules/esm/get_source.js index 18af566df90ae3..7b2a2f42eabed9 100644 --- a/lib/internal/modules/esm/get_source.js +++ b/lib/internal/modules/esm/get_source.js @@ -28,8 +28,7 @@ async function defaultGetSource(url, { format } = {}, defaultGetSource) { return { source: Buffer.from(body, base64 ? 'base64' : 'utf8') }; - } else { - throw new ERR_INVALID_URL_SCHEME(['file', 'data']); } + throw new ERR_INVALID_URL_SCHEME(['file', 'data']); } exports.defaultGetSource = defaultGetSource; diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 3b79ac2df5ceef..3f11ffc768eedb 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -8,6 +8,7 @@ const { SafePromise, StringPrototypeIncludes, StringPrototypeMatch, + StringPrototypeReplace, StringPrototypeSplit, } = primordials; @@ -108,13 +109,14 @@ class ModuleJob { if (format === 'commonjs') { const importStatement = splitStack[1]; const namedImports = StringPrototypeMatch(importStatement, /{.*}/)[0]; + const destructuringAssignment = StringPrototypeReplace(namedImports, /\s+as\s+/g, ': '); e.message = `The requested module '${childSpecifier}' is expected ` + 'to be of type CommonJS, which does not support named exports. ' + 'CommonJS modules can be imported by importing the default ' + 'export.\n' + 'For example:\n' + `import pkg from '${childSpecifier}';\n` + - `const ${namedImports} = pkg;`; + `const ${destructuringAssignment} = pkg;`; const newStack = StringPrototypeSplit(e.stack, '\n'); newStack[3] = `SyntaxError: ${e.message}`; e.stack = ArrayPrototypeJoin(newStack, '\n'); diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index cbcdb020ed7cd3..987a139c6aae57 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -26,10 +26,6 @@ const assert = require('internal/assert'); const internalFS = require('internal/fs/utils'); const { NativeModule } = require('internal/bootstrap/loaders'); const { - closeSync, - fstatSync, - openSync, - readFileSync, realpathSync, statSync, Stats, @@ -53,6 +49,7 @@ const { ERR_UNSUPPORTED_ESM_URL_SCHEME, } = require('internal/errors').codes; +const packageJsonReader = require('internal/modules/package_json_reader'); const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import']); const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS); @@ -78,37 +75,25 @@ function tryStatSync(path) { } } -function readIfFile(path) { - let fd; - try { - fd = openSync(path, 'r'); - } catch { - return undefined; - } - try { - if (!fstatSync(fd).isFile()) return undefined; - return readFileSync(fd, 'utf8'); - } finally { - closeSync(fd); - } +/** + * + * '/foo/package.json' -> '/foo' + */ +function removePackageJsonFromPath(path) { + return StringPrototypeSlice(path, 0, path.length - 13); } -function getPackageConfig(path, base) { +function getPackageConfig(path) { const existing = packageJSONCache.get(path); if (existing !== undefined) { - if (!existing.isValid) { - throw new ERR_INVALID_PACKAGE_CONFIG(path, fileURLToPath(base), false); - } return existing; } - - const source = readIfFile(path); + const source = packageJsonReader.read(path).string; if (source === undefined) { const packageConfig = { exists: false, main: undefined, name: undefined, - isValid: true, type: 'none', exports: undefined }; @@ -119,17 +104,9 @@ function getPackageConfig(path, base) { let packageJSON; try { packageJSON = JSONParse(source); - } catch { - const packageConfig = { - exists: true, - main: undefined, - name: undefined, - isValid: false, - type: 'none', - exports: undefined - }; - packageJSONCache.set(path, packageConfig); - return packageConfig; + } catch (error) { + const errorPath = removePackageJsonFromPath(path); + throw new ERR_INVALID_PACKAGE_CONFIG(errorPath, error.message, true); } let { main, name, type } = packageJSON; @@ -143,7 +120,6 @@ function getPackageConfig(path, base) { exists: true, main, name, - isValid: true, type, exports }; @@ -171,7 +147,6 @@ function getPackageScopeConfig(resolved, base) { exists: false, main: undefined, name: undefined, - isValid: true, type: 'none', exports: undefined }; @@ -455,10 +430,9 @@ function packageMainResolve(packageJSONUrl, packageConfig, base, conditions) { if (packageConfig.main !== undefined) { return finalizeResolution( new URL(packageConfig.main, packageJSONUrl), base); - } else { - return finalizeResolution( - new URL('index', packageJSONUrl), base); } + return finalizeResolution( + new URL('index', packageJSONUrl), base); } return legacyMainResolve(packageJSONUrl, packageConfig); } @@ -578,10 +552,9 @@ function packageResolve(specifier, base, conditions) { } else if (packageSubpath === '') { return packageMainResolve(packageJSONUrl, packageConfig, base, conditions); - } else { - return packageExportsResolve( - packageJSONUrl, packageSubpath, packageConfig, base, conditions); } + return packageExportsResolve( + packageJSONUrl, packageSubpath, packageConfig, base, conditions); } } @@ -590,8 +563,7 @@ function packageResolve(specifier, base, conditions) { let packageJSONPath = fileURLToPath(packageJSONUrl); let lastPath; do { - const stat = tryStatSync( - StringPrototypeSlice(packageJSONPath, 0, packageJSONPath.length - 13)); + const stat = tryStatSync(removePackageJsonFromPath(packageJSONPath)); if (!stat.isDirectory()) { lastPath = packageJSONPath; packageJSONUrl = new URL((isScoped ? @@ -611,10 +583,9 @@ function packageResolve(specifier, base, conditions) { } else if (packageConfig.exports !== undefined) { return packageExportsResolve( packageJSONUrl, packageSubpath, packageConfig, base, conditions); - } else { - return finalizeResolution( - new URL(packageSubpath, packageJSONUrl), base); } + return finalizeResolution( + new URL(packageSubpath, packageJSONUrl), base); // Cross-platform root check. } while (packageJSONPath.length !== lastPath.length); diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index a7252c1c99f954..f314ba96b3476c 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -11,6 +11,12 @@ const { StringPrototypeReplace, } = primordials; +let _TYPES = null; +function lazyTypes() { + if (_TYPES !== null) return _TYPES; + return _TYPES = require('internal/util/types'); +} + const { stripBOM, loadNativeModule @@ -26,7 +32,10 @@ const createDynamicModule = require( const { fileURLToPath, URL } = require('url'); const { debuglog } = require('internal/util/debuglog'); const { emitExperimentalWarning } = require('internal/util'); -const { ERR_UNKNOWN_BUILTIN_MODULE } = require('internal/errors').codes; +const { + ERR_UNKNOWN_BUILTIN_MODULE, + ERR_INVALID_RETURN_PROPERTY_VALUE +} = require('internal/errors').codes; const { maybeCacheSourceMap } = require('internal/source_map/source_map_cache'); const moduleWrap = internalBinding('module_wrap'); const { ModuleWrap } = moduleWrap; @@ -39,6 +48,30 @@ const debug = debuglog('esm'); const translators = new SafeMap(); exports.translators = translators; +let DECODER = null; +function assertBufferSource(body, allowString, hookName) { + if (allowString && typeof body === 'string') { + return; + } + const { isArrayBufferView, isAnyArrayBuffer } = lazyTypes(); + if (isArrayBufferView(body) || isAnyArrayBuffer(body)) { + return; + } + throw new ERR_INVALID_RETURN_PROPERTY_VALUE( + `${allowString ? 'string, ' : ''}array buffer, or typed array`, + hookName, + 'source', + body + ); +} + +function stringify(body) { + if (typeof body === 'string') return body; + assertBufferSource(body, false, 'transformSource'); + DECODER = DECODER === null ? new TextDecoder() : DECODER; + return DECODER.decode(body); +} + function errPath(url) { const parsed = new URL(url); if (parsed.protocol === 'file:') { @@ -80,9 +113,10 @@ function initializeImportMeta(meta, { url }) { translators.set('module', async function moduleStrategy(url) { let { source } = await this._getSource( url, { format: 'module' }, defaultGetSource); - source = `${source}`; + assertBufferSource(source, true, 'getSource'); ({ source } = await this._transformSource( source, { url, format: 'module' }, defaultTransformSource)); + source = stringify(source); maybeCacheSourceMap(url, source); debug(`Translating StandardModule ${url}`); const module = new ModuleWrap(url, undefined, source, 0, 0); @@ -157,9 +191,10 @@ translators.set('json', async function jsonStrategy(url) { } let { source } = await this._getSource( url, { format: 'json' }, defaultGetSource); - source = `${source}`; + assertBufferSource(source, true, 'getSource'); ({ source } = await this._transformSource( source, { url, format: 'json' }, defaultTransformSource)); + source = stringify(source); if (pathname) { // A require call could have been called on the same file during loading and // that resolves synchronously. To make sure we always return the identical @@ -200,8 +235,10 @@ translators.set('wasm', async function(url) { emitExperimentalWarning('Importing Web Assembly modules'); let { source } = await this._getSource( url, { format: 'wasm' }, defaultGetSource); + assertBufferSource(source, false, 'getSource'); ({ source } = await this._transformSource( source, { url, format: 'wasm' }, defaultTransformSource)); + assertBufferSource(source, false, 'transformSource'); debug(`Translating WASMModule ${url}`); let compiled; try { diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js new file mode 100644 index 00000000000000..066047b55eb9d8 --- /dev/null +++ b/lib/internal/modules/package_json_reader.js @@ -0,0 +1,23 @@ +'use strict'; + +const { SafeMap } = primordials; +const { internalModuleReadJSON } = internalBinding('fs'); + +const cache = new SafeMap(); + +/** + * + * @param {string} path + */ +function read(path) { + if (cache.has(path)) { + return cache.get(path); + } + + const [string, containsKeys] = internalModuleReadJSON(path); + const result = { string, containsKeys }; + cache.set(path, result); + return result; +} + +module.exports = { read }; diff --git a/lib/internal/policy/manifest.js b/lib/internal/policy/manifest.js index 02cf0743d728cd..ae5e6cd3f43dfd 100644 --- a/lib/internal/policy/manifest.js +++ b/lib/internal/policy/manifest.js @@ -145,32 +145,31 @@ class Manifest { const dependencyRedirectList = (toSpecifier) => { if (toSpecifier in dependencyMap !== true) { return null; - } else { - const to = dependencyMap[toSpecifier]; - if (to === true) { - return true; - } - if (parsedURLs.has(to)) { - return parsedURLs.get(to); - } else if (canBeRequiredByUsers(to)) { - const href = `node:${to}`; - const resolvedURL = new URL(href); - parsedURLs.set(to, resolvedURL); - parsedURLs.set(href, resolvedURL); - return resolvedURL; - } else if (RegExpPrototypeTest(kRelativeURLStringPattern, to)) { - const resolvedURL = new URL(to, manifestURL); - const href = resourceURL.href; - parsedURLs.set(to, resolvedURL); - parsedURLs.set(href, resolvedURL); - return resolvedURL; - } - const resolvedURL = new URL(to); + } + const to = dependencyMap[toSpecifier]; + if (to === true) { + return true; + } + if (parsedURLs.has(to)) { + return parsedURLs.get(to); + } else if (canBeRequiredByUsers(to)) { + const href = `node:${to}`; + const resolvedURL = new URL(href); + parsedURLs.set(to, resolvedURL); + parsedURLs.set(href, resolvedURL); + return resolvedURL; + } else if (RegExpPrototypeTest(kRelativeURLStringPattern, to)) { + const resolvedURL = new URL(to, manifestURL); const href = resourceURL.href; parsedURLs.set(to, resolvedURL); parsedURLs.set(href, resolvedURL); return resolvedURL; } + const resolvedURL = new URL(to); + const href = resourceURL.href; + parsedURLs.set(to, resolvedURL); + parsedURLs.set(href, resolvedURL); + return resolvedURL; }; dependencies.set(resourceHREF, dependencyRedirectList); } else if (dependencyMap === true) { diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index a6d6d2325a7f79..4406ea09bba30c 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -153,7 +153,7 @@ function createOnGlobalUncaughtException() { report.writeReport(er ? er.message : 'Exception', 'Exception', null, - er ? er.stack : undefined); + er ? er : {}); } } catch {} // Ignore the exception. Diagnostic reporting is unavailable. } diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js index 72a8b0c1ebe337..114e35ecf2bd06 100644 --- a/lib/internal/process/report.js +++ b/lib/internal/process/report.js @@ -25,7 +25,7 @@ const report = { throw new ERR_INVALID_ARG_TYPE('err', 'Object', err); } - return nr.writeReport('JavaScript API', 'API', file, err.stack); + return nr.writeReport('JavaScript API', 'API', file, err); }, getReport(err) { if (err === undefined) @@ -33,7 +33,7 @@ const report = { else if (err === null || typeof err !== 'object') throw new ERR_INVALID_ARG_TYPE('err', 'Object', err); - return JSONParse(nr.getReport(err.stack)); + return JSONParse(nr.getReport(err)); }, get directory() { return nr.getDirectory(); diff --git a/lib/internal/querystring.js b/lib/internal/querystring.js index 7df1c495c6e5c5..ee589e1984294d 100644 --- a/lib/internal/querystring.js +++ b/lib/internal/querystring.js @@ -36,19 +36,25 @@ function encodeStr(str, noEscapeTable, hexTable) { let out = ''; let lastPos = 0; + let i = 0; - for (let i = 0; i < len; i++) { + outer: + for (; i < len; i++) { let c = str.charCodeAt(i); // ASCII - if (c < 0x80) { - if (noEscapeTable[c] === 1) - continue; - if (lastPos < i) - out += str.slice(lastPos, i); - lastPos = i + 1; - out += hexTable[c]; - continue; + while (c < 0x80) { + if (noEscapeTable[c] !== 1) { + if (lastPos < i) + out += str.slice(lastPos, i); + lastPos = i + 1; + out += hexTable[c]; + } + + if (++i === len) + break outer; + + c = str.charCodeAt(i); } if (lastPos < i) diff --git a/lib/internal/source_map/source_map.js b/lib/internal/source_map/source_map.js index 35ec3ae740e887..2cd70c5c944e19 100644 --- a/lib/internal/source_map/source_map.js +++ b/lib/internal/source_map/source_map.js @@ -196,15 +196,14 @@ class SourceMap { return {}; } else if (!entry) { return {}; - } else { - return { - generatedLine: entry[0], - generatedColumn: entry[1], - originalSource: entry[2], - originalLine: entry[3], - originalColumn: entry[4] - }; } + return { + generatedLine: entry[0], + generatedColumn: entry[1], + originalSource: entry[2], + originalLine: entry[3], + originalColumn: entry[4] + }; } /** diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index b64af7eed6e097..06b1a2a5f52289 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -192,9 +192,8 @@ function sourceMapCacheToObject() { if (ObjectKeys(obj).length === 0) { return undefined; - } else { - return obj; } + return obj; } // Since WeakMap can't be iterated over, we use Module._cache's @@ -243,9 +242,8 @@ function findSourceMap(uri, error) { } if (sourceMap && sourceMap.data) { return new SourceMap(sourceMap.data); - } else { - return undefined; } + return undefined; } module.exports = { diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js index 84c7745e47368f..9796f6866d96c8 100644 --- a/lib/internal/trace_events_async_hooks.js +++ b/lib/internal/trace_events_async_hooks.js @@ -10,12 +10,16 @@ const { const { trace } = internalBinding('trace_events'); const async_wrap = internalBinding('async_wrap'); const async_hooks = require('async_hooks'); +const { + CHAR_LOWERCASE_B, + CHAR_LOWERCASE_E, +} = require('internal/constants'); // Use small letters such that chrome://tracing groups by the name. // The behavior is not only useful but the same as the events emitted using // the specific C++ macros. -const kBeforeEvent = 'b'.charCodeAt(0); -const kEndEvent = 'e'.charCodeAt(0); +const kBeforeEvent = CHAR_LOWERCASE_B; +const kEndEvent = CHAR_LOWERCASE_E; const kTraceEventCategory = 'node,node.async_hooks'; const kEnabled = Symbol('enabled'); diff --git a/lib/internal/url.js b/lib/internal/url.js index efb842a074d750..78f5b32745a043 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -228,9 +228,8 @@ class URLSearchParams { return `${this.constructor.name} {\n ${output.join(',\n ')} }`; } else if (output.length) { return `${this.constructor.name} { ${output.join(separator)} }`; - } else { - return `${this.constructor.name} {}`; } + return `${this.constructor.name} {}`; } } @@ -1315,16 +1314,15 @@ function getPathFromURLWin32(url) { // already taken care of that for us. Note that this only // causes IDNs with an appropriate `xn--` prefix to be decoded. return `\\\\${domainToUnicode(hostname)}${pathname}`; - } else { - // Otherwise, it's a local path that requires a drive letter - const letter = pathname.codePointAt(1) | 0x20; - const sep = pathname[2]; - if (letter < CHAR_LOWERCASE_A || letter > CHAR_LOWERCASE_Z || // a..z A..Z - (sep !== ':')) { - throw new ERR_INVALID_FILE_URL_PATH('must be absolute'); - } - return pathname.slice(1); } + // Otherwise, it's a local path that requires a drive letter + const letter = pathname.codePointAt(1) | 0x20; + const sep = pathname[2]; + if (letter < CHAR_LOWERCASE_A || letter > CHAR_LOWERCASE_Z || // a..z A..Z + (sep !== ':')) { + throw new ERR_INVALID_FILE_URL_PATH('must be absolute'); + } + return pathname.slice(1); } function getPathFromURLPosix(url) { diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 600bdd2b888f24..796fb2717a2362 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -12,6 +12,8 @@ const { DatePrototypeToString, ErrorPrototypeToString, Float32Array, + FunctionPrototypeToString, + Int16Array, JSONStringify, Map, MapPrototype, @@ -170,6 +172,10 @@ const numberRegExp = /^(0|[1-9][0-9]*)$/; const coreModuleRegExp = /^ at (?:[^/\\(]+ \(|)((? { return code <= 0x1F || // C0 control codes - (code > 0x7F && code <= 0x9F) || // C1 control codes + (code >= 0x7F && code <= 0x9F) || // C1 control codes (code >= 0x300 && code <= 0x36F) || // Combining Diacritical Marks (code >= 0x200B && code <= 0x200F) || // Modifying Invisible Characters + // Combining Diacritical Marks for Symbols + (code >= 0x20D0 && code <= 0x20FF) || (code >= 0xFE00 && code <= 0xFE0F) || // Variation Selectors (code >= 0xFE20 && code <= 0xFE2F) || // Combining Half Marks (code >= 0xE0100 && code <= 0xE01EF); // Variation Selectors diff --git a/lib/internal/util/inspector.js b/lib/internal/util/inspector.js index 5a95bcf8ea852a..8d413b116fd0f2 100644 --- a/lib/internal/util/inspector.js +++ b/lib/internal/util/inspector.js @@ -1,6 +1,7 @@ 'use strict'; const { + ObjectDefineProperty, ObjectKeys, } = primordials; @@ -42,6 +43,9 @@ function wrapConsole(consoleFromNode, consoleFromVM) { consoleFromNode[key] = consoleCall.bind(consoleFromNode, consoleFromVM[key], consoleFromNode[key]); + ObjectDefineProperty(consoleFromNode[key], 'name', { + value: key + }); } else { // Add additional console APIs from the inspector consoleFromNode[key] = consoleFromVM[key]; diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 5f92a7898e93a9..d9e0f9f516aba9 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -215,7 +215,7 @@ class Worker extends EventEmitter { this[kDispose](); if (customErr) { debug(`[${threadId}] failing with custom error ${customErr} \ - and with reason {customErrReason}`); + and with reason ${customErrReason}`); this.emit('error', new errorCodes[customErr](customErrReason)); } this.emit('exit', code); @@ -242,8 +242,11 @@ class Worker extends EventEmitter { return this[kOnErrorMessage](message.error); case messageTypes.STDIO_PAYLOAD: { - const { stream, chunk, encoding } = message; - return this[kParentSideStdio][stream].push(chunk, encoding); + const { stream, chunks } = message; + const readable = this[kParentSideStdio][stream]; + for (const { chunk, encoding } of chunks) + readable.push(chunk, encoding); + return; } case messageTypes.STDIO_WANTS_MORE_DATA: { diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js index 1167198676b01b..0a97f17595faa8 100644 --- a/lib/internal/worker/io.js +++ b/lib/internal/worker/io.js @@ -206,12 +206,11 @@ class WritableWorkerStdio extends Writable { this[kWritableCallbacks] = []; } - _write(chunk, encoding, cb) { + _writev(chunks, cb) { this[kPort].postMessage({ type: messageTypes.STDIO_PAYLOAD, stream: this[kName], - chunk, - encoding + chunks: chunks.map(({ chunk, encoding }) => ({ chunk, encoding })) }); this[kWritableCallbacks].push(cb); if (this[kPort][kWaitingStreams]++ === 0) @@ -222,7 +221,7 @@ class WritableWorkerStdio extends Writable { this[kPort].postMessage({ type: messageTypes.STDIO_PAYLOAD, stream: this[kName], - chunk: null + chunks: [ { chunk: null, encoding: '' } ] }); cb(); } diff --git a/lib/net.js b/lib/net.js index fa6574c183e48e..7c61bfcb47d235 100644 --- a/lib/net.js +++ b/lib/net.js @@ -119,6 +119,8 @@ const { kTimeout } = require('internal/timers'); const DEFAULT_IPV4_ADDR = '0.0.0.0'; const DEFAULT_IPV6_ADDR = '::'; +const isWindows = process.platform === 'win32'; + function noop() {} function getFlags(ipv6Only) { @@ -336,8 +338,7 @@ function Socket(options) { this[async_id_symbol] = this._handle.getAsyncId(); if ((fd === 1 || fd === 2) && - (this._handle instanceof Pipe) && - process.platform === 'win32') { + (this._handle instanceof Pipe) && isWindows) { // Make stdout and stderr blocking on Windows err = this._handle.setBlocking(true); if (err) @@ -542,9 +543,8 @@ ObjectDefineProperty(Socket.prototype, 'readyState', { return 'readOnly'; } else if (!this.readable && this.writable) { return 'writeOnly'; - } else { - return 'closed'; } + return 'closed'; } }); @@ -1028,7 +1028,7 @@ function lookupAndConnect(self, options) { hints: options.hints || 0 }; - if (process.platform !== 'win32' && + if (!isWindows && dnsopts.family !== 4 && dnsopts.family !== 6 && dnsopts.hints === 0) { @@ -1227,7 +1227,7 @@ function createServerHandle(address, port, addressType, fd, flags) { assert(!address && !port); } else if (port === -1 && addressType === -1) { handle = new Pipe(PipeConstants.SERVER); - if (process.platform === 'win32') { + if (isWindows) { const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); if (!NumberIsNaN(instances)) { handle.setPendingInstances(instances); @@ -1519,9 +1519,8 @@ Server.prototype.address = function() { return out; } else if (this._pipeName) { return this._pipeName; - } else { - return null; } + return null; }; function onconnection(err, clientHandle) { @@ -1711,7 +1710,7 @@ Server.prototype.unref = function() { let _setSimultaneousAccepts; let warnSimultaneousAccepts = true; -if (process.platform === 'win32') { +if (isWindows) { let simultaneousAccepts; _setSimultaneousAccepts = function(handle) { diff --git a/lib/querystring.js b/lib/querystring.js index 954b35d69e3fbd..f057226f08b51f 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -26,6 +26,7 @@ const { Array, ArrayIsArray, + MathAbs, ObjectCreate, ObjectKeys, } = primordials; @@ -162,6 +163,25 @@ function stringifyPrimitive(v) { } +function encodeStringified(v, encode) { + if (typeof v === 'string') + return (v.length ? encode(v) : ''); + if (typeof v === 'number' && isFinite(v)) { + // Values >= 1e21 automatically switch to scientific notation which requires + // escaping due to the inclusion of a '+' in the output + return (MathAbs(v) < 1e21 ? '' + v : encode('' + v)); + } + if (typeof v === 'boolean') + return v ? 'true' : 'false'; + return ''; +} + + +function encodeStringifiedCustom(v, encode) { + return encode(stringifyPrimitive(v)); +} + + function stringify(obj, sep, eq, options) { sep = sep || '&'; eq = eq || '='; @@ -170,35 +190,36 @@ function stringify(obj, sep, eq, options) { if (options && typeof options.encodeURIComponent === 'function') { encode = options.encodeURIComponent; } + const convert = + (encode === qsEscape ? encodeStringified : encodeStringifiedCustom); if (obj !== null && typeof obj === 'object') { const keys = ObjectKeys(obj); const len = keys.length; - const flast = len - 1; let fields = ''; for (let i = 0; i < len; ++i) { const k = keys[i]; const v = obj[k]; - let ks = encode(stringifyPrimitive(k)); + let ks = convert(k, encode); ks += eq; if (ArrayIsArray(v)) { const vlen = v.length; if (vlen === 0) continue; - const vlast = vlen - 1; + if (fields) + fields += sep; for (let j = 0; j < vlen; ++j) { - fields += ks; - fields += encode(stringifyPrimitive(v[j])); - if (j < vlast) + if (j) fields += sep; + fields += ks; + fields += convert(v[j], encode); } } else { + if (fields) + fields += sep; fields += ks; - fields += encode(stringifyPrimitive(v)); + fields += convert(v, encode); } - - if (i < flast) - fields += sep; } return fields; } diff --git a/lib/readline.js b/lib/readline.js index e86fb50b22cec4..d3e881b2bdb0fe 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -848,6 +848,8 @@ Interface.prototype._ttyWrite = function(s, key) { if (key.ctrl && key.shift) { /* Control and shift pressed */ switch (key.name) { + // TODO(BridgeAR): The transmitted escape sequence is `\b` and that is + // identical to -h. It should have a unique escape sequence. case 'backspace': this._deleteLineLeft(); break; @@ -945,8 +947,10 @@ Interface.prototype._ttyWrite = function(s, key) { } break; - // TODO(BridgeAR): This seems broken? case 'w': // Delete backwards to a word boundary + // TODO(BridgeAR): The transmitted escape sequence is `\b` and that is + // identical to -h. It should have a unique escape sequence. + // Falls through case 'backspace': this._deleteWordLeft(); break; diff --git a/lib/repl.js b/lib/repl.js index 5fdf4ffb9de8db..29a061d2f9e5ac 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -781,9 +781,8 @@ function REPLServer(prompt, self[kBufferedCommandSymbol] += cmd + '\n'; self.displayPrompt(); return; - } else { - self._domain.emit('error', e.err || e); } + self._domain.emit('error', e.err || e); } // Clear buffer if no SyntaxErrors diff --git a/lib/v8.js b/lib/v8.js index 5841f204986fd7..fe848dad72a15c 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -251,14 +251,13 @@ class DefaultDeserializer extends Deserializer { return new ctor(this.buffer.buffer, offset, byteLength / BYTES_PER_ELEMENT); - } else { - // Copy to an aligned buffer first. - const buffer_copy = Buffer.allocUnsafe(byteLength); - copy(this.buffer, buffer_copy, 0, byteOffset, byteOffset + byteLength); - return new ctor(buffer_copy.buffer, - buffer_copy.byteOffset, - byteLength / BYTES_PER_ELEMENT); } + // Copy to an aligned buffer first. + const buffer_copy = Buffer.allocUnsafe(byteLength); + copy(this.buffer, buffer_copy, 0, byteOffset, byteOffset + byteLength); + return new ctor(buffer_copy.buffer, + buffer_copy.byteOffset, + byteLength / BYTES_PER_ELEMENT); } } diff --git a/lib/vm.js b/lib/vm.js index 211755b9728566..448b9ef0daabb0 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -116,9 +116,8 @@ class Script extends ContextifyScript { const { breakOnSigint, args } = getRunInContextArgs(options); if (breakOnSigint && process.listenerCount('SIGINT') > 0) { return sigintHandlersWrap(super.runInThisContext, this, args); - } else { - return super.runInThisContext(...args); } + return super.runInThisContext(...args); } runInContext(contextifiedObject, options) { @@ -127,9 +126,8 @@ class Script extends ContextifyScript { if (breakOnSigint && process.listenerCount('SIGINT') > 0) { return sigintHandlersWrap(super.runInContext, this, [contextifiedObject, ...args]); - } else { - return super.runInContext(contextifiedObject, ...args); } + return super.runInContext(contextifiedObject, ...args); } runInNewContext(contextObject, options) { diff --git a/lib/wasi.js b/lib/wasi.js index a6dee9498463dc..9e8f19e6eda307 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -1,5 +1,4 @@ 'use strict'; -/* global WebAssembly */ const { ArrayPrototypeMap, ArrayPrototypePush, @@ -12,9 +11,11 @@ const { ERR_WASI_ALREADY_STARTED } = require('internal/errors').codes; const { emitExperimentalWarning } = require('internal/util'); +const { isArrayBuffer } = require('internal/util/types'); const { validateArray, validateBoolean, + validateInt32, validateObject, } = require('internal/validators'); const { WASI: _WASI } = internalBinding('wasi'); @@ -50,7 +51,13 @@ class WASI { } } - const wrap = new _WASI(args, env, preopens); + const { stdin = 0, stdout = 1, stderr = 2 } = options; + validateInt32(stdin, 'options.stdin', 0); + validateInt32(stdout, 'options.stdout', 0); + validateInt32(stderr, 'options.stderr', 0); + const stdio = [stdin, stdout, stderr]; + + const wrap = new _WASI(args, env, preopens, stdio); for (const prop in wrap) { wrap[prop] = FunctionPrototypeBind(wrap[prop], wrap); @@ -70,10 +77,7 @@ class WASI { } start(instance) { - if (!(instance instanceof WebAssembly.Instance)) { - throw new ERR_INVALID_ARG_TYPE( - 'instance', 'WebAssembly.Instance', instance); - } + validateObject(instance, 'instance'); const exports = instance.exports; @@ -91,9 +95,19 @@ class WASI { 'instance.exports._initialize', 'undefined', _initialize); } - if (!(memory instanceof WebAssembly.Memory)) { + // WASI::_SetMemory() in src/node_wasi.cc only expects that |memory| is + // an object. It will try to look up the .buffer property when needed + // and fail with UVWASI_EINVAL when the property is missing or is not + // an ArrayBuffer. Long story short, we don't need much validation here + // but we type-check anyway because it helps catch bugs in the user's + // code early. + validateObject(memory, 'instance.exports.memory'); + + if (!isArrayBuffer(memory.buffer)) { throw new ERR_INVALID_ARG_TYPE( - 'instance.exports.memory', 'WebAssembly.Memory', memory); + 'instance.exports.memory.buffer', + ['WebAssembly.Memory'], + memory.buffer); } if (this[kStarted]) { diff --git a/lib/zlib.js b/lib/zlib.js index 4bb6af0322033f..978eeadaaa1d1e 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -763,15 +763,14 @@ function createConvenienceMethod(ctor, sync) { return function syncBufferWrapper(buffer, opts) { return zlibBufferSync(new ctor(opts), buffer); }; - } else { - return function asyncBufferWrapper(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new ctor(opts), buffer, callback); - }; } + return function asyncBufferWrapper(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new ctor(opts), buffer, callback); + }; } const kMaxBrotliParam = MathMax(...ObjectKeys(constants).map((key) => { diff --git a/node.gyp b/node.gyp index ad572f89728ee5..b030de8364a429 100644 --- a/node.gyp +++ b/node.gyp @@ -155,6 +155,7 @@ 'lib/internal/main/run_third_party_main.js', 'lib/internal/main/worker_thread.js', 'lib/internal/modules/run_main.js', + 'lib/internal/modules/package_json_reader.js', 'lib/internal/modules/cjs/helpers.js', 'lib/internal/modules/cjs/loader.js', 'lib/internal/modules/esm/loader.js', @@ -570,7 +571,6 @@ 'src/node_contextify.cc', 'src/node_credentials.cc', 'src/node_dir.cc', - 'src/node_domain.cc', 'src/node_env_var.cc', 'src/node_errors.cc', 'src/node_file.cc', @@ -735,6 +735,7 @@ 'variables': { 'openssl_system_ca_path%': '', + 'openssl_default_cipher_list%': '', }, 'defines': [ @@ -751,6 +752,11 @@ 'msvs_disabled_warnings!': [4244], 'conditions': [ + [ 'openssl_default_cipher_list!=""', { + 'defines': [ + 'NODE_OPENSSL_DEFAULT_CIPHER_LIST="<(openssl_default_cipher_list)"' + ] + }], [ 'node_builtin_modules_path!=""', { 'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ] }], diff --git a/src/README.md b/src/README.md index 2e59c51c3c37e9..563dbe4014cfba 100644 --- a/src/README.md +++ b/src/README.md @@ -137,7 +137,7 @@ function getFoo(obj) { } ``` -```c++ +```cpp v8::Local GetFoo(v8::Local context, v8::Local obj) { v8::Isolate* isolate = context->GetIsolate(); @@ -168,7 +168,7 @@ See [exception handling][] for more information about the usage of `.To()`, If it is known that a `Local` refers to a more specific type, it can be cast to that type using `.As<...>()`: -```c++ +```cpp v8::Local some_value; // CHECK() is a Node.js utilitity that works similar to assert(). CHECK(some_value->IsUint8Array()); @@ -201,7 +201,7 @@ alive even if no other objects refer to them. Weak global handles do not do that, and instead optionally call a callback when the object they refer to is garbage-collected. -```c++ +```cpp v8::Global reference; void StoreReference(v8::Isolate* isolate, v8::Local obj) { @@ -329,7 +329,7 @@ The platform can be accessed through `isolate_data->platform()` given an C++ functions exposed to JS follow a specific signature. The following example is from `node_util.cc`: -```c++ +```cpp void ArrayBufferViewHasBuffer(const FunctionCallbackInfo& args) { CHECK(args[0]->IsArrayBufferView()); args.GetReturnValue().Set(args[0].As()->HasBuffer()); @@ -351,7 +351,7 @@ floating-point number or a `Local` to set the return value. Node.js provides various helpers for building JS classes in C++ and/or attaching C++ functions to the exports of a built-in module: -```c++ +```cpp void Initialize(Local target, Local unused, Local context, @@ -473,7 +473,7 @@ to perform further calls to APIs that return `Maybe`s. A typical pattern for dealing with APIs that return `Maybe` and `MaybeLocal` is using `.ToLocal()` and `.To()` and returning early in case there is an error: -```c++ +```cpp // This could also return a v8::MaybeLocal, for example. v8::Maybe SumNumbers(v8::Local context, v8::Local array_of_integers) { @@ -642,7 +642,7 @@ A helper for this is the `ASSIGN_OR_RETURN_UNWRAP` macro that returns from the current function if unwrapping fails (typically that means that the `BaseObject` has been deleted earlier). -```c++ +```cpp void Http2Session::Request(const FunctionCallbackInfo& args) { Http2Session* session; ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder()); @@ -730,7 +730,7 @@ queues once it returns. Before calling `MakeCallback()`, it is typically necessary to enter both a `HandleScope` and a `Context::Scope`. -```c++ +```cpp void StatWatcher::Callback(uv_fs_poll_t* handle, int status, const uv_stat_t* prev, @@ -822,7 +822,7 @@ The `Utf8Value`, `TwoByteValue` (i.e. UTF-16 value) and `BufferValue` inherit from this class and allow accessing the characters in a JavaScript string this way. -```c++ +```cpp static void Chdir(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); // ... @@ -860,7 +860,7 @@ Node.js provides a few macros that behave similar to `assert()`: The `OnScopeLeave()` function can be used to run a piece of code when leaving the current C++ scope. -```c++ +```cpp static void GetUserInfo(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); uv_passwd_t pwd; diff --git a/src/api/callback.cc b/src/api/callback.cc index a03a2587b4c796..9f52c25cf0d900 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -158,20 +158,33 @@ MaybeLocal InternalMakeCallback(Environment* env, CHECK(!argv[i].IsEmpty()); #endif - InternalCallbackScope scope(env, resource, asyncContext); + Local hook_cb = env->async_hooks_callback_trampoline(); + int flags = InternalCallbackScope::kNoFlags; + int hook_count = 0; + if (!hook_cb.IsEmpty()) { + flags = InternalCallbackScope::kSkipAsyncHooks; + AsyncHooks* async_hooks = env->async_hooks(); + hook_count = async_hooks->fields()[AsyncHooks::kBefore] + + async_hooks->fields()[AsyncHooks::kAfter]; + } + + InternalCallbackScope scope(env, resource, asyncContext, flags); if (scope.Failed()) { return MaybeLocal(); } - Local domain_cb = env->domain_callback(); MaybeLocal ret; - if (asyncContext.async_id != 0 || domain_cb.IsEmpty()) { - ret = callback->Call(env->context(), recv, argc, argv); + + if (hook_count != 0) { + MaybeStackBuffer, 16> args(2 + argc); + args[0] = v8::Number::New(env->isolate(), asyncContext.async_id); + args[1] = callback; + for (int i = 0; i < argc; i++) { + args[i + 2] = argv[i]; + } + ret = hook_cb->Call(env->context(), recv, args.length(), &args[0]); } else { - std::vector> args(1 + argc); - args[0] = callback; - std::copy(&argv[0], &argv[argc], args.begin() + 1); - ret = domain_cb->Call(env->context(), recv, args.size(), &args[0]); + ret = callback->Call(env->context(), recv, argc, argv); } if (ret.IsEmpty()) { diff --git a/src/api/environment.cc b/src/api/environment.cc index 09d71b34581268..5526859e551c10 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -48,17 +48,11 @@ static MaybeLocal PrepareStackTraceCallback(Local context, Local trace) { Environment* env = Environment::GetCurrent(context); if (env == nullptr) { - MaybeLocal s = exception->ToString(context); - return s.IsEmpty() ? - MaybeLocal() : - MaybeLocal(s.ToLocalChecked()); + return exception->ToString(context).FromMaybe(Local()); } Local prepare = env->prepare_stack_trace_callback(); if (prepare.IsEmpty()) { - MaybeLocal s = exception->ToString(context); - return s.IsEmpty() ? - MaybeLocal() : - MaybeLocal(s.ToLocalChecked()); + return exception->ToString(context).FromMaybe(Local()); } Local args[] = { context->Global(), @@ -423,7 +417,7 @@ void InitializeContextRuntime(Local context) { if (context->Global()->Get(context, intl_string).ToLocal(&intl_v) && intl_v->IsObject()) { Local intl = intl_v.As(); - intl->Delete(context, break_iter_string).FromJust(); + intl->Delete(context, break_iter_string).Check(); } // Delete `Atomics.wake` @@ -434,7 +428,7 @@ void InitializeContextRuntime(Local context) { if (context->Global()->Get(context, atomics_string).ToLocal(&atomics_v) && atomics_v->IsObject()) { Local atomics = atomics_v.As(); - atomics->Delete(context, wake_string).FromJust(); + atomics->Delete(context, wake_string).Check(); } // Remove __proto__ @@ -504,10 +498,10 @@ bool InitializePrimordials(Local context) { MaybeLocal maybe_fn = native_module::NativeModuleEnv::LookupAndCompile( context, *module, ¶meters, nullptr); - if (maybe_fn.IsEmpty()) { + Local fn; + if (!maybe_fn.ToLocal(&fn)) { return false; } - Local fn = maybe_fn.ToLocalChecked(); MaybeLocal result = fn->Call(context, Undefined(isolate), arraysize(arguments), arguments); // Execution failed during context creation. diff --git a/src/api/hooks.cc b/src/api/hooks.cc index 2dd0cc994ea7f2..037bdda6f41c82 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -30,15 +30,21 @@ void AtExit(Environment* env, void (*cb)(void* arg), void* arg) { } void EmitBeforeExit(Environment* env) { - env->RunBeforeExitCallbacks(); + TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment), + "BeforeExit", env); + if (!env->destroy_async_id_list()->empty()) + AsyncWrap::DestroyAsyncIdsCallback(env); HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); - Local exit_code = env->process_object() - ->Get(env->context(), env->exit_code_string()) - .ToLocalChecked() - ->ToInteger(env->context()) - .ToLocalChecked(); + + Local exit_code_v; + if (!env->process_object()->Get(env->context(), env->exit_code_string()) + .ToLocal(&exit_code_v)) return; + + Local exit_code; + if (!exit_code_v->ToInteger(env->context()).ToLocal(&exit_code)) return; + ProcessEmit(env, "beforeExit", exit_code).ToLocalChecked(); } diff --git a/src/async_wrap.cc b/src/async_wrap.cc index b7c34f0121760c..43565eea16ea57 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -469,6 +469,14 @@ void AsyncWrap::QueueDestroyAsyncId(const FunctionCallbackInfo& args) { args[0].As()->Value()); } +void AsyncWrap::SetCallbackTrampoline(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); + + CHECK(args[0]->IsFunction()); + + env->set_async_hooks_callback_trampoline(args[0].As()); +} + Local AsyncWrap::GetConstructorTemplate(Environment* env) { Local tmpl = env->async_wrap_ctor_template(); if (tmpl.IsEmpty()) { @@ -491,6 +499,7 @@ void AsyncWrap::Initialize(Local target, HandleScope scope(isolate); env->SetMethod(target, "setupHooks", SetupHooks); + env->SetMethod(target, "setCallbackTrampoline", SetCallbackTrampoline); env->SetMethod(target, "pushAsyncContext", PushAsyncContext); env->SetMethod(target, "popAsyncContext", PopAsyncContext); env->SetMethod(target, "queueDestroyAsyncId", QueueDestroyAsyncId); diff --git a/src/async_wrap.h b/src/async_wrap.h index 24bc3672fa467d..1248323ac5c0af 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -140,6 +140,8 @@ class AsyncWrap : public BaseObject { static void GetProviderType(const v8::FunctionCallbackInfo& args); static void QueueDestroyAsyncId( const v8::FunctionCallbackInfo& args); + static void SetCallbackTrampoline( + const v8::FunctionCallbackInfo& args); static void EmitAsyncInit(Environment* env, v8::Local object, diff --git a/src/base64.h b/src/base64.h index ba609704319dae..1cb90bdeba75b0 100644 --- a/src/base64.h +++ b/src/base64.h @@ -11,37 +11,26 @@ namespace node { //// Base 64 //// static inline constexpr size_t base64_encoded_size(size_t size) { - return ((size + 2 - ((size + 2) % 3)) / 3 * 4); + return ((size + 2) / 3 * 4); } // Doesn't check for padding at the end. Can be 1-2 bytes over. -static inline size_t base64_decoded_size_fast(size_t size) { - size_t remainder = size % 4; - - size = (size / 4) * 3; - if (remainder) { - if (size == 0 && remainder == 1) { - // special case: 1-byte input cannot be decoded - size = 0; - } else { - // non-padded input, add 1 or 2 extra bytes - size += 1 + (remainder == 3); - } - } - - return size; +static inline constexpr size_t base64_decoded_size_fast(size_t size) { + // 1-byte input cannot be decoded + return size > 1 ? (size / 4) * 3 + (size % 4 + 1) / 2 : 0; } template size_t base64_decoded_size(const TypeName* src, size_t size) { - if (size == 0) + // 1-byte input cannot be decoded + if (size < 2) return 0; - if (src[size - 1] == '=') + if (src[size - 1] == '=') { size--; - if (size > 0 && src[size - 1] == '=') - size--; - + if (src[size - 1] == '=') + size--; + } return base64_decoded_size_fast(size); } @@ -166,25 +155,22 @@ static size_t base64_encode(const char* src, k += 4; } - if (n != slen) { - switch (slen - n) { - case 1: - a = src[i + 0] & 0xff; - dst[k + 0] = table[a >> 2]; - dst[k + 1] = table[(a & 3) << 4]; - dst[k + 2] = '='; - dst[k + 3] = '='; - break; - - case 2: - a = src[i + 0] & 0xff; - b = src[i + 1] & 0xff; - dst[k + 0] = table[a >> 2]; - dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; - dst[k + 2] = table[(b & 0x0f) << 2]; - dst[k + 3] = '='; - break; - } + switch (slen - n) { + case 1: + a = src[i + 0] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[(a & 3) << 4]; + dst[k + 2] = '='; + dst[k + 3] = '='; + break; + case 2: + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[(b & 0x0f) << 2]; + dst[k + 3] = '='; + break; } return dlen; diff --git a/src/base_object-inl.h b/src/base_object-inl.h index fc2611444c1af4..5dad438d1f55bf 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -216,20 +216,22 @@ BaseObject::PointerData* BaseObjectPtrImpl::pointer_data() const { if (kIsWeak) { return data_.pointer_data; - } else { - if (get_base_object() == nullptr) return nullptr; - return get_base_object()->pointer_data(); } + if (get_base_object() == nullptr) { + return nullptr; + } + return get_base_object()->pointer_data(); } template BaseObject* BaseObjectPtrImpl::get_base_object() const { if (kIsWeak) { - if (pointer_data() == nullptr) return nullptr; + if (pointer_data() == nullptr) { + return nullptr; + } return pointer_data()->self; - } else { - return data_.target; } + return data_.target; } template diff --git a/src/base_object.h b/src/base_object.h index 2c67445c31fbb6..cc7a220d078552 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -24,9 +24,9 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS +#include // std::remove_reference #include "memory_tracker.h" #include "v8.h" -#include // std::remove_reference namespace node { @@ -84,7 +84,7 @@ class BaseObject : public MemoryRetainer { template static void InternalFieldGet(v8::Local property, const v8::PropertyCallbackInfo& info); - template + template static void InternalFieldSet(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info); @@ -103,6 +103,7 @@ class BaseObject : public MemoryRetainer { private: v8::Local WrappedObject() const override; + bool IsRootNode() const override; static void DeleteMe(void* data); // persistent_handle_ needs to be at a fixed offset from the start of the @@ -156,13 +157,11 @@ inline T* Unwrap(v8::Local obj) { return BaseObject::FromJSObject(obj); } - -#define ASSIGN_OR_RETURN_UNWRAP(ptr, obj, ...) \ - do { \ - *ptr = static_cast::type>( \ - BaseObject::FromJSObject(obj)); \ - if (*ptr == nullptr) \ - return __VA_ARGS__; \ +#define ASSIGN_OR_RETURN_UNWRAP(ptr, obj, ...) \ + do { \ + *ptr = static_cast::type>( \ + BaseObject::FromJSObject(obj)); \ + if (*ptr == nullptr) return __VA_ARGS__; \ } while (0) // Implementation of a generic strong or weak pointer to a BaseObject. @@ -198,7 +197,7 @@ class BaseObjectPtrImpl final { private: union { - BaseObject* target; // Used for strong pointers. + BaseObject* target; // Used for strong pointers. BaseObject::PointerData* pointer_data; // Used for weak pointers. } data_; diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 8d1e3bc8794dfe..4a332db71279a4 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -152,7 +152,7 @@ using node_ares_task_list = class ChannelWrap : public AsyncWrap { public: - ChannelWrap(Environment* env, Local object); + ChannelWrap(Environment* env, Local object, int timeout); ~ChannelWrap() override; static void New(const FunctionCallbackInfo& args); @@ -190,18 +190,21 @@ class ChannelWrap : public AsyncWrap { bool query_last_ok_; bool is_servers_default_; bool library_inited_; + int timeout_; int active_query_count_; node_ares_task_list task_list_; }; ChannelWrap::ChannelWrap(Environment* env, - Local object) + Local object, + int timeout) : AsyncWrap(env, object, PROVIDER_DNSCHANNEL), timer_handle_(nullptr), channel_(nullptr), query_last_ok_(true), is_servers_default_(true), library_inited_(false), + timeout_(timeout), active_query_count_(0) { MakeWeak(); @@ -210,10 +213,11 @@ ChannelWrap::ChannelWrap(Environment* env, void ChannelWrap::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - CHECK_EQ(args.Length(), 0); - + CHECK_EQ(args.Length(), 1); + CHECK(args[0]->IsInt32()); + const int timeout = args[0].As()->Value(); Environment* env = Environment::GetCurrent(args); - new ChannelWrap(env, args.This()); + new ChannelWrap(env, args.This(), timeout); } class GetAddrInfoReqWrap : public ReqWrap { @@ -462,6 +466,7 @@ void ChannelWrap::Setup() { options.flags = ARES_FLAG_NOCHECKRESP; options.sock_state_cb = ares_sockstate_cb; options.sock_state_cb_data = this; + options.timeout = timeout_; int r; if (!library_inited_) { @@ -474,9 +479,9 @@ void ChannelWrap::Setup() { } /* We do the call to ares_init_option for caller. */ - r = ares_init_options(&channel_, - &options, - ARES_OPT_FLAGS | ARES_OPT_SOCK_STATE_CB); + const int optmask = + ARES_OPT_FLAGS | ARES_OPT_TIMEOUTMS | ARES_OPT_SOCK_STATE_CB; + r = ares_init_options(&channel_, &options, optmask); if (r != ARES_SUCCESS) { Mutex::ScopedLock lock(ares_library_mutex); @@ -495,7 +500,10 @@ void ChannelWrap::StartTimer() { } else if (uv_is_active(reinterpret_cast(timer_handle_))) { return; } - uv_timer_start(timer_handle_, AresTimeout, 1000, 1000); + int timeout = timeout_; + if (timeout == 0) timeout = 1; + if (timeout < 0 || timeout > 1000) timeout = 1000; + uv_timer_start(timer_handle_, AresTimeout, timeout, timeout); } void ChannelWrap::CloseTimer() { diff --git a/src/env.cc b/src/env.cc index 657d711e539d81..18788e4ceaf208 100644 --- a/src/env.cc +++ b/src/env.cc @@ -366,13 +366,6 @@ Environment::Environment(IsolateData* isolate_data, } destroy_async_id_list_.reserve(512); - BeforeExit( - [](void* arg) { - Environment* env = static_cast(arg); - if (!env->destroy_async_id_list()->empty()) - AsyncWrap::DestroyAsyncIdsCallback(env); - }, - this); performance_state_ = std::make_unique(isolate()); @@ -640,19 +633,6 @@ void Environment::RunCleanup() { } } -void Environment::RunBeforeExitCallbacks() { - TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment), - "BeforeExit", this); - for (ExitCallback before_exit : before_exit_functions_) { - before_exit.cb_(before_exit.arg_); - } - before_exit_functions_.clear(); -} - -void Environment::BeforeExit(void (*cb)(void* arg), void* arg) { - before_exit_functions_.push_back(ExitCallback{cb, arg}); -} - void Environment::RunAtExitCallbacks() { TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment), "AtExit", this); @@ -1006,33 +986,16 @@ Environment* Environment::worker_parent_env() const { return worker_context_->env(); } -void MemoryTracker::TrackField(const char* edge_name, - const CleanupHookCallback& value, - const char* node_name) { - HandleScope handle_scope(isolate_); - // Here, we utilize the fact that CleanupHookCallback instances - // are all unique and won't be tracked twice in one BuildEmbedderGraph - // callback. - MemoryRetainerNode* n = - PushNode("CleanupHookCallback", sizeof(value), edge_name); - // TODO(joyeecheung): at the moment only arguments of type BaseObject will be - // identified and tracked here (based on their deleters), - // but we may convert and track other known types here. - BaseObject* obj = value.GetBaseObject(); - if (obj != nullptr && obj->IsDoneInitializing()) { - TrackField("arg", obj); - } - CHECK_EQ(CurrentNode(), n); - CHECK_NE(n->size_, 0); - PopNode(); -} - void Environment::BuildEmbedderGraph(Isolate* isolate, EmbedderGraph* graph, void* data) { MemoryTracker tracker(isolate, graph); Environment* env = static_cast(data); tracker.Track(env); + env->ForEachBaseObject([&](BaseObject* obj) { + if (obj->IsDoneInitializing()) + tracker.Track(obj); + }); } inline size_t Environment::SelfSize() const { @@ -1062,7 +1025,8 @@ void Environment::MemoryInfo(MemoryTracker* tracker) const { tracker->TrackField("fs_stats_field_array", fs_stats_field_array_); tracker->TrackField("fs_stats_field_bigint_array", fs_stats_field_bigint_array_); - tracker->TrackField("cleanup_hooks", cleanup_hooks_); + tracker->TrackFieldWithSize( + "cleanup_hooks", cleanup_hooks_.size() * sizeof(CleanupHookCallback)); tracker->TrackField("async_hooks", async_hooks_); tracker->TrackField("immediate_info", immediate_info_); tracker->TrackField("tick_info", tick_info_); @@ -1156,4 +1120,8 @@ Local BaseObject::WrappedObject() const { return object(); } +bool BaseObject::IsRootNode() const { + return !persistent_handle_.IsWeak(); +} + } // namespace node diff --git a/src/env.h b/src/env.h index 6de5ba9b192dd1..d22b579b25ce4e 100644 --- a/src/env.h +++ b/src/env.h @@ -434,13 +434,13 @@ constexpr size_t kFsStatsBufferLength = V(as_callback_data, v8::Object) \ V(async_hooks_after_function, v8::Function) \ V(async_hooks_before_function, v8::Function) \ + V(async_hooks_callback_trampoline, v8::Function) \ V(async_hooks_binding, v8::Object) \ V(async_hooks_destroy_function, v8::Function) \ V(async_hooks_init_function, v8::Function) \ V(async_hooks_promise_resolve_function, v8::Function) \ V(buffer_prototype_object, v8::Object) \ V(crypto_key_object_constructor, v8::Function) \ - V(domain_callback, v8::Function) \ V(domexception_function, v8::Function) \ V(enhance_fatal_stack_after_inspector, v8::Function) \ V(enhance_fatal_stack_before_inspector, v8::Function) \ @@ -1118,8 +1118,6 @@ class Environment : public MemoryRetainer { const char* name, v8::FunctionCallback callback); - void BeforeExit(void (*cb)(void* arg), void* arg); - void RunBeforeExitCallbacks(); void AtExit(void (*cb)(void* arg), void* arg); void RunAtExitCallbacks(); @@ -1394,7 +1392,6 @@ class Environment : public MemoryRetainer { void (*cb_)(void* arg); void* arg_; }; - std::list before_exit_functions_; std::list at_exit_functions_; diff --git a/src/heap_utils.cc b/src/heap_utils.cc index 2e979e49e87922..386bf61e4eca00 100644 --- a/src/heap_utils.cc +++ b/src/heap_utils.cc @@ -15,7 +15,6 @@ using v8::Global; using v8::HandleScope; using v8::HeapSnapshot; using v8::Isolate; -using v8::JSON; using v8::Local; using v8::MaybeLocal; using v8::Number; diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 94433b75d0fdb2..7712a62d7cbeb0 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -45,11 +45,9 @@ using v8::Isolate; using v8::Local; using v8::Message; using v8::Object; -using v8::String; using v8::Task; using v8::TaskRunner; using v8::Value; - using v8_inspector::StringBuffer; using v8_inspector::StringView; using v8_inspector::V8Inspector; diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index ed3b36ad5ca80e..9bc244ceb4a597 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -12,7 +12,6 @@ namespace node { namespace inspector { namespace { -using v8::Boolean; using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc index 9e27bd30f76871..29e0c128026ed0 100644 --- a/src/inspector_socket_server.cc +++ b/src/inspector_socket_server.cc @@ -373,7 +373,7 @@ void InspectorSocketServer::SendListResponse(InspectorSocket* socket, std::string InspectorSocketServer::GetFrontendURL(bool is_compat, const std::string &formatted_address) { std::ostringstream frontend_url; - frontend_url << "chrome-devtools://devtools/bundled/"; + frontend_url << "devtools://devtools/bundled/"; frontend_url << (is_compat ? "inspector" : "js_app"); frontend_url << ".html?experiments=true&v8only=true&ws="; frontend_url << formatted_address; diff --git a/src/js_native_api.h b/src/js_native_api.h index 2675da505c2368..00dedfbfc71c38 100644 --- a/src/js_native_api.h +++ b/src/js_native_api.h @@ -28,6 +28,9 @@ #ifndef NAPI_EXTERN #ifdef _WIN32 #define NAPI_EXTERN __declspec(dllexport) + #elif defined(__wasm32__) + #define NAPI_EXTERN __attribute__((visibility("default"))) \ + __attribute__((__import_module__("napi"))) #else #define NAPI_EXTERN __attribute__((visibility("default"))) #endif diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index a351edc023c562..ec6c5256143ea2 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -267,7 +267,8 @@ class RefBase : protected Finalizer, RefTracker { protected: inline void Finalize(bool is_env_teardown = false) override { if (_finalize_callback != nullptr) { - _env->CallIntoModuleThrow([&](napi_env env) { + v8::HandleScope handle_scope(_env->isolate); + _env->CallIntoModule([&](napi_env env) { _finalize_callback( env, _finalize_data, @@ -508,7 +509,7 @@ class CallbackWrapperBase : public CallbackWrapper { napi_callback cb = _bundle->*FunctionField; napi_value result; - env->CallIntoModuleThrow([&](napi_env env) { + env->CallIntoModule([&](napi_env env) { result = cb(env, cbinfo_wrapper); }); diff --git a/src/js_native_api_v8.h b/src/js_native_api_v8.h index 32fc16f155a7fe..9c737f3c9cc9fc 100644 --- a/src/js_native_api_v8.h +++ b/src/js_native_api_v8.h @@ -82,8 +82,13 @@ struct napi_env__ { return v8::Just(true); } - template - void CallIntoModule(T&& call, U&& handle_exception) { + static inline void + HandleThrow(napi_env env, v8::Local value) { + env->isolate->ThrowException(value); + } + + template + inline void CallIntoModule(T&& call, U&& handle_exception = HandleThrow) { int open_handle_scopes_before = open_handle_scopes; int open_callback_scopes_before = open_callback_scopes; napi_clear_last_error(this); @@ -96,13 +101,6 @@ struct napi_env__ { } } - template - void CallIntoModuleThrow(T&& call) { - CallIntoModule(call, [&](napi_env env, v8::Local value) { - env->isolate->ThrowException(value); - }); - } - v8impl::Persistent last_exception; // We store references in two different lists, depending on whether they have diff --git a/src/json_utils.cc b/src/json_utils.cc index aa03a6d7305d75..96f178cf351d96 100644 --- a/src/json_utils.cc +++ b/src/json_utils.cc @@ -41,12 +41,11 @@ std::string EscapeJsonChars(const std::string& str) { } std::string Reindent(const std::string& str, int indent_depth) { - std::string indent; - for (int i = 0; i < indent_depth; i++) indent += ' '; - + if (indent_depth <= 0) return str; + const std::string indent(indent_depth, ' '); std::string out; std::string::size_type pos = 0; - do { + for (;;) { std::string::size_type prev_pos = pos; pos = str.find('\n', pos); @@ -59,7 +58,7 @@ std::string Reindent(const std::string& str, int indent_depth) { pos++; out.append(str, prev_pos, pos - prev_pos); } - } while (true); + } return out; } diff --git a/src/memory_tracker.h b/src/memory_tracker.h index 6cd372f493c41d..83443cbd6bf679 100644 --- a/src/memory_tracker.h +++ b/src/memory_tracker.h @@ -208,13 +208,6 @@ class MemoryTracker { inline void TrackField(const char* edge_name, const MallocedBuffer& value, const char* node_name = nullptr); - // We do not implement CleanupHookCallback as MemoryRetainer - // but instead specialize the method here to avoid the cost of - // virtual pointers. - // TODO(joyeecheung): do this for BaseObject and remove WrappedObject() - void TrackField(const char* edge_name, - const CleanupHookCallback& value, - const char* node_name = nullptr); inline void TrackField(const char* edge_name, const uv_buf_t& value, const char* node_name = nullptr); diff --git a/src/module_wrap.cc b/src/module_wrap.cc index f578f752b02d8b..97403eb54c9445 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -34,9 +34,7 @@ using v8::HandleScope; using v8::Integer; using v8::IntegrityLevel; using v8::Isolate; -using v8::Just; using v8::Local; -using v8::Maybe; using v8::MaybeLocal; using v8::Module; using v8::Number; diff --git a/src/node.cc b/src/node.cc index 4ff7824b001168..728785d5d2773d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -634,7 +634,10 @@ void ResetStdio() { err = tcsetattr(fd, TCSANOW, &s.termios); while (err == -1 && errno == EINTR); // NOLINT CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr)); - CHECK_EQ(0, err); + + // Normally we expect err == 0. But if macOS App Sandbox is enabled, + // tcsetattr will fail with err == -1 and errno == EPERM. + CHECK_IMPLIES(err != 0, err == -1 && errno == EPERM); } } #endif // __POSIX__ diff --git a/src/node_api.cc b/src/node_api.cc index b87690752b3d9a..fe24eca1b8e2d8 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -57,7 +57,7 @@ class BufferFinalizer : private Finalizer { v8::HandleScope handle_scope(finalizer->_env->isolate); v8::Context::Scope context_scope(finalizer->_env->context()); - finalizer->_env->CallIntoModuleThrow([&](napi_env env) { + finalizer->_env->CallIntoModule([&](napi_env env) { finalizer->_finalize_callback( env, finalizer->_finalize_data, @@ -308,7 +308,7 @@ class ThreadSafeFunction : public node::AsyncResource { v8::Local::New(env->isolate, ref); js_callback = v8impl::JsValueFromV8LocalValue(js_cb); } - env->CallIntoModuleThrow([&](napi_env env) { + env->CallIntoModule([&](napi_env env) { call_js_cb(env, js_callback, context, data); }); } @@ -318,7 +318,7 @@ class ThreadSafeFunction : public node::AsyncResource { v8::HandleScope scope(env->isolate); if (finalize_cb) { CallbackScope cb_scope(this); - env->CallIntoModuleThrow([&](napi_env env) { + env->CallIntoModule([&](napi_env env) { finalize_cb(env, finalize_data, context); }); } @@ -455,7 +455,7 @@ void napi_module_register_by_symbol(v8::Local exports, napi_env env = v8impl::NewEnv(context); napi_value _exports; - env->CallIntoModuleThrow([&](napi_env env) { + env->CallIntoModule([&](napi_env env) { _exports = init(env, v8impl::JsValueFromV8LocalValue(exports)); }); diff --git a/src/node_api.h b/src/node_api.h index a4d3cc60e9bb5c..2f1b45572d8130 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -5,6 +5,8 @@ #ifdef _WIN32 // Building native module against node #define NAPI_EXTERN __declspec(dllimport) + #elif defined(__wasm32__) + #define NAPI_EXTERN __attribute__((__import_module__("napi"))) #endif #endif #include "js_native_api.h" @@ -71,15 +73,27 @@ typedef struct { } \ EXTERN_C_END +#define NAPI_MODULE_INITIALIZER_X(base, version) \ + NAPI_MODULE_INITIALIZER_X_HELPER(base, version) +#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version + +#ifdef __wasm32__ +#define NAPI_WASM_INITIALIZER \ + NAPI_MODULE_INITIALIZER_X(napi_register_wasm_v, NAPI_MODULE_VERSION) +#define NAPI_MODULE(modname, regfunc) \ + EXTERN_C_START \ + NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \ + napi_value exports) { \ + return regfunc(env, exports); \ + } \ + EXTERN_C_END +#else #define NAPI_MODULE(modname, regfunc) \ NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) +#endif #define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v -#define NAPI_MODULE_INITIALIZER_X(base, version) \ - NAPI_MODULE_INITIALIZER_X_HELPER(base, version) -#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version - #define NAPI_MODULE_INITIALIZER \ NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, \ NAPI_MODULE_VERSION) @@ -196,6 +210,7 @@ NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, #if NAPI_VERSION >= 4 +#ifndef __wasm32__ // Calling into JS from other threads NAPI_EXTERN napi_status napi_create_threadsafe_function(napi_env env, @@ -231,6 +246,7 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); NAPI_EXTERN napi_status napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); +#endif // __wasm32__ #endif // NAPI_VERSION >= 4 diff --git a/src/node_binding.cc b/src/node_binding.cc index 91ae3530d09b16..0b5f6cfa038369 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -42,7 +42,6 @@ V(config) \ V(contextify) \ V(credentials) \ - V(domain) \ V(errors) \ V(fs) \ V(fs_dir) \ diff --git a/src/node_code_cache_stub.cc b/src/node_code_cache_stub.cc index 2dd6d8beb9e17e..3851508170f812 100644 --- a/src/node_code_cache_stub.cc +++ b/src/node_code_cache_stub.cc @@ -1,7 +1,9 @@ #include "node_native_module_env.h" -// This is supposed to be generated by tools/generate_code_cache.js -// The stub here is used when configure is run without `--code-cache-path` +// The stub here is used when configure is run without `--code-cache-path`. +// When --code-cache-path is set this stub will not be used and instead +// an implementation will be generated. See tools/code_cache/README.md for +// more information. namespace node { namespace native_module { diff --git a/src/node_constants.h b/src/node_constants.h index af5aa002eb5795..d7de705fb8ec7e 100644 --- a/src/node_constants.h +++ b/src/node_constants.h @@ -41,6 +41,9 @@ #define RSA_PSS_SALTLEN_AUTO -2 #endif +#if defined(NODE_OPENSSL_DEFAULT_CIPHER_LIST) +#define DEFAULT_CIPHER_LIST_CORE NODE_OPENSSL_DEFAULT_CIPHER_LIST +#else // TLSv1.3 suites start with TLS_, and are the OpenSSL defaults, see: // https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_ciphersuites.html #define DEFAULT_CIPHER_LIST_CORE \ @@ -68,7 +71,8 @@ "!PSK:" \ "!SRP:" \ "!CAMELLIA" -#endif +#endif // NODE_OPENSSL_DEFAULT_CIPHER_LIST +#endif // HAVE_OPENSSL namespace node { diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 3072dc8a7bb50f..b90b369d1b379c 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -419,7 +419,7 @@ void ContextifyContext::PropertySetterCallback( args.GetReturnValue().Set(false); } - ctx->sandbox()->Set(ctx->context(), property, value).Check(); + USE(ctx->sandbox()->Set(ctx->context(), property, value)); } // static @@ -437,9 +437,10 @@ void ContextifyContext::PropertyDescriptorCallback( Local sandbox = ctx->sandbox(); if (sandbox->HasOwnProperty(context, property).FromMaybe(false)) { - args.GetReturnValue().Set( - sandbox->GetOwnPropertyDescriptor(context, property) - .ToLocalChecked()); + Local desc; + if (sandbox->GetOwnPropertyDescriptor(context, property).ToLocal(&desc)) { + args.GetReturnValue().Set(desc); + } } } @@ -482,8 +483,7 @@ void ContextifyContext::PropertyDefinerCallback( desc_for_sandbox->set_configurable(desc.configurable()); } // Set the property on the sandbox. - sandbox->DefineProperty(context, property, *desc_for_sandbox) - .Check(); + USE(sandbox->DefineProperty(context, property, *desc_for_sandbox)); }; if (desc.has_get() || desc.has_set()) { diff --git a/src/node_credentials.cc b/src/node_credentials.cc index ad0e1dbb9bb68e..d552a501726396 100644 --- a/src/node_credentials.cc +++ b/src/node_credentials.cc @@ -15,7 +15,6 @@ namespace node { using v8::Array; using v8::Context; -using v8::Function; using v8::FunctionCallbackInfo; using v8::HandleScope; using v8::Isolate; @@ -45,12 +44,13 @@ bool SafeGetenv(const char* key, std::string* text, Environment* env) { if (env != nullptr) { HandleScope handle_scope(env->isolate()); TryCatch ignore_errors(env->isolate()); - MaybeLocal value = env->env_vars()->Get( + MaybeLocal maybe_value = env->env_vars()->Get( env->isolate(), String::NewFromUtf8(env->isolate(), key, NewStringType::kNormal) .ToLocalChecked()); - if (value.IsEmpty()) goto fail; - String::Utf8Value utf8_value(env->isolate(), value.ToLocalChecked()); + Local value; + if (!maybe_value.ToLocal(&value)) goto fail; + String::Utf8Value utf8_value(env->isolate(), value); if (*utf8_value == nullptr) goto fail; *text = std::string(*utf8_value, utf8_value.length()); return true; diff --git a/src/node_crypto.cc b/src/node_crypto.cc index f08d68d6b6e630..c132e6a089b3cb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -988,6 +988,24 @@ static X509_STORE* NewRootCertStore() { } +void GetRootCertificates(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); + Local result[arraysize(root_certs)]; + + for (size_t i = 0; i < arraysize(root_certs); i++) { + if (!String::NewFromOneByte( + env->isolate(), + reinterpret_cast(root_certs[i]), + NewStringType::kNormal).ToLocal(&result[i])) { + return; + } + } + + args.GetReturnValue().Set( + Array::New(env->isolate(), result, arraysize(root_certs))); +} + + void SecureContext::AddCACert(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); @@ -2664,21 +2682,6 @@ static inline Local BIOToStringOrBuffer(Environment* env, } } -static MaybeLocal X509ToPEM(Environment* env, X509* cert) { - BIOPointer bio(BIO_new(BIO_s_mem())); - if (!bio) { - ThrowCryptoError(env, ERR_get_error(), "BIO_new"); - return MaybeLocal(); - } - - if (PEM_write_bio_X509(bio.get(), cert) == 0) { - ThrowCryptoError(env, ERR_get_error(), "PEM_write_bio_X509"); - return MaybeLocal(); - } - - return BIOToStringOrBuffer(env, bio.get(), kKeyFormatPEM); -} - static bool WritePublicKeyInner(EVP_PKEY* pkey, const BIOPointer& bio, const PublicKeyEncodingConfig& config) { @@ -6676,36 +6679,6 @@ void ExportChallenge(const FunctionCallbackInfo& args) { } -void GetRootCertificates(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - - if (root_cert_store == nullptr) - root_cert_store = NewRootCertStore(); - - stack_st_X509_OBJECT* objs = X509_STORE_get0_objects(root_cert_store); - int num_objs = sk_X509_OBJECT_num(objs); - - std::vector> result; - result.reserve(num_objs); - - for (int i = 0; i < num_objs; i++) { - X509_OBJECT* obj = sk_X509_OBJECT_value(objs, i); - if (X509_OBJECT_get_type(obj) == X509_LU_X509) { - X509* cert = X509_OBJECT_get0_X509(obj); - - Local value; - if (!X509ToPEM(env, cert).ToLocal(&value)) - return; - - result.push_back(value); - } - } - - args.GetReturnValue().Set( - Array::New(env->isolate(), result.data(), result.size())); -} - - // Convert the input public key to compressed, uncompressed, or hybrid formats. void ConvertKey(const FunctionCallbackInfo& args) { MarkPopErrorOnReturn mark_pop_error_on_return; diff --git a/src/node_dir.cc b/src/node_dir.cc index 92d6bc96e48ad5..97f0537c5509dc 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -28,7 +28,6 @@ using fs::GetReqWrap; using v8::Array; using v8::Context; -using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::HandleScope; diff --git a/src/node_domain.cc b/src/node_domain.cc deleted file mode 100644 index 9075845442fd4d..00000000000000 --- a/src/node_domain.cc +++ /dev/null @@ -1,35 +0,0 @@ -#include "env-inl.h" -#include "v8.h" - -namespace node { -namespace domain { - -using v8::Context; -using v8::Function; -using v8::FunctionCallbackInfo; -using v8::Local; -using v8::Object; -using v8::Value; - - -void Enable(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - - CHECK(args[0]->IsFunction()); - - env->set_domain_callback(args[0].As()); -} - -void Initialize(Local target, - Local unused, - Local context, - void* priv) { - Environment* env = Environment::GetCurrent(context); - - env->SetMethod(target, "enable", Enable); -} - -} // namespace domain -} // namespace node - -NODE_MODULE_CONTEXT_AWARE_INTERNAL(domain, node::domain::Initialize) diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index fc58734c59ae15..3c407f3447f171 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -57,7 +57,6 @@ using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::Object; -using v8::String; using v8::Value; #define SLURP_STRING(obj, member, valp) \ diff --git a/src/node_errors.cc b/src/node_errors.cc index 4e13c24e15e1d0..6961e748c06ad9 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -25,7 +25,6 @@ using v8::Local; using v8::Maybe; using v8::MaybeLocal; using v8::Message; -using v8::Number; using v8::Object; using v8::ScriptOrigin; using v8::StackFrame; @@ -419,7 +418,7 @@ void OnFatalError(const char* location, const char* message) { if (report_on_fatalerror) { report::TriggerNodeReport( - isolate, env, message, "FatalError", "", Local()); + isolate, env, message, "FatalError", "", Local()); } fflush(stderr); diff --git a/src/node_file.cc b/src/node_file.cc index bc99eaa612d37d..f9e0dbf8f885d4 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -51,6 +51,7 @@ namespace node { namespace fs { using v8::Array; +using v8::Boolean; using v8::Context; using v8::EscapableHandleScope; using v8::Function; @@ -437,9 +438,9 @@ int FileHandle::ReadStart() { // Push the read wrap back to the freelist, or let it be destroyed // once we’re exiting the current scope. - constexpr size_t wanted_freelist_fill = 100; + constexpr size_t kWantedFreelistFill = 100; auto& freelist = handle->env()->file_handle_read_wrap_freelist(); - if (freelist.size() < wanted_freelist_fill) { + if (freelist.size() < kWantedFreelistFill) { read_wrap->Reset(); freelist.emplace_back(std::move(read_wrap)); } @@ -704,7 +705,7 @@ void AfterScanDir(uv_fs_t* req) { int r; std::vector> name_v; - for (int i = 0; ; i++) { + for (;;) { uv_dirent_t ent; r = uv_fs_scandir_next(req, &ent); @@ -745,7 +746,7 @@ void AfterScanDirWithTypes(uv_fs_t* req) { std::vector> name_v; std::vector> type_v; - for (int i = 0; ; i++) { + for (;;) { uv_dirent_t ent; r = uv_fs_scandir_next(req, &ent); @@ -826,9 +827,7 @@ void Close(const FunctionCallbackInfo& args) { } -// Used to speed up module loading. Returns the contents of the file as -// a string or undefined when the file cannot be opened or "main" is not found -// in the file. +// Used to speed up module loading. Returns an array [string, boolean] static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); @@ -837,14 +836,16 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { CHECK(args[0]->IsString()); node::Utf8Value path(isolate, args[0]); - if (strlen(*path) != path.length()) + if (strlen(*path) != path.length()) { + args.GetReturnValue().Set(Array::New(isolate)); return; // Contains a nul byte. - + } uv_fs_t open_req; const int fd = uv_fs_open(loop, &open_req, *path, O_RDONLY, 0, nullptr); uv_fs_req_cleanup(&open_req); if (fd < 0) { + args.GetReturnValue().Set(Array::New(isolate)); return; } @@ -870,9 +871,10 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { numchars = uv_fs_read(loop, &read_req, fd, &buf, 1, offset, nullptr); uv_fs_req_cleanup(&read_req); - if (numchars < 0) + if (numchars < 0) { + args.GetReturnValue().Set(Array::New(isolate)); return; - + } offset += numchars; } while (static_cast(numchars) == kBlockSize); @@ -908,18 +910,16 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { } } - Local return_value; - if (p < pe) { - return_value = - String::NewFromUtf8(isolate, - &chars[start], - v8::NewStringType::kNormal, - size).ToLocalChecked(); - } else { - return_value = env->empty_object_string(); - } - args.GetReturnValue().Set(return_value); + Local return_value[] = { + String::NewFromUtf8(isolate, + &chars[start], + v8::NewStringType::kNormal, + size).ToLocalChecked(), + Boolean::New(isolate, p < pe ? true : false) + }; + args.GetReturnValue().Set( + Array::New(isolate, return_value, arraysize(return_value))); } // Used to speed up module loading. Returns 0 if the path refers to @@ -1037,7 +1037,7 @@ static void Symlink(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); - int argc = args.Length(); + const int argc = args.Length(); CHECK_GE(argc, 4); BufferValue target(isolate, args[0]); @@ -1066,7 +1066,7 @@ static void Link(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); - int argc = args.Length(); + const int argc = args.Length(); CHECK_GE(argc, 3); BufferValue src(isolate, args[0]); @@ -1093,7 +1093,7 @@ static void ReadLink(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); - int argc = args.Length(); + const int argc = args.Length(); CHECK_GE(argc, 3); BufferValue path(isolate, args[0]); @@ -1136,7 +1136,7 @@ static void Rename(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); - int argc = args.Length(); + const int argc = args.Length(); CHECK_GE(argc, 3); BufferValue old_path(isolate, args[0]); diff --git a/src/node_http2.cc b/src/node_http2.cc index d7cefd880d8e62..b428436361e613 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -18,7 +18,6 @@ using v8::ArrayBuffer; using v8::ArrayBufferView; using v8::Boolean; using v8::Context; -using v8::Float64Array; using v8::Function; using v8::Integer; using v8::NewStringType; @@ -26,7 +25,6 @@ using v8::Number; using v8::ObjectTemplate; using v8::String; using v8::Uint32; -using v8::Uint32Array; using v8::Uint8Array; using v8::Undefined; diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 5dfb64113040c3..91bb30cb4e3ee6 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -20,7 +20,6 @@ using v8::HandleScope; using v8::Isolate; using v8::Local; using v8::Locker; -using v8::Object; using v8::SealHandleScope; NodeMainInstance::NodeMainInstance(Isolate* isolate, diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 16b1a97eec2dfc..f19e541bff08fb 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -15,7 +15,6 @@ using v8::ArrayBuffer; using v8::ArrayBufferCreationMode; using v8::Context; using v8::EscapableHandleScope; -using v8::Exception; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 1b916d645d8639..7362207412efa4 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -7,14 +7,11 @@ namespace native_module { using v8::Context; using v8::EscapableHandleScope; using v8::Function; -using v8::HandleScope; using v8::Integer; using v8::Isolate; using v8::Local; -using v8::Maybe; using v8::MaybeLocal; using v8::Object; -using v8::Script; using v8::ScriptCompiler; using v8::ScriptOrigin; using v8::String; @@ -255,10 +252,13 @@ MaybeLocal NativeModuleLoader::LookupAndCompile( Local column_offset = Integer::New(isolate, 0); ScriptOrigin origin(filename, line_offset, column_offset, True(isolate)); - Mutex::ScopedLock lock(code_cache_mutex_); - ScriptCompiler::CachedData* cached_data = nullptr; { + // Note: The lock here should not extend into the + // `CompileFunctionInContext()` call below, because this function may + // recurse if there is a syntax error during bootstrap (because the fatal + // exception handler is invoked, which may load built-in modules). + Mutex::ScopedLock lock(code_cache_mutex_); auto cache_it = code_cache_.find(id); if (cache_it != code_cache_.end()) { // Transfer ownership to ScriptCompiler::Source later. @@ -284,14 +284,14 @@ MaybeLocal NativeModuleLoader::LookupAndCompile( // This could fail when there are early errors in the native modules, // e.g. the syntax errors - if (maybe_fun.IsEmpty()) { + Local fun; + if (!maybe_fun.ToLocal(&fun)) { // In the case of early errors, v8 is already capable of // decorating the stack for us - note that we use CompileFunctionInContext // so there is no need to worry about wrappers. return MaybeLocal(); } - Local fun = maybe_fun.ToLocalChecked(); // XXX(joyeecheung): this bookkeeping is not exactly accurate because // it only starts after the Environment is created, so the per_context.js // will never be in any of these two sets, but the two sets are only for @@ -305,8 +305,13 @@ MaybeLocal NativeModuleLoader::LookupAndCompile( ScriptCompiler::CreateCodeCacheForFunction(fun)); CHECK_NOT_NULL(new_cached_data); - // The old entry should've been erased by now so we can just emplace - code_cache_.emplace(id, std::move(new_cached_data)); + { + Mutex::ScopedLock lock(code_cache_mutex_); + // The old entry should've been erased by now so we can just emplace. + // If another thread did the same thing in the meantime, that should not + // be an issue. + code_cache_.emplace(id, std::move(new_cached_data)); + } return scope.Escape(fun); } diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc index 31536000fc8d2f..9a6ccf99313cf8 100644 --- a/src/node_native_module_env.cc +++ b/src/node_native_module_env.cc @@ -11,7 +11,6 @@ using v8::FunctionCallbackInfo; using v8::IntegrityLevel; using v8::Isolate; using v8::Local; -using v8::Maybe; using v8::MaybeLocal; using v8::Name; using v8::None; @@ -128,8 +127,9 @@ void NativeModuleEnv::CompileFunction(const FunctionCallbackInfo& args) { NativeModuleLoader::GetInstance()->CompileAsModule( env->context(), id, &result); RecordResult(id, result, env); - if (!maybe.IsEmpty()) { - args.GetReturnValue().Set(maybe.ToLocalChecked()); + Local fn; + if (maybe.ToLocal(&fn)) { + args.GetReturnValue().Set(fn); } } diff --git a/src/node_options.cc b/src/node_options.cc index 8b3a161c2d2f83..047237a31e37b2 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -18,7 +18,6 @@ using v8::Local; using v8::Map; using v8::Number; using v8::Object; -using v8::String; using v8::Undefined; using v8::Value; @@ -834,7 +833,8 @@ std::string GetBashCompletion() { " return 0\n" " fi\n" "}\n" - "complete -F _node_complete node node_g"; + "complete -o filenames -o nospace -o bashdefault " + "-F _node_complete node node_g"; return out.str(); } diff --git a/src/node_os.cc b/src/node_os.cc index 6d52c2e44d0aec..b6fbb126b2f7bc 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -273,10 +273,10 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { Local options = args[0].As(); MaybeLocal maybe_encoding = options->Get(env->context(), env->encoding_string()); - if (maybe_encoding.IsEmpty()) - return; + Local encoding_opt; + if (!maybe_encoding.ToLocal(&encoding_opt)) + return; - Local encoding_opt = maybe_encoding.ToLocalChecked(); encoding = ParseEncoding(env->isolate(), encoding_opt, UTF8); } else { encoding = UTF8; diff --git a/src/node_perf.cc b/src/node_perf.cc index 4b8bf2a8a7c913..e5ce41c1b20731 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -11,7 +11,6 @@ namespace node { namespace performance { -using v8::Array; using v8::Context; using v8::DontDelete; using v8::Function; @@ -25,14 +24,12 @@ using v8::Isolate; using v8::Local; using v8::Map; using v8::MaybeLocal; -using v8::Name; using v8::NewStringType; using v8::Number; using v8::Object; using v8::PropertyAttribute; using v8::ReadOnly; using v8::String; -using v8::Uint32Array; using v8::Value; // Microseconds in a millisecond, as a float. diff --git a/src/node_platform.cc b/src/node_platform.cc index 3f6786d6dda162..5b878f886a1320 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -66,13 +66,13 @@ class WorkerThreadsTaskRunner::DelayedTaskScheduler { } void PostDelayedTask(std::unique_ptr task, double delay_in_seconds) { - tasks_.Push(std::unique_ptr(new ScheduleTask(this, std::move(task), - delay_in_seconds))); + tasks_.Push(std::make_unique(this, std::move(task), + delay_in_seconds)); uv_async_send(&flush_tasks_); } void Stop() { - tasks_.Push(std::unique_ptr(new StopTask(this))); + tasks_.Push(std::make_unique(this)); uv_async_send(&flush_tasks_); } diff --git a/src/node_process_events.cc b/src/node_process_events.cc index d192ef19b7abad..ae387de447753e 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -24,10 +24,16 @@ MaybeLocal ProcessEmit(Environment* env, const char* event, Local message) { // Send message to enable debug in cluster workers - Local process = env->process_object(); Isolate* isolate = env->isolate(); - Local argv[] = {OneByteString(isolate, event), message}; + Local event_string; + if (!String::NewFromOneByte(isolate, + reinterpret_cast(event), + NewStringType::kNormal) + .ToLocal(&event_string)) return MaybeLocal(); + + Local process = env->process_object(); + Local argv[] = {event_string, message}; return MakeCallback(isolate, process, "emit", arraysize(argv), argv, {0, 0}); } diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 15e2e1b39b67c4..82be06aa7869ca 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -36,13 +36,11 @@ using v8::ArrayBuffer; using v8::BigUint64Array; using v8::Context; using v8::Float64Array; -using v8::Function; using v8::FunctionCallbackInfo; using v8::HeapStatistics; using v8::Integer; using v8::Isolate; using v8::Local; -using v8::Name; using v8::NewStringType; using v8::Number; using v8::Object; diff --git a/src/node_process_object.cc b/src/node_process_object.cc index ddbb58abe535b0..941840389161d3 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -15,10 +15,8 @@ using v8::EscapableHandleScope; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; -using v8::HandleScope; using v8::Integer; using v8::Isolate; -using v8::Just; using v8::Local; using v8::MaybeLocal; using v8::Name; diff --git a/src/node_report.cc b/src/node_report.cc index 98da24c9567a28..c93e03afe63918 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -37,15 +37,19 @@ using node::Mutex; using node::NativeSymbolDebuggingContext; using node::TIME_TYPE; using node::worker::Worker; +using v8::Array; +using v8::Context; using v8::HeapSpaceStatistics; using v8::HeapStatistics; using v8::Isolate; using v8::Local; using v8::Number; +using v8::Object; using v8::StackTrace; using v8::String; -using v8::V8; +using v8::TryCatch; using v8::Value; +using v8::V8; namespace per_process = node::per_process; @@ -56,13 +60,16 @@ static void WriteNodeReport(Isolate* isolate, const char* trigger, const std::string& filename, std::ostream& out, - Local stackstr, + Local error, bool compact); static void PrintVersionInformation(JSONWriter* writer); -static void PrintJavaScriptStack(JSONWriter* writer, - Isolate* isolate, - Local stackstr, - const char* trigger); +static void PrintJavaScriptErrorStack(JSONWriter* writer, + Isolate* isolate, + Local error, + const char* trigger); +static void PrintJavaScriptErrorProperties(JSONWriter* writer, + Isolate* isolate, + Local error); static void PrintNativeStack(JSONWriter* writer); static void PrintResourceUsage(JSONWriter* writer); static void PrintGCStatistics(JSONWriter* writer, Isolate* isolate); @@ -79,7 +86,7 @@ std::string TriggerNodeReport(Isolate* isolate, const char* message, const char* trigger, const std::string& name, - Local stackstr) { + Local error) { std::string filename; // Determine the required report filename. In order of priority: @@ -145,7 +152,7 @@ std::string TriggerNodeReport(Isolate* isolate, compact = per_process::cli_options->report_compact; } WriteNodeReport(isolate, env, message, trigger, filename, *outstream, - stackstr, compact); + error, compact); // Do not close stdout/stderr, only close files we opened. if (outfile.is_open()) { @@ -164,9 +171,9 @@ void GetNodeReport(Isolate* isolate, Environment* env, const char* message, const char* trigger, - Local stackstr, + Local error, std::ostream& out) { - WriteNodeReport(isolate, env, message, trigger, "", out, stackstr, false); + WriteNodeReport(isolate, env, message, trigger, "", out, error, false); } // Internal function to coordinate and write the various @@ -177,7 +184,7 @@ static void WriteNodeReport(Isolate* isolate, const char* trigger, const std::string& filename, std::ostream& out, - Local stackstr, + Local error, bool compact) { // Obtain the current time and the pid. TIME_TYPE tm_struct; @@ -262,8 +269,13 @@ static void WriteNodeReport(Isolate* isolate, PrintVersionInformation(&writer); writer.json_objectend(); - // Report summary JavaScript stack backtrace - PrintJavaScriptStack(&writer, isolate, stackstr, trigger); + writer.json_objectstart("javascriptStack"); + // Report summary JavaScript error stack backtrace + PrintJavaScriptErrorStack(&writer, isolate, error, trigger); + + // Report summary JavaScript error properties backtrace + PrintJavaScriptErrorProperties(&writer, isolate, error); + writer.json_objectend(); // the end of 'javascriptStack' // Report native stack backtrace PrintNativeStack(&writer); @@ -304,7 +316,7 @@ static void WriteNodeReport(Isolate* isolate, env, "Worker thread subreport", trigger, - Local(), + Local(), os); Mutex::ScopedLock lock(workers_mutex); @@ -458,18 +470,56 @@ static void PrintNetworkInterfaceInfo(JSONWriter* writer) { } } +static void PrintJavaScriptErrorProperties(JSONWriter* writer, + Isolate* isolate, + Local error) { + writer->json_objectstart("errorProperties"); + if (!error.IsEmpty()) { + TryCatch try_catch(isolate); + Local context = error->GetIsolate()->GetCurrentContext(); + Local keys; + if (!error->GetOwnPropertyNames(context).ToLocal(&keys)) { + return writer->json_objectend(); // the end of 'errorProperties' + } + uint32_t keys_length = keys->Length(); + for (uint32_t i = 0; i < keys_length; i++) { + Local key; + if (!keys->Get(context, i).ToLocal(&key) || !key->IsString()) { + continue; + } + Local value; + Local value_string; + if (!error->Get(context, key).ToLocal(&value) || + !value->ToString(context).ToLocal(&value_string)) { + continue; + } + String::Utf8Value k(isolate, key); + if (!strcmp(*k, "stack") || !strcmp(*k, "message")) continue; + String::Utf8Value v(isolate, value_string); + writer->json_keyvalue(std::string(*k, k.length()), + std::string(*v, v.length())); + } + } + writer->json_objectend(); // the end of 'errorProperties' +} + // Report the JavaScript stack. -static void PrintJavaScriptStack(JSONWriter* writer, +static void PrintJavaScriptErrorStack(JSONWriter* writer, Isolate* isolate, - Local stackstr, + Local error, const char* trigger) { - writer->json_objectstart("javascriptStack"); - - std::string ss; + Local stackstr; + std::string ss = ""; + TryCatch try_catch(isolate); if ((!strcmp(trigger, "FatalError")) || (!strcmp(trigger, "Signal"))) { ss = "No stack.\nUnavailable.\n"; - } else { + } else if (!error.IsEmpty() && + error + ->Get(isolate->GetCurrentContext(), + node::FIXED_ONE_BYTE_STRING(isolate, + "stack")) + .ToLocal(&stackstr)) { String::Utf8Value sv(isolate, stackstr); ss = std::string(*sv, sv.length()); } @@ -493,7 +543,6 @@ static void PrintJavaScriptStack(JSONWriter* writer, } writer->json_arrayend(); } - writer->json_objectend(); } // Report a native stack backtrace diff --git a/src/node_report.h b/src/node_report.h index 98490784dd6e70..f4992f220221ed 100644 --- a/src/node_report.h +++ b/src/node_report.h @@ -20,12 +20,12 @@ std::string TriggerNodeReport(v8::Isolate* isolate, const char* message, const char* trigger, const std::string& name, - v8::Local stackstr); + v8::Local error); void GetNodeReport(v8::Isolate* isolate, node::Environment* env, const char* message, const char* trigger, - v8::Local stackstr, + v8::Local error, std::ostream& out); // Function declarations - utility functions in src/node_report_utils.cc diff --git a/src/node_report_module.cc b/src/node_report_module.cc index 700dd88aba645e..d9dad28221a5cf 100644 --- a/src/node_report_module.cc +++ b/src/node_report_module.cc @@ -18,9 +18,7 @@ namespace report { using node::Environment; using node::Mutex; using node::Utf8Value; -using v8::Boolean; using v8::Context; -using v8::Function; using v8::FunctionCallbackInfo; using v8::HandleScope; using v8::Isolate; @@ -34,18 +32,21 @@ void WriteReport(const FunctionCallbackInfo& info) { Isolate* isolate = env->isolate(); HandleScope scope(isolate); std::string filename; - Local stackstr; + Local error; CHECK_EQ(info.Length(), 4); String::Utf8Value message(isolate, info[0].As()); String::Utf8Value trigger(isolate, info[1].As()); - stackstr = info[3].As(); if (info[2]->IsString()) filename = *String::Utf8Value(isolate, info[2]); + if (!info[3].IsEmpty() && info[3]->IsObject()) + error = info[3].As(); + else + error = Local(); filename = TriggerNodeReport( - isolate, env, *message, *trigger, filename, stackstr); + isolate, env, *message, *trigger, filename, error); // Return value is the report filename info.GetReturnValue().Set( String::NewFromUtf8(isolate, filename.c_str(), v8::NewStringType::kNormal) @@ -57,10 +58,17 @@ void GetReport(const FunctionCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); Isolate* isolate = env->isolate(); HandleScope scope(isolate); + Local error; std::ostringstream out; + CHECK_EQ(info.Length(), 1); + if (!info[0].IsEmpty() && info[0]->IsObject()) + error = info[0].As(); + else + error = Local(); + GetNodeReport( - isolate, env, "JavaScript API", __func__, info[0].As(), out); + isolate, env, "JavaScript API", __func__, error, out); // Return value is the contents of a report as a string. info.GetReturnValue().Set(String::NewFromUtf8(isolate, diff --git a/src/node_url.cc b/src/node_url.cc index 27e89e8d9b7652..029a04a429b7a5 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -1487,7 +1487,7 @@ void URL::Parse(const char* input, state = kSpecialRelativeOrAuthority; } else if (special) { state = kSpecialAuthoritySlashes; - } else if (p[1] == '/') { + } else if (p + 1 < end && p[1] == '/') { state = kPathOrAuthority; p++; } else { @@ -1547,7 +1547,7 @@ void URL::Parse(const char* input, } break; case kSpecialRelativeOrAuthority: - if (ch == '/' && p[1] == '/') { + if (ch == '/' && p + 1 < end && p[1] == '/') { state = kSpecialAuthorityIgnoreSlashes; p++; } else { @@ -1695,7 +1695,7 @@ void URL::Parse(const char* input, break; case kSpecialAuthoritySlashes: state = kSpecialAuthorityIgnoreSlashes; - if (ch == '/' && p[1] == '/') { + if (ch == '/' && p + 1 < end && p[1] == '/') { p++; } else { continue; diff --git a/src/node_util.cc b/src/node_util.cc index db9b8ec8d65f51..eb956daac6c782 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -10,7 +10,6 @@ using v8::Array; using v8::ArrayBufferView; using v8::Boolean; using v8::Context; -using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Global; @@ -149,11 +148,11 @@ static void GetHiddenValue(const FunctionCallbackInfo& args) { CHECK(args[1]->IsUint32()); Local obj = args[0].As(); - auto index = args[1]->Uint32Value(env->context()).FromJust(); - auto private_symbol = IndexToPrivateSymbol(env, index); - auto maybe_value = obj->GetPrivate(env->context(), private_symbol); - - args.GetReturnValue().Set(maybe_value.ToLocalChecked()); + uint32_t index = args[1].As()->Value(); + Local private_symbol = IndexToPrivateSymbol(env, index); + Local ret; + if (obj->GetPrivate(env->context(), private_symbol).ToLocal(&ret)) + args.GetReturnValue().Set(ret); } static void SetHiddenValue(const FunctionCallbackInfo& args) { @@ -163,11 +162,11 @@ static void SetHiddenValue(const FunctionCallbackInfo& args) { CHECK(args[1]->IsUint32()); Local obj = args[0].As(); - auto index = args[1]->Uint32Value(env->context()).FromJust(); - auto private_symbol = IndexToPrivateSymbol(env, index); - auto maybe_value = obj->SetPrivate(env->context(), private_symbol, args[2]); - - args.GetReturnValue().Set(maybe_value.FromJust()); + uint32_t index = args[1].As()->Value(); + Local private_symbol = IndexToPrivateSymbol(env, index); + bool ret; + if (obj->SetPrivate(env->context(), private_symbol, args[2]).To(&ret)) + args.GetReturnValue().Set(ret); } static void Sleep(const FunctionCallbackInfo& args) { diff --git a/src/node_version.h b/src/node_version.h index 705343a2a2fa7b..9252d51555f0e1 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -29,7 +29,7 @@ #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Erbium" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) diff --git a/src/node_wasi.cc b/src/node_wasi.cc index 0e23243918b31f..c9e9ddd67ec51a 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -162,10 +162,11 @@ void WASI::DecreaseAllocatedSize(size_t size) { void WASI::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - CHECK_EQ(args.Length(), 3); + CHECK_EQ(args.Length(), 4); CHECK(args[0]->IsArray()); CHECK(args[1]->IsArray()); CHECK(args[2]->IsArray()); + CHECK(args[3]->IsArray()); Environment* env = Environment::GetCurrent(args); Local context = env->context(); @@ -173,9 +174,15 @@ void WASI::New(const FunctionCallbackInfo& args) { const uint32_t argc = argv->Length(); uvwasi_options_t options; - options.in = 0; - options.out = 1; - options.err = 2; + Local stdio = args[3].As(); + CHECK_EQ(stdio->Length(), 3); + options.in = stdio->Get(context, 0).ToLocalChecked()-> + Int32Value(context).FromJust(); + options.out = stdio->Get(context, 1).ToLocalChecked()-> + Int32Value(context).FromJust(); + options.err = stdio->Get(context, 2).ToLocalChecked()-> + Int32Value(context).FromJust(); + options.fd_table_size = 3; options.argc = argc; options.argv = @@ -660,27 +667,24 @@ void WASI::FdPread(const FunctionCallbackInfo& args) { iovs_ptr, iovs_len * UVWASI_SERDES_SIZE_iovec_t); CHECK_BOUNDS_OR_RETURN(args, mem_size, nread_ptr, UVWASI_SERDES_SIZE_size_t); - uvwasi_iovec_t* iovs = UncheckedCalloc(iovs_len); + std::vector iovs(iovs_len); uvwasi_errno_t err; - if (iovs == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - - err = uvwasi_serdes_readv_iovec_t(memory, mem_size, iovs_ptr, iovs, iovs_len); + err = uvwasi_serdes_readv_iovec_t(memory, + mem_size, + iovs_ptr, + iovs.data(), + iovs_len); if (err != UVWASI_ESUCCESS) { - free(iovs); args.GetReturnValue().Set(err); return; } uvwasi_size_t nread; - err = uvwasi_fd_pread(&wasi->uvw_, fd, iovs, iovs_len, offset, &nread); + err = uvwasi_fd_pread(&wasi->uvw_, fd, iovs.data(), iovs_len, offset, &nread); if (err == UVWASI_ESUCCESS) uvwasi_serdes_write_size_t(memory, nread_ptr, nread); - free(iovs); args.GetReturnValue().Set(err); } @@ -763,31 +767,29 @@ void WASI::FdPwrite(const FunctionCallbackInfo& args) { mem_size, nwritten_ptr, UVWASI_SERDES_SIZE_size_t); - uvwasi_ciovec_t* iovs = UncheckedCalloc(iovs_len); + std::vector iovs(iovs_len); uvwasi_errno_t err; - if (iovs == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - err = uvwasi_serdes_readv_ciovec_t(memory, mem_size, iovs_ptr, - iovs, + iovs.data(), iovs_len); if (err != UVWASI_ESUCCESS) { - free(iovs); args.GetReturnValue().Set(err); return; } uvwasi_size_t nwritten; - err = uvwasi_fd_pwrite(&wasi->uvw_, fd, iovs, iovs_len, offset, &nwritten); + err = uvwasi_fd_pwrite(&wasi->uvw_, + fd, + iovs.data(), + iovs_len, + offset, + &nwritten); if (err == UVWASI_ESUCCESS) uvwasi_serdes_write_size_t(memory, nwritten_ptr, nwritten); - free(iovs); args.GetReturnValue().Set(err); } @@ -813,27 +815,24 @@ void WASI::FdRead(const FunctionCallbackInfo& args) { iovs_ptr, iovs_len * UVWASI_SERDES_SIZE_iovec_t); CHECK_BOUNDS_OR_RETURN(args, mem_size, nread_ptr, UVWASI_SERDES_SIZE_size_t); - uvwasi_iovec_t* iovs = UncheckedCalloc(iovs_len); + std::vector iovs(iovs_len); uvwasi_errno_t err; - if (iovs == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - - err = uvwasi_serdes_readv_iovec_t(memory, mem_size, iovs_ptr, iovs, iovs_len); + err = uvwasi_serdes_readv_iovec_t(memory, + mem_size, + iovs_ptr, + iovs.data(), + iovs_len); if (err != UVWASI_ESUCCESS) { - free(iovs); args.GetReturnValue().Set(err); return; } uvwasi_size_t nread; - err = uvwasi_fd_read(&wasi->uvw_, fd, iovs, iovs_len, &nread); + err = uvwasi_fd_read(&wasi->uvw_, fd, iovs.data(), iovs_len, &nread); if (err == UVWASI_ESUCCESS) uvwasi_serdes_write_size_t(memory, nread_ptr, nread); - free(iovs); args.GetReturnValue().Set(err); } @@ -995,31 +994,24 @@ void WASI::FdWrite(const FunctionCallbackInfo& args) { mem_size, nwritten_ptr, UVWASI_SERDES_SIZE_size_t); - uvwasi_ciovec_t* iovs = UncheckedCalloc(iovs_len); + std::vector iovs(iovs_len); uvwasi_errno_t err; - if (iovs == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - err = uvwasi_serdes_readv_ciovec_t(memory, mem_size, iovs_ptr, - iovs, + iovs.data(), iovs_len); if (err != UVWASI_ESUCCESS) { - free(iovs); args.GetReturnValue().Set(err); return; } uvwasi_size_t nwritten; - err = uvwasi_fd_write(&wasi->uvw_, fd, iovs, iovs_len, &nwritten); + err = uvwasi_fd_write(&wasi->uvw_, fd, iovs.data(), iovs_len, &nwritten); if (err == UVWASI_ESUCCESS) uvwasi_serdes_write_size_t(memory, nwritten_ptr, nwritten); - free(iovs); args.GetReturnValue().Set(err); } @@ -1434,21 +1426,8 @@ void WASI::PollOneoff(const FunctionCallbackInfo& args) { mem_size, nevents_ptr, UVWASI_SERDES_SIZE_size_t); - uvwasi_subscription_t* in = - UncheckedCalloc(nsubscriptions); - - if (in == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - - uvwasi_event_t* out = UncheckedCalloc(nsubscriptions); - - if (out == nullptr) { - free(in); - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } + std::vector in(nsubscriptions); + std::vector out(nsubscriptions); for (uint32_t i = 0; i < nsubscriptions; ++i) { uvwasi_serdes_read_subscription_t(memory, in_ptr, &in[i]); @@ -1457,8 +1436,8 @@ void WASI::PollOneoff(const FunctionCallbackInfo& args) { uvwasi_size_t nevents; uvwasi_errno_t err = uvwasi_poll_oneoff(&wasi->uvw_, - in, - out, + in.data(), + out.data(), nsubscriptions, &nevents); if (err == UVWASI_ESUCCESS) { @@ -1470,8 +1449,6 @@ void WASI::PollOneoff(const FunctionCallbackInfo& args) { } } - free(in); - free(out); args.GetReturnValue().Set(err); } @@ -1562,20 +1539,13 @@ void WASI::SockRecv(const FunctionCallbackInfo& args) { ri_data_len * UVWASI_SERDES_SIZE_iovec_t); CHECK_BOUNDS_OR_RETURN(args, mem_size, ro_datalen_ptr, 4); CHECK_BOUNDS_OR_RETURN(args, mem_size, ro_flags_ptr, 4); - uvwasi_iovec_t* ri_data = UncheckedCalloc(ri_data_len); - - if (ri_data == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - + std::vector ri_data(ri_data_len); uvwasi_errno_t err = uvwasi_serdes_readv_iovec_t(memory, mem_size, ri_data_ptr, - ri_data, + ri_data.data(), ri_data_len); if (err != UVWASI_ESUCCESS) { - free(ri_data); args.GetReturnValue().Set(err); return; } @@ -1584,7 +1554,7 @@ void WASI::SockRecv(const FunctionCallbackInfo& args) { uvwasi_roflags_t ro_flags; err = uvwasi_sock_recv(&wasi->uvw_, sock, - ri_data, + ri_data.data(), ri_data_len, ri_flags, &ro_datalen, @@ -1594,7 +1564,6 @@ void WASI::SockRecv(const FunctionCallbackInfo& args) { uvwasi_serdes_write_roflags_t(memory, ro_flags_ptr, ro_flags); } - free(ri_data); args.GetReturnValue().Set(err); } @@ -1631,20 +1600,13 @@ void WASI::SockSend(const FunctionCallbackInfo& args) { mem_size, so_datalen_ptr, UVWASI_SERDES_SIZE_size_t); - uvwasi_ciovec_t* si_data = UncheckedCalloc(si_data_len); - - if (si_data == nullptr) { - args.GetReturnValue().Set(UVWASI_ENOMEM); - return; - } - + std::vector si_data(si_data_len); uvwasi_errno_t err = uvwasi_serdes_readv_ciovec_t(memory, mem_size, si_data_ptr, - si_data, + si_data.data(), si_data_len); if (err != UVWASI_ESUCCESS) { - free(si_data); args.GetReturnValue().Set(err); return; } @@ -1652,14 +1614,13 @@ void WASI::SockSend(const FunctionCallbackInfo& args) { uvwasi_size_t so_datalen; err = uvwasi_sock_send(&wasi->uvw_, sock, - si_data, + si_data.data(), si_data_len, si_flags, &so_datalen); if (err == UVWASI_ESUCCESS) uvwasi_serdes_write_size_t(memory, so_datalen_ptr, so_datalen); - free(si_data); args.GetReturnValue().Set(err); } diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index 107a25bc977bd3..3ed39067896289 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -432,4 +432,4 @@ static void Initialize(Local target, } // namespace node -NODE_MODULE_CONTEXT_AWARE_INTERNAL(watchdog, node::watchdog::Initialize); +NODE_MODULE_CONTEXT_AWARE_INTERNAL(watchdog, node::watchdog::Initialize) diff --git a/src/node_worker.cc b/src/node_worker.cc index 7f4aec6a0bebc8..367541bea6aa0f 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -513,9 +513,9 @@ void Worker::New(const FunctionCallbackInfo& args) { #ifndef NODE_WITHOUT_NODE_OPTIONS MaybeLocal maybe_node_opts = env_vars->Get(isolate, OneByteString(isolate, "NODE_OPTIONS")); - if (!maybe_node_opts.IsEmpty()) { - std::string node_options( - *String::Utf8Value(isolate, maybe_node_opts.ToLocalChecked())); + Local node_opts; + if (maybe_node_opts.ToLocal(&node_opts)) { + std::string node_options(*String::Utf8Value(isolate, node_opts)); std::vector errors{}; std::vector env_argv = ParseNodeOptionsEnvVar(node_options, &errors); @@ -555,14 +555,11 @@ void Worker::New(const FunctionCallbackInfo& args) { if (!array->Get(env->context(), i).ToLocal(&arg)) { return; } - MaybeLocal arg_v8_string = - arg->ToString(env->context()); - if (arg_v8_string.IsEmpty()) { + Local arg_v8; + if (!arg->ToString(env->context()).ToLocal(&arg_v8)) { return; } - Utf8Value arg_utf8_value( - args.GetIsolate(), - arg_v8_string.FromMaybe(Local())); + Utf8Value arg_utf8_value(args.GetIsolate(), arg_v8); std::string arg_string(arg_utf8_value.out(), arg_utf8_value.length()); exec_argv.push_back(arg_string); } diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 9ac792d90cc673..ee83134407e7e8 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -43,7 +43,6 @@ namespace node { -using v8::Array; using v8::ArrayBuffer; using v8::Context; using v8::Function; @@ -56,7 +55,6 @@ using v8::Integer; using v8::Local; using v8::Object; using v8::String; -using v8::Uint32; using v8::Uint32Array; using v8::Value; diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index c4a5b7cd62e1b4..9e6831b2ed3b04 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -39,7 +39,6 @@ using v8::EscapableHandleScope; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; -using v8::HandleScope; using v8::Int32; using v8::Isolate; using v8::Local; diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 17b4d6247f0a3d..ebf57c6be8d64c 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -31,7 +31,6 @@ #include // memcpy #include -#include // When creating strings >= this length v8's gc spins up and consumes // most of the execution time. For these cases it's more performant to @@ -653,11 +652,11 @@ MaybeLocal StringBytes::Encode(Isolate* isolate, return MaybeLocal(); } auto maybe_buf = Buffer::Copy(isolate, buf, buflen); - if (maybe_buf.IsEmpty()) { + Local buf; + if (!maybe_buf.ToLocal(&buf)) { *error = node::ERR_MEMORY_ALLOCATION_FAILED(isolate); - return MaybeLocal(); } - return maybe_buf.ToLocalChecked(); + return buf; } case ASCII: @@ -674,15 +673,17 @@ MaybeLocal StringBytes::Encode(Isolate* isolate, } case UTF8: - val = String::NewFromUtf8(isolate, - buf, - v8::NewStringType::kNormal, - buflen); - if (val.IsEmpty()) { - *error = node::ERR_STRING_TOO_LONG(isolate); - return MaybeLocal(); + { + val = String::NewFromUtf8(isolate, + buf, + v8::NewStringType::kNormal, + buflen); + Local str; + if (!val.ToLocal(&str)) { + *error = node::ERR_STRING_TOO_LONG(isolate); + } + return str; } - return val.ToLocalChecked(); case LATIN1: return ExternOneByteString::NewFromCopy(isolate, buf, buflen, error); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 619c9ef6196373..ef1b80939e91f9 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -42,7 +42,6 @@ using v8::EscapableHandleScope; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; -using v8::HandleScope; using v8::Int32; using v8::Integer; using v8::Local; diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 39dcf532a9fb7a..bb09ee99e07017 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -46,7 +46,6 @@ using v8::FunctionTemplate; using v8::Integer; using v8::Isolate; using v8::Local; -using v8::Maybe; using v8::MaybeLocal; using v8::Object; using v8::ReadOnly; diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h index 27408eafd832ae..c11544dd42cdd0 100644 --- a/src/tracing/trace_event.h +++ b/src/tracing/trace_event.h @@ -70,8 +70,7 @@ enum CategoryGroupEnabledFlags { // const uint8_t* // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group) #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ - node::tracing::TraceEventHelper::GetTracingController() \ - ->GetCategoryGroupEnabled + node::tracing::TraceEventHelper::GetCategoryGroupEnabled // Get the number of times traces have been recorded. This is used to implement // the TRACE_EVENT_IS_NEW_TRACE facility. @@ -115,9 +114,10 @@ enum CategoryGroupEnabledFlags { // const uint8_t* category_group_enabled, // const char* name, // uint64_t id) -#define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ - node::tracing::TraceEventHelper::GetTracingController() \ - ->UpdateTraceEventDuration +#define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ + if (auto controller = \ + node::tracing::TraceEventHelper::GetTracingController()) \ + controller->UpdateTraceEventDuration // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method // on the convertable value will be called at flush time. @@ -317,6 +317,13 @@ class NODE_EXTERN TraceEventHelper { static TracingController* GetTracingController(); static Agent* GetAgent(); static void SetAgent(Agent* agent); + + static inline const uint8_t* GetCategoryGroupEnabled(const char* group) { + v8::TracingController* controller = GetTracingController(); + static const uint8_t disabled = 0; + if (UNLIKELY(controller == nullptr)) return &disabled; + return controller->GetCategoryGroupEnabled(group); + } }; // TraceID encapsulates an ID that can either be an integer or pointer. Pointers @@ -465,6 +472,7 @@ static inline uint64_t AddTraceEventImpl( // DCHECK(num_args, 2); v8::TracingController* controller = node::tracing::TraceEventHelper::GetTracingController(); + if (controller == nullptr) return 0; return controller->AddTraceEvent(phase, category_group_enabled, name, scope, id, bind_id, num_args, arg_names, arg_types, arg_values, arg_convertibles, flags); @@ -487,6 +495,7 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl( // DCHECK_LE(num_args, 2); v8::TracingController* controller = node::tracing::TraceEventHelper::GetTracingController(); + if (controller == nullptr) return 0; return controller->AddTraceEventWithTimestamp( phase, category_group_enabled, name, scope, id, bind_id, num_args, arg_names, arg_types, arg_values, arg_convertables, flags, timestamp); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index 8536fae3ed7383..401c2513dbc628 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -32,7 +32,6 @@ namespace node { using v8::Array; using v8::Context; -using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Integer; diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 770782ee9cf38e..82406d0eaf19bc 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -228,12 +228,12 @@ int sockaddr_for_family(int address_family, const unsigned short port, struct sockaddr_storage* addr) { switch (address_family) { - case AF_INET: - return uv_ip4_addr(address, port, reinterpret_cast(addr)); - case AF_INET6: - return uv_ip6_addr(address, port, reinterpret_cast(addr)); - default: - CHECK(0 && "unexpected address family"); + case AF_INET: + return uv_ip4_addr(address, port, reinterpret_cast(addr)); + case AF_INET6: + return uv_ip6_addr(address, port, reinterpret_cast(addr)); + default: + CHECK(0 && "unexpected address family"); } } diff --git a/src/util.h b/src/util.h index 5efd92eb6e239c..eb214a880feba5 100644 --- a/src/util.h +++ b/src/util.h @@ -33,9 +33,7 @@ #pragma GCC diagnostic pop #endif -#include -#include // PATH_MAX -#include +#include #include #include #include @@ -323,6 +321,11 @@ inline bool StringEqualNoCase(const char* a, const char* b); // strncasecmp() is locale-sensitive. Use StringEqualNoCaseN() instead. inline bool StringEqualNoCaseN(const char* a, const char* b, size_t length); +template +constexpr size_t arraysize(const T (&)[N]) { + return N; +} + // Allocates an array of member type T. For up to kStackStorageSize items, // the stack is used, otherwise malloc(). template @@ -362,8 +365,7 @@ class MaybeStackBuffer { // Current maximum capacity of the buffer with which SetLength() can be used // without first calling AllocateSufficientStorage(). size_t capacity() const { - return IsAllocated() ? capacity_ : - IsInvalidated() ? 0 : kStackStorageSize; + return capacity_; } // Make sure enough space for `storage` entries is available. @@ -405,6 +407,7 @@ class MaybeStackBuffer { // be used. void Invalidate() { CHECK(!IsAllocated()); + capacity_ = 0; length_ = 0; buf_ = nullptr; } @@ -425,10 +428,11 @@ class MaybeStackBuffer { CHECK(IsAllocated()); buf_ = buf_st_; length_ = 0; - capacity_ = 0; + capacity_ = arraysize(buf_st_); } - MaybeStackBuffer() : length_(0), capacity_(0), buf_(buf_st_) { + MaybeStackBuffer() + : length_(0), capacity_(arraysize(buf_st_)), buf_(buf_st_) { // Default to a zero-length, null-terminated buffer. buf_[0] = T(); } @@ -703,11 +707,6 @@ inline bool IsBigEndian() { return GetEndianness() == kBigEndian; } -template -constexpr size_t arraysize(const T (&)[N]) { - return N; -} - // Round up a to the next highest multiple of b. template constexpr T RoundUp(T a, T b) { diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js index 2ca7050d8ab4ea..78e73e0dc8557b 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js @@ -38,9 +38,8 @@ assert.throws(() => { name: 'Error' })(e); return true; - } else { - return true; } + return true; }); assert.throws(() => { diff --git a/test/async-hooks/init-hooks.js b/test/async-hooks/init-hooks.js index b10ec827198f6d..59ecc96b881a5a 100644 --- a/test/async-hooks/init-hooks.js +++ b/test/async-hooks/init-hooks.js @@ -165,14 +165,13 @@ class ActivityCollector { // Worker threads start main script execution inside of an AsyncWrap // callback, so we don't yield errors for these. return null; - } else { - const err = new Error(`Found a handle whose ${hook}` + - ' hook was invoked but not its init hook'); - // Don't throw if we see invocations due to an assertion in a test - // failing since we want to list the assertion failure instead - if (/process\._fatalException/.test(err.stack)) return null; - throw err; } + const err = new Error(`Found a handle whose ${hook}` + + ' hook was invoked but not its init hook'); + // Don't throw if we see invocations due to an assertion in a test + // failing since we want to list the assertion failure instead + if (/process\._fatalException/.test(err.stack)) return null; + throw err; } return h; } diff --git a/test/cctest/test_url.cc b/test/cctest/test_url.cc index 96f9741386360f..2e78b24a5e3424 100644 --- a/test/cctest/test_url.cc +++ b/test/cctest/test_url.cc @@ -81,6 +81,26 @@ TEST_F(URLTest, Base3) { EXPECT_EQ(simple.path(), "/baz"); } +TEST_F(URLTest, TruncatedAfterProtocol) { + char input[2] = { 'q', ':' }; + URL simple(input, sizeof(input)); + + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); + EXPECT_EQ(simple.protocol(), "q:"); + EXPECT_EQ(simple.host(), ""); + EXPECT_EQ(simple.path(), "/"); +} + +TEST_F(URLTest, TruncatedAfterProtocol2) { + char input[6] = { 'h', 't', 't', 'p', ':', '/' }; + URL simple(input, sizeof(input)); + + EXPECT_TRUE(simple.flags() & URL_FLAGS_FAILED); + EXPECT_EQ(simple.protocol(), "http:"); + EXPECT_EQ(simple.host(), ""); + EXPECT_EQ(simple.path(), ""); +} + TEST_F(URLTest, ToFilePath) { #define T(url, path) EXPECT_EQ(path, URL(url).ToFilePath()) T("http://example.org/foo/bar", ""); diff --git a/test/common/dns.js b/test/common/dns.js index 37f80dde02782c..d8a703cc53be86 100644 --- a/test/common/dns.js +++ b/test/common/dns.js @@ -36,16 +36,15 @@ function readDomainFromPacket(buffer, offset) { nread: 1 + length + nread, domain: domain ? `${chunk}.${domain}` : chunk }; - } else { - // Pointer to another part of the packet. - assert.strictEqual(length & 0xC0, 0xC0); - // eslint-disable-next-line space-infix-ops, space-unary-ops - const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000; - return { - nread: 2, - domain: readDomainFromPacket(buffer, pointeeOffset) - }; } + // Pointer to another part of the packet. + assert.strictEqual(length & 0xC0, 0xC0); + // eslint-disable-next-line space-infix-ops, space-unary-ops + const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000; + return { + nread: 2, + domain: readDomainFromPacket(buffer, pointeeOffset) + }; } function parseDNSPacket(buffer) { diff --git a/test/common/index.js b/test/common/index.js index a16ce6e6f73adf..50722f65c09b82 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -27,7 +27,7 @@ const process = global.process; // Some tests tamper with the process global. const assert = require('assert'); const { exec, execSync, spawnSync } = require('child_process'); const fs = require('fs'); -// Do not require 'os' until needed so that test-os-checked-fucnction can +// Do not require 'os' until needed so that test-os-checked-function can // monkey patch it. If 'os' is required here, that test will fail. const path = require('path'); const util = require('util'); @@ -309,10 +309,9 @@ function runCallChecks(exitCode) { if ('minimum' in context) { context.messageSegment = `at least ${context.minimum}`; return context.actual < context.minimum; - } else { - context.messageSegment = `exactly ${context.exact}`; - return context.actual !== context.exact; } + context.messageSegment = `exactly ${context.exact}`; + return context.actual !== context.exact; }); failed.forEach(function(context) { @@ -418,9 +417,12 @@ function getCallSite(top) { function mustNotCall(msg) { const callSite = getCallSite(mustNotCall); - return function mustNotCall() { + return function mustNotCall(...args) { + const argsInfo = args.length > 0 ? + `\ncalled with arguments: ${args.map(util.inspect).join(', ')}` : ''; assert.fail( - `${msg || 'function should not have been called'} at ${callSite}`); + `${msg || 'function should not have been called'} at ${callSite}` + + argsInfo); }; } @@ -465,9 +467,8 @@ function nodeProcessAborted(exitCode, signal) { // the expected exit codes or signals. if (signal !== null) { return expectedSignals.includes(signal); - } else { - return expectedExitCodes.includes(exitCode); } + return expectedExitCodes.includes(exitCode); } function isAlive(pid) { diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index d430137746dd81..77d7928af135a6 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -217,9 +217,8 @@ class InspectorSession { return Promise .all(commands.map((command) => this._sendMessage(command))) .then(() => {}); - } else { - return this._sendMessage(commands); } + return this._sendMessage(commands); } waitForNotification(methodOrPredicate, description) { diff --git a/test/common/report.js b/test/common/report.js index 3b6b46eeec0f8d..f49493b443edea 100644 --- a/test/common/report.js +++ b/test/common/report.js @@ -24,16 +24,16 @@ function findReports(pid, dir) { return results; } -function validate(filepath) { +function validate(filepath, fields) { const report = fs.readFileSync(filepath, 'utf8'); if (process.report.compact) { const end = report.indexOf('\n'); assert.strictEqual(end, report.length - 1); } - validateContent(JSON.parse(report)); + validateContent(JSON.parse(report), fields); } -function validateContent(report) { +function validateContent(report, fields = []) { if (typeof report === 'string') { try { report = JSON.parse(report); @@ -43,7 +43,7 @@ function validateContent(report) { } } try { - _validateContent(report); + _validateContent(report, fields); } catch (err) { try { err.stack += util.format('\n------\nFailing Report:\n%O', report); @@ -52,7 +52,7 @@ function validateContent(report) { } } -function _validateContent(report) { +function _validateContent(report, fields = []) { const isWindows = process.platform === 'win32'; // Verify that all sections are present as own properties of the report. @@ -71,6 +71,26 @@ function _validateContent(report) { assert(typeof report[section] === 'object' && report[section] !== null); }); + fields.forEach((field) => { + function checkLoop(actual, rest, expect) { + actual = actual[rest.shift()]; + if (rest.length === 0 && actual !== undefined) { + assert.strictEqual(actual, expect); + } else { + assert(actual); + checkLoop(actual, rest, expect); + } + } + let actual, expect; + if (Array.isArray(field)) { + [actual, expect] = field; + } else { + actual = field; + expect = undefined; + } + checkLoop(report, actual.split('.'), expect); + }); + // Verify the format of the header section. const header = report.header; const headerFields = ['event', 'trigger', 'filename', 'dumpEventTime', @@ -144,7 +164,10 @@ function _validateContent(report) { assert.strictEqual(header.host, os.hostname()); // Verify the format of the javascriptStack section. - checkForUnknownFields(report.javascriptStack, ['message', 'stack']); + checkForUnknownFields(report.javascriptStack, + ['message', 'stack', 'errorProperties']); + assert.strictEqual(typeof report.javascriptStack.errorProperties, + 'object'); assert.strictEqual(typeof report.javascriptStack.message, 'string'); if (report.javascriptStack.stack !== undefined) { assert(Array.isArray(report.javascriptStack.stack)); @@ -262,7 +285,7 @@ function _validateContent(report) { // Verify the format of the workers section. assert(Array.isArray(report.workers)); - report.workers.forEach(_validateContent); + report.workers.forEach((worker) => _validateContent(worker)); } function checkForUnknownFields(actual, expected) { diff --git a/test/common/shared-lib-util.js b/test/common/shared-lib-util.js index e522a71b4748d8..9f891a6043ef3d 100644 --- a/test/common/shared-lib-util.js +++ b/test/common/shared-lib-util.js @@ -36,9 +36,8 @@ function getSharedLibPath() { return path.join(kExecPath, 'node.dll'); } else if (common.isOSX) { return path.join(kExecPath, `libnode.${kShlibSuffix}`); - } else { - return path.join(kExecPath, 'lib.target', `libnode.${kShlibSuffix}`); } + return path.join(kExecPath, 'lib.target', `libnode.${kShlibSuffix}`); } // Get the binary path of stack frames. diff --git a/test/common/wpt.js b/test/common/wpt.js index e33d0c86cc7ed9..e79bd66b370735 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -73,9 +73,8 @@ class ResourceLoader { text() { return data.toString(); } }; }); - } else { - return fs.readFileSync(file, 'utf8'); } + return fs.readFileSync(file, 'utf8'); } } @@ -603,24 +602,23 @@ class WPTRunner { const matches = code.match(/\/\/ META: .+/g); if (!matches) { return {}; - } else { - const result = {}; - for (const match of matches) { - const parts = match.match(/\/\/ META: ([^=]+?)=(.+)/); - const key = parts[1]; - const value = parts[2]; - if (key === 'script') { - if (result[key]) { - result[key].push(value); - } else { - result[key] = [value]; - } + } + const result = {}; + for (const match of matches) { + const parts = match.match(/\/\/ META: ([^=]+?)=(.+)/); + const key = parts[1]; + const value = parts[2]; + if (key === 'script') { + if (result[key]) { + result[key].push(value); } else { - result[key] = value; + result[key] = [value]; } + } else { + result[key] = value; } - return result; } + return result; } buildQueue() { diff --git a/test/es-module/test-esm-cjs-named-error.mjs b/test/es-module/test-esm-cjs-named-error.mjs index d34f762dfb4e26..d71dc959e21fb7 100644 --- a/test/es-module/test-esm-cjs-named-error.mjs +++ b/test/es-module/test-esm-cjs-named-error.mjs @@ -10,6 +10,13 @@ const expectedRelative = 'The requested module \'./fail.cjs\' is expected to ' + 'import pkg from \'./fail.cjs\';\n' + 'const { comeOn } = pkg;'; +const expectedRenamed = 'The requested module \'./fail.cjs\' is expected to ' + + 'be of type CommonJS, which does not support named exports. CommonJS ' + + 'modules can be imported by importing the default export.\n' + + 'For example:\n' + + 'import pkg from \'./fail.cjs\';\n' + + 'const { comeOn: comeOnRenamed } = pkg;'; + const expectedPackageHack = 'The requested module \'./json-hack/fail.js\' is ' + 'expected to be of type CommonJS, which does not support named exports. ' + 'CommonJS modules can be imported by importing the default export.\n' + @@ -38,6 +45,13 @@ rejects(async () => { message: expectedRelative }, 'should support relative specifiers with double quotes'); +rejects(async () => { + await import(`${fixtureBase}/renamed-import.mjs`); +}, { + name: 'SyntaxError', + message: expectedRenamed +}, 'should correctly format named imports with renames'); + rejects(async () => { await import(`${fixtureBase}/json-hack.mjs`); }, { diff --git a/test/es-module/test-esm-invalid-pjson.js b/test/es-module/test-esm-invalid-pjson.js new file mode 100644 index 00000000000000..83f4ad5baba4a7 --- /dev/null +++ b/test/es-module/test-esm-invalid-pjson.js @@ -0,0 +1,29 @@ +'use strict'; + +const { mustCall, isWindows } = require('../common'); +const fixtures = require('../common/fixtures'); +const { spawn } = require('child_process'); +const { strictEqual, ok } = require('assert'); + +const entry = fixtures.path('/es-modules/import-invalid-pjson.mjs'); +const invalidJson = fixtures.path('/node_modules/invalid-pjson/package.json'); + +const child = spawn(process.execPath, [entry]); +child.stderr.setEncoding('utf8'); +let stderr = ''; +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', mustCall((code, signal) => { + strictEqual(code, 1); + strictEqual(signal, null); + ok( + stderr.includes( + [ + '[ERR_INVALID_PACKAGE_CONFIG]: ', + `Invalid package config ${invalidJson}, `, + `Unexpected token } in JSON at position ${isWindows ? 16 : 14}` + ].join(''), + ), + stderr); +})); diff --git a/test/es-module/test-esm-loader-stringify-text.mjs b/test/es-module/test-esm-loader-stringify-text.mjs new file mode 100644 index 00000000000000..ed9bd5069ebf1d --- /dev/null +++ b/test/es-module/test-esm-loader-stringify-text.mjs @@ -0,0 +1,50 @@ +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/string-sources.mjs +import { mustCall, mustNotCall } from '../common/index.mjs'; +import assert from 'assert'; + +import('test:Array').then( + mustNotCall('Should not accept Arrays'), + mustCall((e) => { + assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE'); + }) +); +import('test:ArrayBuffer').then( + mustCall(), + mustNotCall('Should accept ArrayBuffers'), +); +import('test:null').then( + mustNotCall('Should not accept null'), + mustCall((e) => { + assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE'); + }) +); +import('test:Object').then( + mustNotCall('Should not stringify or valueOf Objects'), + mustCall((e) => { + assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE'); + }) +); +import('test:SharedArrayBuffer').then( + mustCall(), + mustNotCall('Should accept SharedArrayBuffers'), +); +import('test:string').then( + mustCall(), + mustNotCall('Should accept strings'), +); +import('test:String').then( + mustNotCall('Should not accept wrapper Strings'), + mustCall((e) => { + assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE'); + }) +); +import('test:Uint8Array').then( + mustCall(), + mustNotCall('Should accept Uint8Arrays'), +); +import('test:undefined').then( + mustNotCall('Should not accept undefined'), + mustCall((e) => { + assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE'); + }) +); diff --git a/test/fixtures/0-dns/README.md b/test/fixtures/0-dns/README.md index 9a4a4a2b3d8a93..928efbec9609c2 100644 --- a/test/fixtures/0-dns/README.md +++ b/test/fixtures/0-dns/README.md @@ -6,7 +6,7 @@ can be created by using `asn1.js` and `asn1.js-rfc5280`, ## How to create a test cert. -```sh +```console $ openssl genrsa -out 0-dns-key.pem 2048 Generating RSA private key, 2048 bit long modulus ...................+++ diff --git a/test/fixtures/es-module-loaders/string-sources.mjs b/test/fixtures/es-module-loaders/string-sources.mjs new file mode 100644 index 00000000000000..3133231208ce1e --- /dev/null +++ b/test/fixtures/es-module-loaders/string-sources.mjs @@ -0,0 +1,30 @@ +const SOURCES = { + __proto__: null, + 'test:Array': ['1', '2'], // both `1,2` and `12` are valid ESM + 'test:ArrayBuffer': new ArrayBuffer(0), + 'test:null': null, + 'test:Object': {}, + 'test:SharedArrayBuffer': new SharedArrayBuffer(0), + 'test:string': '', + 'test:String': new String(''), + 'test:Uint8Array': new Uint8Array(0), + 'test:undefined': undefined, +} +export function resolve(specifier, context, defaultFn) { + if (specifier.startsWith('test:')) { + return { url: specifier }; + } + return defaultFn(specifier, context); +} +export function getFormat(href, context, defaultFn) { + if (href.startsWith('test:')) { + return { format: 'module' }; + } + return defaultFn(href, context); +} +export function getSource(href, context, defaultFn) { + if (href.startsWith('test:')) { + return { source: SOURCES[href] }; + } + return defaultFn(href, context); +} diff --git a/test/fixtures/es-module-loaders/transform-source.mjs b/test/fixtures/es-module-loaders/transform-source.mjs index ab147c34cb34fd..25d983b64e62ca 100644 --- a/test/fixtures/es-module-loaders/transform-source.mjs +++ b/test/fixtures/es-module-loaders/transform-source.mjs @@ -1,6 +1,9 @@ export async function transformSource( source, { url, format }, defaultTransformSource) { - if (source && source.replace) { + if (format === 'module') { + if (typeof source !== 'string') { + source = new TextDecoder().decode(source); + } return { source: source.replace(`'A message';`, `'A message'.toUpperCase();`) }; diff --git a/test/fixtures/es-modules/import-invalid-pjson.mjs b/test/fixtures/es-modules/import-invalid-pjson.mjs new file mode 100644 index 00000000000000..61f4aa83458bac --- /dev/null +++ b/test/fixtures/es-modules/import-invalid-pjson.mjs @@ -0,0 +1 @@ +import 'invalid-pjson'; diff --git a/test/fixtures/es-modules/package-cjs-named-error/renamed-import.mjs b/test/fixtures/es-modules/package-cjs-named-error/renamed-import.mjs new file mode 100644 index 00000000000000..dc601f28fe2f99 --- /dev/null +++ b/test/fixtures/es-modules/package-cjs-named-error/renamed-import.mjs @@ -0,0 +1 @@ +import { comeOn as comeOnRenamed } from "./fail.cjs" diff --git a/test/fixtures/macos-app-sandbox/Info.plist b/test/fixtures/macos-app-sandbox/Info.plist new file mode 100644 index 00000000000000..38362085af4bf8 --- /dev/null +++ b/test/fixtures/macos-app-sandbox/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleExecutable + node + CFBundleIdentifier + org.nodejs.test.node_sandboxed + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + node_sandboxed + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + + \ No newline at end of file diff --git a/test/fixtures/macos-app-sandbox/node_sandboxed.entitlements b/test/fixtures/macos-app-sandbox/node_sandboxed.entitlements new file mode 100644 index 00000000000000..852fa1a4728ae4 --- /dev/null +++ b/test/fixtures/macos-app-sandbox/node_sandboxed.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/test/fixtures/node_modules/invalid-pjson/package.json b/test/fixtures/node_modules/invalid-pjson/package.json new file mode 100644 index 00000000000000..5864c29c04a731 --- /dev/null +++ b/test/fixtures/node_modules/invalid-pjson/package.json @@ -0,0 +1,3 @@ +{ + "invalid" +} diff --git a/test/fixtures/tools/checkimports/invalid.cc b/test/fixtures/tools/checkimports/invalid.cc new file mode 100644 index 00000000000000..deace1287f11bb --- /dev/null +++ b/test/fixtures/tools/checkimports/invalid.cc @@ -0,0 +1,7 @@ +using v8::MaybeLocal; +using v8::Array; +using v8::Local; + +MaybeLocal CreateObject() const { + return MaybeLocal(); +} diff --git a/test/fixtures/tools/checkimports/maybe.cc b/test/fixtures/tools/checkimports/maybe.cc new file mode 100644 index 00000000000000..e96899be775ae7 --- /dev/null +++ b/test/fixtures/tools/checkimports/maybe.cc @@ -0,0 +1,7 @@ +using v8::Array; +using v8::Local; +using v8::MaybeLocal; + +MaybeLocal CreateObject() const { + return MaybeLocal(); +} diff --git a/test/fixtures/tools/checkimports/unsorted.cc b/test/fixtures/tools/checkimports/unsorted.cc new file mode 100644 index 00000000000000..0e6b540dccc466 --- /dev/null +++ b/test/fixtures/tools/checkimports/unsorted.cc @@ -0,0 +1,6 @@ +using v8::MaybeLocal; +using v8::Array; + +MaybeLocal CreateObject() const { + return MaybeLocal(); +} diff --git a/test/fixtures/tools/checkimports/unused.cc b/test/fixtures/tools/checkimports/unused.cc new file mode 100644 index 00000000000000..231f5549e2900c --- /dev/null +++ b/test/fixtures/tools/checkimports/unused.cc @@ -0,0 +1,5 @@ +using v8::Context; + +static void MyMethod(void) { + return; +} diff --git a/test/fixtures/tools/checkimports/valid.cc b/test/fixtures/tools/checkimports/valid.cc new file mode 100644 index 00000000000000..7e52968883ad8b --- /dev/null +++ b/test/fixtures/tools/checkimports/valid.cc @@ -0,0 +1,6 @@ +using v8::Array; +using v8::MaybeLocal; + +MaybeLocal CreateObject() const { + return MaybeLocal(); +} diff --git a/test/internet/internet.status b/test/internet/internet.status new file mode 100644 index 00000000000000..8cef8b6719949a --- /dev/null +++ b/test/internet/internet.status @@ -0,0 +1,26 @@ +prefix internet + +# To mark a test as flaky, list the test name in the appropriate section +# below, without ".js", followed by ": PASS,FLAKY". Example: +# sample-test : PASS,FLAKY + +[true] # This section applies to all platforms + + +[$system==win32] + +[$system==linux] +# https://github.com/nodejs/node/issues/32946 +test-dgram-multicast-ssmv6-multi-process: PASS, FLAKY + +[$system==macos] + +[$system==solaris] # Also applies to SmartOS + +[$system==freebsd] + +[$system==aix] + +[$system==ibmi] + +[$arch==arm] diff --git a/test/message/assert_throws_stack.out b/test/message/assert_throws_stack.out index e9f9cc5e891c37..a2da1f2b6c5b37 100644 --- a/test/message/assert_throws_stack.out +++ b/test/message/assert_throws_stack.out @@ -29,6 +29,6 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: at * at * at *, - expected: [Object], + expected: { bar: true }, operator: 'throws' } diff --git a/test/message/eval_messages.out b/test/message/eval_messages.out index 8840633959a18b..64743d4ae67acf 100644 --- a/test/message/eval_messages.out +++ b/test/message/eval_messages.out @@ -55,11 +55,11 @@ ReferenceError: y is not defined var ______________________________________________; throw 10 ^ 10 -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) [eval]:1 var ______________________________________________; throw 10 ^ 10 -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) done diff --git a/test/message/stdin_messages.out b/test/message/stdin_messages.out index 72edb0b00b28cd..3c71c5683b7d94 100644 --- a/test/message/stdin_messages.out +++ b/test/message/stdin_messages.out @@ -67,11 +67,11 @@ ReferenceError: y is not defined let ______________________________________________; throw 10 ^ 10 -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) [stdin]:1 let ______________________________________________; throw 10 ^ 10 -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) done diff --git a/test/message/throw_error_with_getter_throw.out b/test/message/throw_error_with_getter_throw.out index 5daf35aad44ce3..2162185e7845fc 100644 --- a/test/message/throw_error_with_getter_throw.out +++ b/test/message/throw_error_with_getter_throw.out @@ -3,4 +3,4 @@ throw { // eslint-disable-line no-throw-literal ^ [object Object] -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) diff --git a/test/message/throw_null.out b/test/message/throw_null.out index db6cc3edf583ef..c97dcbfe134a22 100644 --- a/test/message/throw_null.out +++ b/test/message/throw_null.out @@ -3,4 +3,4 @@ throw null; ^ null -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) diff --git a/test/message/throw_undefined.out b/test/message/throw_undefined.out index 016eb8ffd95e33..4b2bfdbc590708 100644 --- a/test/message/throw_undefined.out +++ b/test/message/throw_undefined.out @@ -3,4 +3,4 @@ throw undefined; ^ undefined -(Use `node --trace-uncaught ...` to show where the exception was thrown) +(Use `* --trace-uncaught ...` to show where the exception was thrown) diff --git a/test/node-api/test_worker_terminate_finalization/binding.gyp b/test/node-api/test_worker_terminate_finalization/binding.gyp new file mode 100644 index 00000000000000..800ed54d568e16 --- /dev/null +++ b/test/node-api/test_worker_terminate_finalization/binding.gyp @@ -0,0 +1,8 @@ +{ + "targets": [ + { + "target_name": "test_worker_terminate_finalization", + "sources": [ "test_worker_terminate_finalization.c" ] + } + ] +} diff --git a/test/node-api/test_worker_terminate_finalization/test.js b/test/node-api/test_worker_terminate_finalization/test.js new file mode 100644 index 00000000000000..76cece7bcf3cc4 --- /dev/null +++ b/test/node-api/test_worker_terminate_finalization/test.js @@ -0,0 +1,18 @@ +'use strict'; +const common = require('../../common'); +const { Worker, isMainThread } = require('worker_threads'); + +if (isMainThread) { + const worker = new Worker(__filename); + worker.on('error', common.mustNotCall()); +} else { + const { Test } = + require(`./build/${common.buildType}/test_worker_terminate_finalization`); + + // Spin up thread and call add-on create the right sequence + // of rerences to hit the case reported in + // https://github.com/nodejs/node-addon-api/issues/722 + // will crash if run under debug and its not possible to + // create object in the specific finalizer + Test(new Object()); +} diff --git a/test/node-api/test_worker_terminate_finalization/test_worker_terminate_finalization.c b/test/node-api/test_worker_terminate_finalization/test_worker_terminate_finalization.c new file mode 100644 index 00000000000000..6171f01e1519eb --- /dev/null +++ b/test/node-api/test_worker_terminate_finalization/test_worker_terminate_finalization.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include "../../js-native-api/common.h" + +#define BUFFER_SIZE 4 + +int wrappedNativeData; +napi_ref ref; +void WrapFinalizer(napi_env env, void* data, void* hint) { + uint32_t count; + NAPI_CALL_RETURN_VOID(env, napi_reference_unref(env, ref, &count)); + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, ref)); +} + +void BufferFinalizer(napi_env env, void* data, void* hint) { + free(hint); +} + +napi_value Test(napi_env env, napi_callback_info info) { + size_t argc = 1; + napi_value argv[1]; + napi_value result; + napi_ref ref; + void* bufferData = malloc(BUFFER_SIZE); + + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); + NAPI_CALL(env, napi_create_external_buffer(env, BUFFER_SIZE, bufferData, BufferFinalizer, bufferData, &result)); + NAPI_CALL(env, napi_create_reference(env, result, 1, &ref)); + NAPI_CALL(env, napi_wrap(env, argv[0], (void*) &wrappedNativeData, WrapFinalizer, NULL, NULL)); + return NULL; +} + +napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor properties[] = { + DECLARE_NAPI_PROPERTY("Test", Test) + }; + + NAPI_CALL(env, napi_define_properties( + env, exports, sizeof(properties) / sizeof(*properties), properties)); + + return exports; +} + +// Do not start using NAPI_MODULE_INIT() here, so that we can test +// compatibility of Workers with NAPI_MODULE(). +NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 193cd820ac9683..b72cd30775c05c 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -40,6 +40,8 @@ test-async-hooks-http-parser-destroy: PASS,FLAKY # https://github.com/nodejs/node/pull/31178 test-crypto-dh-stateless: SKIP test-crypto-keygen: SKIP +# https://github.com/nodejs/node/issues/33796 +test-fs-stream-construct: PASS,FLAKY [$system==solaris] # Also applies to SmartOS diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 914f9ecd1a3823..cc3132d55ecdb9 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -958,8 +958,6 @@ assertDeepAndStrictEqual(obj1, obj2); // Check proxies. { - // TODO(BridgeAR): Check if it would not be better to detect proxies instead - // of just using the proxy value. const arrProxy = new Proxy([1, 2], {}); assert.deepStrictEqual(arrProxy, [1, 2]); const tmp = util.inspect.defaultOptions; diff --git a/test/parallel/test-bash-completion.js b/test/parallel/test-bash-completion.js index 4492c2f85c470f..c0b284153a7058 100644 --- a/test/parallel/test-bash-completion.js +++ b/test/parallel/test-bash-completion.js @@ -24,7 +24,8 @@ const suffix = `' -- "\${cur_word}") ) return 0 fi } -complete -F _node_complete node node_g`.replace(/\r/g, ''); +complete -o filenames -o nospace -o bashdefault -F _node_complete node node_g` + .replace(/\r/g, ''); assert.ok( output.includes(prefix), diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index ee2a40c0a6cd79..b9e7855c3b3301 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -49,6 +49,7 @@ const expectedModules = new Set([ 'NativeModule internal/idna', 'NativeModule internal/linkedlist', 'NativeModule internal/modules/run_main', + 'NativeModule internal/modules/package_json_reader', 'NativeModule internal/modules/cjs/helpers', 'NativeModule internal/modules/cjs/loader', 'NativeModule internal/modules/esm/create_dynamic_module', diff --git a/test/parallel/test-common-must-not-call.js b/test/parallel/test-common-must-not-call.js index d70daabf0a4bd0..dcea7059dac7f5 100644 --- a/test/parallel/test-common-must-not-call.js +++ b/test/parallel/test-common-must-not-call.js @@ -3,24 +3,39 @@ const common = require('../common'); const assert = require('assert'); const path = require('path'); +const util = require('util'); const message = 'message'; -const testFunction = common.mustNotCall(message); +const testFunction1 = common.mustNotCall(message); -const validateError = common.mustCall((e) => { +const testFunction2 = common.mustNotCall(message); + +const createValidate = (line, args = []) => common.mustCall((e) => { const prefix = `${message} at `; assert.ok(e.message.startsWith(prefix)); if (process.platform === 'win32') { e.message = e.message.substring(2); // remove 'C:' } - const [ fileName, lineNumber ] = e.message - .substring(prefix.length).split(':'); + const msg = e.message.substring(prefix.length); + const firstColon = msg.indexOf(':'); + const fileName = msg.substring(0, firstColon); + const rest = msg.substring(firstColon + 1); assert.strictEqual(path.basename(fileName), 'test-common-must-not-call.js'); - assert.strictEqual(lineNumber, '8'); + const argsInfo = args.length > 0 ? + `\ncalled with arguments: ${args.map(util.inspect).join(', ')}` : ''; + assert.strictEqual(rest, line + argsInfo); }); +const validate1 = createValidate('9'); +try { + testFunction1(); +} catch (e) { + validate1(e); +} + +const validate2 = createValidate('11', ['hello', 42]); try { - testFunction(); + testFunction2('hello', 42); } catch (e) { - validateError(e); + validate2(e); } diff --git a/test/parallel/test-console-methods.js b/test/parallel/test-console-methods.js index 00dc144761cb57..d338cc1f807f2c 100644 --- a/test/parallel/test-console-methods.js +++ b/test/parallel/test-console-methods.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -// This test ensures that console methods -// cannot be invoked as constructors +// This test ensures that console methods cannot be invoked as constructors and +// that their name is always correct. const assert = require('assert'); @@ -32,7 +32,30 @@ const methods = [ 'groupCollapsed', ]; +const alternateNames = { + debug: 'log', + info: 'log', + dirxml: 'log', + error: 'warn', + groupCollapsed: 'group' +}; + +function assertEqualName(method) { + try { + assert.strictEqual(console[method].name, method); + } catch { + assert.strictEqual(console[method].name, alternateNames[method]); + } + try { + assert.strictEqual(newInstance[method].name, method); + } catch { + assert.strictEqual(newInstance[method].name, alternateNames[method]); + } +} + for (const method of methods) { + assertEqualName(method); + assert.throws(() => new console[method](), err); assert.throws(() => new newInstance[method](), err); assert.throws(() => Reflect.construct({}, [], console[method]), err); diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index b70bfccae47eef..ff410dcf00fa6a 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -391,12 +391,18 @@ assert.throws( }); [1, {}, [], Infinity].forEach((input) => { + let prop = '"key" argument'; + let value = input; + if (typeof input === 'object') { + prop = '"key.key" property'; + value = undefined; + } const errObj = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "key" argument must be of type string or an instance of ' + - 'Buffer, TypedArray, DataView, or KeyObject.' + - common.invalidArgTypeHelper(input) + message: `The ${prop} must be of type string or ` + + 'an instance of Buffer, TypedArray, DataView, or KeyObject.' + + common.invalidArgTypeHelper(value) }; assert.throws(() => sign.sign(input), errObj); @@ -478,25 +484,33 @@ assert.throws( [1, {}, [], true, Infinity].forEach((input) => { const data = Buffer.alloc(1); const sig = Buffer.alloc(1); - const received = common.invalidArgTypeHelper(input); const errObj = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', message: 'The "data" argument must be an instance of Buffer, ' + - `TypedArray, or DataView.${received}` + 'TypedArray, or DataView.' + + common.invalidArgTypeHelper(input) }; assert.throws(() => crypto.sign(null, input, 'asdf'), errObj); assert.throws(() => crypto.verify(null, input, 'asdf', sig), errObj); - errObj.message = 'The "key" argument must be of type string or an instance ' + - `of Buffer, TypedArray, DataView, or KeyObject.${received}`; + let prop = '"key" argument'; + let value = input; + if (typeof input === 'object') { + prop = '"key.key" property'; + value = undefined; + } + errObj.message = `The ${prop} must be of type string or ` + + 'an instance of Buffer, TypedArray, DataView, or KeyObject.' + + common.invalidArgTypeHelper(value); assert.throws(() => crypto.sign(null, data, input), errObj); assert.throws(() => crypto.verify(null, data, input, sig), errObj); errObj.message = 'The "signature" argument must be an instance of ' + - `Buffer, TypedArray, or DataView.${received}`; + 'Buffer, TypedArray, or DataView.' + + common.invalidArgTypeHelper(input); assert.throws(() => crypto.verify(null, data, 'test', input), errObj); }); diff --git a/test/parallel/test-dns-channel-timeout.js b/test/parallel/test-dns-channel-timeout.js new file mode 100644 index 00000000000000..1e4dac5489730a --- /dev/null +++ b/test/parallel/test-dns-channel-timeout.js @@ -0,0 +1,53 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const dns = require('dns'); + +for (const ctor of [dns.Resolver, dns.promises.Resolver]) { + for (const timeout of [null, true, false, '', '2']) { + assert.throws(() => new ctor({ timeout }), { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + }); + } + + for (const timeout of [-2, 4.2, 2 ** 31]) { + assert.throws(() => new ctor({ timeout }), { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError', + }); + } + + for (const timeout of [-1, 0, 1]) new ctor({ timeout }); // OK +} + +for (const timeout of [0, 1, 2]) { + const server = dgram.createSocket('udp4'); + server.bind(0, '127.0.0.1', common.mustCall(() => { + const resolver = new dns.Resolver({ timeout }); + resolver.setServers([`127.0.0.1:${server.address().port}`]); + resolver.resolve4('nodejs.org', common.mustCall((err) => { + assert.throws(() => { throw err; }, { + code: 'ETIMEOUT', + name: 'Error', + }); + server.close(); + })); + })); +} + +for (const timeout of [0, 1, 2]) { + const server = dgram.createSocket('udp4'); + server.bind(0, '127.0.0.1', common.mustCall(() => { + const resolver = new dns.promises.Resolver({ timeout }); + resolver.setServers([`127.0.0.1:${server.address().port}`]); + resolver.resolve4('nodejs.org').catch(common.mustCall((err) => { + assert.throws(() => { throw err; }, { + code: 'ETIMEOUT', + name: 'Error', + }); + server.close(); + })); + })); +} diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js index 6168566334a11d..2f0c757a99df35 100644 --- a/test/parallel/test-domain-http-server.js +++ b/test/parallel/test-domain-http-server.js @@ -20,12 +20,14 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const domain = require('domain'); const http = require('http'); const assert = require('assert'); const debug = require('util').debuglog('test'); +process.on('warning', common.mustNotCall()); + const objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] }; objects.baz.asdf = objects; diff --git a/test/parallel/test-domain-implicit-binding.js b/test/parallel/test-domain-implicit-binding.js index 15f6685df93b7b..9f119a420368f0 100644 --- a/test/parallel/test-domain-implicit-binding.js +++ b/test/parallel/test-domain-implicit-binding.js @@ -6,6 +6,8 @@ const domain = require('domain'); const fs = require('fs'); const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable); +process.on('warning', common.mustNotCall()); + { const d = new domain.Domain(); diff --git a/test/parallel/test-domain-implicit-fs.js b/test/parallel/test-domain-implicit-fs.js index d5a6e79bc90734..c785ff75c67656 100644 --- a/test/parallel/test-domain-implicit-fs.js +++ b/test/parallel/test-domain-implicit-fs.js @@ -26,6 +26,8 @@ const common = require('../common'); const assert = require('assert'); const domain = require('domain'); +process.on('warning', common.mustNotCall()); + const d = new domain.Domain(); d.on('error', common.mustCall(function(er) { diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index 63701150f8c331..072f8e86bb077c 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -26,6 +26,8 @@ const common = require('../common'); const domain = require('domain'); const http = require('http'); +process.on('warning', common.mustNotCall()); + const a = domain.create(); a.enter(); // This will be our "root" domain diff --git a/test/parallel/test-domain-promise.js b/test/parallel/test-domain-promise.js index 704092522357fd..2a127f3d40272b 100644 --- a/test/parallel/test-domain-promise.js +++ b/test/parallel/test-domain-promise.js @@ -5,6 +5,8 @@ const domain = require('domain'); const fs = require('fs'); const vm = require('vm'); +process.on('warning', common.mustNotCall()); + { const d = domain.create(); diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js index c5af446198d55c..b68fdbf3a1fbfc 100644 --- a/test/parallel/test-file-write-stream3.js +++ b/test/parallel/test-file-write-stream3.js @@ -182,10 +182,12 @@ const run_test_4 = common.mustCall(function() { const fn = () => { fs.createWriteStream(filepath, { start: -5, flags: 'r+' }); }; + // Verify the range of values using a common integer verifier. + // Limit Number.MAX_SAFE_INTEGER const err = { code: 'ERR_OUT_OF_RANGE', message: 'The value of "start" is out of range. ' + - 'It must be >= 0 and <= 2 ** 53 - 1. Received -5', + `It must be >= 0 && <= ${Number.MAX_SAFE_INTEGER}. Received -5`, name: 'RangeError' }; assert.throws(fn, err); @@ -197,10 +199,13 @@ const run_test_5 = common.mustCall(function() { const fn = () => { fs.createWriteStream(filepath, { start: 2 ** 53, flags: 'r+' }); }; + // Verify the range of values using a common integer verifier. + // Limit Number.MAX_SAFE_INTEGER const err = { code: 'ERR_OUT_OF_RANGE', message: 'The value of "start" is out of range. It must be ' + - '>= 0 and <= 2 ** 53 - 1. Received 9_007_199_254_740_992', + `>= 0 && <= ${Number.MAX_SAFE_INTEGER}. ` + + 'Received 9_007_199_254_740_992', name: 'RangeError' }; assert.throws(fn, err); diff --git a/test/parallel/test-fs-mkdir-mode-mask.js b/test/parallel/test-fs-mkdir-mode-mask.js index 515b982054b82b..40bd7bec441373 100644 --- a/test/parallel/test-fs-mkdir-mode-mask.js +++ b/test/parallel/test-fs-mkdir-mode-mask.js @@ -7,15 +7,12 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs'); -let mode; - if (common.isWindows) { common.skip('mode is not supported in mkdir on Windows'); return; -} else { - mode = 0o644; } +const mode = 0o644; const maskToIgnore = 0o10000; const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-fs-readdir-buffer.js b/test/parallel/test-fs-readdir-buffer.js new file mode 100644 index 00000000000000..a679aad01bf447 --- /dev/null +++ b/test/parallel/test-fs-readdir-buffer.js @@ -0,0 +1,17 @@ +'use strict'; +const common = require('../common'); +const fs = require('fs'); + +if (!common.isOSX) { + common.skip('this tests works only on MacOS'); +} + +const assert = require('assert'); + +fs.readdir( + Buffer.from('/dev'), + { withFileTypes: true, encoding: 'buffer' }, + common.mustCall((e, d) => { + assert.strictEqual(e, null); + }) +); diff --git a/test/parallel/test-fs-readv-promisify.js b/test/parallel/test-fs-readv-promisify.js new file mode 100644 index 00000000000000..2af418bcc2d12b --- /dev/null +++ b/test/parallel/test-fs-readv-promisify.js @@ -0,0 +1,18 @@ +'use strict'; + +const common = require('../common'); +const fixtures = require('../common/fixtures'); +const fs = require('fs'); +const readv = require('util').promisify(fs.readv); +const assert = require('assert'); +const filepath = fixtures.path('x.txt'); +const fd = fs.openSync(filepath, 'r'); + +const expected = [Buffer.from('xyz\n')]; + +readv(fd, expected) + .then(function({ bytesRead, buffers }) { + assert.deepStrictEqual(bytesRead, expected[0].length); + assert.deepStrictEqual(buffers, expected); + }) + .then(common.mustCall()); diff --git a/test/parallel/test-fs-symlink-longpath.js b/test/parallel/test-fs-symlink-longpath.js new file mode 100644 index 00000000000000..f6824218137bf2 --- /dev/null +++ b/test/parallel/test-fs-symlink-longpath.js @@ -0,0 +1,29 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); + +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); +const tmpDir = tmpdir.path; +const longPath = path.join(...[tmpDir].concat(Array(30).fill('1234567890'))); +fs.mkdirSync(longPath, { recursive: true }); + +// Test if we can have symlinks to files and folders with long filenames +const targetDirtectory = path.join(longPath, 'target-directory'); +fs.mkdirSync(targetDirtectory); +const pathDirectory = path.join(tmpDir, 'new-directory'); +fs.symlink(targetDirtectory, pathDirectory, 'dir', common.mustCall((err) => { + assert.ifError(err); + assert(fs.existsSync(pathDirectory)); +})); + +const targetFile = path.join(longPath, 'target-file'); +fs.writeFileSync(targetFile, 'data'); +const pathFile = path.join(tmpDir, 'new-file'); +fs.symlink(targetFile, pathFile, common.mustCall((err) => { + assert.ifError(err); + assert(fs.existsSync(pathFile)); +})); diff --git a/test/parallel/test-fs-utils-get-dirents.js b/test/parallel/test-fs-utils-get-dirents.js new file mode 100644 index 00000000000000..6afe6dbca3e529 --- /dev/null +++ b/test/parallel/test-fs-utils-get-dirents.js @@ -0,0 +1,123 @@ +// Flags: --expose-internals +'use strict'; + +const common = require('../common'); +const { getDirents, getDirent } = require('internal/fs/utils'); +const assert = require('assert'); +const { internalBinding } = require('internal/test/binding'); +const { UV_DIRENT_UNKNOWN } = internalBinding('constants').fs; +const fs = require('fs'); +const path = require('path'); + +const tmpdir = require('../common/tmpdir'); +const filename = 'foo'; + +{ + // setup + tmpdir.refresh(); + fs.writeFileSync(path.join(tmpdir.path, filename), ''); +} +// getDirents +{ + // string + string + getDirents( + tmpdir.path, + [[filename], [UV_DIRENT_UNKNOWN]], + common.mustCall((err, names) => { + assert.strictEqual(err, null); + assert.strictEqual(names.length, 1); + }, + )); +} +{ + // string + Buffer + getDirents( + tmpdir.path, + [[Buffer.from(filename)], [UV_DIRENT_UNKNOWN]], + common.mustCall((err, names) => { + assert.strictEqual(err, null); + assert.strictEqual(names.length, 1); + }, + )); +} +{ + // Buffer + Buffer + getDirents( + Buffer.from(tmpdir.path), + [[Buffer.from(filename)], [UV_DIRENT_UNKNOWN]], + common.mustCall((err, names) => { + assert.strictEqual(err, null); + assert.strictEqual(names.length, 1); + }, + )); +} +{ + // wrong combination + getDirents( + 42, + [[Buffer.from(filename)], [UV_DIRENT_UNKNOWN]], + common.mustCall((err) => { + assert.strictEqual( + err.message, + [ + 'The "path" argument must be of type string or an ' + + 'instance of Buffer. Received type number (42)' + ].join('')); + }, + )); +} +// getDirent +{ + // string + string + getDirent( + tmpdir.path, + filename, + UV_DIRENT_UNKNOWN, + common.mustCall((err, dirent) => { + assert.strictEqual(err, null); + assert.strictEqual(dirent.name, filename); + }, + )); +} +{ + // string + Buffer + const filenameBuffer = Buffer.from(filename); + getDirent( + tmpdir.path, + filenameBuffer, + UV_DIRENT_UNKNOWN, + common.mustCall((err, dirent) => { + assert.strictEqual(err, null); + assert.strictEqual(dirent.name, filenameBuffer); + }, + )); +} +{ + // Buffer + Buffer + const filenameBuffer = Buffer.from(filename); + getDirent( + Buffer.from(tmpdir.path), + filenameBuffer, + UV_DIRENT_UNKNOWN, + common.mustCall((err, dirent) => { + assert.strictEqual(err, null); + assert.strictEqual(dirent.name, filenameBuffer); + }, + )); +} +{ + // wrong combination + getDirent( + 42, + Buffer.from(filename), + UV_DIRENT_UNKNOWN, + common.mustCall((err) => { + assert.strictEqual( + err.message, + [ + 'The "path" argument must be of type string or an ' + + 'instance of Buffer. Received type number (42)' + ].join('')); + }, + )); +} diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index c5ed73733c5c40..b72d263cf6ce50 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -31,15 +31,14 @@ tmpdir.refresh(); function stat_resource(resource) { if (typeof resource === 'string') { return fs.statSync(resource); - } else { - const stats = fs.fstatSync(resource); - // Ensure mtime has been written to disk - // except for directories on AIX where it cannot be synced - if (common.isAIX && stats.isDirectory()) - return stats; - fs.fsyncSync(resource); - return fs.fstatSync(resource); } + const stats = fs.fstatSync(resource); + // Ensure mtime has been written to disk + // except for directories on AIX where it cannot be synced + if (common.isAIX && stats.isDirectory()) + return stats; + fs.fsyncSync(resource); + return fs.fstatSync(resource); } function check_mtime(resource, mtime) { diff --git a/test/parallel/test-http-destroyed-socket-write2.js b/test/parallel/test-http-destroyed-socket-write2.js index 551cea19829d93..6878b16085f0c3 100644 --- a/test/parallel/test-http-destroyed-socket-write2.js +++ b/test/parallel/test-http-destroyed-socket-write2.js @@ -47,6 +47,7 @@ server.listen(0, function() { } req.on('error', common.mustCall(function(er) { + assert.strictEqual(req.res, null); switch (er.code) { // This is the expected case case 'ECONNRESET': @@ -73,10 +74,7 @@ server.listen(0, function() { server.close(); })); - req.on('response', function(res) { - res.on('data', common.mustNotCall('Should not receive response data')); - res.on('end', common.mustNotCall('Should not receive response end')); - }); + req.on('response', common.mustNotCall()); write(); }); diff --git a/test/parallel/test-http-outgoing-end-types.js b/test/parallel/test-http-outgoing-end-types.js new file mode 100644 index 00000000000000..20b443bff2c1f5 --- /dev/null +++ b/test/parallel/test-http-outgoing-end-types.js @@ -0,0 +1,18 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +const httpServer = http.createServer(common.mustCall(function(req, res) { + httpServer.close(); + assert.throws(() => { + res.end(['Throws.']); + }, { + code: 'ERR_INVALID_ARG_TYPE' + }); + res.end(); +})); + +httpServer.listen(0, common.mustCall(function() { + http.get({ port: this.address().port }); +})); diff --git a/test/parallel/test-http2-compat-serverresponse-end.js b/test/parallel/test-http2-compat-serverresponse-end.js index 8505d6c4969db1..52d4c603e95e04 100644 --- a/test/parallel/test-http2-compat-serverresponse-end.js +++ b/test/parallel/test-http2-compat-serverresponse-end.js @@ -25,16 +25,16 @@ const { // but callback will only be called once const server = createServer(mustCall((request, response) => { response.end('end', 'utf8', mustCall(() => { - response.end(mustNotCall()); + response.end(mustCall()); process.nextTick(() => { - response.end(mustNotCall()); + response.end(mustCall()); server.close(); }); })); response.on('finish', mustCall(() => { - response.end(mustNotCall()); + response.end(mustCall()); })); - response.end(mustNotCall()); + response.end(mustCall()); })); server.listen(0, mustCall(() => { let data = ''; @@ -294,7 +294,7 @@ const { })); response.end('data', mustCall(() => { strictEqual(finished, false); - response.end('data', mustNotCall()); + response.end('data', mustCall()); })); })); server.listen(0, mustCall(() => { @@ -328,7 +328,7 @@ const { // Should be able to respond to HEAD with just .end const server = createServer(mustCall((request, response) => { response.end('data', mustCall()); - response.end(mustNotCall()); + response.end(mustCall()); })); server.listen(0, mustCall(() => { const { port } = server.address(); diff --git a/test/parallel/test-http2-compat-serverresponse-headers.js b/test/parallel/test-http2-compat-serverresponse-headers.js index 14e480f611857a..96875e1bce3400 100644 --- a/test/parallel/test-http2-compat-serverresponse-headers.js +++ b/test/parallel/test-http2-compat-serverresponse-headers.js @@ -102,11 +102,13 @@ server.listen(0, common.mustCall(function() { response.setHeader(real, expectedValue); const expectedHeaderNames = [real]; assert.deepStrictEqual(response.getHeaderNames(), expectedHeaderNames); - const expectedHeaders = { [real]: expectedValue }; + const expectedHeaders = Object.create(null); + expectedHeaders[real] = expectedValue; assert.deepStrictEqual(response.getHeaders(), expectedHeaders); response.getHeaders()[fake] = fake; assert.strictEqual(response.hasHeader(fake), false); + assert.strictEqual(Object.getPrototypeOf(response.getHeaders()), null); assert.strictEqual(response.sendDate, true); response.sendDate = false; diff --git a/test/parallel/test-http2-res-corked.js b/test/parallel/test-http2-res-corked.js new file mode 100644 index 00000000000000..5a6c623edf0f82 --- /dev/null +++ b/test/parallel/test-http2-res-corked.js @@ -0,0 +1,54 @@ +'use strict'; +const common = require('../common'); +if (!common.hasCrypto) { common.skip('missing crypto'); } + +// Test for Http2ServerResponse#[writableCorked,cork,uncork] + +const { strictEqual } = require('assert'); +const http2 = require('http2'); + +{ + let corksLeft = 0; + const server = http2.createServer(common.mustCall((req, res) => { + strictEqual(res.writableCorked, corksLeft); + res.write(Buffer.from('1'.repeat(1024))); + res.cork(); + corksLeft++; + strictEqual(res.writableCorked, corksLeft); + res.write(Buffer.from('1'.repeat(1024))); + res.cork(); + corksLeft++; + strictEqual(res.writableCorked, corksLeft); + res.write(Buffer.from('1'.repeat(1024))); + res.cork(); + corksLeft++; + strictEqual(res.writableCorked, corksLeft); + res.write(Buffer.from('1'.repeat(1024))); + res.cork(); + corksLeft++; + strictEqual(res.writableCorked, corksLeft); + res.uncork(); + corksLeft--; + strictEqual(res.writableCorked, corksLeft); + res.uncork(); + corksLeft--; + strictEqual(res.writableCorked, corksLeft); + res.uncork(); + corksLeft--; + strictEqual(res.writableCorked, corksLeft); + res.uncork(); + corksLeft--; + strictEqual(res.writableCorked, corksLeft); + res.end(); + })); + server.listen(0, common.mustCall(() => { + const URL = `http://localhost:${server.address().port}`; + const client = http2.connect(URL); + const req = client.request(); + req.on('data', common.mustCall(2)); + req.on('end', common.mustCall(() => { + server.close(); + client.close(); + })); + })); +} diff --git a/test/parallel/test-http2-res-writable-properties.js b/test/parallel/test-http2-res-writable-properties.js new file mode 100644 index 00000000000000..488cb1babf3e8a --- /dev/null +++ b/test/parallel/test-http2-res-writable-properties.js @@ -0,0 +1,30 @@ +'use strict'; +const common = require('../common'); +if (!common.hasCrypto) { common.skip('missing crypto'); } +const assert = require('assert'); +const http2 = require('http2'); + +const server = http2.createServer(common.mustCall((req, res) => { + const hwm = req.socket.writableHighWaterMark; + assert.strictEqual(res.writableHighWaterMark, hwm); + assert.strictEqual(res.writableLength, 0); + res.write(''); + const len = res.writableLength; + res.write('asd'); + assert.strictEqual(res.writableLength, len + 3); + res.end(); + res.on('finish', common.mustCall(() => { + assert.strictEqual(res.writableLength, 0); + assert.ok(res.writableFinished, 'writableFinished is not truthy'); + server.close(); + })); +})); + +server.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + const request = client.request(); + request.on('data', common.mustCall()); + request.on('end', common.mustCall(() => { + client.close(); + })); +})); diff --git a/test/parallel/test-icu-stringwidth.js b/test/parallel/test-icu-stringwidth.js index 4e8389961d0d6d..66142a8d6811c0 100644 --- a/test/parallel/test-icu-stringwidth.js +++ b/test/parallel/test-icu-stringwidth.js @@ -2,9 +2,6 @@ 'use strict'; const common = require('../common'); -if (!common.hasIntl) - common.skip('missing Intl'); - const assert = require('assert'); const { getStringWidth } = require('internal/util/inspect'); @@ -88,7 +85,7 @@ for (let i = 0; i < 256; i++) { } } -{ +if (common.hasIntl) { const a = '한글'.normalize('NFD'); // 한글 const b = '한글'.normalize('NFC'); // 한글 assert.strictEqual(a.length, 6); diff --git a/test/parallel/test-macos-app-sandbox.js b/test/parallel/test-macos-app-sandbox.js new file mode 100644 index 00000000000000..f7fcf5e5728815 --- /dev/null +++ b/test/parallel/test-macos-app-sandbox.js @@ -0,0 +1,65 @@ +'use strict'; +const common = require('../common'); +if (process.platform !== 'darwin') + common.skip('App Sandbox is only avaliable on Darwin'); + +const fixtures = require('../common/fixtures'); +const tmpdir = require('../common/tmpdir'); +const assert = require('assert'); +const child_process = require('child_process'); +const path = require('path'); +const fs = require('fs'); +const os = require('os'); + +const nodeBinary = process.execPath; + +tmpdir.refresh(); + +const appBundlePath = path.join(tmpdir.path, 'node_sandboxed.app'); +const appBundleContentPath = path.join(appBundlePath, 'Contents'); +const appExecutablePath = path.join( + appBundleContentPath, 'MacOS', 'node'); + +// Construct the app bundle and put the node executable in it: +// node_sandboxed.app/ +// └── Contents +// ├── Info.plist +// ├── MacOS +// │ └── node +fs.mkdirSync(appBundlePath); +fs.mkdirSync(appBundleContentPath); +fs.mkdirSync(path.join(appBundleContentPath, 'MacOS')); +fs.copyFileSync( + fixtures.path('macos-app-sandbox', 'Info.plist'), + path.join(appBundleContentPath, 'Info.plist')); +fs.copyFileSync( + nodeBinary, + appExecutablePath); + + +// Sign the app bundle with sandbox entitlements: +assert.strictEqual( + child_process.spawnSync('/usr/bin/codesign', [ + '--entitlements', fixtures.path( + 'macos-app-sandbox', 'node_sandboxed.entitlements'), + '-s', '-', + appBundlePath + ]).status, + 0); + +// Sandboxed app shouldn't be able to read the home dir +assert.notStrictEqual( + child_process.spawnSync(appExecutablePath, [ + '-e', 'fs.readdirSync(process.argv[1])', os.homedir() + ]).status, + 0); + +if (process.stdin.isTTY) { + // Run the sandboxed node instance with inherited tty stdin + const spawnResult = child_process.spawnSync( + appExecutablePath, ['-e', ''], + { stdio: 'inherit' } + ); + + assert.strictEqual(spawnResult.signal, null); +} diff --git a/test/parallel/test-module-binding.js b/test/parallel/test-module-binding.js index d0e122605ddc00..a0fa0a038990f0 100644 --- a/test/parallel/test-module-binding.js +++ b/test/parallel/test-module-binding.js @@ -6,11 +6,32 @@ const { internalBinding } = require('internal/test/binding'); const { internalModuleReadJSON } = internalBinding('fs'); const { readFileSync } = require('fs'); const { strictEqual } = require('assert'); - -strictEqual(internalModuleReadJSON('nosuchfile'), undefined); -strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), '{}'); -strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')), '{}'); +{ + const [string, containsKeys] = internalModuleReadJSON('nosuchfile'); + strictEqual(string, undefined); + strictEqual(containsKeys, undefined); +} +{ + const [string, containsKeys] = + internalModuleReadJSON(fixtures.path('empty.txt')); + strictEqual(string, ''); + strictEqual(containsKeys, false); +} +{ + const [string, containsKeys] = + internalModuleReadJSON(fixtures.path('empty.txt')); + strictEqual(string, ''); + strictEqual(containsKeys, false); +} +{ + const [string, containsKeys] = + internalModuleReadJSON(fixtures.path('empty-with-bom.txt')); + strictEqual(string, ''); + strictEqual(containsKeys, false); +} { const filename = fixtures.path('require-bin/package.json'); - strictEqual(internalModuleReadJSON(filename), readFileSync(filename, 'utf8')); + const [string, containsKeys] = internalModuleReadJSON(filename); + strictEqual(string, readFileSync(filename, 'utf8')); + strictEqual(containsKeys, true); } diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index 99a02eda22fb1d..e87ee10e43df84 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -103,10 +103,9 @@ function pingPongTest(port, host) { assert.strictEqual(client.writable, false); assert.strictEqual(client.readable, true); return; - } else { - assert.strictEqual(client.writable, true); - assert.strictEqual(client.readable, true); } + assert.strictEqual(client.writable, true); + assert.strictEqual(client.readable, true); if (count < N) { client.write('PING'); diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index 72d8e3315f04fc..7dbd2101dd1a9f 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -144,7 +144,8 @@ const qsWeirdObjects = [ [{ n: null }, 'n=', { 'n': '' }], [{ nan: NaN }, 'nan=', { 'nan': '' }], [{ inf: Infinity }, 'inf=', { 'inf': '' }], - [{ a: [], b: [] }, '', {}] + [{ a: [], b: [] }, '', {}], + [{ a: 1, b: [] }, 'a=1', { 'a': '1' }] ]; // }}} diff --git a/test/parallel/test-readline-position.js b/test/parallel/test-readline-position.js index f01786eaf19d3c..3603a42ecedc68 100644 --- a/test/parallel/test-readline-position.js +++ b/test/parallel/test-readline-position.js @@ -1,7 +1,6 @@ // Flags: --expose-internals 'use strict'; const common = require('../common'); -const { internalBinding } = require('internal/test/binding'); const { PassThrough } = require('stream'); const readline = require('readline'); const assert = require('assert'); @@ -21,22 +20,14 @@ common.skipIfDumbTerminal(); const tests = [ [1, 'a'], [2, 'ab'], - [2, '丁'] + [2, '丁'], + [0, '\u0301'], // COMBINING ACUTE ACCENT + [1, 'a\u0301'], // á + [0, '\u20DD'], // COMBINING ENCLOSING CIRCLE + [2, 'a\u20DDb'], // a⃝b + [0, '\u200E'], // LEFT-TO-RIGHT MARK ]; - // The non-ICU JS implementation of character width calculation is only aware - // of the wide/narrow distinction. Only test these more advanced cases when - // ICU is available. - if (internalBinding('config').hasIntl) { - tests.push( - [0, '\u0301'], // COMBINING ACUTE ACCENT - [1, 'a\u0301'], // á - [0, '\u20DD'], // COMBINING ENCLOSING CIRCLE - [2, 'a\u20DDb'], // a⃝b - [0, '\u200E'] // LEFT-TO-RIGHT MARK - ); - } - for (const [cursor, string] of tests) { rl.write(string); assert.strictEqual(rl.getCursorPos().cols, cursor); diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js index 48e9e37605a085..018d8707009ad9 100644 --- a/test/parallel/test-repl-top-level-await.js +++ b/test/parallel/test-repl-top-level-await.js @@ -116,7 +116,7 @@ async function ordinaryTests() { ['await 0; function foo() {}'], ['foo', '[Function: foo]'], ['class Foo {}; await 1;', '1'], - ['Foo', '[Function: Foo]'], + ['Foo', '[class Foo]'], ['if (await true) { function bar() {}; }'], ['bar', '[Function: bar]'], ['if (await true) { class Bar {}; }'], diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 9b8578293d9e52..73a919e5eacb3c 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -754,6 +754,39 @@ const errorTests = [ /^Uncaught SyntaxError: / ] }, + { + send: 'console', + expect: [ + '{', + ' log: [Function: log],', + ' warn: [Function: warn],', + ' dir: [Function: dir],', + ' time: [Function: time],', + ' timeEnd: [Function: timeEnd],', + ' timeLog: [Function: timeLog],', + ' trace: [Function: trace],', + ' assert: [Function: assert],', + ' clear: [Function: clear],', + ' count: [Function: count],', + ' countReset: [Function: countReset],', + ' group: [Function: group],', + ' groupEnd: [Function: groupEnd],', + ' table: [Function: table],', + / debug: \[Function: (debug|log)],/, + / info: \[Function: (info|log)],/, + / dirxml: \[Function: (dirxml|log)],/, + / error: \[Function: (error|warn)],/, + / groupCollapsed: \[Function: (groupCollapsed|group)],/, + / Console: \[Function: Console],?/, + ...process.features.inspector ? [ + ' profile: [Function: profile],', + ' profileEnd: [Function: profileEnd],', + ' timeStamp: [Function: timeStamp],', + ' context: [Function: context]', + ] : [], + '}', + ] + }, ]; const tcpTests = [ diff --git a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js index f1e74ad949c590..7be2c358eedd95 100644 --- a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js +++ b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js @@ -95,8 +95,7 @@ function test2() { r._read = function(n) { if (!reads--) return r.push(null); // EOF - else - return r.push(Buffer.from('x')); + return r.push(Buffer.from('x')); }; const results = []; diff --git a/test/parallel/test-tls-root-certificates.js b/test/parallel/test-tls-root-certificates.js index f200231fa301a5..5f7aa418ac05a3 100644 --- a/test/parallel/test-tls-root-certificates.js +++ b/test/parallel/test-tls-root-certificates.js @@ -2,49 +2,30 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); -const fixtures = require('../common/fixtures'); const assert = require('assert'); const tls = require('tls'); -const { fork } = require('child_process'); - -if (process.argv[2] !== 'child') { - // Parent - const NODE_EXTRA_CA_CERTS = fixtures.path('keys', 'ca1-cert.pem'); - - fork( - __filename, - ['child'], - { env: { ...process.env, NODE_EXTRA_CA_CERTS } } - ).on('exit', common.mustCall(function(status) { - assert.strictEqual(status, 0); - })); -} else { - // Child - assert(Array.isArray(tls.rootCertificates)); - assert(tls.rootCertificates.length > 0); - - // Getter should return the same object. - assert.strictEqual(tls.rootCertificates, tls.rootCertificates); - - // Array is immutable... - assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/); - assert.throws(() => tls.rootCertificates.sort(), /TypeError/); - - // ...and so is the property. - assert.throws(() => tls.rootCertificates = 0, /TypeError/); - - // Does not contain duplicates. - assert.strictEqual(tls.rootCertificates.length, - new Set(tls.rootCertificates).size); - - assert(tls.rootCertificates.every((s) => { - return s.startsWith('-----BEGIN CERTIFICATE-----\n'); - })); - - assert(tls.rootCertificates.every((s) => { - return s.endsWith('\n-----END CERTIFICATE-----\n'); - })); - - const extraCert = fixtures.readKey('ca1-cert.pem', 'utf8'); - assert(tls.rootCertificates.includes(extraCert)); -} + +assert(Array.isArray(tls.rootCertificates)); +assert(tls.rootCertificates.length > 0); + +// Getter should return the same object. +assert.strictEqual(tls.rootCertificates, tls.rootCertificates); + +// Array is immutable... +assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/); +assert.throws(() => tls.rootCertificates.sort(), /TypeError/); + +// ...and so is the property. +assert.throws(() => tls.rootCertificates = 0, /TypeError/); + +// Does not contain duplicates. +assert.strictEqual(tls.rootCertificates.length, + new Set(tls.rootCertificates).size); + +assert(tls.rootCertificates.every((s) => { + return s.startsWith('-----BEGIN CERTIFICATE-----\n'); +})); + +assert(tls.rootCertificates.every((s) => { + return s.endsWith('\n-----END CERTIFICATE-----'); +})); diff --git a/test/parallel/test-tls-transport-destroy-after-own-gc.js b/test/parallel/test-tls-transport-destroy-after-own-gc.js index 46f630982af643..9b9c8353077dfe 100644 --- a/test/parallel/test-tls-transport-destroy-after-own-gc.js +++ b/test/parallel/test-tls-transport-destroy-after-own-gc.js @@ -15,13 +15,12 @@ const makeDuplexPair = require('../common/duplexpair'); let { clientSide } = makeDuplexPair(); let clientTLS = new TLSSocket(clientSide, { isServer: false }); -// eslint-disable-next-line no-unused-vars let clientTLSHandle = clientTLS._handle; setImmediate(() => { clientTLS = null; global.gc(); - clientTLSHandle = null; + clientTLSHandle = null; // eslint-disable-line no-unused-vars global.gc(); setImmediate(() => { clientSide = null; diff --git a/test/parallel/test-trace-events-api.js b/test/parallel/test-trace-events-api.js index 676e7f31e13710..e45f374bab642c 100644 --- a/test/parallel/test-trace-events-api.js +++ b/test/parallel/test-trace-events-api.js @@ -25,9 +25,8 @@ function getEnabledCategoriesFromCommandLine() { const indexOfCatFlag = process.execArgv.indexOf('--trace-event-categories'); if (indexOfCatFlag === -1) { return undefined; - } else { - return process.execArgv[indexOfCatFlag + 1]; } + return process.execArgv[indexOfCatFlag + 1]; } const isChild = process.argv[2] === 'child'; diff --git a/test/parallel/test-trace-exit.js b/test/parallel/test-trace-exit.js index 237512ac273db1..7a4c222c40f74c 100644 --- a/test/parallel/test-trace-exit.js +++ b/test/parallel/test-trace-exit.js @@ -47,12 +47,12 @@ switch (true) { stderr.match(/WARNING: Exited the environment with code 0/g); if (warnings === 0) { assert.strictEqual(actualWarnings, null); - return; + continue; } assert.strictEqual(actualWarnings.length, warnings); if (variant.startsWith('worker')) { - const workerIds = stderr.match(/\(node:\d+, thread:\d+)/g); + const workerIds = stderr.match(/\(node:\d+, thread:\d+\)/g); assert.strictEqual(workerIds.length, warnings); } } diff --git a/test/parallel/test-ttywrap-invalid-fd.js b/test/parallel/test-ttywrap-invalid-fd.js index 5539ff22962244..ea2e0f276dbf9a 100644 --- a/test/parallel/test-ttywrap-invalid-fd.js +++ b/test/parallel/test-ttywrap-invalid-fd.js @@ -21,14 +21,13 @@ assert.throws( { const info = { - code: common.isWindows || common.isIBMi ? 'EBADF' : 'EINVAL', - message: common.isWindows || - common.isIBMi ? 'bad file descriptor' : 'invalid argument', - errno: common.isWindows || common.isIBMi ? UV_EBADF : UV_EINVAL, + code: common.isWindows ? 'EBADF' : 'EINVAL', + message: common.isWindows ? 'bad file descriptor' : 'invalid argument', + errno: common.isWindows ? UV_EBADF : UV_EINVAL, syscall: 'uv_tty_init' }; - const suffix = common.isWindows || common.isIBMi ? + const suffix = common.isWindows ? 'EBADF (bad file descriptor)' : 'EINVAL (invalid argument)'; const message = `TTY initialization failed: uv_tty_init returned ${suffix}`; diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 7bb0464335e82f..2c7a3a96fa93d2 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1968,6 +1968,88 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); ); }); +// Verify that classes are properly inspected. +[ + /* eslint-disable spaced-comment, no-multi-spaces, brace-style */ + // The whitespace is intentional. + [class { }, '[class (anonymous)]'], + [class extends Error { log() {} }, '[class (anonymous) extends Error]'], + [class A { constructor(a) { this.a = a; } log() { return this.a; } }, + '[class A]'], + [class + // Random { // comments /* */ are part of the toString() result + /* eslint-disable-next-line space-before-blocks */ + äß/**/extends/*{*/TypeError{}, '[class äß extends TypeError]'], + /* The whitespace and new line is intended! */ + // Foobar !!! + [class X extends /****/ Error + // More comments + {}, '[class X extends Error]'] + /* eslint-enable spaced-comment, no-multi-spaces, brace-style */ +].forEach(([clazz, string]) => { + const inspected = util.inspect(clazz); + assert.strictEqual(inspected, string); + Object.defineProperty(clazz, Symbol.toStringTag, { + value: 'Woohoo' + }); + const parts = inspected.slice(0, -1).split(' '); + const [, name, ...rest] = parts; + rest.unshift('[Woohoo]'); + if (rest.length) { + rest[rest.length - 1] += ']'; + } + assert.strictEqual( + util.inspect(clazz), + ['[class', name, ...rest].join(' ') + ); + if (rest.length) { + rest[rest.length - 1] = rest[rest.length - 1].slice(0, -1); + rest.length = 1; + } + Object.setPrototypeOf(clazz, null); + assert.strictEqual( + util.inspect(clazz), + ['[class', name, ...rest, 'extends [null prototype]]'].join(' ') + ); + Object.defineProperty(clazz, 'name', { value: 'Foo' }); + const res = ['[class', 'Foo', ...rest, 'extends [null prototype]]'].join(' '); + assert.strictEqual(util.inspect(clazz), res); + clazz.foo = true; + assert.strictEqual(util.inspect(clazz), `${res} { foo: true }`); +}); + +// "class" properties should not be detected as "class". +{ + // eslint-disable-next-line space-before-function-paren + let obj = { class () {} }; + assert.strictEqual( + util.inspect(obj), + '{ class: [Function: class] }' + ); + obj = { class: () => {} }; + assert.strictEqual( + util.inspect(obj), + '{ class: [Function: class] }' + ); + obj = { ['class Foo {}']() {} }; + assert.strictEqual( + util.inspect(obj), + "{ 'class Foo {}': [Function: class Foo {}] }" + ); + function Foo() {} + Object.defineProperty(Foo, 'toString', { value: () => 'class Foo {}' }); + assert.strictEqual( + util.inspect(Foo), + '[Function: Foo]' + ); + function fn() {} + Object.defineProperty(fn, 'name', { value: 'class Foo {}' }); + assert.strictEqual( + util.inspect(fn), + '[Function: class Foo {}]' + ); +} + // Verify that throwing in valueOf and toString still produces nice results. [ [new String(55), "[String: '55']"], @@ -2158,6 +2240,12 @@ assert.strictEqual( assert.deepStrictEqual(inspect.colors[bgColor], [40 + i, 49]); assert.deepStrictEqual(inspect.colors[`${bgColor}Bright`], [100 + i, 49]); }); + + // Unknown colors are handled gracefully: + const stringStyle = inspect.styles.string; + inspect.styles.string = 'UNKNOWN'; + assert.strictEqual(inspect('foobar', { colors: true }), "'foobar'"); + inspect.styles.string = stringStyle; } assert.strictEqual( diff --git a/test/parallel/test-util-promisify.js b/test/parallel/test-util-promisify.js index c18f454d2f77ef..cbbe8983fdf105 100644 --- a/test/parallel/test-util-promisify.js +++ b/test/parallel/test-util-promisify.js @@ -143,9 +143,7 @@ const stat = promisify(fs.stat); o.fn = fn; - o.fn().then(common.mustCall(function(val) { - assert(val); - })); + o.fn().then(common.mustCall((val) => assert(val))); } { diff --git a/test/parallel/test-vm-context-property-forwarding.js b/test/parallel/test-vm-context-property-forwarding.js index 800a9fa2438988..53d38c1467a5a2 100644 --- a/test/parallel/test-vm-context-property-forwarding.js +++ b/test/parallel/test-vm-context-property-forwarding.js @@ -43,3 +43,23 @@ assert.deepStrictEqual(pd_actual, pd_expected); assert.strictEqual(ctx2[1], 5); delete ctx2[1]; assert.strictEqual(ctx2[1], undefined); + +// https://github.com/nodejs/node/issues/33806 +{ + const ctx = vm.createContext(); + + Object.defineProperty(ctx, 'prop', { + get() { + return undefined; + }, + set(val) { + throw new Error('test error'); + }, + }); + + assert.throws(() => { + vm.runInContext('prop = 42', ctx); + }, { + message: 'test error', + }); +} diff --git a/test/parallel/test-worker-stdio-from-preload-module.js b/test/parallel/test-worker-stdio-from-preload-module.js new file mode 100644 index 00000000000000..e4178c58d46b21 --- /dev/null +++ b/test/parallel/test-worker-stdio-from-preload-module.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const fixtures = require('../common/fixtures'); +const { Worker } = require('worker_threads'); +const assert = require('assert'); + +// Regression test for https://github.com/nodejs/node/issues/31777: +// stdio operations coming from preload modules should count towards the +// ref count of the internal communication port on the Worker side. + +for (let i = 0; i < 10; i++) { + const w = new Worker('console.log("B");', { + execArgv: ['--require', fixtures.path('printA.js')], + eval: true, + stdout: true + }); + w.on('exit', common.mustCall(() => { + assert.strictEqual(w.stdout.read().toString(), 'A\nB\n'); + })); +} diff --git a/test/pummel/test-heapdump-env.js b/test/pummel/test-heapdump-env.js index 8175797cce4f1e..7030271469c512 100644 --- a/test/pummel/test-heapdump-env.js +++ b/test/pummel/test-heapdump-env.js @@ -5,7 +5,6 @@ require('../common'); const { validateSnapshotNodes } = require('../common/heap'); -const assert = require('assert'); // This is just using ContextifyScript as an example here, it can be replaced // with any BaseObject that we can easily instantiate here and register in @@ -16,51 +15,10 @@ const context = require('vm').createScript('const foo = 123'); validateSnapshotNodes('Node / Environment', [{ children: [ - cleanupHooksFilter, { node_name: 'Node / cleanup_hooks', edge_name: 'cleanup_hooks' }, { node_name: 'process', edge_name: 'process_object' }, { node_name: 'Node / IsolateData', edge_name: 'isolate_data' }, ] }]); -function cleanupHooksFilter(edge) { - if (edge.name !== 'cleanup_hooks') { - return false; - } - if (edge.to.type === 'native') { - verifyCleanupHooksInSnapshot(edge.to); - } else { - verifyCleanupHooksInGraph(edge.to); - } - return true; -} - -function verifyCleanupHooksInSnapshot(node) { - assert.strictEqual(node.name, 'Node / cleanup_hooks'); - const baseObjects = []; - for (const hook of node.outgoingEdges) { - for (const hookEdge of hook.to.outgoingEdges) { - if (hookEdge.name === 'arg') { - baseObjects.push(hookEdge.to); - } - } - } - // Make sure our ContextifyScript show up. - assert(baseObjects.some((node) => node.name === 'Node / ContextifyScript')); -} - -function verifyCleanupHooksInGraph(node) { - assert.strictEqual(node.name, 'Node / cleanup_hooks'); - const baseObjects = []; - for (const hook of node.edges) { - for (const hookEdge of hook.to.edges) { - if (hookEdge.name === 'arg') { - baseObjects.push(hookEdge.to); - } - } - } - // Make sure our ContextifyScript show up. - assert(baseObjects.some((node) => node.name === 'Node / ContextifyScript')); -} - console.log(context); // Make sure it's not GC'ed diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index b9507d519d8e6d..f21160a1fa2a4d 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -88,9 +88,8 @@ function pingPongTest(host, on_complete) { if (sent_final_ping) { assert.strictEqual(client.readyState, 'readOnly'); return; - } else { - assert.strictEqual(client.readyState, 'open'); } + assert.strictEqual(client.readyState, 'open'); if (count < N) { client.write('PING'); diff --git a/test/report/test-report-getreport.js b/test/report/test-report-getreport.js index 4c68b4ecbb5e48..9f1200002bbab4 100644 --- a/test/report/test-report-getreport.js +++ b/test/report/test-report-getreport.js @@ -23,6 +23,13 @@ const helper = require('../common/report'); assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []); } +{ + const error = new Error(); + error.foo = 'goo'; + helper.validateContent(process.report.getReport(error), + [['javascriptStack.errorProperties.foo', 'goo']]); +} + // Test with an invalid error argument. [null, 1, Symbol(), function() {}, 'foo'].forEach((error) => { assert.throws(() => { diff --git a/test/report/test-report-writereport.js b/test/report/test-report-writereport.js index 50514c68373d15..971afd84c22281 100644 --- a/test/report/test-report-writereport.js +++ b/test/report/test-report-writereport.js @@ -15,7 +15,7 @@ process.report.directory = tmpdir.path; function validate() { const reports = helper.findReports(process.pid, tmpdir.path); assert.strictEqual(reports.length, 1); - helper.validate(reports[0]); + helper.validate(reports[0], arguments[0]); fs.unlinkSync(reports[0]); return reports[0]; } @@ -40,6 +40,13 @@ function validate() { validate(); } +{ + const error = new Error(); + error.foo = 'goo'; + process.report.writeReport(error); + validate([['javascriptStack.errorProperties.foo', 'goo']]); +} + { // Test with a file argument. const file = process.report.writeReport('custom-name-1.json'); diff --git a/test/sequential/test-inspector-already-activated-cli.js b/test/sequential/test-inspector-already-activated-cli.js new file mode 100644 index 00000000000000..ba76d5168c14b9 --- /dev/null +++ b/test/sequential/test-inspector-already-activated-cli.js @@ -0,0 +1,19 @@ +// Flags: --inspect=0 +'use strict'; + +const common = require('../common'); +common.skipIfInspectorDisabled(); +common.skipIfWorker(); + +const assert = require('assert'); +const inspector = require('inspector'); +const wsUrl = inspector.url(); +assert(wsUrl.startsWith('ws://')); +assert.throws(() => { + inspector.open(0, undefined, false); +}, { + code: 'ERR_INSPECTOR_ALREADY_ACTIVATED' +}); +assert.strictEqual(inspector.url(), wsUrl); +inspector.close(); +assert.strictEqual(inspector.url(), undefined); diff --git a/test/sequential/test-inspector-open.js b/test/sequential/test-inspector-open.js index 967ebe49bfb764..190a99e7282e52 100644 --- a/test/sequential/test-inspector-open.js +++ b/test/sequential/test-inspector-open.js @@ -10,6 +10,10 @@ const fork = require('child_process').fork; const net = require('net'); const url = require('url'); +const kFirstOpen = 0; +const kOpenWhileOpen = 1; +const kReOpen = 2; + if (process.env.BE_CHILD) return beChild(); @@ -19,7 +23,7 @@ const child = fork(__filename, child.once('message', common.mustCall((msg) => { assert.strictEqual(msg.cmd, 'started'); - child.send({ cmd: 'open', args: [0] }); + child.send({ cmd: 'open', args: [kFirstOpen] }); child.once('message', common.mustCall(firstOpen)); })); @@ -31,7 +35,7 @@ function firstOpen(msg) { ping(port, (err) => { assert.ifError(err); // Inspector is already open, and won't be reopened, so args don't matter. - child.send({ cmd: 'open', args: [] }); + child.send({ cmd: 'open', args: [kOpenWhileOpen] }); child.once('message', common.mustCall(tryToOpenWhenOpen)); firstPort = port; }); @@ -62,7 +66,7 @@ function closeWhenOpen(msg) { function tryToCloseWhenClosed(msg) { assert.strictEqual(msg.cmd, 'url'); assert.strictEqual(msg.url, undefined); - child.send({ cmd: 'open', args: [] }); + child.send({ cmd: 'open', args: [kReOpen] }); child.once('message', common.mustCall(reopenAfterClose)); } @@ -93,7 +97,17 @@ function beChild() { process.on('message', (msg) => { if (msg.cmd === 'open') { - inspector.open(...msg.args); + if (msg.args[0] === kFirstOpen) { + inspector.open(0, false, undefined); + } else if (msg.args[0] === kOpenWhileOpen) { + assert.throws(() => { + inspector.open(0, false, undefined); + }, { + code: 'ERR_INSPECTOR_ALREADY_ACTIVATED' + }); + } else if (msg.args[0] === kReOpen) { + inspector.open(0, false, undefined); + } } if (msg.cmd === 'close') { inspector.close(); diff --git a/test/tools/test_checkimports.py b/test/tools/test_checkimports.py new file mode 100644 index 00000000000000..6e8e17cc3f9c23 --- /dev/null +++ b/test/tools/test_checkimports.py @@ -0,0 +1,77 @@ +import unittest +import sys +from contextlib import contextmanager +from os import path +sys.path.append(path.abspath(path.join(path.dirname(__file__), + '..', '..', 'tools'))) +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + +from checkimports import is_valid + +@contextmanager +def captured_output(): + tmp_out, tmp_err = StringIO(), StringIO() + old_out, old_err = sys.stdout, sys.stderr + try: + sys.stdout, sys.stderr = tmp_out, tmp_err + yield sys.stdout, sys.stderr + finally: + sys.stdout, sys.stderr = old_out, old_err + tmp_out.close() + tmp_err.close() + +class CheckImportsTest(unittest.TestCase): + fixturesDir = path.join(path.dirname(__file__), '..', '..', + 'test', 'fixtures', 'tools', 'checkimports') + + def test_unused_and_unsorted(self): + with captured_output() as (out, err): + self.assertEqual(is_valid(path.join(self.fixturesDir, 'invalid.cc')), + False) + output = out.getvalue() + self.assertIn('does not use "Local"', output); + self.assertIn('using statements aren\'t sorted in', output); + self.assertIn('Line 1: Actual: v8::MaybeLocal, Expected: v8::Array', + output); + self.assertIn('Line 2: Actual: v8::Array, Expected: v8::Local', + output); + self.assertIn('Line 3: Actual: v8::Local, Expected: v8::MaybeLocal', + output); + + def test_unused_complex(self): + with captured_output() as (out, err): + self.assertEqual(is_valid(path.join(self.fixturesDir, 'maybe.cc')), + False) + output = out.getvalue() + self.assertIn('does not use "Local"', output); + + def test_unused_simple(self): + with captured_output() as (out, err): + self.assertEqual(is_valid(path.join(self.fixturesDir, 'unused.cc')), + False) + output = out.getvalue() + self.assertIn('does not use "Context"', output); + + def test_unsorted(self): + with captured_output() as (out, err): + self.assertEqual(is_valid(path.join(self.fixturesDir, 'unsorted.cc')), + False) + output = out.getvalue() + self.assertIn('using statements aren\'t sorted in', output); + self.assertIn('Line 1: Actual: v8::MaybeLocal, Expected: v8::Array', + output); + self.assertIn('Line 2: Actual: v8::Array, Expected: v8::MaybeLocal', + output); + + def test_valid(self): + with captured_output() as (out, err): + self.assertEqual(is_valid(path.join(self.fixturesDir, 'valid.cc')), + True) + output = out.getvalue() + self.assertEqual(output, ''); + +if __name__ == '__main__': + unittest.main() diff --git a/test/wasi/c/poll.c b/test/wasi/c/poll.c index 6b6ef71fd68c3b..9afb6325a98a03 100644 --- a/test/wasi/c/poll.c +++ b/test/wasi/c/poll.c @@ -2,30 +2,72 @@ #include #include #include +#include +#include int main(void) { - struct pollfd fds[2]; + struct pollfd fds[4]; time_t before, now; int ret; + char* platform; + int is_aix; + int is_win; + platform = getenv("NODE_PLATFORM"); + is_aix = platform != NULL && 0 == strcmp(platform, "aix"); + is_win = platform != NULL && 0 == strcmp(platform, "win32"); + + // Test sleep() behavior. + time(&before); + sleep(1); + time(&now); + assert(now - before >= 1); + + // Test poll() timeout behavior. + fds[0] = (struct pollfd){.fd = -1, .events = 0, .revents = 0}; + time(&before); + ret = poll(fds, 1, 2000); + time(&now); + assert(ret == 0); + assert(now - before >= 2); + + // The rest of the test is unsupported on Windows. + if (is_win) + return 0; + + fds[0] = (struct pollfd){.fd = 1, .events = POLLOUT, .revents = 0}; + fds[1] = (struct pollfd){.fd = 2, .events = POLLOUT, .revents = 0}; + + ret = poll(fds, 2, -1); + assert(ret == 2); + assert(fds[0].revents == POLLOUT); + assert(fds[1].revents == POLLOUT); + + // Make a poll() call with duplicate file descriptors. fds[0] = (struct pollfd){.fd = 1, .events = POLLOUT, .revents = 0}; fds[1] = (struct pollfd){.fd = 2, .events = POLLOUT, .revents = 0}; + fds[2] = (struct pollfd){.fd = 1, .events = POLLOUT, .revents = 0}; + fds[3] = (struct pollfd){.fd = 1, .events = POLLIN, .revents = 0}; ret = poll(fds, 2, -1); assert(ret == 2); assert(fds[0].revents == POLLOUT); assert(fds[1].revents == POLLOUT); + assert(fds[2].revents == 0); + assert(fds[3].revents == 0); + // The original version of this test expected a timeout and return value of + // zero. In the Node test suite, STDIN is not a TTY, and poll() returns one, + // with revents = POLLHUP | POLLIN, except on AIX whose poll() does not + // support POLLHUP. fds[0] = (struct pollfd){.fd = 0, .events = POLLIN, .revents = 0}; - time(&before); ret = poll(fds, 1, 2000); - time(&now); - assert(ret == 0); - assert(now - before >= 2); + assert(ret == 1); - sleep(1); - time(&now); - assert(now - before >= 3); + if (is_aix) + assert(fds[0].revents == POLLIN); + else + assert(fds[0].revents == (POLLHUP | POLLIN)); return 0; } diff --git a/test/wasi/test-wasi-options-validation.js b/test/wasi/test-wasi-options-validation.js index 36411bc179cab8..913095631aa22f 100644 --- a/test/wasi/test-wasi-options-validation.js +++ b/test/wasi/test-wasi-options-validation.js @@ -25,6 +25,18 @@ assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); }, assert.throws(() => { new WASI({ returnOnExit: 'fhqwhgads' }); }, { code: 'ERR_INVALID_ARG_TYPE', message: /\breturnOnExit\b/ }); +// If stdin is not an int32 and not undefined, it should throw. +assert.throws(() => { new WASI({ stdin: 'fhqwhgads' }); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bstdin\b/ }); + +// If stdout is not an int32 and not undefined, it should throw. +assert.throws(() => { new WASI({ stdout: 'fhqwhgads' }); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bstdout\b/ }); + +// If stderr is not an int32 and not undefined, it should throw. +assert.throws(() => { new WASI({ stderr: 'fhqwhgads' }); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bstderr\b/ }); + // If options is provided, but not an object, the constructor should throw. [null, 'foo', '', 0, NaN, Symbol(), true, false, () => {}].forEach((value) => { assert.throws(() => { new WASI(value); }, diff --git a/test/wasi/test-wasi-start-validation.js b/test/wasi/test-wasi-start-validation.js index 617738442ee64a..3134514d704595 100644 --- a/test/wasi/test-wasi-start-validation.js +++ b/test/wasi/test-wasi-start-validation.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert'); +const vm = require('vm'); const { WASI } = require('wasi'); const fixtures = require('../common/fixtures'); @@ -15,7 +16,10 @@ const bufferSource = fixtures.readSync('simple.wasm'); assert.throws( () => { wasi.start(); }, - { code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Instance\b/ } + { + code: 'ERR_INVALID_ARG_TYPE', + message: /"instance" argument must be of type object/ + } ); } @@ -87,11 +91,79 @@ const bufferSource = fixtures.readSync('simple.wasm'); () => { wasi.start(instance); }, { code: 'ERR_INVALID_ARG_TYPE', - message: /"instance\.exports\.memory" property .+ WebAssembly\.Memory/ + message: /"instance\.exports\.memory" property must be of type object/ + } + ); + } + + { + // Verify that a non-ArrayBuffer memory.buffer is rejected. + const wasi = new WASI({}); + const wasm = await WebAssembly.compile(bufferSource); + const instance = await WebAssembly.instantiate(wasm); + + Object.defineProperty(instance, 'exports', { + get() { + return { + _start() {}, + memory: {}, + }; + } + }); + // The error message is a little white lie because any object + // with a .buffer property of type ArrayBuffer is accepted, + // but 99% of the time a WebAssembly.Memory object is used. + assert.throws( + () => { wasi.start(instance); }, + { + code: 'ERR_INVALID_ARG_TYPE', + message: /"instance\.exports\.memory\.buffer" property must be an WebAssembly\.Memory/ } ); } + { + // Verify that an argument that duck-types as a WebAssembly.Instance + // is accepted. + const wasi = new WASI({}); + const wasm = await WebAssembly.compile(bufferSource); + const instance = await WebAssembly.instantiate(wasm); + + Object.defineProperty(instance, 'exports', { + get() { + return { + _start() {}, + memory: { buffer: new ArrayBuffer(0) }, + }; + } + }); + wasi.start(instance); + } + + { + // Verify that a WebAssembly.Instance from another VM context is accepted. + const wasi = new WASI({}); + const instance = await vm.runInNewContext(` + (async () => { + const wasm = await WebAssembly.compile(bufferSource); + const instance = await WebAssembly.instantiate(wasm); + + Object.defineProperty(instance, 'exports', { + get() { + return { + _start() {}, + memory: new WebAssembly.Memory({ initial: 1 }) + }; + } + }); + + return instance; + })() + `, { bufferSource }); + + wasi.start(instance); + } + { // Verify that start() can only be called once. const wasi = new WASI({}); diff --git a/test/wasi/test-wasi-stdio.js b/test/wasi/test-wasi-stdio.js new file mode 100644 index 00000000000000..4abe3c1ad8ae0d --- /dev/null +++ b/test/wasi/test-wasi-stdio.js @@ -0,0 +1,34 @@ +// Flags: --experimental-wasi-unstable-preview1 --experimental-wasm-bigint +'use strict'; +require('../common'); +const tmpdir = require('../common/tmpdir'); +const { strictEqual } = require('assert'); +const { closeSync, openSync, readFileSync, writeFileSync } = require('fs'); +const { join } = require('path'); +const { WASI } = require('wasi'); +const modulePath = join(__dirname, 'wasm', 'stdin.wasm'); +const buffer = readFileSync(modulePath); +const stdinFile = join(tmpdir.path, 'stdin.txt'); +const stdoutFile = join(tmpdir.path, 'stdout.txt'); +const stderrFile = join(tmpdir.path, 'stderr.txt'); + +tmpdir.refresh(); +// Write 33 x's. The test's buffer only holds 31 x's + a terminator. +writeFileSync(stdinFile, 'x'.repeat(33)); + +const stdin = openSync(stdinFile, 'r'); +const stdout = openSync(stdoutFile, 'a'); +const stderr = openSync(stderrFile, 'a'); +const wasi = new WASI({ stdin, stdout, stderr, returnOnExit: true }); +const importObject = { wasi_snapshot_preview1: wasi.wasiImport }; + +(async () => { + const { instance } = await WebAssembly.instantiate(buffer, importObject); + + strictEqual(wasi.start(instance), 0); + closeSync(stdin); + closeSync(stdout); + closeSync(stderr); + strictEqual(readFileSync(stdoutFile, 'utf8').trim(), 'x'.repeat(31)); + strictEqual(readFileSync(stderrFile, 'utf8').trim(), ''); +})(); diff --git a/test/wasi/test-wasi-worker-terminate.js b/test/wasi/test-wasi-worker-terminate.js new file mode 100644 index 00000000000000..118c2a9d47e411 --- /dev/null +++ b/test/wasi/test-wasi-worker-terminate.js @@ -0,0 +1,44 @@ +// Flags: --experimental-wasi-unstable-preview1 +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const { WASI } = require('wasi'); +const { Worker, parentPort } = require('worker_threads'); + +// void _start(void) { for (;;); } +const bytecode = new Uint8Array([ + 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60, + 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x04, 0x05, 0x01, 0x70, 0x01, 0x01, + 0x01, 0x05, 0x03, 0x01, 0x00, 0x02, 0x06, 0x08, 0x01, 0x7f, 0x01, 0x41, + 0x80, 0x88, 0x04, 0x0b, 0x07, 0x13, 0x02, 0x06, 0x6d, 0x65, 0x6d, 0x6f, + 0x72, 0x79, 0x02, 0x00, 0x06, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x00, + 0x00, 0x0a, 0x09, 0x01, 0x07, 0x00, 0x03, 0x40, 0x0c, 0x00, 0x0b, 0x0b, + 0x00, 0x10, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x01, 0x09, 0x01, 0x00, 0x06, + 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x00, 0x2f, 0x09, 0x70, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x65, 0x72, 0x73, 0x01, 0x0c, 0x70, 0x72, 0x6f, 0x63, + 0x65, 0x73, 0x73, 0x65, 0x64, 0x2d, 0x62, 0x79, 0x01, 0x05, 0x63, 0x6c, + 0x61, 0x6e, 0x67, 0x0f, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2d, 0x34, + 0x75, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x31 +]); + +// Do not use isMainThread so that this test itself can be run inside a Worker. +if (!process.env.HAS_STARTED_WORKER) { + process.env.HAS_STARTED_WORKER = 1; + const worker = new Worker(__filename); + worker.once('message', (message) => { + assert.strictEqual(message, 'start'); + setTimeout(() => worker.terminate(), common.platformTimeout(50)); + }); +} else { + go(); +} + +async function go() { + const wasi = new WASI({ returnOnExit: true }); + const imports = { wasi_snapshot_preview1: wasi.wasiImport }; + const module = await WebAssembly.compile(bytecode); + const instance = await WebAssembly.instantiate(module, imports); + parentPort.postMessage('start'); + wasi.start(instance); +} diff --git a/test/wasi/test-wasi.js b/test/wasi/test-wasi.js index 89d8f73d684833..e4bd44e83d186c 100644 --- a/test/wasi/test-wasi.js +++ b/test/wasi/test-wasi.js @@ -38,7 +38,13 @@ if (process.argv[2] === 'wasi-child') { function runWASI(options) { console.log('executing', options.test); - const opts = { env: { ...process.env, NODE_DEBUG_NATIVE: 'wasi' } }; + const opts = { + env: { + ...process.env, + NODE_DEBUG_NATIVE: 'wasi', + NODE_PLATFORM: process.platform + } + }; if (options.stdin !== undefined) opts.input = options.stdin; @@ -75,7 +81,7 @@ if (process.argv[2] === 'wasi-child') { runWASI({ test: 'link' }); runWASI({ test: 'main_args' }); runWASI({ test: 'notdir' }); - // runWASI({ test: 'poll' }); + runWASI({ test: 'poll' }); runWASI({ test: 'preopen_populates' }); runWASI({ test: 'read_file', stdout: `hello from input.txt${EOL}` }); runWASI({ diff --git a/test/wasi/wasm/poll.wasm b/test/wasi/wasm/poll.wasm index 90b39c502ef4db..37e17b8d880ad2 100755 Binary files a/test/wasi/wasm/poll.wasm and b/test/wasi/wasm/poll.wasm differ diff --git a/tools/check-imports.py b/tools/checkimports.py similarity index 84% rename from tools/check-imports.py rename to tools/checkimports.py index 51b4e63aa03903..609a75f542748f 100755 --- a/tools/check-imports.py +++ b/tools/checkimports.py @@ -9,7 +9,7 @@ def do_exist(file_name, lines, imported): if not any(not re.match('using \w+::{0};'.format(imported), line) and - re.search(imported, line) for line in lines): + re.search('\\b{0}\\b'.format(imported), line) for line in lines): print('File "{0}" does not use "{1}"'.format(file_name, imported)) return False return True @@ -40,4 +40,6 @@ def is_valid(file_name): else: return valid -sys.exit(0 if all(map(is_valid, glob.iglob('src/*.cc'))) else 1) +if __name__ == '__main__': + files = glob.iglob(sys.argv[1] if len(sys.argv) > 1 else 'src/*.cc') + sys.exit(0 if all(map(is_valid, files)) else 1) diff --git a/tools/code_cache/cache_builder.cc b/tools/code_cache/cache_builder.cc index 28d61a6c70c467..837357a0fbda76 100644 --- a/tools/code_cache/cache_builder.cc +++ b/tools/code_cache/cache_builder.cc @@ -13,10 +13,7 @@ namespace node { namespace native_module { using v8::Context; -using v8::Function; -using v8::Isolate; using v8::Local; -using v8::MaybeLocal; using v8::ScriptCompiler; static std::string GetDefName(const std::string& id) { diff --git a/tools/code_cache/mkcodecache.cc b/tools/code_cache/mkcodecache.cc index fabb6a1a5d2f4d..a3f15f28092068 100644 --- a/tools/code_cache/mkcodecache.cc +++ b/tools/code_cache/mkcodecache.cc @@ -3,7 +3,6 @@ #include #include #include -#include #include "cache_builder.h" #include "debug_utils-inl.h" diff --git a/tools/doc/README.md b/tools/doc/README.md index 3679c2c23df6e2..f2f37faa653d4d 100644 --- a/tools/doc/README.md +++ b/tools/doc/README.md @@ -4,7 +4,7 @@ Here's how the node docs work. Each type of heading has a description block. -```md +```markdown # module diff --git a/tools/doc/json.js b/tools/doc/json.js index 94241d9903ef45..bcba923d907fb2 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -456,8 +456,6 @@ const maybeAncestors = r`(?:${id}\.?)*`; const callWithParams = r`\([^)]*\)`; -const noCallOrProp = '(?![.[(])'; - const maybeExtends = `(?: +extends +${maybeAncestors}${classId})?`; /* eslint-disable max-len */ @@ -478,7 +476,7 @@ const headingExpressions = [ `^${maybeBacktick}${maybeAncestors}(${id})${callWithParams}${maybeBacktick}$`, 'i') }, { type: 'property', re: RegExp( - `^${maybeClassPropertyPrefix}${maybeBacktick}${ancestors}(${id})${maybeBacktick}${noCallOrProp}$`, 'i') }, + `^${maybeClassPropertyPrefix}${maybeBacktick}${ancestors}(${id})${maybeBacktick}$`, 'i') }, ]; /* eslint-enable max-len */ @@ -508,8 +506,7 @@ function textJoin(nodes, file) { return `_${textJoin(node.children, file)}_`; } else if (node.children) { return textJoin(node.children, file); - } else { - return node.value; } + return node.value; }).join(''); } diff --git a/tools/icu/README.md b/tools/icu/README.md index 4ce7e4483fcf40..011ce1f24f7ca9 100644 --- a/tools/icu/README.md +++ b/tools/icu/README.md @@ -25,7 +25,7 @@ internationalization functionality. * Configure Node.js with the specific [ICU version](http://icu-project.org/download) you want to upgrade to, for example: -```shell +```bash ./configure \ --with-intl=small-icu \ --with-icu-source=http://download.icu-project.org/files/icu4c/58.1/icu4c-58_1-src.tgz @@ -42,7 +42,7 @@ make * Verify the Node.js build works: -```shell +```bash make test-ci ``` @@ -58,13 +58,13 @@ new Intl.DateTimeFormat('es', {month: 'long'}).format(new Date(9E8)); * Now, copy `deps/icu` over to `deps/icu-small` -```shell +```bash python tools/icu/shrink-icu-src.py ``` * Now, do a clean rebuild of Node.js to test: -```shell +```bash make -k distclean ./configure make @@ -86,7 +86,7 @@ so make this a separate commit from the smaller changes. * Now, rebuild the Node.js license. -```shell +```bash # clean up - remove deps/icu make clean tools/license-builder.sh @@ -96,7 +96,7 @@ tools/license-builder.sh It should match the ICU URL used in the first step. When this is done, the following should build with full ICU. -```shell +```bash # clean up rm -rf out deps/icu deps/icu4c* ./configure --with-intl=full-icu --download=all diff --git a/tools/js2c.py b/tools/js2c.py index 4594694a2cab0d..195e6a6189a989 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -178,6 +178,7 @@ def write_if_chaged(content, target): else: old_content = '' if old_content == content: + os.utime(target, None) return with open(target, "wt") as output: output.write(content) diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 14eb4514a6c3ec..8f58a8f2986660 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -103,6 +103,9 @@ addlicense "brotli" "deps/brotli" "$(cat ${rootdir}/deps/brotli/LICENSE)" addlicense "HdrHistogram" "deps/histogram" "$(cat ${rootdir}/deps/histogram/LICENSE.txt)" +addlicense "highlight.js" "doc/api_assets/highlight.pack.js" \ + "$(curl -sL https://raw.githubusercontent.com/highlightjs/highlight.js/63f367c46f2eeb6f9b7a3545e325eeeb917f9942/LICENSE)" + addlicense "node-heapdump" "src/heap_utils.cc" \ "$(curl -sL https://raw.githubusercontent.com/bnoordhuis/node-heapdump/0ca52441e46241ffbea56a389e2856ec01c48c97/LICENSE)" diff --git a/tools/lint-md.js b/tools/lint-md.js index 5335fafb1e8f6f..c7421709febe66 100644 --- a/tools/lint-md.js +++ b/tools/lint-md.js @@ -16744,12 +16744,12 @@ var colorName$1 = { "aliceblue": [240, 248, 255], "antiquewhite": [250, 235, 215], "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], "blue": [0, 0, 255], "blueviolet": [138, 43, 226], "brown": [165, 42, 42], @@ -16882,12 +16882,12 @@ var colorName$1 = { "teal": [0, 128, 128], "thistle": [216, 191, 216], "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], "yellowgreen": [154, 205, 50] }; @@ -43322,63 +43322,10 @@ function stringify$6(options) { var remark = unified_1().use(remarkParse).use(remarkStringify).freeze(); -const _from = "remark@latest"; -const _id = "remark@12.0.0"; -const _inBundle = false; -const _integrity = "sha512-oX4lMIS0csgk8AEbzY0h2jdR0ngiCHOpwwpxjmRa5TqAkeknY+tkhjRJGZqnCmvyuWh55/0SW5WY3R3nn3PH9A=="; -const _location = "/remark"; -const _phantomChildren = { -}; -const _requested = { - type: "tag", - registry: true, - raw: "remark@latest", - name: "remark", - escapedName: "remark", - rawSpec: "latest", - saveSpec: null, - fetchSpec: "latest" -}; -const _requiredBy = [ - "#USER", - "/" -]; -const _resolved = "https://registry.npmjs.org/remark/-/remark-12.0.0.tgz"; -const _shasum = "d1c145c07341c9232f93b2f8539d56da15a2548c"; -const _spec = "remark@latest"; -const _where = "/Users/trott/io.js/tools/node-lint-md-cli-rollup"; -const author = { - name: "Titus Wormer", - email: "tituswormer@gmail.com", - url: "https://wooorm.com" -}; -const bugs = { - url: "https://github.com/remarkjs/remark/issues" -}; -const bundleDependencies = false; -const contributors = [ - { - name: "Titus Wormer", - email: "tituswormer@gmail.com", - url: "https://wooorm.com" - } -]; -const dependencies = { - "remark-parse": "^8.0.0", - "remark-stringify": "^8.0.0", - unified: "^9.0.0" -}; -const deprecated$1 = false; +const name$1 = "remark"; +const version$1 = "12.0.0"; const description = "Markdown processor powered by plugins part of the unified collective"; -const files = [ - "index.js", - "types/index.d.ts" -]; -const funding = { - type: "opencollective", - url: "https://opencollective.com/unified" -}; -const homepage = "https://remark.js.org"; +const license = "MIT"; const keywords = [ "unified", "remark", @@ -43394,83 +43341,77 @@ const keywords = [ "compile", "process" ]; -const license = "MIT"; -const name$1 = "remark"; -const repository = { - type: "git", - url: "https://github.com/remarkjs/remark/tree/master/packages/remark" +const homepage = "https://remark.js.org"; +const repository = "https://github.com/remarkjs/remark/tree/master/packages/remark"; +const bugs = "https://github.com/remarkjs/remark/issues"; +const funding = { + type: "opencollective", + url: "https://opencollective.com/unified" +}; +const author = "Titus Wormer (https://wooorm.com)"; +const contributors = [ + "Titus Wormer (https://wooorm.com)" +]; +const files = [ + "index.js", + "types/index.d.ts" +]; +const types = "types/index.d.ts"; +const dependencies = { + "remark-parse": "^8.0.0", + "remark-stringify": "^8.0.0", + unified: "^9.0.0" }; const scripts = { test: "tape test.js" }; -const types = "types/index.d.ts"; -const version$1 = "12.0.0"; const xo = false; +const _resolved = "https://registry.npmjs.org/remark/-/remark-12.0.0.tgz"; +const _integrity = "sha512-oX4lMIS0csgk8AEbzY0h2jdR0ngiCHOpwwpxjmRa5TqAkeknY+tkhjRJGZqnCmvyuWh55/0SW5WY3R3nn3PH9A=="; +const _from = "remark@12.0.0"; var _package = { - _from: _from, - _id: _id, - _inBundle: _inBundle, - _integrity: _integrity, - _location: _location, - _phantomChildren: _phantomChildren, - _requested: _requested, - _requiredBy: _requiredBy, - _resolved: _resolved, - _shasum: _shasum, - _spec: _spec, - _where: _where, - author: author, - bugs: bugs, - bundleDependencies: bundleDependencies, - contributors: contributors, - dependencies: dependencies, - deprecated: deprecated$1, + name: name$1, + version: version$1, description: description, - files: files, - funding: funding, - homepage: homepage, - keywords: keywords, license: license, - name: name$1, + keywords: keywords, + homepage: homepage, repository: repository, - scripts: scripts, + bugs: bugs, + funding: funding, + author: author, + contributors: contributors, + files: files, types: types, - version: version$1, - xo: xo + dependencies: dependencies, + scripts: scripts, + xo: xo, + _resolved: _resolved, + _integrity: _integrity, + _from: _from }; var _package$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - _from: _from, - _id: _id, - _inBundle: _inBundle, - _integrity: _integrity, - _location: _location, - _phantomChildren: _phantomChildren, - _requested: _requested, - _requiredBy: _requiredBy, - _resolved: _resolved, - _shasum: _shasum, - _spec: _spec, - _where: _where, - author: author, - bugs: bugs, - bundleDependencies: bundleDependencies, - contributors: contributors, - dependencies: dependencies, - deprecated: deprecated$1, + name: name$1, + version: version$1, description: description, - files: files, - funding: funding, - homepage: homepage, - keywords: keywords, license: license, - name: name$1, + keywords: keywords, + homepage: homepage, repository: repository, - scripts: scripts, + bugs: bugs, + funding: funding, + author: author, + contributors: contributors, + files: files, types: types, - version: version$1, + dependencies: dependencies, + scripts: scripts, xo: xo, + _resolved: _resolved, + _integrity: _integrity, + _from: _from, 'default': _package }); @@ -43488,7 +43429,7 @@ const dependencies$1 = { "markdown-extensions": "^1.1.1", remark: "^12.0.0", "remark-lint": "^7.0.0", - "remark-preset-lint-node": "^1.15.0", + "remark-preset-lint-node": "^1.16.0", "unified-args": "^8.0.0" }; const main = "dist/index.js"; @@ -44172,1535 +44113,958 @@ function lintMessageControl() { return remarkMessageControl({name: 'lint', source: 'remark-lint'}) } -var vfileLocation$2 = factory$8; - -function factory$8(file) { - var contents = indices$2(String(file)); - - return { - toPosition: offsetToPositionFactory$2(contents), - toOffset: positionToOffsetFactory$2(contents) - } -} - -// Factory to get the line and column-based `position` for `offset` in the bound -// indices. -function offsetToPositionFactory$2(indices) { - return offsetToPosition +/** + * An Array.prototype.slice.call(arguments) alternative + * + * @param {Object} args something with a length + * @param {Number} slice + * @param {Number} sliceEnd + * @api public + */ - // Get the line and column-based `position` for `offset` in the bound indices. - function offsetToPosition(offset) { - var index = -1; - var length = indices.length; +var sliced = function (args, slice, sliceEnd) { + var ret = []; + var len = args.length; - if (offset < 0) { - return {} - } + if (0 === len) return ret; - while (++index < length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset - } - } - } + var start = slice < 0 + ? Math.max(0, slice + len) + : slice || 0; - return {} + if (sliceEnd !== undefined) { + len = sliceEnd < 0 + ? sliceEnd + len + : sliceEnd; } -} -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$2(indices) { - return positionToOffset + while (len-- > start) { + ret[len - start] = args[len]; + } - // Get the `offset` for a line and column-based `position` in the bound - // indices. - function positionToOffset(position) { - var line = position && position.line; - var column = position && position.column; + return ret; +}; - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 - } +/** + * slice() reference. + */ - return -1 - } -} +var slice$4 = Array.prototype.slice; -// Get indices of line-breaks in `value`. -function indices$2(value) { - var result = []; - var index = value.indexOf('\n'); +/** + * Expose `co`. + */ - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); - } +var co_1 = co; - result.push(value.length + 1); +/** + * Wrap the given generator `fn` and + * return a thunk. + * + * @param {Function} fn + * @return {Function} + * @api public + */ - return result -} +function co(fn) { + var isGenFun = isGeneratorFunction(fn); -var convert_1$2 = convert$5; + return function (done) { + var ctx = this; -function convert$5(test) { - if (typeof test === 'string') { - return typeFactory$2(test) - } + // in toThunk() below we invoke co() + // with a generator, so optimize for + // this case + var gen = fn; - if (test === null || test === undefined) { - return ok$3 - } + // we only need to parse the arguments + // if gen is a generator function. + if (isGenFun) { + var args = slice$4.call(arguments), len = args.length; + var hasCallback = len && 'function' == typeof args[len - 1]; + done = hasCallback ? args.pop() : error; + gen = fn.apply(this, args); + } else { + done = done || error; + } - if (typeof test === 'object') { - return ('length' in test ? anyFactory$2 : matchesFactory$2)(test) - } + next(); - if (typeof test === 'function') { - return test - } + // #92 + // wrap the callback in a setImmediate + // so that any of its errors aren't caught by `co` + function exit(err, res) { + setImmediate(function(){ + done.call(ctx, err, res); + }); + } - throw new Error('Expected function, string, or object as test') -} + function next(err, res) { + var ret; -function convertAll$2(tests) { - var results = []; - var length = tests.length; - var index = -1; + // multiple args + if (arguments.length > 2) res = slice$4.call(arguments, 1); - while (++index < length) { - results[index] = convert$5(tests[index]); - } + // error + if (err) { + try { + ret = gen.throw(err); + } catch (e) { + return exit(e); + } + } - return results -} + // ok + if (!err) { + try { + ret = gen.next(res); + } catch (e) { + return exit(e); + } + } -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$2(test) { - return matches + // done + if (ret.done) return exit(null, ret.value); - function matches(node) { - var key; + // normalize + ret.value = toThunk(ret.value, ctx); - for (key in test) { - if (node[key] !== test[key]) { - return false + // run + if ('function' == typeof ret.value) { + var called = false; + try { + ret.value.call(ctx, function(){ + if (called) return; + called = true; + next.apply(ctx, arguments); + }); + } catch (e) { + setImmediate(function(){ + if (called) return; + called = true; + next(e); + }); + } + return; } - } - return true + // invalid + next(new TypeError('You may only yield a function, promise, generator, array, or object, ' + + 'but the following was passed: "' + String(ret.value) + '"')); + } } } -function anyFactory$2(tests) { - var checks = convertAll$2(tests); - var length = checks.length; +/** + * Convert `obj` into a normalized thunk. + * + * @param {Mixed} obj + * @param {Mixed} ctx + * @return {Function} + * @api private + */ - return matches +function toThunk(obj, ctx) { - function matches() { - var index = -1; + if (isGeneratorFunction(obj)) { + return co(obj.call(ctx)); + } - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } + if (isGenerator(obj)) { + return co(obj); + } - return false + if (isPromise(obj)) { + return promiseToThunk(obj); } -} -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$2(test) { - return type + if ('function' == typeof obj) { + return obj; + } - function type(node) { - return Boolean(node && node.type === test) + if (isObject$3(obj) || Array.isArray(obj)) { + return objectToThunk.call(ctx, obj); } -} -// Utility to return true. -function ok$3() { - return true + return obj; } -var unistUtilVisitParents$2 = visitParents$2; - - - -var CONTINUE$4 = true; -var SKIP$4 = 'skip'; -var EXIT$4 = false; - -visitParents$2.CONTINUE = CONTINUE$4; -visitParents$2.SKIP = SKIP$4; -visitParents$2.EXIT = EXIT$4; - -function visitParents$2(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$2(test); +/** + * Convert an object of yieldables to a thunk. + * + * @param {Object} obj + * @return {Function} + * @api private + */ - one(tree, null, []); +function objectToThunk(obj){ + var ctx = this; + var isArray = Array.isArray(obj); - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; + return function(done){ + var keys = Object.keys(obj); + var pending = keys.length; + var results = isArray + ? new Array(pending) // predefine the array length + : new obj.constructor(); + var finished; - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$2(visitor(node, parents)); + if (!pending) { + setImmediate(function(){ + done(null, results); + }); + return; + } - if (result[0] === EXIT$4) { - return result + // prepopulate object keys to preserve key ordering + if (!isArray) { + for (var i = 0; i < pending; i++) { + results[keys[i]] = undefined; } } - if (node.children && result[0] !== SKIP$4) { - subresult = toResult$2(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$4 ? subresult : result + for (var i = 0; i < keys.length; i++) { + run(obj[keys[i]], keys[i]); } - return result - } + function run(fn, key) { + if (finished) return; + try { + fn = toThunk(fn, ctx); - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; + if ('function' != typeof fn) { + results[key] = fn; + return --pending || done(null, results); + } - while (index > min && index < children.length) { - result = one(children[index], index, parents); + fn.call(ctx, function(err, res){ + if (finished) return; - if (result[0] === EXIT$4) { - return result - } + if (err) { + finished = true; + return done(err); + } - index = typeof result[1] === 'number' ? result[1] : index + step; + results[key] = res; + --pending || done(null, results); + }); + } catch (err) { + finished = true; + done(err); + } } } } -function toResult$2(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } +/** + * Convert `promise` to a thunk. + * + * @param {Object} promise + * @return {Function} + * @api private + */ - if (typeof value === 'number') { - return [CONTINUE$4, value] +function promiseToThunk(promise) { + return function(fn){ + promise.then(function(res) { + fn(null, res); + }, fn); } - - return [value] } -var unistUtilVisit$2 = visit$2; +/** + * Check if `obj` is a promise. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ +function isPromise(obj) { + return obj && 'function' == typeof obj.then; +} +/** + * Check if `obj` is a generator. + * + * @param {Mixed} obj + * @return {Boolean} + * @api private + */ -var CONTINUE$5 = unistUtilVisitParents$2.CONTINUE; -var SKIP$5 = unistUtilVisitParents$2.SKIP; -var EXIT$5 = unistUtilVisitParents$2.EXIT; +function isGenerator(obj) { + return obj && 'function' == typeof obj.next && 'function' == typeof obj.throw; +} -visit$2.CONTINUE = CONTINUE$5; -visit$2.SKIP = SKIP$5; -visit$2.EXIT = EXIT$5; +/** + * Check if `obj` is a generator function. + * + * @param {Mixed} obj + * @return {Boolean} + * @api private + */ -function visit$2(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } +function isGeneratorFunction(obj) { + return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name; +} - unistUtilVisitParents$2(tree, test, overload, reverse); +/** + * Check for plain object. + * + * @param {Mixed} val + * @return {Boolean} + * @api private + */ - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } +function isObject$3(val) { + return val && Object == val.constructor; } -var unifiedMessageControl$1 = messageControl$2; +/** + * Throw `err` in a new stack. + * + * This is used when co() is invoked + * without supplying a callback, which + * should only be for demonstrational + * purposes. + * + * @param {Error} err + * @api private + */ -function messageControl$2(options) { - var settings = options || {}; - var name = settings.name; - var marker = settings.marker; - var test = settings.test; - var sources = settings.source; - var known = settings.known; - var reset = settings.reset; - var enable = settings.enable || []; - var disable = settings.disable || []; - - if (!name) { - throw new Error('Expected `name` in `options`, got `' + name + '`') - } - - if (!marker) { - throw new Error('Expected `marker` in `options`, got `' + marker + '`') - } - - if (!sources) { - sources = [name]; - } else if (typeof sources === 'string') { - sources = [sources]; - } +function error(err) { + if (!err) return; + setImmediate(function(){ + throw err; + }); +} - return transformer +/** + * Module Dependencies + */ - function transformer(tree, file) { - var toOffset = vfileLocation$2(file).toOffset; - var initial = !reset; - var gaps = detectGaps$1(tree, file); - var scope = {}; - var globals = []; - unistUtilVisit$2(tree, test, visitor); +var noop$3 = function(){}; - file.messages = file.messages.filter(filter); - function visitor(node, position, parent) { - var mark = marker(node); - var ruleIds; - var ruleId; - var verb; - var index; - var length; - var next; - var pos; - var tail; +/** + * Export `wrapped` + */ - if (!mark || mark.name !== name) { - return - } +var wrapped_1 = wrapped; - ruleIds = mark.attributes.split(/\s/g); - verb = ruleIds.shift(); - next = parent.children[position + 1]; - pos = mark.node.position && mark.node.position.start; - tail = next && next.position && next.position.end; +/** + * Wrap a function to support + * sync, async, and gen functions. + * + * @param {Function} fn + * @return {Function} + * @api public + */ - if (verb !== 'enable' && verb !== 'disable' && verb !== 'ignore') { - file.fail( - 'Unknown keyword `' + - verb + - '`: expected ' + - "`'enable'`, `'disable'`, or `'ignore'`", - mark.node - ); - } +function wrapped(fn) { + function wrap() { + var args = sliced(arguments); + var last = args[args.length - 1]; + var ctx = this; - length = ruleIds.length; - index = -1; + // done + var done = typeof last == 'function' ? args.pop() : noop$3; - // Apply to all rules. - if (length === 0) { - if (verb === 'ignore') { - toggle(pos, false); - toggle(tail, true); - } else { - toggle(pos, verb === 'enable'); - reset = verb !== 'enable'; - } - } else { - while (++index < length) { - ruleId = ruleIds[index]; + // nothing + if (!fn) { + return done.apply(ctx, [null].concat(args)); + } - if (isKnown(ruleId, verb, mark.node)) { - toggle(pos, verb === 'enable', ruleId); + // generator + if (generator(fn)) { + return co_1(fn).apply(ctx, args.concat(done)); + } - if (verb === 'ignore') { - toggle(tail, true, ruleId); - } - } - } + // async + if (fn.length > args.length) { + // NOTE: this only handles uncaught synchronous errors + try { + return fn.apply(ctx, args.concat(done)); + } catch (e) { + return done(e); } } - function filter(message) { - var gapIndex = gaps.length; - var ruleId = message.ruleId; - var ranges = scope[ruleId]; - var pos; - - // Keep messages from a different source. - if (!message.source || sources.indexOf(message.source) === -1) { - return true - } + // sync + return sync$5(fn, done).apply(ctx, args); + } - // We only ignore messages if they‘re disabled, *not* when they’re not in - // the document. - if (!message.line) { - message.line = 1; - } + return wrap; +} - if (!message.column) { - message.column = 1; - } +/** + * Wrap a synchronous function execution. + * + * @param {Function} fn + * @param {Function} done + * @return {Function} + * @api private + */ - // Check whether the warning is inside a gap. - pos = toOffset(message); +function sync$5(fn, done) { + return function () { + var ret; - while (gapIndex--) { - if (gaps[gapIndex].start <= pos && gaps[gapIndex].end > pos) { - return false - } - } + try { + ret = fn.apply(this, arguments); + } catch (err) { + return done(err); + } - // Check whether allowed by specific and global states. - return check(message, ranges, ruleId) && check(message, globals) + if (promise(ret)) { + ret.then(function (value) { done(null, value); }, done); + } else { + ret instanceof Error ? done(ret) : done(null, ret); } + } +} - // Helper to check (and possibly warn) if a `ruleId` is unknown. - function isKnown(ruleId, verb, pos) { - var result = known ? known.indexOf(ruleId) !== -1 : true; +/** + * Is `value` a generator? + * + * @param {Mixed} value + * @return {Boolean} + * @api private + */ - if (!result) { - file.message( - 'Unknown rule: cannot ' + verb + " `'" + ruleId + "'`", - pos - ); - } +function generator(value) { + return value + && value.constructor + && 'GeneratorFunction' == value.constructor.name; +} - return result - } - // Get the latest state of a rule. - // When without `ruleId`, gets global state. - function getState(ruleId) { - var ranges = ruleId ? scope[ruleId] : globals; +/** + * Is `value` a promise? + * + * @param {Mixed} value + * @return {Boolean} + * @api private + */ - if (ranges && ranges.length !== 0) { - return ranges[ranges.length - 1].state - } +function promise(value) { + return value && 'function' == typeof value.then; +} - if (!ruleId) { - return !reset - } +var unifiedLintRule = factory$8; - if (reset) { - return enable.indexOf(ruleId) !== -1 - } +function factory$8(id, rule) { + var parts = id.split(':'); + var source = parts[0]; + var ruleId = parts[1]; + var fn = wrapped_1(rule); - return disable.indexOf(ruleId) === -1 - } + /* istanbul ignore if - possibly useful if externalised later. */ + if (!ruleId) { + ruleId = source; + source = null; + } - // Handle a rule. - function toggle(pos, state, ruleId) { - var markers = ruleId ? scope[ruleId] : globals; - var previousState; + attacher.displayName = id; - if (!markers) { - markers = []; - scope[ruleId] = markers; - } + return attacher - previousState = getState(ruleId); + function attacher(raw) { + var config = coerce(ruleId, raw); + var severity = config[0]; + var options = config[1]; + var fatal = severity === 2; - if (state !== previousState) { - markers.push({state: state, position: pos}); - } + return severity ? transformer : undefined - // Toggle all known rules. - if (!ruleId) { - for (ruleId in scope) { - toggle(pos, state, ruleId); - } - } - } + function transformer(tree, file, next) { + var index = file.messages.length; - // Check all `ranges` for `message`. - function check(message, ranges, id) { - // Check the state at the message’s position. - var index = ranges && ranges.length; - var length = -1; - var range; + fn(tree, file, options, done); - while (--index > length) { - range = ranges[index]; + function done(err) { + var messages = file.messages; + var message; - /* istanbul ignore if - Generated marker. */ - if (!range.position || !range.position.line || !range.position.column) { - continue + // Add the error, if not already properly added. + /* istanbul ignore if - only happens for incorrect plugins */ + if (err && messages.indexOf(err) === -1) { + try { + file.fail(err); + } catch (_) {} } - if ( - range.position.line < message.line || - (range.position.line === message.line && - range.position.column <= message.column) - ) { - return range.state === true + while (index < messages.length) { + message = messages[index]; + message.ruleId = ruleId; + message.source = source; + message.fatal = fatal; + + index++; } - } - // The first marker ocurred after the first message, so we check the - // initial state. - if (!id) { - return initial || reset + next(); } - - return reset ? enable.indexOf(id) !== -1 : disable.indexOf(id) === -1 } } } -// Detect gaps in `tree`. -function detectGaps$1(tree, file) { - var lastNode = tree.children[tree.children.length - 1]; - var offset = 0; - var isGap = false; - var gaps = []; - - // Find all gaps. - unistUtilVisit$2(tree, one); +// Coerce a value to a severity--options tuple. +function coerce(name, value) { + var def = 1; + var result; + var level; - // Get the end of the document. - // This detects if the last node was the last node. - // If not, there’s an extra gap between the last node and the end of the - // document. - if ( - lastNode && - lastNode.position && - lastNode.position.end && - offset === lastNode.position.end.offset && - trim$1(file.toString().slice(offset)) !== '' + /* istanbul ignore if - Handled by unified in v6.0.0 */ + if (typeof value === 'boolean') { + result = [value]; + } else if (value == null) { + result = [def]; + } else if ( + typeof value === 'object' && + (typeof value[0] === 'number' || + typeof value[0] === 'boolean' || + typeof value[0] === 'string') ) { - update(); - - update( - tree && tree.position && tree.position.end && tree.position.end.offset - 1 - ); + result = value.concat(); + } else { + result = [1, value]; } - return gaps - - function one(node) { - var pos = node.position; - - update(pos && pos.start && pos.start.offset); + level = result[0]; - if (!node.children) { - update(pos && pos.end && pos.end.offset); + if (typeof level === 'boolean') { + level = level ? 1 : 0; + } else if (typeof level === 'string') { + if (level === 'off') { + level = 0; + } else if (level === 'on' || level === 'warn') { + level = 1; + } else if (level === 'error') { + level = 2; + } else { + level = 1; + result = [level, result]; } } - // Detect a new position. - function update(latest) { - if (latest === null || latest === undefined) { - isGap = true; - return - } - - if (offset >= latest) { - return - } - - if (isGap) { - gaps.push({start: offset, end: latest}); - isGap = false; - } - - offset = latest; + if (level < 0 || level > 2) { + throw new Error( + 'Incorrect severity `' + + level + + '` for `' + + name + + '`, ' + + 'expected 0, 1, or 2' + ) } -} -function trim$1(value) { - return value.replace(/^\s*|\s*$/g, '') + result[0] = level; + + return result } -var remarkMessageControl$1 = messageControl$3; +var remarkLintFinalNewline = unifiedLintRule('remark-lint:final-newline', finalNewline); -var test$1 = [ - 'html', // Comments are `html` nodes in mdast. - 'comment' // In MDX, comments have their own node. -]; +function finalNewline(tree, file) { + var contents = String(file); + var last = contents.length - 1; -function messageControl$3(options) { - return unifiedMessageControl$1(Object.assign({marker: mdastCommentMarker, test: test$1}, options)) + if (last > -1 && contents.charAt(last) !== '\n') { + file.message('Missing newline character at end of file'); + } } -var remarkLint$1 = lint$1; +var pluralize = createCommonjsModule(function (module, exports) { +/* global define */ -// `remark-lint`. -// This adds support for ignoring stuff from messages (``). -// All rules are in their own packages and presets. -function lint$1() { - this.use(lintMessageControl$1); -} +(function (root, pluralize) { + /* istanbul ignore else */ + if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') { + // Node. + module.exports = pluralize(); + } else { + // Browser global. + root.pluralize = pluralize(); + } +})(commonjsGlobal, function () { + // Rule storage - pluralize and singularize need to be run sequentially, + // while other rules can be optimized using an object for instant lookups. + var pluralRules = []; + var singularRules = []; + var uncountables = {}; + var irregularPlurals = {}; + var irregularSingles = {}; -function lintMessageControl$1() { - return remarkMessageControl$1({name: 'lint', source: 'remark-lint'}) -} + /** + * Sanitize a pluralization rule to a usable regular expression. + * + * @param {(RegExp|string)} rule + * @return {RegExp} + */ + function sanitizeRule (rule) { + if (typeof rule === 'string') { + return new RegExp('^' + rule + '$', 'i'); + } -/** - * An Array.prototype.slice.call(arguments) alternative - * - * @param {Object} args something with a length - * @param {Number} slice - * @param {Number} sliceEnd - * @api public - */ + return rule; + } -var sliced = function (args, slice, sliceEnd) { - var ret = []; - var len = args.length; + /** + * Pass in a word token to produce a function that can replicate the case on + * another word. + * + * @param {string} word + * @param {string} token + * @return {Function} + */ + function restoreCase (word, token) { + // Tokens are an exact match. + if (word === token) return token; - if (0 === len) return ret; + // Lower cased words. E.g. "hello". + if (word === word.toLowerCase()) return token.toLowerCase(); - var start = slice < 0 - ? Math.max(0, slice + len) - : slice || 0; + // Upper cased words. E.g. "WHISKY". + if (word === word.toUpperCase()) return token.toUpperCase(); - if (sliceEnd !== undefined) { - len = sliceEnd < 0 - ? sliceEnd + len - : sliceEnd; + // Title cased words. E.g. "Title". + if (word[0] === word[0].toUpperCase()) { + return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase(); + } + + // Lower cased words. E.g. "test". + return token.toLowerCase(); } - while (len-- > start) { - ret[len - start] = args[len]; + /** + * Interpolate a regexp string. + * + * @param {string} str + * @param {Array} args + * @return {string} + */ + function interpolate (str, args) { + return str.replace(/\$(\d{1,2})/g, function (match, index) { + return args[index] || ''; + }); } - return ret; -}; + /** + * Replace a word using a rule. + * + * @param {string} word + * @param {Array} rule + * @return {string} + */ + function replace (word, rule) { + return word.replace(rule[0], function (match, index) { + var result = interpolate(rule[1], arguments); -/** - * slice() reference. - */ + if (match === '') { + return restoreCase(word[index - 1], result); + } -var slice$4 = Array.prototype.slice; + return restoreCase(match, result); + }); + } -/** - * Expose `co`. - */ - -var co_1 = co; - -/** - * Wrap the given generator `fn` and - * return a thunk. - * - * @param {Function} fn - * @return {Function} - * @api public - */ - -function co(fn) { - var isGenFun = isGeneratorFunction(fn); - - return function (done) { - var ctx = this; - - // in toThunk() below we invoke co() - // with a generator, so optimize for - // this case - var gen = fn; - - // we only need to parse the arguments - // if gen is a generator function. - if (isGenFun) { - var args = slice$4.call(arguments), len = args.length; - var hasCallback = len && 'function' == typeof args[len - 1]; - done = hasCallback ? args.pop() : error; - gen = fn.apply(this, args); - } else { - done = done || error; + /** + * Sanitize a word by passing in the word and sanitization rules. + * + * @param {string} token + * @param {string} word + * @param {Array} rules + * @return {string} + */ + function sanitizeWord (token, word, rules) { + // Empty string or doesn't need fixing. + if (!token.length || uncountables.hasOwnProperty(token)) { + return word; } - next(); + var len = rules.length; - // #92 - // wrap the callback in a setImmediate - // so that any of its errors aren't caught by `co` - function exit(err, res) { - setImmediate(function(){ - done.call(ctx, err, res); - }); - } + // Iterate over the sanitization rules and use the first one to match. + while (len--) { + var rule = rules[len]; - function next(err, res) { - var ret; + if (rule[0].test(word)) return replace(word, rule); + } - // multiple args - if (arguments.length > 2) res = slice$4.call(arguments, 1); + return word; + } - // error - if (err) { - try { - ret = gen.throw(err); - } catch (e) { - return exit(e); - } - } + /** + * Replace a word with the updated word. + * + * @param {Object} replaceMap + * @param {Object} keepMap + * @param {Array} rules + * @return {Function} + */ + function replaceWord (replaceMap, keepMap, rules) { + return function (word) { + // Get the correct token and case restoration functions. + var token = word.toLowerCase(); - // ok - if (!err) { - try { - ret = gen.next(res); - } catch (e) { - return exit(e); - } + // Check against the keep object map. + if (keepMap.hasOwnProperty(token)) { + return restoreCase(word, token); } - // done - if (ret.done) return exit(null, ret.value); - - // normalize - ret.value = toThunk(ret.value, ctx); - - // run - if ('function' == typeof ret.value) { - var called = false; - try { - ret.value.call(ctx, function(){ - if (called) return; - called = true; - next.apply(ctx, arguments); - }); - } catch (e) { - setImmediate(function(){ - if (called) return; - called = true; - next(e); - }); - } - return; + // Check against the replacement map for a direct word replacement. + if (replaceMap.hasOwnProperty(token)) { + return restoreCase(word, replaceMap[token]); } - // invalid - next(new TypeError('You may only yield a function, promise, generator, array, or object, ' - + 'but the following was passed: "' + String(ret.value) + '"')); - } + // Run all the rules against the word. + return sanitizeWord(token, word, rules); + }; } -} -/** - * Convert `obj` into a normalized thunk. - * - * @param {Mixed} obj - * @param {Mixed} ctx - * @return {Function} - * @api private - */ + /** + * Check if a word is part of the map. + */ + function checkWord (replaceMap, keepMap, rules, bool) { + return function (word) { + var token = word.toLowerCase(); -function toThunk(obj, ctx) { + if (keepMap.hasOwnProperty(token)) return true; + if (replaceMap.hasOwnProperty(token)) return false; - if (isGeneratorFunction(obj)) { - return co(obj.call(ctx)); + return sanitizeWord(token, token, rules) === token; + }; } - if (isGenerator(obj)) { - return co(obj); - } + /** + * Pluralize or singularize a word based on the passed in count. + * + * @param {string} word The word to pluralize + * @param {number} count How many of the word exist + * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks) + * @return {string} + */ + function pluralize (word, count, inclusive) { + var pluralized = count === 1 + ? pluralize.singular(word) : pluralize.plural(word); - if (isPromise(obj)) { - return promiseToThunk(obj); + return (inclusive ? count + ' ' : '') + pluralized; } - if ('function' == typeof obj) { - return obj; - } + /** + * Pluralize a word. + * + * @type {Function} + */ + pluralize.plural = replaceWord( + irregularSingles, irregularPlurals, pluralRules + ); - if (isObject$3(obj) || Array.isArray(obj)) { - return objectToThunk.call(ctx, obj); - } + /** + * Check if a word is plural. + * + * @type {Function} + */ + pluralize.isPlural = checkWord( + irregularSingles, irregularPlurals, pluralRules + ); - return obj; -} + /** + * Singularize a word. + * + * @type {Function} + */ + pluralize.singular = replaceWord( + irregularPlurals, irregularSingles, singularRules + ); -/** - * Convert an object of yieldables to a thunk. - * - * @param {Object} obj - * @return {Function} - * @api private - */ + /** + * Check if a word is singular. + * + * @type {Function} + */ + pluralize.isSingular = checkWord( + irregularPlurals, irregularSingles, singularRules + ); -function objectToThunk(obj){ - var ctx = this; - var isArray = Array.isArray(obj); + /** + * Add a pluralization rule to the collection. + * + * @param {(string|RegExp)} rule + * @param {string} replacement + */ + pluralize.addPluralRule = function (rule, replacement) { + pluralRules.push([sanitizeRule(rule), replacement]); + }; - return function(done){ - var keys = Object.keys(obj); - var pending = keys.length; - var results = isArray - ? new Array(pending) // predefine the array length - : new obj.constructor(); - var finished; + /** + * Add a singularization rule to the collection. + * + * @param {(string|RegExp)} rule + * @param {string} replacement + */ + pluralize.addSingularRule = function (rule, replacement) { + singularRules.push([sanitizeRule(rule), replacement]); + }; - if (!pending) { - setImmediate(function(){ - done(null, results); - }); + /** + * Add an uncountable word rule. + * + * @param {(string|RegExp)} word + */ + pluralize.addUncountableRule = function (word) { + if (typeof word === 'string') { + uncountables[word.toLowerCase()] = true; return; } - // prepopulate object keys to preserve key ordering - if (!isArray) { - for (var i = 0; i < pending; i++) { - results[keys[i]] = undefined; - } - } - - for (var i = 0; i < keys.length; i++) { - run(obj[keys[i]], keys[i]); - } - - function run(fn, key) { - if (finished) return; - try { - fn = toThunk(fn, ctx); - - if ('function' != typeof fn) { - results[key] = fn; - return --pending || done(null, results); - } - - fn.call(ctx, function(err, res){ - if (finished) return; - - if (err) { - finished = true; - return done(err); - } - - results[key] = res; - --pending || done(null, results); - }); - } catch (err) { - finished = true; - done(err); - } - } - } -} - -/** - * Convert `promise` to a thunk. - * - * @param {Object} promise - * @return {Function} - * @api private - */ - -function promiseToThunk(promise) { - return function(fn){ - promise.then(function(res) { - fn(null, res); - }, fn); - } -} - -/** - * Check if `obj` is a promise. - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ - -function isPromise(obj) { - return obj && 'function' == typeof obj.then; -} - -/** - * Check if `obj` is a generator. - * - * @param {Mixed} obj - * @return {Boolean} - * @api private - */ - -function isGenerator(obj) { - return obj && 'function' == typeof obj.next && 'function' == typeof obj.throw; -} - -/** - * Check if `obj` is a generator function. - * - * @param {Mixed} obj - * @return {Boolean} - * @api private - */ - -function isGeneratorFunction(obj) { - return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name; -} - -/** - * Check for plain object. - * - * @param {Mixed} val - * @return {Boolean} - * @api private - */ + // Set singular and plural references for the word. + pluralize.addPluralRule(word, '$0'); + pluralize.addSingularRule(word, '$0'); + }; -function isObject$3(val) { - return val && Object == val.constructor; -} + /** + * Add an irregular word definition. + * + * @param {string} single + * @param {string} plural + */ + pluralize.addIrregularRule = function (single, plural) { + plural = plural.toLowerCase(); + single = single.toLowerCase(); -/** - * Throw `err` in a new stack. - * - * This is used when co() is invoked - * without supplying a callback, which - * should only be for demonstrational - * purposes. - * - * @param {Error} err - * @api private - */ + irregularSingles[single] = plural; + irregularPlurals[plural] = single; + }; -function error(err) { - if (!err) return; - setImmediate(function(){ - throw err; + /** + * Irregular rules. + */ + [ + // Pronouns. + ['I', 'we'], + ['me', 'us'], + ['he', 'they'], + ['she', 'they'], + ['them', 'them'], + ['myself', 'ourselves'], + ['yourself', 'yourselves'], + ['itself', 'themselves'], + ['herself', 'themselves'], + ['himself', 'themselves'], + ['themself', 'themselves'], + ['is', 'are'], + ['was', 'were'], + ['has', 'have'], + ['this', 'these'], + ['that', 'those'], + // Words ending in with a consonant and `o`. + ['echo', 'echoes'], + ['dingo', 'dingoes'], + ['volcano', 'volcanoes'], + ['tornado', 'tornadoes'], + ['torpedo', 'torpedoes'], + // Ends with `us`. + ['genus', 'genera'], + ['viscus', 'viscera'], + // Ends with `ma`. + ['stigma', 'stigmata'], + ['stoma', 'stomata'], + ['dogma', 'dogmata'], + ['lemma', 'lemmata'], + ['schema', 'schemata'], + ['anathema', 'anathemata'], + // Other irregular rules. + ['ox', 'oxen'], + ['axe', 'axes'], + ['die', 'dice'], + ['yes', 'yeses'], + ['foot', 'feet'], + ['eave', 'eaves'], + ['goose', 'geese'], + ['tooth', 'teeth'], + ['quiz', 'quizzes'], + ['human', 'humans'], + ['proof', 'proofs'], + ['carve', 'carves'], + ['valve', 'valves'], + ['looey', 'looies'], + ['thief', 'thieves'], + ['groove', 'grooves'], + ['pickaxe', 'pickaxes'], + ['passerby', 'passersby'] + ].forEach(function (rule) { + return pluralize.addIrregularRule(rule[0], rule[1]); }); -} -/** - * Module Dependencies - */ + /** + * Pluralization rules. + */ + [ + [/s?$/i, 's'], + [/[^\u0000-\u007F]$/i, '$0'], + [/([^aeiou]ese)$/i, '$1'], + [/(ax|test)is$/i, '$1es'], + [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'], + [/(e[mn]u)s?$/i, '$1s'], + [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'], + [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'], + [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], + [/(seraph|cherub)(?:im)?$/i, '$1im'], + [/(her|at|gr)o$/i, '$1oes'], + [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'], + [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'], + [/sis$/i, 'ses'], + [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'], + [/([^aeiouy]|qu)y$/i, '$1ies'], + [/([^ch][ieo][ln])ey$/i, '$1ies'], + [/(x|ch|ss|sh|zz)$/i, '$1es'], + [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'], + [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], + [/(pe)(?:rson|ople)$/i, '$1ople'], + [/(child)(?:ren)?$/i, '$1ren'], + [/eaux$/i, '$0'], + [/m[ae]n$/i, 'men'], + ['thou', 'you'] + ].forEach(function (rule) { + return pluralize.addPluralRule(rule[0], rule[1]); + }); - -var noop$3 = function(){}; - - -/** - * Export `wrapped` - */ - -var wrapped_1 = wrapped; - -/** - * Wrap a function to support - * sync, async, and gen functions. - * - * @param {Function} fn - * @return {Function} - * @api public - */ - -function wrapped(fn) { - function wrap() { - var args = sliced(arguments); - var last = args[args.length - 1]; - var ctx = this; - - // done - var done = typeof last == 'function' ? args.pop() : noop$3; - - // nothing - if (!fn) { - return done.apply(ctx, [null].concat(args)); - } - - // generator - if (generator(fn)) { - return co_1(fn).apply(ctx, args.concat(done)); - } - - // async - if (fn.length > args.length) { - // NOTE: this only handles uncaught synchronous errors - try { - return fn.apply(ctx, args.concat(done)); - } catch (e) { - return done(e); - } - } - - // sync - return sync$5(fn, done).apply(ctx, args); - } - - return wrap; -} - -/** - * Wrap a synchronous function execution. - * - * @param {Function} fn - * @param {Function} done - * @return {Function} - * @api private - */ - -function sync$5(fn, done) { - return function () { - var ret; - - try { - ret = fn.apply(this, arguments); - } catch (err) { - return done(err); - } - - if (promise(ret)) { - ret.then(function (value) { done(null, value); }, done); - } else { - ret instanceof Error ? done(ret) : done(null, ret); - } - } -} - -/** - * Is `value` a generator? - * - * @param {Mixed} value - * @return {Boolean} - * @api private - */ - -function generator(value) { - return value - && value.constructor - && 'GeneratorFunction' == value.constructor.name; -} - - -/** - * Is `value` a promise? - * - * @param {Mixed} value - * @return {Boolean} - * @api private - */ - -function promise(value) { - return value && 'function' == typeof value.then; -} - -var unifiedLintRule = factory$9; - -function factory$9(id, rule) { - var parts = id.split(':'); - var source = parts[0]; - var ruleId = parts[1]; - var fn = wrapped_1(rule); - - /* istanbul ignore if - possibly useful if externalised later. */ - if (!ruleId) { - ruleId = source; - source = null; - } - - attacher.displayName = id; - - return attacher - - function attacher(raw) { - var config = coerce(ruleId, raw); - var severity = config[0]; - var options = config[1]; - var fatal = severity === 2; - - return severity ? transformer : undefined - - function transformer(tree, file, next) { - var index = file.messages.length; - - fn(tree, file, options, done); - - function done(err) { - var messages = file.messages; - var message; - - // Add the error, if not already properly added. - /* istanbul ignore if - only happens for incorrect plugins */ - if (err && messages.indexOf(err) === -1) { - try { - file.fail(err); - } catch (_) {} - } - - while (index < messages.length) { - message = messages[index]; - message.ruleId = ruleId; - message.source = source; - message.fatal = fatal; - - index++; - } - - next(); - } - } - } -} - -// Coerce a value to a severity--options tuple. -function coerce(name, value) { - var def = 1; - var result; - var level; - - /* istanbul ignore if - Handled by unified in v6.0.0 */ - if (typeof value === 'boolean') { - result = [value]; - } else if (value == null) { - result = [def]; - } else if ( - typeof value === 'object' && - (typeof value[0] === 'number' || - typeof value[0] === 'boolean' || - typeof value[0] === 'string') - ) { - result = value.concat(); - } else { - result = [1, value]; - } - - level = result[0]; - - if (typeof level === 'boolean') { - level = level ? 1 : 0; - } else if (typeof level === 'string') { - if (level === 'off') { - level = 0; - } else if (level === 'on' || level === 'warn') { - level = 1; - } else if (level === 'error') { - level = 2; - } else { - level = 1; - result = [level, result]; - } - } - - if (level < 0 || level > 2) { - throw new Error( - 'Incorrect severity `' + - level + - '` for `' + - name + - '`, ' + - 'expected 0, 1, or 2' - ) - } - - result[0] = level; - - return result -} - -var remarkLintFinalNewline = unifiedLintRule('remark-lint:final-newline', finalNewline); - -function finalNewline(tree, file) { - var contents = String(file); - var last = contents.length - 1; - - if (last > -1 && contents.charAt(last) !== '\n') { - file.message('Missing newline character at end of file'); - } -} - -var pluralize = createCommonjsModule(function (module, exports) { -/* global define */ - -(function (root, pluralize) { - /* istanbul ignore else */ - if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') { - // Node. - module.exports = pluralize(); - } else { - // Browser global. - root.pluralize = pluralize(); - } -})(commonjsGlobal, function () { - // Rule storage - pluralize and singularize need to be run sequentially, - // while other rules can be optimized using an object for instant lookups. - var pluralRules = []; - var singularRules = []; - var uncountables = {}; - var irregularPlurals = {}; - var irregularSingles = {}; - - /** - * Sanitize a pluralization rule to a usable regular expression. - * - * @param {(RegExp|string)} rule - * @return {RegExp} - */ - function sanitizeRule (rule) { - if (typeof rule === 'string') { - return new RegExp('^' + rule + '$', 'i'); - } - - return rule; - } - - /** - * Pass in a word token to produce a function that can replicate the case on - * another word. - * - * @param {string} word - * @param {string} token - * @return {Function} - */ - function restoreCase (word, token) { - // Tokens are an exact match. - if (word === token) return token; - - // Lower cased words. E.g. "hello". - if (word === word.toLowerCase()) return token.toLowerCase(); - - // Upper cased words. E.g. "WHISKY". - if (word === word.toUpperCase()) return token.toUpperCase(); - - // Title cased words. E.g. "Title". - if (word[0] === word[0].toUpperCase()) { - return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase(); - } - - // Lower cased words. E.g. "test". - return token.toLowerCase(); - } - - /** - * Interpolate a regexp string. - * - * @param {string} str - * @param {Array} args - * @return {string} - */ - function interpolate (str, args) { - return str.replace(/\$(\d{1,2})/g, function (match, index) { - return args[index] || ''; - }); - } - - /** - * Replace a word using a rule. - * - * @param {string} word - * @param {Array} rule - * @return {string} - */ - function replace (word, rule) { - return word.replace(rule[0], function (match, index) { - var result = interpolate(rule[1], arguments); - - if (match === '') { - return restoreCase(word[index - 1], result); - } - - return restoreCase(match, result); - }); - } - - /** - * Sanitize a word by passing in the word and sanitization rules. - * - * @param {string} token - * @param {string} word - * @param {Array} rules - * @return {string} - */ - function sanitizeWord (token, word, rules) { - // Empty string or doesn't need fixing. - if (!token.length || uncountables.hasOwnProperty(token)) { - return word; - } - - var len = rules.length; - - // Iterate over the sanitization rules and use the first one to match. - while (len--) { - var rule = rules[len]; - - if (rule[0].test(word)) return replace(word, rule); - } - - return word; - } - - /** - * Replace a word with the updated word. - * - * @param {Object} replaceMap - * @param {Object} keepMap - * @param {Array} rules - * @return {Function} - */ - function replaceWord (replaceMap, keepMap, rules) { - return function (word) { - // Get the correct token and case restoration functions. - var token = word.toLowerCase(); - - // Check against the keep object map. - if (keepMap.hasOwnProperty(token)) { - return restoreCase(word, token); - } - - // Check against the replacement map for a direct word replacement. - if (replaceMap.hasOwnProperty(token)) { - return restoreCase(word, replaceMap[token]); - } - - // Run all the rules against the word. - return sanitizeWord(token, word, rules); - }; - } - - /** - * Check if a word is part of the map. - */ - function checkWord (replaceMap, keepMap, rules, bool) { - return function (word) { - var token = word.toLowerCase(); - - if (keepMap.hasOwnProperty(token)) return true; - if (replaceMap.hasOwnProperty(token)) return false; - - return sanitizeWord(token, token, rules) === token; - }; - } - - /** - * Pluralize or singularize a word based on the passed in count. - * - * @param {string} word The word to pluralize - * @param {number} count How many of the word exist - * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks) - * @return {string} - */ - function pluralize (word, count, inclusive) { - var pluralized = count === 1 - ? pluralize.singular(word) : pluralize.plural(word); - - return (inclusive ? count + ' ' : '') + pluralized; - } - - /** - * Pluralize a word. - * - * @type {Function} - */ - pluralize.plural = replaceWord( - irregularSingles, irregularPlurals, pluralRules - ); - - /** - * Check if a word is plural. - * - * @type {Function} - */ - pluralize.isPlural = checkWord( - irregularSingles, irregularPlurals, pluralRules - ); - - /** - * Singularize a word. - * - * @type {Function} - */ - pluralize.singular = replaceWord( - irregularPlurals, irregularSingles, singularRules - ); - - /** - * Check if a word is singular. - * - * @type {Function} - */ - pluralize.isSingular = checkWord( - irregularPlurals, irregularSingles, singularRules - ); - - /** - * Add a pluralization rule to the collection. - * - * @param {(string|RegExp)} rule - * @param {string} replacement - */ - pluralize.addPluralRule = function (rule, replacement) { - pluralRules.push([sanitizeRule(rule), replacement]); - }; - - /** - * Add a singularization rule to the collection. - * - * @param {(string|RegExp)} rule - * @param {string} replacement - */ - pluralize.addSingularRule = function (rule, replacement) { - singularRules.push([sanitizeRule(rule), replacement]); - }; - - /** - * Add an uncountable word rule. - * - * @param {(string|RegExp)} word - */ - pluralize.addUncountableRule = function (word) { - if (typeof word === 'string') { - uncountables[word.toLowerCase()] = true; - return; - } - - // Set singular and plural references for the word. - pluralize.addPluralRule(word, '$0'); - pluralize.addSingularRule(word, '$0'); - }; - - /** - * Add an irregular word definition. - * - * @param {string} single - * @param {string} plural - */ - pluralize.addIrregularRule = function (single, plural) { - plural = plural.toLowerCase(); - single = single.toLowerCase(); - - irregularSingles[single] = plural; - irregularPlurals[plural] = single; - }; + /** + * Singularization rules. + */ + [ + [/s$/i, ''], + [/(ss)$/i, '$1'], + [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'], + [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], + [/ies$/i, 'y'], + [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'], + [/\b(mon|smil)ies$/i, '$1ey'], + [/\b((?:tit)?m|l)ice$/i, '$1ouse'], + [/(seraph|cherub)im$/i, '$1'], + [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'], + [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'], + [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], + [/(test)(?:is|es)$/i, '$1is'], + [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'], + [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'], + [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'], + [/(alumn|alg|vertebr)ae$/i, '$1a'], + [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'], + [/(matr|append)ices$/i, '$1ix'], + [/(pe)(rson|ople)$/i, '$1rson'], + [/(child)ren$/i, '$1'], + [/(eau)x?$/i, '$1'], + [/men$/i, 'man'] + ].forEach(function (rule) { + return pluralize.addSingularRule(rule[0], rule[1]); + }); /** - * Irregular rules. - */ - [ - // Pronouns. - ['I', 'we'], - ['me', 'us'], - ['he', 'they'], - ['she', 'they'], - ['them', 'them'], - ['myself', 'ourselves'], - ['yourself', 'yourselves'], - ['itself', 'themselves'], - ['herself', 'themselves'], - ['himself', 'themselves'], - ['themself', 'themselves'], - ['is', 'are'], - ['was', 'were'], - ['has', 'have'], - ['this', 'these'], - ['that', 'those'], - // Words ending in with a consonant and `o`. - ['echo', 'echoes'], - ['dingo', 'dingoes'], - ['volcano', 'volcanoes'], - ['tornado', 'tornadoes'], - ['torpedo', 'torpedoes'], - // Ends with `us`. - ['genus', 'genera'], - ['viscus', 'viscera'], - // Ends with `ma`. - ['stigma', 'stigmata'], - ['stoma', 'stomata'], - ['dogma', 'dogmata'], - ['lemma', 'lemmata'], - ['schema', 'schemata'], - ['anathema', 'anathemata'], - // Other irregular rules. - ['ox', 'oxen'], - ['axe', 'axes'], - ['die', 'dice'], - ['yes', 'yeses'], - ['foot', 'feet'], - ['eave', 'eaves'], - ['goose', 'geese'], - ['tooth', 'teeth'], - ['quiz', 'quizzes'], - ['human', 'humans'], - ['proof', 'proofs'], - ['carve', 'carves'], - ['valve', 'valves'], - ['looey', 'looies'], - ['thief', 'thieves'], - ['groove', 'grooves'], - ['pickaxe', 'pickaxes'], - ['passerby', 'passersby'] - ].forEach(function (rule) { - return pluralize.addIrregularRule(rule[0], rule[1]); - }); - - /** - * Pluralization rules. - */ - [ - [/s?$/i, 's'], - [/[^\u0000-\u007F]$/i, '$0'], - [/([^aeiou]ese)$/i, '$1'], - [/(ax|test)is$/i, '$1es'], - [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'], - [/(e[mn]u)s?$/i, '$1s'], - [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'], - [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'], - [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], - [/(seraph|cherub)(?:im)?$/i, '$1im'], - [/(her|at|gr)o$/i, '$1oes'], - [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'], - [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'], - [/sis$/i, 'ses'], - [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'], - [/([^aeiouy]|qu)y$/i, '$1ies'], - [/([^ch][ieo][ln])ey$/i, '$1ies'], - [/(x|ch|ss|sh|zz)$/i, '$1es'], - [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'], - [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], - [/(pe)(?:rson|ople)$/i, '$1ople'], - [/(child)(?:ren)?$/i, '$1ren'], - [/eaux$/i, '$0'], - [/m[ae]n$/i, 'men'], - ['thou', 'you'] - ].forEach(function (rule) { - return pluralize.addPluralRule(rule[0], rule[1]); - }); - - /** - * Singularization rules. - */ - [ - [/s$/i, ''], - [/(ss)$/i, '$1'], - [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'], - [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], - [/ies$/i, 'y'], - [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'], - [/\b(mon|smil)ies$/i, '$1ey'], - [/\b((?:tit)?m|l)ice$/i, '$1ouse'], - [/(seraph|cherub)im$/i, '$1'], - [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'], - [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'], - [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], - [/(test)(?:is|es)$/i, '$1is'], - [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'], - [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'], - [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'], - [/(alumn|alg|vertebr)ae$/i, '$1a'], - [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'], - [/(matr|append)ices$/i, '$1ix'], - [/(pe)(rson|ople)$/i, '$1rson'], - [/(child)ren$/i, '$1'], - [/(eau)x?$/i, '$1'], - [/men$/i, 'man'] - ].forEach(function (rule) { - return pluralize.addSingularRule(rule[0], rule[1]); - }); - - /** - * Uncountable rules. + * Uncountable rules. */ [ // Singular words with no plurals. @@ -45785,8357 +45149,1694 @@ var pluralize = createCommonjsModule(function (module, exports) { 'shrimp', 'software', 'species', - 'staff', - 'swine', - 'tennis', - 'traffic', - 'transportation', - 'trout', - 'tuna', - 'wealth', - 'welfare', - 'whiting', - 'wildebeest', - 'wildlife', - 'you', - /pok[eé]mon$/i, - // Regexes. - /[^aeiou]ese$/i, // "chinese", "japanese" - /deer$/i, // "deer", "reindeer" - /fish$/i, // "fish", "blowfish", "angelfish" - /measles$/i, - /o[iu]s$/i, // "carnivorous" - /pox$/i, // "chickpox", "smallpox" - /sheep$/i - ].forEach(pluralize.addUncountableRule); - - return pluralize; -}); -}); - -var convert_1$3 = convert$6; - -function convert$6(test) { - if (typeof test === 'string') { - return typeFactory$3(test) - } - - if (test === null || test === undefined) { - return ok$4 - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$3 : matchesFactory$3)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$3(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$6(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$3(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$3(tests) { - var checks = convertAll$3(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$3(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$4() { - return true -} - -var unistUtilVisitParents$3 = visitParents$3; - - - -var CONTINUE$6 = true; -var SKIP$6 = 'skip'; -var EXIT$6 = false; - -visitParents$3.CONTINUE = CONTINUE$6; -visitParents$3.SKIP = SKIP$6; -visitParents$3.EXIT = EXIT$6; - -function visitParents$3(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$3(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$3(visitor(node, parents)); - - if (result[0] === EXIT$6) { - return result - } - } - - if (node.children && result[0] !== SKIP$6) { - subresult = toResult$3(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$6 ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$6) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$3(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$6, value] - } - - return [value] -} - -var unistUtilVisit$3 = visit$3; - - - -var CONTINUE$7 = unistUtilVisitParents$3.CONTINUE; -var SKIP$7 = unistUtilVisitParents$3.SKIP; -var EXIT$7 = unistUtilVisitParents$3.EXIT; - -visit$3.CONTINUE = CONTINUE$7; -visit$3.SKIP = SKIP$7; -visit$3.EXIT = EXIT$7; - -function visit$3(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$3(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var start$1 = factory$a('start'); -var end = factory$a('end'); - -var unistUtilPosition = position$1; - -position$1.start = start$1; -position$1.end = end; - -function position$1(node) { - return {start: start$1(node), end: end(node)} -} - -function factory$a(type) { - point.displayName = type; - - return point - - function point(node) { - var point = (node && node.position && node.position[type]) || {}; - - return { - line: point.line || null, - column: point.column || null, - offset: isNaN(point.offset) ? null : point.offset - } - } -} - -var unistUtilGenerated = generated; - -function generated(node) { - var position = optional(optional(node).position); - var start = optional(position.start); - var end = optional(position.end); - - return !start.line || !start.column || !end.line || !end.column -} - -function optional(value) { - return value && typeof value === 'object' ? value : {} -} - -var remarkLintListItemBulletIndent = unifiedLintRule( - 'remark-lint:list-item-bullet-indent', - listItemBulletIndent -); - -var start$2 = unistUtilPosition.start; - -function listItemBulletIndent(tree, file) { - var contents = String(file); - - unistUtilVisit$3(tree, 'list', visitor); - - function visitor(node) { - node.children.forEach(visitItems); - } - - function visitItems(item) { - var final; - var indent; - var reason; - - if (!unistUtilGenerated(item)) { - final = start$2(item.children[0]); - indent = contents.slice(start$2(item).offset, final.offset).match(/^\s*/)[0] - .length; - - if (indent !== 0) { - reason = - 'Incorrect indentation before bullet: remove ' + - indent + - ' ' + - pluralize('space', indent); - - file.message(reason, { - line: final.line, - column: final.column - indent - }); - } - } - } -} - -var convert_1$4 = convert$7; - -function convert$7(test) { - if (typeof test === 'string') { - return typeFactory$4(test) - } - - if (test === null || test === undefined) { - return ok$5 - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$4 : matchesFactory$4)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$4(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$7(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$4(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$4(tests) { - var checks = convertAll$4(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$4(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$5() { - return true -} - -var unistUtilVisitParents$4 = visitParents$4; - - - -var CONTINUE$8 = true; -var SKIP$8 = 'skip'; -var EXIT$8 = false; - -visitParents$4.CONTINUE = CONTINUE$8; -visitParents$4.SKIP = SKIP$8; -visitParents$4.EXIT = EXIT$8; - -function visitParents$4(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$4(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$4(visitor(node, parents)); - - if (result[0] === EXIT$8) { - return result - } - } - - if (node.children && result[0] !== SKIP$8) { - subresult = toResult$4(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$8 ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$8) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$4(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$8, value] - } - - return [value] -} - -var unistUtilVisit$4 = visit$4; - - - -var CONTINUE$9 = unistUtilVisitParents$4.CONTINUE; -var SKIP$9 = unistUtilVisitParents$4.SKIP; -var EXIT$9 = unistUtilVisitParents$4.EXIT; - -visit$4.CONTINUE = CONTINUE$9; -visit$4.SKIP = SKIP$9; -visit$4.EXIT = EXIT$9; - -function visit$4(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$4(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintListItemIndent = unifiedLintRule('remark-lint:list-item-indent', listItemIndent); - -var start$3 = unistUtilPosition.start; - -var styles$1 = {'tab-size': true, mixed: true, space: true}; - -function listItemIndent(tree, file, option) { - var contents = String(file); - var preferred = typeof option === 'string' ? option : 'tab-size'; - - if (styles$1[preferred] !== true) { - file.fail( - 'Incorrect list-item indent style `' + - preferred + - "`: use either `'tab-size'`, `'space'`, or `'mixed'`" - ); - } - - unistUtilVisit$4(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; - var abs; - - marker = contents - .slice(start$3(item).offset, final.offset) - .replace(/\[[x ]?]\s*$/i, ''); - - bulletSize = marker.replace(/\s+$/, '').length; - - style = - preferred === 'tab-size' || (preferred === 'mixed' && spread) - ? Math.ceil(bulletSize / 4) * 4 - : bulletSize + 1; - - if (marker.length !== style) { - diff = style - marker.length; - abs = Math.abs(diff); - - reason = - 'Incorrect list-item indent: ' + - (diff > 0 ? 'add' : 'remove') + - ' ' + - abs + - ' ' + - pluralize('space', abs); - - file.message(reason, final); - } - } - } -} - -var convert_1$5 = convert$8; - -function convert$8(test) { - if (typeof test === 'string') { - return typeFactory$5(test) - } - - if (test === null || test === undefined) { - return ok$6 - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$5 : matchesFactory$5)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$5(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$8(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$5(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$5(tests) { - var checks = convertAll$5(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$5(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$6() { - return true -} - -var unistUtilVisitParents$5 = visitParents$5; - - - -var CONTINUE$a = true; -var SKIP$a = 'skip'; -var EXIT$a = false; - -visitParents$5.CONTINUE = CONTINUE$a; -visitParents$5.SKIP = SKIP$a; -visitParents$5.EXIT = EXIT$a; - -function visitParents$5(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$5(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$5(visitor(node, parents)); - - if (result[0] === EXIT$a) { - return result - } - } - - if (node.children && result[0] !== SKIP$a) { - subresult = toResult$5(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$a ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$a) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$5(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$a, value] - } - - return [value] -} - -var unistUtilVisit$5 = visit$5; - - - -var CONTINUE$b = unistUtilVisitParents$5.CONTINUE; -var SKIP$b = unistUtilVisitParents$5.SKIP; -var EXIT$b = unistUtilVisitParents$5.EXIT; - -visit$5.CONTINUE = CONTINUE$b; -visit$5.SKIP = SKIP$b; -visit$5.EXIT = EXIT$b; - -function visit$5(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$5(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var mdastUtilToString = toString$3; - -// Get the text content of a node. -// Prefer the node’s plain-text fields, otherwise serialize its children, -// and if the given value is an array, serialize the nodes in it. -function toString$3(node) { - return ( - (node && - (node.value || - node.alt || - node.title || - ('children' in node && all$1(node.children)) || - ('length' in node && all$1(node)))) || - '' - ) -} - -function all$1(values) { - var result = []; - var length = values.length; - var index = -1; - - while (++index < length) { - result[index] = toString$3(values[index]); - } - - return result.join('') -} - -var remarkLintNoAutoLinkWithoutProtocol = unifiedLintRule( - 'remark-lint:no-auto-link-without-protocol', - noAutoLinkWithoutProtocol -); - -var start$4 = unistUtilPosition.start; -var end$1 = unistUtilPosition.end; - -// Protocol expression. -// See: . -var protocol$2 = /^[a-z][a-z+.-]+:\/?/i; - -var reason = 'All automatic links must start with a protocol'; - -function noAutoLinkWithoutProtocol(tree, file) { - unistUtilVisit$5(tree, 'link', visitor); - - function visitor(node) { - var children; - - if (!unistUtilGenerated(node)) { - children = node.children; - - if ( - start$4(node).column === start$4(children[0]).column - 1 && - end$1(node).column === end$1(children[children.length - 1]).column + 1 && - !protocol$2.test(mdastUtilToString(node)) - ) { - file.message(reason, node); - } - } - } -} - -var vfileLocation$3 = factory$b; - -function factory$b(file) { - var contents = indices$3(String(file)); - - return { - toPosition: offsetToPositionFactory$3(contents), - toOffset: positionToOffsetFactory$3(contents) - } -} - -// Factory to get the line and column-based `position` for `offset` in the bound -// indices. -function offsetToPositionFactory$3(indices) { - return offsetToPosition - - // Get the line and column-based `position` for `offset` in the bound indices. - function offsetToPosition(offset) { - var index = -1; - var length = indices.length; - - if (offset < 0) { - return {} - } - - while (++index < length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset - } - } - } - - return {} - } -} - -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$3(indices) { - return positionToOffset - - // Get the `offset` for a line and column-based `position` in the bound - // indices. - function positionToOffset(position) { - var line = position && position.line; - var column = position && position.column; - - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 - } - - return -1 - } -} - -// Get indices of line-breaks in `value`. -function indices$3(value) { - var result = []; - var index = value.indexOf('\n'); - - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); - } - - result.push(value.length + 1); - - return result -} - -var convert_1$6 = convert$9; - -function convert$9(test) { - if (typeof test === 'string') { - return typeFactory$6(test) - } - - if (test === null || test === undefined) { - return ok$7 - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$6 : matchesFactory$6)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$6(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$9(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$6(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$6(tests) { - var checks = convertAll$6(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$6(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$7() { - return true -} - -var unistUtilVisitParents$6 = visitParents$6; - - - -var CONTINUE$c = true; -var SKIP$c = 'skip'; -var EXIT$c = false; - -visitParents$6.CONTINUE = CONTINUE$c; -visitParents$6.SKIP = SKIP$c; -visitParents$6.EXIT = EXIT$c; - -function visitParents$6(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$6(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$6(visitor(node, parents)); - - if (result[0] === EXIT$c) { - return result - } - } - - if (node.children && result[0] !== SKIP$c) { - subresult = toResult$6(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$c ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$c) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$6(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$c, value] - } - - return [value] -} - -var unistUtilVisit$6 = visit$6; - - - -var CONTINUE$d = unistUtilVisitParents$6.CONTINUE; -var SKIP$d = unistUtilVisitParents$6.SKIP; -var EXIT$d = unistUtilVisitParents$6.EXIT; - -visit$6.CONTINUE = CONTINUE$d; -visit$6.SKIP = SKIP$d; -visit$6.EXIT = EXIT$d; - -function visit$6(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$6(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoBlockquoteWithoutMarker = unifiedLintRule( - 'remark-lint:no-blockquote-without-marker', - noBlockquoteWithoutMarker -); - -var reason$1 = 'Missing marker in block quote'; - -function noBlockquoteWithoutMarker(tree, file) { - var contents = String(file); - var location = vfileLocation$3(file); - var last = contents.length; - - unistUtilVisit$6(tree, 'blockquote', visitor); - - function visitor(node) { - var indent = node.position && node.position.indent; - var start; - var length; - var index; - var line; - var offset; - var character; - var pos; - - if (unistUtilGenerated(node) || !indent || indent.length === 0) { - return - } - - start = unistUtilPosition.start(node).line; - length = indent.length; - index = -1; - - while (++index < length) { - line = start + index + 1; - pos = {line: line, column: indent[index]}; - offset = location.toOffset(pos) - 1; - - while (++offset < last) { - character = contents.charAt(offset); - - if (character === '>') { - break - } - - /* istanbul ignore else - just for safety */ - if (character !== ' ' && character !== '\t') { - file.message(reason$1, pos); - break - } - } - } - } -} - -var convert_1$7 = convert$a; - -function convert$a(test) { - if (typeof test === 'string') { - return typeFactory$7(test) - } - - if (test === null || test === undefined) { - return ok$8 - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$7 : matchesFactory$7)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$7(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$a(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$7(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$7(tests) { - var checks = convertAll$7(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$7(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$8() { - return true -} - -var unistUtilVisitParents$7 = visitParents$7; - - - -var CONTINUE$e = true; -var SKIP$e = 'skip'; -var EXIT$e = false; - -visitParents$7.CONTINUE = CONTINUE$e; -visitParents$7.SKIP = SKIP$e; -visitParents$7.EXIT = EXIT$e; - -function visitParents$7(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$7(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$7(visitor(node, parents)); - - if (result[0] === EXIT$e) { - return result - } - } - - if (node.children && result[0] !== SKIP$e) { - subresult = toResult$7(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$e ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$e) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$7(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$e, value] - } - - return [value] -} - -var unistUtilVisit$7 = visit$7; - - - -var CONTINUE$f = unistUtilVisitParents$7.CONTINUE; -var SKIP$f = unistUtilVisitParents$7.SKIP; -var EXIT$f = unistUtilVisitParents$7.EXIT; - -visit$7.CONTINUE = CONTINUE$f; -visit$7.SKIP = SKIP$f; -visit$7.EXIT = EXIT$f; - -function visit$7(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$7(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoLiteralUrls = unifiedLintRule('remark-lint:no-literal-urls', noLiteralURLs); - -var start$5 = unistUtilPosition.start; -var end$2 = unistUtilPosition.end; -var mailto$2 = 'mailto:'; -var reason$2 = 'Don’t use literal URLs without angle brackets'; - -function noLiteralURLs(tree, file) { - unistUtilVisit$7(tree, 'link', visitor); - - function visitor(node) { - var children = node.children; - var value = mdastUtilToString(node); - - if ( - !unistUtilGenerated(node) && - start$5(node).column === start$5(children[0]).column && - end$2(node).column === end$2(children[children.length - 1]).column && - (node.url === mailto$2 + value || node.url === value) - ) { - file.message(reason$2, node); - } - } -} - -var convert_1$8 = convert$b; - -function convert$b(test) { - if (typeof test === 'string') { - return typeFactory$8(test) - } - - if (test === null || test === undefined) { - return ok$9 - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$8 : matchesFactory$8)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$8(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$b(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$8(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$8(tests) { - var checks = convertAll$8(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$8(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$9() { - return true -} - -var unistUtilVisitParents$8 = visitParents$8; - - - -var CONTINUE$g = true; -var SKIP$g = 'skip'; -var EXIT$g = false; - -visitParents$8.CONTINUE = CONTINUE$g; -visitParents$8.SKIP = SKIP$g; -visitParents$8.EXIT = EXIT$g; - -function visitParents$8(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$8(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$8(visitor(node, parents)); - - if (result[0] === EXIT$g) { - return result - } - } - - if (node.children && result[0] !== SKIP$g) { - subresult = toResult$8(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$g ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$g) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$8(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$g, value] - } - - return [value] -} - -var unistUtilVisit$8 = visit$8; - - - -var CONTINUE$h = unistUtilVisitParents$8.CONTINUE; -var SKIP$h = unistUtilVisitParents$8.SKIP; -var EXIT$h = unistUtilVisitParents$8.EXIT; - -visit$8.CONTINUE = CONTINUE$h; -visit$8.SKIP = SKIP$h; -visit$8.EXIT = EXIT$h; - -function visit$8(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$8(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintOrderedListMarkerStyle = unifiedLintRule( - 'remark-lint:ordered-list-marker-style', - orderedListMarkerStyle -); - -var start$6 = unistUtilPosition.start; - -var styles$2 = { - ')': true, - '.': true, - null: true -}; - -function orderedListMarkerStyle(tree, file, option) { - var contents = String(file); - var preferred = - typeof option !== 'string' || option === 'consistent' ? null : option; - - if (styles$2[preferred] !== true) { - file.fail( - 'Incorrect ordered list item marker style `' + - preferred + - "`: use either `'.'` or `')'`" - ); - } - - unistUtilVisit$8(tree, 'list', visitor); - - function visitor(node) { - var children = node.children; - var length = node.ordered ? children.length : 0; - var index = -1; - var marker; - var child; - - while (++index < length) { - child = children[index]; - - if (!unistUtilGenerated(child)) { - marker = contents - .slice(start$6(child).offset, start$6(child.children[0]).offset) - .replace(/\s|\d/g, '') - .replace(/\[[x ]?]\s*$/i, ''); - - if (preferred) { - if (marker !== preferred) { - file.message('Marker style should be `' + preferred + '`', child); - } - } else { - preferred = marker; - } - } - } - } -} - -var convert_1$9 = convert$c; - -function convert$c(test) { - if (typeof test === 'string') { - return typeFactory$9(test) - } - - if (test === null || test === undefined) { - return ok$a - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$9 : matchesFactory$9)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$9(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$c(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$9(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$9(tests) { - var checks = convertAll$9(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$9(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$a() { - return true -} - -var unistUtilVisitParents$9 = visitParents$9; - - - -var CONTINUE$i = true; -var SKIP$i = 'skip'; -var EXIT$i = false; - -visitParents$9.CONTINUE = CONTINUE$i; -visitParents$9.SKIP = SKIP$i; -visitParents$9.EXIT = EXIT$i; - -function visitParents$9(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$9(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$9(visitor(node, parents)); - - if (result[0] === EXIT$i) { - return result - } - } - - if (node.children && result[0] !== SKIP$i) { - subresult = toResult$9(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$i ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$i) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$9(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$i, value] - } - - return [value] -} - -var unistUtilVisit$9 = visit$9; - - - -var CONTINUE$j = unistUtilVisitParents$9.CONTINUE; -var SKIP$j = unistUtilVisitParents$9.SKIP; -var EXIT$j = unistUtilVisitParents$9.EXIT; - -visit$9.CONTINUE = CONTINUE$j; -visit$9.SKIP = SKIP$j; -visit$9.EXIT = EXIT$j; - -function visit$9(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$9(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintHardBreakSpaces = unifiedLintRule('remark-lint:hard-break-spaces', hardBreakSpaces); - -var reason$3 = 'Use two spaces for hard line breaks'; - -function hardBreakSpaces(tree, file) { - var contents = String(file); - - unistUtilVisit$9(tree, 'break', visitor); - - function visitor(node) { - var value; - - if (!unistUtilGenerated(node)) { - value = contents - .slice(unistUtilPosition.start(node).offset, unistUtilPosition.end(node).offset) - .split('\n', 1)[0] - .replace(/\r$/, ''); - - if (value.length > 2) { - file.message(reason$3, node); - } - } - } -} - -var convert_1$a = convert$d; - -function convert$d(test) { - if (typeof test === 'string') { - return typeFactory$a(test) - } - - if (test === null || test === undefined) { - return ok$b - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$a : matchesFactory$a)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$a(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$d(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$a(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$a(tests) { - var checks = convertAll$a(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$a(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$b() { - return true -} - -var unistUtilVisitParents$a = visitParents$a; - - - -var CONTINUE$k = true; -var SKIP$k = 'skip'; -var EXIT$k = false; - -visitParents$a.CONTINUE = CONTINUE$k; -visitParents$a.SKIP = SKIP$k; -visitParents$a.EXIT = EXIT$k; - -function visitParents$a(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$a(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$a(visitor(node, parents)); - - if (result[0] === EXIT$k) { - return result - } - } - - if (node.children && result[0] !== SKIP$k) { - subresult = toResult$a(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$k ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$k) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$a(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$k, value] - } - - return [value] -} - -var unistUtilVisit$a = visit$a; - - - -var CONTINUE$l = unistUtilVisitParents$a.CONTINUE; -var SKIP$l = unistUtilVisitParents$a.SKIP; -var EXIT$l = unistUtilVisitParents$a.EXIT; - -visit$a.CONTINUE = CONTINUE$l; -visit$a.SKIP = SKIP$l; -visit$a.EXIT = EXIT$l; - -function visit$a(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$a(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -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$a(tree, ['definition', 'footnoteDefinition'], check); - - function check(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 convert_1$b = convert$e; - -function convert$e(test) { - if (typeof test === 'string') { - return typeFactory$b(test) - } - - if (test === null || test === undefined) { - return ok$c - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$b : matchesFactory$b)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$b(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$e(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$b(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$b(tests) { - var checks = convertAll$b(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$b(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$c() { - return true -} - -var unistUtilVisitParents$b = visitParents$b; - - - -var CONTINUE$m = true; -var SKIP$m = 'skip'; -var EXIT$m = false; - -visitParents$b.CONTINUE = CONTINUE$m; -visitParents$b.SKIP = SKIP$m; -visitParents$b.EXIT = EXIT$m; - -function visitParents$b(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$b(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$b(visitor(node, parents)); - - if (result[0] === EXIT$m) { - return result - } - } - - if (node.children && result[0] !== SKIP$m) { - subresult = toResult$b(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$m ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$m) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$b(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$m, value] - } - - return [value] -} - -var unistUtilVisit$b = visit$b; - - - -var CONTINUE$n = unistUtilVisitParents$b.CONTINUE; -var SKIP$n = unistUtilVisitParents$b.SKIP; -var EXIT$n = unistUtilVisitParents$b.EXIT; - -visit$b.CONTINUE = CONTINUE$n; -visit$b.SKIP = SKIP$n; -visit$b.EXIT = EXIT$n; - -function visit$b(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$b(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -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$7 = unistUtilPosition.start; -var end$3 = unistUtilPosition.end; - -function noHeadingContentIndent(tree, file) { - var contents = String(file); - - unistUtilVisit$b(tree, 'heading', visitor); - - function visitor(node) { - var depth; - var children; - var type; - var head; - var initial; - var final; - var diff; - var index; - var char; - var reason; - var abs; - - if (unistUtilGenerated(node)) { - return - } - - depth = node.depth; - children = node.children; - type = mdastUtilHeadingStyle(node, 'atx'); - - if (type === 'atx' || type === 'atx-closed') { - initial = start$7(node); - index = initial.offset; - char = contents.charAt(index); - - while (char && char !== '#') { - char = contents.charAt(++index); - } - - /* istanbul ignore if - CR/LF bug: remarkjs/remark#195. */ - if (!char) { - return - } - - index = depth + (index - initial.offset); - head = start$7(children[0]).column; - - // Ignore empty headings. - if (!head) { - return - } - - diff = head - initial.column - 1 - index; - - if (diff) { - abs = Math.abs(diff); - - reason = - (diff > 0 ? 'Remove' : 'Add') + - ' ' + - abs + - ' ' + - pluralize('space', abs) + - ' before this heading’s content'; - - file.message(reason, start$7(children[0])); - } - } - - // Closed ATX headings always must have a space 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; - - if (diff) { - reason = - 'Remove ' + - diff + - ' ' + - pluralize('space', diff) + - ' after this heading’s content'; - - file.message(reason, final); - } - } - } -} - -var convert_1$c = convert$f; - -function convert$f(test) { - if (typeof test === 'string') { - return typeFactory$c(test) - } - - if (test === null || test === undefined) { - return ok$d - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$c : matchesFactory$c)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$c(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$f(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$c(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$c(tests) { - var checks = convertAll$c(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$c(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$d() { - return true -} - -var unistUtilVisitParents$c = visitParents$c; - - - -var CONTINUE$o = true; -var SKIP$o = 'skip'; -var EXIT$o = false; - -visitParents$c.CONTINUE = CONTINUE$o; -visitParents$c.SKIP = SKIP$o; -visitParents$c.EXIT = EXIT$o; - -function visitParents$c(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$c(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$c(visitor(node, parents)); - - if (result[0] === EXIT$o) { - return result - } - } - - if (node.children && result[0] !== SKIP$o) { - subresult = toResult$c(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$o ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$o) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$c(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$o, value] - } - - return [value] -} - -var unistUtilVisit$c = visit$c; - - - -var CONTINUE$p = unistUtilVisitParents$c.CONTINUE; -var SKIP$p = unistUtilVisitParents$c.SKIP; -var EXIT$p = unistUtilVisitParents$c.EXIT; - -visit$c.CONTINUE = CONTINUE$p; -visit$c.SKIP = SKIP$p; -visit$c.EXIT = EXIT$p; - -function visit$c(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$c(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoInlinePadding = unifiedLintRule('remark-lint:no-inline-padding', noInlinePadding); - -function noInlinePadding(tree, file) { - unistUtilVisit$c(tree, ['emphasis', 'strong', 'delete', 'image', 'link'], visitor); - - function visitor(node) { - var contents; - - if (!unistUtilGenerated(node)) { - contents = mdastUtilToString(node); - - if ( - contents.charAt(0) === ' ' || - contents.charAt(contents.length - 1) === ' ' - ) { - file.message('Don’t pad `' + node.type + '` with inner spaces', node); - } - } - } -} - -var convert_1$d = convert$g; - -function convert$g(test) { - if (typeof test === 'string') { - return typeFactory$d(test) - } - - if (test === null || test === undefined) { - return ok$e - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$d : matchesFactory$d)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$d(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$g(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$d(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$d(tests) { - var checks = convertAll$d(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$d(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$e() { - return true -} - -var unistUtilVisitParents$d = visitParents$d; - - - -var CONTINUE$q = true; -var SKIP$q = 'skip'; -var EXIT$q = false; - -visitParents$d.CONTINUE = CONTINUE$q; -visitParents$d.SKIP = SKIP$q; -visitParents$d.EXIT = EXIT$q; - -function visitParents$d(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$d(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$d(visitor(node, parents)); - - if (result[0] === EXIT$q) { - return result - } - } - - if (node.children && result[0] !== SKIP$q) { - subresult = toResult$d(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$q ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$q) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$d(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$q, value] - } - - return [value] -} - -var unistUtilVisit$d = visit$d; - - - -var CONTINUE$r = unistUtilVisitParents$d.CONTINUE; -var SKIP$r = unistUtilVisitParents$d.SKIP; -var EXIT$r = unistUtilVisitParents$d.EXIT; - -visit$d.CONTINUE = CONTINUE$r; -visit$d.SKIP = SKIP$r; -visit$d.EXIT = EXIT$r; - -function visit$d(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$d(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoShortcutReferenceImage = unifiedLintRule( - 'remark-lint:no-shortcut-reference-image', - noShortcutReferenceImage -); - -var reason$5 = 'Use the trailing [] on reference images'; - -function noShortcutReferenceImage(tree, file) { - unistUtilVisit$d(tree, 'imageReference', visitor); - - function visitor(node) { - if (!unistUtilGenerated(node) && node.referenceType === 'shortcut') { - file.message(reason$5, node); - } - } -} - -var convert_1$e = convert$h; - -function convert$h(test) { - if (typeof test === 'string') { - return typeFactory$e(test) - } - - if (test === null || test === undefined) { - return ok$f - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$e : matchesFactory$e)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$e(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$h(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$e(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$e(tests) { - var checks = convertAll$e(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$e(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$f() { - return true -} - -var unistUtilVisitParents$e = visitParents$e; - - - -var CONTINUE$s = true; -var SKIP$s = 'skip'; -var EXIT$s = false; - -visitParents$e.CONTINUE = CONTINUE$s; -visitParents$e.SKIP = SKIP$s; -visitParents$e.EXIT = EXIT$s; - -function visitParents$e(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$e(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$e(visitor(node, parents)); - - if (result[0] === EXIT$s) { - return result - } - } - - if (node.children && result[0] !== SKIP$s) { - subresult = toResult$e(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$s ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$s) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$e(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$s, value] - } - - return [value] -} - -var unistUtilVisit$e = visit$e; - - - -var CONTINUE$t = unistUtilVisitParents$e.CONTINUE; -var SKIP$t = unistUtilVisitParents$e.SKIP; -var EXIT$t = unistUtilVisitParents$e.EXIT; - -visit$e.CONTINUE = CONTINUE$t; -visit$e.SKIP = SKIP$t; -visit$e.EXIT = EXIT$t; - -function visit$e(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$e(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoShortcutReferenceLink = unifiedLintRule( - 'remark-lint:no-shortcut-reference-link', - noShortcutReferenceLink -); - -var reason$6 = 'Use the trailing `[]` on reference links'; - -function noShortcutReferenceLink(tree, file) { - unistUtilVisit$e(tree, 'linkReference', visitor); - - function visitor(node) { - if (!unistUtilGenerated(node) && node.referenceType === 'shortcut') { - file.message(reason$6, node); - } - } -} - -var convert_1$f = convert$i; - -function convert$i(test) { - if (typeof test === 'string') { - return typeFactory$f(test) - } - - if (test === null || test === undefined) { - return ok$g - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$f : matchesFactory$f)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$f(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$i(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$f(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$f(tests) { - var checks = convertAll$f(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$f(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$g() { - return true -} - -var unistUtilVisitParents$f = visitParents$f; - - - -var CONTINUE$u = true; -var SKIP$u = 'skip'; -var EXIT$u = false; - -visitParents$f.CONTINUE = CONTINUE$u; -visitParents$f.SKIP = SKIP$u; -visitParents$f.EXIT = EXIT$u; - -function visitParents$f(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$f(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$f(visitor(node, parents)); - - if (result[0] === EXIT$u) { - return result - } - } - - if (node.children && result[0] !== SKIP$u) { - subresult = toResult$f(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$u ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$u) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$f(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$u, value] - } - - return [value] -} - -var unistUtilVisit$f = visit$f; - - - -var CONTINUE$v = unistUtilVisitParents$f.CONTINUE; -var SKIP$v = unistUtilVisitParents$f.SKIP; -var EXIT$v = unistUtilVisitParents$f.EXIT; - -visit$f.CONTINUE = CONTINUE$v; -visit$f.SKIP = SKIP$v; -visit$f.EXIT = EXIT$v; - -function visit$f(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$f(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoUndefinedReferences = unifiedLintRule( - 'remark-lint:no-undefined-references', - noUndefinedReferences -); - -var reason$7 = 'Found reference to undefined definition'; - -// The identifier is upcased to avoid naming collisions with fields inherited -// from `Object.prototype`. -// If `Object.create(null)` was used in place of `{}`, downcasing would work -// equally well. -function normalize$3(s) { - return collapseWhiteSpace(s.toUpperCase()) -} - -function noUndefinedReferences(tree, file, option) { - var allow = ((option || {}).allow || []).map(normalize$3); - var map = {}; - - unistUtilVisit$f(tree, ['definition', 'footnoteDefinition'], mark); - unistUtilVisit$f(tree, ['imageReference', 'linkReference', 'footnoteReference'], find); - - function mark(node) { - if (!unistUtilGenerated(node)) { - map[normalize$3(node.identifier)] = true; - } - } - - function find(node) { - if ( - !unistUtilGenerated(node) && - !(normalize$3(node.identifier) in map) && - allow.indexOf(normalize$3(node.identifier)) === -1 - ) { - file.message(reason$7, node); - } - } -} - -var convert_1$g = convert$j; - -function convert$j(test) { - if (typeof test === 'string') { - return typeFactory$g(test) - } - - if (test === null || test === undefined) { - return ok$h - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$g : matchesFactory$g)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$g(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$j(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$g(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$g(tests) { - var checks = convertAll$g(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$g(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$h() { - return true -} - -var unistUtilVisitParents$g = visitParents$g; - - - -var CONTINUE$w = true; -var SKIP$w = 'skip'; -var EXIT$w = false; - -visitParents$g.CONTINUE = CONTINUE$w; -visitParents$g.SKIP = SKIP$w; -visitParents$g.EXIT = EXIT$w; - -function visitParents$g(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$g(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$g(visitor(node, parents)); - - if (result[0] === EXIT$w) { - return result - } - } - - if (node.children && result[0] !== SKIP$w) { - subresult = toResult$g(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$w ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$w) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$g(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$w, value] - } - - return [value] -} - -var unistUtilVisit$g = visit$g; - - - -var CONTINUE$x = unistUtilVisitParents$g.CONTINUE; -var SKIP$x = unistUtilVisitParents$g.SKIP; -var EXIT$x = unistUtilVisitParents$g.EXIT; - -visit$g.CONTINUE = CONTINUE$x; -visit$g.SKIP = SKIP$x; -visit$g.EXIT = EXIT$x; - -function visit$g(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$g(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoUnusedDefinitions = unifiedLintRule('remark-lint:no-unused-definitions', noUnusedDefinitions); - -var reason$8 = 'Found unused definition'; - -function noUnusedDefinitions(tree, file) { - var map = {}; - var identifier; - var entry; - - unistUtilVisit$g(tree, ['definition', 'footnoteDefinition'], find); - unistUtilVisit$g(tree, ['imageReference', 'linkReference', 'footnoteReference'], mark); - - for (identifier in map) { - entry = map[identifier]; - - if (!entry.used) { - file.message(reason$8, entry.node); - } - } - - function find(node) { - if (!unistUtilGenerated(node)) { - map[node.identifier.toUpperCase()] = {node: node, used: false}; - } - } - - function mark(node) { - var info = map[node.identifier.toUpperCase()]; - - if (!unistUtilGenerated(node) && info) { - info.used = true; - } - } -} - -var plugins$1 = [ - remarkLint$1, - // Unix compatibility. - remarkLintFinalNewline, - // Rendering across vendors differs greatly if using other styles. - remarkLintListItemBulletIndent, - [remarkLintListItemIndent, 'tab-size'], - // Differs or unsupported across vendors. - remarkLintNoAutoLinkWithoutProtocol, - remarkLintNoBlockquoteWithoutMarker, - remarkLintNoLiteralUrls, - [remarkLintOrderedListMarkerStyle, '.'], - // Mistakes. - remarkLintHardBreakSpaces, - remarkLintNoDuplicateDefinitions, - remarkLintNoHeadingContentIndent, - remarkLintNoInlinePadding, - remarkLintNoShortcutReferenceImage, - remarkLintNoShortcutReferenceLink, - remarkLintNoUndefinedReferences, - remarkLintNoUnusedDefinitions -]; - -var remarkPresetLintRecommended = { - plugins: plugins$1 -}; - -var convert_1$h = convert$k; - -function convert$k(test) { - if (typeof test === 'string') { - return typeFactory$h(test) - } - - if (test === null || test === undefined) { - return ok$i - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$h : matchesFactory$h)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$h(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$k(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$h(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$h(tests) { - var checks = convertAll$h(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$h(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$i() { - return true -} - -var unistUtilVisitParents$h = visitParents$h; - - - -var CONTINUE$y = true; -var SKIP$y = 'skip'; -var EXIT$y = false; - -visitParents$h.CONTINUE = CONTINUE$y; -visitParents$h.SKIP = SKIP$y; -visitParents$h.EXIT = EXIT$y; - -function visitParents$h(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$h(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$h(visitor(node, parents)); - - if (result[0] === EXIT$y) { - return result - } - } - - if (node.children && result[0] !== SKIP$y) { - subresult = toResult$h(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$y ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$y) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$h(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$y, value] - } - - return [value] -} - -var unistUtilVisit$h = visit$h; - - - -var CONTINUE$z = unistUtilVisitParents$h.CONTINUE; -var SKIP$z = unistUtilVisitParents$h.SKIP; -var EXIT$z = unistUtilVisitParents$h.EXIT; - -visit$h.CONTINUE = CONTINUE$z; -visit$h.SKIP = SKIP$z; -visit$h.EXIT = EXIT$z; - -function visit$h(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$h(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintBlockquoteIndentation = unifiedLintRule( - 'remark-lint:blockquote-indentation', - blockquoteIndentation -); - -function blockquoteIndentation(tree, file, option) { - var preferred = typeof option === 'number' && !isNaN(option) ? option : null; - - unistUtilVisit$h(tree, 'blockquote', visitor); - - function visitor(node) { - var abs; - var diff; - var reason; - - if (unistUtilGenerated(node) || node.children.length === 0) { - return - } - - if (preferred) { - diff = preferred - check$3(node); - - if (diff !== 0) { - abs = Math.abs(diff); - reason = - (diff > 0 ? 'Add' : 'Remove') + - ' ' + - abs + - ' ' + - pluralize('space', abs) + - ' between block quote and content'; - - file.message(reason, unistUtilPosition.start(node.children[0])); - } - } else { - preferred = check$3(node); - } - } -} - -function check$3(node) { - var head = node.children[0]; - var indentation = unistUtilPosition.start(head).column - unistUtilPosition.start(node).column; - var padding = mdastUtilToString(head).match(/^ +/); - - if (padding) { - indentation += padding[0].length; - } - - return indentation -} - -var vfileLocation$4 = factory$c; - -function factory$c(file) { - var contents = indices$4(String(file)); - - return { - toPosition: offsetToPositionFactory$4(contents), - toOffset: positionToOffsetFactory$4(contents) - } -} - -// Factory to get the line and column-based `position` for `offset` in the bound -// indices. -function offsetToPositionFactory$4(indices) { - return offsetToPosition - - // Get the line and column-based `position` for `offset` in the bound indices. - function offsetToPosition(offset) { - var index = -1; - var length = indices.length; - - if (offset < 0) { - return {} - } - - while (++index < length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset - } - } - } - - return {} - } -} - -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$4(indices) { - return positionToOffset - - // Get the `offset` for a line and column-based `position` in the bound - // indices. - function positionToOffset(position) { - var line = position && position.line; - var column = position && position.column; - - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 - } - - return -1 - } -} - -// Get indices of line-breaks in `value`. -function indices$4(value) { - var result = []; - var index = value.indexOf('\n'); - - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); - } - - result.push(value.length + 1); - - return result -} - -var convert_1$i = convert$l; - -function convert$l(test) { - if (typeof test === 'string') { - return typeFactory$i(test) - } - - if (test === null || test === undefined) { - return ok$j - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$i : matchesFactory$i)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$i(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$l(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$i(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$i(tests) { - var checks = convertAll$i(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$i(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$j() { - return true -} - -var unistUtilVisitParents$i = visitParents$i; - - - -var CONTINUE$A = true; -var SKIP$A = 'skip'; -var EXIT$A = false; - -visitParents$i.CONTINUE = CONTINUE$A; -visitParents$i.SKIP = SKIP$A; -visitParents$i.EXIT = EXIT$A; - -function visitParents$i(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$i(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$i(visitor(node, parents)); - - if (result[0] === EXIT$A) { - return result - } - } - - if (node.children && result[0] !== SKIP$A) { - subresult = toResult$i(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$A ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$A) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$i(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$A, value] - } - - return [value] -} - -var unistUtilVisit$i = visit$i; - - - -var CONTINUE$B = unistUtilVisitParents$i.CONTINUE; -var SKIP$B = unistUtilVisitParents$i.SKIP; -var EXIT$B = unistUtilVisitParents$i.EXIT; - -visit$i.CONTINUE = CONTINUE$B; -visit$i.SKIP = SKIP$B; -visit$i.EXIT = EXIT$B; - -function visit$i(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$i(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintCheckboxCharacterStyle = unifiedLintRule( - 'remark-lint:checkbox-character-style', - checkboxCharacterStyle -); - -var start$8 = unistUtilPosition.start; -var end$4 = unistUtilPosition.end; - -var checked = {x: true, X: true}; -var unchecked = {' ': true, '\t': true}; -var types$1 = {true: 'checked', false: 'unchecked'}; - -function checkboxCharacterStyle(tree, file, option) { - var contents = String(file); - var location = vfileLocation$4(file); - var preferred = typeof option === 'object' ? option : {}; - - if (preferred.unchecked && unchecked[preferred.unchecked] !== true) { - file.fail( - 'Incorrect unchecked checkbox marker `' + - preferred.unchecked + - "`: use either `'\\t'`, or `' '`" - ); - } - - if (preferred.checked && checked[preferred.checked] !== true) { - file.fail( - 'Incorrect checked checkbox marker `' + - preferred.checked + - "`: use either `'x'`, or `'X'`" - ); - } - - unistUtilVisit$i(tree, 'listItem', visitor); - - function visitor(node) { - var type; - var initial; - var final; - var value; - var style; - var character; - var reason; - - // Exit early for items without checkbox. - if (typeof node.checked !== 'boolean' || unistUtilGenerated(node)) { - return - } - - type = types$1[node.checked]; - initial = start$8(node).offset; - final = (node.children.length === 0 ? end$4(node) : start$8(node.children[0])) - .offset; - - // For a checkbox to be parsed, it must be followed by a whitespace. - value = contents.slice(initial, final).replace(/\s+$/, '').slice(0, -1); - - // The checkbox character is behind a square bracket. - character = value.charAt(value.length - 1); - style = preferred[type]; - - if (style) { - if (character !== style) { - reason = - type.charAt(0).toUpperCase() + - type.slice(1) + - ' checkboxes should use `' + - style + - '` as a marker'; - - file.message(reason, { - start: location.toPosition(initial + value.length - 1), - end: location.toPosition(initial + value.length) - }); - } - } else { - preferred[type] = character; - } - } -} - -var vfileLocation$5 = factory$d; - -function factory$d(file) { - var contents = indices$5(String(file)); - - return { - toPosition: offsetToPositionFactory$5(contents), - toOffset: positionToOffsetFactory$5(contents) - } -} - -// Factory to get the line and column-based `position` for `offset` in the bound -// indices. -function offsetToPositionFactory$5(indices) { - return offsetToPosition - - // Get the line and column-based `position` for `offset` in the bound indices. - function offsetToPosition(offset) { - var index = -1; - var length = indices.length; - - if (offset < 0) { - return {} - } - - while (++index < length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset - } - } - } - - return {} - } -} - -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$5(indices) { - return positionToOffset - - // Get the `offset` for a line and column-based `position` in the bound - // indices. - function positionToOffset(position) { - var line = position && position.line; - var column = position && position.column; - - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 - } - - return -1 - } -} - -// Get indices of line-breaks in `value`. -function indices$5(value) { - var result = []; - var index = value.indexOf('\n'); - - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); - } - - result.push(value.length + 1); - - return result -} - -var convert_1$j = convert$m; - -function convert$m(test) { - if (typeof test === 'string') { - return typeFactory$j(test) - } - - if (test === null || test === undefined) { - return ok$k - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$j : matchesFactory$j)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$j(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$m(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$j(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$j(tests) { - var checks = convertAll$j(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$j(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$k() { - return true -} - -var unistUtilVisitParents$j = visitParents$j; - - - -var CONTINUE$C = true; -var SKIP$C = 'skip'; -var EXIT$C = false; - -visitParents$j.CONTINUE = CONTINUE$C; -visitParents$j.SKIP = SKIP$C; -visitParents$j.EXIT = EXIT$C; - -function visitParents$j(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$j(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$j(visitor(node, parents)); - - if (result[0] === EXIT$C) { - return result - } - } - - if (node.children && result[0] !== SKIP$C) { - subresult = toResult$j(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$C ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$C) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$j(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$C, value] - } - - return [value] -} - -var unistUtilVisit$j = visit$j; - - - -var CONTINUE$D = unistUtilVisitParents$j.CONTINUE; -var SKIP$D = unistUtilVisitParents$j.SKIP; -var EXIT$D = unistUtilVisitParents$j.EXIT; - -visit$j.CONTINUE = CONTINUE$D; -visit$j.SKIP = SKIP$D; -visit$j.EXIT = EXIT$D; - -function visit$j(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$j(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintCheckboxContentIndent = unifiedLintRule( - 'remark-lint:checkbox-content-indent', - checkboxContentIndent -); - -var start$9 = unistUtilPosition.start; -var end$5 = unistUtilPosition.end; - -var reason$9 = 'Checkboxes should be followed by a single character'; - -function checkboxContentIndent(tree, file) { - var contents = String(file); - var location = vfileLocation$5(file); - - unistUtilVisit$j(tree, 'listItem', visitor); - - function visitor(node) { - var initial; - var final; - var value; - - // Exit early for items without checkbox. - if (typeof node.checked !== 'boolean' || unistUtilGenerated(node)) { - return - } - - initial = start$9(node).offset; - /* istanbul ignore next - hard to test, couldn’t find a case. */ - final = (node.children.length === 0 ? end$5(node) : start$9(node.children[0])) - .offset; - - while (/[^\S\n]/.test(contents.charAt(final))) { - final++; - } - - // For a checkbox to be parsed, it must be followed by a whitespace. - value = contents.slice(initial, final); - value = value.slice(value.indexOf(']') + 1); - - if (value.length !== 1) { - file.message(reason$9, { - start: location.toPosition(final - value.length + 1), - end: location.toPosition(final) - }); - } - } -} - -var convert_1$k = convert$n; - -function convert$n(test) { - if (typeof test === 'string') { - return typeFactory$k(test) - } - - if (test === null || test === undefined) { - return ok$l - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$k : matchesFactory$k)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$k(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$n(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$k(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$k(tests) { - var checks = convertAll$k(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$k(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$l() { - return true -} - -var unistUtilVisitParents$k = visitParents$k; - - - -var CONTINUE$E = true; -var SKIP$E = 'skip'; -var EXIT$E = false; - -visitParents$k.CONTINUE = CONTINUE$E; -visitParents$k.SKIP = SKIP$E; -visitParents$k.EXIT = EXIT$E; - -function visitParents$k(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$k(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$k(visitor(node, parents)); - - if (result[0] === EXIT$E) { - return result - } - } - - if (node.children && result[0] !== SKIP$E) { - subresult = toResult$k(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$E ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$E) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$k(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$E, value] - } - - return [value] -} - -var unistUtilVisit$k = visit$k; - - - -var CONTINUE$F = unistUtilVisitParents$k.CONTINUE; -var SKIP$F = unistUtilVisitParents$k.SKIP; -var EXIT$F = unistUtilVisitParents$k.EXIT; - -visit$k.CONTINUE = CONTINUE$F; -visit$k.SKIP = SKIP$F; -visit$k.EXIT = EXIT$F; - -function visit$k(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$k(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintCodeBlockStyle = unifiedLintRule('remark-lint:code-block-style', codeBlockStyle); - -var start$a = unistUtilPosition.start; -var end$6 = unistUtilPosition.end; - -var styles$3 = {null: true, fenced: true, indented: true}; - -function codeBlockStyle(tree, file, option) { - var contents = String(file); - var preferred = - typeof option === 'string' && option !== 'consistent' ? option : null; - - if (styles$3[preferred] !== true) { - file.fail( - 'Incorrect code block style `' + - preferred + - "`: use either `'consistent'`, `'fenced'`, or `'indented'`" - ); - } - - unistUtilVisit$k(tree, 'code', visitor); - - function visitor(node) { - var initial; - var final; - var current; - - if (unistUtilGenerated(node)) { - return null - } - - initial = start$a(node).offset; - final = end$6(node).offset; - - current = - node.lang || /^\s*([~`])\1{2,}/.test(contents.slice(initial, final)) - ? 'fenced' - : 'indented'; - - if (preferred) { - if (preferred !== current) { - file.message('Code blocks should be ' + preferred, node); - } - } else { - preferred = current; - } - } -} - -var convert_1$l = convert$o; - -function convert$o(test) { - if (typeof test === 'string') { - return typeFactory$l(test) - } - - if (test === null || test === undefined) { - return ok$m - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$l : matchesFactory$l)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$l(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$o(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$l(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$l(tests) { - var checks = convertAll$l(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$l(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$m() { - return true -} - -var unistUtilVisitParents$l = visitParents$l; - - - -var CONTINUE$G = true; -var SKIP$G = 'skip'; -var EXIT$G = false; - -visitParents$l.CONTINUE = CONTINUE$G; -visitParents$l.SKIP = SKIP$G; -visitParents$l.EXIT = EXIT$G; - -function visitParents$l(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$l(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$l(visitor(node, parents)); - - if (result[0] === EXIT$G) { - return result - } - } - - if (node.children && result[0] !== SKIP$G) { - subresult = toResult$l(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$G ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$G) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$l(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$G, value] - } - - return [value] -} - -var unistUtilVisit$l = visit$l; - - - -var CONTINUE$H = unistUtilVisitParents$l.CONTINUE; -var SKIP$H = unistUtilVisitParents$l.SKIP; -var EXIT$H = unistUtilVisitParents$l.EXIT; - -visit$l.CONTINUE = CONTINUE$H; -visit$l.SKIP = SKIP$H; -visit$l.EXIT = EXIT$H; - -function visit$l(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$l(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintDefinitionSpacing = unifiedLintRule('remark-lint:definition-spacing', definitionSpacing); - -var label$1 = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/; -var reason$a = 'Do not use consecutive whitespace in definition labels'; - -function definitionSpacing(tree, file) { - var contents = String(file); - - unistUtilVisit$l(tree, ['definition', 'footnoteDefinition'], check); - - function check(node) { - var start = unistUtilPosition.start(node).offset; - var end = unistUtilPosition.end(node).offset; - - if ( - !unistUtilGenerated(node) && - /[ \t\n]{2,}/.test(contents.slice(start, end).match(label$1)[1]) - ) { - file.message(reason$a, node); - } - } -} - -var convert_1$m = convert$p; - -function convert$p(test) { - if (typeof test === 'string') { - return typeFactory$m(test) - } - - if (test === null || test === undefined) { - return ok$n - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$m : matchesFactory$m)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$m(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$p(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$m(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$m(tests) { - var checks = convertAll$m(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$m(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$n() { - return true -} - -var unistUtilVisitParents$m = visitParents$m; - - - -var CONTINUE$I = true; -var SKIP$I = 'skip'; -var EXIT$I = false; - -visitParents$m.CONTINUE = CONTINUE$I; -visitParents$m.SKIP = SKIP$I; -visitParents$m.EXIT = EXIT$I; - -function visitParents$m(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$m(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$m(visitor(node, parents)); - - if (result[0] === EXIT$I) { - return result - } - } - - if (node.children && result[0] !== SKIP$I) { - subresult = toResult$m(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$I ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$I) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$m(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$I, value] - } - - return [value] -} - -var unistUtilVisit$m = visit$m; - - - -var CONTINUE$J = unistUtilVisitParents$m.CONTINUE; -var SKIP$J = unistUtilVisitParents$m.SKIP; -var EXIT$J = unistUtilVisitParents$m.EXIT; - -visit$m.CONTINUE = CONTINUE$J; -visit$m.SKIP = SKIP$J; -visit$m.EXIT = EXIT$J; - -function visit$m(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$m(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintFencedCodeFlag = unifiedLintRule('remark-lint:fenced-code-flag', fencedCodeFlag); - -var start$b = unistUtilPosition.start; -var end$7 = unistUtilPosition.end; - -var fence$2 = /^ {0,3}([~`])\1{2,}/; -var reasonIncorrect = 'Incorrect code language flag'; -var reasonMissing = 'Missing code language flag'; - -function fencedCodeFlag(tree, file, option) { - var contents = String(file); - var allowEmpty = false; - var allowed = []; - var flags = option; - - if (typeof flags === 'object' && !('length' in flags)) { - allowEmpty = Boolean(flags.allowEmpty); - flags = flags.flags; - } - - if (typeof flags === 'object' && 'length' in flags) { - allowed = String(flags).split(','); - } - - unistUtilVisit$m(tree, 'code', visitor); - - function visitor(node) { - var value; - - if (!unistUtilGenerated(node)) { - if (node.lang) { - if (allowed.length !== 0 && allowed.indexOf(node.lang) === -1) { - file.message(reasonIncorrect, node); - } - } else { - value = contents.slice(start$b(node).offset, end$7(node).offset); - - if (!allowEmpty && fence$2.test(value)) { - file.message(reasonMissing, node); - } - } - } - } -} - -var convert_1$n = convert$q; - -function convert$q(test) { - if (typeof test === 'string') { - return typeFactory$n(test) - } - - if (test === null || test === undefined) { - return ok$o - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$n : matchesFactory$n)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$n(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$q(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$n(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$n(tests) { - var checks = convertAll$n(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$n(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$o() { - return true -} - -var unistUtilVisitParents$n = visitParents$n; - - - -var CONTINUE$K = true; -var SKIP$K = 'skip'; -var EXIT$K = false; - -visitParents$n.CONTINUE = CONTINUE$K; -visitParents$n.SKIP = SKIP$K; -visitParents$n.EXIT = EXIT$K; - -function visitParents$n(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$n(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$n(visitor(node, parents)); - - if (result[0] === EXIT$K) { - return result - } - } - - if (node.children && result[0] !== SKIP$K) { - subresult = toResult$n(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$K ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$K) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$n(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$K, value] - } - - return [value] -} - -var unistUtilVisit$n = visit$n; - - - -var CONTINUE$L = unistUtilVisitParents$n.CONTINUE; -var SKIP$L = unistUtilVisitParents$n.SKIP; -var EXIT$L = unistUtilVisitParents$n.EXIT; - -visit$n.CONTINUE = CONTINUE$L; -visit$n.SKIP = SKIP$L; -visit$n.EXIT = EXIT$L; - -function visit$n(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$n(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintFencedCodeMarker = unifiedLintRule('remark-lint:fenced-code-marker', fencedCodeMarker); - -var markers = { - '`': true, - '~': true, - null: true -}; - -function fencedCodeMarker(tree, file, option) { - var contents = String(file); - var preferred = - typeof option === 'string' && option !== 'consistent' ? option : null; - - if (markers[preferred] !== true) { - file.fail( - 'Incorrect fenced code marker `' + - preferred + - "`: use either `'consistent'`, `` '`' ``, or `'~'`" - ); - } - - unistUtilVisit$n(tree, 'code', visitor); - - function visitor(node) { - var start; - var marker; - var label; - - if (!unistUtilGenerated(node)) { - start = unistUtilPosition.start(node).offset; - marker = contents - .slice(start, start + 4) - .replace(/^\s+/, '') - .charAt(0); - - // Ignore unfenced code blocks. - if (markers[marker] === true) { - if (preferred) { - if (marker !== preferred) { - label = preferred === '~' ? preferred : '` ` `'; - file.message( - 'Fenced code should use `' + label + '` as a marker', - node - ); - } - } else { - preferred = marker; - } - } - } - } -} - -var remarkLintFileExtension = unifiedLintRule('remark-lint:file-extension', fileExtension); - -function fileExtension(tree, file, option) { - var ext = file.extname; - var preferred = typeof option === 'string' ? option : 'md'; - - if (ext && ext.slice(1) !== preferred) { - file.message('Incorrect extension: use `' + preferred + '`'); - } -} - -var convert_1$o = convert$r; - -function convert$r(test) { - if (typeof test === 'string') { - return typeFactory$o(test) - } - - if (test === null || test === undefined) { - return ok$p - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$o : matchesFactory$o)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$o(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$r(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$o(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$o(tests) { - var checks = convertAll$o(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$o(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$p() { - return true -} - -var unistUtilVisitParents$o = visitParents$o; - - - -var CONTINUE$M = true; -var SKIP$M = 'skip'; -var EXIT$M = false; - -visitParents$o.CONTINUE = CONTINUE$M; -visitParents$o.SKIP = SKIP$M; -visitParents$o.EXIT = EXIT$M; - -function visitParents$o(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$o(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$o(visitor(node, parents)); - - if (result[0] === EXIT$M) { - return result - } - } - - if (node.children && result[0] !== SKIP$M) { - subresult = toResult$o(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$M ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$M) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$o(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$M, value] - } - - return [value] -} - -var unistUtilVisit$o = visit$o; - - - -var CONTINUE$N = unistUtilVisitParents$o.CONTINUE; -var SKIP$N = unistUtilVisitParents$o.SKIP; -var EXIT$N = unistUtilVisitParents$o.EXIT; - -visit$o.CONTINUE = CONTINUE$N; -visit$o.SKIP = SKIP$N; -visit$o.EXIT = EXIT$N; - -function visit$o(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$o(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintFinalDefinition = unifiedLintRule('remark-lint:final-definition', finalDefinition); - -var start$c = unistUtilPosition.start; - -function finalDefinition(tree, file) { - var last = null; - - unistUtilVisit$o(tree, visitor, true); - - function visitor(node) { - var line = start$c(node).line; - - // Ignore generated nodes. - if (node.type === 'root' || unistUtilGenerated(node)) { - return - } - - if (node.type === 'definition') { - if (last !== null && last > line) { - file.message( - 'Move definitions to the end of the file (after the node at line `' + - last + - '`)', - node - ); - } - } else if (last === null) { - last = line; - } - } -} - -var convert_1$p = convert$s; - -function convert$s(test) { - if (typeof test === 'string') { - return typeFactory$p(test) - } - - if (test === null || test === undefined) { - return ok$q - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$p : matchesFactory$p)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$p(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$s(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$p(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$p(tests) { - var checks = convertAll$p(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$p(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$q() { - return true -} - -var unistUtilVisitParents$p = visitParents$p; - - - -var CONTINUE$O = true; -var SKIP$O = 'skip'; -var EXIT$O = false; - -visitParents$p.CONTINUE = CONTINUE$O; -visitParents$p.SKIP = SKIP$O; -visitParents$p.EXIT = EXIT$O; - -function visitParents$p(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$p(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$p(visitor(node, parents)); - - if (result[0] === EXIT$O) { - return result - } - } - - if (node.children && result[0] !== SKIP$O) { - subresult = toResult$p(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$O ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$O) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$p(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$O, value] - } - - return [value] -} - -var unistUtilVisit$p = visit$p; - - - -var CONTINUE$P = unistUtilVisitParents$p.CONTINUE; -var SKIP$P = unistUtilVisitParents$p.SKIP; -var EXIT$P = unistUtilVisitParents$p.EXIT; - -visit$p.CONTINUE = CONTINUE$P; -visit$p.SKIP = SKIP$P; -visit$p.EXIT = EXIT$P; - -function visit$p(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$p(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintFirstHeadingLevel = unifiedLintRule('remark-lint:first-heading-level', firstHeadingLevel); - -var re$3 = / min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$Q) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$q(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$Q, value] - } - - return [value] -} - -var unistUtilVisit$q = visit$q; - - - -var CONTINUE$R = unistUtilVisitParents$q.CONTINUE; -var SKIP$R = unistUtilVisitParents$q.SKIP; -var EXIT$R = unistUtilVisitParents$q.EXIT; - -visit$q.CONTINUE = CONTINUE$R; -visit$q.SKIP = SKIP$R; -visit$q.EXIT = EXIT$R; - -function visit$q(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$q(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintHeadingStyle = unifiedLintRule('remark-lint:heading-style', headingStyle); - -var types$2 = ['atx', 'atx-closed', 'setext']; - -function headingStyle(tree, file, option) { - var preferred = types$2.indexOf(option) === -1 ? null : option; - - unistUtilVisit$q(tree, 'heading', visitor); - - function visitor(node) { - if (!unistUtilGenerated(node)) { - if (preferred) { - if (mdastUtilHeadingStyle(node, preferred) !== preferred) { - file.message('Headings should use ' + preferred, node); - } - } else { - preferred = mdastUtilHeadingStyle(node, preferred); - } - } - } -} - -var convert_1$r = convert$u; - -function convert$u(test) { - if (typeof test === 'string') { - return typeFactory$r(test) - } - - if (test === null || test === undefined) { - return ok$s - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$r : matchesFactory$r)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$r(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$u(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$r(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$r(tests) { - var checks = convertAll$r(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$r(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$s() { - return true -} - -var unistUtilVisitParents$r = visitParents$r; - - - -var CONTINUE$S = true; -var SKIP$S = 'skip'; -var EXIT$S = false; - -visitParents$r.CONTINUE = CONTINUE$S; -visitParents$r.SKIP = SKIP$S; -visitParents$r.EXIT = EXIT$S; - -function visitParents$r(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$r(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$r(visitor(node, parents)); - - if (result[0] === EXIT$S) { - return result - } - } - - if (node.children && result[0] !== SKIP$S) { - subresult = toResult$r(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$S ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$S) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$r(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$S, value] - } - - return [value] -} - -var unistUtilVisit$r = visit$r; - - - -var CONTINUE$T = unistUtilVisitParents$r.CONTINUE; -var SKIP$T = unistUtilVisitParents$r.SKIP; -var EXIT$T = unistUtilVisitParents$r.EXIT; - -visit$r.CONTINUE = CONTINUE$T; -visit$r.SKIP = SKIP$T; -visit$r.EXIT = EXIT$T; - -function visit$r(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$r(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintMaximumLineLength = unifiedLintRule('remark-lint:maximum-line-length', maximumLineLength); - -var start$d = unistUtilPosition.start; -var end$8 = unistUtilPosition.end; - -function maximumLineLength(tree, file, option) { - var preferred = typeof option === 'number' && !isNaN(option) ? option : 80; - var content = String(file); - var lines = content.split(/\r?\n/); - var length = lines.length; - var index = -1; - var lineLength; - - // Note: JSX is from MDX: . - unistUtilVisit$r(tree, ['heading', 'table', 'code', 'definition', 'html', 'jsx'], ignore); - unistUtilVisit$r(tree, ['link', 'image', 'inlineCode'], inline); - - // Iterate over every line, and warn for violating lines. - while (++index < length) { - lineLength = lines[index].length; - - if (lineLength > preferred) { - file.message('Line must be at most ' + preferred + ' 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 whitespace 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$d(node); - final = end$8(node); - - // No whitelisting when starting after the border, or ending before it. - if (initial.column > preferred || final.column < preferred) { - return - } - - // No whitelisting when there’s whitespace after the link. - if ( - next && - start$d(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$d(node).line - 1, end$8(node).line); - } - } - - // Whitelist from `initial` to `final`, zero-based. - function whitelist(initial, final) { - while (initial < final) { - lines[initial++] = ''; - } - } -} - -var convert_1$s = convert$v; - -function convert$v(test) { - if (typeof test === 'string') { - return typeFactory$s(test) - } - - if (test === null || test === undefined) { - return ok$t - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$s : matchesFactory$s)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$s(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$v(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$s(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$s(tests) { - var checks = convertAll$s(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$s(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$t() { - return true -} - -var unistUtilVisitParents$s = visitParents$s; - - - -var CONTINUE$U = true; -var SKIP$U = 'skip'; -var EXIT$U = false; - -visitParents$s.CONTINUE = CONTINUE$U; -visitParents$s.SKIP = SKIP$U; -visitParents$s.EXIT = EXIT$U; - -function visitParents$s(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$s(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$s(visitor(node, parents)); - - if (result[0] === EXIT$U) { - return result - } - } - - if (node.children && result[0] !== SKIP$U) { - subresult = toResult$s(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$U ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$U) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$s(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$U, value] - } - - return [value] -} - -var unistUtilVisit$s = visit$s; - - - -var CONTINUE$V = unistUtilVisitParents$s.CONTINUE; -var SKIP$V = unistUtilVisitParents$s.SKIP; -var EXIT$V = unistUtilVisitParents$s.EXIT; - -visit$s.CONTINUE = CONTINUE$V; -visit$s.SKIP = SKIP$V; -visit$s.EXIT = EXIT$V; - -function visit$s(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$s(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - -var remarkLintNoConsecutiveBlankLines = unifiedLintRule( - 'remark-lint:no-consecutive-blank-lines', - noConsecutiveBlankLines -); - -function noConsecutiveBlankLines(tree, file) { - unistUtilVisit$s(tree, visitor); - - function visitor(node) { - var children = node.children; - var head; - var tail; - - if (!unistUtilGenerated(node) && children) { - head = children[0]; - - if (head && !unistUtilGenerated(head)) { - // Compare parent and first child. - compare(unistUtilPosition.start(node), unistUtilPosition.start(head), 0); - - // Compare between each child. - children.forEach(visitChild); - - tail = children[children.length - 1]; - - // Compare parent and last child. - if (tail !== head && !unistUtilGenerated(tail)) { - compare(unistUtilPosition.end(node), unistUtilPosition.end(tail), 1); - } - } - } - } - - // Compare the difference between `start` and `end`, and warn when that - // difference exceeds `max`. - function compare(start, end, max) { - var diff = end.line - start.line; - var lines = Math.abs(diff) - max; - var reason; - - if (lines > 0) { - reason = - 'Remove ' + - lines + - ' ' + - pluralize('line', Math.abs(lines)) + - ' ' + - (diff > 0 ? 'before' : 'after') + - ' node'; - - file.message(reason, end); - } - } - - function visitChild(child, index, all) { - var previous = all[index - 1]; - var max = 2; - - if (previous && !unistUtilGenerated(previous) && !unistUtilGenerated(child)) { - if ( - (previous.type === 'list' && child.type === 'list') || - (child.type === 'code' && previous.type === 'list' && !child.lang) - ) { - max++; - } - - compare(unistUtilPosition.end(previous), unistUtilPosition.start(child), max); - } - } -} - -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$b = 'Do not use consecutive dashes in a file name'; - -function noFileNameConsecutiveDashes(tree, file) { - if (file.stem && /-{2,}/.test(file.stem)) { - file.message(reason$b); - } -} - -var remarkLintNoFileNameOuterDashes = unifiedLintRule( - 'remark-lint:no-file-name-outer-dashes', - noFileNameOuterDashes -); - -var reason$c = 'Do not use initial or final dashes in a file name'; - -function noFileNameOuterDashes(tree, file) { - if (file.stem && /^-|-$/.test(file.stem)) { - file.message(reason$c); - } -} - -var convert_1$t = convert$w; - -function convert$w(test) { - if (typeof test === 'string') { - return typeFactory$t(test) - } - - if (test === null || test === undefined) { - return ok$u - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$t : matchesFactory$t)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$t(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$w(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$t(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$t(tests) { - var checks = convertAll$t(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$t(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$u() { - return true -} - -var unistUtilVisitParents$t = visitParents$t; - - - -var CONTINUE$W = true; -var SKIP$W = 'skip'; -var EXIT$W = false; - -visitParents$t.CONTINUE = CONTINUE$W; -visitParents$t.SKIP = SKIP$W; -visitParents$t.EXIT = EXIT$W; - -function visitParents$t(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$t(test); - - one(tree, null, []); + 'staff', + 'swine', + 'tennis', + 'traffic', + 'transportation', + 'trout', + 'tuna', + 'wealth', + 'welfare', + 'whiting', + 'wildebeest', + 'wildlife', + 'you', + /pok[eé]mon$/i, + // Regexes. + /[^aeiou]ese$/i, // "chinese", "japanese" + /deer$/i, // "deer", "reindeer" + /fish$/i, // "fish", "blowfish", "angelfish" + /measles$/i, + /o[iu]s$/i, // "carnivorous" + /pox$/i, // "chickpox", "smallpox" + /sheep$/i + ].forEach(pluralize.addUncountableRule); - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; + return pluralize; +}); +}); - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$t(visitor(node, parents)); +var start$1 = factory$9('start'); +var end = factory$9('end'); - if (result[0] === EXIT$W) { - return result - } - } +var unistUtilPosition = position$1; - if (node.children && result[0] !== SKIP$W) { - subresult = toResult$t(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$W ? subresult : result - } +position$1.start = start$1; +position$1.end = end; - return result - } +function position$1(node) { + return {start: start$1(node), end: end(node)} +} - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; +function factory$9(type) { + point.displayName = type; - while (index > min && index < children.length) { - result = one(children[index], index, parents); + return point - if (result[0] === EXIT$W) { - return result - } + function point(node) { + var point = (node && node.position && node.position[type]) || {}; - index = typeof result[1] === 'number' ? result[1] : index + step; + return { + line: point.line || null, + column: point.column || null, + offset: isNaN(point.offset) ? null : point.offset } } } -function toResult$t(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } +var unistUtilGenerated = generated; - if (typeof value === 'number') { - return [CONTINUE$W, value] - } +function generated(node) { + var position = optional(optional(node).position); + var start = optional(position.start); + var end = optional(position.end); - return [value] + return !start.line || !start.column || !end.line || !end.column } -var unistUtilVisit$t = visit$t; - - - -var CONTINUE$X = unistUtilVisitParents$t.CONTINUE; -var SKIP$X = unistUtilVisitParents$t.SKIP; -var EXIT$X = unistUtilVisitParents$t.EXIT; - -visit$t.CONTINUE = CONTINUE$X; -visit$t.SKIP = SKIP$X; -visit$t.EXIT = EXIT$X; - -function visit$t(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$t(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } +function optional(value) { + return value && typeof value === 'object' ? value : {} } -var remarkLintNoHeadingIndent = unifiedLintRule('remark-lint:no-heading-indent', noHeadingIndent); +var remarkLintListItemBulletIndent = unifiedLintRule( + 'remark-lint:list-item-bullet-indent', + listItemBulletIndent +); -var start$e = unistUtilPosition.start; +var start$2 = unistUtilPosition.start; -function noHeadingIndent(tree, file) { +function listItemBulletIndent(tree, file) { var contents = String(file); - var length = contents.length; - unistUtilVisit$t(tree, 'heading', visitor); + unistUtilVisit(tree, 'list', visitor); function visitor(node) { - var initial; - var begin; - var index; - var character; - var diff; + node.children.forEach(visitItems); + } - if (unistUtilGenerated(node)) { - return - } + function visitItems(item) { + var final; + var indent; + var reason; - initial = start$e(node); - begin = initial.offset; - index = begin - 1; + if (!unistUtilGenerated(item)) { + final = start$2(item.children[0]); + indent = contents.slice(start$2(item).offset, final.offset).match(/^\s*/)[0] + .length; - while (++index < length) { - character = contents.charAt(index); + if (indent !== 0) { + reason = + 'Incorrect indentation before bullet: remove ' + + indent + + ' ' + + pluralize('space', indent); - if (character !== ' ' && character !== '\t') { - break + file.message(reason, { + line: final.line, + column: final.column - indent + }); } } - - diff = index - begin; - - if (diff) { - file.message( - 'Remove ' + diff + ' ' + pluralize('space', diff) + ' before this heading', - { - line: initial.line, - column: initial.column + diff - } - ); - } } } -var convert_1$u = convert$x; +var remarkLintListItemIndent = unifiedLintRule('remark-lint:list-item-indent', listItemIndent); -function convert$x(test) { - if (typeof test === 'string') { - return typeFactory$u(test) - } +var start$3 = unistUtilPosition.start; - if (test === null || test === undefined) { - return ok$v - } +var styles$1 = {'tab-size': true, mixed: true, space: true}; - if (typeof test === 'object') { - return ('length' in test ? anyFactory$u : matchesFactory$u)(test) - } +function listItemIndent(tree, file, option) { + var contents = String(file); + var preferred = typeof option === 'string' ? option : 'tab-size'; - if (typeof test === 'function') { - return test + if (styles$1[preferred] !== true) { + file.fail( + 'Incorrect list-item indent style `' + + preferred + + "`: use either `'tab-size'`, `'space'`, or `'mixed'`" + ); } - throw new Error('Expected function, string, or object as test') -} - -function convertAll$u(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$x(tests[index]); - } + unistUtilVisit(tree, 'list', visitor); - return results -} + function visitor(node) { + var spread = node.spread || node.loose; -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$u(test) { - return matches + if (!unistUtilGenerated(node)) { + node.children.forEach(visitItem); + } - function matches(node) { - var key; + function visitItem(item) { + var head = item.children[0]; + var final = start$3(head); + var marker; + var bulletSize; + var style; + var diff; + var reason; + var abs; - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } + marker = contents + .slice(start$3(item).offset, final.offset) + .replace(/\[[x ]?]\s*$/i, ''); - return true - } -} + bulletSize = marker.replace(/\s+$/, '').length; -function anyFactory$u(tests) { - var checks = convertAll$u(tests); - var length = checks.length; + style = + preferred === 'tab-size' || (preferred === 'mixed' && spread) + ? Math.ceil(bulletSize / 4) * 4 + : bulletSize + 1; - return matches + if (marker.length !== style) { + diff = style - marker.length; + abs = Math.abs(diff); - function matches() { - var index = -1; + reason = + 'Incorrect list-item indent: ' + + (diff > 0 ? 'add' : 'remove') + + ' ' + + abs + + ' ' + + pluralize('space', abs); - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true + file.message(reason, final); } } - - return false } } -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$u(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} +var mdastUtilToString = toString$3; -// Utility to return true. -function ok$v() { - return true +// Get the text content of a node. +// Prefer the node’s plain-text fields, otherwise serialize its children, +// and if the given value is an array, serialize the nodes in it. +function toString$3(node) { + return ( + (node && + (node.value || + node.alt || + node.title || + ('children' in node && all$1(node.children)) || + ('length' in node && all$1(node)))) || + '' + ) } -var unistUtilVisitParents$u = visitParents$u; - - - -var CONTINUE$Y = true; -var SKIP$Y = 'skip'; -var EXIT$Y = false; - -visitParents$u.CONTINUE = CONTINUE$Y; -visitParents$u.SKIP = SKIP$Y; -visitParents$u.EXIT = EXIT$Y; - -function visitParents$u(tree, test, visitor, reverse) { - var is; +function all$1(values) { + var result = []; + var length = values.length; + var index = -1; - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; + while (++index < length) { + result[index] = toString$3(values[index]); } - is = convert_1$u(test); - - one(tree, null, []); + return result.join('') +} - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; +var remarkLintNoAutoLinkWithoutProtocol = unifiedLintRule( + 'remark-lint:no-auto-link-without-protocol', + noAutoLinkWithoutProtocol +); - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$u(visitor(node, parents)); +var start$4 = unistUtilPosition.start; +var end$1 = unistUtilPosition.end; - if (result[0] === EXIT$Y) { - return result - } - } +// Protocol expression. +// See: . +var protocol$2 = /^[a-z][a-z+.-]+:\/?/i; - if (node.children && result[0] !== SKIP$Y) { - subresult = toResult$u(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$Y ? subresult : result - } +var reason = 'All automatic links must start with a protocol'; - return result - } +function noAutoLinkWithoutProtocol(tree, file) { + unistUtilVisit(tree, 'link', visitor); - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; + function visitor(node) { + var children; - while (index > min && index < children.length) { - result = one(children[index], index, parents); + if (!unistUtilGenerated(node)) { + children = node.children; - if (result[0] === EXIT$Y) { - return result + if ( + start$4(node).column === start$4(children[0]).column - 1 && + end$1(node).column === end$1(children[children.length - 1]).column + 1 && + !protocol$2.test(mdastUtilToString(node)) + ) { + file.message(reason, node); } - - index = typeof result[1] === 'number' ? result[1] : index + step; } } } -function toResult$u(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$Y, value] - } - - return [value] -} - -var unistUtilVisit$u = visit$u; - - - -var CONTINUE$Z = unistUtilVisitParents$u.CONTINUE; -var SKIP$Z = unistUtilVisitParents$u.SKIP; -var EXIT$Z = unistUtilVisitParents$u.EXIT; - -visit$u.CONTINUE = CONTINUE$Z; -visit$u.SKIP = SKIP$Z; -visit$u.EXIT = EXIT$Z; +var remarkLintNoBlockquoteWithoutMarker = unifiedLintRule( + 'remark-lint:no-blockquote-without-marker', + noBlockquoteWithoutMarker +); -function visit$u(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } +var reason$1 = 'Missing marker in block quote'; - unistUtilVisitParents$u(tree, test, overload, reverse); +function noBlockquoteWithoutMarker(tree, file) { + var contents = String(file); + var location = vfileLocation(file); + var last = contents.length; - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} + unistUtilVisit(tree, 'blockquote', visitor); -var start$f = unistUtilPosition.start; + function visitor(node) { + var indent = node.position && node.position.indent; + var start; + var length; + var index; + var line; + var offset; + var character; + var pos; + if (unistUtilGenerated(node) || !indent || indent.length === 0) { + return + } + start = unistUtilPosition.start(node).line; + length = indent.length; + index = -1; -var remarkLintNoMultipleToplevelHeadings = unifiedLintRule( - 'remark-lint:no-multiple-toplevel-headings', - noMultipleToplevelHeadings -); + while (++index < length) { + line = start + index + 1; + pos = {line: line, column: indent[index]}; + offset = location.toOffset(pos) - 1; -function noMultipleToplevelHeadings(tree, file, option) { - var preferred = option || 1; - var duplicate; + while (++offset < last) { + character = contents.charAt(offset); - unistUtilVisit$u(tree, 'heading', visitor); + if (character === '>') { + break + } - function visitor(node) { - if (!unistUtilGenerated(node) && node.depth === preferred) { - if (duplicate) { - file.message( - 'Don’t use multiple top level headings (' + duplicate + ')', - node - ); - } else { - duplicate = unistUtilStringifyPosition(start$f(node)); + /* istanbul ignore else - just for safety */ + if (character !== ' ' && character !== '\t') { + file.message(reason$1, pos); + break + } } } } } -var convert_1$v = convert$y; +var remarkLintNoLiteralUrls = unifiedLintRule('remark-lint:no-literal-urls', noLiteralURLs); -function convert$y(test) { - if (typeof test === 'string') { - return typeFactory$v(test) - } +var start$5 = unistUtilPosition.start; +var end$2 = unistUtilPosition.end; +var mailto$2 = 'mailto:'; +var reason$2 = 'Don’t use literal URLs without angle brackets'; - if (test === null || test === undefined) { - return ok$w - } +function noLiteralURLs(tree, file) { + unistUtilVisit(tree, 'link', visitor); - if (typeof test === 'object') { - return ('length' in test ? anyFactory$v : matchesFactory$v)(test) - } + function visitor(node) { + var children = node.children; + var value = mdastUtilToString(node); - if (typeof test === 'function') { - return test + if ( + !unistUtilGenerated(node) && + start$5(node).column === start$5(children[0]).column && + end$2(node).column === end$2(children[children.length - 1]).column && + (node.url === mailto$2 + value || node.url === value) + ) { + file.message(reason$2, node); + } } - - throw new Error('Expected function, string, or object as test') } -function convertAll$v(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$y(tests[index]); - } - - return results -} +var remarkLintOrderedListMarkerStyle = unifiedLintRule( + 'remark-lint:ordered-list-marker-style', + orderedListMarkerStyle +); -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$v(test) { - return matches +var start$6 = unistUtilPosition.start; - function matches(node) { - var key; +var styles$2 = { + ')': true, + '.': true, + null: true +}; - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } +function orderedListMarkerStyle(tree, file, option) { + var contents = String(file); + var preferred = + typeof option !== 'string' || option === 'consistent' ? null : option; - return true + if (styles$2[preferred] !== true) { + file.fail( + 'Incorrect ordered list item marker style `' + + preferred + + "`: use either `'.'` or `')'`" + ); } -} - -function anyFactory$v(tests) { - var checks = convertAll$v(tests); - var length = checks.length; - return matches + unistUtilVisit(tree, 'list', visitor); - function matches() { + function visitor(node) { + var children = node.children; + var length = node.ordered ? children.length : 0; var index = -1; + var marker; + var child; while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$v(test) { - return type + child = children[index]; - function type(node) { - return Boolean(node && node.type === test) - } -} + if (!unistUtilGenerated(child)) { + marker = contents + .slice(start$6(child).offset, start$6(child.children[0]).offset) + .replace(/\s|\d/g, '') + .replace(/\[[x ]?]\s*$/i, ''); -// Utility to return true. -function ok$w() { - return true + if (preferred) { + if (marker !== preferred) { + file.message('Marker style should be `' + preferred + '`', child); + } + } else { + preferred = marker; + } + } + } + } } -var unistUtilVisitParents$v = visitParents$v; +var remarkLintHardBreakSpaces = unifiedLintRule('remark-lint:hard-break-spaces', hardBreakSpaces); +var reason$3 = 'Use two spaces for hard line breaks'; +function hardBreakSpaces(tree, file) { + var contents = String(file); -var CONTINUE$_ = true; -var SKIP$_ = 'skip'; -var EXIT$_ = false; + unistUtilVisit(tree, 'break', visitor); -visitParents$v.CONTINUE = CONTINUE$_; -visitParents$v.SKIP = SKIP$_; -visitParents$v.EXIT = EXIT$_; + function visitor(node) { + var value; -function visitParents$v(tree, test, visitor, reverse) { - var is; + if (!unistUtilGenerated(node)) { + value = contents + .slice(unistUtilPosition.start(node).offset, unistUtilPosition.end(node).offset) + .split('\n', 1)[0] + .replace(/\r$/, ''); - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; + if (value.length > 2) { + file.message(reason$3, node); + } + } } +} - is = convert_1$v(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$v(visitor(node, parents)); +var remarkLintNoDuplicateDefinitions = unifiedLintRule( + 'remark-lint:no-duplicate-definitions', + noDuplicateDefinitions +); - if (result[0] === EXIT$_) { - return result - } - } +var reason$4 = 'Do not use definitions with the same identifier'; - if (node.children && result[0] !== SKIP$_) { - subresult = toResult$v(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$_ ? subresult : result - } +function noDuplicateDefinitions(tree, file) { + var map = {}; - return result - } + unistUtilVisit(tree, ['definition', 'footnoteDefinition'], check); - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; + function check(node) { + var identifier; + var duplicate; - while (index > min && index < children.length) { - result = one(children[index], index, parents); + if (!unistUtilGenerated(node)) { + identifier = node.identifier; + duplicate = map[identifier]; - if (result[0] === EXIT$_) { - return result + if (duplicate && duplicate.type) { + file.message( + reason$4 + ' (' + unistUtilStringifyPosition(unistUtilPosition.start(duplicate)) + ')', + node + ); } - index = typeof result[1] === 'number' ? result[1] : index + step; + map[identifier] = node; } } } -function toResult$v(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$_, value] - } - - return [value] -} +var mdastUtilHeadingStyle = style; -var unistUtilVisit$v = visit$v; +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) + } -var CONTINUE$$ = unistUtilVisitParents$v.CONTINUE; -var SKIP$$ = unistUtilVisitParents$v.SKIP; -var EXIT$$ = unistUtilVisitParents$v.EXIT; + return 'atx-closed' + } -visit$v.CONTINUE = CONTINUE$$; -visit$v.SKIP = SKIP$$; -visit$v.EXIT = EXIT$$; + if (final.line + 1 === pos.line) { + return 'setext' + } -function visit$v(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; + if (final.column + depth < pos.column) { + return 'atx-closed' } - unistUtilVisitParents$v(tree, test, overload, reverse); + return consolidate(depth, relative) +} - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } +// 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 remarkLintNoShellDollars = unifiedLintRule('remark-lint:no-shell-dollars', noShellDollars); +var remarkLintNoHeadingContentIndent = unifiedLintRule( + 'remark-lint:no-heading-content-indent', + noHeadingContentIndent +); -var reason$d = 'Do not use dollar signs before shell commands'; +var start$7 = unistUtilPosition.start; +var end$3 = unistUtilPosition.end; -// List of shell script file extensions (also used as code flags for syntax -// highlighting on GitHub): -// See: -var flags = [ - 'sh', - 'bash', - 'bats', - 'cgi', - 'command', - 'fcgi', - 'ksh', - 'tmux', - 'tool', - 'zsh' -]; +function noHeadingContentIndent(tree, file) { + var contents = String(file); -function noShellDollars(tree, file) { - unistUtilVisit$v(tree, 'code', visitor); + unistUtilVisit(tree, 'heading', visitor); function visitor(node) { - var lines; - var line; - var length; + var depth; + var children; + var type; + var head; + var initial; + var final; + var diff; var index; + var char; + var reason; + var abs; - // Check both known shell code and unknown code. - if (!unistUtilGenerated(node) && node.lang && flags.indexOf(node.lang) !== -1) { - lines = node.value.split('\n'); - length = lines.length; - index = -1; + if (unistUtilGenerated(node)) { + return + } + + depth = node.depth; + children = node.children; + type = mdastUtilHeadingStyle(node, 'atx'); + + if (type === 'atx' || type === 'atx-closed') { + initial = start$7(node); + index = initial.offset; + char = contents.charAt(index); + + while (char && char !== '#') { + char = contents.charAt(++index); + } - if (length <= 1) { + /* istanbul ignore if - CR/LF bug: remarkjs/remark#195. */ + if (!char) { return } - while (++index < length) { - line = lines[index]; + index = depth + (index - initial.offset); + head = start$7(children[0]).column; - if (line.trim() && !line.match(/^\s*\$\s*/)) { - return - } + // Ignore empty headings. + if (!head) { + return } - file.message(reason$d, node); - } - } -} + diff = head - initial.column - 1 - index; -var convert_1$w = convert$z; + if (diff) { + abs = Math.abs(diff); -function convert$z(test) { - if (typeof test === 'string') { - return typeFactory$w(test) - } + reason = + (diff > 0 ? 'Remove' : 'Add') + + ' ' + + abs + + ' ' + + pluralize('space', abs) + + ' before this heading’s content'; - if (test === null || test === undefined) { - return ok$x - } + file.message(reason, start$7(children[0])); + } + } - if (typeof test === 'object') { - return ('length' in test ? anyFactory$w : matchesFactory$w)(test) - } + // Closed ATX headings always must have a space 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; - if (typeof test === 'function') { - return test - } + if (diff) { + reason = + 'Remove ' + + diff + + ' ' + + pluralize('space', diff) + + ' after this heading’s content'; - throw new Error('Expected function, string, or object as test') + file.message(reason, final); + } + } + } } -function convertAll$w(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$z(tests[index]); - } +var remarkLintNoInlinePadding = unifiedLintRule('remark-lint:no-inline-padding', noInlinePadding); - return results -} +function noInlinePadding(tree, file) { + unistUtilVisit(tree, ['emphasis', 'strong', 'delete', 'image', 'link'], visitor); -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$w(test) { - return matches + function visitor(node) { + var contents; - function matches(node) { - var key; + if (!unistUtilGenerated(node)) { + contents = mdastUtilToString(node); - for (key in test) { - if (node[key] !== test[key]) { - return false + if ( + contents.charAt(0) === ' ' || + contents.charAt(contents.length - 1) === ' ' + ) { + file.message('Don’t pad `' + node.type + '` with inner spaces', node); } } - - return true } } -function anyFactory$w(tests) { - var checks = convertAll$w(tests); - var length = checks.length; +var remarkLintNoShortcutReferenceImage = unifiedLintRule( + 'remark-lint:no-shortcut-reference-image', + noShortcutReferenceImage +); - return matches +var reason$5 = 'Use the trailing [] on reference images'; - function matches() { - var index = -1; +function noShortcutReferenceImage(tree, file) { + unistUtilVisit(tree, 'imageReference', visitor); - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } + function visitor(node) { + if (!unistUtilGenerated(node) && node.referenceType === 'shortcut') { + file.message(reason$5, node); } - - return false } } -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$w(test) { - return type +var remarkLintNoShortcutReferenceLink = unifiedLintRule( + 'remark-lint:no-shortcut-reference-link', + noShortcutReferenceLink +); - function type(node) { - return Boolean(node && node.type === test) - } -} +var reason$6 = 'Use the trailing `[]` on reference links'; -// Utility to return true. -function ok$x() { - return true +function noShortcutReferenceLink(tree, file) { + unistUtilVisit(tree, 'linkReference', visitor); + + function visitor(node) { + if (!unistUtilGenerated(node) && node.referenceType === 'shortcut') { + file.message(reason$6, node); + } + } } -var unistUtilVisitParents$w = visitParents$w; +var remarkLintNoUndefinedReferences = unifiedLintRule( + 'remark-lint:no-undefined-references', + noUndefinedReferences +); +var reason$7 = 'Found reference to undefined definition'; +// The identifier is upcased to avoid naming collisions with fields inherited +// from `Object.prototype`. +// If `Object.create(null)` was used in place of `{}`, downcasing would work +// equally well. +function normalize$3(s) { + return collapseWhiteSpace(s.toUpperCase()) +} -var CONTINUE$10 = true; -var SKIP$10 = 'skip'; -var EXIT$10 = false; +function noUndefinedReferences(tree, file, option) { + var allow = ((option || {}).allow || []).map(normalize$3); + var map = {}; -visitParents$w.CONTINUE = CONTINUE$10; -visitParents$w.SKIP = SKIP$10; -visitParents$w.EXIT = EXIT$10; + unistUtilVisit(tree, ['definition', 'footnoteDefinition'], mark); + unistUtilVisit(tree, ['imageReference', 'linkReference', 'footnoteReference'], find); -function visitParents$w(tree, test, visitor, reverse) { - var is; + function mark(node) { + if (!unistUtilGenerated(node)) { + map[normalize$3(node.identifier)] = true; + } + } - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; + function find(node) { + if ( + !unistUtilGenerated(node) && + !(normalize$3(node.identifier) in map) && + allow.indexOf(normalize$3(node.identifier)) === -1 + ) { + file.message(reason$7, node); + } } +} - is = convert_1$w(test); +var remarkLintNoUnusedDefinitions = unifiedLintRule('remark-lint:no-unused-definitions', noUnusedDefinitions); - one(tree, null, []); +var reason$8 = 'Found unused definition'; - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; +function noUnusedDefinitions(tree, file) { + var map = {}; + var identifier; + var entry; - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$w(visitor(node, parents)); + unistUtilVisit(tree, ['definition', 'footnoteDefinition'], find); + unistUtilVisit(tree, ['imageReference', 'linkReference', 'footnoteReference'], mark); - if (result[0] === EXIT$10) { - return result - } - } + for (identifier in map) { + entry = map[identifier]; - if (node.children && result[0] !== SKIP$10) { - subresult = toResult$w(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$10 ? subresult : result + if (!entry.used) { + file.message(reason$8, entry.node); } - - return result } - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); + function find(node) { + if (!unistUtilGenerated(node)) { + map[node.identifier.toUpperCase()] = {node: node, used: false}; + } + } - if (result[0] === EXIT$10) { - return result - } + function mark(node) { + var info = map[node.identifier.toUpperCase()]; - index = typeof result[1] === 'number' ? result[1] : index + step; + if (!unistUtilGenerated(node) && info) { + info.used = true; } } } -function toResult$w(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$10, value] - } +var plugins$1 = [ + remarkLint, + // Unix compatibility. + remarkLintFinalNewline, + // Rendering across vendors differs greatly if using other styles. + remarkLintListItemBulletIndent, + [remarkLintListItemIndent, 'tab-size'], + // Differs or unsupported across vendors. + remarkLintNoAutoLinkWithoutProtocol, + remarkLintNoBlockquoteWithoutMarker, + remarkLintNoLiteralUrls, + [remarkLintOrderedListMarkerStyle, '.'], + // Mistakes. + remarkLintHardBreakSpaces, + remarkLintNoDuplicateDefinitions, + remarkLintNoHeadingContentIndent, + remarkLintNoInlinePadding, + remarkLintNoShortcutReferenceImage, + remarkLintNoShortcutReferenceLink, + remarkLintNoUndefinedReferences, + remarkLintNoUnusedDefinitions +]; - return [value] -} +var remarkPresetLintRecommended = { + plugins: plugins$1 +}; -var unistUtilVisit$w = visit$w; +var remarkLintBlockquoteIndentation = unifiedLintRule( + 'remark-lint:blockquote-indentation', + blockquoteIndentation +); +function blockquoteIndentation(tree, file, option) { + var preferred = typeof option === 'number' && !isNaN(option) ? option : null; + unistUtilVisit(tree, 'blockquote', visitor); -var CONTINUE$11 = unistUtilVisitParents$w.CONTINUE; -var SKIP$11 = unistUtilVisitParents$w.SKIP; -var EXIT$11 = unistUtilVisitParents$w.EXIT; + function visitor(node) { + var abs; + var diff; + var reason; -visit$w.CONTINUE = CONTINUE$11; -visit$w.SKIP = SKIP$11; -visit$w.EXIT = EXIT$11; + if (unistUtilGenerated(node) || node.children.length === 0) { + return + } -function visit$w(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } + if (preferred) { + diff = preferred - check$3(node); - unistUtilVisitParents$w(tree, test, overload, reverse); + if (diff !== 0) { + abs = Math.abs(diff); + reason = + (diff > 0 ? 'Add' : 'Remove') + + ' ' + + abs + + ' ' + + pluralize('space', abs) + + ' between block quote and content'; - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) + file.message(reason, unistUtilPosition.start(node.children[0])); + } + } else { + preferred = check$3(node); + } } } -var remarkLintNoTableIndentation = unifiedLintRule('remark-lint:no-table-indentation', noTableIndentation); +function check$3(node) { + var head = node.children[0]; + var indentation = unistUtilPosition.start(head).column - unistUtilPosition.start(node).column; + var padding = mdastUtilToString(head).match(/^ +/); -var reason$e = 'Do not indent table rows'; + if (padding) { + indentation += padding[0].length; + } -function noTableIndentation(tree, file) { - var contents = String(file); + return indentation +} - unistUtilVisit$w(tree, 'table', visitor); +var remarkLintCheckboxCharacterStyle = unifiedLintRule( + 'remark-lint:checkbox-character-style', + checkboxCharacterStyle +); - function visitor(node) { - if (!unistUtilGenerated(node)) { - node.children.forEach(each); - } +var start$8 = unistUtilPosition.start; +var end$4 = unistUtilPosition.end; - return unistUtilVisit$w.SKIP - } +var checked = {x: true, X: true}; +var unchecked = {' ': true, '\t': true}; +var types$1 = {true: 'checked', false: 'unchecked'}; - function each(row) { - var fence = contents.slice( - unistUtilPosition.start(row).offset, - unistUtilPosition.start(row.children[0]).offset - ); +function checkboxCharacterStyle(tree, file, option) { + var contents = String(file); + var location = vfileLocation(file); + var preferred = typeof option === 'object' ? option : {}; - if (fence.indexOf('|') > 1) { - file.message(reason$e, row); - } + if (preferred.unchecked && unchecked[preferred.unchecked] !== true) { + file.fail( + 'Incorrect unchecked checkbox marker `' + + preferred.unchecked + + "`: use either `'\\t'`, or `' '`" + ); } -} - -var vfileLocation$6 = factory$e; -function factory$e(file) { - var contents = indices$6(String(file)); - - return { - toPosition: offsetToPositionFactory$6(contents), - toOffset: positionToOffsetFactory$6(contents) + if (preferred.checked && checked[preferred.checked] !== true) { + file.fail( + 'Incorrect checked checkbox marker `' + + preferred.checked + + "`: use either `'x'`, or `'X'`" + ); } -} -// Factory to get the line and column-based `position` for `offset` in the bound -// indices. -function offsetToPositionFactory$6(indices) { - return offsetToPosition + unistUtilVisit(tree, 'listItem', visitor); - // Get the line and column-based `position` for `offset` in the bound indices. - function offsetToPosition(offset) { - var index = -1; - var length = indices.length; + function visitor(node) { + var type; + var initial; + var final; + var value; + var style; + var character; + var reason; - if (offset < 0) { - return {} + // Exit early for items without checkbox. + if (typeof node.checked !== 'boolean' || unistUtilGenerated(node)) { + return } - while (++index < length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset - } - } - } + type = types$1[node.checked]; + initial = start$8(node).offset; + final = (node.children.length === 0 ? end$4(node) : start$8(node.children[0])) + .offset; - return {} - } -} + // For a checkbox to be parsed, it must be followed by a whitespace. + value = contents.slice(initial, final).replace(/\s+$/, '').slice(0, -1); -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$6(indices) { - return positionToOffset + // The checkbox character is behind a square bracket. + character = value.charAt(value.length - 1); + style = preferred[type]; - // Get the `offset` for a line and column-based `position` in the bound - // indices. - function positionToOffset(position) { - var line = position && position.line; - var column = position && position.column; + if (style) { + if (character !== style) { + reason = + type.charAt(0).toUpperCase() + + type.slice(1) + + ' checkboxes should use `' + + style + + '` as a marker'; - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 + file.message(reason, { + start: location.toPosition(initial + value.length - 1), + end: location.toPosition(initial + value.length) + }); + } + } else { + preferred[type] = character; } - - return -1 } } -// Get indices of line-breaks in `value`. -function indices$6(value) { - var result = []; - var index = value.indexOf('\n'); +var remarkLintCheckboxContentIndent = unifiedLintRule( + 'remark-lint:checkbox-content-indent', + checkboxContentIndent +); - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); - } +var start$9 = unistUtilPosition.start; +var end$5 = unistUtilPosition.end; - result.push(value.length + 1); +var reason$9 = 'Checkboxes should be followed by a single character'; - return result -} +function checkboxContentIndent(tree, file) { + var contents = String(file); + var location = vfileLocation(file); -var remarkLintNoTabs = unifiedLintRule('remark-lint:no-tabs', noTabs); + unistUtilVisit(tree, 'listItem', visitor); -var reason$f = 'Use spaces instead of tabs'; + function visitor(node) { + var initial; + var final; + var value; -function noTabs(tree, file) { - var content = String(file); - var position = vfileLocation$6(file).toPosition; - var index = content.indexOf('\t'); + // Exit early for items without checkbox. + if (typeof node.checked !== 'boolean' || unistUtilGenerated(node)) { + return + } - while (index !== -1) { - file.message(reason$f, position(index)); - index = content.indexOf('\t', index + 1); - } -} + initial = start$9(node).offset; + /* istanbul ignore next - hard to test, couldn’t find a case. */ + final = (node.children.length === 0 ? end$5(node) : start$9(node.children[0])) + .offset; -var remarkLintNoTrailingSpaces = unifiedLintRule('remark-lint:no-trailing-spaces', noTrailingSpaces); + while (/[^\S\n]/.test(contents.charAt(final))) { + final++; + } -/** - * Lines that are just space characters are not present in - * the AST, which is why we loop through lines manually. - */ + // For a checkbox to be parsed, it must be followed by a whitespace. + value = contents.slice(initial, final); + value = value.slice(value.indexOf(']') + 1); -function noTrailingSpaces(ast, file) { - var lines = file.toString().split(/\r?\n/); - for (var i = 0; i < lines.length; i++) { - var currentLine = lines[i]; - var lineIndex = i + 1; - if (/\s$/.test(currentLine)) { - file.message('Remove trailing whitespace', { - position: { - start: { line: lineIndex, column: currentLine.length + 1 }, - end: { line: lineIndex } - } + if (value.length !== 1) { + file.message(reason$9, { + start: location.toPosition(final - value.length + 1), + end: location.toPosition(final) }); } } } -var escapeStringRegexp$1 = string => { - if (typeof string !== 'string') { - throw new TypeError('Expected a string'); - } - - // Escape characters with special meaning either inside or outside character sets. - // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. - return string - .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') - .replace(/-/g, '\\x2d'); -}; - -var convert_1$x = convert$A; +var remarkLintCodeBlockStyle = unifiedLintRule('remark-lint:code-block-style', codeBlockStyle); -function convert$A(test) { - if (typeof test === 'string') { - return typeFactory$x(test) - } +var start$a = unistUtilPosition.start; +var end$6 = unistUtilPosition.end; - if (test === null || test === undefined) { - return ok$y - } +var styles$3 = {null: true, fenced: true, indented: true}; - if (typeof test === 'object') { - return ('length' in test ? anyFactory$x : matchesFactory$x)(test) - } +function codeBlockStyle(tree, file, option) { + var contents = String(file); + var preferred = + typeof option === 'string' && option !== 'consistent' ? option : null; - if (typeof test === 'function') { - return test + if (styles$3[preferred] !== true) { + file.fail( + 'Incorrect code block style `' + + preferred + + "`: use either `'consistent'`, `'fenced'`, or `'indented'`" + ); } - throw new Error('Expected function, string, or object as test') -} - -function convertAll$x(tests) { - var results = []; - var length = tests.length; - var index = -1; + unistUtilVisit(tree, 'code', visitor); - while (++index < length) { - results[index] = convert$A(tests[index]); - } + function visitor(node) { + var initial; + var final; + var current; - return results -} + if (unistUtilGenerated(node)) { + return null + } -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$x(test) { - return matches + initial = start$a(node).offset; + final = end$6(node).offset; - function matches(node) { - var key; + current = + node.lang || /^\s*([~`])\1{2,}/.test(contents.slice(initial, final)) + ? 'fenced' + : 'indented'; - for (key in test) { - if (node[key] !== test[key]) { - return false + if (preferred) { + if (preferred !== current) { + file.message('Code blocks should be ' + preferred, node); } + } else { + preferred = current; } - - return true } } -function anyFactory$x(tests) { - var checks = convertAll$x(tests); - var length = checks.length; - - return matches +var remarkLintDefinitionSpacing = unifiedLintRule('remark-lint:definition-spacing', definitionSpacing); - function matches() { - var index = -1; +var label$1 = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/; +var reason$a = 'Do not use consecutive whitespace in definition labels'; - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } +function definitionSpacing(tree, file) { + var contents = String(file); - return false - } -} + unistUtilVisit(tree, ['definition', 'footnoteDefinition'], check); -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$x(test) { - return type + function check(node) { + var start = unistUtilPosition.start(node).offset; + var end = unistUtilPosition.end(node).offset; - function type(node) { - return Boolean(node && node.type === test) + if ( + !unistUtilGenerated(node) && + /[ \t\n]{2,}/.test(contents.slice(start, end).match(label$1)[1]) + ) { + file.message(reason$a, node); + } } } -// Utility to return true. -function ok$y() { - return true -} - -var unistUtilVisitParents$x = visitParents$x; - - +var remarkLintFencedCodeFlag = unifiedLintRule('remark-lint:fenced-code-flag', fencedCodeFlag); -var CONTINUE$12 = true; -var SKIP$12 = 'skip'; -var EXIT$12 = false; +var start$b = unistUtilPosition.start; +var end$7 = unistUtilPosition.end; -visitParents$x.CONTINUE = CONTINUE$12; -visitParents$x.SKIP = SKIP$12; -visitParents$x.EXIT = EXIT$12; +var fence$2 = /^ {0,3}([~`])\1{2,}/; +var reasonIncorrect = 'Incorrect code language flag'; +var reasonMissing = 'Missing code language flag'; -function visitParents$x(tree, test, visitor, reverse) { - var is; +function fencedCodeFlag(tree, file, option) { + var contents = String(file); + var allowEmpty = false; + var allowed = []; + var flags = option; - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; + if (typeof flags === 'object' && !('length' in flags)) { + allowEmpty = Boolean(flags.allowEmpty); + flags = flags.flags; } - is = convert_1$x(test); + if (typeof flags === 'object' && 'length' in flags) { + allowed = String(flags).split(','); + } - one(tree, null, []); + unistUtilVisit(tree, 'code', visitor); - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; + function visitor(node) { + var value; - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$x(visitor(node, parents)); + if (!unistUtilGenerated(node)) { + if (node.lang) { + if (allowed.length !== 0 && allowed.indexOf(node.lang) === -1) { + file.message(reasonIncorrect, node); + } + } else { + value = contents.slice(start$b(node).offset, end$7(node).offset); - if (result[0] === EXIT$12) { - return result + if (!allowEmpty && fence$2.test(value)) { + file.message(reasonMissing, node); + } } } + } +} - if (node.children && result[0] !== SKIP$12) { - subresult = toResult$x(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$12 ? subresult : result - } +var remarkLintFencedCodeMarker = unifiedLintRule('remark-lint:fenced-code-marker', fencedCodeMarker); - return result +var markers = { + '`': true, + '~': true, + null: true +}; + +function fencedCodeMarker(tree, file, option) { + var contents = String(file); + var preferred = + typeof option === 'string' && option !== 'consistent' ? option : null; + + if (markers[preferred] !== true) { + file.fail( + 'Incorrect fenced code marker `' + + preferred + + "`: use either `'consistent'`, `` '`' ``, or `'~'`" + ); } - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; + unistUtilVisit(tree, 'code', visitor); - while (index > min && index < children.length) { - result = one(children[index], index, parents); + function visitor(node) { + var start; + var marker; + var label; - if (result[0] === EXIT$12) { - return result - } + if (!unistUtilGenerated(node)) { + start = unistUtilPosition.start(node).offset; + marker = contents + .slice(start, start + 4) + .replace(/^\s+/, '') + .charAt(0); - index = typeof result[1] === 'number' ? result[1] : index + step; + // Ignore unfenced code blocks. + if (markers[marker] === true) { + if (preferred) { + if (marker !== preferred) { + label = preferred === '~' ? preferred : '` ` `'; + file.message( + 'Fenced code should use `' + label + '` as a marker', + node + ); + } + } else { + preferred = marker; + } + } } } } -function toResult$x(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } +var remarkLintFileExtension = unifiedLintRule('remark-lint:file-extension', fileExtension); - if (typeof value === 'number') { - return [CONTINUE$12, value] - } +function fileExtension(tree, file, option) { + var ext = file.extname; + var preferred = typeof option === 'string' ? option : 'md'; - return [value] + if (ext && ext.slice(1) !== preferred) { + file.message('Incorrect extension: use `' + preferred + '`'); + } } -var unistUtilVisit$x = visit$x; - +var remarkLintFinalDefinition = unifiedLintRule('remark-lint:final-definition', finalDefinition); +var start$c = unistUtilPosition.start; -var CONTINUE$13 = unistUtilVisitParents$x.CONTINUE; -var SKIP$13 = unistUtilVisitParents$x.SKIP; -var EXIT$13 = unistUtilVisitParents$x.EXIT; +function finalDefinition(tree, file) { + var last = null; -visit$x.CONTINUE = CONTINUE$13; -visit$x.SKIP = SKIP$13; -visit$x.EXIT = EXIT$13; + unistUtilVisit(tree, visitor, true); -function visit$x(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } + function visitor(node) { + var line = start$c(node).line; - unistUtilVisitParents$x(tree, test, overload, reverse); + // Ignore generated nodes. + if (node.type === 'root' || unistUtilGenerated(node)) { + return + } - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) + if (node.type === 'definition') { + if (last !== null && last > line) { + file.message( + 'Move definitions to the end of the file (after the node at line `' + + last + + '`)', + node + ); + } + } else if (last === null) { + last = line; + } } } -var vfileLocation$7 = factory$f; +var remarkLintFirstHeadingLevel = unifiedLintRule('remark-lint:first-heading-level', firstHeadingLevel); -function factory$f(file) { - var contents = indices$7(String(file)); +var re$3 = / offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset + if (rank !== undefined) { + if (rank !== preferred) { + file.message( + 'First heading level should be `' + preferred + '`', + node + ); } + + return unistUtilVisit.EXIT } } - - return {} } } -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$7(indices) { - return positionToOffset - - // Get the `offset` for a line and column-based `position` in the bound - // indices. - function positionToOffset(position) { - var line = position && position.line; - var column = position && position.column; - - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 - } - - return -1 - } +function infer(node) { + var results = node.value.match(re$3); + return results ? Number(results[1]) : undefined } -// Get indices of line-breaks in `value`. -function indices$7(value) { - var result = []; - var index = value.indexOf('\n'); - - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); - } - - result.push(value.length + 1); - - return result -} +var remarkLintHeadingStyle = unifiedLintRule('remark-lint:heading-style', headingStyle); -const start$g = unistUtilPosition.start; +var types$2 = ['atx', 'atx-closed', 'setext']; -var remarkLintProhibitedStrings = unifiedLintRule('remark-lint:prohibited-strings', prohibitedStrings); +function headingStyle(tree, file, option) { + var preferred = types$2.indexOf(option) === -1 ? null : option; -function testProhibited (val, content) { - let regexpFlags = 'g'; + unistUtilVisit(tree, 'heading', visitor); - if (!val.no) { - val.no = escapeStringRegexp$1(val.yes); - regexpFlags += 'i'; + function visitor(node) { + if (!unistUtilGenerated(node)) { + if (preferred) { + if (mdastUtilHeadingStyle(node, preferred) !== preferred) { + file.message('Headings should use ' + preferred, node); + } + } else { + preferred = mdastUtilHeadingStyle(node, preferred); + } + } } +} - let regexpString = '(?. + unistUtilVisit(tree, ['heading', 'table', 'code', 'definition', 'html', 'jsx'], ignore); + unistUtilVisit(tree, ['link', 'image', 'inlineCode'], inline); - // If it ends with a letter, make sure it is a word break. - if (/\b$/.test(val.no)) { - regexpString += '\\b'; - } - regexpString += '(?!\\.\\w)'; - const re = new RegExp(regexpString, regexpFlags); + // Iterate over every line, and warn for violating lines. + while (++index < length) { + lineLength = lines[index].length; - const results = []; - let result = re.exec(content); - while (result) { - if (result[1] !== val.yes) { - results.push({ result: result[1], index: result.index }); + if (lineLength > preferred) { + file.message('Line must be at most ' + preferred + ' characters', { + line: index + 1, + column: lineLength + 1 + }); } - result = re.exec(content); } - return results -} - -function prohibitedStrings (ast, file, strings) { - const location = vfileLocation$7(file); + // Finally, whitelist some inline spans, but only if they occur at or after + // the wrap. + // However, when they do, and there’s whitespace after it, they are not + // whitelisted. + function inline(node, pos, parent) { + var next = parent.children[pos + 1]; + var initial; + var final; - unistUtilVisit$x(ast, 'text', checkText); + /* istanbul ignore if - Nothing to whitelist when generated. */ + if (unistUtilGenerated(node)) { + return + } - function checkText (node) { - const content = node.value; - const initial = start$g(node).offset; + initial = start$d(node); + final = end$8(node); - strings.forEach((val) => { - const results = testProhibited(val, content); - if (results.length) { - results.forEach(({ result, index }) => { - const message = val.yes ? `Use "${val.yes}" instead of "${result}"` : `Do not use "${result}"`; - file.message(message, { - start: location.toPosition(initial + index), - end: location.toPosition(initial + index + [...result].length) - }); - }); - } - }); - } -} + // No whitelisting when starting after the border, or ending before it. + if (initial.column > preferred || final.column < preferred) { + return + } -var convert_1$y = convert$B; + // No whitelisting when there’s whitespace after the link. + if ( + next && + start$d(next).line === initial.line && + (!next.value || /^(.+?[ \t].+?)/.test(next.value)) + ) { + return + } -function convert$B(test) { - if (typeof test === 'string') { - return typeFactory$y(test) + whitelist(initial.line - 1, final.line); } - if (test === null || test === undefined) { - return ok$z + function ignore(node) { + /* istanbul ignore else - Hard to test, as we only run this case on `position: true` */ + if (!unistUtilGenerated(node)) { + whitelist(start$d(node).line - 1, end$8(node).line); + } } - if (typeof test === 'object') { - return ('length' in test ? anyFactory$y : matchesFactory$y)(test) + // Whitelist from `initial` to `final`, zero-based. + function whitelist(initial, final) { + while (initial < final) { + lines[initial++] = ''; + } } +} - if (typeof test === 'function') { - return test - } +var remarkLintNoConsecutiveBlankLines = unifiedLintRule( + 'remark-lint:no-consecutive-blank-lines', + noConsecutiveBlankLines +); - throw new Error('Expected function, string, or object as test') -} +function noConsecutiveBlankLines(tree, file) { + unistUtilVisit(tree, visitor); -function convertAll$y(tests) { - var results = []; - var length = tests.length; - var index = -1; + function visitor(node) { + var children = node.children; + var head; + var tail; - while (++index < length) { - results[index] = convert$B(tests[index]); - } + if (!unistUtilGenerated(node) && children) { + head = children[0]; - return results -} + if (head && !unistUtilGenerated(head)) { + // Compare parent and first child. + compare(unistUtilPosition.start(node), unistUtilPosition.start(head), 0); -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$y(test) { - return matches + // Compare between each child. + children.forEach(visitChild); - function matches(node) { - var key; + tail = children[children.length - 1]; - for (key in test) { - if (node[key] !== test[key]) { - return false + // Compare parent and last child. + if (tail !== head && !unistUtilGenerated(tail)) { + compare(unistUtilPosition.end(node), unistUtilPosition.end(tail), 1); + } } } - - return true } -} -function anyFactory$y(tests) { - var checks = convertAll$y(tests); - var length = checks.length; + // Compare the difference between `start` and `end`, and warn when that + // difference exceeds `max`. + function compare(start, end, max) { + var diff = end.line - start.line; + var lines = Math.abs(diff) - max; + var reason; - return matches + if (lines > 0) { + reason = + 'Remove ' + + lines + + ' ' + + pluralize('line', Math.abs(lines)) + + ' ' + + (diff > 0 ? 'before' : 'after') + + ' node'; - function matches() { - var index = -1; + file.message(reason, end); + } + } - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true + function visitChild(child, index, all) { + var previous = all[index - 1]; + var max = 2; + + if (previous && !unistUtilGenerated(previous) && !unistUtilGenerated(child)) { + if ( + (previous.type === 'list' && child.type === 'list') || + (child.type === 'code' && previous.type === 'list' && !child.lang) + ) { + max++; } - } - return false + compare(unistUtilPosition.end(previous), unistUtilPosition.start(child), max); + } } } -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$y(test) { - return type +var remarkLintNoFileNameArticles = unifiedLintRule('remark-lint:no-file-name-articles', noFileNameArticles); - function type(node) { - return Boolean(node && node.type === test) - } -} +function noFileNameArticles(tree, file) { + var match = file.stem && file.stem.match(/^(the|teh|an?)\b/i); -// Utility to return true. -function ok$z() { - return true + if (match) { + file.message('Do not start file names with `' + match[0] + '`'); + } } -var unistUtilVisitParents$y = visitParents$y; - +var remarkLintNoFileNameConsecutiveDashes = unifiedLintRule( + 'remark-lint:no-file-name-consecutive-dashes', + noFileNameConsecutiveDashes +); +var reason$b = 'Do not use consecutive dashes in a file name'; -var CONTINUE$14 = true; -var SKIP$14 = 'skip'; -var EXIT$14 = false; +function noFileNameConsecutiveDashes(tree, file) { + if (file.stem && /-{2,}/.test(file.stem)) { + file.message(reason$b); + } +} -visitParents$y.CONTINUE = CONTINUE$14; -visitParents$y.SKIP = SKIP$14; -visitParents$y.EXIT = EXIT$14; +var remarkLintNoFileNameOuterDashes = unifiedLintRule( + 'remark-lint:no-file-name-outer-dashes', + noFileNameOuterDashes +); -function visitParents$y(tree, test, visitor, reverse) { - var is; +var reason$c = 'Do not use initial or final dashes in a file name'; - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; +function noFileNameOuterDashes(tree, file) { + if (file.stem && /^-|-$/.test(file.stem)) { + file.message(reason$c); } +} - is = convert_1$y(test); +var remarkLintNoHeadingIndent = unifiedLintRule('remark-lint:no-heading-indent', noHeadingIndent); - one(tree, null, []); +var start$e = unistUtilPosition.start; - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; +function noHeadingIndent(tree, file) { + var contents = String(file); + var length = contents.length; - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$y(visitor(node, parents)); + unistUtilVisit(tree, 'heading', visitor); - if (result[0] === EXIT$14) { - return result - } - } + function visitor(node) { + var initial; + var begin; + var index; + var character; + var diff; - if (node.children && result[0] !== SKIP$14) { - subresult = toResult$y(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$14 ? subresult : result + if (unistUtilGenerated(node)) { + return } - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; + initial = start$e(node); + begin = initial.offset; + index = begin - 1; - while (index > min && index < children.length) { - result = one(children[index], index, parents); + while (++index < length) { + character = contents.charAt(index); - if (result[0] === EXIT$14) { - return result + if (character !== ' ' && character !== '\t') { + break } - - index = typeof result[1] === 'number' ? result[1] : index + step; } - } -} -function toResult$y(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } + diff = index - begin; - if (typeof value === 'number') { - return [CONTINUE$14, value] + if (diff) { + file.message( + 'Remove ' + diff + ' ' + pluralize('space', diff) + ' before this heading', + { + line: initial.line, + column: initial.column + diff + } + ); + } } - - return [value] } -var unistUtilVisit$y = visit$y; - +var start$f = unistUtilPosition.start; -var CONTINUE$15 = unistUtilVisitParents$y.CONTINUE; -var SKIP$15 = unistUtilVisitParents$y.SKIP; -var EXIT$15 = unistUtilVisitParents$y.EXIT; -visit$y.CONTINUE = CONTINUE$15; -visit$y.SKIP = SKIP$15; -visit$y.EXIT = EXIT$15; +var remarkLintNoMultipleToplevelHeadings = unifiedLintRule( + 'remark-lint:no-multiple-toplevel-headings', + noMultipleToplevelHeadings +); -function visit$y(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } +function noMultipleToplevelHeadings(tree, file, option) { + var preferred = option || 1; + var duplicate; - unistUtilVisitParents$y(tree, test, overload, reverse); + unistUtilVisit(tree, 'heading', visitor); - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) + function visitor(node) { + if (!unistUtilGenerated(node) && node.depth === preferred) { + if (duplicate) { + file.message( + 'Don’t use multiple top level headings (' + duplicate + ')', + node + ); + } else { + duplicate = unistUtilStringifyPosition(start$f(node)); + } + } } } -var rule = unifiedLintRule; - - - +var remarkLintNoShellDollars = unifiedLintRule('remark-lint:no-shell-dollars', noShellDollars); -var remarkLintRuleStyle = rule('remark-lint:rule-style', ruleStyle); +var reason$d = 'Do not use dollar signs before shell commands'; -var start$h = unistUtilPosition.start; -var end$9 = unistUtilPosition.end; +// List of shell script file extensions (also used as code flags for syntax +// highlighting on GitHub): +// See: +var flags = [ + 'sh', + 'bash', + 'bats', + 'cgi', + 'command', + 'fcgi', + 'ksh', + 'tmux', + 'tool', + 'zsh' +]; -function ruleStyle(tree, file, option) { - var contents = String(file); - var preferred = - typeof option === 'string' && option !== 'consistent' ? option : null; +function noShellDollars(tree, file) { + unistUtilVisit(tree, 'code', visitor); - if (preferred !== null && /[^-_* ]/.test(preferred)) { - file.fail( - "Incorrect preferred rule style: provide a correct markdown rule or `'consistent'`" - ); - } + function visitor(node) { + var lines; + var line; + var length; + var index; - unistUtilVisit$y(tree, 'thematicBreak', visitor); + // Check both known shell code and unknown code. + if (!unistUtilGenerated(node) && node.lang && flags.indexOf(node.lang) !== -1) { + lines = node.value.split('\n').filter(notEmpty); + length = lines.length; + index = -1; - function visitor(node) { - var initial = start$h(node).offset; - var final = end$9(node).offset; - var rule; + if (length === 0) { + return + } - if (!unistUtilGenerated(node)) { - rule = contents.slice(initial, final); + while (++index < length) { + line = lines[index]; - if (preferred) { - if (rule !== preferred) { - file.message('Rules should use `' + preferred + '`', node); + if (line.trim() && !line.match(/^\s*\$\s*/)) { + return } - } else { - preferred = rule; } + + file.message(reason$d, node); } } -} -var convert_1$z = convert$C; - -function convert$C(test) { - if (typeof test === 'string') { - return typeFactory$z(test) + function notEmpty(line) { + return line.trim().length !== 0 } +} - if (test === null || test === undefined) { - return ok$A - } +var remarkLintNoTableIndentation = unifiedLintRule('remark-lint:no-table-indentation', noTableIndentation); - if (typeof test === 'object') { - return ('length' in test ? anyFactory$z : matchesFactory$z)(test) - } +var reason$e = 'Do not indent table rows'; - if (typeof test === 'function') { - return test - } +function noTableIndentation(tree, file) { + var contents = String(file); - throw new Error('Expected function, string, or object as test') -} + unistUtilVisit(tree, 'table', visitor); -function convertAll$z(tests) { - var results = []; - var length = tests.length; - var index = -1; + function visitor(node) { + if (!unistUtilGenerated(node)) { + node.children.forEach(each); + } - while (++index < length) { - results[index] = convert$C(tests[index]); + return unistUtilVisit.SKIP } - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$z(test) { - return matches - - function matches(node) { - var key; + function each(row) { + var fence = contents.slice( + unistUtilPosition.start(row).offset, + unistUtilPosition.start(row.children[0]).offset + ); - for (key in test) { - if (node[key] !== test[key]) { - return false - } + if (fence.indexOf('|') > 1) { + file.message(reason$e, row); } - - return true } } -function anyFactory$z(tests) { - var checks = convertAll$z(tests); - var length = checks.length; - - return matches +var remarkLintNoTabs = unifiedLintRule('remark-lint:no-tabs', noTabs); - function matches() { - var index = -1; +var reason$f = 'Use spaces instead of tabs'; - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } +function noTabs(tree, file) { + var content = String(file); + var position = vfileLocation(file).toPosition; + var index = content.indexOf('\t'); - return false + while (index !== -1) { + file.message(reason$f, position(index)); + index = content.indexOf('\t', index + 1); } } -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$z(test) { - return type +var remarkLintNoTrailingSpaces = unifiedLintRule('remark-lint:no-trailing-spaces', noTrailingSpaces); - function type(node) { - return Boolean(node && node.type === test) +/** + * Lines that are just space characters are not present in + * the AST, which is why we loop through lines manually. + */ + +function noTrailingSpaces(ast, file) { + var lines = file.toString().split(/\r?\n/); + for (var i = 0; i < lines.length; i++) { + var currentLine = lines[i]; + var lineIndex = i + 1; + if (/\s$/.test(currentLine)) { + file.message('Remove trailing whitespace', { + position: { + start: { line: lineIndex, column: currentLine.length + 1 }, + end: { line: lineIndex } + } + }); + } } } -// Utility to return true. -function ok$A() { - return true -} +var escapeStringRegexp$1 = string => { + if (typeof string !== 'string') { + throw new TypeError('Expected a string'); + } + + // Escape characters with special meaning either inside or outside character sets. + // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. + return string + .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') + .replace(/-/g, '\\x2d'); +}; -var unistUtilVisitParents$z = visitParents$z; +const start$g = unistUtilPosition.start; +var remarkLintProhibitedStrings = unifiedLintRule('remark-lint:prohibited-strings', prohibitedStrings); +function testProhibited (val, content) { + let regexpFlags = 'g'; + let no = val.no; -var CONTINUE$16 = true; -var SKIP$16 = 'skip'; -var EXIT$16 = false; + if (!no) { + no = escapeStringRegexp$1(val.yes); + regexpFlags += 'i'; + } -visitParents$z.CONTINUE = CONTINUE$16; -visitParents$z.SKIP = SKIP$16; -visitParents$z.EXIT = EXIT$16; + let regexpString = '(? min && index < children.length) { - result = one(children[index], index, parents); + function checkText (node) { + const content = node.value; + const initial = start$g(node).offset; - if (result[0] === EXIT$16) { - return result + strings.forEach((val) => { + const results = testProhibited(val, content); + if (results.length) { + results.forEach(({ result, index }) => { + const message = val.yes ? `Use "${val.yes}" instead of "${result}"` : `Do not use "${result}"`; + file.message(message, { + start: location.toPosition(initial + index), + end: location.toPosition(initial + index + [...result].length) + }); + }); } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } + }); } } -function toResult$z(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$16, value] - } +var rule = unifiedLintRule; - return [value] -} -var unistUtilVisit$z = visit$z; +var remarkLintRuleStyle = rule('remark-lint:rule-style', ruleStyle); -var CONTINUE$17 = unistUtilVisitParents$z.CONTINUE; -var SKIP$17 = unistUtilVisitParents$z.SKIP; -var EXIT$17 = unistUtilVisitParents$z.EXIT; +var start$h = unistUtilPosition.start; +var end$9 = unistUtilPosition.end; -visit$z.CONTINUE = CONTINUE$17; -visit$z.SKIP = SKIP$17; -visit$z.EXIT = EXIT$17; +function ruleStyle(tree, file, option) { + var contents = String(file); + var preferred = + typeof option === 'string' && option !== 'consistent' ? option : null; -function visit$z(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; + if (preferred !== null && /[^-_* ]/.test(preferred)) { + file.fail( + "Incorrect preferred rule style: provide a correct markdown rule or `'consistent'`" + ); } - unistUtilVisitParents$z(tree, test, overload, reverse); + unistUtilVisit(tree, 'thematicBreak', visitor); - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) + function visitor(node) { + var initial = start$h(node).offset; + var final = end$9(node).offset; + var rule; + + if (!unistUtilGenerated(node)) { + rule = contents.slice(initial, final); + + if (preferred) { + if (rule !== preferred) { + file.message('Rules should use `' + preferred + '`', node); + } + } else { + preferred = rule; + } + } } } @@ -54156,7 +46857,7 @@ function strongMarker(tree, file, option) { ); } - unistUtilVisit$z(tree, 'strong', visitor); + unistUtilVisit(tree, 'strong', visitor); function visitor(node) { var marker = contents.charAt(unistUtilPosition.start(node).offset); @@ -54176,197 +46877,6 @@ function strongMarker(tree, file, option) { } } -var convert_1$A = convert$D; - -function convert$D(test) { - if (typeof test === 'string') { - return typeFactory$A(test) - } - - if (test === null || test === undefined) { - return ok$B - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$A : matchesFactory$A)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$A(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$D(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$A(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$A(tests) { - var checks = convertAll$A(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$A(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$B() { - return true -} - -var unistUtilVisitParents$A = visitParents$A; - - - -var CONTINUE$18 = true; -var SKIP$18 = 'skip'; -var EXIT$18 = false; - -visitParents$A.CONTINUE = CONTINUE$18; -visitParents$A.SKIP = SKIP$18; -visitParents$A.EXIT = EXIT$18; - -function visitParents$A(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$A(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$A(visitor(node, parents)); - - if (result[0] === EXIT$18) { - return result - } - } - - if (node.children && result[0] !== SKIP$18) { - subresult = toResult$A(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$18 ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$18) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$A(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$18, value] - } - - return [value] -} - -var unistUtilVisit$A = visit$A; - - - -var CONTINUE$19 = unistUtilVisitParents$A.CONTINUE; -var SKIP$19 = unistUtilVisitParents$A.SKIP; -var EXIT$19 = unistUtilVisitParents$A.EXIT; - -visit$A.CONTINUE = CONTINUE$19; -visit$A.SKIP = SKIP$19; -visit$A.EXIT = EXIT$19; - -function visit$A(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$A(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - var remarkLintTableCellPadding = unifiedLintRule('remark-lint:table-cell-padding', tableCellPadding); var start$i = unistUtilPosition.start; @@ -54387,7 +46897,7 @@ function tableCellPadding(tree, file, option) { ); } - unistUtilVisit$A(tree, 'table', visitor); + unistUtilVisit(tree, 'table', visitor); function visitor(node) { var rows = node.children; @@ -54460,7 +46970,7 @@ function tableCellPadding(tree, file, option) { checkSide('end', entry, style, sizes); } - return unistUtilVisit$A.SKIP + return unistUtilVisit.SKIP } function checkSide(side, entry, style, sizes) { @@ -54503,197 +47013,6 @@ function size(node) { return end$a(node).offset - start$i(node).offset } -var convert_1$B = convert$E; - -function convert$E(test) { - if (typeof test === 'string') { - return typeFactory$B(test) - } - - if (test === null || test === undefined) { - return ok$C - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$B : matchesFactory$B)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$B(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$E(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$B(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$B(tests) { - var checks = convertAll$B(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$B(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$C() { - return true -} - -var unistUtilVisitParents$B = visitParents$B; - - - -var CONTINUE$1a = true; -var SKIP$1a = 'skip'; -var EXIT$1a = false; - -visitParents$B.CONTINUE = CONTINUE$1a; -visitParents$B.SKIP = SKIP$1a; -visitParents$B.EXIT = EXIT$1a; - -function visitParents$B(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$B(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$B(visitor(node, parents)); - - if (result[0] === EXIT$1a) { - return result - } - } - - if (node.children && result[0] !== SKIP$1a) { - subresult = toResult$B(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$1a ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$1a) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$B(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$1a, value] - } - - return [value] -} - -var unistUtilVisit$B = visit$B; - - - -var CONTINUE$1b = unistUtilVisitParents$B.CONTINUE; -var SKIP$1b = unistUtilVisitParents$B.SKIP; -var EXIT$1b = unistUtilVisitParents$B.EXIT; - -visit$B.CONTINUE = CONTINUE$1b; -visit$B.SKIP = SKIP$1b; -visit$B.EXIT = EXIT$1b; - -function visit$B(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$B(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - var remarkLintTablePipes = unifiedLintRule('remark-lint:table-pipes', tablePipes); var start$j = unistUtilPosition.start; @@ -54705,7 +47024,7 @@ var reasonEnd = 'Missing final pipe in table fence'; function tablePipes(tree, file) { var contents = String(file); - unistUtilVisit$B(tree, 'table', visitor); + unistUtilVisit(tree, 'table', visitor); function visitor(node) { var rows = node.children; @@ -54740,197 +47059,6 @@ function tablePipes(tree, file) { } } -var convert_1$C = convert$F; - -function convert$F(test) { - if (typeof test === 'string') { - return typeFactory$C(test) - } - - if (test === null || test === undefined) { - return ok$D - } - - if (typeof test === 'object') { - return ('length' in test ? anyFactory$C : matchesFactory$C)(test) - } - - if (typeof test === 'function') { - return test - } - - throw new Error('Expected function, string, or object as test') -} - -function convertAll$C(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$F(tests[index]); - } - - return results -} - -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$C(test) { - return matches - - function matches(node) { - var key; - - for (key in test) { - if (node[key] !== test[key]) { - return false - } - } - - return true - } -} - -function anyFactory$C(tests) { - var checks = convertAll$C(tests); - var length = checks.length; - - return matches - - function matches() { - var index = -1; - - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true - } - } - - return false - } -} - -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$C(test) { - return type - - function type(node) { - return Boolean(node && node.type === test) - } -} - -// Utility to return true. -function ok$D() { - return true -} - -var unistUtilVisitParents$C = visitParents$C; - - - -var CONTINUE$1c = true; -var SKIP$1c = 'skip'; -var EXIT$1c = false; - -visitParents$C.CONTINUE = CONTINUE$1c; -visitParents$C.SKIP = SKIP$1c; -visitParents$C.EXIT = EXIT$1c; - -function visitParents$C(tree, test, visitor, reverse) { - var is; - - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - is = convert_1$C(test); - - one(tree, null, []); - - // Visit a single node. - function one(node, index, parents) { - var result = []; - var subresult; - - if (!test || is(node, index, parents[parents.length - 1] || null)) { - result = toResult$C(visitor(node, parents)); - - if (result[0] === EXIT$1c) { - return result - } - } - - if (node.children && result[0] !== SKIP$1c) { - subresult = toResult$C(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$1c ? subresult : result - } - - return result - } - - // Visit children in `parent`. - function all(children, parents) { - var min = -1; - var step = reverse ? -1 : 1; - var index = (reverse ? children.length : min) + step; - var result; - - while (index > min && index < children.length) { - result = one(children[index], index, parents); - - if (result[0] === EXIT$1c) { - return result - } - - index = typeof result[1] === 'number' ? result[1] : index + step; - } - } -} - -function toResult$C(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } - - if (typeof value === 'number') { - return [CONTINUE$1c, value] - } - - return [value] -} - -var unistUtilVisit$C = visit$C; - - - -var CONTINUE$1d = unistUtilVisitParents$C.CONTINUE; -var SKIP$1d = unistUtilVisitParents$C.SKIP; -var EXIT$1d = unistUtilVisitParents$C.EXIT; - -visit$C.CONTINUE = CONTINUE$1d; -visit$C.SKIP = SKIP$1d; -visit$C.EXIT = EXIT$1d; - -function visit$C(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - - unistUtilVisitParents$C(tree, test, overload, reverse); - - function overload(node, parents) { - var parent = parents[parents.length - 1]; - var index = parent ? parent.children.indexOf(node) : null; - return visitor(node, index, parent) - } -} - var remarkLintUnorderedListMarkerStyle = unifiedLintRule( 'remark-lint:unordered-list-marker-style', unorderedListMarkerStyle @@ -54958,7 +47086,7 @@ function unorderedListMarkerStyle(tree, file, option) { ); } - unistUtilVisit$C(tree, 'list', visitor); + unistUtilVisit(tree, 'list', visitor); function visitor(node) { var children = node.children; @@ -55004,7 +47132,26 @@ var plugins$2 = [ remarkLintCheckboxContentIndent, [remarkLintCodeBlockStyle, "fenced"], remarkLintDefinitionSpacing, - remarkLintFencedCodeFlag, + [ + remarkLintFencedCodeFlag, + { + flags: [ + "bash", + "c", + "coffee", + "console", + "cpp", + "diff", + "http", + "js", + "json", + "markdown", + "powershell", + "r", + "text", + ], + }, + ], [remarkLintFencedCodeMarker, "`"], [remarkLintFileExtension, "md"], remarkLintFinalDefinition, diff --git a/tools/msvs/msi/custom_actions.vcxproj b/tools/msvs/msi/custom_actions.vcxproj index 3716f07ff6de3d..f984ccd7ad9985 100644 --- a/tools/msvs/msi/custom_actions.vcxproj +++ b/tools/msvs/msi/custom_actions.vcxproj @@ -1,6 +1,10 @@  + + Debug + ARM64 + Debug Win32 @@ -9,6 +13,10 @@ Debug x64 + + Release + ARM64 + Release Win32 @@ -31,6 +39,12 @@ Unicode true + + DynamicLibrary + $(PlatformToolset) + Unicode + true + DynamicLibrary $(PlatformToolset) @@ -42,6 +56,11 @@ $(PlatformToolset) Unicode + + DynamicLibrary + $(PlatformToolset) + Unicode + DynamicLibrary $(PlatformToolset) @@ -53,12 +72,18 @@ + + + + + + @@ -69,12 +94,18 @@ true + + true + true false + + false + false @@ -97,6 +128,25 @@ Windows + + + Disabled + $(WixSdkDir)\inc;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + ProgramDatabase + + + msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) + $(WixSdkDir)\lib\ARM64;%(AdditionalLibraryDirectories) + custom_actions.def + true + Windows + + Disabled @@ -142,6 +192,32 @@ true + + + MaxSpeed + true + $(WixSdkDir)\inc;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + true + Level3 + ProgramDatabase + NotUsing + + + + + + + msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) + $(WixSdkDir)\lib\ARM64;%(AdditionalLibraryDirectories) + custom_actions.def + true + Windows + true + true + + MaxSpeed diff --git a/tools/msvs/msi/nodemsi.sln b/tools/msvs/msi/nodemsi.sln index 9a3bab3f5cb448..86b4b10dcb043f 100644 --- a/tools/msvs/msi/nodemsi.sln +++ b/tools/msvs/msi/nodemsi.sln @@ -7,24 +7,34 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "custom_actions", "custom_ac EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|ARM64 = Release|ARM64 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|ARM64.ActiveCfg = Debug|arm64 + {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|ARM64.Build.0 = Debug|arm64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|x64.ActiveCfg = Debug|x64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|x64.Build.0 = Debug|x64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|x86.ActiveCfg = Debug|x86 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|x86.Build.0 = Debug|x86 + {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|ARM64.ActiveCfg = Release|arm64 + {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|ARM64.Build.0 = Release|arm64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x64.ActiveCfg = Release|x64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x64.Build.0 = Release|x64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x86.ActiveCfg = Release|x86 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x86.Build.0 = Release|x86 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|ARM64.Build.0 = Debug|ARM64 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x64.ActiveCfg = Debug|x64 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x64.Build.0 = Debug|x64 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x86.ActiveCfg = Debug|Win32 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x86.Build.0 = Debug|Win32 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|ARM64.ActiveCfg = Release|ARM64 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|ARM64.Build.0 = Release|ARM64 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x64.ActiveCfg = Release|x64 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x64.Build.0 = Release|x64 {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x86.ActiveCfg = Release|Win32 diff --git a/tools/msvs/msi/nodemsi.wixproj b/tools/msvs/msi/nodemsi.wixproj index 66a97f243d8dde..d4bf09cb34c131 100644 --- a/tools/msvs/msi/nodemsi.wixproj +++ b/tools/msvs/msi/nodemsi.wixproj @@ -34,6 +34,16 @@ obj\$(Configuration)\ Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder + + ..\..\..\ + obj\$(Configuration)\ + Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder + + + ..\..\..\ + obj\$(Configuration)\ + Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder + True diff --git a/tools/node-lint-md-cli-rollup/package-lock.json b/tools/node-lint-md-cli-rollup/package-lock.json index efd36027c65c22..9392260f13f4bb 100644 --- a/tools/node-lint-md-cli-rollup/package-lock.json +++ b/tools/node-lint-md-cli-rollup/package-lock.json @@ -856,32 +856,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-checkbox-character-style": { @@ -894,37 +868,6 @@ "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0", "vfile-location": "^3.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - }, - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" - } } }, "remark-lint-checkbox-content-indent": { @@ -937,37 +880,6 @@ "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0", "vfile-location": "^3.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - }, - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" - } } }, "remark-lint-code-block-style": { @@ -979,32 +891,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-definition-spacing": { @@ -1016,32 +902,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-fenced-code-flag": { @@ -1053,32 +913,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-fenced-code-marker": { @@ -1090,32 +924,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-file-extension": { @@ -1135,32 +943,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-final-newline": { @@ -1179,32 +961,6 @@ "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-hard-break-spaces": { @@ -1216,32 +972,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-heading-style": { @@ -1253,32 +983,6 @@ "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-list-item-bullet-indent": { @@ -1291,32 +995,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-list-item-indent": { @@ -1329,32 +1007,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-maximum-line-length": { @@ -1366,32 +1018,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-auto-link-without-protocol": { @@ -1404,32 +1030,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-blockquote-without-marker": { @@ -1442,37 +1042,6 @@ "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0", "vfile-location": "^3.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - }, - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" - } } }, "remark-lint-no-consecutive-blank-lines": { @@ -1485,32 +1054,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-duplicate-definitions": { @@ -1523,32 +1066,6 @@ "unist-util-position": "^3.0.0", "unist-util-stringify-position": "^2.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-file-name-articles": { @@ -1586,32 +1103,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-heading-indent": { @@ -1624,32 +1115,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-inline-padding": { @@ -1661,32 +1126,6 @@ "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-literal-urls": { @@ -1699,32 +1138,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-multiple-toplevel-headings": { @@ -1737,68 +1150,16 @@ "unist-util-position": "^3.0.0", "unist-util-stringify-position": "^2.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-shell-dollars": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-no-shell-dollars/-/remark-lint-no-shell-dollars-2.0.0.tgz", - "integrity": "sha512-1uEM0kSGlV6UY7w3PdIeIf/USFFvVuU1352myQdaiw/Wof7+uVXznFFCPnhJDTVlPN4vrgwFnLb32UwXrjkrQw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/remark-lint-no-shell-dollars/-/remark-lint-no-shell-dollars-2.0.1.tgz", + "integrity": "sha512-N+wOq3nmZ8WnCreWhi/rfIKQJPAz+pcbErQATcnQzH0znzldXlX8Ovlm54yDx/A+TmGMex/epkCwuiewIj9m4g==", "requires": { "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-shortcut-reference-image": { @@ -1809,32 +1170,6 @@ "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-shortcut-reference-link": { @@ -1845,32 +1180,6 @@ "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-table-indentation": { @@ -1882,32 +1191,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-tabs": { @@ -1917,13 +1200,6 @@ "requires": { "unified-lint-rule": "^1.0.0", "vfile-location": "^3.0.0" - }, - "dependencies": { - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" - } } }, "remark-lint-no-trailing-spaces": { @@ -1943,111 +1219,33 @@ "unified-lint-rule": "^1.0.0", "unist-util-generated": "^1.1.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-no-unused-definitions": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/remark-lint-no-unused-definitions/-/remark-lint-no-unused-definitions-2.0.0.tgz", "integrity": "sha512-Y8zrulwaf7z6WR1ICfEGjW92iq2SPEN7Zhrs0nloNITHOg22tIPf28TurUz9HSQ3sEd52d9bZCfW9RkdfMq1xw==", - "requires": { - "unified-lint-rule": "^1.0.0", - "unist-util-generated": "^1.1.0", - "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } - } - }, - "remark-lint-ordered-list-marker-style": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/remark-lint-ordered-list-marker-style/-/remark-lint-ordered-list-marker-style-2.0.0.tgz", - "integrity": "sha512-zYMZA8tQD/slJYKqsstZv0/Q34Hkdlf4DjC8SOr92PSA60R/xr7JdVd/AHHisbMsFvdnHZrxaB8oIOtbAUJCSw==", - "requires": { - "unified-lint-rule": "^1.0.0", - "unist-util-generated": "^1.1.0", - "unist-util-position": "^3.0.0", - "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-visit": "^2.0.0" + } + }, + "remark-lint-ordered-list-marker-style": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remark-lint-ordered-list-marker-style/-/remark-lint-ordered-list-marker-style-2.0.0.tgz", + "integrity": "sha512-zYMZA8tQD/slJYKqsstZv0/Q34Hkdlf4DjC8SOr92PSA60R/xr7JdVd/AHHisbMsFvdnHZrxaB8oIOtbAUJCSw==", + "requires": { + "unified-lint-rule": "^1.0.0", + "unist-util-generated": "^1.1.0", + "unist-util-position": "^3.0.0", + "unist-util-visit": "^2.0.0" } }, "remark-lint-prohibited-strings": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/remark-lint-prohibited-strings/-/remark-lint-prohibited-strings-1.5.1.tgz", - "integrity": "sha512-YZoRWbzIGRIQkngAowwAKG39kUAGSalYvrxqTzUU4LYj1dS37q7i5WDr4m/mnCcc5KwRin08D62Dphs6g9Btnw==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/remark-lint-prohibited-strings/-/remark-lint-prohibited-strings-1.5.2.tgz", + "integrity": "sha512-1+WIHboeLxmAnlxTFW6XNfvxvhnC2WRxn0rGgcNp/M7CrANHhnadY2/YeXFLF9oY22SAylrxiPG9eAuUmJuW6w==", "requires": { "escape-string-regexp": "^4.0.0", "unified-lint-rule": "^1.0.2", @@ -2060,35 +1258,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" - }, - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - }, - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" } } }, @@ -2101,32 +1270,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-strong-marker": { @@ -2138,32 +1281,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-table-cell-padding": { @@ -2175,32 +1292,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-table-pipes": { @@ -2212,32 +1303,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-lint-unordered-list-marker-style": { @@ -2249,32 +1314,6 @@ "unist-util-generated": "^1.1.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - } } }, "remark-message-control": { @@ -2310,9 +1349,9 @@ } }, "remark-preset-lint-node": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-1.15.0.tgz", - "integrity": "sha512-1G7S2F/u7bk3kc4tZPrUphceP0RfT9AF6e+gzWbNi8URutECe3kl+Ur6ooMI5f1VqJUzcLF/U1YuhnFhkPnKkA==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-1.16.0.tgz", + "integrity": "sha512-/SeIfHFDZkpi29quPG6Bt9FAao0oic3fTkvGFy1Xzu27qtuZba0h3wHIkNRRPZ281PRdT6LB6MfsigBr2A5eMw==", "requires": { "remark-lint": "^7.0.0", "remark-lint-blockquote-indentation": "^2.0.0", @@ -2338,70 +1377,13 @@ "remark-lint-no-table-indentation": "^2.0.0", "remark-lint-no-tabs": "^2.0.0", "remark-lint-no-trailing-spaces": "^2.0.1", - "remark-lint-prohibited-strings": "^1.5.1", + "remark-lint-prohibited-strings": "^1.5.2", "remark-lint-rule-style": "^2.0.0", "remark-lint-strong-marker": "^2.0.0", "remark-lint-table-cell-padding": "^2.0.0", "remark-lint-table-pipes": "^2.0.0", "remark-lint-unordered-list-marker-style": "^2.0.0", "remark-preset-lint-recommended": "^4.0.0" - }, - "dependencies": { - "remark-lint": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/remark-lint/-/remark-lint-7.0.0.tgz", - "integrity": "sha512-OLrWPYy0MUcGLa/2rjuy1kQILTRRK+JiRtyUzqe4XRoHboGuvFDcy/W2e7sq5hu/0xmD+Eh7cEa1Coiqp7LeaA==", - "requires": { - "remark-message-control": "^6.0.0" - } - }, - "remark-message-control": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/remark-message-control/-/remark-message-control-6.0.0.tgz", - "integrity": "sha512-k9bt7BYc3G7YBdmeAhvd3VavrPa/XlKWR3CyHjr4sLO9xJyly8WHHT3Sp+8HPR8lEUv+/sZaffL7IjMLV0f6BA==", - "requires": { - "mdast-comment-marker": "^1.0.0", - "unified-message-control": "^3.0.0" - } - }, - "unified-message-control": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/unified-message-control/-/unified-message-control-3.0.1.tgz", - "integrity": "sha512-K2Kvvp1DBzeuxYLLsumZh/gDWUTl4e2z/P3VReFirC78cfHKtQifbhnfRrSBtKtd1Uc6cvYTW0/SZIUaMAEcTg==", - "requires": { - "unist-util-visit": "^2.0.0", - "vfile-location": "^3.0.0" - } - }, - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - }, - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" - } } }, "remark-preset-lint-recommended": { @@ -2425,63 +1407,6 @@ "remark-lint-no-undefined-references": "^2.0.0", "remark-lint-no-unused-definitions": "^2.0.0", "remark-lint-ordered-list-marker-style": "^2.0.0" - }, - "dependencies": { - "remark-lint": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/remark-lint/-/remark-lint-7.0.0.tgz", - "integrity": "sha512-OLrWPYy0MUcGLa/2rjuy1kQILTRRK+JiRtyUzqe4XRoHboGuvFDcy/W2e7sq5hu/0xmD+Eh7cEa1Coiqp7LeaA==", - "requires": { - "remark-message-control": "^6.0.0" - } - }, - "remark-message-control": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/remark-message-control/-/remark-message-control-6.0.0.tgz", - "integrity": "sha512-k9bt7BYc3G7YBdmeAhvd3VavrPa/XlKWR3CyHjr4sLO9xJyly8WHHT3Sp+8HPR8lEUv+/sZaffL7IjMLV0f6BA==", - "requires": { - "mdast-comment-marker": "^1.0.0", - "unified-message-control": "^3.0.0" - } - }, - "unified-message-control": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/unified-message-control/-/unified-message-control-3.0.1.tgz", - "integrity": "sha512-K2Kvvp1DBzeuxYLLsumZh/gDWUTl4e2z/P3VReFirC78cfHKtQifbhnfRrSBtKtd1Uc6cvYTW0/SZIUaMAEcTg==", - "requires": { - "unist-util-visit": "^2.0.0", - "vfile-location": "^3.0.0" - } - }, - "unist-util-is": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", - "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==" - }, - "unist-util-visit": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.2.tgz", - "integrity": "sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" - } - }, - "unist-util-visit-parents": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.0.2.tgz", - "integrity": "sha512-yJEfuZtzFpQmg1OSCyS9M5NJRrln/9FbYosH3iW0MG402QbdbaB8ZESwUv9RO6nRfLAKvWcMxCwdLWOov36x/g==", - "requires": { - "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" - } - }, - "vfile-location": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.0.1.tgz", - "integrity": "sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ==" - } } }, "remark-stringify": { diff --git a/tools/node-lint-md-cli-rollup/package.json b/tools/node-lint-md-cli-rollup/package.json index aa203f67b33217..069a93e801da41 100644 --- a/tools/node-lint-md-cli-rollup/package.json +++ b/tools/node-lint-md-cli-rollup/package.json @@ -13,7 +13,7 @@ "markdown-extensions": "^1.1.1", "remark": "^12.0.0", "remark-lint": "^7.0.0", - "remark-preset-lint-node": "^1.15.0", + "remark-preset-lint-node": "^1.16.0", "unified-args": "^8.0.0" }, "main": "dist/index.js", diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 427544bad668c0..0cb3963b2c0b22 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -5,7 +5,6 @@
    [![Open Collective Backers](https://img.shields.io/opencollective/backers/eslint)](https://opencollective.com/eslint) [![Open Collective Sponsors](https://img.shields.io/opencollective/sponsors/eslint)](https://opencollective.com/eslint) -[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Follow us on Twitter](https://img.shields.io/twitter/follow/geteslint?label=Follow&style=social)](https://twitter.com/intent/user?screen_name=geteslint) # ESLint @@ -18,7 +17,7 @@ [Code of Conduct](https://js.foundation/community/code-of-conduct) | [Twitter](https://twitter.com/geteslint) | [Mailing List](https://groups.google.com/group/eslint) | -[Chat Room](https://gitter.im/eslint/eslint) +[Chat Room](https://eslint.org/chat) ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions: @@ -134,7 +133,7 @@ Once a language feature has been adopted into the ECMAScript standard (stage 4 a ### Where to ask for help? -Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](https://gitter.im/eslint/eslint). +Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](https://eslint.org/chat). ## Releases @@ -251,8 +250,8 @@ The following companies, organizations, and individuals support ESLint's ongoing

    Gold Sponsors

    Shopify Salesforce Airbnb

    Silver Sponsors

    -

    AMP Project

    Bronze Sponsors

    -

    CasinoTop.com Casino Topp Writers Per Hour Anagram Solver vpn netflix Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Top Web Design Agencies Bugsnag Stability Monitoring Mixpanel VPS Server Free Icons by Icons8 UI UX Design Agencies clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks

    +

    Liftoff AMP Project

    Bronze Sponsors

    +

    Bruce EduBirdie CasinoTop.com Casino Topp Writers Per Hour Anagram Solver vpn netflix Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Bugsnag Stability Monitoring Mixpanel VPS Server Free Icons by Icons8 Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks

    ## Technology Sponsors diff --git a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js index b6aa995beef933..802a405c04ac72 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js @@ -403,7 +403,7 @@ function getCacheFile(cacheFile, cwd) { try { fileStats = fs.lstatSync(resolvedCacheFile); - } catch (ex) { + } catch { fileStats = null; } @@ -991,7 +991,7 @@ class CLIEngine { const npmFormat = naming.normalizePackageName(normalizedFormatName, "eslint-formatter"); formatterPath = ModuleResolver.resolve(npmFormat, path.join(cwd, "__placeholder__.js")); - } catch (e) { + } catch { formatterPath = path.resolve(__dirname, "formatters", normalizedFormatName); } } diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js index fa3fdb3bedd89b..7c0fba65c67d0a 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js @@ -517,7 +517,7 @@ class ConfigArrayFactory { try { loadPackageJSONConfigFile(filePath); return filePath; - } catch (error) { /* ignore */ } + } catch { /* ignore */ } } else { return filePath; } diff --git a/tools/node_modules/eslint/lib/init/config-initializer.js b/tools/node_modules/eslint/lib/init/config-initializer.js index 70f0a250ad1dd6..dce39946e6b876 100644 --- a/tools/node_modules/eslint/lib/init/config-initializer.js +++ b/tools/node_modules/eslint/lib/init/config-initializer.js @@ -265,11 +265,7 @@ function processAnswers(answers) { }; config.parserOptions.ecmaVersion = espree.latestEcmaVersion; - config.env.es6 = true; - config.globals = { - Atomics: "readonly", - SharedArrayBuffer: "readonly" - }; + config.env.es2020 = true; // set the module type if (answers.moduleType === "esm") { @@ -326,6 +322,7 @@ function processAnswers(answers) { } if (answers.typescript && config.extends.includes("eslint:recommended")) { config.extends.push("plugin:@typescript-eslint/eslint-recommended"); + config.extends.push("plugin:@typescript-eslint/recommended"); } // normalize extends @@ -349,7 +346,7 @@ function getLocalESLintVersion() { const eslint = require(eslintPath); return eslint.linter.version || null; - } catch (_err) { + } catch { return null; } } diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js index 8a623e33ea0681..b612cf43566b0c 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js @@ -33,10 +33,10 @@ function isCaseNode(node) { * Checks whether the given logical operator is taken into account for the code * path analysis. * @param {string} operator The operator found in the LogicalExpression node - * @returns {boolean} `true` if the operator is "&&" or "||" + * @returns {boolean} `true` if the operator is "&&" or "||" or "??" */ function isHandledLogicalOperator(operator) { - return operator === "&&" || operator === "||"; + return operator === "&&" || operator === "||" || operator === "??"; } /** diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js index 75de1bc6ce4c4a..9e760601a0f744 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js @@ -201,6 +201,7 @@ function finalizeTestSegmentsOfFor(context, choiceContext, head) { if (!choiceContext.processed) { choiceContext.trueForkContext.add(head); choiceContext.falseForkContext.add(head); + choiceContext.qqForkContext.add(head); } if (context.test !== true) { @@ -351,6 +352,7 @@ class CodePathState { isForkingAsResult, trueForkContext: ForkContext.newEmpty(this.forkContext), falseForkContext: ForkContext.newEmpty(this.forkContext), + qqForkContext: ForkContext.newEmpty(this.forkContext), processed: false }; } @@ -370,6 +372,7 @@ class CodePathState { switch (context.kind) { case "&&": case "||": + case "??": /* * If any result were not transferred from child contexts, @@ -379,6 +382,7 @@ class CodePathState { if (!context.processed) { context.trueForkContext.add(headSegments); context.falseForkContext.add(headSegments); + context.qqForkContext.add(headSegments); } /* @@ -390,6 +394,7 @@ class CodePathState { parentContext.trueForkContext.addAll(context.trueForkContext); parentContext.falseForkContext.addAll(context.falseForkContext); + parentContext.qqForkContext.addAll(context.qqForkContext); parentContext.processed = true; return context; @@ -456,13 +461,24 @@ class CodePathState { * This got segments already from the child choice context. * Creates the next path from own true/false fork context. */ - const prevForkContext = - context.kind === "&&" ? context.trueForkContext - /* kind === "||" */ : context.falseForkContext; + let prevForkContext; + + switch (context.kind) { + case "&&": // if true then go to the right-hand side. + prevForkContext = context.trueForkContext; + break; + case "||": // if false then go to the right-hand side. + prevForkContext = context.falseForkContext; + break; + case "??": // Both true/false can short-circuit, so needs the third path to go to the right-hand side. That's qqForkContext. + prevForkContext = context.qqForkContext; + break; + default: + throw new Error("unreachable"); + } forkContext.replaceHead(prevForkContext.makeNext(0, -1)); prevForkContext.clear(); - context.processed = false; } else { @@ -471,14 +487,19 @@ class CodePathState { * So addresses the head segments. * The head segments are the path of the left-hand operand. */ - if (context.kind === "&&") { - - // The path does short-circuit if false. - context.falseForkContext.add(forkContext.head); - } else { - - // The path does short-circuit if true. - context.trueForkContext.add(forkContext.head); + switch (context.kind) { + case "&&": // the false path can short-circuit. + context.falseForkContext.add(forkContext.head); + break; + case "||": // the true path can short-circuit. + context.trueForkContext.add(forkContext.head); + break; + case "??": // both can short-circuit. + context.trueForkContext.add(forkContext.head); + context.falseForkContext.add(forkContext.head); + break; + default: + throw new Error("unreachable"); } forkContext.replaceHead(forkContext.makeNext(-1, -1)); @@ -501,6 +522,7 @@ class CodePathState { if (!context.processed) { context.trueForkContext.add(forkContext.head); context.falseForkContext.add(forkContext.head); + context.qqForkContext.add(forkContext.head); } context.processed = false; diff --git a/tools/node_modules/eslint/lib/linter/config-comment-parser.js b/tools/node_modules/eslint/lib/linter/config-comment-parser.js index 35862315d515f8..067d02480302cb 100644 --- a/tools/node_modules/eslint/lib/linter/config-comment-parser.js +++ b/tools/node_modules/eslint/lib/linter/config-comment-parser.js @@ -78,7 +78,7 @@ module.exports = class ConfigCommentParser { config: items }; } - } catch (ex) { + } catch { debug("Levn parsing failed; falling back to manual parsing."); diff --git a/tools/node_modules/eslint/lib/linter/linter.js b/tools/node_modules/eslint/lib/linter/linter.js index 1d021d1e82e7fb..f9f38790b3c4d1 100644 --- a/tools/node_modules/eslint/lib/linter/linter.js +++ b/tools/node_modules/eslint/lib/linter/linter.js @@ -938,7 +938,8 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser }); }); - const eventGenerator = new CodePathAnalyzer(new NodeEventGenerator(emitter)); + // only run code path analyzer if the top level node is "Program", skip otherwise + const eventGenerator = nodeQueue[0].node.type === "Program" ? new CodePathAnalyzer(new NodeEventGenerator(emitter)) : new NodeEventGenerator(emitter); nodeQueue.forEach(traversalInfo => { currentNode = traversalInfo.node; diff --git a/tools/node_modules/eslint/lib/rules/accessor-pairs.js b/tools/node_modules/eslint/lib/rules/accessor-pairs.js index 02548258ca2e28..cf994ad257446b 100644 --- a/tools/node_modules/eslint/lib/rules/accessor-pairs.js +++ b/tools/node_modules/eslint/lib/rules/accessor-pairs.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to flag wrapping non-iife in parens + * @fileoverview Rule to enforce getter and setter pairs in objects and classes. * @author Gyandeep Singh */ diff --git a/tools/node_modules/eslint/lib/rules/arrow-parens.js b/tools/node_modules/eslint/lib/rules/arrow-parens.js index dc3c3825791a68..bfd32447ac6f3d 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-parens.js +++ b/tools/node_modules/eslint/lib/rules/arrow-parens.js @@ -105,10 +105,27 @@ module.exports = { ], `${shouldAddSpaceForAsync ? " " : ""}${paramToken.value}`); } + /** + * Checks whether there are comments inside the params or not. + * @returns {boolean} `true` if there are comments inside of parens, else `false` + */ + function hasCommentsInParens() { + if (astUtils.isOpeningParenToken(firstTokenOfParam)) { + const closingParenToken = sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken); + + return closingParenToken && sourceCode.commentsExistBetween(firstTokenOfParam, closingParenToken); + } + return false; + + } + + if (hasCommentsInParens()) { + return; + } + // "as-needed", { "requireForBlockBody": true }: x => x if ( requireForBlockBody && - node.params.length === 1 && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && node.body.type !== "BlockStatement" && @@ -144,7 +161,6 @@ module.exports = { // "as-needed": x => x if (asNeeded && - node.params.length === 1 && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.returnType @@ -178,7 +194,7 @@ module.exports = { } return { - ArrowFunctionExpression: parens + "ArrowFunctionExpression[params.length=1]": parens }; } }; diff --git a/tools/node_modules/eslint/lib/rules/block-spacing.js b/tools/node_modules/eslint/lib/rules/block-spacing.js index c6ed44a2798a6b..c4b30b0b70b983 100644 --- a/tools/node_modules/eslint/lib/rules/block-spacing.js +++ b/tools/node_modules/eslint/lib/rules/block-spacing.js @@ -102,9 +102,18 @@ module.exports = { // Check. if (!isValid(openBrace, firstToken)) { + let loc = openBrace.loc; + + if (messageId === "extra") { + loc = { + start: openBrace.loc.end, + end: firstToken.loc.start + }; + } + context.report({ node, - loc: openBrace.loc.start, + loc, messageId, data: { location: "after", @@ -120,9 +129,17 @@ module.exports = { }); } if (!isValid(lastToken, closeBrace)) { + let loc = closeBrace.loc; + + if (messageId === "extra") { + loc = { + start: lastToken.loc.end, + end: closeBrace.loc.start + }; + } context.report({ node, - loc: closeBrace.loc.start, + loc, messageId, data: { location: "before", diff --git a/tools/node_modules/eslint/lib/rules/callback-return.js b/tools/node_modules/eslint/lib/rules/callback-return.js index 5df792d436341e..ba13c9a6481768 100644 --- a/tools/node_modules/eslint/lib/rules/callback-return.js +++ b/tools/node_modules/eslint/lib/rules/callback-return.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/callback-return"], + replacedBy: [], type: "suggestion", 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 dccdd0a40c6d76..5ecb63ecfa7b60 100644 --- a/tools/node_modules/eslint/lib/rules/func-call-spacing.js +++ b/tools/node_modules/eslint/lib/rules/func-call-spacing.js @@ -116,7 +116,13 @@ module.exports = { if (never && hasWhitespace) { context.report({ node, - loc: leftToken.loc.start, + loc: { + start: leftToken.loc.end, + end: { + line: rightToken.loc.start.line, + column: rightToken.loc.start.column - 1 + } + }, messageId: "unexpectedWhitespace", fix(fixer) { @@ -134,7 +140,13 @@ module.exports = { } else if (!never && !hasWhitespace) { context.report({ node, - loc: leftToken.loc.start, + loc: { + start: { + line: leftToken.loc.end.line, + column: leftToken.loc.end.column - 1 + }, + end: rightToken.loc.start + }, messageId: "missing", fix(fixer) { return fixer.insertTextBefore(rightToken, " "); @@ -143,7 +155,10 @@ module.exports = { } else if (!never && !allowNewlines && hasNewline) { context.report({ node, - loc: leftToken.loc.start, + loc: { + start: leftToken.loc.end, + end: rightToken.loc.start + }, messageId: "unexpectedNewline", fix(fixer) { return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " "); diff --git a/tools/node_modules/eslint/lib/rules/global-require.js b/tools/node_modules/eslint/lib/rules/global-require.js index 9bd073b88546d6..469c0175d2556b 100644 --- a/tools/node_modules/eslint/lib/rules/global-require.js +++ b/tools/node_modules/eslint/lib/rules/global-require.js @@ -50,7 +50,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/global-require"], + replacedBy: [], type: "suggestion", 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 8ad63bbd53a77b..b92490ad16bdaf 100644 --- a/tools/node_modules/eslint/lib/rules/handle-callback-err.js +++ b/tools/node_modules/eslint/lib/rules/handle-callback-err.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/handle-callback-err"], + replacedBy: [], type: "suggestion", diff --git a/tools/node_modules/eslint/lib/rules/index.js b/tools/node_modules/eslint/lib/rules/index.js index 7f563eb2ebfb96..9e5571dd97d4cc 100644 --- a/tools/node_modules/eslint/lib/rules/index.js +++ b/tools/node_modules/eslint/lib/rules/index.js @@ -148,6 +148,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({ "no-lone-blocks": () => require("./no-lone-blocks"), "no-lonely-if": () => require("./no-lonely-if"), "no-loop-func": () => require("./no-loop-func"), + "no-loss-of-precision": () => require("./no-loss-of-precision"), "no-magic-numbers": () => require("./no-magic-numbers"), "no-misleading-character-class": () => require("./no-misleading-character-class"), "no-mixed-operators": () => require("./no-mixed-operators"), diff --git a/tools/node_modules/eslint/lib/rules/keyword-spacing.js b/tools/node_modules/eslint/lib/rules/keyword-spacing.js index 2b3fef33bd7ac4..99979a32a5bbf7 100644 --- a/tools/node_modules/eslint/lib/rules/keyword-spacing.js +++ b/tools/node_modules/eslint/lib/rules/keyword-spacing.js @@ -152,7 +152,7 @@ module.exports = { sourceCode.isSpaceBetweenTokens(prevToken, token) ) { context.report({ - loc: token.loc.start, + loc: { start: prevToken.loc.end, end: token.loc.start }, messageId: "unexpectedBefore", data: token, fix(fixer) { @@ -203,8 +203,9 @@ module.exports = { astUtils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken) ) { + context.report({ - loc: token.loc.start, + loc: { start: token.loc.end, end: nextToken.loc.start }, messageId: "unexpectedAfter", data: token, fix(fixer) { @@ -442,6 +443,12 @@ module.exports = { checkSpacingAround(sourceCode.getTokenAfter(firstToken)); } + if (node.type === "ExportAllDeclaration" && node.exported) { + const asToken = sourceCode.getTokenBefore(node.exported); + + checkSpacingBefore(asToken, PREV_TOKEN_M); + } + if (node.source) { const fromToken = sourceCode.getTokenBefore(node.source); diff --git a/tools/node_modules/eslint/lib/rules/linebreak-style.js b/tools/node_modules/eslint/lib/rules/linebreak-style.js index 078eaf2cd268d2..b3b393ead77de8 100644 --- a/tools/node_modules/eslint/lib/rules/linebreak-style.js +++ b/tools/node_modules/eslint/lib/rules/linebreak-style.js @@ -86,8 +86,14 @@ module.exports = { context.report({ node, loc: { - line: i, - column: sourceCode.lines[i - 1].length + start: { + line: i, + column: sourceCode.lines[i - 1].length + }, + end: { + line: i + 1, + column: 0 + } }, messageId: expectedLF ? "expectedLF" : "expectedCRLF", fix: createFix(range, expectedLFChars) 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 03539fae470078..aa423a60a1faaa 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 @@ -134,7 +134,7 @@ module.exports = { * @returns {boolean} True if it's an IIFE */ function isIIFE(node) { - return node.type === "FunctionExpression" && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node; + return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node; } /** diff --git a/tools/node_modules/eslint/lib/rules/multiline-ternary.js b/tools/node_modules/eslint/lib/rules/multiline-ternary.js index 1df90b6feb8321..6668bff4824842 100644 --- a/tools/node_modules/eslint/lib/rules/multiline-ternary.js +++ b/tools/node_modules/eslint/lib/rules/multiline-ternary.js @@ -39,25 +39,7 @@ module.exports = { const option = context.options[0]; const multiline = option !== "never"; const allowSingleLine = option === "always-multiline"; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Tests whether node is preceded by supplied tokens - * @param {ASTNode} node node to check - * @param {ASTNode} parentNode parent of node to report - * @param {boolean} expected whether newline was expected or not - * @returns {void} - * @private - */ - function reportError(node, parentNode, expected) { - context.report({ - node, - messageId: `${expected ? "expected" : "unexpected"}${node === parentNode.test ? "TestCons" : "ConsAlt"}` - }); - } + const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- // Public @@ -65,16 +47,39 @@ module.exports = { return { ConditionalExpression(node) { - const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(node.test, node.consequent); - const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(node.consequent, node.alternate); + const questionToken = sourceCode.getTokenAfter(node.test, astUtils.isNotClosingParenToken); + const colonToken = sourceCode.getTokenAfter(node.consequent, astUtils.isNotClosingParenToken); + + const firstTokenOfTest = sourceCode.getFirstToken(node); + const lastTokenOfTest = sourceCode.getTokenBefore(questionToken); + const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken); + const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken); + const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken); + + const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent); + const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate); if (!multiline) { if (!areTestAndConsequentOnSameLine) { - reportError(node.test, node, false); + context.report({ + node: node.test, + loc: { + start: firstTokenOfTest.loc.start, + end: lastTokenOfTest.loc.end + }, + messageId: "unexpectedTestCons" + }); } if (!areConsequentAndAlternateOnSameLine) { - reportError(node.consequent, node, false); + context.report({ + node: node.consequent, + loc: { + start: firstTokenOfConsequent.loc.start, + end: lastTokenOfConsequent.loc.end + }, + messageId: "unexpectedConsAlt" + }); } } else { if (allowSingleLine && node.loc.start.line === node.loc.end.line) { @@ -82,11 +87,25 @@ module.exports = { } if (areTestAndConsequentOnSameLine) { - reportError(node.test, node, true); + context.report({ + node: node.test, + loc: { + start: firstTokenOfTest.loc.start, + end: lastTokenOfTest.loc.end + }, + messageId: "expectedTestCons" + }); } if (areConsequentAndAlternateOnSameLine) { - reportError(node.consequent, node, true); + context.report({ + node: node.consequent, + loc: { + start: firstTokenOfConsequent.loc.start, + end: lastTokenOfConsequent.loc.end + }, + messageId: "expectedConsAlt" + }); } } } 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 5dce047b92312e..152dda0ceae2ce 100644 --- a/tools/node_modules/eslint/lib/rules/no-buffer-constructor.js +++ b/tools/node_modules/eslint/lib/rules/no-buffer-constructor.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-deprecated-api"], + replacedBy: [], type: "problem", 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 b39f731c3cdf29..146c4f22d01257 100644 --- a/tools/node_modules/eslint/lib/rules/no-control-regex.js +++ b/tools/node_modules/eslint/lib/rules/no-control-regex.js @@ -35,7 +35,7 @@ const collector = new (class { try { this._source = regexpStr; this._validator.validatePattern(regexpStr); // Call onCharacter hook - } catch (err) { + } catch { // Ignore syntax errors in RegExp. } 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 aba8e63e086a41..b90757b112658c 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 @@ -172,6 +172,9 @@ module.exports = { case "UnaryExpression": return precedence(node) < precedence(parent); case "LogicalExpression": + if (astUtils.isMixedLogicalAndCoalesceExpressions(node, parent)) { + return true; + } if (previousNode === parent.left) { return precedence(node) < precedence(parent); } 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 7cbb7522ebedfa..bae1a498cf0cf1 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-parens.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-parens.js @@ -51,7 +51,8 @@ module.exports = { ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] }, enforceForArrowConditionals: { type: "boolean" }, enforceForSequenceExpressions: { type: "boolean" }, - enforceForNewInMemberExpressions: { type: "boolean" } + enforceForNewInMemberExpressions: { type: "boolean" }, + enforceForFunctionPrototypeMethods: { type: "boolean" } }, additionalProperties: false } @@ -83,12 +84,28 @@ module.exports = { context.options[1].enforceForSequenceExpressions === false; const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && context.options[1].enforceForNewInMemberExpressions === false; + const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && + context.options[1].enforceForFunctionPrototypeMethods === false; const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" }); const PRECEDENCE_OF_UPDATE_EXPR = precedence({ type: "UpdateExpression" }); let reportsBuffer; + /** + * Determines whether the given node is a `call` or `apply` method call, invoked directly on a `FunctionExpression` node. + * Example: function(){}.call() + * @param {ASTNode} node The node to be checked. + * @returns {boolean} True if the node is an immediate `call` or `apply` method call. + * @private + */ + function isImmediateFunctionPrototypeMethodCall(node) { + return node.type === "CallExpression" && + node.callee.type === "MemberExpression" && + node.callee.object.type === "FunctionExpression" && + ["call", "apply"].includes(astUtils.getStaticPropertyName(node.callee)); + } + /** * Determines if this rule should be enforced for a node given the current configuration. * @param {ASTNode} node The node to be checked. @@ -125,6 +142,10 @@ module.exports = { return false; } + if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS) { + return false; + } + return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression"; } @@ -478,6 +499,7 @@ module.exports = { if (!shouldSkipLeft && hasExcessParens(node.left)) { if ( !(node.left.type === "UnaryExpression" && isExponentiation) && + !astUtils.isMixedLogicalAndCoalesceExpressions(node.left, node) && (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation)) || isParenthesisedTwice(node.left) ) { @@ -487,6 +509,7 @@ module.exports = { if (!shouldSkipRight && hasExcessParens(node.right)) { if ( + !astUtils.isMixedLogicalAndCoalesceExpressions(node.right, node) && (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation)) || isParenthesisedTwice(node.right) ) { @@ -927,7 +950,12 @@ module.exports = { LogicalExpression: checkBinaryLogical, MemberExpression(node) { - const nodeObjHasExcessParens = hasExcessParens(node.object); + const nodeObjHasExcessParens = hasExcessParens(node.object) && + !( + isImmediateFunctionPrototypeMethodCall(node.parent) && + node.parent.callee === node && + IGNORE_FUNCTION_PROTOTYPE_METHODS + ); if ( nodeObjHasExcessParens && 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 c09e36fd017697..48b7188d49f9c5 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js @@ -93,7 +93,7 @@ module.exports = { try { validator.validateFlags(flags); return null; - } catch (err) { + } catch { return `Invalid flags supplied to RegExp constructor '${flags}'`; } } diff --git a/tools/node_modules/eslint/lib/rules/no-loss-of-precision.js b/tools/node_modules/eslint/lib/rules/no-loss-of-precision.js new file mode 100644 index 00000000000000..b95677c2e0b272 --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/no-loss-of-precision.js @@ -0,0 +1,198 @@ +/** + * @fileoverview Rule to flag numbers that will lose significant figure precision at runtime + * @author Jacob Moore + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: "problem", + + docs: { + description: "disallow literal numbers that lose precision", + category: "Possible Errors", + recommended: false, + url: "https://eslint.org/docs/rules/no-loss-of-precision" + }, + schema: [], + messages: { + noLossOfPrecision: "This number literal will lose precision at runtime." + } + }, + + create(context) { + + /** + * Returns whether the node is number literal + * @param {Node} node the node literal being evaluated + * @returns {boolean} true if the node is a number literal + */ + function isNumber(node) { + return typeof node.value === "number"; + } + + + /** + * Checks whether the number is base ten + * @param {ASTNode} node the node being evaluated + * @returns {boolean} true if the node is in base ten + */ + function isBaseTen(node) { + const prefixes = ["0x", "0X", "0b", "0B", "0o", "0O"]; + + return prefixes.every(prefix => !node.raw.startsWith(prefix)) && + !/^0[0-7]+$/u.test(node.raw); + } + + /** + * Checks that the user-intended non-base ten number equals the actual number after is has been converted to the Number type + * @param {Node} node the node being evaluated + * @returns {boolean} true if they do not match + */ + function notBaseTenLosesPrecision(node) { + const rawString = node.raw.toUpperCase(); + let base = 0; + + if (rawString.startsWith("0B")) { + base = 2; + } else if (rawString.startsWith("0X")) { + base = 16; + } else { + base = 8; + } + + return !rawString.endsWith(node.value.toString(base).toUpperCase()); + } + + /** + * Adds a decimal point to the numeric string at index 1 + * @param {string} stringNumber the numeric string without any decimal point + * @returns {string} the numeric string with a decimal point in the proper place + */ + function addDecimalPointToNumber(stringNumber) { + return `${stringNumber.slice(0, 1)}.${stringNumber.slice(1)}`; + } + + /** + * Returns the number stripped of leading zeros + * @param {string} numberAsString the string representation of the number + * @returns {string} the stripped string + */ + function removeLeadingZeros(numberAsString) { + return numberAsString.replace(/^0*/u, ""); + } + + /** + * Returns the number stripped of trailing zeros + * @param {string} numberAsString the string representation of the number + * @returns {string} the stripped string + */ + function removeTrailingZeros(numberAsString) { + return numberAsString.replace(/0*$/u, ""); + } + + /** + * Converts an integer to to an object containing the the integer's coefficient and order of magnitude + * @param {string} stringInteger the string representation of the integer being converted + * @returns {Object} the object containing the the integer's coefficient and order of magnitude + */ + function normalizeInteger(stringInteger) { + const significantDigits = removeTrailingZeros(removeLeadingZeros(stringInteger)); + + return { + magnitude: stringInteger.startsWith("0") ? stringInteger.length - 2 : stringInteger.length - 1, + coefficient: addDecimalPointToNumber(significantDigits) + }; + } + + /** + * + * Converts a float to to an object containing the the floats's coefficient and order of magnitude + * @param {string} stringFloat the string representation of the float being converted + * @returns {Object} the object containing the the integer's coefficient and order of magnitude + */ + function normalizeFloat(stringFloat) { + const trimmedFloat = removeLeadingZeros(stringFloat); + + if (trimmedFloat.startsWith(".")) { + const decimalDigits = trimmedFloat.split(".").pop(); + const significantDigits = removeLeadingZeros(decimalDigits); + + return { + magnitude: significantDigits.length - decimalDigits.length - 1, + coefficient: addDecimalPointToNumber(significantDigits) + }; + + } + return { + magnitude: trimmedFloat.indexOf(".") - 1, + coefficient: addDecimalPointToNumber(trimmedFloat.replace(".", "")) + + }; + } + + + /** + * Converts a base ten number to proper scientific notation + * @param {string} stringNumber the string representation of the base ten number to be converted + * @returns {string} the number converted to scientific notation + */ + function convertNumberToScientificNotation(stringNumber) { + const splitNumber = stringNumber.replace("E", "e").split("e"); + const originalCoefficient = splitNumber[0]; + const normalizedNumber = stringNumber.includes(".") ? normalizeFloat(originalCoefficient) + : normalizeInteger(originalCoefficient); + const normalizedCoefficient = normalizedNumber.coefficient; + const magnitude = splitNumber.length > 1 ? (parseInt(splitNumber[1], 10) + normalizedNumber.magnitude) + : normalizedNumber.magnitude; + + return `${normalizedCoefficient}e${magnitude}`; + + } + + /** + * Checks that the user-intended base ten number equals the actual number after is has been converted to the Number type + * @param {Node} node the node being evaluated + * @returns {boolean} true if they do not match + */ + function baseTenLosesPrecision(node) { + const normalizedRawNumber = convertNumberToScientificNotation(node.raw); + const requestedPrecision = normalizedRawNumber.split("e")[0].replace(".", "").length; + + if (requestedPrecision > 100) { + return true; + } + const storedNumber = node.value.toPrecision(requestedPrecision); + const normalizedStoredNumber = convertNumberToScientificNotation(storedNumber); + + return normalizedRawNumber !== normalizedStoredNumber; + } + + + /** + * Checks that the user-intended number equals the actual number after is has been converted to the Number type + * @param {Node} node the node being evaluated + * @returns {boolean} true if they do not match + */ + function losesPrecision(node) { + return isBaseTen(node) ? baseTenLosesPrecision(node) : notBaseTenLosesPrecision(node); + } + + + return { + Literal(node) { + if (node.value && isNumber(node) && losesPrecision(node)) { + context.report({ + messageId: "noLossOfPrecision", + node + }); + } + } + }; + } +}; 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 9315ba64972f79..3d004615c3f070 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 @@ -147,7 +147,7 @@ module.exports = { pattern.length, flags.includes("u") ); - } catch (e) { + } catch { // Ignore regular expressions with syntax errors return; 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 37e8906e827a4c..f0290e93ece8db 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js @@ -21,13 +21,15 @@ const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="]; const LOGICAL_OPERATORS = ["&&", "||"]; const RELATIONAL_OPERATORS = ["in", "instanceof"]; const TERNARY_OPERATOR = ["?:"]; +const COALESCE_OPERATOR = ["??"]; const ALL_OPERATORS = [].concat( ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS, - TERNARY_OPERATOR + TERNARY_OPERATOR, + COALESCE_OPERATOR ); const DEFAULT_GROUPS = [ ARITHMETIC_OPERATORS, @@ -236,7 +238,6 @@ module.exports = { return { BinaryExpression: check, LogicalExpression: check - }; } }; 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 bfe9b7aa97858a..a02de9104bdd88 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-requires.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-requires.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-mixed-requires"], + replacedBy: [], type: "suggestion", 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 16c2bd4122e851..287cbda03daf5a 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 @@ -67,7 +67,7 @@ module.exports = { * or the reverse before non-tab/-space * characters begin. */ - let regex = /^(?=[\t ]*(\t | \t))/u; + let regex = /^(?=( +|\t+))\1(?:\t| )/u; if (smartTabs) { @@ -75,19 +75,27 @@ module.exports = { * At least one space followed by a tab * before non-tab/-space characters begin. */ - regex = /^(?=[\t ]* \t)/u; + regex = /^(?=(\t*))\1(?=( +))\2\t/u; } lines.forEach((line, i) => { const match = regex.exec(line); if (match) { - const lineNumber = i + 1, - column = match.index + 1, - loc = { line: lineNumber, column }; + const lineNumber = i + 1; + const loc = { + start: { + line: lineNumber, + column: match[0].length - 2 + }, + end: { + line: lineNumber, + column: match[0].length + } + }; if (!ignoredCommentLines.has(lineNumber)) { - const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc)); + const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start)); if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) { context.report({ 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 d1360e9dee036d..9af4e31cabf6d4 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-func.js +++ b/tools/node_modules/eslint/lib/rules/no-new-func.js @@ -29,26 +29,29 @@ module.exports = { create(context) { - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports a node. - * @param {ASTNode} node The node to report - * @returns {void} - * @private - */ - function report(node) { - context.report({ - node, - messageId: "noFunctionConstructor" - }); - } - return { - "NewExpression[callee.name = 'Function']": report, - "CallExpression[callee.name = 'Function']": report + "Program:exit"() { + const globalScope = context.getScope(); + const variable = globalScope.set.get("Function"); + + if (variable && variable.defs.length === 0) { + variable.references.forEach(ref => { + const node = ref.identifier; + const { parent } = node; + + if ( + parent && + (parent.type === "NewExpression" || parent.type === "CallExpression") && + node === parent.callee + ) { + context.report({ + node: parent, + messageId: "noFunctionConstructor" + }); + } + }); + } + } }; } 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 7f81e83fd782c3..063f783e70cc3c 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-require.js +++ b/tools/node_modules/eslint/lib/rules/no-new-require.js @@ -13,7 +13,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-new-require"], + replacedBy: [], type: "suggestion", 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 cb7e4f0fc88d69..aeb509c0d9c142 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-symbol.js +++ b/tools/node_modules/eslint/lib/rules/no-new-symbol.js @@ -37,8 +37,9 @@ module.exports = { if (variable && variable.defs.length === 0) { variable.references.forEach(ref => { const node = ref.identifier; + const parent = node.parent; - if (node.parent && node.parent.type === "NewExpression") { + if (parent && parent.type === "NewExpression" && parent.callee === node) { context.report({ node, messageId: "noNewSymbol" 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 77a03a7f952b04..fc1f894f878988 100644 --- a/tools/node_modules/eslint/lib/rules/no-path-concat.js +++ b/tools/node_modules/eslint/lib/rules/no-path-concat.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-path-concat"], + replacedBy: [], type: "suggestion", 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 24bb9f9971d5c9..49d1734906e81f 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-env.js +++ b/tools/node_modules/eslint/lib/rules/no-process-env.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-process-env"], + replacedBy: [], type: "suggestion", 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 9c70ea8808b4c4..77c9cfd7cbd342 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-exit.js +++ b/tools/node_modules/eslint/lib/rules/no-process-exit.js @@ -12,7 +12,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-process-exit"], + replacedBy: [], type: "suggestion", 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 afb26d70259f1b..e6d4c9efba75fe 100644 --- a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js @@ -76,7 +76,7 @@ module.exports = { try { regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, flags.includes("u")); - } catch (e) { + } catch { // Ignore regular expressions with syntax errors return; diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-exports.js b/tools/node_modules/eslint/lib/rules/no-restricted-exports.js index 5b5c7d9bffb99c..6031e26de2c7e8 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-exports.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-exports.js @@ -61,6 +61,12 @@ module.exports = { } return { + ExportAllDeclaration(node) { + if (node.exported) { + checkExportedName(node.exported); + } + }, + ExportNamedDeclaration(node) { const declaration = node.declaration; 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 61834ceeb444d3..d0b8a78a507fa8 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js @@ -42,7 +42,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-restricted-require"], + replacedBy: [], type: "suggestion", diff --git a/tools/node_modules/eslint/lib/rules/no-sync.js b/tools/node_modules/eslint/lib/rules/no-sync.js index 9790d1f94bb20c..06424e0b38f33f 100644 --- a/tools/node_modules/eslint/lib/rules/no-sync.js +++ b/tools/node_modules/eslint/lib/rules/no-sync.js @@ -15,7 +15,7 @@ module.exports = { meta: { deprecated: true, - replacedBy: ["node/no-sync"], + replacedBy: [], type: "suggestion", 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 d4438e2fe08fbe..0fefc42b909820 100644 --- a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js @@ -147,10 +147,12 @@ module.exports = { loc: node.consequent.loc.start, messageId: "unnecessaryConditionalAssignment", fix: fixer => { - const shouldParenthesizeAlternate = ( - astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE && - !astUtils.isParenthesised(sourceCode, node.alternate) - ); + const shouldParenthesizeAlternate = + ( + astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE || + astUtils.isCoalesceExpression(node.alternate) + ) && + !astUtils.isParenthesised(sourceCode, node.alternate); const alternateText = shouldParenthesizeAlternate ? `(${sourceCode.getText(node.alternate)})` : astUtils.getParenthesisedText(sourceCode, node.alternate); 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 26a25b7584bc80..8c049f556ff2d9 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -124,7 +124,7 @@ module.exports = { return true; } - return /^(?:Assignment|Call|New|Update|Yield|Await)Expression$/u.test(node.type) || + return /^(?:Assignment|Call|New|Update|Yield|Await|Import)Expression$/u.test(node.type) || (node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0); } 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 18c48bf0d7810c..50dcab45fe2bb6 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-vars.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-vars.js @@ -619,7 +619,9 @@ module.exports = { // Report the first declaration. if (unusedVar.defs.length > 0) { context.report({ - node: unusedVar.identifiers[0], + node: unusedVar.references.length ? unusedVar.references[ + unusedVar.references.length - 1 + ].identifier : unusedVar.identifiers[0], messageId: "unusedVar", data: unusedVar.references.some(ref => ref.isWrite()) ? getAssignedMessageData(unusedVar) diff --git a/tools/node_modules/eslint/lib/rules/no-useless-backreference.js b/tools/node_modules/eslint/lib/rules/no-useless-backreference.js index 8a6fbe14daafe6..958e3d5dd4e4d5 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-backreference.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-backreference.js @@ -95,7 +95,7 @@ module.exports = { try { regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u")); - } catch (e) { + } catch { // Ignore regular expressions with syntax errors return; 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 30ca2cf49834fe..db4674760a0f27 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 @@ -71,7 +71,7 @@ module.exports = { context.report({ node, messageId: "expectVarOnNewline", - loc: current.loc.start, + loc: current.loc, fix: fixer => fixer.insertTextBefore(current, "\n") }); } diff --git a/tools/node_modules/eslint/lib/rules/padded-blocks.js b/tools/node_modules/eslint/lib/rules/padded-blocks.js index f58a7535ba86c2..fa65eae4e0222d 100644 --- a/tools/node_modules/eslint/lib/rules/padded-blocks.js +++ b/tools/node_modules/eslint/lib/rules/padded-blocks.js @@ -203,10 +203,14 @@ module.exports = { } if (requirePaddingFor(node)) { + if (!blockHasTopPadding) { context.report({ node, - loc: { line: tokenBeforeFirst.loc.start.line, column: tokenBeforeFirst.loc.start.column }, + loc: { + start: tokenBeforeFirst.loc.start, + end: firstBlockToken.loc.start + }, fix(fixer) { return fixer.insertTextAfter(tokenBeforeFirst, "\n"); }, @@ -216,7 +220,10 @@ module.exports = { if (!blockHasBottomPadding) { context.report({ node, - loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 }, + loc: { + end: tokenAfterLast.loc.start, + start: lastBlockToken.loc.end + }, fix(fixer) { return fixer.insertTextBefore(tokenAfterLast, "\n"); }, @@ -228,7 +235,10 @@ module.exports = { context.report({ node, - loc: { line: tokenBeforeFirst.loc.start.line, column: tokenBeforeFirst.loc.start.column }, + loc: { + start: tokenBeforeFirst.loc.start, + end: firstBlockToken.loc.start + }, fix(fixer) { return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n"); }, @@ -240,7 +250,10 @@ module.exports = { context.report({ node, - loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 }, + loc: { + end: tokenAfterLast.loc.start, + start: lastBlockToken.loc.end + }, messageId: "neverPadBlock", fix(fixer) { return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n"); diff --git a/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js b/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js index c8af043c1b5268..7d0aa3f9dc094d 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js +++ b/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js @@ -59,7 +59,7 @@ module.exports = { try { ast = parser.parsePattern(pattern, 0, pattern.length, uFlag); - } catch (_) { + } catch { // ignore regex syntax errors return; diff --git a/tools/node_modules/eslint/lib/rules/quote-props.js b/tools/node_modules/eslint/lib/rules/quote-props.js index a2a4e1d47923ff..fab7bdc9c1555b 100644 --- a/tools/node_modules/eslint/lib/rules/quote-props.js +++ b/tools/node_modules/eslint/lib/rules/quote-props.js @@ -154,7 +154,7 @@ module.exports = { try { tokens = espree.tokenize(key.value); - } catch (e) { + } catch { return; } @@ -239,7 +239,7 @@ module.exports = { try { tokens = espree.tokenize(key.value); - } catch (e) { + } catch { necessaryQuotes = true; return; } 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 4bb5f787c6c568..8cb9814f0c9129 100644 --- a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js +++ b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js @@ -79,10 +79,7 @@ module.exports = { if (alwaysSpace && !hasWhitespace) { context.report({ node, - loc: { - line: operator.loc.end.line, - column: operator.loc.end.column - }, + loc: operator.loc, messageId: "expectedWhitespace", data: { type @@ -95,8 +92,8 @@ module.exports = { context.report({ node, loc: { - line: operator.loc.end.line, - column: operator.loc.end.column + start: operator.loc.end, + end: nextToken.loc.start }, messageId: "unexpectedWhitespace", data: { diff --git a/tools/node_modules/eslint/lib/rules/semi-spacing.js b/tools/node_modules/eslint/lib/rules/semi-spacing.js index 92948533d2789e..936e7661ef4fb3 100644 --- a/tools/node_modules/eslint/lib/rules/semi-spacing.js +++ b/tools/node_modules/eslint/lib/rules/semi-spacing.js @@ -117,6 +117,18 @@ module.exports = { } /** + * Report location example : + * + * for unexpected space `before` + * + * var a = 'b' ; + * ^^^ + * + * for unexpected space `after` + * + * var a = 'b'; c = 10; + * ^^ + * * Reports if the given token has invalid spacing. * @param {Token} token The semicolon token to check. * @param {ASTNode} node The corresponding node of the token. @@ -124,16 +136,19 @@ module.exports = { */ function checkSemicolonSpacing(token, node) { if (astUtils.isSemicolonToken(token)) { - const location = token.loc.start; - if (hasLeadingSpace(token)) { if (!requireSpaceBefore) { + const tokenBefore = sourceCode.getTokenBefore(token); + const loc = { + start: tokenBefore.loc.end, + end: token.loc.start + }; + context.report({ node, - loc: location, + loc, messageId: "unexpectedWhitespaceBefore", fix(fixer) { - const tokenBefore = sourceCode.getTokenBefore(token); return fixer.removeRange([tokenBefore.range[1], token.range[0]]); } @@ -141,9 +156,11 @@ module.exports = { } } else { if (requireSpaceBefore) { + const loc = token.loc; + context.report({ node, - loc: location, + loc, messageId: "missingWhitespaceBefore", fix(fixer) { return fixer.insertTextBefore(token, " "); @@ -155,12 +172,17 @@ module.exports = { if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) { if (hasTrailingSpace(token)) { if (!requireSpaceAfter) { + const tokenAfter = sourceCode.getTokenAfter(token); + const loc = { + start: token.loc.end, + end: tokenAfter.loc.start + }; + context.report({ node, - loc: location, + loc, messageId: "unexpectedWhitespaceAfter", fix(fixer) { - const tokenAfter = sourceCode.getTokenAfter(token); return fixer.removeRange([token.range[1], tokenAfter.range[0]]); } @@ -168,9 +190,11 @@ module.exports = { } } else { if (requireSpaceAfter) { + const loc = token.loc; + context.report({ node, - loc: location, + loc, messageId: "missingWhitespaceAfter", fix(fixer) { return fixer.insertTextAfter(token, " "); 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 9eb6d86077da36..16f586255af567 100644 --- a/tools/node_modules/eslint/lib/rules/template-tag-spacing.js +++ b/tools/node_modules/eslint/lib/rules/template-tag-spacing.js @@ -49,7 +49,10 @@ module.exports = { if (never && hasWhitespace) { context.report({ node, - loc: tagToken.loc.start, + loc: { + start: tagToken.loc.end, + end: literalToken.loc.start + }, messageId: "unexpected", fix(fixer) { const comments = sourceCode.getCommentsBefore(node.quasi); @@ -68,7 +71,10 @@ module.exports = { } else if (!never && !hasWhitespace) { context.report({ node, - loc: tagToken.loc.start, + loc: { + start: node.loc.start, + end: literalToken.loc.start + }, messageId: "missing", fix(fixer) { return fixer.insertTextAfter(tagToken, " "); diff --git a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js index e6a3cb4cac58be..ecea6948da2360 100644 --- a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js +++ b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js @@ -416,6 +416,53 @@ function equalTokens(left, right, sourceCode) { return true; } +/** + * Check if the given node is a true logical expression or not. + * + * The three binary expressions logical-or (`||`), logical-and (`&&`), and + * coalesce (`??`) are known as `ShortCircuitExpression`. + * But ESTree represents those by `LogicalExpression` node. + * + * This function rejects coalesce expressions of `LogicalExpression` node. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is `&&` or `||`. + * @see https://tc39.es/ecma262/#prod-ShortCircuitExpression + */ +function isLogicalExpression(node) { + return ( + node.type === "LogicalExpression" && + (node.operator === "&&" || node.operator === "||") + ); +} + +/** + * Check if the given node is a nullish coalescing expression or not. + * + * The three binary expressions logical-or (`||`), logical-and (`&&`), and + * coalesce (`??`) are known as `ShortCircuitExpression`. + * But ESTree represents those by `LogicalExpression` node. + * + * This function finds only coalesce expressions of `LogicalExpression` node. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is `??`. + */ +function isCoalesceExpression(node) { + return node.type === "LogicalExpression" && node.operator === "??"; +} + +/** + * Check if given two nodes are the pair of a logical expression and a coalesce expression. + * @param {ASTNode} left A node to check. + * @param {ASTNode} right Another node to check. + * @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression. + */ +function isMixedLogicalAndCoalesceExpressions(left, right) { + return ( + (isLogicalExpression(left) && isCoalesceExpression(right)) || + (isCoalesceExpression(left) && isLogicalExpression(right)) + ); +} + //------------------------------------------------------------------------------ // Public Interface //------------------------------------------------------------------------------ @@ -779,6 +826,7 @@ module.exports = { case "LogicalExpression": switch (node.operator) { case "||": + case "??": return 4; case "&&": return 5; @@ -1243,19 +1291,64 @@ module.exports = { /** * Gets next location when the result is not out of bound, otherwise returns null. + * + * Assumptions: + * + * - The given location represents a valid location in the given source code. + * - Columns are 0-based. + * - Lines are 1-based. + * - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location. + * - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end. + * The start (column 0) of that extra line is considered to be a valid location. + * + * Examples of successive locations (line, column): + * + * code: foo + * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null + * + * code: foo + * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null + * + * code: foo + * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null + * + * code: ab + * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null + * + * code: ab + * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null + * + * code: ab + * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null + * + * code: a + * locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null + * + * code: + * locations: (1, 0) -> (2, 0) -> null + * + * code: + * locations: (1, 0) -> null * @param {SourceCode} sourceCode The sourceCode * @param {{line: number, column: number}} location The location * @returns {{line: number, column: number} | null} Next location */ - getNextLocation(sourceCode, location) { - const index = sourceCode.getIndexFromLoc(location); + getNextLocation(sourceCode, { line, column }) { + if (column < sourceCode.lines[line - 1].length) { + return { + line, + column: column + 1 + }; + } - // Avoid out of bound location - if (index + 1 > sourceCode.text.length) { - return null; + if (line < sourceCode.lines.length) { + return { + line: line + 1, + column: 0 + }; } - return sourceCode.getLocFromIndex(index + 1); + return null; }, /** @@ -1370,7 +1463,7 @@ module.exports = { try { tokens = espree.tokenize(leftValue, espreeOptions); - } catch (e) { + } catch { return false; } @@ -1399,7 +1492,7 @@ module.exports = { try { tokens = espree.tokenize(rightValue, espreeOptions); - } catch (e) { + } catch { return false; } @@ -1493,5 +1586,9 @@ module.exports = { */ hasOctalEscapeSequence(rawString) { return OCTAL_ESCAPE_PATTERN.test(rawString); - } + }, + + isLogicalExpression, + isCoalesceExpression, + isMixedLogicalAndCoalesceExpressions }; diff --git a/tools/node_modules/eslint/lib/source-code/source-code.js b/tools/node_modules/eslint/lib/source-code/source-code.js index 591d5a7e454ee2..6b20495b6fc807 100644 --- a/tools/node_modules/eslint/lib/source-code/source-code.js +++ b/tools/node_modules/eslint/lib/source-code/source-code.js @@ -305,6 +305,7 @@ class SourceCode extends TokenStore { * @returns {Object} An object containing a leading and trailing array * of comments indexed by their position. * @public + * @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside(). */ getComments(node) { if (this._commentCache.has(node)) { diff --git a/tools/node_modules/eslint/messages/extend-config-missing.txt b/tools/node_modules/eslint/messages/extend-config-missing.txt index 0411819ec4e18f..f7c5f71ebe3256 100644 --- a/tools/node_modules/eslint/messages/extend-config-missing.txt +++ b/tools/node_modules/eslint/messages/extend-config-missing.txt @@ -2,4 +2,4 @@ ESLint couldn't find the config "<%- configName %>" to extend from. Please check The config "<%- configName %>" was referenced from the config file in "<%- importerName %>". -If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team. +If you still have problems, please stop by https://eslint.org/chat to chat with the team. diff --git a/tools/node_modules/eslint/messages/no-config-found.txt b/tools/node_modules/eslint/messages/no-config-found.txt index 348f6dcd25f62f..f1f7beb63b19a0 100644 --- a/tools/node_modules/eslint/messages/no-config-found.txt +++ b/tools/node_modules/eslint/messages/no-config-found.txt @@ -4,4 +4,4 @@ ESLint couldn't find a configuration file. To set up a configuration file for th ESLint looked for configuration files in <%= directoryPath %> and its ancestors. If it found none, it then looked in your home directory. -If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://gitter.im/eslint/eslint +If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://eslint.org/chat diff --git a/tools/node_modules/eslint/messages/plugin-conflict.txt b/tools/node_modules/eslint/messages/plugin-conflict.txt index 6fcf7c83115d70..f8b60631c58ea1 100644 --- a/tools/node_modules/eslint/messages/plugin-conflict.txt +++ b/tools/node_modules/eslint/messages/plugin-conflict.txt @@ -4,4 +4,4 @@ ESLint couldn't determine the plugin "<%- pluginId %>" uniquely. Please remove the "plugins" setting from either config or remove either plugin installation. -If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team. +If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team. diff --git a/tools/node_modules/eslint/messages/plugin-missing.txt b/tools/node_modules/eslint/messages/plugin-missing.txt index 32e9f0ae5de585..3d376733085667 100644 --- a/tools/node_modules/eslint/messages/plugin-missing.txt +++ b/tools/node_modules/eslint/messages/plugin-missing.txt @@ -8,4 +8,4 @@ It's likely that the plugin isn't installed correctly. Try reinstalling by runni The plugin "<%- pluginName %>" was referenced from the config file in "<%- importerName %>". -If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team. +If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team. diff --git a/tools/node_modules/eslint/messages/whitespace-found.txt b/tools/node_modules/eslint/messages/whitespace-found.txt index eea4efccedb1d1..7d72149a8fd4fb 100644 --- a/tools/node_modules/eslint/messages/whitespace-found.txt +++ b/tools/node_modules/eslint/messages/whitespace-found.txt @@ -1,3 +1,3 @@ ESLint couldn't find the plugin "<%- pluginName %>". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name. -If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team. +If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team. diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js index 62945f7782a774..2dd96e5758c777 100644 --- a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js @@ -29,7 +29,7 @@ function getMarkerLines(loc, source, opts) { column: 0, line: -1 }, loc.start); - const endLoc = Object.assign({}, startLoc, {}, loc.end); + const endLoc = Object.assign(Object.assign({}, startLoc), loc.end); const { linesAbove = 2, linesBelow = 3 diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json b/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json index 7508b5b1402c94..05e388a3549712 100644 --- a/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json @@ -3,9 +3,12 @@ "name": "Sebastian McKenzie", "email": "sebmck@gmail.com" }, + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "dependencies": { - "@babel/highlight": "^7.8.3" + "@babel/highlight": "^7.10.1" }, "deprecated": false, "description": "Generate errors that contain a code frame that point to source locations.", @@ -13,7 +16,7 @@ "chalk": "^2.0.0", "strip-ansi": "^4.0.0" }, - "gitHead": "a7620bd266ae1345975767bbc7abf09034437017", + "gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf", "homepage": "https://babeljs.io/", "license": "MIT", "main": "lib/index.js", @@ -23,7 +26,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-code-frame" }, - "version": "7.8.3" + "version": "7.10.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json index da8c4e12d40ff7..7ca0be602c99a6 100644 --- a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json @@ -1,4 +1,7 @@ { + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "deprecated": false, "description": "Validate identifier/keywords name", @@ -7,7 +10,8 @@ "unicode-13.0.0": "^0.8.0" }, "exports": "./lib/index.js", - "gitHead": "5b97e77e030cf3853a147fdff81844ea4026219d", + "gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf", + "homepage": "https://github.com/babel/babel#readme", "license": "MIT", "main": "./lib/index.js", "name": "@babel/helper-validator-identifier", @@ -16,7 +20,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-validator-identifier" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-helper-validator-identifier" }, - "version": "7.9.5" + "version": "7.10.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json index f4ecd5f2a42a6c..1899d79a7f0fc2 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json @@ -3,9 +3,12 @@ "name": "suchipi", "email": "me@suchipi.com" }, + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "dependencies": { - "@babel/helper-validator-identifier": "^7.9.0", + "@babel/helper-validator-identifier": "^7.10.1", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -14,7 +17,7 @@ "devDependencies": { "strip-ansi": "^4.0.0" }, - "gitHead": "8d5e422be27251cfaadf8dd2536b31b4a5024b02", + "gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf", "homepage": "https://babeljs.io/", "license": "MIT", "main": "lib/index.js", @@ -24,7 +27,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-highlight" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-highlight" }, - "version": "7.9.0" + "version": "7.10.1" } \ No newline at end of file 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 e2b33179c789c7..cef695f96527df 100644 --- a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = global || self, factory(global.acorn = {})); -}(this, function (exports) { 'use strict'; +}(this, (function (exports) { 'use strict'; // Reserved word lists for various dialects of the language @@ -33,8 +33,8 @@ // are only applied when a character is found to actually have a // code point above 128. // Generated by `bin/generate-identifier-regex.js`. - var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\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\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u1cf3\u1cf5\u1cf6\u1cfa\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-\ua7bf\ua7c2-\ua7c6\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-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; - var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\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-\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\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"; + var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\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-\u08c7\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\u0d04-\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\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u1cf3\u1cf5\u1cf6\u1cfa\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-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\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-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; + var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\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\u0b55-\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\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\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\u1abf\u1ac0\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\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\ua82c\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"; var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); @@ -48,10 +48,10 @@ // generated by bin/generate-identifier-regex.js // eslint-disable-next-line comma-spacing - var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,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,155,22,13,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,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,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,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,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,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,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]; + var 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,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,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,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,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,190,0,80,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,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,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,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,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,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938]; // eslint-disable-next-line comma-spacing - var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,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,232,6,3,6,4,0,29,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,1014,0,2,54,8,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,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239]; + var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,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,2,11,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,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,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,1014,0,2,54,8,3,82,0,12,1,19628,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,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239]; // This has a complexity linear to the value of the code. The // assumption is that looking up astral identifier characters is @@ -204,6 +204,7 @@ star: binop("*", 10), slash: binop("/", 10), starstar: new TokenType("**", {beforeExpr: true}), + coalesce: binop("??", 1), // Keyword token types. _break: kw("break"), @@ -600,7 +601,14 @@ start += skipWhiteSpace.exec(this.input)[0].length; var match = literal.exec(this.input.slice(start)); if (!match) { return false } - if ((match[1] || match[2]) === "use strict") { return true } + if ((match[1] || match[2]) === "use strict") { + skipWhiteSpace.lastIndex = start + match[0].length; + var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length; + var next = this.input.charAt(end); + return next === ";" || next === "}" || + (lineBreak.test(spaceAfter[0]) && + !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=")) + } start += match[0].length; // Skip semicolon, if any. @@ -850,7 +858,7 @@ skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - if (nextCh === 40) // '(' + if (nextCh === 40 || nextCh === 46) // '(' or '.' { return this.parseExpressionStatement(node, this.parseExpression()) } } @@ -1150,17 +1158,19 @@ // strict"` declarations when `allowStrict` is true (used for // function bodies). - pp$1.parseBlock = function(createNewLexicalScope, node) { + pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) { if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; if ( node === void 0 ) node = this.startNode(); node.body = []; this.expect(types.braceL); if (createNewLexicalScope) { this.enterScope(0); } - while (!this.eat(types.braceR)) { + while (this.type !== types.braceR) { var stmt = this.parseStatement(null); node.body.push(stmt); } + if (exitStrict) { this.strict = false; } + this.next(); if (createNewLexicalScope) { this.exitScope(); } return this.finishNode(node, "BlockStatement") }; @@ -1311,7 +1321,7 @@ var hadConstructor = false; classBody.body = []; this.expect(types.braceL); - while (!this.eat(types.braceR)) { + while (this.type !== types.braceR) { var element = this.parseClassElement(node.superClass !== null); if (element) { classBody.body.push(element); @@ -1321,8 +1331,9 @@ } } } - node.body = this.finishNode(classBody, "ClassBody"); this.strict = oldStrict; + this.next(); + node.body = this.finishNode(classBody, "ClassBody"); return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") }; @@ -1410,6 +1421,14 @@ this.next(); // export * from '...' if (this.eat(types.star)) { + if (this.options.ecmaVersion >= 11) { + if (this.eatContextual("as")) { + node.exported = this.parseIdent(true); + this.checkExport(exports, node.exported.name, this.lastTokStart); + } else { + node.exported = null; + } + } this.expectContextual("from"); if (this.type !== types.string) { this.unexpected(); } node.source = this.parseExprAtom(); @@ -2026,11 +2045,20 @@ if (prec != null && (!noIn || this.type !== types._in)) { if (prec > minPrec) { var logical = this.type === types.logicalOR || this.type === types.logicalAND; + var coalesce = this.type === types.coalesce; + if (coalesce) { + // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions. + // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error. + prec = types.logicalAND.binop; + } var op = this.value; this.next(); var startPos = this.start, startLoc = this.startLoc; var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn); - var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical); + var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce); + if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) { + this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"); + } return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) } } @@ -2102,7 +2130,8 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && - this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; + this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && + this.potentialArrowAt === base.start; while (true) { var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow); if (element === base || element.type === "ArrowFunctionExpression") { return element } @@ -2266,10 +2295,18 @@ pp$3.parseExprImport = function() { var node = this.startNode(); - this.next(); // skip `import` + + // Consume `import` as an identifier for `import.meta`. + // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`. + if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); } + var meta = this.parseIdent(true); + switch (this.type) { case types.parenL: return this.parseDynamicImport(node) + case types.dot: + node.meta = meta; + return this.parseImportMeta(node) default: this.unexpected(); } @@ -2294,6 +2331,22 @@ return this.finishNode(node, "ImportExpression") }; + pp$3.parseImportMeta = function(node) { + this.next(); // skip `.` + + var containsEsc = this.containsEsc; + node.property = this.parseIdent(true); + + if (node.property.name !== "meta") + { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); } + if (containsEsc) + { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); } + if (this.options.sourceType !== "module") + { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); } + + return this.finishNode(node, "MetaProperty") + }; + pp$3.parseLiteral = function(value) { var node = this.startNode(); node.value = value; @@ -2396,10 +2449,12 @@ node.meta = meta; var containsEsc = this.containsEsc; node.property = this.parseIdent(true); - if (node.property.name !== "target" || containsEsc) - { this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); } + if (node.property.name !== "target") + { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); } + if (containsEsc) + { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); } if (!this.inNonArrowFunction()) - { this.raiseRecoverable(node.start, "new.target can only be used in functions"); } + { this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); } return this.finishNode(node, "MetaProperty") } var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import; @@ -2683,16 +2738,14 @@ // Add the params to varDeclaredNames to ensure that an error is thrown // if a let/const declaration in the function clashes with one of the params. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); - node.body = this.parseBlock(false); + // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' + if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); } + node.body = this.parseBlock(false, undefined, useStrict && !oldStrict); node.expression = false; this.adaptDirectivePrologue(node.body.body); this.labels = oldLabels; } this.exitScope(); - - // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); } - this.strict = oldStrict; }; pp$3.isSimpleParamList = function(params) { @@ -3211,49 +3264,61 @@ // If u flag is given, this returns the code point at the index (it combines a surrogate pair). // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). - RegExpValidationState.prototype.at = function at (i) { + RegExpValidationState.prototype.at = function at (i, forceU) { + if ( forceU === void 0 ) forceU = false; + var s = this.source; var l = s.length; if (i >= l) { return -1 } var c = s.charCodeAt(i); - if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { + if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { return c } var next = s.charCodeAt(i + 1); return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c }; - RegExpValidationState.prototype.nextIndex = function nextIndex (i) { + RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) { + if ( forceU === void 0 ) forceU = false; + var s = this.source; var l = s.length; if (i >= l) { return l } var c = s.charCodeAt(i), next; - if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || + if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { return i + 1 } return i + 2 }; - RegExpValidationState.prototype.current = function current () { - return this.at(this.pos) + RegExpValidationState.prototype.current = function current (forceU) { + if ( forceU === void 0 ) forceU = false; + + return this.at(this.pos, forceU) }; - RegExpValidationState.prototype.lookahead = function lookahead () { - return this.at(this.nextIndex(this.pos)) + RegExpValidationState.prototype.lookahead = function lookahead (forceU) { + if ( forceU === void 0 ) forceU = false; + + return this.at(this.nextIndex(this.pos, forceU), forceU) }; - RegExpValidationState.prototype.advance = function advance () { - this.pos = this.nextIndex(this.pos); + RegExpValidationState.prototype.advance = function advance (forceU) { + if ( forceU === void 0 ) forceU = false; + + this.pos = this.nextIndex(this.pos, forceU); }; - RegExpValidationState.prototype.eat = function eat (ch) { - if (this.current() === ch) { - this.advance(); + RegExpValidationState.prototype.eat = function eat (ch, forceU) { + if ( forceU === void 0 ) forceU = false; + + if (this.current(forceU) === ch) { + this.advance(forceU); return true } return false @@ -3592,9 +3657,9 @@ return false }; - // GroupSpecifier[U] :: + // GroupSpecifier :: // [empty] - // `?` GroupName[?U] + // `?` GroupName pp$8.regexp_groupSpecifier = function(state) { if (state.eat(0x3F /* ? */)) { if (this.regexp_eatGroupName(state)) { @@ -3608,8 +3673,8 @@ } }; - // GroupName[U] :: - // `<` RegExpIdentifierName[?U] `>` + // GroupName :: + // `<` RegExpIdentifierName `>` // Note: this updates `state.lastStringValue` property with the eaten name. pp$8.regexp_eatGroupName = function(state) { state.lastStringValue = ""; @@ -3622,9 +3687,9 @@ return false }; - // RegExpIdentifierName[U] :: - // RegExpIdentifierStart[?U] - // RegExpIdentifierName[?U] RegExpIdentifierPart[?U] + // RegExpIdentifierName :: + // RegExpIdentifierStart + // RegExpIdentifierName RegExpIdentifierPart // Note: this updates `state.lastStringValue` property with the eaten name. pp$8.regexp_eatRegExpIdentifierName = function(state) { state.lastStringValue = ""; @@ -3638,17 +3703,18 @@ return false }; - // RegExpIdentifierStart[U] :: + // RegExpIdentifierStart :: // UnicodeIDStart // `$` // `_` - // `\` RegExpUnicodeEscapeSequence[?U] + // `\` RegExpUnicodeEscapeSequence[+U] pp$8.regexp_eatRegExpIdentifierStart = function(state) { var start = state.pos; - var ch = state.current(); - state.advance(); + var forceU = this.options.ecmaVersion >= 11; + var ch = state.current(forceU); + state.advance(forceU); - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { + if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { ch = state.lastIntValue; } if (isRegExpIdentifierStart(ch)) { @@ -3663,19 +3729,20 @@ return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ } - // RegExpIdentifierPart[U] :: + // RegExpIdentifierPart :: // UnicodeIDContinue // `$` // `_` - // `\` RegExpUnicodeEscapeSequence[?U] + // `\` RegExpUnicodeEscapeSequence[+U] // // pp$8.regexp_eatRegExpIdentifierPart = function(state) { var start = state.pos; - var ch = state.current(); - state.advance(); + var forceU = this.options.ecmaVersion >= 11; + var ch = state.current(forceU); + state.advance(forceU); - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { + if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { ch = state.lastIntValue; } if (isRegExpIdentifierPart(ch)) { @@ -3745,7 +3812,7 @@ this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || - this.regexp_eatRegExpUnicodeEscapeSequence(state) || + this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || this.regexp_eatIdentityEscape(state) ) @@ -3818,13 +3885,16 @@ } // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence - pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) { + pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) { + if ( forceU === void 0 ) forceU = false; + var start = state.pos; + var switchU = forceU || state.switchU; if (state.eat(0x75 /* u */)) { if (this.regexp_eatFixedHexDigits(state, 4)) { var lead = state.lastIntValue; - if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) { + if (switchU && lead >= 0xD800 && lead <= 0xDBFF) { var leadSurrogateEnd = state.pos; if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { var trail = state.lastIntValue; @@ -3839,7 +3909,7 @@ return true } if ( - state.switchU && + switchU && state.eat(0x7B /* { */) && this.regexp_eatHexDigits(state) && state.eat(0x7D /* } */) && @@ -3847,7 +3917,7 @@ ) { return true } - if (state.switchU) { + if (switchU) { state.raise("Invalid unicode escape"); } state.pos = start; @@ -4503,6 +4573,14 @@ return this.finishOp(code === 61 ? types.eq : types.prefix, 1) }; + pp$9.readToken_question = function() { // '?' + if (this.options.ecmaVersion >= 11) { + var next = this.input.charCodeAt(this.pos + 1); + if (next === 63) { return this.finishOp(types.coalesce, 2) } + } + return this.finishOp(types.question, 1) + }; + pp$9.getTokenFromCode = function(code) { switch (code) { // The interpretation of a dot depends on whether it is followed @@ -4520,7 +4598,6 @@ case 123: ++this.pos; return this.finishToken(types.braceL) case 125: ++this.pos; return this.finishToken(types.braceR) case 58: ++this.pos; return this.finishToken(types.colon) - case 63: ++this.pos; return this.finishToken(types.question) case 96: // '`' if (this.options.ecmaVersion < 6) { break } @@ -4570,6 +4647,9 @@ case 61: case 33: // '=!' return this.readToken_eq_excl(code) + case 63: // '?' + return this.readToken_question() + case 126: // '~' return this.finishOp(types.prefix, 1) } @@ -5017,4 +5097,4 @@ Object.defineProperty(exports, '__esModule', { value: true }); -})); +}))); diff --git a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.mjs b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.mjs index f6f707076220d2..09b4b7477e74fa 100644 --- a/tools/node_modules/eslint/node_modules/acorn/dist/acorn.mjs +++ b/tools/node_modules/eslint/node_modules/acorn/dist/acorn.mjs @@ -27,8 +27,8 @@ var keywordRelationalOperator = /^in(stanceof)?$/; // are only applied when a character is found to actually have a // code point above 128. // Generated by `bin/generate-identifier-regex.js`. -var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\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\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u1cf3\u1cf5\u1cf6\u1cfa\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-\ua7bf\ua7c2-\ua7c6\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-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; -var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\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-\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\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"; +var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\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-\u08c7\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\u0d04-\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\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u1cf3\u1cf5\u1cf6\u1cfa\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-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\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-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; +var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\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\u0b55-\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\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\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\u1abf\u1ac0\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\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\ua82c\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"; var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); @@ -42,10 +42,10 @@ nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; // generated by bin/generate-identifier-regex.js // eslint-disable-next-line comma-spacing -var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,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,155,22,13,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,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,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,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,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,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,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]; +var 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,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,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,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,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,190,0,80,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,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,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,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,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,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938]; // eslint-disable-next-line comma-spacing -var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,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,232,6,3,6,4,0,29,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,1014,0,2,54,8,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,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239]; +var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,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,2,11,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,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,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,1014,0,2,54,8,3,82,0,12,1,19628,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,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239]; // This has a complexity linear to the value of the code. The // assumption is that looking up astral identifier characters is @@ -198,6 +198,7 @@ var types = { star: binop("*", 10), slash: binop("/", 10), starstar: new TokenType("**", {beforeExpr: true}), + coalesce: binop("??", 1), // Keyword token types. _break: kw("break"), @@ -594,7 +595,14 @@ pp.strictDirective = function(start) { start += skipWhiteSpace.exec(this.input)[0].length; var match = literal.exec(this.input.slice(start)); if (!match) { return false } - if ((match[1] || match[2]) === "use strict") { return true } + if ((match[1] || match[2]) === "use strict") { + skipWhiteSpace.lastIndex = start + match[0].length; + var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length; + var next = this.input.charAt(end); + return next === ";" || next === "}" || + (lineBreak.test(spaceAfter[0]) && + !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=")) + } start += match[0].length; // Skip semicolon, if any. @@ -844,7 +852,7 @@ pp$1.parseStatement = function(context, topLevel, exports) { skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - if (nextCh === 40) // '(' + if (nextCh === 40 || nextCh === 46) // '(' or '.' { return this.parseExpressionStatement(node, this.parseExpression()) } } @@ -1144,17 +1152,19 @@ pp$1.parseExpressionStatement = function(node, expr) { // strict"` declarations when `allowStrict` is true (used for // function bodies). -pp$1.parseBlock = function(createNewLexicalScope, node) { +pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) { if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; if ( node === void 0 ) node = this.startNode(); node.body = []; this.expect(types.braceL); if (createNewLexicalScope) { this.enterScope(0); } - while (!this.eat(types.braceR)) { + while (this.type !== types.braceR) { var stmt = this.parseStatement(null); node.body.push(stmt); } + if (exitStrict) { this.strict = false; } + this.next(); if (createNewLexicalScope) { this.exitScope(); } return this.finishNode(node, "BlockStatement") }; @@ -1305,7 +1315,7 @@ pp$1.parseClass = function(node, isStatement) { var hadConstructor = false; classBody.body = []; this.expect(types.braceL); - while (!this.eat(types.braceR)) { + while (this.type !== types.braceR) { var element = this.parseClassElement(node.superClass !== null); if (element) { classBody.body.push(element); @@ -1315,8 +1325,9 @@ pp$1.parseClass = function(node, isStatement) { } } } - node.body = this.finishNode(classBody, "ClassBody"); this.strict = oldStrict; + this.next(); + node.body = this.finishNode(classBody, "ClassBody"); return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") }; @@ -1404,6 +1415,14 @@ pp$1.parseExport = function(node, exports) { this.next(); // export * from '...' if (this.eat(types.star)) { + if (this.options.ecmaVersion >= 11) { + if (this.eatContextual("as")) { + node.exported = this.parseIdent(true); + this.checkExport(exports, node.exported.name, this.lastTokStart); + } else { + node.exported = null; + } + } this.expectContextual("from"); if (this.type !== types.string) { this.unexpected(); } node.source = this.parseExprAtom(); @@ -2020,11 +2039,20 @@ pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) { if (prec != null && (!noIn || this.type !== types._in)) { if (prec > minPrec) { var logical = this.type === types.logicalOR || this.type === types.logicalAND; + var coalesce = this.type === types.coalesce; + if (coalesce) { + // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions. + // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error. + prec = types.logicalAND.binop; + } var op = this.value; this.next(); var startPos = this.start, startLoc = this.startLoc; var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn); - var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical); + var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce); + if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) { + this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"); + } return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) } } @@ -2096,7 +2124,8 @@ pp$3.parseExprSubscripts = function(refDestructuringErrors) { pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && - this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; + this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && + this.potentialArrowAt === base.start; while (true) { var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow); if (element === base || element.type === "ArrowFunctionExpression") { return element } @@ -2260,10 +2289,18 @@ pp$3.parseExprAtom = function(refDestructuringErrors) { pp$3.parseExprImport = function() { var node = this.startNode(); - this.next(); // skip `import` + + // Consume `import` as an identifier for `import.meta`. + // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`. + if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); } + var meta = this.parseIdent(true); + switch (this.type) { case types.parenL: return this.parseDynamicImport(node) + case types.dot: + node.meta = meta; + return this.parseImportMeta(node) default: this.unexpected(); } @@ -2288,6 +2325,22 @@ pp$3.parseDynamicImport = function(node) { return this.finishNode(node, "ImportExpression") }; +pp$3.parseImportMeta = function(node) { + this.next(); // skip `.` + + var containsEsc = this.containsEsc; + node.property = this.parseIdent(true); + + if (node.property.name !== "meta") + { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); } + if (containsEsc) + { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); } + if (this.options.sourceType !== "module") + { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); } + + return this.finishNode(node, "MetaProperty") +}; + pp$3.parseLiteral = function(value) { var node = this.startNode(); node.value = value; @@ -2390,10 +2443,12 @@ pp$3.parseNew = function() { node.meta = meta; var containsEsc = this.containsEsc; node.property = this.parseIdent(true); - if (node.property.name !== "target" || containsEsc) - { this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); } + if (node.property.name !== "target") + { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); } + if (containsEsc) + { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); } if (!this.inNonArrowFunction()) - { this.raiseRecoverable(node.start, "new.target can only be used in functions"); } + { this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); } return this.finishNode(node, "MetaProperty") } var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import; @@ -2677,16 +2732,14 @@ pp$3.parseFunctionBody = function(node, isArrowFunction, isMethod) { // Add the params to varDeclaredNames to ensure that an error is thrown // if a let/const declaration in the function clashes with one of the params. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); - node.body = this.parseBlock(false); + // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' + if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); } + node.body = this.parseBlock(false, undefined, useStrict && !oldStrict); node.expression = false; this.adaptDirectivePrologue(node.body.body); this.labels = oldLabels; } this.exitScope(); - - // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); } - this.strict = oldStrict; }; pp$3.isSimpleParamList = function(params) { @@ -3205,49 +3258,61 @@ RegExpValidationState.prototype.raise = function raise (message) { // If u flag is given, this returns the code point at the index (it combines a surrogate pair). // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). -RegExpValidationState.prototype.at = function at (i) { +RegExpValidationState.prototype.at = function at (i, forceU) { + if ( forceU === void 0 ) forceU = false; + var s = this.source; var l = s.length; if (i >= l) { return -1 } var c = s.charCodeAt(i); - if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { + if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { return c } var next = s.charCodeAt(i + 1); return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c }; -RegExpValidationState.prototype.nextIndex = function nextIndex (i) { +RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) { + if ( forceU === void 0 ) forceU = false; + var s = this.source; var l = s.length; if (i >= l) { return l } var c = s.charCodeAt(i), next; - if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || + if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { return i + 1 } return i + 2 }; -RegExpValidationState.prototype.current = function current () { - return this.at(this.pos) +RegExpValidationState.prototype.current = function current (forceU) { + if ( forceU === void 0 ) forceU = false; + + return this.at(this.pos, forceU) }; -RegExpValidationState.prototype.lookahead = function lookahead () { - return this.at(this.nextIndex(this.pos)) +RegExpValidationState.prototype.lookahead = function lookahead (forceU) { + if ( forceU === void 0 ) forceU = false; + + return this.at(this.nextIndex(this.pos, forceU), forceU) }; -RegExpValidationState.prototype.advance = function advance () { - this.pos = this.nextIndex(this.pos); +RegExpValidationState.prototype.advance = function advance (forceU) { + if ( forceU === void 0 ) forceU = false; + + this.pos = this.nextIndex(this.pos, forceU); }; -RegExpValidationState.prototype.eat = function eat (ch) { - if (this.current() === ch) { - this.advance(); +RegExpValidationState.prototype.eat = function eat (ch, forceU) { + if ( forceU === void 0 ) forceU = false; + + if (this.current(forceU) === ch) { + this.advance(forceU); return true } return false @@ -3586,9 +3651,9 @@ pp$8.regexp_eatExtendedPatternCharacter = function(state) { return false }; -// GroupSpecifier[U] :: +// GroupSpecifier :: // [empty] -// `?` GroupName[?U] +// `?` GroupName pp$8.regexp_groupSpecifier = function(state) { if (state.eat(0x3F /* ? */)) { if (this.regexp_eatGroupName(state)) { @@ -3602,8 +3667,8 @@ pp$8.regexp_groupSpecifier = function(state) { } }; -// GroupName[U] :: -// `<` RegExpIdentifierName[?U] `>` +// GroupName :: +// `<` RegExpIdentifierName `>` // Note: this updates `state.lastStringValue` property with the eaten name. pp$8.regexp_eatGroupName = function(state) { state.lastStringValue = ""; @@ -3616,9 +3681,9 @@ pp$8.regexp_eatGroupName = function(state) { return false }; -// RegExpIdentifierName[U] :: -// RegExpIdentifierStart[?U] -// RegExpIdentifierName[?U] RegExpIdentifierPart[?U] +// RegExpIdentifierName :: +// RegExpIdentifierStart +// RegExpIdentifierName RegExpIdentifierPart // Note: this updates `state.lastStringValue` property with the eaten name. pp$8.regexp_eatRegExpIdentifierName = function(state) { state.lastStringValue = ""; @@ -3632,17 +3697,18 @@ pp$8.regexp_eatRegExpIdentifierName = function(state) { return false }; -// RegExpIdentifierStart[U] :: +// RegExpIdentifierStart :: // UnicodeIDStart // `$` // `_` -// `\` RegExpUnicodeEscapeSequence[?U] +// `\` RegExpUnicodeEscapeSequence[+U] pp$8.regexp_eatRegExpIdentifierStart = function(state) { var start = state.pos; - var ch = state.current(); - state.advance(); + var forceU = this.options.ecmaVersion >= 11; + var ch = state.current(forceU); + state.advance(forceU); - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { + if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { ch = state.lastIntValue; } if (isRegExpIdentifierStart(ch)) { @@ -3657,19 +3723,20 @@ function isRegExpIdentifierStart(ch) { return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ } -// RegExpIdentifierPart[U] :: +// RegExpIdentifierPart :: // UnicodeIDContinue // `$` // `_` -// `\` RegExpUnicodeEscapeSequence[?U] +// `\` RegExpUnicodeEscapeSequence[+U] // // pp$8.regexp_eatRegExpIdentifierPart = function(state) { var start = state.pos; - var ch = state.current(); - state.advance(); + var forceU = this.options.ecmaVersion >= 11; + var ch = state.current(forceU); + state.advance(forceU); - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { + if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { ch = state.lastIntValue; } if (isRegExpIdentifierPart(ch)) { @@ -3739,7 +3806,7 @@ pp$8.regexp_eatCharacterEscape = function(state) { this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || - this.regexp_eatRegExpUnicodeEscapeSequence(state) || + this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || this.regexp_eatIdentityEscape(state) ) @@ -3812,13 +3879,16 @@ function isControlLetter(ch) { } // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence -pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) { +pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) { + if ( forceU === void 0 ) forceU = false; + var start = state.pos; + var switchU = forceU || state.switchU; if (state.eat(0x75 /* u */)) { if (this.regexp_eatFixedHexDigits(state, 4)) { var lead = state.lastIntValue; - if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) { + if (switchU && lead >= 0xD800 && lead <= 0xDBFF) { var leadSurrogateEnd = state.pos; if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { var trail = state.lastIntValue; @@ -3833,7 +3903,7 @@ pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) { return true } if ( - state.switchU && + switchU && state.eat(0x7B /* { */) && this.regexp_eatHexDigits(state) && state.eat(0x7D /* } */) && @@ -3841,7 +3911,7 @@ pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) { ) { return true } - if (state.switchU) { + if (switchU) { state.raise("Invalid unicode escape"); } state.pos = start; @@ -4497,6 +4567,14 @@ pp$9.readToken_eq_excl = function(code) { // '=!' return this.finishOp(code === 61 ? types.eq : types.prefix, 1) }; +pp$9.readToken_question = function() { // '?' + if (this.options.ecmaVersion >= 11) { + var next = this.input.charCodeAt(this.pos + 1); + if (next === 63) { return this.finishOp(types.coalesce, 2) } + } + return this.finishOp(types.question, 1) +}; + pp$9.getTokenFromCode = function(code) { switch (code) { // The interpretation of a dot depends on whether it is followed @@ -4514,7 +4592,6 @@ pp$9.getTokenFromCode = function(code) { case 123: ++this.pos; return this.finishToken(types.braceL) case 125: ++this.pos; return this.finishToken(types.braceR) case 58: ++this.pos; return this.finishToken(types.colon) - case 63: ++this.pos; return this.finishToken(types.question) case 96: // '`' if (this.options.ecmaVersion < 6) { break } @@ -4564,6 +4641,9 @@ pp$9.getTokenFromCode = function(code) { case 61: case 33: // '=!' return this.readToken_eq_excl(code) + case 63: // '?' + return this.readToken_question() + case 126: // '~' return this.finishOp(types.prefix, 1) } diff --git a/tools/node_modules/eslint/node_modules/acorn/package.json b/tools/node_modules/eslint/node_modules/acorn/package.json index 39139962fa8331..960e7b1fdbf09d 100644 --- a/tools/node_modules/eslint/node_modules/acorn/package.json +++ b/tools/node_modules/eslint/node_modules/acorn/package.json @@ -40,5 +40,5 @@ "prepare": "cd ..; npm run build:main && npm run build:bin" }, "types": "dist/acorn.d.ts", - "version": "7.1.1" + "version": "7.2.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js b/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js index 6825a8bc5f05f9..7972455008e917 100644 --- a/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js +++ b/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js @@ -2,9 +2,10 @@ const path = require('path'); const which = require('which'); -const pathKey = require('path-key')(); +const getPathKey = require('path-key'); function resolveCommandAttempt(parsed, withoutPathExt) { + const env = parsed.options.env || process.env; const cwd = process.cwd(); const hasCustomCwd = parsed.options.cwd != null; // Worker threads do not have process.chdir() @@ -24,7 +25,7 @@ function resolveCommandAttempt(parsed, withoutPathExt) { try { resolved = which.sync(parsed.command, { - path: (parsed.options.env || process.env)[pathKey], + path: env[getPathKey({ env })], pathExt: withoutPathExt ? path.delimiter : undefined, }); } catch (e) { diff --git a/tools/node_modules/eslint/node_modules/cross-spawn/package.json b/tools/node_modules/eslint/node_modules/cross-spawn/package.json index cc4588cec1e990..5ed16e25e312a4 100644 --- a/tools/node_modules/eslint/node_modules/cross-spawn/package.json +++ b/tools/node_modules/eslint/node_modules/cross-spawn/package.json @@ -77,5 +77,5 @@ "release": "standard-version", "test": "jest --env node --coverage" }, - "version": "7.0.2" + "version": "7.0.3" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js b/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js index 29f853293361d0..63d1935b3a957f 100644 --- a/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js +++ b/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js @@ -593,15 +593,26 @@ class Referencer extends esrecurse.Visitor { this.visitChildren(node); } + // TODO: ExportDeclaration doesn't exist. for bc? ExportDeclaration(node) { this.visitExportDeclaration(node); } + ExportAllDeclaration(node) { + this.visitExportDeclaration(node); + } + + ExportDefaultDeclaration(node) { + this.visitExportDeclaration(node); + } + ExportNamedDeclaration(node) { this.visitExportDeclaration(node); } ExportSpecifier(node) { + + // TODO: `node.id` doesn't exist. for bc? const local = (node.id || node.local); this.visit(local); diff --git a/tools/node_modules/eslint/node_modules/eslint-scope/package.json b/tools/node_modules/eslint/node_modules/eslint-scope/package.json index 1c7fa4450b0c9c..b39dbae1cc391c 100644 --- a/tools/node_modules/eslint/node_modules/eslint-scope/package.json +++ b/tools/node_modules/eslint/node_modules/eslint-scope/package.json @@ -16,7 +16,8 @@ "eslint-config-eslint": "^5.0.1", "eslint-plugin-node": "^9.1.0", "eslint-release": "^1.0.0", - "espree": "^6.0.0", + "eslint-visitor-keys": "^1.2.0", + "espree": "^7.1.0", "istanbul": "^0.4.5", "mocha": "^6.1.4", "npm-license": "^0.3.3", @@ -48,5 +49,5 @@ "publish-release": "eslint-publish-release", "test": "node Makefile.js test" }, - "version": "5.0.0" + "version": "5.1.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json index d31b7b29439a13..e77fb9e4253be6 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json @@ -66,6 +66,7 @@ ], "EmptyStatement": [], "ExportAllDeclaration": [ + "exported", "source" ], "ExportDefaultDeclaration": [ diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json index 68eec940691e0b..12384fc9a4cf8e 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json @@ -44,5 +44,5 @@ "publish-release": "eslint-publish-release", "test": "nyc mocha tests/lib" }, - "version": "1.1.0" + "version": "1.2.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/espree/package.json b/tools/node_modules/eslint/node_modules/espree/package.json index 5f7f545e8785a3..89b04e6f28707c 100644 --- a/tools/node_modules/eslint/node_modules/espree/package.json +++ b/tools/node_modules/eslint/node_modules/espree/package.json @@ -8,9 +8,9 @@ }, "bundleDependencies": false, "dependencies": { - "acorn": "^7.1.1", + "acorn": "^7.2.0", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^1.2.0" }, "deprecated": false, "description": "An Esprima-compatible JavaScript parser built on Acorn", @@ -57,6 +57,7 @@ }, "scripts": { "browserify": "node Makefile.js browserify", + "fixlint": "node Makefile.js lint --fix", "generate-alpharelease": "eslint-generate-prerelease alpha", "generate-betarelease": "eslint-generate-prerelease beta", "generate-rcrelease": "eslint-generate-prerelease rc", @@ -67,5 +68,5 @@ "sync-docs": "node Makefile.js docs", "test": "npm run-script lint && node Makefile.js test" }, - "version": "7.0.0" + "version": "7.1.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/js-yaml/README.md b/tools/node_modules/eslint/node_modules/js-yaml/README.md index 03a9e5ae7f8266..246e56355146df 100644 --- a/tools/node_modules/eslint/node_modules/js-yaml/README.md +++ b/tools/node_modules/eslint/node_modules/js-yaml/README.md @@ -80,12 +80,12 @@ your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and info. ``` javascript -yaml = require('js-yaml'); -fs = require('fs'); +const yaml = require('js-yaml'); +const fs = require('fs'); // Get document, or throw exception on error try { - var doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8')); + const doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8')); console.log(doc); } catch (e) { console.log(e); @@ -95,9 +95,9 @@ try { ### safeLoad (string [ , options ]) -**Recommended loading way.** Parses `string` as single YAML document. Returns a JavaScript -object or throws `YAMLException` on error. By default, does not support regexps, -functions and undefined. This method is safe for untrusted data. +**Recommended loading way.** Parses `string` as single YAML document. Returns either a +plain object, a string or `undefined`, or throws `YAMLException` on error. By default, does +not support regexps, functions and undefined. This method is safe for untrusted data. options: @@ -135,7 +135,7 @@ The core schema also has no such restrictions. It allows binary notation for int must additionally validate object structure to avoid injections: ``` javascript -var untrusted_code = '"toString": ! "function (){very_evil_thing();}"'; +const untrusted_code = '"toString": ! "function (){very_evil_thing();}"'; // I'm just converting that string, what could possibly go wrong? require('js-yaml').load(untrusted_code) + '' @@ -148,7 +148,7 @@ Same as `safeLoad()`, but understands multi-document sources. Applies `iterator` to each document if specified, or returns array of documents. ``` javascript -var yaml = require('js-yaml'); +const yaml = require('js-yaml'); yaml.safeLoadAll(data, function (doc) { console.log(doc); @@ -291,24 +291,9 @@ So, the following YAML document cannot be loaded. ``` -Breaking changes in 2.x.x -> 3.x.x ----------------------------------- +js-yaml for enterprise +---------------------- -If you have not used __custom__ tags or loader classes and not loaded yaml -files via `require()`, no changes are needed. Just upgrade the library. +Available as part of the Tidelift Subscription -Otherwise, you should: - -1. Replace all occurrences of `require('xxxx.yml')` by `fs.readFileSync()` + - `yaml.safeLoad()`. -2. rewrite your custom tags constructors and custom loader - classes, to conform the new API. See - [examples](https://github.com/nodeca/js-yaml/tree/master/examples) and - [wiki](https://github.com/nodeca/js-yaml/wiki) for details. - - -License -------- - -View the [LICENSE](https://github.com/nodeca/js-yaml/blob/master/LICENSE) file -(MIT). +The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.js b/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.js index fad044a48a8e4f..d7287d47c9ce48 100644 --- a/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.js +++ b/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.js @@ -1,4 +1,4 @@ -/* js-yaml 3.13.1 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i */ var CHAR_QUESTION = 0x3F; /* ? */ var CHAR_COMMERCIAL_AT = 0x40; /* @ */ @@ -291,8 +293,23 @@ function isPrintable(c) { || (0x10000 <= c && c <= 0x10FFFF); } +// [34] ns-char ::= nb-char - s-white +// [27] nb-char ::= c-printable - b-char - c-byte-order-mark +// [26] b-char ::= b-line-feed | b-carriage-return +// [24] b-line-feed ::= #xA /* LF */ +// [25] b-carriage-return ::= #xD /* CR */ +// [3] c-byte-order-mark ::= #xFEFF +function isNsChar(c) { + return isPrintable(c) && !isWhitespace(c) + // byte-order-mark + && c !== 0xFEFF + // b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; +} + // Simplified test for values allowed after the first character in plain style. -function isPlainSafe(c) { +function isPlainSafe(c, prev) { // Uses a subset of nb-char - c-flow-indicator - ":" - "#" // where nb-char ::= c-printable - b-char - c-byte-order-mark. return isPrintable(c) && c !== 0xFEFF @@ -303,8 +320,9 @@ function isPlainSafe(c) { && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET // - ":" - "#" + // /* An ns-char preceding */ "#" && c !== CHAR_COLON - && c !== CHAR_SHARP; + && ((c !== CHAR_SHARP) || (prev && isNsChar(prev))); } // Simplified test for values allowed as the first character in plain style. @@ -323,12 +341,13 @@ function isPlainSafeFirst(c) { && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET - // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"” + // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE + && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE @@ -359,7 +378,7 @@ var STYLE_PLAIN = 1, // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { var i; - var char; + var char, prev_char; var hasLineBreak = false; var hasFoldableLine = false; // only checked if shouldTrackWidth var shouldTrackWidth = lineWidth !== -1; @@ -375,7 +394,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te if (!isPrintable(char)) { return STYLE_DOUBLE; } - plain = plain && isPlainSafe(char); + prev_char = i > 0 ? string.charCodeAt(i - 1) : null; + plain = plain && isPlainSafe(char, prev_char); } } else { // Case: block styles permitted. @@ -394,7 +414,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te } else if (!isPrintable(char)) { return STYLE_DOUBLE; } - plain = plain && isPlainSafe(char); + prev_char = i > 0 ? string.charCodeAt(i - 1) : null; + plain = plain && isPlainSafe(char, prev_char); } // in case the end is missing a \n hasFoldableLine = hasFoldableLine || (shouldTrackWidth && @@ -651,10 +672,12 @@ function writeFlowMapping(state, level, object) { pairBuffer; for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = state.condenseFlow ? '"' : ''; + pairBuffer = ''; if (index !== 0) pairBuffer += ', '; + if (state.condenseFlow) pairBuffer += '"'; + objectKey = objectKeyList[index]; objectValue = object[objectKey]; @@ -2370,13 +2393,19 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact if (state.tag !== null && state.tag !== '!') { if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { type = state.implicitTypes[typeIndex]; - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only assigned to plain scalars. So, it isn't - // needed to check for 'kind' conformity. - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched state.result = type.construct(state.result); state.tag = type.tag; @@ -2540,6 +2569,13 @@ function loadDocuments(input, options) { var state = new State(input, options); + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + // Use 0 as string terminator. That significantly simplifies bounds check. state.input += '\0'; @@ -2557,13 +2593,18 @@ function loadDocuments(input, options) { function loadAll(input, iterator, options) { - var documents = loadDocuments(input, options), index, length; + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); if (typeof iterator !== 'function') { return documents; } - for (index = 0, length = documents.length; index < length; index += 1) { + for (var index = 0, length = documents.length; index < length; index += 1) { iterator(documents[index]); } } @@ -2582,12 +2623,13 @@ function load(input, options) { } -function safeLoadAll(input, output, options) { - if (typeof output === 'function') { - loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); - } else { - return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +function safeLoadAll(input, iterator, options) { + if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') { + options = iterator; + iterator = null; } + + return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); } @@ -3462,7 +3504,8 @@ try { var _require = require; esprima = _require('esprima'); } catch (_) { - /*global window */ + /* eslint-disable no-redeclare */ + /* global window */ if (typeof window !== 'undefined') esprima = window.esprima; } diff --git a/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.min.js b/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.min.js index 0623500e6dc5b8..f72401eaef8313 100644 --- a/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.min.js +++ b/tools/node_modules/eslint/node_modules/js-yaml/dist/js-yaml.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).jsyaml=e()}}(function(){return function o(a,s,c){function u(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var r=s[t]={exports:{}};a[t][0].call(r.exports,function(e){return u(a[t][1][e]||e)},r,r.exports,o,a,s,c)}return s[t].exports}for(var l="function"==typeof require&&require,e=0;e=i.flowLevel;switch(H(r,n,i.indent,t,function(e){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n"+V(r,i.indent)+Z(L(function(t,n){var e,i,r=/(\n+)([^\n]*)/g,o=function(){var e=t.indexOf("\n");return e=-1!==e?e:t.length,r.lastIndex=e,z(t.slice(0,e),n)}(),a="\n"===t[0]||" "===t[0];for(;i=r.exec(t);){var s=i[1],c=i[2];e=" "===c[0],o+=s+(a||e||""===c?"":"\n")+z(c,n),a=e}return o}(r,t),e));case $:return'"'+function(e){for(var t,n,i,r="",o=0;ot&&o tag resolver accepts not "'+c+'" style');i=s.represent[c](t,c)}e.dump=i}return!0}return!1}function Q(e,t,n,i,r,o){e.tag=null,e.dump=n,J(e,n,!1)||J(e,n,!0);var a=p.call(e.dump);i&&(i=e.flowLevel<0||e.flowLevel>t);var s,c,u="[object Object]"===a||"[object Array]"===a;if(u&&(c=-1!==(s=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||c||2!==e.indent&&0 "+e.dump)}return!0}function X(e,t){var n,i,r=[],o=[];for(function e(t,n,i){var r,o,a;if(null!==t&&"object"==typeof t)if(-1!==(o=n.indexOf(t)))-1===i.indexOf(o)&&i.push(o);else if(n.push(t),Array.isArray(t))for(o=0,a=t.length;ot)&&0!==i)N(e,"bad indentation of a sequence entry");else if(e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt)&&($(e,t,b,!0,r)&&(m?d=e.result:h=e.result),m||(U(e,l,p,f,d,h,o,a),f=d=h=null),Y(e,!0,-1),s=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==s)N(e,"bad indentation of a mapping entry");else if(e.lineIndentl&&(l=e.lineIndent),j(o))p++;else{if(e.lineIndent>10),56320+(c-65536&1023)),e.position++}else N(e,"unknown escape sequence");n=i=e.position}else j(s)?(L(e,n,i,!0),B(e,Y(e,!1,t)),n=i=e.position):e.position===e.lineStart&&R(e)?N(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}N(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?m=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!I(i)&&!O(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&N(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||N(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Y(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,s,c,u,l,p=e.kind,f=e.result;if(I(l=e.input.charCodeAt(e.position))||O(l)||35===l||38===l||42===l||33===l||124===l||62===l||39===l||34===l||37===l||64===l||96===l)return!1;if((63===l||45===l)&&(I(i=e.input.charCodeAt(e.position+1))||n&&O(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==l;){if(58===l){if(I(i=e.input.charCodeAt(e.position+1))||n&&O(i))break}else if(35===l){if(I(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&R(e)||n&&O(l))break;if(j(l)){if(s=e.line,c=e.lineStart,u=e.lineIndent,Y(e,!1,-1),e.lineIndent>=t){a=!0,l=e.input.charCodeAt(e.position);continue}e.position=o,e.line=s,e.lineStart=c,e.lineIndent=u;break}}a&&(L(e,r,o,!1),B(e,e.line-s),r=o=e.position,a=!1),S(l)||(o=e.position+1),l=e.input.charCodeAt(++e.position)}return L(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,p,x===n)&&(m=!0,null===e.tag&&(e.tag="?")):(m=!0,null===e.tag&&null===e.anchor||N(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===d&&(m=s&&P(e,f))),null!==e.tag&&"!"!==e.tag)if("?"===e.tag){for(c=0,u=e.implicitTypes.length;c tag; it should be "'+l.kind+'", not "'+e.kind+'"'),l.resolve(e.result)?(e.result=l.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):N(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):N(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||m}function H(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(r=e.input.charCodeAt(e.position))&&(Y(e,!0,-1),r=e.input.charCodeAt(e.position),!(0t/2-1){n=" ... ",i+=5;break}for(r="",o=this.position;ot/2-1){r=" ... ",o-=5;break}return a=this.buffer.slice(i,o),s.repeat(" ",e)+n+a+r+"\n"+s.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},t.exports=i},{"./common":2}],7:[function(e,t,n){"use strict";var i=e("./common"),r=e("./exception"),o=e("./type");function a(e,t,i){var r=[];return e.include.forEach(function(e){i=a(e,t,i)}),e[t].forEach(function(n){i.forEach(function(e,t){e.tag===n.tag&&e.kind===n.kind&&r.push(t)}),i.push(n)}),i.filter(function(e,t){return-1===r.indexOf(t)})}function s(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new r("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=a(this,"implicit",[]),this.compiledExplicit=a(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{}};function i(e){n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e>16&255),s.push(a>>8&255),s.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0==(n=r%4*6)?(s.push(a>>16&255),s.push(a>>8&255),s.push(255&a)):18==n?(s.push(a>>10&255),s.push(a>>2&255)):12==n&&s.push(a>>4&255),c?c.from?c.from(s):new c(s):s},predicate:function(e){return c&&c.isBuffer(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=u;for(t=0;t>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0==(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2==n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1==n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}})},{"../type":13}],15:[function(e,t,n){"use strict";var i=e("../type");t.exports=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},{"../type":13}],16:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type"),o=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var a=/^[-+]?[0-9]+e/;t.exports=new r("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!o.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n,i,r;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,r=[],0<="+-".indexOf(t[0])&&(t=t.slice(1)),".inf"===t?1==n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:0<=t.indexOf(":")?(t.split(":").forEach(function(e){r.unshift(parseFloat(e,10))}),t=0,i=1,r.forEach(function(e){t+=e*i,i*=60}),n*t):n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||i.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(e))return"-0.0";return n=e.toString(10),a.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"})},{"../common":2,"../type":13}],17:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type");t.exports=new r("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i,r,o=e.length,a=0,s=!1;if(!o)return!1;if("-"!==(t=e[a])&&"+"!==t||(t=e[++a]),"0"===t){if(a+1===o)return!0;if("b"===(t=e[++a])){for(a++;a=i.flowLevel;switch(V(r,n,i.indent,t,function(e){return function(e,t){for(var n=0,i=e.implicitTypes.length;n"+z(r,i.indent)+J(U(function(t,n){var e,i,r=/(\n+)([^\n]*)/g,o=function(){var e=-1!==(e=t.indexOf("\n"))?e:t.length;return r.lastIndex=e,Q(t.slice(0,e),n)}(),a="\n"===t[0]||" "===t[0];for(;i=r.exec(t);){var s=i[1],c=i[2];e=" "===c[0],o+=s+(a||e||""===c?"":"\n")+Q(c,n),a=e}return o}(r,t),e));case G:return'"'+function(e){for(var t,n,i,r="",o=0;ot&&o tag resolver accepts not "'+o+'" style');i=r.represent[o](t,o)}e.dump=i}return 1}}function ee(e,t,n,i,r,o){e.tag=null,e.dump=n,X(e,n,!1)||X(e,n,!0);var a=p.call(e.dump);i=i&&(e.flowLevel<0||e.flowLevel>t);var s,c,u="[object Object]"===a||"[object Array]"===a;if(u&&(c=-1!==(s=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||c||2!==e.indent&&0 "+e.dump)}return 1}function te(e,t){var n,i,r=[],o=[];for(!function e(t,n,i){var r,o,a;if(null!==t&&"object"==typeof t)if(-1!==(o=n.indexOf(t)))-1===i.indexOf(o)&&i.push(o);else if(n.push(t),Array.isArray(t))for(o=0,a=t.length;o>10),56320+(s-65536&1023)),e.position++}else N(e,"unknown escape sequence");n=i=e.position}else O(p)?(L(e,n,i,!0),B(e,Y(e,!1,t)),n=i=e.position):e.position===e.lineStart&&R(e)?N(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}N(e,"unexpected end of the stream within a double quoted scalar")}}function W(e,t){var n,i,r=e.tag,o=e.anchor,a=[],s=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&45===i&&F(e.input.charCodeAt(e.position+1));)if(s=!0,e.position++,Y(e,!0,-1)&&e.lineIndent<=t)a.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,K(e,t,A,!1,!0),a.push(e.result),Y(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)N(e,"bad indentation of a sequence entry");else if(e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt)&&(K(e,t,b,!0,r)&&(m?d=e.result:h=e.result),m||(U(e,l,p,f,d,h,o,a),f=d=h=null),Y(e,!0,-1),s=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==s)N(e,"bad indentation of a mapping entry");else if(e.lineIndentu&&(u=e.lineIndent),O(f))l++;else{if(e.lineIndent=t){a=!0,f=e.input.charCodeAt(e.position);continue}e.position=o,e.line=s,e.lineStart=c,e.lineIndent=u;break}}a&&(L(e,r,o,!1),B(e,e.line-s),r=o=e.position,a=!1),E(f)||(o=e.position+1),f=e.input.charCodeAt(++e.position)}if(L(e,r,o,!1),e.result)return 1;e.kind=l,e.result=p}}(e,p,x===n)&&(m=!0,null===e.tag&&(e.tag="?")):(m=!0,null===e.tag&&null===e.anchor||N(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===d&&(m=s&&W(e,f))),null!==e.tag&&"!"!==e.tag)if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&N(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),c=0,u=e.implicitTypes.length;c tag; it should be "'+l.kind+'", not "'+e.kind+'"'),l.resolve(e.result)?(e.result=l.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):N(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):N(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||m}function $(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new h(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,N(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.positiont/2-1){n=" ... ",i+=5;break}for(r="",o=this.position;ot/2-1){r=" ... ",o-=5;break}return a=this.buffer.slice(i,o),s.repeat(" ",e)+n+a+r+"\n"+s.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},t.exports=i},{"./common":2}],7:[function(e,t,n){"use strict";var r=e("./common"),o=e("./exception"),a=e("./type");function s(e,t,i){var r=[];return e.include.forEach(function(e){i=s(e,t,i)}),e[t].forEach(function(n){i.forEach(function(e,t){e.tag===n.tag&&e.kind===n.kind&&r.push(t)}),i.push(n)}),i.filter(function(e,t){return-1===r.indexOf(t)})}function c(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=s(this,"implicit",[]),this.compiledExplicit=s(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{}};function i(e){n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e>16&255),a.push(o>>8&255),a.push(255&o)),o=o<<6|r.indexOf(n.charAt(s));return 0==(t=i%4*6)?(a.push(o>>16&255),a.push(o>>8&255),a.push(255&o)):18==t?(a.push(o>>10&255),a.push(o>>2&255)):12==t&&a.push(o>>4&255),c?c.from?c.from(a):new c(a):a},predicate:function(e){return c&&c.isBuffer(e)},represent:function(e){for(var t,n="",i=0,r=e.length,o=u,a=0;a>18&63],n+=o[i>>12&63],n+=o[i>>6&63],n+=o[63&i]),i=(i<<8)+e[a];return 0==(t=r%3)?(n+=o[i>>18&63],n+=o[i>>12&63],n+=o[i>>6&63],n+=o[63&i]):2==t?(n+=o[i>>10&63],n+=o[i>>4&63],n+=o[i<<2&63],n+=o[64]):1==t&&(n+=o[i>>2&63],n+=o[i<<4&63],n+=o[64],n+=o[64]),n}})},{"../type":13}],15:[function(e,t,n){"use strict";var i=e("../type");t.exports=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},{"../type":13}],16:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type"),o=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var a=/^[-+]?[0-9]+e/;t.exports=new r("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!o.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n=e.replace(/_/g,"").toLowerCase(),i="-"===n[0]?-1:1,r=[];return 0<="+-".indexOf(n[0])&&(n=n.slice(1)),".inf"===n?1==i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===n?NaN:0<=n.indexOf(":")?(n.split(":").forEach(function(e){r.unshift(parseFloat(e,10))}),n=0,t=1,r.forEach(function(e){n+=e*t,t*=60}),i*n):i*parseFloat(n,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||i.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(e))return"-0.0";return n=e.toString(10),a.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"})},{"../common":2,"../type":13}],17:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type");t.exports=new r("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i,r,o=e.length,a=0,s=!1;if(!o)return!1;if("-"!==(t=e[a])&&"+"!==t||(t=e[++a]),"0"===t){if(a+1===o)return!0;if("b"===(t=e[++a])){for(a++;a */ var CHAR_QUESTION = 0x3F; /* ? */ var CHAR_COMMERCIAL_AT = 0x40; /* @ */ @@ -188,8 +190,23 @@ function isPrintable(c) { || (0x10000 <= c && c <= 0x10FFFF); } +// [34] ns-char ::= nb-char - s-white +// [27] nb-char ::= c-printable - b-char - c-byte-order-mark +// [26] b-char ::= b-line-feed | b-carriage-return +// [24] b-line-feed ::= #xA /* LF */ +// [25] b-carriage-return ::= #xD /* CR */ +// [3] c-byte-order-mark ::= #xFEFF +function isNsChar(c) { + return isPrintable(c) && !isWhitespace(c) + // byte-order-mark + && c !== 0xFEFF + // b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; +} + // Simplified test for values allowed after the first character in plain style. -function isPlainSafe(c) { +function isPlainSafe(c, prev) { // Uses a subset of nb-char - c-flow-indicator - ":" - "#" // where nb-char ::= c-printable - b-char - c-byte-order-mark. return isPrintable(c) && c !== 0xFEFF @@ -200,8 +217,9 @@ function isPlainSafe(c) { && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET // - ":" - "#" + // /* An ns-char preceding */ "#" && c !== CHAR_COLON - && c !== CHAR_SHARP; + && ((c !== CHAR_SHARP) || (prev && isNsChar(prev))); } // Simplified test for values allowed as the first character in plain style. @@ -220,12 +238,13 @@ function isPlainSafeFirst(c) { && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET - // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"” + // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE + && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE @@ -256,7 +275,7 @@ var STYLE_PLAIN = 1, // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { var i; - var char; + var char, prev_char; var hasLineBreak = false; var hasFoldableLine = false; // only checked if shouldTrackWidth var shouldTrackWidth = lineWidth !== -1; @@ -272,7 +291,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te if (!isPrintable(char)) { return STYLE_DOUBLE; } - plain = plain && isPlainSafe(char); + prev_char = i > 0 ? string.charCodeAt(i - 1) : null; + plain = plain && isPlainSafe(char, prev_char); } } else { // Case: block styles permitted. @@ -291,7 +311,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te } else if (!isPrintable(char)) { return STYLE_DOUBLE; } - plain = plain && isPlainSafe(char); + prev_char = i > 0 ? string.charCodeAt(i - 1) : null; + plain = plain && isPlainSafe(char, prev_char); } // in case the end is missing a \n hasFoldableLine = hasFoldableLine || (shouldTrackWidth && @@ -548,10 +569,12 @@ function writeFlowMapping(state, level, object) { pairBuffer; for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = state.condenseFlow ? '"' : ''; + pairBuffer = ''; if (index !== 0) pairBuffer += ', '; + if (state.condenseFlow) pairBuffer += '"'; + objectKey = objectKeyList[index]; objectValue = object[objectKey]; diff --git a/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js b/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js index 2815c955deb416..ef01386bfee542 100644 --- a/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js +++ b/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js @@ -1393,13 +1393,19 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact if (state.tag !== null && state.tag !== '!') { if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { type = state.implicitTypes[typeIndex]; - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only assigned to plain scalars. So, it isn't - // needed to check for 'kind' conformity. - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched state.result = type.construct(state.result); state.tag = type.tag; @@ -1563,6 +1569,13 @@ function loadDocuments(input, options) { var state = new State(input, options); + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + // Use 0 as string terminator. That significantly simplifies bounds check. state.input += '\0'; @@ -1580,13 +1593,18 @@ function loadDocuments(input, options) { function loadAll(input, iterator, options) { - var documents = loadDocuments(input, options), index, length; + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); if (typeof iterator !== 'function') { return documents; } - for (index = 0, length = documents.length; index < length; index += 1) { + for (var index = 0, length = documents.length; index < length; index += 1) { iterator(documents[index]); } } @@ -1605,12 +1623,13 @@ function load(input, options) { } -function safeLoadAll(input, output, options) { - if (typeof output === 'function') { - loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); - } else { - return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +function safeLoadAll(input, iterator, options) { + if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') { + options = iterator; + iterator = null; } + + return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); } diff --git a/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/type/js/function.js b/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/type/js/function.js index 3604e2333743b8..8fab8c43089ff2 100644 --- a/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/type/js/function.js +++ b/tools/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/type/js/function.js @@ -14,7 +14,8 @@ try { var _require = require; esprima = _require('esprima'); } catch (_) { - /*global window */ + /* eslint-disable no-redeclare */ + /* global window */ if (typeof window !== 'undefined') esprima = window.esprima; } diff --git a/tools/node_modules/eslint/node_modules/js-yaml/package.json b/tools/node_modules/eslint/node_modules/js-yaml/package.json index c779b0b6e9b304..5bb8e811f1f953 100644 --- a/tools/node_modules/eslint/node_modules/js-yaml/package.json +++ b/tools/node_modules/eslint/node_modules/js-yaml/package.json @@ -38,10 +38,10 @@ "benchmark": "^2.1.4", "browserify": "^16.2.2", "codemirror": "^5.13.4", - "eslint": "^4.1.1", - "fast-check": "1.1.3", + "eslint": "^7.0.0", + "fast-check": "^1.24.2", "istanbul": "^0.4.5", - "mocha": "^5.2.0", + "mocha": "^7.1.2", "uglify-js": "^3.0.1" }, "files": [ @@ -51,6 +51,7 @@ "dist/" ], "homepage": "https://github.com/nodeca/js-yaml", + "jsdelivr": "dist/js-yaml.min.js", "keywords": [ "yaml", "parser", @@ -66,5 +67,6 @@ "scripts": { "test": "make test" }, - "version": "3.13.1" + "unpkg": "dist/js-yaml.min.js", + "version": "3.14.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/tslib/README.md b/tools/node_modules/eslint/node_modules/tslib/README.md index 44270f8bad1ec3..2038cf963480aa 100644 --- a/tools/node_modules/eslint/node_modules/tslib/README.md +++ b/tools/node_modules/eslint/node_modules/tslib/README.md @@ -118,7 +118,7 @@ For JSPM users: "importHelpers": true, "baseUrl": "./", "paths": { - "tslib" : ["jspm_packages/npm/tslib@1.11.2/tslib.d.ts"] + "tslib" : ["jspm_packages/npm/tslib@1.13.0/tslib.d.ts"] } } } @@ -134,11 +134,9 @@ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob * Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript). * Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter. * [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md). -* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)). # Documentation * [Quick tutorial](http://www.typescriptlang.org/Tutorial) * [Programming handbook](http://www.typescriptlang.org/Handbook) -* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) * [Homepage](http://www.typescriptlang.org/) diff --git a/tools/node_modules/eslint/node_modules/tslib/package.json b/tools/node_modules/eslint/node_modules/tslib/package.json index 8b346a977284a5..a5a881a34235a0 100644 --- a/tools/node_modules/eslint/node_modules/tslib/package.json +++ b/tools/node_modules/eslint/node_modules/tslib/package.json @@ -29,5 +29,5 @@ }, "sideEffects": false, "typings": "tslib.d.ts", - "version": "1.11.2" + "version": "1.13.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js b/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js index 1b8c2b3ce4bdbd..0e0d8d079ccbd9 100644 --- a/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js +++ b/tools/node_modules/eslint/node_modules/tslib/tslib.es6.js @@ -103,8 +103,13 @@ export function __generator(thisArg, body) { } } +export function __createBinding(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +} + export function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; } export function __values(o) { diff --git a/tools/node_modules/eslint/node_modules/tslib/tslib.js b/tools/node_modules/eslint/node_modules/tslib/tslib.js index 51362508fed099..e5b7c9b8098427 100644 --- a/tools/node_modules/eslint/node_modules/tslib/tslib.js +++ b/tools/node_modules/eslint/node_modules/tslib/tslib.js @@ -12,6 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ + /* global global, define, System, Reflect, Promise */ var __extends; var __assign; @@ -35,6 +36,7 @@ var __importStar; var __importDefault; var __classPrivateFieldGet; var __classPrivateFieldSet; +var __createBinding; (function (factory) { var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; if (typeof define === "function" && define.amd) { @@ -142,8 +144,13 @@ var __classPrivateFieldSet; } }; + __createBinding = function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }; + __exportStar = function (m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; }; __values = function (o) { @@ -249,7 +256,7 @@ var __classPrivateFieldSet; } privateMap.set(receiver, value); return value; - } + }; exporter("__extends", __extends); exporter("__assign", __assign); @@ -260,6 +267,7 @@ var __classPrivateFieldSet; exporter("__awaiter", __awaiter); exporter("__generator", __generator); exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); exporter("__values", __values); exporter("__read", __read); exporter("__spread", __spread); diff --git a/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json b/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json index ee9b001b78754b..83d66522f04c29 100644 --- a/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json +++ b/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json @@ -38,5 +38,5 @@ "posttest": "npm run lint", "test": "tap test/*-test.js" }, - "version": "2.1.0" + "version": "2.1.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js b/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js index bd755d657d9ac7..69f053667046ca 100644 --- a/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js +++ b/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js @@ -272,7 +272,7 @@ class NativeCompileCache { //------------------------------------------------------------------------------ function mkdirpSync(p_) { - _mkdirpSync(path.resolve(p_), parseInt('0777', 8) & ~process.umask()); + _mkdirpSync(path.resolve(p_), 0o777); } function _mkdirpSync(p, mode) { diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index dfcad26d9dc500..0422546fb1ecdc 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -18,10 +18,10 @@ "debug": "^4.0.1", "doctrine": "^3.0.0", "eslint-plugin-markdown": "^1.0.2", - "eslint-scope": "^5.0.0", + "eslint-scope": "^5.1.0", "eslint-utils": "^2.0.0", - "eslint-visitor-keys": "^1.1.0", - "espree": "^7.0.0", + "eslint-visitor-keys": "^1.2.0", + "espree": "^7.1.0", "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", @@ -54,7 +54,7 @@ "devDependencies": { "@babel/core": "^7.4.3", "@babel/preset-env": "^7.4.3", - "acorn": "^7.1.1", + "acorn": "^7.2.0", "babel-loader": "^8.0.5", "chai": "^4.0.1", "cheerio": "^0.22.0", @@ -153,5 +153,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "7.0.0" + "version": "7.2.0" } \ No newline at end of file diff --git a/tools/test-npm-package.js b/tools/test-npm-package.js index b34b8183677211..392d9feaa1938e 100755 --- a/tools/test-npm-package.js +++ b/tools/test-npm-package.js @@ -32,9 +32,8 @@ function spawnCopyDeepSync(source, destination) { if (common.isWindows) { mkdirSync(destination); // Prevent interactive prompt return spawnSync('xcopy.exe', ['/E', source, destination]); - } else { - return spawnSync('cp', ['-r', `${source}/`, destination]); } + return spawnSync('cp', ['-r', `${source}/`, destination]); } function runNPMPackageTests({ srcDir, install, rebuild, testArgs, logfile }) {
    ctrl + shift + delete Delete line rightDoesn't work on Linux and MacDoesn't work on Mac
    ctrl + c Delete backwards to a word boundary ctrl + backspace Doesn't - work as expected on Windows
    ctrl + delete