From b1f2ff1242144465eb332121b890bdad10f87737 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sat, 8 Apr 2023 00:58:25 +0100 Subject: [PATCH] tools: update lint-md-dependencies to @rollup/plugin-node-resolve@15.0.2 PR-URL: https://github.com/nodejs/node/pull/47431 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Rafael Gonzaga --- tools/lint-md/lint-md.mjs | 188 ++++++++++++++++---------------- tools/lint-md/package-lock.json | 48 ++++---- tools/lint-md/package.json | 2 +- 3 files changed, 119 insertions(+), 119 deletions(-) diff --git a/tools/lint-md/lint-md.mjs b/tools/lint-md/lint-md.mjs index 88d51374547d21..71c6c50368b99b 100644 --- a/tools/lint-md/lint-md.mjs +++ b/tools/lint-md/lint-md.mjs @@ -738,28 +738,39 @@ function looksLikeAVFileValue(value) { return typeof value === 'string' || isBuffer(value) } +const emptyOptions = {}; function toString(value, options) { - const includeImageAlt = (options || {}).includeImageAlt; - return one( - value, - typeof includeImageAlt === 'boolean' ? includeImageAlt : true - ) + const settings = options || emptyOptions; + const includeImageAlt = + typeof settings.includeImageAlt === 'boolean' + ? settings.includeImageAlt + : true; + const includeHtml = + typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true; + return one(value, includeImageAlt, includeHtml) } -function one(value, includeImageAlt) { - return ( - (node(value) && - (('value' in value && value.value) || - (includeImageAlt && 'alt' in value && value.alt) || - ('children' in value && all(value.children, includeImageAlt)))) || - (Array.isArray(value) && all(value, includeImageAlt)) || - '' - ) +function one(value, includeImageAlt, includeHtml) { + if (node(value)) { + if ('value' in value) { + return value.type === 'html' && !includeHtml ? '' : value.value + } + if (includeImageAlt && 'alt' in value && value.alt) { + return value.alt + } + if ('children' in value) { + return all(value.children, includeImageAlt, includeHtml) + } + } + if (Array.isArray(value)) { + return all(value, includeImageAlt, includeHtml) + } + return '' } -function all(values, includeImageAlt) { +function all(values, includeImageAlt, includeHtml) { const result = []; let index = -1; while (++index < values.length) { - result[index] = one(values[index], includeImageAlt); + result[index] = one(values[index], includeImageAlt, includeHtml); } return result.join('') } @@ -9827,7 +9838,7 @@ function tokenizePotentialGfmFootnoteCall(effects, ok, nok) { end: self.now() }) ); - if (id.charCodeAt(0) !== 94 || !defined.includes(id.slice(1))) { + if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) { return nok(code) } effects.enter('gfmFootnoteCallLabelMarker'); @@ -9915,24 +9926,32 @@ function tokenizeGfmFootnoteCall(effects, ok, nok) { return callData } function callData(code) { - let token; - if (code === null || code === 91 || size++ > 999) { + if ( + size > 999 || + (code === 93 && !data) || + code === null || + code === 91 || + markdownLineEndingOrSpace(code) + ) { return nok(code) } if (code === 93) { - if (!data) { + effects.exit('chunkString'); + const token = effects.exit('gfmFootnoteCallString'); + if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) { return nok(code) } - effects.exit('chunkString'); - token = effects.exit('gfmFootnoteCallString'); - return defined.includes(normalizeIdentifier(self.sliceSerialize(token))) - ? end(code) - : nok(code) + effects.enter('gfmFootnoteCallLabelMarker'); + effects.consume(code); + effects.exit('gfmFootnoteCallLabelMarker'); + effects.exit('gfmFootnoteCall'); + return ok } - effects.consume(code); if (!markdownLineEndingOrSpace(code)) { data = true; } + size++; + effects.consume(code); return code === 92 ? callEscape : callData } function callEscape(code) { @@ -9943,13 +9962,6 @@ function tokenizeGfmFootnoteCall(effects, ok, nok) { } return callData(code) } - function end(code) { - effects.enter('gfmFootnoteCallLabelMarker'); - effects.consume(code); - effects.exit('gfmFootnoteCallLabelMarker'); - effects.exit('gfmFootnoteCall'); - return ok - } } function tokenizeDefinitionStart(effects, ok, nok) { const self = this; @@ -9964,28 +9976,32 @@ function tokenizeDefinitionStart(effects, ok, nok) { effects.enter('gfmFootnoteDefinitionLabelMarker'); effects.consume(code); effects.exit('gfmFootnoteDefinitionLabelMarker'); - return labelStart + return labelAtMarker } - function labelStart(code) { + function labelAtMarker(code) { if (code === 94) { effects.enter('gfmFootnoteDefinitionMarker'); effects.consume(code); effects.exit('gfmFootnoteDefinitionMarker'); effects.enter('gfmFootnoteDefinitionLabelString'); - return atBreak + effects.enter('chunkString').contentType = 'string'; + return labelInside } return nok(code) } - function atBreak(code) { - let token; - if (code === null || code === 91 || size > 999) { + function labelInside(code) { + if ( + size > 999 || + (code === 93 && !data) || + code === null || + code === 91 || + markdownLineEndingOrSpace(code) + ) { return nok(code) } if (code === 93) { - if (!data) { - return nok(code) - } - token = effects.exit('gfmFootnoteDefinitionLabelString'); + effects.exit('chunkString'); + const token = effects.exit('gfmFootnoteDefinitionLabelString'); identifier = normalizeIdentifier(self.sliceSerialize(token)); effects.enter('gfmFootnoteDefinitionLabelMarker'); effects.consume(code); @@ -9993,55 +10009,38 @@ function tokenizeDefinitionStart(effects, ok, nok) { effects.exit('gfmFootnoteDefinitionLabel'); return labelAfter } - if (markdownLineEnding(code)) { - effects.enter('lineEnding'); - effects.consume(code); - effects.exit('lineEnding'); - size++; - return atBreak - } - effects.enter('chunkString').contentType = 'string'; - return label(code) - } - function label(code) { - if ( - code === null || - markdownLineEnding(code) || - code === 91 || - code === 93 || - size > 999 - ) { - effects.exit('chunkString'); - return atBreak(code) - } if (!markdownLineEndingOrSpace(code)) { data = true; } size++; effects.consume(code); - return code === 92 ? labelEscape : label + return code === 92 ? labelEscape : labelInside } function labelEscape(code) { if (code === 91 || code === 92 || code === 93) { effects.consume(code); size++; - return label + return labelInside } - return label(code) + return labelInside(code) } function labelAfter(code) { if (code === 58) { effects.enter('definitionMarker'); effects.consume(code); effects.exit('definitionMarker'); - return factorySpace(effects, done, 'gfmFootnoteDefinitionWhitespace') + if (!defined.includes(identifier)) { + defined.push(identifier); + } + return factorySpace( + effects, + whitespaceAfter, + 'gfmFootnoteDefinitionWhitespace' + ) } return nok(code) } - function done(code) { - if (!defined.includes(identifier)) { - defined.push(identifier); - } + function whitespaceAfter(code) { return ok(code) } } @@ -10069,8 +10068,9 @@ function tokenizeIndent(effects, ok, nok) { } } -function gfmStrikethrough(options = {}) { - let single = options.singleTilde; +function gfmStrikethrough(options) { + const options_ = options || {}; + let single = options_.singleTilde; const tokenizer = { tokenize: tokenizeStrikethrough, resolveAll: resolveAllStrikethrough @@ -10124,16 +10124,15 @@ function gfmStrikethrough(options = {}) { ['exit', events[open][1], context], ['enter', text, context] ]; - splice( - nextEvents, - nextEvents.length, - 0, - resolveAll( - context.parser.constructs.insideSpan.null, - events.slice(open + 1, index), - context - ) - ); + const insideSpan = context.parser.constructs.insideSpan.null; + if (insideSpan) { + splice( + nextEvents, + nextEvents.length, + 0, + resolveAll(insideSpan, events.slice(open + 1, index), context) + ); + } splice(nextEvents, nextEvents.length, 0, [ ['exit', text, context], ['enter', events[index][1], context], @@ -10673,29 +10672,30 @@ function tokenizeTasklistCheck(effects, ok, nok) { effects.consume(code); effects.exit('taskListCheckMarker'); effects.exit('taskListCheck'); + return after + } + return nok(code) + } + function after(code) { + if (markdownLineEnding(code)) { + return ok(code) + } + if (markdownSpace(code)) { return effects.check( { tokenize: spaceThenNonSpace }, ok, nok - ) + )(code) } return nok(code) } } function spaceThenNonSpace(effects, ok, nok) { - const self = this; return factorySpace(effects, after, 'whitespace') function after(code) { - const tail = self.events[self.events.length - 1]; - return ( - ((tail && tail[1].type === 'whitespace') || - markdownLineEnding(code)) && - code !== null - ? ok(code) - : nok(code) - ) + return code === null ? nok(code) : ok(code) } } diff --git a/tools/lint-md/package-lock.json b/tools/lint-md/package-lock.json index c5d5039b6af444..16d1ca2da26caa 100644 --- a/tools/lint-md/package-lock.json +++ b/tools/lint-md/package-lock.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", - "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-node-resolve": "^15.0.2", "rollup": "^3.20.2", "rollup-plugin-cleanup": "^3.2.1" } @@ -54,15 +54,15 @@ } }, "node_modules/@rollup/plugin-node-resolve": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.1.tgz", - "integrity": "sha512-ReY88T7JhJjeRVbfCyNj+NXAG3IIsVMsX9b5/9jC98dRP8/yxlZdz7mHZbHk5zHr24wZZICS5AcXsFZAXYUQEg==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.2.tgz", + "integrity": "sha512-Y35fRGUjC3FaurG722uhUuG8YHOJRJQbI6/CkbRkdPotSpDj9NtIN85z1zrcyDcCQIW4qp5mgG72U+gJ0TAFEg==", "dev": true, "dependencies": { "@rollup/pluginutils": "^5.0.1", "@types/resolve": "1.20.2", "deepmerge": "^4.2.2", - "is-builtin-module": "^3.2.0", + "is-builtin-module": "^3.2.1", "is-module": "^1.0.0", "resolve": "^1.22.1" }, @@ -755,9 +755,9 @@ } }, "node_modules/mdast-util-to-string": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.1.tgz", - "integrity": "sha512-tGvhT94e+cVnQt8JWE9/b3cUQZWS732TJxXHktvP+BYo62PpYD53Ls/6cC60rW21dW+txxiM4zMdc6abASvZKA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.2.0.tgz", + "integrity": "sha512-V4Zn/ncyN1QNSqSBxTrMOLpjr+IKdHl2v3KVLoWmDPscP4r9GcCi71gjgvUV1SFSKh92AjAG4peFuBl2/YgCJg==", "dependencies": { "@types/mdast": "^3.0.0" }, @@ -869,9 +869,9 @@ } }, "node_modules/micromark-extension-gfm-footnote": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-1.0.4.tgz", - "integrity": "sha512-E/fmPmDqLiMUP8mLJ8NbJWJ4bTw6tS+FEQS8CcuDtZpILuOb2kjLqPEeAePF1djXROHXChM/wPJw0iS4kHCcIg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-1.1.0.tgz", + "integrity": "sha512-RWYce7j8+c0n7Djzv5NzGEGitNNYO3uj+h/XYMdS/JinH1Go+/Qkomg/rfxExFzYTiydaV6GLeffGO5qcJbMPA==", "dependencies": { "micromark-core-commonmark": "^1.0.0", "micromark-factory-space": "^1.0.0", @@ -888,9 +888,9 @@ } }, "node_modules/micromark-extension-gfm-strikethrough": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-1.0.4.tgz", - "integrity": "sha512-/vjHU/lalmjZCT5xt7CcHVJGq8sYRm80z24qAKXzaHzem/xsDYb2yLL+NNVbYvmpLx3O7SYPuGL5pzusL9CLIQ==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-1.0.5.tgz", + "integrity": "sha512-X0oI5eYYQVARhiNfbETy7BfLSmSilzN1eOuoRnrf9oUNsPRrWOAe9UqSizgw1vNxQBfOwL+n2610S3bYjVNi7w==", "dependencies": { "micromark-util-chunked": "^1.0.0", "micromark-util-classify-character": "^1.0.0", @@ -921,9 +921,9 @@ } }, "node_modules/micromark-extension-gfm-tagfilter": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-1.0.1.tgz", - "integrity": "sha512-Ty6psLAcAjboRa/UKUbbUcwjVAv5plxmpUTy2XC/3nJFL37eHej8jrHrRzkqcpipJliuBH30DTs7+3wqNcQUVA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-1.0.2.tgz", + "integrity": "sha512-5XWB9GbAUSHTn8VPU8/1DBXMuKYT5uOgEjJb8gN3mW0PNW5OPHpSdojoqf+iq1xo7vWzw/P8bAHY0n6ijpXF7g==", "dependencies": { "micromark-util-types": "^1.0.0" }, @@ -933,9 +933,9 @@ } }, "node_modules/micromark-extension-gfm-task-list-item": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-1.0.3.tgz", - "integrity": "sha512-PpysK2S1Q/5VXi72IIapbi/jliaiOFzv7THH4amwXeYXLq3l1uo8/2Be0Ac1rEwK20MQEsGH2ltAZLNY2KI/0Q==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-1.0.4.tgz", + "integrity": "sha512-9XlIUUVnYXHsFF2HZ9jby4h3npfX10S1coXTnV035QGPgrtNYQq3J6IfIvcCIUAJrrqBVi5BqA/LmaOMJqPwMQ==", "dependencies": { "micromark-factory-space": "^1.0.0", "micromark-util-character": "^1.0.0", @@ -2215,12 +2215,12 @@ } }, "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", + "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", "dev": true, "dependencies": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.11.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, diff --git a/tools/lint-md/package.json b/tools/lint-md/package.json index f973bf335b6a3c..0dfb1f9c4a7c8c 100644 --- a/tools/lint-md/package.json +++ b/tools/lint-md/package.json @@ -15,7 +15,7 @@ }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", - "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-node-resolve": "^15.0.2", "rollup": "^3.20.2", "rollup-plugin-cleanup": "^3.2.1" }