@@ -288,12 +288,12 @@ VFileMessage.prototype.source = null;
288
288
VFileMessage.prototype.ruleId = null;
289
289
VFileMessage.prototype.position = null;
290
290
291
- function isUrl(fileURLOrPath ) {
291
+ function isUrl(fileUrlOrPath ) {
292
292
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
297
297
)
298
298
}
299
299
@@ -303,7 +303,7 @@ class VFile {
303
303
let options;
304
304
if (!value) {
305
305
options = {};
306
- } else if (typeof value === 'string' || isBuffer (value)) {
306
+ } else if (typeof value === 'string' || buffer (value)) {
307
307
options = {value};
308
308
} else if (isUrl(value)) {
309
309
options = {path: value};
@@ -321,13 +321,19 @@ class VFile {
321
321
let index = -1;
322
322
while (++index < order.length) {
323
323
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
+ ) {
325
329
this[prop] = prop === 'history' ? [...options[prop]] : options[prop];
326
330
}
327
331
}
328
332
let prop;
329
333
for (prop in options) {
330
- if (!order.includes(prop)) this[prop] = options[prop];
334
+ if (!order.includes(prop)) {
335
+ this[prop] = options[prop];
336
+ }
331
337
}
332
338
}
333
339
get path() {
@@ -384,7 +390,7 @@ class VFile {
384
390
this.path = path$1.join(this.dirname || '', stem + (this.extname || ''));
385
391
}
386
392
toString(encoding) {
387
- return (this.value || '').toString(encoding)
393
+ return (this.value || '').toString(encoding || undefined )
388
394
}
389
395
message(reason, place, origin) {
390
396
const message = new VFileMessage(reason, place, origin);
@@ -424,6 +430,9 @@ function assertPath(path, name) {
424
430
throw new Error('Setting `' + name + '` requires `path` to be set too')
425
431
}
426
432
}
433
+ function buffer(value) {
434
+ return isBuffer(value)
435
+ }
427
436
428
437
const unified = base().freeze();
429
438
const own$7 = {}.hasOwnProperty;
@@ -11573,22 +11582,26 @@ function remarkGfm(options = {}) {
11573
11582
}
11574
11583
11575
11584
function 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;
11579
11588
while (search.test(value)) {
11580
11589
indices.push(search.lastIndex);
11581
11590
}
11582
11591
indices.push(value.length + 1);
11583
11592
return {toPoint, toOffset}
11584
11593
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
+ ) {
11587
11600
while (++index < indices.length) {
11588
11601
if (indices[index] > offset) {
11589
11602
return {
11590
11603
line: index + 1,
11591
- column: offset - (indices[index - 1] || 0) + 1,
11604
+ column: offset - (index > 0 ? indices[index - 1] : 0) + 1,
11592
11605
offset
11593
11606
}
11594
11607
}
@@ -11597,19 +11610,21 @@ function location(file) {
11597
11610
return {line: undefined, column: undefined, offset: undefined}
11598
11611
}
11599
11612
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;
11603
11615
if (
11604
11616
typeof line === 'number' &&
11605
11617
typeof column === 'number' &&
11606
11618
!Number.isNaN(line) &&
11607
11619
!Number.isNaN(column) &&
11608
11620
line - 1 in indices
11609
11621
) {
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
+ }
11611
11626
}
11612
- return offset > -1 && offset < indices[indices.length - 1] ? offset : -1
11627
+ return -1
11613
11628
}
11614
11629
}
11615
11630
@@ -20792,13 +20807,16 @@ const settings = {
20792
20807
};
20793
20808
const remarkPresetLintNode = { plugins, settings };
20794
20809
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 )};
20800
20815
}
20801
- return looksLikeAVFile(options) ? options : new VFile(options)
20816
+ return looksLikeAVFile(description)
20817
+ ? description
20818
+ :
20819
+ new VFile(description || undefined)
20802
20820
}
20803
20821
function readSync(description, options) {
20804
20822
const file = toVFile(description);
@@ -20830,7 +20848,8 @@ const read =
20830
20848
try {
20831
20849
fp = path$1.resolve(file.cwd, file.path);
20832
20850
} catch (error) {
20833
- return reject(error)
20851
+ const exception = (error);
20852
+ return reject(exception)
20834
20853
}
20835
20854
fs.readFile(fp, options, done);
20836
20855
function done(error, result) {
@@ -20864,12 +20883,13 @@ const write =
20864
20883
try {
20865
20884
fp = path$1.resolve(file.cwd, file.path);
20866
20885
} catch (error) {
20867
- return reject(error)
20886
+ const exception = (error);
20887
+ return reject(exception, null)
20868
20888
}
20869
- fs.writeFile(fp, file.value || '', options, done);
20889
+ fs.writeFile(fp, file.value || '', options || null , done);
20870
20890
function done(error) {
20871
20891
if (error) {
20872
- reject(error);
20892
+ reject(error, null );
20873
20893
} else {
20874
20894
resolve(file);
20875
20895
}
@@ -20878,11 +20898,11 @@ const write =
20878
20898
}
20879
20899
);
20880
20900
function looksLikeAVFile(value) {
20881
- return (
20901
+ return Boolean (
20882
20902
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
20886
20906
)
20887
20907
}
20888
20908
toVFile.readSync = readSync;
@@ -21259,7 +21279,7 @@ function stringWidth(string, options = {}) {
21259
21279
}
21260
21280
21261
21281
function statistics(value) {
21262
- var result = {true: 0, false: 0, null: 0};
21282
+ const result = {true: 0, false: 0, null: 0};
21263
21283
if (value) {
21264
21284
if (Array.isArray(value)) {
21265
21285
list(value);
@@ -21275,22 +21295,25 @@ function statistics(value) {
21275
21295
total: result.true + result.false + result.null
21276
21296
}
21277
21297
function list(value) {
21278
- var index = -1;
21298
+ let index = -1;
21279
21299
while (++index < value.length) {
21280
21300
one(value[index]);
21281
21301
}
21282
21302
}
21283
21303
function one(value) {
21284
21304
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]++;
21290
21313
}
21291
21314
}
21292
21315
21293
- var severities = {true: 2, false: 1, null: 0, undefined: 0};
21316
+ const severities = {true: 2, false: 1, null: 0, undefined: 0};
21294
21317
function sort(file) {
21295
21318
file.messages.sort(comparator);
21296
21319
return file
@@ -21299,18 +21322,18 @@ function comparator(a, b) {
21299
21322
return (
21300
21323
check(a, b, 'line') ||
21301
21324
check(a, b, 'column') ||
21302
- severities[b.fatal] - severities[a.fatal] ||
21325
+ severities[String( b.fatal) ] - severities[String( a.fatal) ] ||
21303
21326
compare(a, b, 'source') ||
21304
21327
compare(a, b, 'ruleId') ||
21305
21328
compare(a, b, 'reason') ||
21306
21329
0
21307
21330
)
21308
21331
}
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)
21311
21334
}
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 ] || '')
21314
21337
}
21315
21338
21316
21339
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
0 commit comments