From 678b8f53c1a1d0934719630538c061c841eb68f4 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 12 Feb 2023 17:32:18 +0100 Subject: [PATCH] tools: update lint-md-dependencies to rollup@3.15.0 to-vfile@7.2.4 PR-URL: https://github.com/nodejs/node/pull/46623 Reviewed-By: Moshe Atlow Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Colin Ihrig --- tools/lint-md/lint-md.mjs | 117 +++++++++++++++++++------------- tools/lint-md/package-lock.json | 92 +++++++++++++------------ tools/lint-md/package.json | 4 +- 3 files changed, 120 insertions(+), 93 deletions(-) diff --git a/tools/lint-md/lint-md.mjs b/tools/lint-md/lint-md.mjs index 71c00df6abc121..fb8f0deb277c6f 100644 --- a/tools/lint-md/lint-md.mjs +++ b/tools/lint-md/lint-md.mjs @@ -288,12 +288,12 @@ VFileMessage.prototype.source = null; VFileMessage.prototype.ruleId = null; VFileMessage.prototype.position = null; -function isUrl(fileURLOrPath) { +function isUrl(fileUrlOrPath) { return ( - fileURLOrPath !== null && - typeof fileURLOrPath === 'object' && - fileURLOrPath.href && - fileURLOrPath.origin + fileUrlOrPath !== null && + typeof fileUrlOrPath === 'object' && + fileUrlOrPath.href && + fileUrlOrPath.origin ) } @@ -303,7 +303,7 @@ class VFile { let options; if (!value) { options = {}; - } else if (typeof value === 'string' || isBuffer(value)) { + } else if (typeof value === 'string' || buffer(value)) { options = {value}; } else if (isUrl(value)) { options = {path: value}; @@ -321,13 +321,19 @@ class VFile { let index = -1; while (++index < order.length) { const prop = order[index]; - if (prop in options && options[prop] !== undefined) { + if ( + prop in options && + options[prop] !== undefined && + options[prop] !== null + ) { this[prop] = prop === 'history' ? [...options[prop]] : options[prop]; } } let prop; for (prop in options) { - if (!order.includes(prop)) this[prop] = options[prop]; + if (!order.includes(prop)) { + this[prop] = options[prop]; + } } } get path() { @@ -384,7 +390,7 @@ class VFile { this.path = path$1.join(this.dirname || '', stem + (this.extname || '')); } toString(encoding) { - return (this.value || '').toString(encoding) + return (this.value || '').toString(encoding || undefined) } message(reason, place, origin) { const message = new VFileMessage(reason, place, origin); @@ -424,6 +430,9 @@ function assertPath(path, name) { throw new Error('Setting `' + name + '` requires `path` to be set too') } } +function buffer(value) { + return isBuffer(value) +} const unified = base().freeze(); const own$7 = {}.hasOwnProperty; @@ -11573,22 +11582,26 @@ function remarkGfm(options = {}) { } function location(file) { - var value = String(file); - var indices = []; - var search = /\r?\n|\r/g; + const value = String(file); + const indices = []; + const search = /\r?\n|\r/g; while (search.test(value)) { indices.push(search.lastIndex); } indices.push(value.length + 1); return {toPoint, toOffset} function toPoint(offset) { - var index = -1; - if (offset > -1 && offset < indices[indices.length - 1]) { + let index = -1; + if ( + typeof offset === 'number' && + offset > -1 && + offset < indices[indices.length - 1] + ) { while (++index < indices.length) { if (indices[index] > offset) { return { line: index + 1, - column: offset - (indices[index - 1] || 0) + 1, + column: offset - (index > 0 ? indices[index - 1] : 0) + 1, offset } } @@ -11597,9 +11610,8 @@ function location(file) { return {line: undefined, column: undefined, offset: undefined} } function toOffset(point) { - var line = point && point.line; - var column = point && point.column; - var offset; + const line = point && point.line; + const column = point && point.column; if ( typeof line === 'number' && typeof column === 'number' && @@ -11607,9 +11619,12 @@ function location(file) { !Number.isNaN(column) && line - 1 in indices ) { - offset = (indices[line - 2] || 0) + column - 1 || 0; + const offset = (indices[line - 2] || 0) + column - 1 || 0; + if (offset > -1 && offset < indices[indices.length - 1]) { + return offset + } } - return offset > -1 && offset < indices[indices.length - 1] ? offset : -1 + return -1 } } @@ -20792,13 +20807,16 @@ const settings = { }; const remarkPresetLintNode = { plugins, settings }; -function toVFile(options) { - if (typeof options === 'string' || options instanceof URL$1) { - options = {path: options}; - } else if (isBuffer(options)) { - options = {path: String(options)}; +function toVFile(description) { + if (typeof description === 'string' || description instanceof URL$1) { + description = {path: description}; + } else if (isBuffer(description)) { + description = {path: String(description)}; } - return looksLikeAVFile(options) ? options : new VFile(options) + return looksLikeAVFile(description) + ? description + : + new VFile(description || undefined) } function readSync(description, options) { const file = toVFile(description); @@ -20830,7 +20848,8 @@ const read = try { fp = path$1.resolve(file.cwd, file.path); } catch (error) { - return reject(error) + const exception = (error); + return reject(exception) } fs.readFile(fp, options, done); function done(error, result) { @@ -20864,12 +20883,13 @@ const write = try { fp = path$1.resolve(file.cwd, file.path); } catch (error) { - return reject(error) + const exception = (error); + return reject(exception, null) } - fs.writeFile(fp, file.value || '', options, done); + fs.writeFile(fp, file.value || '', options || null, done); function done(error) { if (error) { - reject(error); + reject(error, null); } else { resolve(file); } @@ -20878,11 +20898,11 @@ const write = } ); function looksLikeAVFile(value) { - return ( + return Boolean( value && - typeof value === 'object' && - 'message' in value && - 'messages' in value + typeof value === 'object' && + 'message' in value && + 'messages' in value ) } toVFile.readSync = readSync; @@ -21259,7 +21279,7 @@ function stringWidth(string, options = {}) { } function statistics(value) { - var result = {true: 0, false: 0, null: 0}; + const result = {true: 0, false: 0, null: 0}; if (value) { if (Array.isArray(value)) { list(value); @@ -21275,22 +21295,25 @@ function statistics(value) { total: result.true + result.false + result.null } function list(value) { - var index = -1; + let index = -1; while (++index < value.length) { one(value[index]); } } function one(value) { if ('messages' in value) return list(value.messages) - result[ - value.fatal === undefined || value.fatal === null - ? null - : Boolean(value.fatal) - ]++; + const field = ( + String( + value.fatal === undefined || value.fatal === null + ? null + : Boolean(value.fatal) + ) + ); + result[field]++; } } -var severities = {true: 2, false: 1, null: 0, undefined: 0}; +const severities = {true: 2, false: 1, null: 0, undefined: 0}; function sort(file) { file.messages.sort(comparator); return file @@ -21299,18 +21322,18 @@ function comparator(a, b) { return ( check(a, b, 'line') || check(a, b, 'column') || - severities[b.fatal] - severities[a.fatal] || + severities[String(b.fatal)] - severities[String(a.fatal)] || compare(a, b, 'source') || compare(a, b, 'ruleId') || compare(a, b, 'reason') || 0 ) } -function check(a, b, property) { - return (a[property] || 0) - (b[property] || 0) +function check(a, b, field) { + return (a[field] || 0) - (b[field] || 0) } -function compare(a, b, property) { - return String(a[property] || '').localeCompare(b[property] || '') +function compare(a, b, field) { + return String(a[field] || '').localeCompare(b[field] || '') } function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) { diff --git a/tools/lint-md/package-lock.json b/tools/lint-md/package-lock.json index 29ac8d9d548bee..3de4fe59500393 100644 --- a/tools/lint-md/package-lock.json +++ b/tools/lint-md/package-lock.json @@ -11,14 +11,14 @@ "remark-parse": "^10.0.1", "remark-preset-lint-node": "^3.4.0", "remark-stringify": "^10.0.2", - "to-vfile": "^7.2.3", + "to-vfile": "^7.2.4", "unified": "^10.1.2", "vfile-reporter": "^7.0.5" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-node-resolve": "^15.0.1", - "rollup": "^3.14.0", + "rollup": "^3.15.0", "rollup-plugin-cleanup": "^3.2.1" } }, @@ -2232,9 +2232,9 @@ } }, "node_modules/rollup": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.14.0.tgz", - "integrity": "sha512-o23sdgCLcLSe3zIplT9nQ1+r97okuaiR+vmAPZPTDYB7/f3tgWIYNyiQveMsZwshBT0is4eGax/HH83Q7CG+/Q==", + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.15.0.tgz", + "integrity": "sha512-F9hrCAhnp5/zx/7HYmftvsNBkMfLfk/dXUh73hPSM2E3CRgap65orDNJbLetoiUFwSAk6iHPLvBrZ5iHYvzqsg==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -2378,9 +2378,9 @@ } }, "node_modules/to-vfile": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-7.2.3.tgz", - "integrity": "sha512-QO0A9aE6Z/YkmQadJ0syxpmNXtcQiu0qAtCKYKD5cS3EfgfFTAXfgLX6AOaBrSfWSek5nfsMf3gBZ9KGVFcLuw==", + "version": "7.2.4", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-7.2.4.tgz", + "integrity": "sha512-2eQ+rJ2qGbyw3senPI0qjuM7aut8IYXK6AEoOWb+fJx/mQYzviTckm1wDjq91QYHAPBTYzmdJXxMFA6Mk14mdw==", "dependencies": { "is-buffer": "^2.0.0", "vfile": "^5.1.0" @@ -2563,9 +2563,9 @@ } }, "node_modules/vfile": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.6.tgz", - "integrity": "sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==", + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.7.tgz", + "integrity": "sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==", "dependencies": { "@types/unist": "^2.0.0", "is-buffer": "^2.0.0", @@ -2578,9 +2578,9 @@ } }, "node_modules/vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.1.0.tgz", + "integrity": "sha512-YF23YMyASIIJXpktBa4vIGLJ5Gs88UB/XePgqPmTa7cDA+JeO3yclbpheQYCHjVHBn/yePzrXuygIL+xbvRYHw==", "dependencies": { "@types/unist": "^2.0.0", "vfile": "^5.0.0" @@ -2591,9 +2591,9 @@ } }, "node_modules/vfile-message": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.3.tgz", - "integrity": "sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.4.tgz", + "integrity": "sha512-fa0Z6P8HUrQN4BZaX05SIVXic+7kE3b05PWAtPuYP9QLHsLKYR7/AlLW3NtOrpXRLeawpDLMsVkmk5DG0NXgWw==", "dependencies": { "@types/unist": "^2.0.0", "unist-util-stringify-position": "^3.0.0" @@ -2623,10 +2623,11 @@ } }, "node_modules/vfile-sort": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-3.0.0.tgz", - "integrity": "sha512-fJNctnuMi3l4ikTVcKpxTbzHeCgvDhnI44amA3NVDvA6rTC6oKCFpCVyT5n2fFMr3ebfr+WVQZedOCd73rzSxg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-3.0.1.tgz", + "integrity": "sha512-1os1733XY6y0D5x0ugqSeaVJm9lYgj0j5qdcZQFyxlZOSy1jYarL77lLyb5gK4Wqr1d5OxmuyflSO3zKyFnTFw==", "dependencies": { + "vfile": "^5.0.0", "vfile-message": "^3.0.0" }, "funding": { @@ -2635,10 +2636,11 @@ } }, "node_modules/vfile-statistics": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-2.0.0.tgz", - "integrity": "sha512-foOWtcnJhKN9M2+20AOTlWi2dxNfAoeNIoxD5GXcO182UJyId4QrXa41fWrgcfV3FWTjdEDy3I4cpLVcQscIMA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-2.0.1.tgz", + "integrity": "sha512-W6dkECZmP32EG/l+dp2jCLdYzmnDBIw6jwiLZSER81oR5AHRcVqL+k3Z+pfH1R73le6ayDkJRMk0sutj1bMVeg==", "dependencies": { + "vfile": "^5.0.0", "vfile-message": "^3.0.0" }, "funding": { @@ -4227,9 +4229,9 @@ } }, "rollup": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.14.0.tgz", - "integrity": "sha512-o23sdgCLcLSe3zIplT9nQ1+r97okuaiR+vmAPZPTDYB7/f3tgWIYNyiQveMsZwshBT0is4eGax/HH83Q7CG+/Q==", + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.15.0.tgz", + "integrity": "sha512-F9hrCAhnp5/zx/7HYmftvsNBkMfLfk/dXUh73hPSM2E3CRgap65orDNJbLetoiUFwSAk6iHPLvBrZ5iHYvzqsg==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -4325,9 +4327,9 @@ "dev": true }, "to-vfile": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-7.2.3.tgz", - "integrity": "sha512-QO0A9aE6Z/YkmQadJ0syxpmNXtcQiu0qAtCKYKD5cS3EfgfFTAXfgLX6AOaBrSfWSek5nfsMf3gBZ9KGVFcLuw==", + "version": "7.2.4", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-7.2.4.tgz", + "integrity": "sha512-2eQ+rJ2qGbyw3senPI0qjuM7aut8IYXK6AEoOWb+fJx/mQYzviTckm1wDjq91QYHAPBTYzmdJXxMFA6Mk14mdw==", "requires": { "is-buffer": "^2.0.0", "vfile": "^5.1.0" @@ -4454,9 +4456,9 @@ } }, "vfile": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.6.tgz", - "integrity": "sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==", + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.7.tgz", + "integrity": "sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==", "requires": { "@types/unist": "^2.0.0", "is-buffer": "^2.0.0", @@ -4465,18 +4467,18 @@ } }, "vfile-location": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz", - "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.1.0.tgz", + "integrity": "sha512-YF23YMyASIIJXpktBa4vIGLJ5Gs88UB/XePgqPmTa7cDA+JeO3yclbpheQYCHjVHBn/yePzrXuygIL+xbvRYHw==", "requires": { "@types/unist": "^2.0.0", "vfile": "^5.0.0" } }, "vfile-message": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.3.tgz", - "integrity": "sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.4.tgz", + "integrity": "sha512-fa0Z6P8HUrQN4BZaX05SIVXic+7kE3b05PWAtPuYP9QLHsLKYR7/AlLW3NtOrpXRLeawpDLMsVkmk5DG0NXgWw==", "requires": { "@types/unist": "^2.0.0", "unist-util-stringify-position": "^3.0.0" @@ -4498,18 +4500,20 @@ } }, "vfile-sort": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-3.0.0.tgz", - "integrity": "sha512-fJNctnuMi3l4ikTVcKpxTbzHeCgvDhnI44amA3NVDvA6rTC6oKCFpCVyT5n2fFMr3ebfr+WVQZedOCd73rzSxg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-3.0.1.tgz", + "integrity": "sha512-1os1733XY6y0D5x0ugqSeaVJm9lYgj0j5qdcZQFyxlZOSy1jYarL77lLyb5gK4Wqr1d5OxmuyflSO3zKyFnTFw==", "requires": { + "vfile": "^5.0.0", "vfile-message": "^3.0.0" } }, "vfile-statistics": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-2.0.0.tgz", - "integrity": "sha512-foOWtcnJhKN9M2+20AOTlWi2dxNfAoeNIoxD5GXcO182UJyId4QrXa41fWrgcfV3FWTjdEDy3I4cpLVcQscIMA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-2.0.1.tgz", + "integrity": "sha512-W6dkECZmP32EG/l+dp2jCLdYzmnDBIw6jwiLZSER81oR5AHRcVqL+k3Z+pfH1R73le6ayDkJRMk0sutj1bMVeg==", "requires": { + "vfile": "^5.0.0", "vfile-message": "^3.0.0" } }, diff --git a/tools/lint-md/package.json b/tools/lint-md/package.json index de6d48e54dd26b..cee5774f7b7b4d 100644 --- a/tools/lint-md/package.json +++ b/tools/lint-md/package.json @@ -9,14 +9,14 @@ "remark-parse": "^10.0.1", "remark-preset-lint-node": "^3.4.0", "remark-stringify": "^10.0.2", - "to-vfile": "^7.2.3", + "to-vfile": "^7.2.4", "unified": "^10.1.2", "vfile-reporter": "^7.0.5" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-node-resolve": "^15.0.1", - "rollup": "^3.14.0", + "rollup": "^3.15.0", "rollup-plugin-cleanup": "^3.2.1" } }