Skip to content

Commit

Permalink
tools: update lint-md-dependencies to rollup@3.15.0 to-vfile@7.2.4
Browse files Browse the repository at this point in the history
PR-URL: #46623
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
nodejs-github-bot authored and danielleadams committed Apr 3, 2023
1 parent ee81da5 commit 678b8f5
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 93 deletions.
117 changes: 70 additions & 47 deletions tools/lint-md/lint-md.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand All @@ -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};
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}
Expand All @@ -11597,19 +11610,21 @@ 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' &&
!Number.isNaN(line) &&
!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
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit 678b8f5

Please sign in to comment.