From a94e7dabcc53a950c1d03dd330aa440acfcee38a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 14 May 2020 09:39:03 +0200 Subject: [PATCH 001/179] lib: update executionAsyncId/triggerAsyncId comment This commit updates the comment referring to the executionAsyncId/triggerAsyncId pair being stored in a std::stack. It looks like this was changed from std::stack to AliasedFloat64Array in Commit 83e5215a4e8438a43b9f0002b7a43e2fd2dd37a4 ("async_hooks: use typed array stack as fast path"). PR-URL: https://github.com/nodejs/node/pull/33396 Reviewed-By: Chengzhong Wu Reviewed-By: James M Snell --- lib/internal/async_hooks.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 62ced406bfc1e2..834a3a540d9367 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -38,11 +38,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_ From e3533ab3379cd5a890db0f26e13f7260934f75ca Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 17 Mar 2020 21:22:57 +0100 Subject: [PATCH 002/179] util: mark classes while inspecting them This outlines the basic class setup when inspecting a class. Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/32332 Fixes: https://github.com/nodejs/node/issues/32270 Reviewed-By: Anna Henningsen Reviewed-By: Anto Aravinth --- lib/internal/util/inspect.js | 37 ++++++++++ test/parallel/test-repl-top-level-await.js | 2 +- test/parallel/test-util-inspect.js | 82 ++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 600bdd2b888f24..5dfc0b9235f9cf 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -12,6 +12,7 @@ const { DatePrototypeToString, ErrorPrototypeToString, Float32Array, + FunctionPrototypeToString, JSONStringify, Map, MapPrototype, @@ -170,6 +171,10 @@ const numberRegExp = /^(0|[1-9][0-9]*)$/; const coreModuleRegExp = /^ at (?:[^/\\(]+ \(|)((? { + 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']"], From 8803d7e8cf043c182b933f979641fa4d15f3ce45 Mon Sep 17 00:00:00 2001 From: Jan Krems Date: Sun, 17 May 2020 11:19:05 -0700 Subject: [PATCH 003/179] deps: update node-inspect to v2.0.0 Highlights: * Remove use of `process.binding` on modern node (@addaleax) * Increase timeout for port checking (@yilmazdurmaz) * Auto-resume on start when `NODE_INSPECT_RESUME_ON_START` is set (@dolsem) Compare: https://github.com/nodejs/node-inspect/compare/v1.11.6...v2.0.0 PR-URL: https://github.com/nodejs/node/pull/33447 Reviewed-By: Anna Henningsen Reviewed-By: Matheus Marchini Reviewed-By: Ben Noordhuis --- deps/node-inspect/.github/workflows/ci.yml | 31 ++++++++ deps/node-inspect/lib/_inspect.js | 40 +++++------ .../node-inspect/lib/internal/inspect_repl.js | 19 ++++- deps/node-inspect/package.json | 4 +- deps/node-inspect/test/cli/address.test.js | 71 +++++++++++++++++++ .../test/cli/invalid-args.test.js | 2 +- deps/node-inspect/test/cli/launch.test.js | 20 ++++++ deps/node-inspect/test/cli/start-cli.js | 8 +-- 8 files changed, 166 insertions(+), 29 deletions(-) create mode 100644 deps/node-inspect/.github/workflows/ci.yml create mode 100644 deps/node-inspect/test/cli/address.test.js 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 = []; From c502384ab7c5e796250b727bf86cec61593af6ba Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 1 Feb 2019 00:18:51 +0100 Subject: [PATCH 004/179] worker: use _writev in internal communication PR-URL: https://github.com/nodejs/node/pull/33454 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca --- lib/internal/main/worker_thread.js | 5 +++-- lib/internal/worker.js | 7 +++++-- lib/internal/worker/io.js | 7 +++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index 56ccd9df5e9b53..ade4b822c58013 100644 --- a/lib/internal/main/worker_thread.js +++ b/lib/internal/main/worker_thread.js @@ -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/worker.js b/lib/internal/worker.js index 5f92a7898e93a9..093efde3a5d7ba 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -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(); } From c697b96dea44992216deb2bd003930221db8372a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 15 May 2020 05:52:31 +0200 Subject: [PATCH 005/179] src: remove unnecessary else in base_object-inl.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes two unnecessary else statements in base_object-inl.h. It also tries to make the if statements consistent with regards to braces. PR-URL: https://github.com/nodejs/node/pull/33413 Reviewed-By: Zeyu Yang Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Juan José Arboleda --- src/base_object-inl.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 From 6f6fb1fcf57877c243d3ee3e9abcff667931708c Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 12 May 2020 16:04:02 -0400 Subject: [PATCH 006/179] src: prefer make_unique MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In most of the code base we use make_unique instead of new unique_ptr. Update node_platform.cc to be consistent with that. Signed-off-by: Michael Dawson PR-URL: https://github.com/nodejs/node/pull/33378 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Zeyu Yang Reviewed-By: Juan José Arboleda --- src/node_platform.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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_); } From dfa80282549966f76e4c0a8584d046a413f1bb0e Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 11 May 2020 23:10:50 +0200 Subject: [PATCH 007/179] doc: fix readline key binding documentation The documentation for two key bindings was not correct. Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33361 Reviewed-By: Anto Aravinth --- doc/api/readline.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index bd0f544def6fe1..4151926591ea97 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -739,7 +739,7 @@ const { createInterface } = require('readline'); ctrl + shift + delete Delete line right - Doesn't work on Linux and Mac + Doesn't work on Mac ctrl + c @@ -813,7 +813,7 @@ const { createInterface } = require('readline'); + backspace Delete backwards to a word boundary ctrl + backspace Doesn't - work as expected on Windows + work on Linux, Mac and Windows ctrl + delete From 83c9364bf1f2a6cfb14e6cb1d6e3fc6bb1d17fce Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 11 May 2020 23:11:33 +0200 Subject: [PATCH 008/179] lib: update TODO comments This removes one TODO comment and adds another that indicates that readline is currently not able to trigger specific escape sequences. Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33361 Reviewed-By: Anto Aravinth --- lib/readline.js | 6 +++++- test/parallel/test-assert-deep.js | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) 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/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; From 3e68d21c6ff998cf4ea9b225f0c7361f17af6455 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 14 Jun 2020 14:49:34 -0700 Subject: [PATCH 009/179] doc: use sentence-case for headings in docs PR-URL: https://github.com/nodejs/node/pull/33889 Backport-PR-URL: https://github.com/nodejs/node/pull/33964 Refs: https://developers.google.com/style/capitalization#capitalization-in-titles-and-headings Refs: https://docs.microsoft.com/en-us/style-guide/capitalization Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/api/addons.md | 6 +-- doc/api/async_hooks.md | 8 ++-- doc/api/buffer.md | 4 +- doc/api/child_process.md | 44 ++++++++++---------- doc/api/cli.md | 16 +++---- doc/api/cluster.md | 6 +-- doc/api/crypto.md | 18 ++++---- doc/api/debugger.md | 8 ++-- doc/api/deprecations.md | 14 +++---- doc/api/dgram.md | 10 ++--- doc/api/dns.md | 2 +- doc/api/documentation.md | 6 +-- doc/api/domain.md | 12 +++--- doc/api/errors.md | 20 ++++----- doc/api/esm.md | 56 ++++++++++++------------- doc/api/events.md | 4 +- doc/api/fs.md | 40 +++++++++--------- doc/api/globals.md | 2 +- doc/api/http2.md | 14 +++---- doc/api/index.md | 32 +++++++------- doc/api/inspector.md | 4 +- doc/api/intl.md | 2 +- doc/api/modules.md | 24 +++++------ doc/api/n-api.md | 62 +++++++++++++-------------- doc/api/net.md | 2 +- doc/api/os.md | 18 ++++---- doc/api/perf_hooks.md | 2 +- doc/api/policy.md | 8 ++-- doc/api/process.md | 10 ++--- doc/api/querystring.md | 2 +- doc/api/readline.md | 4 +- doc/api/repl.md | 24 +++++------ doc/api/report.md | 4 +- doc/api/stream.md | 88 +++++++++++++++++++-------------------- doc/api/string_decoder.md | 2 +- doc/api/synopsis.md | 2 +- doc/api/timers.md | 4 +- doc/api/tls.md | 42 ++++++++++--------- doc/api/tracing.md | 6 +-- doc/api/url.md | 6 +-- doc/api/util.md | 8 ++-- doc/api/v8.md | 4 +- doc/api/vm.md | 6 +-- doc/api/worker_threads.md | 2 +- doc/api/zlib.md | 10 ++--- 45 files changed, 336 insertions(+), 332 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index ffbecb02d8ff4d..516e22061e80aa 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -1,4 +1,4 @@ -# C++ Addons +# C++ addons @@ -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 diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 034879316aae06..b15f8cb92263de 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 @@ -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 diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 3b4c8432e6e971..fa322267061fcf 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -53,7 +53,7 @@ const buf6 = Buffer.from('tést'); const buf7 = Buffer.from('tést', 'latin1'); ``` -## Buffers and Character Encodings +## Buffers and character encodings diff --git a/doc/api/child_process.md b/doc/api/child_process.md index d5812c3975486b..e272c7004c1e2d 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} @@ -353,7 +353,7 @@ changes: **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 @@ -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)). @@ -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..b0db6464312113 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. @@ -1051,7 +1051,7 @@ added: v0.1.3 Print node's version. -## Environment Variables +## Environment variables ### `NODE_DEBUG=module[,…]` @@ -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..fa9b96e33bc4d2 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..015e16895d88ea 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -607,7 +607,7 @@ That is, if attempting to resolve with the first server provided results in a subsequent servers provided. Fallback DNS servers will only be used if the earlier ones time out or result in some other error. -## DNS Promises API +## DNS promises API The `dns.promises` API provides an alternative set of asynchronous DNS methods that return `Promise` objects rather than using callbacks. The API is accessible diff --git a/doc/api/documentation.md b/doc/api/documentation.md index 7059c4d33e11ca..f15936b3f43279 100644 --- a/doc/api/documentation.md +++ b/doc/api/documentation.md @@ -1,4 +1,4 @@ -# About this Documentation +# About this documentation @@ -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..ee369baa1f31c6 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` @@ -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` @@ -2183,7 +2183,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 +2562,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..1b5851289e9dce 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1,4 +1,4 @@ -# ECMAScript Modules +# ECMAScript modules @@ -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 @@ -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. @@ -1517,7 +1517,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 +1530,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 +1802,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 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..e5c67abc8a0d38 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,7 +277,7 @@ 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 @@ -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,7 +4175,7 @@ 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: @@ -4751,7 +4751,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 +5315,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 +5339,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 +5371,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 +5399,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 +5493,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 +5537,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 +5597,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 +5743,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/http2.md b/doc/api/http2.md index 4199f857f31087..5e2423b4bd064a 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 @@ -2308,7 +2308,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 +2374,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 +2422,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,27 +38,27 @@ * [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)
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..4babaee2425224 100644 --- a/doc/api/intl.md +++ b/doc/api/intl.md @@ -1,4 +1,4 @@ -# Internationalization Support +# Internationalization support diff --git a/doc/api/modules.md b/doc/api/modules.md index 1b5f9a2b708777..db1f56d901a928 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... @@ -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 @@ -413,7 +413,7 @@ with the default error: Error: Cannot find module 'some-library' ``` -## Loading from `node_modules` Folders +## Loading from `node_modules` folders @@ -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..925d955f0ef51f 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. @@ -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, @@ -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. @@ -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 @@ -343,7 +343,7 @@ NAPI_MODULE_INIT() { } ``` -## Environment Life Cycle APIs +## Environment life cycle APIs > Stability: 1 - Experimental @@ -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, @@ -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 @@ -552,7 +552,7 @@ typedef enum { } 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 @@ -1252,7 +1252,7 @@ The following process scheduling constants are exported by -### libuv Constants +### libuv constants 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..a4a2ad4b032f7b 100644 --- a/doc/api/policy.md +++ b/doc/api/policy.md @@ -49,7 +49,7 @@ node --experimental-policy=policy.json --policy-integrity="sha384-SggXRQHwCG8g+D ## 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..0989d377fbdbd6 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'` @@ -2485,7 +2485,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 @@ -2565,7 +2565,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 4151926591ea97..8cbaf362d5dc03 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -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 diff --git a/doc/api/repl.md b/doc/api/repl.md index 50845785cf9c71..71986c33e07130 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: @@ -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 @@ -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. @@ -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 @@ -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. @@ -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,7 +2012,7 @@ 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. @@ -2073,7 +2073,7 @@ function MyReadable(options) { util.inherits(MyReadable, Readable); ``` -Or, using the Simplified Constructor approach: +Or, using the simplified constructor approach: ```js const { Readable } = require('stream'); @@ -2206,7 +2206,7 @@ For streams not operating in object mode, if the `chunk` parameter of `readable.push()` is `undefined`, it will be treated as empty string or buffer. See [`readable.push('')`][] for more information. -#### Errors While Reading +#### Errors while reading Errors occurring during processing of the [`readable._read()`][] must be propagated through the [`readable.destroy(err)`][readable-_destroy] method. @@ -2228,7 +2228,7 @@ const myReadable = new Readable({ }); ``` -#### An Example Counting Stream +#### An example counting stream @@ -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. @@ -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][] @@ -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..cf4c8dc3f32efa 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*. @@ -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,7 +90,7 @@ 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: @@ -99,12 +99,12 @@ the OpenSSL command-line interface to generate such parameters: 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 @@ -267,7 +271,7 @@ Subsequent connections should say "Reused", for example: Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256 ``` -## Modifying the Default TLS Cipher suite +## 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: @@ -337,8 +341,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][]. @@ -895,7 +899,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 +941,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 diff --git a/doc/api/url.md b/doc/api/url.md index 3da8adbe8568d2..e1ef224d815620 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 @@ -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 @@ -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, diff --git a/doc/api/util.md b/doc/api/util.md index ab2e94ef60ee84..57314ba2fa7904 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -752,7 +752,7 @@ ignored, if not supported. * `bgCyanBright` * `bgWhiteBright` -### Custom inspection functions on Objects +### Custom inspection functions on objects @@ -1041,7 +1041,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 +1067,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 | | ----------------- | -------------------------------- | @@ -2420,7 +2420,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..5356eef4c96471 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -1,4 +1,4 @@ -# VM (Executing JavaScript) +# VM (executing JavaScript) @@ -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/worker_threads.md b/doc/api/worker_threads.md index 120f39d0074e44..5d7708391d21c1 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -1,4 +1,4 @@ -# Worker Threads +# Worker threads 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 From 70d025f510715978340e2120deab337587881757 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 14 Jun 2020 22:51:06 -0700 Subject: [PATCH 010/179] doc: standardize on sentence case for headers Previously, our documentation headers were a mixture of title case, sentence case, and things that were neither. For technical documentation, the _de facto_ standard seems to be sentence case. (See refs below.) So let's standardize on that. This commit follows a commit implementing this standard. This commit adds it to the style guide. Refs: https://developers.google.com/style/capitalization#capitalization-in-titles-and-headings Refs: https://docs.microsoft.com/en-us/style-guide/capitalization PR-URL: https://github.com/nodejs/node/pull/33889 Backport-PR-URL: https://github.com/nodejs/node/pull/33964 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/guides/doc-style-guide.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/guides/doc-style-guide.md b/doc/guides/doc-style-guide.md index fad23941416713..6c67e752bfc394 100644 --- a/doc/guides/doc-style-guide.md +++ b/doc/guides/doc-style-guide.md @@ -62,6 +62,9 @@ * 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_ See also API documentation structure overview in [doctools README][]. From d09f6d55c7d7a629cacd73229df984e48417c6e0 Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Wed, 11 Mar 2020 10:38:00 -0500 Subject: [PATCH 011/179] esm: doc & validate source values for formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/32202 Reviewed-By: Guy Bedford Reviewed-By: Geoffrey Booth Reviewed-By: Michaël Zasso Reviewed-By: Zeyu Yang --- doc/api/esm.md | 35 +++++++++---- lib/internal/modules/esm/translators.js | 43 ++++++++++++++-- .../test-esm-loader-stringify-text.mjs | 50 +++++++++++++++++++ .../es-module-loaders/string-sources.mjs | 30 +++++++++++ .../es-module-loaders/transform-source.mjs | 5 +- 5 files changed, 150 insertions(+), 13 deletions(-) create mode 100644 test/es-module/test-esm-loader-stringify-text.mjs create mode 100644 test/fixtures/es-module-loaders/string-sources.mjs diff --git a/doc/api/esm.md b/doc/api/esm.md index 1b5851289e9dce..87aba188fe11f0 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1170,16 +1170,27 @@ 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 | -| --- | --- | -| `'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 | +| `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][]. + +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 /** @@ -1819,6 +1830,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/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/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/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();`) }; From 3b46e7f1485c62935b2cb1a66bee82fdca738660 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 21 May 2020 14:12:42 +0200 Subject: [PATCH 012/179] win,fs: use namespaced path in absolute symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the namespaced (with the \\?\ prefix) paths for symlink targets when the path is absolute. This allows creation of symlinks to files with long filenames. Fixes: https://github.com/nodejs/node/issues/27795 PR-URL: https://github.com/nodejs/node/pull/33351 Reviewed-By: Colin Ihrig Reviewed-By: Gerhard Stöbich Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- lib/internal/fs/utils.js | 10 +++++--- test/parallel/test-fs-symlink-longpath.js | 29 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-fs-symlink-longpath.js diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 6f096336f20e10..989bccc7c153d3 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -272,10 +272,14 @@ function preprocessSymlinkDestination(path, type, linkPath) { // 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/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)); +})); From 1c64bc5e3465dff3cad957b03a25cadcd3780b90 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 18 May 2020 08:55:17 +0200 Subject: [PATCH 013/179] worker: perform initial port.unref() before preload modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The refcount of the internal communication port is relevant for stdio, but the `port.unref()` call effectively resets any `.ref()` calls happening during stdio operations happening before it. Therefore, do the `.unref()` call before loading preload modules, which may cause stdio operations. Fixes: https://github.com/nodejs/node/issues/31777 PR-URL: https://github.com/nodejs/node/pull/33455 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Juan José Arboleda --- lib/internal/main/worker_thread.js | 2 +- .../test-worker-stdio-from-preload-module.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-worker-stdio-from-preload-module.js diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index ade4b822c58013..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'); 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'); + })); +} From 0837c2cc99e39de7df7923cae790ff3a4860b071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Sat, 25 Apr 2020 20:07:16 -0500 Subject: [PATCH 014/179] src: remove unused headers in src/util.h PR-URL: https://github.com/nodejs/node/pull/33070 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Sam Roberts --- src/util.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util.h b/src/util.h index 5efd92eb6e239c..3489cfccbe4c9d 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 From 5fb1cc8cc143c86a9db884bcb9f5a8503dfe9d91 Mon Sep 17 00:00:00 2001 From: rickyes Date: Thu, 7 May 2020 15:15:23 +0800 Subject: [PATCH 015/179] fs: replace checkPosition with validateInteger PR-URL: https://github.com/nodejs/node/pull/33277 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Yongsheng Zhang --- lib/internal/fs/streams.js | 23 ++++------------------- test/parallel/test-file-write-stream3.js | 9 +++++++-- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 343e09d7bc271b..977de87ab042dd 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; } 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); From a522c0e2c755ed0695ee398097c7d114b6799ee7 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 18 May 2020 13:18:52 +0200 Subject: [PATCH 016/179] src: use MaybeLocal.ToLocal instead of IsEmpty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit suggest using MaybeLocal.ToLocal and passing in the Local fun. The motivation for doing this is that the following MaybeLocal.ToLocalChecked call can then be avoided. PR-URL: https://github.com/nodejs/node/pull/33457 Reviewed-By: Zeyu Yang Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: David Carlier Reviewed-By: Juan José Arboleda --- src/node_native_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 1b916d645d8639..a47b80617f1476 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -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 From ef27e6ce57846ffe31654f38aba53fed210fb7da Mon Sep 17 00:00:00 2001 From: AshCripps Date: Thu, 21 May 2020 16:16:14 +0100 Subject: [PATCH 017/179] test: mark test-dgram-multicast-ssmv6-multi-process flaky refs: https://github.com/nodejs/node/issues/32946 Mark this test as flaky on linux Ive used sequential.status as a template for this file PR-URL: https://github.com/nodejs/node/pull/33498 Refs: https://github.com/nodejs/node/issues/32946 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- test/internet/internet.status | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/internet/internet.status 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] From 1b76377bcec8b4b6bdbad27acde54dc46ddf7fe2 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 13 May 2020 20:37:22 -0700 Subject: [PATCH 018/179] doc: correct CommonJS self-resolve spec PR-URL: https://github.com/nodejs/node/pull/33391 Reviewed-By: James M Snell Reviewed-By: Geoffrey Booth --- doc/api/modules.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index db1f56d901a928..a72646ae9f2cec 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -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 From adb93f153ba1971c715204ce97d2aa5e02bdd87a Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 21 May 2020 14:15:37 +0200 Subject: [PATCH 019/179] fs: unify style in preprocessSymlinkDestination Removes the else after return to match rest of the style of the function. PR-URL: https://github.com/nodejs/node/pull/33496 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- lib/internal/fs/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 989bccc7c153d3..b8ec0726885669 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -267,7 +267,8 @@ 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); From c76ec4d0076b1e815043e275b4a053fa53725150 Mon Sep 17 00:00:00 2001 From: Deep310 <55121371+Deep310@users.noreply.github.com> Date: Wed, 20 May 2020 18:23:56 -0400 Subject: [PATCH 020/179] doc: fixed a grammatical error in path.md It said, " The path.basename() methods returns the last portion....". "Methods" was wrong and it is fixed to "method". PR-URL: https://github.com/nodejs/node/pull/33489 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api/path.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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`][]. From 78734c2698aaaf31a4fe724a81ff9c449ca1ec41 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 19 May 2020 20:21:29 +1000 Subject: [PATCH 021/179] doc: eliminate dead space in API section's sidebar This commit improves overall usability on desktop by removing the "dead" (non-interactive) regions between links in the API section's navigation. No visible changes have been made; this enhancement is purely tactile in nature. PR-URL: https://github.com/nodejs/node/pull/33469 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api_assets/style.css | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index 5799a777353ba7..37e7376d0583f2 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -592,6 +592,50 @@ td > *:last-child { margin: -2px 3px 0 0; } +/* API reference sidebar */ +@media only screen and (min-width: 1025px) { + .apidoc #column2 > .line { + pointer-events: none; + } + .apidoc #column2 > :first-child, + .apidoc #column2 > ul, + .apidoc #column2 > ul > li { + margin: 0; + padding: 0; + } + .apidoc #column2 > :first-child > a[href] { + border-radius: 0; + padding: 1.25rem 1.4375rem .625rem; + display: block; + } + .apidoc #column2 > ul > li > a[href] { + padding: .5rem 1.4375rem; + padding-right: 0; + display: block; + } + .apidoc #column2 > ul > :first-child > a[href] { + padding-top: .625rem; + } + .apidoc #column2 > ul > :last-child > a[href] { + padding-bottom: .625rem; + } + .apidoc #column2 > ul:first-of-type > :last-child > a[href] { + padding-bottom: 1rem; + } + .apidoc #column2 > ul:nth-of-type(2) > :first-child > a[href] { + padding-top: .875rem; + } + .apidoc #column2 > ul:nth-of-type(2) > :last-child > a[href] { + padding-bottom: .9375rem; + } + .apidoc #column2 > ul:last-of-type > :first-child > a[href] { + padding-top: 1rem; + } + .apidoc #column2 > ul:last-of-type > :last-child > a[href] { + padding-bottom: 1.75rem; + } +} + @media only screen and (max-width: 1024px) { #content { overflow: visible; From 383c5b3962f4deb9b9e52ee7b6fc8f1e2281f9ef Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 16 May 2020 13:19:54 +0200 Subject: [PATCH 022/179] wasi: relax WebAssembly.Instance type check Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: https://github.com/nodejs/node/issues/33415 PR-URL: https://github.com/nodejs/node/pull/33431 Reviewed-By: Anna Henningsen Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- lib/wasi.js | 21 ++++--- test/wasi/test-wasi-start-validation.js | 76 ++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 9 deletions(-) diff --git a/lib/wasi.js b/lib/wasi.js index a6dee9498463dc..69c245f9d051be 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -1,5 +1,4 @@ 'use strict'; -/* global WebAssembly */ const { ArrayPrototypeMap, ArrayPrototypePush, @@ -12,6 +11,7 @@ const { ERR_WASI_ALREADY_STARTED } = require('internal/errors').codes; const { emitExperimentalWarning } = require('internal/util'); +const { isArrayBuffer } = require('internal/util/types'); const { validateArray, validateBoolean, @@ -70,10 +70,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 +88,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/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({}); From 6f8b7a85d239129273948386c34775810f2dc4a3 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Sat, 16 May 2020 15:54:24 -0400 Subject: [PATCH 023/179] doc,tools: properly syntax highlight API ref docs Prior to this commit, all
 tags were being
