@@ -288,12 +288,12 @@ VFileMessage.prototype.source = null;
288288VFileMessage.prototype.ruleId = null;
289289VFileMessage.prototype.position = null;
290290
291- function isUrl(fileURLOrPath ) {
291+ function isUrl(fileUrlOrPath ) {
292292 return (
293- fileURLOrPath !== null &&
294- typeof fileURLOrPath === 'object' &&
295- fileURLOrPath .href &&
296- fileURLOrPath .origin
293+ fileUrlOrPath !== null &&
294+ typeof fileUrlOrPath === 'object' &&
295+ fileUrlOrPath .href &&
296+ fileUrlOrPath .origin
297297 )
298298}
299299
@@ -303,7 +303,7 @@ class VFile {
303303 let options;
304304 if (!value) {
305305 options = {};
306- } else if (typeof value === 'string' || isBuffer (value)) {
306+ } else if (typeof value === 'string' || buffer (value)) {
307307 options = {value};
308308 } else if (isUrl(value)) {
309309 options = {path: value};
@@ -321,13 +321,19 @@ class VFile {
321321 let index = -1;
322322 while (++index < order.length) {
323323 const prop = order[index];
324- if (prop in options && options[prop] !== undefined) {
324+ if (
325+ prop in options &&
326+ options[prop] !== undefined &&
327+ options[prop] !== null
328+ ) {
325329 this[prop] = prop === 'history' ? [...options[prop]] : options[prop];
326330 }
327331 }
328332 let prop;
329333 for (prop in options) {
330- if (!order.includes(prop)) this[prop] = options[prop];
334+ if (!order.includes(prop)) {
335+ this[prop] = options[prop];
336+ }
331337 }
332338 }
333339 get path() {
@@ -384,7 +390,7 @@ class VFile {
384390 this.path = path$1.join(this.dirname || '', stem + (this.extname || ''));
385391 }
386392 toString(encoding) {
387- return (this.value || '').toString(encoding)
393+ return (this.value || '').toString(encoding || undefined )
388394 }
389395 message(reason, place, origin) {
390396 const message = new VFileMessage(reason, place, origin);
@@ -424,6 +430,9 @@ function assertPath(path, name) {
424430 throw new Error('Setting `' + name + '` requires `path` to be set too')
425431 }
426432}
433+ function buffer(value) {
434+ return isBuffer(value)
435+ }
427436
428437const unified = base().freeze();
429438const own$7 = {}.hasOwnProperty;
@@ -11573,22 +11582,26 @@ function remarkGfm(options = {}) {
1157311582}
1157411583
1157511584function location(file) {
11576- var value = String(file);
11577- var indices = [];
11578- var search = /\r?\n|\r/g;
11585+ const value = String(file);
11586+ const indices = [];
11587+ const search = /\r?\n|\r/g;
1157911588 while (search.test(value)) {
1158011589 indices.push(search.lastIndex);
1158111590 }
1158211591 indices.push(value.length + 1);
1158311592 return {toPoint, toOffset}
1158411593 function toPoint(offset) {
11585- var index = -1;
11586- if (offset > -1 && offset < indices[indices.length - 1]) {
11594+ let index = -1;
11595+ if (
11596+ typeof offset === 'number' &&
11597+ offset > -1 &&
11598+ offset < indices[indices.length - 1]
11599+ ) {
1158711600 while (++index < indices.length) {
1158811601 if (indices[index] > offset) {
1158911602 return {
1159011603 line: index + 1,
11591- column: offset - (indices[index - 1] || 0) + 1,
11604+ column: offset - (index > 0 ? indices[index - 1] : 0) + 1,
1159211605 offset
1159311606 }
1159411607 }
@@ -11597,19 +11610,21 @@ function location(file) {
1159711610 return {line: undefined, column: undefined, offset: undefined}
1159811611 }
1159911612 function toOffset(point) {
11600- var line = point && point.line;
11601- var column = point && point.column;
11602- var offset;
11613+ const line = point && point.line;
11614+ const column = point && point.column;
1160311615 if (
1160411616 typeof line === 'number' &&
1160511617 typeof column === 'number' &&
1160611618 !Number.isNaN(line) &&
1160711619 !Number.isNaN(column) &&
1160811620 line - 1 in indices
1160911621 ) {
11610- offset = (indices[line - 2] || 0) + column - 1 || 0;
11622+ const offset = (indices[line - 2] || 0) + column - 1 || 0;
11623+ if (offset > -1 && offset < indices[indices.length - 1]) {
11624+ return offset
11625+ }
1161111626 }
11612- return offset > -1 && offset < indices[indices.length - 1] ? offset : -1
11627+ return -1
1161311628 }
1161411629}
1161511630
@@ -20792,13 +20807,16 @@ const settings = {
2079220807};
2079320808const remarkPresetLintNode = { plugins, settings };
2079420809
20795- function toVFile(options ) {
20796- if (typeof options === 'string' || options instanceof URL$1) {
20797- options = {path: options };
20798- } else if (isBuffer(options )) {
20799- options = {path: String(options )};
20810+ function toVFile(description ) {
20811+ if (typeof description === 'string' || description instanceof URL$1) {
20812+ description = {path: description };
20813+ } else if (isBuffer(description )) {
20814+ description = {path: String(description )};
2080020815 }
20801- return looksLikeAVFile(options) ? options : new VFile(options)
20816+ return looksLikeAVFile(description)
20817+ ? description
20818+ :
20819+ new VFile(description || undefined)
2080220820}
2080320821function readSync(description, options) {
2080420822 const file = toVFile(description);
@@ -20830,7 +20848,8 @@ const read =
2083020848 try {
2083120849 fp = path$1.resolve(file.cwd, file.path);
2083220850 } catch (error) {
20833- return reject(error)
20851+ const exception = (error);
20852+ return reject(exception)
2083420853 }
2083520854 fs.readFile(fp, options, done);
2083620855 function done(error, result) {
@@ -20864,12 +20883,13 @@ const write =
2086420883 try {
2086520884 fp = path$1.resolve(file.cwd, file.path);
2086620885 } catch (error) {
20867- return reject(error)
20886+ const exception = (error);
20887+ return reject(exception, null)
2086820888 }
20869- fs.writeFile(fp, file.value || '', options, done);
20889+ fs.writeFile(fp, file.value || '', options || null , done);
2087020890 function done(error) {
2087120891 if (error) {
20872- reject(error);
20892+ reject(error, null );
2087320893 } else {
2087420894 resolve(file);
2087520895 }
@@ -20878,11 +20898,11 @@ const write =
2087820898 }
2087920899 );
2088020900function looksLikeAVFile(value) {
20881- return (
20901+ return Boolean (
2088220902 value &&
20883- typeof value === 'object' &&
20884- 'message' in value &&
20885- 'messages' in value
20903+ typeof value === 'object' &&
20904+ 'message' in value &&
20905+ 'messages' in value
2088620906 )
2088720907}
2088820908toVFile.readSync = readSync;
@@ -21259,7 +21279,7 @@ function stringWidth(string, options = {}) {
2125921279}
2126021280
2126121281function statistics(value) {
21262- var result = {true: 0, false: 0, null: 0};
21282+ const result = {true: 0, false: 0, null: 0};
2126321283 if (value) {
2126421284 if (Array.isArray(value)) {
2126521285 list(value);
@@ -21275,22 +21295,25 @@ function statistics(value) {
2127521295 total: result.true + result.false + result.null
2127621296 }
2127721297 function list(value) {
21278- var index = -1;
21298+ let index = -1;
2127921299 while (++index < value.length) {
2128021300 one(value[index]);
2128121301 }
2128221302 }
2128321303 function one(value) {
2128421304 if ('messages' in value) return list(value.messages)
21285- result[
21286- value.fatal === undefined || value.fatal === null
21287- ? null
21288- : Boolean(value.fatal)
21289- ]++;
21305+ const field = (
21306+ String(
21307+ value.fatal === undefined || value.fatal === null
21308+ ? null
21309+ : Boolean(value.fatal)
21310+ )
21311+ );
21312+ result[field]++;
2129021313 }
2129121314}
2129221315
21293- var severities = {true: 2, false: 1, null: 0, undefined: 0};
21316+ const severities = {true: 2, false: 1, null: 0, undefined: 0};
2129421317function sort(file) {
2129521318 file.messages.sort(comparator);
2129621319 return file
@@ -21299,18 +21322,18 @@ function comparator(a, b) {
2129921322 return (
2130021323 check(a, b, 'line') ||
2130121324 check(a, b, 'column') ||
21302- severities[b.fatal] - severities[a.fatal] ||
21325+ severities[String( b.fatal) ] - severities[String( a.fatal) ] ||
2130321326 compare(a, b, 'source') ||
2130421327 compare(a, b, 'ruleId') ||
2130521328 compare(a, b, 'reason') ||
2130621329 0
2130721330 )
2130821331}
21309- function check(a, b, property ) {
21310- return (a[property ] || 0) - (b[property ] || 0)
21332+ function check(a, b, field ) {
21333+ return (a[field ] || 0) - (b[field ] || 0)
2131121334}
21312- function compare(a, b, property ) {
21313- return String(a[property ] || '').localeCompare(b[property ] || '')
21335+ function compare(a, b, field ) {
21336+ return String(a[field ] || '').localeCompare(b[field ] || '')
2131421337}
2131521338
2131621339function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
0 commit comments