markdownlint 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +1 -1
- package/README.md +18 -1
- package/helpers/helpers.js +1 -1
- package/helpers/package.json +1 -1
- package/lib/markdownlint.js +18 -2
- package/package.json +1 -1
package/.eslintrc.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"linebreak-style": "off",
|
|
22
22
|
"max-lines": "off",
|
|
23
23
|
"max-lines-per-function": "off",
|
|
24
|
-
"max-params": ["error",
|
|
24
|
+
"max-params": ["error", 10],
|
|
25
25
|
"max-statements": ["error", 33],
|
|
26
26
|
"multiline-comment-style": ["error", "separate-lines"],
|
|
27
27
|
"multiline-ternary": "off",
|
package/README.md
CHANGED
|
@@ -360,6 +360,21 @@ title: Title
|
|
|
360
360
|
|
|
361
361
|
Note: Matches must occur at the start of the file.
|
|
362
362
|
|
|
363
|
+
##### options.handleRuleFailures
|
|
364
|
+
|
|
365
|
+
Type: `Boolean`
|
|
366
|
+
|
|
367
|
+
Catches exceptions thrown during rule processing and reports the problem as a
|
|
368
|
+
rule violation.
|
|
369
|
+
|
|
370
|
+
By default, exceptions thrown by rules (or the library itself) are unhandled
|
|
371
|
+
and bubble up the stack to the caller in the conventional manner. By setting
|
|
372
|
+
`handleRuleFailures` to `true`, exceptions thrown by failing rules will be
|
|
373
|
+
handled by the library and the exception message logged as a rule violation.
|
|
374
|
+
This setting can be useful in the presence of (custom) rules that encounter
|
|
375
|
+
unexpected syntax and fail. By enabling this option, the linting process is
|
|
376
|
+
allowed to continue and report any violations that were found.
|
|
377
|
+
|
|
363
378
|
##### options.noInlineConfig
|
|
364
379
|
|
|
365
380
|
Type: `Boolean`
|
|
@@ -699,6 +714,7 @@ For ideas how to integrate `markdownlint` into your workflow, refer to the follo
|
|
|
699
714
|
* [Sinon.JS](https://sinonjs.org/) ([Search repository](https://github.com/sinonjs/sinon/search?q=markdownlint))
|
|
700
715
|
* [TestCafe](https://devexpress.github.io/testcafe/) ([Search repository](https://github.com/DevExpress/testcafe/search?q=markdownlint))
|
|
701
716
|
* [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html) ([Search repository](https://github.com/Microsoft/TypeScript-Handbook/search?q=markdownlint))
|
|
717
|
+
* [V8](https://v8.dev/) ([Search repository](https://github.com/v8/v8.dev/search?q=markdownlint))
|
|
702
718
|
* [webhint](https://webhint.io/) ([Search repository](https://github.com/webhintio/hint/search?q=markdownlint))
|
|
703
719
|
* [webpack](https://webpack.js.org/) ([Search repository](https://github.com/webpack/webpack.js.org/search?q=markdownlint))
|
|
704
720
|
|
|
@@ -724,7 +740,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
|
|
724
740
|
* 0.3.1 - Fix regressions in MD032/MD038, update dependencies.
|
|
725
741
|
* 0.4.0 - Add MD044, enhance MD013/MD032/MD041/MD042/MD043, fix for MD038, dependencies.
|
|
726
742
|
* 0.4.1 - Fixes for MD038/front matter, improvements to MD044, update dependencies.
|
|
727
|
-
* 0.5.0 - Add shareable configuration, noInlineConfig option, README links, fix MD030,
|
|
743
|
+
* 0.5.0 - Add shareable configuration, `noInlineConfig` option, README links, fix MD030,
|
|
728
744
|
improve MD009/MD041, update dependencies.
|
|
729
745
|
* 0.6.0 - `resultVersion` defaults to 1 (breaking change), ignore HTML comments, TOML
|
|
730
746
|
front matter, fixes for MD044, update dependencies.
|
|
@@ -752,6 +768,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
|
|
752
768
|
add MD046/MD047, improve MD033/MD034/MD039, improve custom rule validation and
|
|
753
769
|
in-browser demo, update dependencies.
|
|
754
770
|
* 0.14.1 - Improve MD033.
|
|
771
|
+
* 0.14.2 - Improve MD047, add `handleRuleFailures` option.
|
|
755
772
|
|
|
756
773
|
[npm-image]: https://img.shields.io/npm/v/markdownlint.svg
|
|
757
774
|
[npm-url]: https://www.npmjs.com/package/markdownlint
|
package/helpers/helpers.js
CHANGED
|
@@ -76,7 +76,7 @@ module.exports.clearHtmlCommentText = function clearHtmlCommentText(text) {
|
|
|
76
76
|
let j = text.indexOf(htmlCommentEnd, i);
|
|
77
77
|
if (j === -1) {
|
|
78
78
|
j = text.length;
|
|
79
|
-
text += "
|
|
79
|
+
text += "\\\n";
|
|
80
80
|
}
|
|
81
81
|
const comment = text.slice(i + htmlCommentBegin.length, j);
|
|
82
82
|
if ((comment.length > 0) &&
|
package/helpers/package.json
CHANGED
package/lib/markdownlint.js
CHANGED
|
@@ -301,6 +301,7 @@ function lintContent(
|
|
|
301
301
|
md,
|
|
302
302
|
config,
|
|
303
303
|
frontMatter,
|
|
304
|
+
handleRuleFailures,
|
|
304
305
|
noInlineConfig,
|
|
305
306
|
resultVersion,
|
|
306
307
|
callback) {
|
|
@@ -376,7 +377,18 @@ function lintContent(
|
|
|
376
377
|
});
|
|
377
378
|
}
|
|
378
379
|
// Call (possibly external) rule function
|
|
379
|
-
|
|
380
|
+
if (handleRuleFailures) {
|
|
381
|
+
try {
|
|
382
|
+
rule.function(params, onError);
|
|
383
|
+
} catch (ex) {
|
|
384
|
+
onError({
|
|
385
|
+
"lineNumber": 1,
|
|
386
|
+
"detail": `This rule threw an exception: ${ex.message}`
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
rule.function(params, onError);
|
|
391
|
+
}
|
|
380
392
|
// Record any errors (significant performance benefit from length check)
|
|
381
393
|
if (errors.length) {
|
|
382
394
|
errors.sort(lineNumberComparison);
|
|
@@ -432,6 +444,7 @@ function lintFile(
|
|
|
432
444
|
md,
|
|
433
445
|
config,
|
|
434
446
|
frontMatter,
|
|
447
|
+
handleRuleFailures,
|
|
435
448
|
noInlineConfig,
|
|
436
449
|
resultVersion,
|
|
437
450
|
synchronous,
|
|
@@ -441,7 +454,7 @@ function lintFile(
|
|
|
441
454
|
return callback(err);
|
|
442
455
|
}
|
|
443
456
|
return lintContent(ruleList, file, content, md, config, frontMatter,
|
|
444
|
-
noInlineConfig, resultVersion, callback);
|
|
457
|
+
handleRuleFailures, noInlineConfig, resultVersion, callback);
|
|
445
458
|
}
|
|
446
459
|
// Make a/synchronous call to read file
|
|
447
460
|
if (synchronous) {
|
|
@@ -472,6 +485,7 @@ function lintInput(options, synchronous, callback) {
|
|
|
472
485
|
const config = options.config || { "default": true };
|
|
473
486
|
const frontMatter = (options.frontMatter === undefined) ?
|
|
474
487
|
helpers.frontMatterRe : options.frontMatter;
|
|
488
|
+
const handleRuleFailures = !!options.handleRuleFailures;
|
|
475
489
|
const noInlineConfig = !!options.noInlineConfig;
|
|
476
490
|
const resultVersion = (options.resultVersion === undefined) ?
|
|
477
491
|
2 : options.resultVersion;
|
|
@@ -504,6 +518,7 @@ function lintInput(options, synchronous, callback) {
|
|
|
504
518
|
md,
|
|
505
519
|
config,
|
|
506
520
|
frontMatter,
|
|
521
|
+
handleRuleFailures,
|
|
507
522
|
noInlineConfig,
|
|
508
523
|
resultVersion,
|
|
509
524
|
lintNextItemCallback);
|
|
@@ -515,6 +530,7 @@ function lintInput(options, synchronous, callback) {
|
|
|
515
530
|
md,
|
|
516
531
|
config,
|
|
517
532
|
frontMatter,
|
|
533
|
+
handleRuleFailures,
|
|
518
534
|
noInlineConfig,
|
|
519
535
|
resultVersion,
|
|
520
536
|
synchronous,
|
package/package.json
CHANGED