highlighted as JavaScript. This has been corrected
to syntax highlight all languages appearing in the
API reference docs. This was accomplished by using
highlight.js instead of SHJS for the frontend lib.

* remove SHJS JavaScript code
* add highlight.js bundle
* fix script tags to reflect replacement
* migrate CSS to use highlight.js classes
* add appropriate documentation
* ensure api_assets README.md stays interal

Fixes: https://github.com/nodejs/node/issues/33363

PR-URL: https://github.com/nodejs/node/pull/33442
Reviewed-By: Rich Trott 
Reviewed-By: Luigi Pinca 
Reviewed-By: Ruben Bridgewater 
Reviewed-By: Ujjwal Sharma 
---
 LICENSE                             |  33 ++
 Makefile                            |   2 +-
 doc/api_assets/README.md            |  27 ++
 doc/api_assets/highlight.pack.js    |   6 +
 doc/api_assets/hljs.css             |  29 ++
 doc/api_assets/sh.css               |  25 --
 doc/api_assets/sh_javascript.min.js |   1 -
 doc/api_assets/sh_main.js           | 553 ----------------------------
 doc/guides/doc-style-guide.md       |   3 +-
 doc/template.html                   |   7 +-
 tools/license-builder.sh            |   3 +
 11 files changed, 104 insertions(+), 585 deletions(-)
 create mode 100644 doc/api_assets/README.md
 create mode 100644 doc/api_assets/highlight.pack.js
 create mode 100644 doc/api_assets/hljs.css
 delete mode 100644 doc/api_assets/sh.css
 delete mode 100644 doc/api_assets/sh_javascript.min.js
 delete mode 100644 doc/api_assets/sh_main.js

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..97fb158898f4de 100644
--- a/Makefile
+++ b/Makefile
@@ -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
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],[/ * `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 { From 09277fa5e48dfb676540ae07b44666e7982802cf Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Wed, 6 May 2020 10:40:01 -0500 Subject: [PATCH 028/179] benchmark: fixing http_server_for_chunky_client.js PR-URL: https://github.com/nodejs/node/pull/33271 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- benchmark/http/http_server_for_chunky_client.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); From f495ab3dcba8f5b83ce844faa5758e8ec39363b8 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Sun, 3 May 2020 12:34:03 +0200 Subject: [PATCH 029/179] tools: add docserve target Spaws a webserver serving the docs. Helpful to circumvent the OS permission limitations or to access the docs form a different device on the local network. PR-URL: https://github.com/nodejs/node/pull/33221 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 97fb158898f4de..6f352c48c6f0c5 100644 --- a/Makefile +++ b/Makefile @@ -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 From 5a6d80f25fc866aec86b2df6ad8bbce959774396 Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Tue, 19 May 2020 17:51:55 +0300 Subject: [PATCH 030/179] buffer: remove hoisted variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33470 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Juan José Arboleda Reviewed-By: Ruben Bridgewater --- lib/buffer.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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. From e1050344f8450ed725e21dd7579c89bad5939f6b Mon Sep 17 00:00:00 2001 From: Eric Bickle Date: Fri, 8 May 2020 07:35:17 -0700 Subject: [PATCH 031/179] Revert "src: fix missing extra ca in tls.rootCertificates" A fix to tls.rootCertificates to have it correctly return the process' current root certificates resulted in non-deterministic behavior when Node.js is configured to use an OpenSSL system or file-based certificate store. The safest action is to revert the change and change the specification for tls.rootCertificates to state that it only returns the bundled certificates instead of the current ones. Fixes: https://github.com/nodejs/node/issues/32229 Refs: https://github.com/nodejs/node/issues/32074 PR-URL: https://github.com/nodejs/node/pull/33313 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/node_crypto.cc | 63 ++++++------------- test/parallel/test-tls-root-certificates.js | 69 ++++++++------------- 2 files changed, 43 insertions(+), 89 deletions(-) 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/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-----'); +})); From 281d7f74d8946de75700bd7bfb97df7aa62cdbce Mon Sep 17 00:00:00 2001 From: Eric Bickle Date: Fri, 8 May 2020 07:37:50 -0700 Subject: [PATCH 032/179] doc: correct tls.rootCertificates to match implementation Update tls.rootCertificates documentation to clarify that it returns the bundled Node.js root certificates rather than the root certificates used by tls.createSecureContext. Fixes: https://github.com/nodejs/node/issues/32074 Refs: https://github.com/nodejs/node/issues/32229 PR-URL: https://github.com/nodejs/node/pull/33313 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/tls.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index cf4c8dc3f32efa..8ee91c7fe6b738 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1776,8 +1776,10 @@ added: v12.3.0 * {string[]} An immutable array of strings representing the root certificates (in PEM format) -used for verifying peer certificates. This is the default value of the `ca` -option to [`tls.createSecureContext()`][]. +from the bundled Mozilla CA store as supplied by current Node.js version. + +The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store +that is fixed at release time. It is identical on all supported platforms. ## `tls.DEFAULT_ECDH_CURVE` ## Technology Sponsors diff --git a/tools/node_modules/eslint/lib/init/config-initializer.js b/tools/node_modules/eslint/lib/init/config-initializer.js index 70f0a250ad1dd6..00f17678fc66c0 100644 --- a/tools/node_modules/eslint/lib/init/config-initializer.js +++ b/tools/node_modules/eslint/lib/init/config-initializer.js @@ -326,6 +326,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 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/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/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/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-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-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-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-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/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/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/utils/ast-utils.js b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js index e6a3cb4cac58be..83ecf69434dafb 100644 --- a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js +++ b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js @@ -1243,19 +1243,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; }, /** 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/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/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/package.json b/tools/node_modules/eslint/package.json index dfcad26d9dc500..f5d0ed08f0aa90 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -153,5 +153,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "7.0.0" + "version": "7.1.0" } \ No newline at end of file From 74a1493441d2521cd05a9e7cb31efecb47ef5935 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Thu, 21 May 2020 19:59:49 -0400 Subject: [PATCH 044/179] doc: normalize C code block info strings Prior to this commit, C fenced code blocks in Markdown files had inconsistent info strings. This has been corrected to standardize on the lowercase variant, which matches the others, is the typical file extension for C files, and is the CSS class used by highlight.js despite representing a minority of appearances in the doc/api/ dir. Stats: > 'C' => 181, > 'c' => 3, Refs: https://github.com/highlightjs/highlight.js/pull/2577 PR-URL: https://github.com/nodejs/node/pull/33507 Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: Ruben Bridgewater --- doc/api/n-api.md | 362 +++++++++++++++++++++++------------------------ 1 file changed, 181 insertions(+), 181 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 925d955f0ef51f..85fb8bcc7a2dc3 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -109,7 +109,7 @@ versions: 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 ``` @@ -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 ``` @@ -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" @@ -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); ``` @@ -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; @@ -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,7 +545,7 @@ 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 @@ -610,7 +610,7 @@ Function pointer type for user-provided native functions which are to be exposed to JavaScript via N-API. Callback functions should satisfy the following signature: -```C +```c typedef napi_value (*napi_callback)(napi_env, napi_callback_info); ``` @@ -626,7 +626,7 @@ must provide a function satisfying the following signature which would get called upon the object's collection. Currently, `napi_finalize` can be used for finding out when objects that have external data are collected. -```C +```c typedef void (*napi_finalize)(napi_env env, void* finalize_data, void* finalize_hint); @@ -640,7 +640,7 @@ napiVersion: 1 Function pointer used with functions that support asynchronous operations. Callback functions must satisfy the following signature: -```C +```c typedef void (*napi_async_execute_callback)(napi_env env, void* data); ``` @@ -659,7 +659,7 @@ napiVersion: 1 Function pointer used with functions that support asynchronous operations. Callback functions must satisfy the following signature: -```C +```c typedef void (*napi_async_complete_callback)(napi_env env, napi_status status, void* data); @@ -687,7 +687,7 @@ via `napi_make_callback`. Callback functions must satisfy the following signature: -```C +```c typedef void (*napi_threadsafe_function_call_js)(napi_env env, napi_value js_callback, void* context, @@ -746,7 +746,7 @@ added: v8.0.0 napiVersion: 1 --> -```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); ``` @@ -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, @@ -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; @@ -1583,7 +1583,7 @@ 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][]): -```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; @@ -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, @@ -1774,7 +1774,7 @@ added: v8.0.0 napiVersion: 1 --> -```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) ``` @@ -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) @@ -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, @@ -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); @@ -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, @@ -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); ``` @@ -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, @@ -4734,7 +4734,7 @@ added: v9.6.0 napiVersion: 3 --> -```C +```c NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env, napi_value resource_object, napi_async_context context, @@ -4761,7 +4761,7 @@ added: v9.6.0 napiVersion: 3 --> -```C +```c NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, napi_callback_scope scope) ``` @@ -4779,7 +4779,7 @@ added: v8.4.0 napiVersion: 1 --> -```C +```c typedef struct { uint32_t major; uint32_t minor; @@ -4808,7 +4808,7 @@ added: v8.0.0 napiVersion: 1 --> -```C +```c napi_status napi_get_version(napi_env env, uint32_t* result); ``` @@ -4840,7 +4840,7 @@ added: v8.5.0 napiVersion: 1 --> -```C +```c NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env, int64_t change_in_bytes, int64_t* result); @@ -4921,7 +4921,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 +4943,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 +4968,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 +4993,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 +5015,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 +5051,7 @@ added: napiVersion: 2 --> -```C +```c NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env, struct uv_loop_s** loop); ``` @@ -5177,7 +5177,7 @@ changes: description: Made `func` parameter optional with custom `call_js_cb`. --> -```C +```c NAPI_EXTERN napi_status napi_create_threadsafe_function(napi_env env, napi_value func, @@ -5221,7 +5221,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 +5239,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 +5267,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_acquire_threadsafe_function(napi_threadsafe_function func); ``` @@ -5289,7 +5289,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 +5318,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); ``` @@ -5339,7 +5339,7 @@ added: v10.6.0 napiVersion: 4 --> -```C +```c NAPI_EXTERN napi_status napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); ``` From 7ea6b07b901c1b6c14f64b8b45d86e10dadbced5 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Wed, 20 May 2020 11:10:22 -0400 Subject: [PATCH 045/179] doc: normalize shell code block info strings Prior to this commit, shell fenced code blocks in Markdown files had inconsistent info strings. This has been corrected to standarize on the one with the highest frequency in the doc/api/ dir. Stats: > 'console' => 54, > 'shell' => 2, PR-URL: https://github.com/nodejs/node/pull/33486 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- README.md | 2 +- doc/api/intl.md | 4 ++-- doc/guides/backporting-to-release-lines.md | 4 ++-- doc/guides/maintaining-V8.md | 6 +++--- doc/guides/maintaining-root-certs.md | 6 +++--- doc/guides/maintaining-zlib.md | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index af3a57ccaac992..a26109b24d62df 100644 --- a/README.md +++ b/README.md @@ -572,7 +572,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 diff --git a/doc/api/intl.md b/doc/api/intl.md index 4babaee2425224..31f2dd95e7584a 100644 --- a/doc/api/intl.md +++ b/doc/api/intl.md @@ -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/guides/backporting-to-release-lines.md b/doc/guides/backporting-to-release-lines.md index 6fcbdc43f72396..5a96b160351700 100644 --- a/doc/guides/backporting-to-release-lines.md +++ b/doc/guides/backporting-to-release-lines.md @@ -35,7 +35,7 @@ replace that with the staging branch for the targeted release line. 2. Make sure that the local staging branch is up to date with the remote. 3. Create a new branch off of the staging branch, as shown below. - ```shell + ```bash # Assuming your fork of Node.js is checked out in $NODE_DIR, # the origin remote points to your fork, and the upstream remote points # to git://github.com/nodejs/node @@ -55,7 +55,7 @@ replace that with the staging branch for the targeted release line. will likely fail due to conflicts. In that case, you will see something like this: - ```shell + ```console # Say the $SHA is 773cdc31ef $ git cherry-pick $SHA # Use your commit hash error: could not apply 773cdc3... 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-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 From 18dc03d6a5cbeaf58cafea4ca6b576cf1ebf5e97 Mon Sep 17 00:00:00 2001 From: Ben Bucksch Date: Wed, 20 May 2020 14:13:29 +0200 Subject: [PATCH 046/179] crypto: fix wrong error message When calling `crypto.sign()`, if the `key` parameter object is missing the `key` property, the error message is wrong. Before the fix: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received an instance of Object Expected: TypeError [ERR_INVALID_ARG_TYPE]: The "key.key property" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received undefined This seems like a copy&paste bug. Somebody copied from the end of the function, where this is correct, to here, where it's wrong. PR-URL: https://github.com/nodejs/node/pull/33482 Fixes: https://github.com/nodejs/node/issues/33480 Reviewed-By: Ruben Bridgewater Reviewed-By: Ujjwal Sharma --- lib/internal/crypto/keys.js | 4 ++-- test/parallel/test-crypto-sign-verify.js | 30 +++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js index 087cef014f0fb1..40f1a54abc0fad 100644 --- a/lib/internal/crypto/keys.js +++ b/lib/internal/crypto/keys.js @@ -268,10 +268,10 @@ 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 = 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); }); From cf82adf87fa42ca9e05b748d5795850cb5c5964b Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Fri, 22 May 2020 02:33:40 -0400 Subject: [PATCH 047/179] doc: normalize Bash code block info strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, Bash fenced code blocks in Markdown files had inconsistent info strings. This has been corrected to standardize on the less-obscure variant. PR-URL: https://github.com/nodejs/node/pull/33510 Reviewed-By: Michaël Zasso Reviewed-By: Ruben Bridgewater --- doc/api/deprecations.md | 2 +- doc/api/esm.md | 4 ++-- doc/api/modules.md | 2 +- doc/api/policy.md | 4 ++-- doc/api/tls.md | 14 +++++++------- doc/api/tty.md | 2 +- doc/guides/collaborator-guide.md | 2 +- doc/guides/maintaining-openssl.md | 10 +++++----- doc/guides/onboarding-extras.md | 2 +- doc/guides/releases.md | 6 +++--- test/fixtures/0-dns/README.md | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index ad41b56578a632..0d3f6a785be2aa 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1577,7 +1577,7 @@ querystring.parse(str, '\n', '='); This function is not completely equivalent to `querystring.parse()`. One difference is that `querystring.parse()` does url decoding: -```sh +```console > querystring.parse('%E5%A5%BD=1', '\n', '='); { '好': '1' } > tls.parseCertString('%E5%A5%BD=1'); diff --git a/doc/api/esm.md b/doc/api/esm.md index 87aba188fe11f0..8f70b9c7cb5ea4 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -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 ``` @@ -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 diff --git a/doc/api/modules.md b/doc/api/modules.md index a72646ae9f2cec..0b5ebac54ef1b6 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -680,7 +680,7 @@ In `entry.js` script: console.log(require.main); ``` -```sh +```bash node entry.js ``` diff --git a/doc/api/policy.md b/doc/api/policy.md index a4a2ad4b032f7b..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,7 +43,7 @@ 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 ``` diff --git a/doc/api/tls.md b/doc/api/tls.md index 8ee91c7fe6b738..17939b613ccc09 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -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 ``` @@ -95,7 +95,7 @@ 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 ``` @@ -254,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 ``` @@ -308,7 +308,7 @@ 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 +```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" 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/guides/collaborator-guide.md b/doc/guides/collaborator-guide.md index 11ca506dacee3e..14de2a0c253b3b 100644 --- a/doc/guides/collaborator-guide.md +++ b/doc/guides/collaborator-guide.md @@ -638,7 +638,7 @@ That means a commit has landed since your last rebase against `upstream/master`. To fix this, pull with rebase from upstream, run the tests again, and (if the tests pass) push again: -```sh +```bash git pull upstream master --rebase make -j4 test git push upstream master 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/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..327ceb605431fc 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -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/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 ...................+++ From bba41bf6e157cd2b39bd67081020c64c6ccab275 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 28 Apr 2020 21:34:22 +0200 Subject: [PATCH 048/179] build: fix makefile script on windows On Windows there is a program "find.exe" located in C:\Windows\System32, which is usually in the PATH before MSYS version of that program (required for running makefile). The Windows version of the program uses different CLI syntax, which results in errors like "File not found - *node_modules*" This commit specifies the full path to the program, which is also properly handled by MSYS on Windows. PR-URL: https://github.com/nodejs/node/pull/33136 Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Ben Noordhuis --- Makefile | 7 ++++--- configure.py | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6f352c48c6f0c5..f88a664e6e8b2e 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) @@ -168,7 +169,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 @@ -1200,7 +1201,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) @@ -1377,7 +1378,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/configure.py b/configure.py index 0e72ed24ccecbe..cdc8922d29a416 100755 --- a/configure.py +++ b/configure.py @@ -1744,6 +1744,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 += [''] From 05cbd8f6f2b795f621fe6f5c2cabe9cd365da685 Mon Sep 17 00:00:00 2001 From: himself65 Date: Mon, 25 May 2020 23:41:48 +0800 Subject: [PATCH 049/179] src: use const in constant args.Length() PR-URL: https://github.com/nodejs/node/pull/33555 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau --- src/node_file.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index b632a5590435de..089e45322ba686 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -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]); From 3032f0f38de76a74dcede09b72a8dfe99d79ded3 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sun, 24 May 2020 17:23:02 +0200 Subject: [PATCH 050/179] test: make flaky test stricter Make assertions in flaky test stricter to possibly make it easier to determine the root cause. Refs: https://github.com/nodejs/node/issues/4066 PR-URL: https://github.com/nodejs/node/pull/33539 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- test/parallel/test-http-destroyed-socket-write2.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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(); }); From 103479a0c5ca6202e64b75adfbd47713cb023092 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 25 May 2020 14:15:43 +0200 Subject: [PATCH 051/179] src: use MaybeLocal.ToLocal instead of IsEmpty This commit suggest using MaybeLocal.ToLocal and passing in the Local fn. The motivation for doing this is that the following MaybeLocal.ToLocalChecked call can then be avoided. PR-URL: https://github.com/nodejs/node/pull/33554 Reviewed-By: Zeyu Yang Reviewed-By: Colin Ihrig Reviewed-By: David Carlier Reviewed-By: James M Snell --- src/api/environment.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index 9645b84c9eba41..60cc016b7702a9 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -498,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. From 3d05e3d86162c73c72d019cea4f40c4350eb917b Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Wed, 6 May 2020 11:20:14 -0400 Subject: [PATCH 052/179] tools: fix check-imports.py to match on word boundaries `check-imports.py` was missing some unused `using` statements as it was not matching on word boundaries (e.g. `MaybeLocal` was considered a use of `Local`). Fix that and add some unit tests (which required the script to be renamed to drop the `-` so it could be imported into the test script). PR-URL: https://github.com/nodejs/node/pull/33268 Refs: https://github.com/nodejs/node/issues/29226 Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater Reviewed-By: Christian Clauss Reviewed-By: Daniel Bevenius Reviewed-By: Beth Griggs --- Makefile | 4 +- test/fixtures/tools/checkimports/invalid.cc | 7 ++ test/fixtures/tools/checkimports/maybe.cc | 7 ++ test/fixtures/tools/checkimports/unsorted.cc | 6 ++ test/fixtures/tools/checkimports/unused.cc | 5 ++ test/fixtures/tools/checkimports/valid.cc | 6 ++ test/tools/test_checkimports.py | 77 ++++++++++++++++++++ tools/{check-imports.py => checkimports.py} | 6 +- 8 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/tools/checkimports/invalid.cc create mode 100644 test/fixtures/tools/checkimports/maybe.cc create mode 100644 test/fixtures/tools/checkimports/unsorted.cc create mode 100644 test/fixtures/tools/checkimports/unused.cc create mode 100644 test/fixtures/tools/checkimports/valid.cc create mode 100644 test/tools/test_checkimports.py rename tools/{check-imports.py => checkimports.py} (84%) diff --git a/Makefile b/Makefile index f88a664e6e8b2e..934b3253838150 100644 --- a/Makefile +++ b/Makefile @@ -1322,13 +1322,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 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/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/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) From b7ea7be2a8f09d1898e0ae2607e16b334e7a4151 Mon Sep 17 00:00:00 2001 From: Ash Cripps Date: Thu, 21 May 2020 16:48:09 +0100 Subject: [PATCH 053/179] meta: add flaky test issue template Add a flaky test issue template to ensure that enough information is provided for investigation PR-URL: https://github.com/nodejs/node/pull/33500 Reviewed-By: Ruben Bridgewater Reviewed-By: Beth Griggs --- .../ISSUE_TEMPLATE/4-report-a-flaky-test.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/4-report-a-flaky-test.md 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..b5b005c21bbaae --- /dev/null +++ b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md @@ -0,0 +1,30 @@ +--- +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**: From 41d879616fa7177eb9cb127afff56fe9a59b29d8 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 26 May 2020 08:48:17 +0200 Subject: [PATCH 054/179] src: remove unused using declarations This commit removes the unused using declarations reported by lint-cpp. PR-URL: https://github.com/nodejs/node/pull/33268 Refs: https://github.com/nodejs/node/issues/29226 Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater Reviewed-By: Christian Clauss Reviewed-By: Daniel Bevenius Reviewed-By: Beth Griggs --- src/heap_utils.cc | 1 - src/inspector_agent.cc | 2 -- src/inspector_js_api.cc | 1 - src/module_wrap.cc | 2 -- src/node_credentials.cc | 1 - src/node_dir.cc | 1 - src/node_dtrace.cc | 1 - src/node_errors.cc | 1 - src/node_http2.cc | 2 -- src/node_main_instance.cc | 1 - src/node_messaging.cc | 1 - src/node_native_module.cc | 3 --- src/node_native_module_env.cc | 1 - src/node_options.cc | 1 - src/node_perf.cc | 3 --- src/node_process_methods.cc | 2 -- src/node_process_object.cc | 2 -- src/node_report.cc | 3 --- src/node_report_module.cc | 2 -- src/node_util.cc | 1 - src/node_zlib.cc | 2 -- src/pipe_wrap.cc | 1 - src/tcp_wrap.cc | 1 - src/tls_wrap.cc | 1 - src/tty_wrap.cc | 1 - 25 files changed, 38 deletions(-) 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/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_credentials.cc b/src/node_credentials.cc index ad0e1dbb9bb68e..d7be988d978b8a 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; 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_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..576db539358f35 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; 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 a47b80617f1476..e61d5896b79acf 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; diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc index 31536000fc8d2f..e419b3ab5a7852 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; diff --git a/src/node_options.cc b/src/node_options.cc index 8b3a161c2d2f83..b7978871f020be 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; 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_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..62b3d7abd1057b 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -41,11 +41,8 @@ using v8::HeapSpaceStatistics; using v8::HeapStatistics; using v8::Isolate; using v8::Local; -using v8::Number; -using v8::StackTrace; using v8::String; using v8::V8; -using v8::Value; namespace per_process = node::per_process; diff --git a/src/node_report_module.cc b/src/node_report_module.cc index 700dd88aba645e..5afc0cfe104fe6 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; diff --git a/src/node_util.cc b/src/node_util.cc index db9b8ec8d65f51..ec3f8e1fe7deaf 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; 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/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/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; From ed741ecb1ed75a4305fa6d3f0c5cbcc3258b600b Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Tue, 26 May 2020 08:32:26 -0700 Subject: [PATCH 055/179] n-api: remove `napi_env::CallIntoModuleThrow` Give `napi_env::CallIntoModule` the thrower used by `CallIntoModuleThrow` as its default second argument. That way we do not need two different methods on `napi_env` for calling into the addon. PR-URL: https://github.com/nodejs/node/pull/33570 Signed-off-by: Gabriel Schulhof Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Chengzhong Wu Reviewed-By: Michael Dawson --- src/js_native_api_v8.cc | 4 ++-- src/js_native_api_v8.h | 16 +++++++--------- src/node_api.cc | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index a351edc023c562..485c242dce23eb 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -267,7 +267,7 @@ class RefBase : protected Finalizer, RefTracker { protected: inline void Finalize(bool is_env_teardown = false) override { if (_finalize_callback != nullptr) { - _env->CallIntoModuleThrow([&](napi_env env) { + _env->CallIntoModule([&](napi_env env) { _finalize_callback( env, _finalize_data, @@ -508,7 +508,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/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)); }); From a3b7e5992dba393cbf2e7cf5fc3e5630eb407fe4 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Sat, 25 Apr 2020 15:47:37 +0530 Subject: [PATCH 056/179] http2: use `Object.create(null)` for `getHeaders` refactor `getHeaders` to initialize headers using `Object.create(null)` Refs: https://github.com/nodejs/node/issues/29829 PR-URL: https://github.com/nodejs/node/pull/33188 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Sebastiaan Deckers Reviewed-By: Trivikram Kamat --- lib/internal/http2/compat.js | 3 ++- test/parallel/test-http2-compat-serverresponse-headers.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 9c49d52b5d37d7..92e8d38869e53f 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -555,7 +555,8 @@ class Http2ServerResponse extends Stream { } getHeaders() { - return { ...this[kHeaders] }; + const headers = ObjectCreate(null); + return ObjectAssign(headers, this[kHeaders]); } hasHeader(name) { 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; From 11dad02e503ebe72c96e059353bdc17ee3bea8a5 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Wed, 27 May 2020 12:19:06 -0400 Subject: [PATCH 057/179] build: fix python-version selection with actions s/PYTHON\_VERSION/python-version Refs: https://github.com/actions/setup-python Refs: https://github.com/nodejs/node/pull/32609 PR-URL: https://github.com/nodejs/node/pull/33589 Reviewed-By: Ruben Bridgewater Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Jiawen Geng --- .github/workflows/linters.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 9c69296990b0df51499b7473d30c452d537bc1b9 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 27 May 2020 12:24:32 -0700 Subject: [PATCH 058/179] src: don't use semicolon outside function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33592 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michael Dawson Reviewed-By: Matheus Marchini Reviewed-By: Ruben Bridgewater Reviewed-By: Juan José Arboleda Reviewed-By: Chengzhong Wu Reviewed-By: Zeyu Yang Reviewed-By: James M Snell --- src/node_watchdog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 7dc28ab4d3e27946112f145134f981f89b5ed186 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 23 Apr 2020 11:01:52 -0700 Subject: [PATCH 059/179] doc: update ```txt ```fandamental and ```raw code blocks These are changed to either ```text or ```console. PR-URL: https://github.com/nodejs/node/pull/33028 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api/errors.md | 2 +- doc/api/fs.md | 2 +- doc/api/http.md | 2 +- doc/api/http2.md | 4 ++-- doc/api/modules.md | 4 ++-- doc/api/report.md | 2 +- doc/api/tls.md | 2 +- doc/api/tracing.md | 8 ++++---- doc/api/url.md | 4 ++-- doc/api/util.md | 6 +++--- doc/guides/building-node-with-ninja.md | 2 +- doc/guides/contributing/pull-requests.md | 2 +- doc/guides/releases.md | 8 ++++---- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 21d8bf965d560e..672f8d20b2fb94 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -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) diff --git a/doc/api/fs.md b/doc/api/fs.md index e5c67abc8a0d38..3d384b6d7d111e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -3479,7 +3479,7 @@ is recommended. For example, given the following directory structure: -```fundamental +```text - txtDir -- file.txt - app.js 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 5e2423b4bd064a..d4da077cd9da22 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -2982,7 +2982,7 @@ added: v8.4.0 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 @@ -2998,7 +2998,7 @@ Then `request.url` will be: To parse the url into its parts `require('url').parse(request.url)` can be used: -```txt +```console $ node > require('url').parse('/status?name=ryan') Url { diff --git a/doc/api/modules.md b/doc/api/modules.md index 0b5ebac54ef1b6..2517c2132102f0 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -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 @@ -409,7 +409,7 @@ 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' ``` diff --git a/doc/api/report.md b/doc/api/report.md index 1966335c2021f7..da96ba28cb29bc 100644 --- a/doc/api/report.md +++ b/doc/api/report.md @@ -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 diff --git a/doc/api/tls.md b/doc/api/tls.md index 17939b613ccc09..8364ae9517f640 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -276,7 +276,7 @@ Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256 Node.js is built with a default suite of enabled and disabled TLS ciphers. Currently, the default cipher suite is: -```txt +```text TLS_AES_256_GCM_SHA384: TLS_CHACHA20_POLY1305_SHA256: TLS_AES_128_GCM_SHA256: diff --git a/doc/api/tracing.md b/doc/api/tracing.md index 08107f924eb2db..907fc2bbe23ba7 100644 --- a/doc/api/tracing.md +++ b/doc/api/tracing.md @@ -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/url.md b/doc/api/url.md index 024bff5b1c359f..38f5c496c199e1 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -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 │ ├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤ @@ -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 57314ba2fa7904..526e85a4159984 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] ``` diff --git a/doc/guides/building-node-with-ninja.md b/doc/guides/building-node-with-ninja.md index b4b36f76c6acb2..1b95b6886792da 100644 --- a/doc/guides/building-node-with-ninja.md +++ b/doc/guides/building-node-with-ninja.md @@ -15,7 +15,7 @@ the project's root. When running `make`, you will see output similar to the following if the build has succeeded: -```txt +```console ninja: Entering directory `out/Release` [4/4] LINK node, POSTBUILDS ``` diff --git a/doc/guides/contributing/pull-requests.md b/doc/guides/contributing/pull-requests.md index a37929726612d1..f7c76f3324edf9 100644 --- a/doc/guides/contributing/pull-requests.md +++ b/doc/guides/contributing/pull-requests.md @@ -178,7 +178,7 @@ situation would trigger the breaking change and what is the exact change. Sample complete commit message: -```txt +```text subsystem: explain the commit in one line The body of the commit message should be one or more paragraphs, explaining diff --git a/doc/guides/releases.md b/doc/guides/releases.md index 327ceb605431fc..9bd0992fcc17d3 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -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 ( From 8def93429ee3759f613c815fbf9a2865d811221c Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Sun, 26 Apr 2020 09:39:18 +0530 Subject: [PATCH 060/179] http2: add type checks for Http2ServerResponse.end Refs: https://github.com/nodejs/node/issues/29829 PR-URL: https://github.com/nodejs/node/pull/33146 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- test/parallel/test-http-outgoing-end-types.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/parallel/test-http-outgoing-end-types.js 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 }); +})); From 0f0720a66556440473efa01d41ab18b57de4f609 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Fri, 22 May 2020 05:48:40 +0530 Subject: [PATCH 061/179] http2: add writable* properties to compat api added writableHighWaterMark, writableLength, and writableFinished properties with test. Refs: https://github.com/nodejs/node/issues/29829 PR-URL: https://github.com/nodejs/node/pull/33506 Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- lib/internal/http2/compat.js | 12 ++++++++ .../test-http2-res-writable-properties.js | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/parallel/test-http2-res-writable-properties.js diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 92e8d38869e53f..6d234b23f93ee7 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) 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(); + })); +})); From 76b06e53c6a54f10c500e0bb27f37ebc2ee28ec0 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 22 May 2020 14:18:21 +0200 Subject: [PATCH 062/179] errors: fully inspect errors on exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes sure errors are fully inspected during exit. That is important to provide as many debugging information to the user as possible. Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33523 Reviewed-By: Michaël Zasso Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- lib/internal/errors.js | 7 ++++++- test/message/assert_throws_stack.out | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 09f76faa6554be..2e9b8244500e56 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; } 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' } From 80782cb2611d72d97fe5758e77df9fba17f52c83 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 22 May 2020 14:17:52 +0200 Subject: [PATCH 063/179] console: remove dead code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This check is always truthy. Thus, it's removed. Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33524 Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Anto Aravinth --- lib/internal/console/constructor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 167f5528de9975..79c42d3b3e6507 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -487,7 +487,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; From d8365bc71e02b869b6da25b73f4e331132eb50be Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 22 May 2020 14:04:51 +0200 Subject: [PATCH 064/179] console: mark special console properties as non-enumerable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes sure internal console properties are not visible during default inspection. They are still visible when inspecting the console with `showHidden` set to `true`. These properties are confusing while working with the REPL and easily show up. Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33524 Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Anto Aravinth --- lib/internal/console/constructor.js | 276 +++++++++++++++------------- 1 file changed, 147 insertions(+), 129 deletions(-) diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 79c42d3b3e6507..ef688ca96eacfa 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -150,68 +150,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 +322,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)); From a9c5b3348c5f64a9ca301b4cc7bef3733809c068 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 22 May 2020 14:02:04 +0200 Subject: [PATCH 065/179] console: name console functions appropriately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current name of most of the global console functions is "bound consoleCall". This is changed to the actual functions name e.g., "log" or "error". Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33524 Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Anto Aravinth --- lib/internal/console/constructor.js | 3 +++ lib/internal/console/global.js | 2 ++ lib/internal/util/inspector.js | 4 ++++ test/parallel/test-console-methods.js | 27 ++++++++++++++++++++-- test/parallel/test-repl.js | 33 +++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index ef688ca96eacfa..8c0d1a887f7ce9 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -131,6 +131,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); 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/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/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-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 = [ From 543605782d6a269c8376bdae6f410dd1e43e97ff Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 24 May 2020 00:24:59 +0200 Subject: [PATCH 066/179] doc: outline when origin is set to unhandledRejection The `uncaughtException` listener's origin argument was ambiguous about unhandled rejections. This should clarify when origin is set to `'unhandledRejection'`. Fixes: https://github.com/nodejs/node/issues/32907 Signed-off-by: Ruben Bridgewater PR-URL: https://github.com/nodejs/node/pull/33530 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- doc/api/process.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 0989d377fbdbd6..53c3ac9aaca4c8 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -231,8 +231,9 @@ changes: * `err` {Error} The uncaught exception. * `origin` {string} Indicates if the exception originates from an unhandled - rejection or from synchronous errors. Can either be `'uncaughtException'` or - `'unhandledRejection'`. + rejection or from an synchronous error. Can either be `'uncaughtException'` or + `'unhandledRejection'`. The latter is only used in conjunction with the + [`--unhandled-rejections`][] flag set to `strict` and an unhandled rejection. The `'uncaughtException'` event is emitted when an uncaught JavaScript exception bubbles all the way back to the event loop. By default, Node.js @@ -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 From 4fcbfdc45c795937f3a50986ed1bc59d5c8dc739 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Sat, 23 May 2020 19:34:40 -0400 Subject: [PATCH 067/179] doc: normalize JavaScript code block info strings Prior to this commit, JavaScript fenced code blocks in Markdown files had inconsistent info strings. This has been corrected to standardize on the one with the highest frequency in the doc/api/ dir. Stats: > 'js' => 1091, > 'javascript' => 2, PR-URL: https://github.com/nodejs/node/pull/33531 Reviewed-By: Ruben Bridgewater Reviewed-By: Zeyu Yang --- doc/api/fs.md | 2 +- doc/api/stream.md | 2 +- doc/guides/writing-tests.md | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 3d384b6d7d111e..bd374ff08b1af5 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -4180,7 +4180,7 @@ recommended. 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); ``` diff --git a/doc/api/stream.md b/doc/api/stream.md index 8d6a3137fff4aa..7d212d7be859d3 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -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. diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md index 385e3813fdbd69..474304a83e517a 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 From a5ce90c46b2563833456380d96d1b97dc69fa996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kacper=20Jagie=C5=82=C5=82o?= Date: Sun, 24 May 2020 14:07:34 +0200 Subject: [PATCH 068/179] build: add --v8-lite-mode flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33541 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Juan José Arboleda Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- configure.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure.py b/configure.py index cdc8922d29a416..2947df6ace826c 100755 --- a/configure.py +++ b/configure.py @@ -635,6 +635,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', @@ -1231,6 +1239,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 From a3b6095db1e22df84256e5ee48aea7fd4c76b1f0 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Sun, 24 May 2020 00:59:13 -0400 Subject: [PATCH 069/179] doc: normalize Markdown code block info strings Prior to this commit, Markdown fenced code blocks in Markdown files had inconsistent info strings. This has been corrected to standardize on the one shown in the CommonMark spec. Refs: https://github.com/commonmark/commonmark-spec/blob/1103710025f340702edcb070be41f9982b6544d5/spec.txt#L131 PR-URL: https://github.com/nodejs/node/pull/33542 Reviewed-By: Ruben Bridgewater Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/guides/releases.md | 2 +- tools/doc/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/releases.md b/doc/guides/releases.md index 9bd0992fcc17d3..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 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 From 8adfb542eb035f3c567fda2c1bfc9aa66eedc454 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 26 Mar 2020 00:22:13 -0400 Subject: [PATCH 070/179] wasi: allow WASI stdio to be configured MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds stdin, stderr, and stdout options to WASI, which allow the stdio streams to be configured. PR-URL: https://github.com/nodejs/node/pull/33544 Reviewed-By: Anna Henningsen Reviewed-By: David Carlier Reviewed-By: Juan José Arboleda Reviewed-By: Zeyu Yang Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/wasi.md | 6 ++++ lib/wasi.js | 9 +++++- src/node_wasi.cc | 15 +++++++--- test/wasi/test-wasi-options-validation.js | 12 ++++++++ test/wasi/test-wasi-stdio.js | 34 +++++++++++++++++++++++ 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 test/wasi/test-wasi-stdio.js diff --git a/doc/api/wasi.md b/doc/api/wasi.md index 23c2182fff8ffd..e9c39d868aa90f 100644 --- a/doc/api/wasi.md +++ b/doc/api/wasi.md @@ -62,6 +62,12 @@ added: v12.16.0 process via the `__wasi_proc_exit()` function. Setting this option to `true` causes `wasi.start()` to return the exit code rather than terminate the process. **Default:** `false`. + * `stdin` {integer} The file descriptor used as standard input in the + WebAssembly application. **Default:** `0`. + * `stdout` {integer} The file descriptor used as standard output in the + WebAssembly application. **Default:** `1`. + * `stderr` {integer} The file descriptor used as standard error in the + WebAssembly application. **Default:** `2`. ### `wasi.start(instance)` + +Create a new resolver. + +* `options` {Object} + * `timeout` {integer} Query timeout in milliseconds, or `-1` to use the + default timeout. + ### `resolver.cancel()` * **Test**: From f534ac06bde0f4452fd33cc24d7f62103535c0f2 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 31 May 2020 15:44:10 -0400 Subject: [PATCH 081/179] meta: fix a typo in the flaky test template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "occasionally" was spelled incorrectly. PR-URL: https://github.com/nodejs/node/pull/33677 Reviewed-By: Ruben Bridgewater Reviewed-By: Zeyu Yang Reviewed-By: Jiawen Geng Reviewed-By: Beth Griggs Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Juan José Arboleda --- .github/ISSUE_TEMPLATE/4-report-a-flaky-test.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md index 25ebd736e193c6..544c9d5f47b0f5 100644 --- a/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md +++ b/.github/ISSUE_TEMPLATE/4-report-a-flaky-test.md @@ -8,9 +8,9 @@ labels: "CI / flaky test" * [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. From 067578a9c36710a875d446a06fb4576f729fdfbd Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 1 Jun 2020 21:37:23 -0400 Subject: [PATCH 084/179] doc: remove shell dollar signs without output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to https://github.com/nodejs/remark-preset-lint-node/pull/94 PR-URL: https://github.com/nodejs/node/pull/33692 Reviewed-By: Michaël Zasso Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- doc/guides/building-node-with-ninja.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/building-node-with-ninja.md b/doc/guides/building-node-with-ninja.md index 1b95b6886792da..5231b73a8cdd6e 100644 --- a/doc/guides/building-node-with-ninja.md +++ b/doc/guides/building-node-with-ninja.md @@ -29,7 +29,7 @@ number of processes to run for [Ninja][] using the environment variable `JOBS`. This will be the equivalent to the `-j` parameter in the regular `make`: ```bash -$ JOBS=12 make +JOBS=12 make ``` ## Producing a debug build @@ -37,7 +37,7 @@ $ JOBS=12 make To create a debug build rather than a release build: ```bash -$ ./configure --ninja --debug && make +./configure --ninja --debug && make ``` [Ninja]: https://ninja-build.org/ From d0a7b9f048ebcff76c09ca0f63a5bb190c9731c2 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 1 Jun 2020 14:36:40 +0200 Subject: [PATCH 085/179] src: remove unnecessary ToLocalChecked call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33683 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: David Carlier Reviewed-By: Benjamin Gruenbaum Reviewed-By: Juan José Arboleda --- src/node_native_module_env.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc index e419b3ab5a7852..9a6ccf99313cf8 100644 --- a/src/node_native_module_env.cc +++ b/src/node_native_module_env.cc @@ -127,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); } } From 63147ba3e7689b4c2359fa088f063cdf01c6604c Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Jun 2020 11:12:38 +0200 Subject: [PATCH 086/179] src: use ToLocal in SafeGetenv This commit replaces the IsEmpty call to use ToLocal instead which allows for the following ToLocalChecked function call to be avoided. PR-URL: https://github.com/nodejs/node/pull/33695 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: David Carlier --- src/node_credentials.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node_credentials.cc b/src/node_credentials.cc index d7be988d978b8a..d552a501726396 100644 --- a/src/node_credentials.cc +++ b/src/node_credentials.cc @@ -44,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; From 8a516707b04baa20cf0766eafe2765d07396305a Mon Sep 17 00:00:00 2001 From: Sagar Jadhav Date: Wed, 3 Jun 2020 18:01:53 +0530 Subject: [PATCH 087/179] test: changed function to arrow function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert callback functions that are anonymous to arrow functions for better readability. PR-URL: https://github.com/nodejs/node/pull/33711 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Juan José Arboleda Reviewed-By: Zeyu Yang --- test/parallel/test-util-promisify.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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))); } { From 8d44c00cba7dbddfdda3a921833be36d324eccea Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 4 Jun 2020 05:41:27 -0700 Subject: [PATCH 088/179] tools: update remark-preset-lint-node from 1.15.0 to 1.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33727 Reviewed-By: Michaël Zasso Reviewed-By: Richard Lau --- BUILDING.md | 2 +- tools/lint-md.js | 11843 +++------------- .../node-lint-md-cli-rollup/package-lock.json | 1125 +- tools/node-lint-md-cli-rollup/package.json | 2 +- 4 files changed, 2042 insertions(+), 10930 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index c0a133768fac7d..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. diff --git a/tools/lint-md.js b/tools/lint-md.js index 5335fafb1e8f6f..f8e54d6d2f3fce 100644 --- a/tools/lint-md.js +++ b/tools/lint-md.js @@ -16744,9 +16744,9 @@ 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], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], "bisque": [255, 228, 196], "black": [0, 0, 0], "blanchedalmond": [255, 235, 205], @@ -16885,9 +16885,9 @@ var colorName$1 = { "turquoise": [64, 224, 208], "violet": [238, 130, 238], "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], "yellowgreen": [154, 205, 50] }; @@ -43488,7 +43488,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.15.1", "unified-args": "^8.0.0" }; const main = "dist/index.js"; @@ -44172,1535 +44172,958 @@ function lintMessageControl() { return remarkMessageControl({name: 'lint', source: 'remark-lint'}) } -var vfileLocation$2 = factory$8; +/** + * An Array.prototype.slice.call(arguments) alternative + * + * @param {Object} args something with a length + * @param {Number} slice + * @param {Number} sliceEnd + * @api public + */ + +var sliced = function (args, slice, sliceEnd) { + var ret = []; + var len = args.length; + + if (0 === len) return ret; -function factory$8(file) { - var contents = indices$2(String(file)); + var start = slice < 0 + ? Math.max(0, slice + len) + : slice || 0; - return { - toPosition: offsetToPositionFactory$2(contents), - toOffset: positionToOffsetFactory$2(contents) + if (sliceEnd !== undefined) { + len = sliceEnd < 0 + ? sliceEnd + len + : sliceEnd; } -} -// Factory to get the line and column-based `position` for `offset` in the bound -// indices. -function offsetToPositionFactory$2(indices) { - return offsetToPosition + while (len-- > start) { + ret[len - start] = args[len]; + } - // Get the line and column-based `position` for `offset` in the bound indices. - function offsetToPosition(offset) { - var index = -1; - var length = indices.length; + return ret; +}; - if (offset < 0) { - return {} +/** + * slice() reference. + */ + +var slice$4 = Array.prototype.slice; + +/** + * 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; } - while (++index < length) { - if (indices[index] > offset) { - return { - line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, - offset: offset - } - } + next(); + + // #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); + }); } - return {} - } -} + function next(err, res) { + var ret; -// Factory to get the `offset` for a line and column-based `position` in the -// bound indices. -function positionToOffsetFactory$2(indices) { - return positionToOffset + // multiple args + if (arguments.length > 2) res = slice$4.call(arguments, 1); - // 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; + // error + if (err) { + try { + ret = gen.throw(err); + } catch (e) { + return exit(e); + } + } - if (!isNaN(line) && !isNaN(column) && line - 1 in indices) { - return (indices[line - 2] || 0) + column - 1 || 0 - } + // ok + if (!err) { + try { + ret = gen.next(res); + } catch (e) { + return exit(e); + } + } - return -1 - } -} + // done + if (ret.done) return exit(null, ret.value); -// Get indices of line-breaks in `value`. -function indices$2(value) { - var result = []; - var index = value.indexOf('\n'); + // normalize + ret.value = toThunk(ret.value, ctx); - while (index !== -1) { - result.push(index + 1); - index = value.indexOf('\n', index + 1); + // 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; + } + + // invalid + next(new TypeError('You may only yield a function, promise, generator, array, or object, ' + + 'but the following was passed: "' + String(ret.value) + '"')); + } } +} - result.push(value.length + 1); +/** + * Convert `obj` into a normalized thunk. + * + * @param {Mixed} obj + * @param {Mixed} ctx + * @return {Function} + * @api private + */ - return result -} +function toThunk(obj, ctx) { -var convert_1$2 = convert$5; + if (isGeneratorFunction(obj)) { + return co(obj.call(ctx)); + } -function convert$5(test) { - if (typeof test === 'string') { - return typeFactory$2(test) + if (isGenerator(obj)) { + return co(obj); } - if (test === null || test === undefined) { - return ok$3 + if (isPromise(obj)) { + return promiseToThunk(obj); } - if (typeof test === 'object') { - return ('length' in test ? anyFactory$2 : matchesFactory$2)(test) + if ('function' == typeof obj) { + return obj; } - if (typeof test === 'function') { - return test + if (isObject$3(obj) || Array.isArray(obj)) { + return objectToThunk.call(ctx, obj); } - throw new Error('Expected function, string, or object as test') + return obj; } -function convertAll$2(tests) { - var results = []; - var length = tests.length; - var index = -1; - - while (++index < length) { - results[index] = convert$5(tests[index]); - } +/** + * Convert an object of yieldables to a thunk. + * + * @param {Object} obj + * @return {Function} + * @api private + */ - return results -} +function objectToThunk(obj){ + var ctx = this; + var isArray = Array.isArray(obj); -// Utility assert each property in `test` is represented in `node`, and each -// values are strictly equal. -function matchesFactory$2(test) { - return matches + 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; - function matches(node) { - var key; + if (!pending) { + setImmediate(function(){ + done(null, results); + }); + return; + } - for (key in test) { - if (node[key] !== test[key]) { - return false + // prepopulate object keys to preserve key ordering + if (!isArray) { + for (var i = 0; i < pending; i++) { + results[keys[i]] = undefined; } } - return true - } -} + for (var i = 0; i < keys.length; i++) { + run(obj[keys[i]], keys[i]); + } -function anyFactory$2(tests) { - var checks = convertAll$2(tests); - var length = checks.length; + function run(fn, key) { + if (finished) return; + try { + fn = toThunk(fn, ctx); - return matches + if ('function' != typeof fn) { + results[key] = fn; + return --pending || done(null, results); + } - function matches() { - var index = -1; + fn.call(ctx, function(err, res){ + if (finished) return; - while (++index < length) { - if (checks[index].apply(this, arguments)) { - return true + if (err) { + finished = true; + return done(err); + } + + results[key] = res; + --pending || done(null, results); + }); + } catch (err) { + finished = true; + done(err); } } - - return false } } -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$2(test) { - return type +/** + * Convert `promise` to a thunk. + * + * @param {Object} promise + * @return {Function} + * @api private + */ - function type(node) { - return Boolean(node && node.type === test) +function promiseToThunk(promise) { + return function(fn){ + promise.then(function(res) { + fn(null, res); + }, fn); } } -// Utility to return true. -function ok$3() { - return true +/** + * Check if `obj` is a promise. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + +function isPromise(obj) { + return obj && 'function' == typeof obj.then; } -var unistUtilVisitParents$2 = visitParents$2; +/** + * 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 + */ -var CONTINUE$4 = true; -var SKIP$4 = 'skip'; -var EXIT$4 = false; +function isGeneratorFunction(obj) { + return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name; +} -visitParents$2.CONTINUE = CONTINUE$4; -visitParents$2.SKIP = SKIP$4; -visitParents$2.EXIT = EXIT$4; +/** + * Check for plain object. + * + * @param {Mixed} val + * @return {Boolean} + * @api private + */ -function visitParents$2(tree, test, visitor, reverse) { - var is; +function isObject$3(val) { + return val && Object == val.constructor; +} - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } +/** + * 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 + */ - is = convert_1$2(test); +function error(err) { + if (!err) return; + setImmediate(function(){ + throw err; + }); +} - one(tree, null, []); +/** + * Module Dependencies + */ - // 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$2(visitor(node, parents)); +var noop$3 = function(){}; - if (result[0] === EXIT$4) { - return result - } - } - if (node.children && result[0] !== SKIP$4) { - subresult = toResult$2(all(node.children, parents.concat(node))); - return subresult[0] === EXIT$4 ? subresult : result - } +/** + * Export `wrapped` + */ - return result - } +var wrapped_1 = wrapped; - // 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; +/** + * Wrap a function to support + * sync, async, and gen functions. + * + * @param {Function} fn + * @return {Function} + * @api public + */ - while (index > min && index < children.length) { - result = one(children[index], index, parents); +function wrapped(fn) { + function wrap() { + var args = sliced(arguments); + var last = args[args.length - 1]; + var ctx = this; - if (result[0] === EXIT$4) { - return result - } + // done + var done = typeof last == 'function' ? args.pop() : noop$3; - index = typeof result[1] === 'number' ? result[1] : index + step; + // nothing + if (!fn) { + return done.apply(ctx, [null].concat(args)); } - } -} -function toResult$2(value) { - if (value !== null && typeof value === 'object' && 'length' in value) { - return value - } + // generator + if (generator(fn)) { + return co_1(fn).apply(ctx, args.concat(done)); + } - if (typeof value === 'number') { - return [CONTINUE$4, value] + // 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 [value] + return wrap; } -var unistUtilVisit$2 = visit$2; +/** + * 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); + } + } +} -var CONTINUE$5 = unistUtilVisitParents$2.CONTINUE; -var SKIP$5 = unistUtilVisitParents$2.SKIP; -var EXIT$5 = unistUtilVisitParents$2.EXIT; +/** + * Is `value` a generator? + * + * @param {Mixed} value + * @return {Boolean} + * @api private + */ -visit$2.CONTINUE = CONTINUE$5; -visit$2.SKIP = SKIP$5; -visit$2.EXIT = EXIT$5; +function generator(value) { + return value + && value.constructor + && 'GeneratorFunction' == value.constructor.name; +} -function visit$2(tree, test, visitor, reverse) { - if (typeof test === 'function' && typeof visitor !== 'function') { - reverse = visitor; - visitor = test; - test = null; - } - unistUtilVisitParents$2(tree, test, overload, reverse); +/** + * Is `value` a promise? + * + * @param {Mixed} value + * @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 promise(value) { + return value && 'function' == typeof value.then; } -var unifiedMessageControl$1 = messageControl$2; +var unifiedLintRule = factory$8; -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 || []; +function factory$8(id, rule) { + var parts = id.split(':'); + var source = parts[0]; + var ruleId = parts[1]; + var fn = wrapped_1(rule); - if (!name) { - throw new Error('Expected `name` in `options`, got `' + name + '`') + /* istanbul ignore if - possibly useful if externalised later. */ + if (!ruleId) { + ruleId = source; + source = null; } - if (!marker) { - throw new Error('Expected `marker` in `options`, got `' + marker + '`') - } - - if (!sources) { - sources = [name]; - } else if (typeof sources === 'string') { - sources = [sources]; - } - - return transformer - - 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); + attacher.displayName = id; - file.messages = file.messages.filter(filter); + return attacher - 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; + function attacher(raw) { + var config = coerce(ruleId, raw); + var severity = config[0]; + var options = config[1]; + var fatal = severity === 2; - if (!mark || mark.name !== name) { - return - } + return severity ? transformer : undefined - 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; + function transformer(tree, file, next) { + var index = file.messages.length; - if (verb !== 'enable' && verb !== 'disable' && verb !== 'ignore') { - file.fail( - 'Unknown keyword `' + - verb + - '`: expected ' + - "`'enable'`, `'disable'`, or `'ignore'`", - mark.node - ); - } + fn(tree, file, options, done); - length = ruleIds.length; - index = -1; + function done(err) { + var messages = file.messages; + var message; - // Apply to all rules. - if (length === 0) { - if (verb === 'ignore') { - toggle(pos, false); - toggle(tail, true); - } else { - toggle(pos, verb === 'enable'); - reset = verb !== 'enable'; + // 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 (_) {} } - } else { - while (++index < length) { - ruleId = ruleIds[index]; - if (isKnown(ruleId, verb, mark.node)) { - toggle(pos, verb === 'enable', ruleId); + while (index < messages.length) { + message = messages[index]; + message.ruleId = ruleId; + message.source = source; + message.fatal = fatal; - if (verb === 'ignore') { - toggle(tail, true, ruleId); - } - } + index++; } - } - } - - 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 - } - - // We only ignore messages if they‘re disabled, *not* when they’re not in - // the document. - if (!message.line) { - message.line = 1; + next(); } + } + } +} - if (!message.column) { - message.column = 1; - } +// Coerce a value to a severity--options tuple. +function coerce(name, value) { + var def = 1; + var result; + var level; - // Check whether the warning is inside a gap. - pos = toOffset(message); + /* 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]; + } - while (gapIndex--) { - if (gaps[gapIndex].start <= pos && gaps[gapIndex].end > pos) { - return false - } - } + level = result[0]; - // Check whether allowed by specific and global states. - return check(message, ranges, ruleId) && check(message, globals) + 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]; } + } - // Helper to check (and possibly warn) if a `ruleId` is unknown. - function isKnown(ruleId, verb, pos) { - var result = known ? known.indexOf(ruleId) !== -1 : true; + if (level < 0 || level > 2) { + throw new Error( + 'Incorrect severity `' + + level + + '` for `' + + name + + '`, ' + + 'expected 0, 1, or 2' + ) + } - if (!result) { - file.message( - 'Unknown rule: cannot ' + verb + " `'" + ruleId + "'`", - pos - ); - } + result[0] = level; - return result - } + return result +} - // Get the latest state of a rule. - // When without `ruleId`, gets global state. - function getState(ruleId) { - var ranges = ruleId ? scope[ruleId] : globals; +var remarkLintFinalNewline = unifiedLintRule('remark-lint:final-newline', finalNewline); - if (ranges && ranges.length !== 0) { - return ranges[ranges.length - 1].state - } +function finalNewline(tree, file) { + var contents = String(file); + var last = contents.length - 1; - if (!ruleId) { - return !reset - } + if (last > -1 && contents.charAt(last) !== '\n') { + file.message('Missing newline character at end of file'); + } +} - if (reset) { - return enable.indexOf(ruleId) !== -1 - } +var pluralize = createCommonjsModule(function (module, exports) { +/* global define */ - return disable.indexOf(ruleId) === -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 = {}; + + /** + * 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'); } - // Handle a rule. - function toggle(pos, state, ruleId) { - var markers = ruleId ? scope[ruleId] : globals; - var previousState; + return rule; + } - if (!markers) { - markers = []; - scope[ruleId] = markers; - } + /** + * 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; - previousState = getState(ruleId); + // Lower cased words. E.g. "hello". + if (word === word.toLowerCase()) return token.toLowerCase(); - if (state !== previousState) { - markers.push({state: state, position: pos}); - } + // Upper cased words. E.g. "WHISKY". + if (word === word.toUpperCase()) return token.toUpperCase(); - // Toggle all known rules. - if (!ruleId) { - for (ruleId in scope) { - toggle(pos, state, ruleId); - } - } + // Title cased words. E.g. "Title". + if (word[0] === word[0].toUpperCase()) { + return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase(); } - // 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; + // Lower cased words. E.g. "test". + return token.toLowerCase(); + } - while (--index > length) { - range = ranges[index]; + /** + * 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] || ''; + }); + } - /* istanbul ignore if - Generated marker. */ - if (!range.position || !range.position.line || !range.position.column) { - continue - } + /** + * 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 ( - range.position.line < message.line || - (range.position.line === message.line && - range.position.column <= message.column) - ) { - return range.state === true - } + if (match === '') { + return restoreCase(word[index - 1], result); } - // The first marker ocurred after the first message, so we check the - // initial state. - if (!id) { - return initial || reset - } + return restoreCase(match, result); + }); + } - return reset ? enable.indexOf(id) !== -1 : disable.indexOf(id) === -1 + /** + * 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; } - } -} -// 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 = []; + var len = rules.length; - // Find all gaps. - unistUtilVisit$2(tree, one); + // Iterate over the sanitization rules and use the first one to match. + while (len--) { + var rule = rules[len]; - // 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)) !== '' - ) { - update(); + if (rule[0].test(word)) return replace(word, rule); + } - update( - tree && tree.position && tree.position.end && tree.position.end.offset - 1 - ); + return word; } - return gaps + /** + * 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(); - function one(node) { - var pos = node.position; + // Check against the keep object map. + if (keepMap.hasOwnProperty(token)) { + return restoreCase(word, token); + } - update(pos && pos.start && pos.start.offset); + // Check against the replacement map for a direct word replacement. + if (replaceMap.hasOwnProperty(token)) { + return restoreCase(word, replaceMap[token]); + } - if (!node.children) { - update(pos && pos.end && pos.end.offset); - } + // Run all the rules against the word. + return sanitizeWord(token, word, rules); + }; } - // Detect a new position. - function update(latest) { - if (latest === null || latest === undefined) { - isGap = true; - return - } - - if (offset >= latest) { - return - } + /** + * Check if a word is part of the map. + */ + function checkWord (replaceMap, keepMap, rules, bool) { + return function (word) { + var token = word.toLowerCase(); - if (isGap) { - gaps.push({start: offset, end: latest}); - isGap = false; - } + if (keepMap.hasOwnProperty(token)) return true; + if (replaceMap.hasOwnProperty(token)) return false; - offset = latest; + return sanitizeWord(token, token, rules) === token; + }; } -} - -function trim$1(value) { - return value.replace(/^\s*|\s*$/g, '') -} - -var remarkMessageControl$1 = messageControl$3; -var test$1 = [ - 'html', // Comments are `html` nodes in mdast. - 'comment' // In MDX, comments have their own node. -]; - -function messageControl$3(options) { - return unifiedMessageControl$1(Object.assign({marker: mdastCommentMarker, test: test$1}, options)) -} + /** + * 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); -var remarkLint$1 = lint$1; + return (inclusive ? count + ' ' : '') + pluralized; + } -// `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); -} + /** + * Pluralize a word. + * + * @type {Function} + */ + pluralize.plural = replaceWord( + irregularSingles, irregularPlurals, pluralRules + ); -function lintMessageControl$1() { - return remarkMessageControl$1({name: 'lint', source: 'remark-lint'}) -} + /** + * Check if a word is plural. + * + * @type {Function} + */ + pluralize.isPlural = checkWord( + irregularSingles, irregularPlurals, pluralRules + ); -/** - * An Array.prototype.slice.call(arguments) alternative - * - * @param {Object} args something with a length - * @param {Number} slice - * @param {Number} sliceEnd - * @api public - */ + /** + * Singularize a word. + * + * @type {Function} + */ + pluralize.singular = replaceWord( + irregularPlurals, irregularSingles, singularRules + ); -var sliced = function (args, slice, sliceEnd) { - var ret = []; - var len = args.length; + /** + * Check if a word is singular. + * + * @type {Function} + */ + pluralize.isSingular = checkWord( + irregularPlurals, irregularSingles, singularRules + ); - if (0 === len) return ret; + /** + * Add a pluralization rule to the collection. + * + * @param {(string|RegExp)} rule + * @param {string} replacement + */ + pluralize.addPluralRule = function (rule, replacement) { + pluralRules.push([sanitizeRule(rule), replacement]); + }; - var start = slice < 0 - ? Math.max(0, slice + len) - : slice || 0; + /** + * 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 (sliceEnd !== undefined) { - len = sliceEnd < 0 - ? sliceEnd + len - : sliceEnd; - } - - while (len-- > start) { - ret[len - start] = args[len]; - } - - return ret; -}; - -/** - * slice() reference. - */ - -var slice$4 = Array.prototype.slice; - -/** - * 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; - } - - next(); - - // #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); - }); - } - - function next(err, res) { - var ret; - - // multiple args - if (arguments.length > 2) res = slice$4.call(arguments, 1); - - // error - if (err) { - try { - ret = gen.throw(err); - } catch (e) { - return exit(e); - } - } - - // ok - if (!err) { - try { - ret = gen.next(res); - } catch (e) { - return exit(e); - } - } - - // 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; - } - - // invalid - next(new TypeError('You may only yield a function, promise, generator, array, or object, ' - + 'but the following was passed: "' + String(ret.value) + '"')); - } - } -} - -/** - * Convert `obj` into a normalized thunk. - * - * @param {Mixed} obj - * @param {Mixed} ctx - * @return {Function} - * @api private - */ - -function toThunk(obj, ctx) { - - if (isGeneratorFunction(obj)) { - return co(obj.call(ctx)); - } - - if (isGenerator(obj)) { - return co(obj); - } - - if (isPromise(obj)) { - return promiseToThunk(obj); - } - - if ('function' == typeof obj) { - return obj; - } - - if (isObject$3(obj) || Array.isArray(obj)) { - return objectToThunk.call(ctx, obj); - } - - return obj; -} - -/** - * Convert an object of yieldables to a thunk. - * - * @param {Object} obj - * @return {Function} - * @api private - */ - -function objectToThunk(obj){ - var ctx = this; - var isArray = Array.isArray(obj); - - 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 (!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 - */ - - -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; -} + /** + * 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]); + }); -/** - * 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; - }; - - /** - * 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]); - }); + /** + * 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]); + }); /** - * 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. @@ -45779,8363 +45202,1700 @@ var pluralize = createCommonjsModule(function (module, exports) { 'rice', 'salmon', 'scissors', - 'series', - 'sewage', - 'shambles', - '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, []); + 'series', + 'sewage', + 'shambles', + '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); - // 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 - } -} + child = children[index]; -// Utility to convert a string into a function which checks a given node’s type -// for said string. -function typeFactory$v(test) { - return type + if (!unistUtilGenerated(child)) { + marker = contents + .slice(start$6(child).offset, start$6(child.children[0]).offset) + .replace(/\s|\d/g, '') + .replace(/\[[x ]?]\s*$/i, ''); - function type(node) { - return Boolean(node && node.type === test) + if (preferred) { + if (marker !== preferred) { + file.message('Marker style should be `' + preferred + '`', child); + } + } else { + preferred = marker; + } + } + } } } -// Utility to return true. -function ok$w() { - return true -} - -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'); + } -var unistUtilVisitParents$z = visitParents$z; + // 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'); +}; + +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 +46916,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 +46936,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 +46956,7 @@ function tableCellPadding(tree, file, option) { ); } - unistUtilVisit$A(tree, 'table', visitor); + unistUtilVisit(tree, 'table', visitor); function visitor(node) { var rows = node.children; @@ -54460,7 +47029,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 +47072,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 +47083,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 +47118,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 +47145,7 @@ function unorderedListMarkerStyle(tree, file, option) { ); } - unistUtilVisit$C(tree, 'list', visitor); + unistUtilVisit(tree, 'list', visitor); function visitor(node) { var children = node.children; diff --git a/tools/node-lint-md-cli-rollup/package-lock.json b/tools/node-lint-md-cli-rollup/package-lock.json index efd36027c65c22..660d0802ca277b 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.15.1", + "resolved": "https://registry.npmjs.org/remark-preset-lint-node/-/remark-preset-lint-node-1.15.1.tgz", + "integrity": "sha512-jRWBKCEkLGObhlgmlth0w78vxLKxvJYnkpqLvkl5AAatytv9kHjc4fN/dfUX2rj1KFYr/xC4KG/MM68gKQNJ0w==", "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..ee03028112bc92 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.15.1", "unified-args": "^8.0.0" }, "main": "dist/index.js", From c3f50e3241b513a12085f8e3066e425245ac3d01 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 09:42:11 -0700 Subject: [PATCH 089/179] doc: remove default parameter value from header In the docs, we specify the default value of function parameters in the list below the header. There is one exception where we use default parameter notation. Change that instance to be like the rest of the docs instead. I rather like the default parameter notation, and I get why we didn't use it to begin with. (The notation didn't exist in JavaScript at the time.) I wouldn't mind switching to it, but that would result in big churn. That can be a separate topic of discussion. For now, though, let's get the docs consistent. PR-URL: https://github.com/nodejs/node/pull/33752 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/api/cluster.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/cluster.md b/doc/api/cluster.md index 320aed644f17c9..dc18eb3e0f9f72 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -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 From 31063f9f859fa5820d925740824cf4234d49ad11 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Wed, 20 May 2020 09:35:59 -0400 Subject: [PATCH 090/179] doc: normalize C++ code block info strings Prior to this commit, C++ fenced code blocks in Markdown files had inconsistent info strings. This has been corrected to standarize on the one with the highest frequency in the doc/api/ dir. Stats: > 'cpp' => 19, > 'C++' => 6, > 'c++' => 3, PR-URL: https://github.com/nodejs/node/pull/33483 Reviewed-By: Luigi Pinca Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api/addons.md | 12 ++++---- doc/api/n-api.md | 10 +++---- doc/guides/cpp-style-guide.md | 28 +++++++++---------- .../investigating_native_memory_leak.md | 2 +- doc/guides/node-postmortem-support.md | 4 +-- doc/guides/writing-tests.md | 2 +- src/README.md | 18 ++++++------ 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 516e22061e80aa..8210c5ba1d7412 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -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); diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 85fb8bcc7a2dc3..841875cc472d76 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -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); @@ -87,7 +87,7 @@ versions: * the Node.js C++ APIs available via any of - ```C++ + ```cpp #include #include #include @@ -96,13 +96,13 @@ 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 ``` diff --git a/doc/guides/cpp-style-guide.md b/doc/guides/cpp-style-guide.md index 32a178ea81256c..85db8e1595aa9c 100644 --- a/doc/guides/cpp-style-guide.md +++ b/doc/guides/cpp-style-guide.md @@ -67,7 +67,7 @@ Comments should also start with uppercase and finish with a dot. Examples: -```c++ +```cpp // A single-line comment. // Multi-line comments @@ -82,14 +82,14 @@ comments. ### 2 spaces of indentation for blocks or bodies of conditionals -```c++ +```cpp if (foo) bar(); ``` or -```c++ +```cpp if (foo) { bar(); baz(); @@ -102,7 +102,7 @@ Braces are optional if the statement body only has one line. ### 4 spaces of indentation for statement continuations -```c++ +```cpp VeryLongTypeName very_long_result = SomeValueWithAVeryLongName + SomeOtherValueWithAVeryLongName; ``` @@ -111,7 +111,7 @@ Operators are before the line break in these cases. ### Align function arguments vertically -```c++ +```cpp void FunctionWithAVeryLongName(int parameter_with_a_very_long_name, double other_parameter_with_a_very_long_name, ...); @@ -119,7 +119,7 @@ void FunctionWithAVeryLongName(int parameter_with_a_very_long_name, If that doesn’t work, break after the `(` and use 4 spaces of indentation: -```c++ +```cpp void FunctionWithAReallyReallyReallyLongNameSeriouslyStopIt( int okay_there_is_no_space_left_in_the_previous_line, ...); @@ -129,7 +129,7 @@ void FunctionWithAReallyReallyReallyLongNameSeriouslyStopIt( Long initialization lists are formatted like this: -```c++ +```cpp HandleWrap::HandleWrap(Environment* env, Local object, uv_handle_t* handle, @@ -144,7 +144,7 @@ HandleWrap::HandleWrap(Environment* env, Exceptions are simple getters/setters, which are named `property_name()` and `set_property_name()`, respectively. -```c++ +```cpp class FooBar { public: void DoSomething(); @@ -157,7 +157,7 @@ class FooBar { ### `snake_case` for local variables and parameters -```c++ +```cpp int FunctionThatDoesSomething(const char* important_string) { const char* pointer_into_string = important_string; } @@ -165,7 +165,7 @@ int FunctionThatDoesSomething(const char* important_string) { ### `snake_case_` for private class fields -```c++ +```cpp class Foo { private: int counter_ = 0; @@ -176,7 +176,7 @@ class Foo { For plain C-like structs snake_case can be used. -```c++ +```cpp struct foo_bar { int name; } @@ -184,7 +184,7 @@ struct foo_bar { ### Space after `template` -```c++ +```cpp template class FancyContainer { ... @@ -232,7 +232,7 @@ Using non-const references often obscures which values are changed by an assignment. Consider using a pointer instead, which requires more explicit syntax to indicate that modifications take place. -```c++ +```cpp class ExampleClass { public: explicit ExampleClass(OtherClass* other_ptr) : pointer_to_other_(other_ptr) {} @@ -269,7 +269,7 @@ When working with typed arrays that involve direct data modification from C++, use an `AliasedBuffer` when possible. The API abstraction and the usage scope of `AliasedBuffer` are documented in [aliased_buffer.h][]. -```c++ +```cpp // Create an AliasedBuffer. AliasedBuffer data; ... diff --git a/doc/guides/investigating_native_memory_leak.md b/doc/guides/investigating_native_memory_leak.md index 366cc2917f6a4c..8e58854007b789 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; 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/writing-tests.md b/doc/guides/writing-tests.md index 474304a83e517a..e441d934113e75 100644 --- a/doc/guides/writing-tests.md +++ b/doc/guides/writing-tests.md @@ -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/src/README.md b/src/README.md index 2e59c51c3c37e9..922bacf9aa5973 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); // ... From 99d34ea61c05d951afc328a4757467620caba9cd Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 29 May 2020 23:28:25 +0200 Subject: [PATCH 091/179] benchmark: fix async-resource benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the benchmark, because it performs asynchronous operations before writing its HTTP replies, the underlying socket can be closed by the peer before the response is written. Since 28e6626ce7020, that means that attempting to `.end()` the HTTP response results in an uncaught exception, breaking the benchmark. Fix that by checking whether the response object has been destroyed or not before attempting to call `.end()`. https://github.com/nodejs/node/issues/33591 PR-URL: https://github.com/nodejs/node/pull/33642 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Juan José Arboleda --- benchmark/async_hooks/async-resource-vs-destroy.js | 2 ++ 1 file changed, 2 insertions(+) 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() })); }); From 1a5ef19b366096158b1a2da742e8bb08112d1e8f Mon Sep 17 00:00:00 2001 From: antsmartian Date: Fri, 29 May 2020 14:35:36 +0530 Subject: [PATCH 092/179] stream: fix the spellings PR-URL: https://github.com/nodejs/node/pull/33635 Reviewed-By: Zeyu Yang Reviewed-By: Matteo Collina Reviewed-By: Robert Nagy Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- lib/_stream_duplex.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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'; From fec56a9a8433361dda22b59dbc4bee93f849cc0c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 10:10:59 -0700 Subject: [PATCH 093/179] doc: change "pre Node.js v0.10" to "prior to Node.js 0.10" The phrasing "pre Node.js v0.10" is not grammatical, as "pre" is not a word. This also changes "Node.js v0.10" to "Node.js 0.10". We dropped use of the "v" prefix in prose some time ago to avoid confusion as to whether "v8" referred to the V8 JavaScript engine or Node.js 8.x. PR-URL: https://github.com/nodejs/node/pull/33754 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau Reviewed-By: Benjamin Gruenbaum Reviewed-By: Trivikram Kamat --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index fa9b96e33bc4d2..c91ebd55e42789 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -3021,7 +3021,7 @@ key may be passed for `key`. ## Notes -### Legacy streams API (prior to Node.js 0.10) +### Legacy Streams API (prior to Node.js 0.10) The Crypto module was added to Node.js before there was the concept of a unified Stream API, and before there were [`Buffer`][] objects for handling From 215325d4e722bca81f5aa058f0d310f81a8ddb93 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 10:44:20 -0700 Subject: [PATCH 094/179] doc: remove "currently" from util.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33756 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michaël Zasso Reviewed-By: Trivikram Kamat --- doc/api/util.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 526e85a4159984..8afe7c735e6d0a 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -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 From 55d84a8efebfd6735f59cfa2818343d1783695c1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 10:45:29 -0700 Subject: [PATCH 095/179] doc: remove "currently" from addons.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33756 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michaël Zasso Reviewed-By: Trivikram Kamat --- doc/api/addons.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 8210c5ba1d7412..9a2b6d1a536359 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -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 @@ -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 From 772d407650922f36a376bbb0e1897c9230361bc8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 10:46:44 -0700 Subject: [PATCH 096/179] doc: remove "currently" from vm.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33756 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michaël Zasso Reviewed-By: Trivikram Kamat --- doc/api/vm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/vm.md b/doc/api/vm.md index 5356eef4c96471..d1eccc3580c92a 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -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 From 43f32e3c761d00cc3ab622735cf2f1575d01aaa3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 10:49:21 -0700 Subject: [PATCH 097/179] doc: remove "currently" from repl.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33756 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michaël Zasso Reviewed-By: Trivikram Kamat --- doc/api/repl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/repl.md b/doc/api/repl.md index 71986c33e07130..c8420720fdc566 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -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: From 2db875c3bc71be54279d50f265f986beab19fe91 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 5 Jun 2020 10:33:27 -0700 Subject: [PATCH 098/179] doc: add formatting for version numbers to doc-style-guide.md PR-URL: https://github.com/nodejs/node/pull/33755 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/guides/doc-style-guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/guides/doc-style-guide.md b/doc/guides/doc-style-guide.md index bb10a852bb5203..286727b42d88f3 100644 --- a/doc/guides/doc-style-guide.md +++ b/doc/guides/doc-style-guide.md @@ -65,6 +65,12 @@ * 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][]. From 6db21cce308a6b67962668c7afc1af53c5c4ff77 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Mon, 8 Jun 2020 04:56:16 +0530 Subject: [PATCH 099/179] doc: fix linting in doc-style-guide.md Disable lint checks (enable prohibited-strings remark-lint) for doc-style-guide.md:66. This was producing lint errors in builds on master. PR-URL: https://github.com/nodejs/node/pull/33787 Reviewed-By: Rich Trott Reviewed-By: Daniel Bevenius --- doc/guides/doc-style-guide.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/guides/doc-style-guide.md b/doc/guides/doc-style-guide.md index 286727b42d88f3..5f076698784e29 100644 --- a/doc/guides/doc-style-guide.md +++ b/doc/guides/doc-style-guide.md @@ -61,14 +61,15 @@ * 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 + 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_ From 7aac9832f2451ce7bc204539a49ee8fd5ab2bcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 30 Jul 2019 07:45:31 +0100 Subject: [PATCH 100/179] fs: close file descriptor of promisified truncate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original PR: PR-URL: https://github.com/nodejs/node/pull/28858 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig PR-URL: https://github.com/nodejs/node/pull/34239 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Gerhard Stöbich --- lib/internal/fs/promises.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { From 8d258c43c3265c2fc5617c740d86ea940e12f722 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 3 Jun 2020 05:54:14 +0200 Subject: [PATCH 101/179] src: use Check() instead of FromJust in environment This commit replaces FromJust() calls with Check() in places where the value that FromJust() returns is not used. PR-URL: https://github.com/nodejs/node/pull/33706 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: David Carlier --- src/api/environment.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index 60cc016b7702a9..5526859e551c10 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -417,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` @@ -428,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__ From 68615a01d1b95a2cc705f16acdab3cd7cb9f023e Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Jun 2020 13:21:40 +0200 Subject: [PATCH 102/179] build: add LINT_CPP_FILES to checkimports check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds the prerequisites which contains all the files to lint. Currently the only the files in 'src' will be checked. PR-URL: https://github.com/nodejs/node/pull/33697 Reviewed-By: Richard Lau Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 934b3253838150..46e3b5b160498f 100644 --- a/Makefile +++ b/Makefile @@ -1328,7 +1328,7 @@ lint-cpp: tools/.cpplintstamp tools/.cpplintstamp: $(LINT_CPP_FILES) @echo "Running C++ linter..." @$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) $? - @$(PYTHON) tools/checkimports.py + @$(PYTHON) tools/checkimports.py $? @touch $@ .PHONY: lint-addon-docs From f458be228c83cb972c99f8f2bf65df0014b01020 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Jun 2020 13:27:45 +0200 Subject: [PATCH 103/179] tools: remove unused using declarations code_cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes the reported unused using declarations from cache_builder.cc PR-URL: https://github.com/nodejs/node/pull/33697 Reviewed-By: Richard Lau Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- tools/code_cache/cache_builder.cc | 3 --- 1 file changed, 3 deletions(-) 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) { From cad115b06ddc95fadff8669494dc8f287b634ef3 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 3 Jun 2020 12:56:58 +0200 Subject: [PATCH 104/179] src,build: add --openssl-default-cipher-list This commit adds a configuration option named openssl-default-cipher-list which takes a colon separated string specifying ciphers that should be used as the default ciphers instead of the ones defined in node_constants. The motivation for this is a use case where Fedora/RHEL would like to be able to specify a default cipher in the format PROFILE=SYSTEM. This would enable Fedora/RHEL to have a system wide security level for all applications. PR-URL: https://github.com/nodejs/node/pull/33708 Refs: https://docs.fedoraproject.org/en-US/packaging-guidelines/CryptoPolicies/ Reviewed-By: David Carlier Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Richard Lau --- configure.py | 10 ++++++++ doc/api/tls.md | 55 +++++++++++++++++++++++--------------------- node.gyp | 6 +++++ src/node_constants.h | 6 ++++- 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/configure.py b/configure.py index 2947df6ace826c..463fa9292e9e5f 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", @@ -1286,6 +1291,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: @@ -1295,6 +1302,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'] diff --git a/doc/api/tls.md b/doc/api/tls.md index 8364ae9517f640..4cba528f3f775f 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -273,33 +273,36 @@ 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: +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. -```text -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: +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 ``` diff --git a/node.gyp b/node.gyp index 281a8f0176db24..68ca0f2c035353 100644 --- a/node.gyp +++ b/node.gyp @@ -736,6 +736,7 @@ 'variables': { 'openssl_system_ca_path%': '', + 'openssl_default_cipher_list%': '', }, 'defines': [ @@ -752,6 +753,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/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 { From 397ff6d901984ee643fd11491971cf8d5fcf1e6f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 5 Jun 2020 14:17:13 +0200 Subject: [PATCH 105/179] src: add "missing" bash completion options Currently, when using the bash completions for node the normal completions for filenames directories do not work. For example, after finding a node completion and then wanting to use tab completion for a filename in the test directory, it is only possible to get the name of the test directory completed, followed by a space. What is expected is to be able to continue with tab completion for directories. This commit adds options to the complete command to enable default bash completions. PR-URL: https://github.com/nodejs/node/pull/33744 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Richard Lau --- src/node_options.cc | 3 ++- test/parallel/test-bash-completion.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node_options.cc b/src/node_options.cc index b7978871f020be..047237a31e37b2 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -833,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/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), From c97c2878110457c5adafe6d60e0cd0cd0ce1f560 Mon Sep 17 00:00:00 2001 From: sapics Date: Thu, 4 Jun 2020 16:08:43 +0900 Subject: [PATCH 106/179] src: simplify Reindent function in json_utils.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33722 Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Zeyu Yang Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Juan José Arboleda --- src/json_utils.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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; } From 69c9233e5f3ad62c58c36ad350f10a0b01180f46 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 5 Jun 2020 14:21:37 -0400 Subject: [PATCH 107/179] doc: update V8 inspector example This commit updates the V8 inspector example to reflect what is currently printed to the console. PR-URL: https://github.com/nodejs/node/pull/33758 Reviewed-By: Anna Henningsen Reviewed-By: Eugene Ostroukhov Reviewed-By: Matheus Marchini Reviewed-By: Trivikram Kamat Reviewed-By: David Carlier --- doc/api/debugger.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/api/debugger.md b/doc/api/debugger.md index 321d7b3755d7b7..8253c176e43c95 100644 --- a/doc/api/debugger.md +++ b/doc/api/debugger.md @@ -185,9 +185,8 @@ flag instead of `--inspect`. ```console $ node --inspect index.js -Debugger listening on 127.0.0.1:9229. -To start debugging, open the following URL in Chrome: - chrome-devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29 +Debugger listening on ws://127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29 +For help, see: https://nodejs.org/en/docs/inspector ``` (In the example above, the UUID dc9010dd-f8b8-4ac5-a510-c1a114ec7d29 From 26d6b2a13aa716bae44ed6b3806befa83b520f08 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 5 Jun 2020 14:22:39 -0400 Subject: [PATCH 108/179] inspector: drop 'chrome-' from inspector url It has been reported that the https://github.com/cjihrig/node-v8-inspector V8 inspector extension can no longer connect DevTools (despite no code changes to the extension since Feb. 2017). Upon investigation, Chrome dropped support for the chrome-devtools: scheme recently. I've confirmed that dropping 'chrome-' from the URL here allows the debugger to function properly with modern Chrome. Refs: https://chromium.googlesource.com/chromium/src/+/6700d12448f76712c62a6d2372a95b97a26d4779 PR-URL: https://github.com/nodejs/node/pull/33758 Reviewed-By: Anna Henningsen Reviewed-By: Eugene Ostroukhov Reviewed-By: Matheus Marchini Reviewed-By: Trivikram Kamat Reviewed-By: David Carlier --- src/inspector_socket_server.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 8149b725d9d261b2204ce8d7c90682edfa1d6b81 Mon Sep 17 00:00:00 2001 From: legendecas Date: Sat, 6 Jun 2020 15:06:21 +0800 Subject: [PATCH 109/179] test: fix invalid regular expressions in case test-trace-exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33769 Fixes: https://github.com/nodejs/node/issues/30516 Reviewed-By: Denys Otrishko Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- test/parallel/test-trace-exit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } } From 7ee0b303d161eb7d231cd7a286c4eb08647e8113 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Mon, 1 Jun 2020 23:09:16 +0200 Subject: [PATCH 110/179] win,msi: add arm64 config for windows msi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds configuration to allow building an MSI installer for Windows ARM64. MSI can be created by running `vcbuild.bat release msi arm64` Refs: https://github.com/nodejs/node/issues/25998 Refs: https://github.com/nodejs/node/issues/32582 PR-URL: https://github.com/nodejs/node/pull/33689 Reviewed-By: João Reis Reviewed-By: Bartosz Sosnowski --- tools/msvs/msi/custom_actions.vcxproj | 76 +++++++++++++++++++++++++++ tools/msvs/msi/nodemsi.sln | 10 ++++ tools/msvs/msi/nodemsi.wixproj | 10 ++++ 3 files changed, 96 insertions(+) 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 From ce0ab705dcfc72a355db8a2c8d627e71c8d5bec5 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 9 Jun 2020 14:28:28 -0400 Subject: [PATCH 111/179] test: temporarily exclude test on arm Refs: https://github.com/nodejs/node/issues/33796 Signed-off-by: Michael Dawson PR-URL: https://github.com/nodejs/node/pull/33814 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- test/parallel/parallel.status | 2 ++ 1 file changed, 2 insertions(+) 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 From 9e5d9d606a8fa4af298fb8b763b9eb170f2e4337 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 21 May 2020 22:05:16 -0400 Subject: [PATCH 112/179] n-api: ensure scope present for finalization Refs: https://github.com/nodejs/node-addon-api/issues/722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson PR-URL: https://github.com/nodejs/node/pull/33508 Reviewed-By: Gabriel Schulhof Reviewed-By: James M Snell --- src/js_native_api_v8.cc | 1 + .../binding.gyp | 8 ++++ .../test.js | 18 +++++++ .../test_worker_terminate_finalization.c | 48 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 test/node-api/test_worker_terminate_finalization/binding.gyp create mode 100644 test/node-api/test_worker_terminate_finalization/test.js create mode 100644 test/node-api/test_worker_terminate_finalization/test_worker_terminate_finalization.c diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index 485c242dce23eb..ec6c5256143ea2 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -267,6 +267,7 @@ class RefBase : protected Finalizer, RefTracker { protected: inline void Finalize(bool is_env_teardown = false) override { if (_finalize_callback != nullptr) { + v8::HandleScope handle_scope(_env->isolate); _env->CallIntoModule([&](napi_env env) { _finalize_callback( env, 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) From ae135bb033ed58cb410efe3504c36875409cb5e6 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Sun, 24 May 2020 12:37:21 -0400 Subject: [PATCH 113/179] doc: fix misc. mislabeled code block info strings Prior to this commit, a handful of misc. code blocks were in need of fixup. Corrections are according to predetermined conventions. Closes: https://github.com/nodejs/node/issues/32938 PR-URL: https://github.com/nodejs/node/pull/33548 Fixes: https://github.com/nodejs/node/issues/32938 Reviewed-By: Rich Trott --- doc/guides/investigating_native_memory_leak.md | 2 +- doc/guides/writing-and-running-benchmarks.md | 4 ++-- src/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/guides/investigating_native_memory_leak.md b/doc/guides/investigating_native_memory_leak.md index 8e58854007b789..f0a156286e3e5f 100644 --- a/doc/guides/investigating_native_memory_leak.md +++ b/doc/guides/investigating_native_memory_leak.md @@ -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/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/src/README.md b/src/README.md index 922bacf9aa5973..563dbe4014cfba 100644 --- a/src/README.md +++ b/src/README.md @@ -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; From f9b551415b864c2f567f60f70f0f3832eadb1b50 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 3 Jun 2020 13:20:48 +0200 Subject: [PATCH 114/179] doc: use single quotes in --tls-cipher-list Currently, running the example code will produce the following error in bash: $ node --tls-cipher-list="ECDHE-RSA-AES128-GCM-SHA256:!RC4" server.js bash: !RC4: event not found This commit changes the two examples to use single quotes to avoid the shell from trying to interpret '!' as the history command. PR-URL: https://github.com/nodejs/node/pull/33709 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- doc/api/tls.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index 4cba528f3f775f..e7b912b35eec6b 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -312,9 +312,9 @@ instance, the following makes `ECDHE-RSA-AES128-GCM-SHA256:!RC4` the default TLS cipher suite: ```bash -node --tls-cipher-list="ECDHE-RSA-AES128-GCM-SHA256:!RC4" server.js +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 ``` From e5218487f5127777a4211347dbb01f2c370fa9e9 Mon Sep 17 00:00:00 2001 From: Andrey Pechkurov Date: Fri, 5 Jun 2020 16:55:01 +0300 Subject: [PATCH 115/179] doc: add snippet for AsyncResource and EE integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33751 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Robert Nagy Reviewed-By: James M Snell Reviewed-By: Denys Otrishko Reviewed-By: Gerhard Stöbich Reviewed-By: Stephen Belanger Reviewed-By: Vladimir de Turckheim --- doc/api/async_hooks.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index b15f8cb92263de..d7182f43f45288 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -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])); @@ -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`

Gold Sponsors

Shopify Salesforce Airbnb

Silver Sponsors

-

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

+

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 00f17678fc66c0..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") { @@ -350,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/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/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/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-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-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-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-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-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/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/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 83ecf69434dafb..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; @@ -1415,7 +1463,7 @@ module.exports = { try { tokens = espree.tokenize(leftValue, espreeOptions); - } catch (e) { + } catch { return false; } @@ -1444,7 +1492,7 @@ module.exports = { try { tokens = espree.tokenize(rightValue, espreeOptions); - } catch (e) { + } catch { return false; } @@ -1538,5 +1586,9 @@ module.exports = { */ hasOctalEscapeSequence(rawString) { return OCTAL_ESCAPE_PATTERN.test(rawString); - } + }, + + isLogicalExpression, + isCoalesceExpression, + isMixedLogicalAndCoalesceExpressions }; 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/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/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 f5d0ed08f0aa90..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.1.0" + "version": "7.2.0" } \ No newline at end of file From 0590c0e4b1c4962cac6d8cde9c017bd12c23d915 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Wed, 20 May 2020 10:58:12 -0400 Subject: [PATCH 121/179] esm: fix loader hooks doc annotations Prior to this commit, the type annotations on the ESM loader hooks were invalid. This has been corrected and is ensured to be compatible with both the TypeScript and Closure type systems. Notes: https://www.typescriptlang.org/play/index.html?useJavaScript=true#code/PQKhCgAIUgBAHAhgJ0QW0gbwM4BdkCWAdgOYC+kArsgDZQwIrpYDyARgFYCmAxrhTwD2RXFwAeuSAAoe1ZFxE0AnpC5p4uJQEp6cJKgyYAYpSJ8CwigBMuAM0SUauAOJdcRwcjSJcu2PNxqImwsAAVkQTQCbC4AHkxIW09vXAAuSDxCUkgyAD4yemBwcXhPSURsJTNE03NhSBI3Dy8fKWoaABpIIRFxXC6be0cXJuSfLSwoSAJbaQBZHwALADpUIitIqQncyAAGZYBWCYTgYEgAZUiubuErAlwLImWpyEhTyGaMq8hPSEQaGiQACqACUADLYAaCL5oa6yPCRSA0QQkAg8RK-GyiLzEYgkDEtXDPV6vd4AQRoAHdEEoQgEgn8iD9OLxJIJZrhFtckl4sDyUulYpk8fkupSufJIJyuC83md+T5piFhNd2VKuRl8HiQsR1ddcIg2DRrobBAA3LjEkn05BMzCy14KtKQADkaEEVkcXBdHVlZAA3FMCqSzgAROxcZBS6EAOQ9lo4IR5fwBP2lUdBEKtNqZgwcTlc7jGuDatC6PVEEgGdnzIyLhK0gbIQA https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540warning_level%2520VERBOSE%250A%252F%252F%2520%2540jscomp_error%2520strictCheckTypes%250A%252F%252F%2520%2540language_out%2520ECMASCRIPT_NEXT%250A%252F%252F%2520%2540checks_only%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F**%250A%2520*%2520%2540param%2520%257Bstring%257D%2520url%250A%2520*%2520%2540param%2520%257BObject%257D%2520context%2520(currently%2520empty)%250A%2520*%2520%2540param%2520%257BFunction%257D%2520defaultGetFormat%250A%2520*%2520%2540returns%2520%257BPromise%253C%257B%2520format%253A%2520string%2520%257D%253E%257D%250A%2520*%252F%250Aexport%2520async%2520function%2520getFormat(url%252C%2520context%252C%2520defaultGetFormat)%2520%257B%250A%2520%2520if%2520(Math.random()%2520%253E%25200.5)%2520%257B%2520%252F%252F%2520Some%2520condition.%250A%2520%2520%2520%2520%252F%252F%2520For%2520some%2520or%2520all%2520URLs%252C%2520do%2520some%2520custom%2520logic%2520for%2520determining%2520format.%250A%2520%2520%2520%2520%252F%252F%2520Always%2520return%2520an%2520object%2520of%2520the%2520form%2520%257Bformat%253A%2520%253Cstring%253E%257D%252C%2520where%2520the%250A%2520%2520%2520%2520%252F%252F%2520format%2520is%2520one%2520of%2520the%2520strings%2520in%2520the%2520table%2520above.%250A%2520%2520%2520%2520return%2520%257B%250A%2520%2520%2520%2520%2520%2520format%253A%2520'module'%252C%250A%2520%2520%2520%2520%257D%253B%250A%2520%2520%257D%250A%2520%2520%252F%252F%2520Defer%2520to%2520Node.js%2520for%2520all%2520other%2520URLs.%250A%2520%2520return%2520defaultGetFormat(url%252C%2520context%252C%2520defaultGetFormat)%253B%250A%257D https://www.typescriptlang.org/play/?useJavaScript=true#code/PQKhCgAIUgBAHAhgJ0QW0gbwM4BdkCWAdgOYC+k28ApgMYEBmB1yUMCK6WmbkfSyakVwBVAEoAZAFyQAhAAo8hUpAA+kAK5EAJtSZFq2gJQAaXn1oB7HQVwFr2GQoCCyVAE8APEuIkAfKa8ZBRWwtQAHri8HKgYmABiWrR21hS6DIgaADa4YtTYllkAbtTRgrgayETYWAoACsiWaATY1J6YmshZMj4qZAFkbMDgEfCWyLiQiNjuRLSQDEkpRJCCBcXUijT0TCwmkKG4Ebj76Zk5eeslRlhQBw6THQJCopKQALyQRNlZkBSfh2OAG47oxIPIALKIXAACwAdKgdE15Dc-JAAAxwgCsNw6wGAkAAyk1qPcbMs4Xc+PjIPFxpQSZB6Ygsr8qHRGMxkNhTpYGWhSbQNHgmpAspYSAR5gx6WtCkVfJS+NSCc4sgB3RDuGrlSorRArSwAIwAVnRJpYGJBYaSZcg4pVupBvPhfH4yErlbqqrdlcrHTJnsJxBJIAB+Kl+r7UdWQENbDm7ZD7IOvCRGOEwwRWqSRv0GWPx9k7LkZrN6Mx+sggviDPhgyHQ+GI7TIm6eDHY3GQGnOIiWG3IMnaWz2IielWQADqMKEBxZWV8kAABmdsrl8vLqMv9japsgSBoBcIarQDZAjaS0JYR7ttHDIABJFawlqRmln1qQWwAchqiG0EcVANAdZyHIoWQ0W16TQaFaBhJdQhHZYWUgUZxlwbAJ1WagKh9NcLk3DYExLPZfSjOFKMBSJKyjJDRwcGQAG1KLhajcDY6xkLHHlIB-EDBwAWno5YfwAXVo2sjBrP47hpAARPQWGtPkADkb2oOETRqO0plZJlB0obZORYLC7m9FYCI3K5NmLEzkzJI4aMgKzLi3aTwDIIA https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540warning_level%2520VERBOSE%250A%252F%252F%2520%2540jscomp_error%2520strictCheckTypes%250A%252F%252F%2520%2540language_out%2520ECMASCRIPT_NEXT%250A%252F%252F%2520%2540checks_only%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F**%250A%2520*%2520%2540param%2520%257Bstring%257D%2520specifier%250A%2520*%2520%2540param%2520%257B%257B%250A%2520*%2520%2520%2520parentURL%253A%2520!(string%2520%257C%2520undefined)%252C%250A%2520*%2520%2520%2520conditions%253A%2520!(Array%253Cstring%253E)%252C%250A%2520*%2520%257D%257D%2520context%250A%2520*%2520%2540param%2520%257BFunction%257D%2520defaultResolve%250A%2520*%2520%2540returns%2520%257B!(Promise%253C%257B%2520url%253A%2520string%2520%257D%253E)%257D%250A%2520*%252F%250Aexport%2520async%2520function%2520resolve(specifier%252C%2520context%252C%2520defaultResolve)%2520%257B%250A%2520%2520const%2520%257B%2520parentURL%2520%253D%2520null%2520%257D%2520%253D%2520context%253B%250A%2520%2520if%2520(Math.random()%2520%253E%25200.5)%2520%257B%2520%252F%252F%2520Some%2520condition.%250A%2520%2520%2520%2520%252F%252F%2520For%2520some%2520or%2520all%2520specifiers%252C%2520do%2520some%2520custom%2520logic%2520for%2520resolving.%250A%2520%2520%2520%2520%252F%252F%2520Always%2520return%2520an%2520object%2520of%2520the%2520form%2520%257Burl%253A%2520%253Cstring%253E%257D.%250A%2520%2520%2520%2520return%2520%257B%250A%2520%2520%2520%2520%2520%2520url%253A%2520parentURL%2520%253F%250A%2520%2520%2520%2520%2520%2520%2520%2520new%2520URL(specifier%252C%2520parentURL).href%2520%253A%250A%2520%2520%2520%2520%2520%2520%2520%2520new%2520URL(specifier).href%252C%250A%2520%2520%2520%2520%257D%253B%250A%2520%2520%257D%250A%2520%2520if%2520(Math.random()%2520%253C%25200.5)%2520%257B%2520%252F%252F%2520Another%2520condition.%250A%2520%2520%2520%2520%252F%252F%2520When%2520calling%2520%2560defaultResolve%2560%252C%2520the%2520arguments%2520can%2520be%2520modified.%2520In%2520this%250A%2520%2520%2520%2520%252F%252F%2520case%2520it's%2520adding%2520another%2520value%2520for%2520matching%2520conditional%2520exports.%250A%2520%2520%2520%2520return%2520defaultResolve(specifier%252C%2520%257B%250A%2520%2520%2520%2520%2520%2520...context%252C%250A%2520%2520%2520%2520%2520%2520conditions%253A%2520%255B...context.conditions%252C%2520'another-condition'%255D%252C%250A%2520%2520%2520%2520%257D)%253B%250A%2520%2520%257D%250A%2520%2520%252F%252F%2520Defer%2520to%2520Node.js%2520for%2520all%2520other%2520specifiers.%250A%2520%2520return%2520defaultResolve(specifier%252C%2520context%252C%2520defaultResolve)%253B%250A%257D https://www.typescriptlang.org/play/?useJavaScript=true#code/PQKhCgAIUgBAHAhgJ0QW0gbwM4BdkCWAdgOYC+kArsgDZQwIrpaaQBmA9smorgFyQ8hUpDIUAxhyK4ApgA9c9OElQZMAMUpFxuAlIoATGW0SUauAOIzcAZQ7VxMpbGTXqRbFgAKyDmgLYMgA8rNj2yI4CAIQAFDYAFigyBgCCyKgAngBClGxsMsiQAD6C+MQkxZAAqsS4ABxpmQCUogB8ZPTA4PLwXLiQiNgZ2uxaOnpEkCTWdg4yMdQ0ADSQktLyuCtGJmaWM+GOLZhQq1J4WOxcPP0UALyn6woA3CcEbJAxALK88QB0qEQDH4Yi1WpAAAy-ACsR0gwGAkDsaBkDwMBF0Ul+J0gcIR6i4gj8KIJiBoNGqACUADLYLYcQnI1aUPB+SA0DgkAjiS6FVxlGQAN3KkFw8RRYTmWJxOPhkBSNAA7ogMp4+e4BpMOAAjABWMh0kA471FKM43CwEoiMgEQSE5SKWty+WQ7Sl0rVyEmx2l0stkUgAHJfsGA0tsaIXjiOjKEQARYwFEX0gByHCMvx1njNAzJhpNhSq1Owbo9k22pnMVlsB3mixWa1kCi2xgre2rcyaLzIQA https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540warning_level%2520VERBOSE%250A%252F%252F%2520%2540jscomp_error%2520strictCheckTypes%250A%252F%252F%2520%2540language_out%2520ECMASCRIPT_NEXT%250A%252F%252F%2520%2540checks_only%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F**%250A%2520*%2520%2540param%2520%257Bstring%257D%2520url%250A%2520*%2520%2540param%2520%257B%257B%2520format%253A%2520string%2520%257D%257D%2520context%250A%2520*%2520%2540param%2520%257BFunction%257D%2520defaultGetSource%250A%2520*%2520%2540returns%2520%257BPromise%253C%257B%2520source%253A%2520!(SharedArrayBuffer%2520%257C%2520string%2520%257C%2520Uint8Array)%2520%257D%253E%257D%250A%2520*%252F%250Aexport%2520async%2520function%2520getSource(url%252C%2520context%252C%2520defaultGetSource)%2520%257B%250A%2520%2520const%2520%257B%2520format%2520%257D%2520%253D%2520context%253B%250A%2520%2520if%2520(Math.random()%2520%253E%25200.5)%2520%257B%2520%252F%252F%2520Some%2520condition.%250A%2520%2520%2520%2520%252F%252F%2520For%2520some%2520or%2520all%2520URLs%252C%2520do%2520some%2520custom%2520logic%2520for%2520retrieving%2520the%2520source.%250A%2520%2520%2520%2520%252F%252F%2520Always%2520return%2520an%2520object%2520of%2520the%2520form%2520%257Bsource%253A%2520%253Cstring%257Cbuffer%253E%257D.%250A%2520%2520%2520%2520return%2520%257B%250A%2520%2520%2520%2520%2520%2520source%253A%2520'...'%252C%250A%2520%2520%2520%2520%257D%253B%250A%2520%2520%257D%250A%2520%2520%252F%252F%2520Defer%2520to%2520Node.js%2520for%2520all%2520other%2520URLs.%250A%2520%2520return%2520defaultGetSource(url%252C%2520context%252C%2520defaultGetSource)%253B%250A%257D https://www.typescriptlang.org/play/?useJavaScript=true#code/PQKhCgAIUgBAHAhgJ0QW0gbwIQAoDKAFigKYAmAgsqgJ4BCArgGZMnKQA+kAzgC7IBLAHYBzTpACqw3gA4qtAJQBfHgHsGyAMYkoMBCnRZMuyKY0AbAFw9+wkQBoTppquRpEva30GjH0SEoqmqpCvCQAHrwm+qgYmABiDEKavAIhKmQkTIgM5rwAKqhC3C5u+OpaOv6wyCS8GsVYAArIqmgC3CQAPJhqGtrWeESklNSI9Mys7FzeduJSoXJjNAoBAHxKusDgEfCuvJCI3DTJkExJKWlCkPyIxaVo5f0kuNwV2vaQwaERvJ+Z2VyBSKJVcj3eJFWxlM3z4WEgFk+Dw8AUgAF4viEwpEANxQSACJiQXAAWQ8hAAdEUyG1cKs1pAAAwUgCsUMgwGAkHKaBImKEZAEqRCFPxpk5kHirjUvMg0sQ5nMkgASgAZbj-VQyvmaBh8NqQcyqEQCTRnaVoVSCpg0Oa8Qh8t7PUWmcVcijmADu424kFq9WQ1zucoARgArEgpOVE+18h5YJ2VaxdWaiDghyZsDYu13+hpYMWuxMDSAAcgpFdLfldSjxpk2bsgABEsmwblqAHJWkgUsO+0qHRVy2PsYskbg5vOByAAnJ5Qp3UFlCGvCGfb7Yv4zrJz4GLh5PSoKPFKIA https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540warning_level%2520VERBOSE%250A%252F%252F%2520%2540jscomp_error%2520strictCheckTypes%250A%252F%252F%2520%2540language_out%2520ECMASCRIPT_NEXT%250A%252F%252F%2520%2540checks_only%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F**%250A%2520*%2520%2540param%2520%257B!(SharedArrayBuffer%2520%257C%2520string%2520%257C%2520Uint8Array)%257D%2520source%250A%2520*%2520%2540param%2520%257B%257B%250A%2520*%2520%2520%2520url%253A%2520string%252C%250A%2520*%2520%2520%2520format%253A%2520string%252C%250A%2520*%2520%257D%257D%2520context%250A%2520*%2520%2540param%2520%257BFunction%257D%2520defaultTransformSource%250A%2520*%2520%2540returns%2520%257BPromise%253C%257B%2520source%253A%2520!(SharedArrayBuffer%2520%257C%2520string%2520%257C%2520Uint8Array)%2520%257D%253E%257D%250A%2520*%252F%250Aexport%2520async%2520function%2520transformSource(source%252C%2520context%252C%2520defaultTransformSource)%2520%257B%250A%2520%2520const%2520%257B%2520url%252C%2520format%2520%257D%2520%253D%2520context%253B%250A%2520%2520if%2520(Math.random()%2520%253E%25200.5)%2520%257B%2520%252F%252F%2520Some%2520condition.%250A%2520%2520%2520%2520%252F%252F%2520For%2520some%2520or%2520all%2520URLs%252C%2520do%2520some%2520custom%2520logic%2520for%2520modifying%2520the%2520source.%250A%2520%2520%2520%2520%252F%252F%2520Always%2520return%2520an%2520object%2520of%2520the%2520form%2520%257Bsource%253A%2520%253Cstring%257Cbuffer%253E%257D.%250A%2520%2520%2520%2520return%2520%257B%250A%2520%2520%2520%2520%2520%2520source%253A%2520'...'%252C%250A%2520%2520%2520%2520%257D%253B%250A%2520%2520%257D%250A%2520%2520%252F%252F%2520Defer%2520to%2520Node.js%2520for%2520all%2520other%2520sources.%250A%2520%2520return%2520defaultTransformSource(source%252C%2520context%252C%2520defaultTransformSource)%253B%250A%257D PR-URL: https://github.com/nodejs/node/pull/33563 Co-authored-by: Geoffrey Booth Reviewed-By: Geoffrey Booth --- doc/api/esm.md | 73 +++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 8f70b9c7cb5ea4..d5c1a66bccc0c3 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -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, @@ -1195,18 +1196,17 @@ 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. @@ -1226,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. @@ -1265,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); } ``` From 6840aef6ed80a2d7bb762d27eaa0be95ef05628c Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 10 Jun 2020 08:16:16 +0200 Subject: [PATCH 122/179] doc: move --force-context-aware option in cli.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit moves the --force-context-aware option so that the options list is in alphabetical order. PR-URL: https://github.com/nodejs/node/pull/33823 Reviewed-By: Michaël Zasso Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- doc/api/cli.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index b0db6464312113..27ab46d5553ac5 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -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` From 9a1f98b02f1fbd47481598a3baad8c02c7a2e100 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Jun 2020 19:46:47 -0700 Subject: [PATCH 144/179] doc: change "GitHub Repo" to "Code repository" "GitHub Repo & Issue Tracker" changed to "Code repository and issue tracker". PR-URL: https://github.com/nodejs/node/pull/33985 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Gus Caplan Reviewed-By: Myles Borins --- doc/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/index.md b/doc/api/index.md index 63bce05108cf95..c1abf7e7ba3fc4 100644 --- a/doc/api/index.md +++ b/doc/api/index.md @@ -63,4 +63,4 @@
-* [GitHub Repo & Issue Tracker](https://github.com/nodejs/node) +* [Code repository and issue tracker](https://github.com/nodejs/node) From 56722feaa8bc70d30793f81128cb7211c9e1385d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Jun 2020 21:15:40 -0700 Subject: [PATCH 145/179] doc: fix lexical sorting of bottom-references in dns doc The links are sorted in lexical order except for the two RFC links which are reversed. Fix that. PR-URL: https://github.com/nodejs/node/pull/33987 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- doc/api/dns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/dns.md b/doc/api/dns.md index 85e6a213db2969..b84c8298f070b0 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -1199,6 +1199,6 @@ uses. For instance, _they do not use the configuration from `/etc/hosts`_. [DNS error codes]: #dns_error_codes [Domain Name System (DNS)]: https://en.wikipedia.org/wiki/Domain_Name_System [Implementation considerations section]: #dns_implementation_considerations -[RFC 8482]: https://tools.ietf.org/html/rfc8482 [RFC 5952]: https://tools.ietf.org/html/rfc5952#section-6 +[RFC 8482]: https://tools.ietf.org/html/rfc8482 [supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags From 8046c8b5ca2f792d43d277988ad8efbc4d0ece57 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 17 Jun 2020 11:11:09 +0200 Subject: [PATCH 146/179] build: add target specific build_type variable This commit add a target specific variable named 'build_type' to the node and node_g targets. The motivation for doing this is that both targets share the same prerequisites, and the recepies are the same (apart from the build type) so some duplication can be avoided. PR-URL: https://github.com/nodejs/node/pull/33925 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 46e3b5b160498f..32a8a6c2dca732 100644 --- a/Makefile +++ b/Makefile @@ -98,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) From 070cedbce80837362414efb5ba1b2108a1b25752 Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Fri, 12 Jun 2020 13:25:04 +0200 Subject: [PATCH 147/179] doc: warn that tls.connect() doesn't set SNI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: https://github.com/nodejs/node/pull/33855 Fixes: https://github.com/nodejs/node/issues/28167 Co-authored-by: Denys Otrishko Reviewed-By: Robert Nagy Reviewed-By: Denys Otrishko Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- doc/api/tls.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/tls.md b/doc/api/tls.md index e7b912b35eec6b..128da2c10b377d 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1392,6 +1392,12 @@ The `callback` function, if specified, will be added as a listener for the `tls.connect()` returns a [`tls.TLSSocket`][] object. +Unlike the `https` API, `tls.connect()` does not enable the +SNI (Server Name Indication) extension by default, which may cause some +servers to return an incorrect certificate or reject the connection +altogether. To enable SNI, set the `servername` option in addition +to `host`. + The following illustrates a client for the echo server example from [`tls.createServer()`][]: From 37692b5f60164dce06e857109458d5006d3c493a Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sat, 20 Jun 2020 00:51:30 +0800 Subject: [PATCH 148/179] src: improve indention for upd_wrap.cc PR-URL: https://github.com/nodejs/node/pull/33976 Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- src/udp_wrap.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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"); } } From eb4b1d6111b7022afa0dcbe17ebf79944c062430 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sat, 20 Jun 2020 00:57:27 +0800 Subject: [PATCH 149/179] test: fix typo in common/index.js PR-URL: https://github.com/nodejs/node/pull/33976 Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- test/common/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index 34deea094c535d..5fe949b330bef2 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'); From f205b5fa323138f5ed508d38b1645c9ce26f6ad6 Mon Sep 17 00:00:00 2001 From: Shakil-Shahadat Date: Wed, 10 Jun 2020 06:15:31 +0600 Subject: [PATCH 150/179] doc: update fs.md First class heading is made to look like other headings. PR-URL: https://github.com/nodejs/node/pull/33820 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 452bdcad058f01..53e9caa498afc7 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -284,7 +284,7 @@ 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` From a4e4222aa91b8072402b351839ac51dd2ed6a79f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Jun 2020 21:10:50 -0700 Subject: [PATCH 151/179] doc: revise text in dns module documentation introduction PR-URL: https://github.com/nodejs/node/pull/33986 Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/api/dns.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/api/dns.md b/doc/api/dns.md index b84c8298f070b0..b395d0acec4cea 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'); From 4291b11b9ffe1cb73ef33ba51cb1fc0326651f2b Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 18 Jun 2020 14:38:04 -0700 Subject: [PATCH 152/179] test: account for non-node basename PR-URL: https://github.com/nodejs/node/pull/33952 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/message/eval_messages.out | 4 ++-- test/message/stdin_messages.out | 4 ++-- test/message/throw_error_with_getter_throw.out | 2 +- test/message/throw_null.out | 2 +- test/message/throw_undefined.out | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) 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) From aa9badf916b39c00e015777b196b8cd154e4ae38 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 20 Jun 2020 16:46:33 -0700 Subject: [PATCH 153/179] doc: use a single space between sentences We mostly have a single space between the punctuation that ends a sentence and the start of the next sentence. Change instances with two spaces to one. PR-URL: https://github.com/nodejs/node/pull/33995 Reviewed-By: Matheus Marchini Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- doc/api/buffer.md | 2 +- doc/api/child_process.md | 6 +++--- doc/api/crypto.md | 2 +- doc/api/fs.md | 6 +++--- doc/api/modules.md | 14 +++++++------- doc/api/n-api.md | 2 +- doc/api/net.md | 2 +- doc/api/process.md | 2 +- doc/api/readline.md | 6 +++--- doc/api/stream.md | 2 +- doc/api/tls.md | 20 ++++++++++---------- doc/api/util.md | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 675a5981745975..9f0b7a391688d9 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -2700,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 e272c7004c1e2d..f09768573e3142 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -347,7 +347,7 @@ 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`. @@ -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 @@ -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 diff --git a/doc/api/crypto.md b/doc/api/crypto.md index c91ebd55e42789..3076bdaa5e5028 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -2060,7 +2060,7 @@ added: v0.1.92 * `options` {Object} [`stream.Writable` options][] * Returns: {Sign} -Creates and returns a `Sign` object that uses the given `algorithm`. Use +Creates and returns a `Sign` object that uses the given `algorithm`. Use [`crypto.getHashes()`][] to obtain the names of the available digest algorithms. Optional `options` argument controls the `stream.Writable` behavior. diff --git a/doc/api/fs.md b/doc/api/fs.md index 53e9caa498afc7..f477138bbdc01c 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -3594,14 +3594,14 @@ changes: * `err` {Error} Asynchronous symlink(2) which creates the link called `path` pointing to -`target`. No arguments other than a possible exception are given to the +`target`. No arguments other than a possible exception are given to the completion callback. The `type` argument is only available on Windows and ignored on other platforms. It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not exist, `'file'` will be used. Windows junction points -require the destination path to be absolute. When using `'junction'`, the +require the destination path to be absolute. When using `'junction'`, the `target` argument will automatically be normalized to absolute path. Relative targets are relative to the link’s parent directory. @@ -4200,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'`. diff --git a/doc/api/modules.md b/doc/api/modules.md index 2517c2132102f0..7cb5de8c4589e2 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -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, @@ -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" ``` diff --git a/doc/api/n-api.md b/doc/api/n-api.md index f8ae7f00d8922b..9a8103ce585ef5 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -646,7 +646,7 @@ typedef void (*napi_async_execute_callback)(napi_env env, void* data); Implementations of this function must avoid making N-API calls that execute JavaScript or interact with -JavaScript objects. N-API +JavaScript objects. N-API calls should be in the `napi_async_complete_callback` instead. Do not use the `napi_env` parameter as it will likely result in execution of JavaScript. diff --git a/doc/api/net.md b/doc/api/net.md index b2d60d1ede6456..2b427b3de77139 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -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/process.md b/doc/api/process.md index 53c3ac9aaca4c8..2fb0b77f7df702 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -554,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., diff --git a/doc/api/readline.md b/doc/api/readline.md index 8cbaf362d5dc03..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])` diff --git a/doc/api/stream.md b/doc/api/stream.md index 81e32f607fac79..b8c864c7913cd0 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -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'`. diff --git a/doc/api/tls.md b/doc/api/tls.md index 128da2c10b377d..41f99c91c852b0 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -325,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. @@ -768,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 @@ -1610,11 +1610,11 @@ changes: [OpenSSL Options][]. * `secureProtocol` {string} Legacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and - maximum version, and does not support limiting the protocol to TLSv1.3. Use - `minVersion` and `maxVersion` instead. The possible values are listed as - [SSL_METHODS][], use the function names as strings. For example, use + maximum version, and does not support limiting the protocol to TLSv1.3. Use + `minVersion` and `maxVersion` instead. The possible values are listed as + [SSL_METHODS][], use the function names as strings. For example, use `'TLSv1_1_method'` to force TLS version 1.1, or `'TLS_method'` to allow any - TLS protocol version up to TLSv1.3. It is not recommended to use TLS + TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability. **Default:** none, see `minVersion`. * `sessionIdContext` {string} Opaque identifier used by servers to ensure @@ -1812,7 +1812,7 @@ added: v11.4.0 [`tls.createSecureContext()`][]. It can be assigned any of the supported TLS protocol versions, `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. **Default:** `'TLSv1.3'`, unless changed using CLI options. Using - `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets + `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used. diff --git a/doc/api/util.md b/doc/api/util.md index 8afe7c735e6d0a..85a4a5782e1952 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1262,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 From 4b1f0729d3b8a1d2fecbdae6adc00c44de8cc020 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 20 Jun 2020 18:03:52 -0700 Subject: [PATCH 154/179] doc: correct default values in http2 docs The http2 docs include invalid JavaScript values as defaults for three options. The intention was increased clarity, but we specify valid values everywhere else in our docs, so let's do that for consistency. PR-URL: https://github.com/nodejs/node/pull/33997 Reviewed-By: Anna Henningsen Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- doc/api/http2.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index d4da077cd9da22..b22fc04c40c140 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -2443,15 +2443,15 @@ properties. * `headerTableSize` {number} Specifies the maximum number of bytes used for header compression. The minimum allowed value is 0. The maximum allowed value - is 232-1. **Default:** `4,096 octets`. + is 232-1. **Default:** `4096`. * `enablePush` {boolean} Specifies `true` if HTTP/2 Push Streams are to be permitted on the `Http2Session` instances. **Default:** `true`. -* `initialWindowSize` {number} Specifies the *senders* initial window size - for stream-level flow control. The minimum allowed value is 0. The maximum - allowed value is 232-1. **Default:** `65,535 bytes`. -* `maxFrameSize` {number} Specifies the size of the largest frame payload. - The minimum allowed value is 16,384. The maximum allowed value - is 224-1. **Default:** `16,384 bytes`. +* `initialWindowSize` {number} Specifies the *sender's* initial window size in + bytes for stream-level flow control. The minimum allowed value is 0. The + maximum allowed value is 232-1. **Default:** `65535`. +* `maxFrameSize` {number} Specifies the size in bytes of the largest frame + payload. The minimum allowed value is 16,384. The maximum allowed value is + 224-1. **Default:** `16384`. * `maxConcurrentStreams` {number} Specifies the maximum number of concurrent streams permitted on an `Http2Session`. There is no default value which implies, at least theoretically, 232-1 streams may be open From fb1548299e9c4dcc7331a22c12dda8b93d01387d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 20 Jun 2020 21:31:24 -0700 Subject: [PATCH 155/179] doc: use npm team for npm upgrades in collaborator guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The collaborator guide suggests pinging individuals about npm upgrades. Change to pinging the npm team instead. PR-URL: https://github.com/nodejs/node/pull/33999 Reviewed-By: Anna Henningsen Reviewed-By: Gerhard Stöbich Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Andrey Pechkurov --- doc/guides/collaborator-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/guides/collaborator-guide.md b/doc/guides/collaborator-guide.md index 14de2a0c253b3b..fb03df4740bd20 100644 --- a/doc/guides/collaborator-guide.md +++ b/doc/guides/collaborator-guide.md @@ -745,7 +745,7 @@ may impact an LTS release. | upgrading c-ares | @rvagg | | upgrading http-parser | @nodejs/http, @nodejs/http2 | | upgrading libuv | @nodejs/libuv | -| upgrading npm | @fishrock123, @MylesBorins | +| upgrading npm | @nodejs/npm | | upgrading V8 | @nodejs/V8, @nodejs/post-mortem | | Embedded use or delivery of Node.js | @nodejs/delivery-channels | From c0febb593ce9bb48b879c22e15bd8553d73d299e Mon Sep 17 00:00:00 2001 From: legendecas Date: Sun, 14 Jun 2020 15:44:19 +0800 Subject: [PATCH 156/179] doc: clarify thread-safe function references PR-URL: https://github.com/nodejs/node/pull/33871 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Gabriel Schulhof --- doc/api/n-api.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 9a8103ce585ef5..23262c853fcf41 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -5095,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, @@ -5123,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 @@ -5142,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 @@ -5162,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 @@ -5169,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