markdownlint 0.21.0 → 0.21.1

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/README.md CHANGED
@@ -905,6 +905,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
905
905
  update TypeScript declaration file, hide `toString` on `LintResults`, add ability
906
906
  to fix in browser demo, allow custom rules in `.markdownlint.json` schema, improve
907
907
  MD042/MD044, improve documentation, update dependencies.
908
+ * 0.21.1 - Improve MD011/MD031, export `getVersion` API.
908
909
 
909
910
  [npm-image]: https://img.shields.io/npm/v/markdownlint.svg
910
911
  [npm-url]: https://www.npmjs.com/package/markdownlint
@@ -66,6 +66,8 @@ module.exports.isObject = function isObject(obj) {
66
66
  // Example: Contains nothing, whitespace, or comments
67
67
  var blankLineRe = />|(?:<!--.*?-->)/g;
68
68
  module.exports.isBlankLine = function isBlankLine(line) {
69
+ // Call to String.replace follows best practices and is not a security check
70
+ // False-positive for js/incomplete-multi-character-sanitization
69
71
  return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
70
72
  };
71
73
  /**
@@ -353,6 +355,7 @@ function forEachInlineCodeSpan(input, handler) {
353
355
  var currentTicks = 0;
354
356
  var state = "normal";
355
357
  // Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
358
+ // False-positive for js/index-out-of-bounds
356
359
  for (; index <= input.length; index++) {
357
360
  var char = input[index];
358
361
  // Ignore backticks in link destination
@@ -1030,9 +1033,8 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
1030
1033
  try {
1031
1034
  var json = JSON.parse(parameter);
1032
1035
  config = __assign(__assign({}, config), json);
1033
- // eslint-disable-next-line unicorn/prefer-optional-catch-binding
1034
1036
  }
1035
- catch (error) {
1037
+ catch (_a) {
1036
1038
  // Ignore parse errors for inline configuration
1037
1039
  }
1038
1040
  }
@@ -1594,17 +1596,26 @@ function readConfigSync(file, parsers) {
1594
1596
  }
1595
1597
  return config;
1596
1598
  }
1599
+ /**
1600
+ * Gets the (semantic) version of the library.
1601
+ *
1602
+ * @returns {string} SemVer string.
1603
+ */
1604
+ function getVersion() {
1605
+ return require("../package.json").version;
1606
+ }
1597
1607
  // Export a/synchronous/Promise APIs
1598
1608
  markdownlint.sync = markdownlintSync;
1599
1609
  markdownlint.readConfig = readConfig;
1600
1610
  markdownlint.readConfigSync = readConfigSync;
1611
+ markdownlint.getVersion = getVersion;
1601
1612
  markdownlint.promises = {
1602
1613
  "markdownlint": markdownlintPromise,
1603
1614
  "readConfig": readConfigPromise
1604
1615
  };
1605
1616
  module.exports = markdownlint;
1606
1617
 
1607
- },{"../helpers":2,"./cache":3,"./rules":49,"fs":51,"markdown-it":1,"path":53,"util":57}],5:[function(require,module,exports){
1618
+ },{"../helpers":2,"../package.json":50,"./cache":3,"./rules":49,"fs":51,"markdown-it":1,"path":53,"util":57}],5:[function(require,module,exports){
1608
1619
  // @ts-check
1609
1620
  "use strict";
1610
1621
  var _a = require("../helpers"), addErrorDetailIf = _a.addErrorDetailIf, filterTokens = _a.filterTokens;
@@ -1954,11 +1965,15 @@ module.exports = {
1954
1965
  var line = params.lines[lineNumber - 1];
1955
1966
  var column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
1956
1967
  var length_1 = reversedLink.length;
1957
- addError(onError, lineNumber, reversedLink, null, [column, length_1], {
1958
- "editColumn": column,
1959
- "deleteCount": length_1,
1960
- "insertText": "[" + linkText + "](" + linkDestination + ")"
1961
- });
1968
+ var range = column ? [column, length_1] : null;
1969
+ var fixInfo = column ?
1970
+ {
1971
+ "editColumn": column,
1972
+ "deleteCount": length_1,
1973
+ "insertText": "[" + linkText + "](" + linkDestination + ")"
1974
+ } :
1975
+ null;
1976
+ addError(onError, lineNumber, reversedLink, null, range, fixInfo);
1962
1977
  }
1963
1978
  });
1964
1979
  }
@@ -2604,11 +2619,12 @@ module.exports = {
2604
2619
  if ((includeListItems || !inItem) &&
2605
2620
  ((onTopFence && !isBlankLine(lines[i - 1])) ||
2606
2621
  (onBottomFence && !isBlankLine(lines[i + 1])))) {
2607
- var _a = line.match(codeFencePrefixRe), prefix = _a[1];
2608
- addErrorContext(onError, i + 1, lines[i].trim(), null, null, null, {
2622
+ var _a = line.match(codeFencePrefixRe) || [], prefix = _a[1];
2623
+ var fixInfo = (prefix === undefined) ? null : {
2609
2624
  "lineNumber": i + (onTopFence ? 1 : 2),
2610
2625
  "insertText": prefix + "\n"
2611
- });
2626
+ };
2627
+ addErrorContext(onError, i + 1, lines[i].trim(), null, null, null, fixInfo);
2612
2628
  }
2613
2629
  });
2614
2630
  }
@@ -3433,7 +3449,7 @@ module.exports = rules;
3433
3449
  },{"../package.json":50,"./md001":5,"./md002":6,"./md003":7,"./md004":8,"./md005":9,"./md006":10,"./md007":11,"./md009":12,"./md010":13,"./md011":14,"./md012":15,"./md013":16,"./md014":17,"./md018":18,"./md019":19,"./md020":20,"./md021":21,"./md022":22,"./md023":23,"./md024":24,"./md025":25,"./md026":26,"./md027":27,"./md028":28,"./md029":29,"./md030":30,"./md031":31,"./md032":32,"./md033":33,"./md034":34,"./md035":35,"./md036":36,"./md037":37,"./md038":38,"./md039":39,"./md040":40,"./md041":41,"./md042":42,"./md043":43,"./md044":44,"./md045":45,"./md046":46,"./md047":47,"./md048":48}],50:[function(require,module,exports){
3434
3450
  module.exports={
3435
3451
  "name": "markdownlint",
3436
- "version": "0.21.0",
3452
+ "version": "0.21.1",
3437
3453
  "description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
3438
3454
  "main": "lib/markdownlint.js",
3439
3455
  "types": "lib/markdownlint.d.ts",
@@ -3453,7 +3469,7 @@ module.exports={
3453
3469
  "lint": "eslint --max-warnings 0 lib helpers test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0, no-var: 0, unicorn/prefer-add-event-listener: 0, unicorn/prefer-query-selector: 0, unicorn/prefer-replace-all: 0\" demo && eslint --rule \"no-console: 0, no-invalid-this: 0, no-shadow: 0, object-property-newline: 0, node/no-missing-require: 0, node/no-extraneous-require: 0\" example",
3454
3470
  "ci": "npm run test-cover && npm run lint && npm run test-declaration",
3455
3471
  "build-config-schema": "node schema/build-config-schema.js",
3456
- "build-declaration": "tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration",
3472
+ "build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'",
3457
3473
  "build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && browserify ../lib-es3/helpers/helpers.js --standalone helpers >> markdownlint-rule-helpers-browser.js && uglifyjs markdownlint-browser.js markdownlint-rule-helpers-browser.js --compress --mangle --comments --output markdownlint-browser.min.js",
3458
3474
  "build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
3459
3475
  "example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
@@ -3481,9 +3497,9 @@ module.exports={
3481
3497
  "js-yaml": "~3.14.0",
3482
3498
  "make-dir-cli": "~2.0.0",
3483
3499
  "markdown-it-for-inline": "~0.1.1",
3484
- "@iktakahiro/markdown-it-katex": "~4.0.0",
3485
3500
  "markdown-it-sub": "~1.0.0",
3486
3501
  "markdown-it-sup": "~1.0.0",
3502
+ "markdown-it-texmath": "~0.8.0",
3487
3503
  "markdownlint-rule-helpers": "~0.11.0",
3488
3504
  "rimraf": "~3.0.2",
3489
3505
  "strip-json-comments": "~3.1.1",
@@ -3560,7 +3576,7 @@ exports.homedir = function () {
3560
3576
  };
3561
3577
 
3562
3578
  },{}],53:[function(require,module,exports){
3563
- (function (process){
3579
+ (function (process){(function (){
3564
3580
  // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
3565
3581
  // backported and transplited with Babel, with backwards-compat fixes
3566
3582
 
@@ -3864,7 +3880,7 @@ var substr = 'ab'.substr(-1) === 'b'
3864
3880
  }
3865
3881
  ;
3866
3882
 
3867
- }).call(this,require('_process'))
3883
+ }).call(this)}).call(this,require('_process'))
3868
3884
  },{"_process":54}],54:[function(require,module,exports){
3869
3885
  // shim for using process in browser
3870
3886
  var process = module.exports = {};
@@ -4084,7 +4100,7 @@ module.exports = function isBuffer(arg) {
4084
4100
  && typeof arg.readUInt8 === 'function';
4085
4101
  }
4086
4102
  },{}],57:[function(require,module,exports){
4087
- (function (process,global){
4103
+ (function (process,global){(function (){
4088
4104
  // Copyright Joyent, Inc. and other Node contributors.
4089
4105
  //
4090
4106
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -4672,6 +4688,6 @@ function hasOwnProperty(obj, prop) {
4672
4688
  return Object.prototype.hasOwnProperty.call(obj, prop);
4673
4689
  }
4674
4690
 
4675
- }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4691
+ }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4676
4692
  },{"./support/isBuffer":56,"_process":54,"inherits":55}]},{},[4])(4)
4677
4693
  });
package/doc/Rules.md CHANGED
@@ -1752,7 +1752,7 @@ Or with reference syntax as:
1752
1752
 
1753
1753
  Guidance for writing alternate text is available from the [W3C](https://www.w3.org/WAI/alt/),
1754
1754
  [Wikipedia](https://en.wikipedia.org/wiki/Alt_attribute), and
1755
- [other locations](https://www.phase2technology.com/blog/no-more-excuses-definitive-guide-alt-text-field).
1755
+ [other locations](https://www.phase2technology.com/blog/no-more-excuses).
1756
1756
 
1757
1757
  Rationale: Alternate text is important for accessibility and describes the
1758
1758
  content of an image for people who may not be able to see it.
@@ -61,6 +61,8 @@ module.exports.isObject = function isObject(obj) {
61
61
  // Example: Contains nothing, whitespace, or comments
62
62
  const blankLineRe = />|(?:<!--.*?-->)/g;
63
63
  module.exports.isBlankLine = function isBlankLine(line) {
64
+ // Call to String.replace follows best practices and is not a security check
65
+ // False-positive for js/incomplete-multi-character-sanitization
64
66
  return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
65
67
  };
66
68
 
@@ -355,6 +357,7 @@ function forEachInlineCodeSpan(input, handler) {
355
357
  let currentTicks = 0;
356
358
  let state = "normal";
357
359
  // Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
360
+ // False-positive for js/index-out-of-bounds
358
361
  for (; index <= input.length; index++) {
359
362
  const char = input[index];
360
363
  // Ignore backticks in link destination
@@ -8,7 +8,7 @@ export = markdownlint;
8
8
  */
9
9
  declare function markdownlint(options: Options, callback: LintCallback): void;
10
10
  declare namespace markdownlint {
11
- export { markdownlintSync as sync, readConfig, readConfigSync, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback };
11
+ export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback };
12
12
  }
13
13
  /**
14
14
  * Configuration options.
@@ -82,6 +82,12 @@ declare function readConfig(file: string, parsers: ConfigurationParser[] | ReadC
82
82
  * @returns {Configuration} Configuration object.
83
83
  */
84
84
  declare function readConfigSync(file: string, parsers?: ConfigurationParser[]): Configuration;
85
+ /**
86
+ * Gets the (semantic) version of the library.
87
+ *
88
+ * @returns {string} SemVer string.
89
+ */
90
+ declare function getVersion(): string;
85
91
  declare namespace promises {
86
92
  export { markdownlintPromise as markdownlint };
87
93
  export { readConfigPromise as readConfig };
@@ -345,8 +345,7 @@ function getEnabledRulesPerLineNumber(
345
345
  ...config,
346
346
  ...json
347
347
  };
348
- // eslint-disable-next-line unicorn/prefer-optional-catch-binding
349
- } catch (error) {
348
+ } catch {
350
349
  // Ignore parse errors for inline configuration
351
350
  }
352
351
  }
@@ -985,10 +984,20 @@ function readConfigSync(file, parsers) {
985
984
  return config;
986
985
  }
987
986
 
987
+ /**
988
+ * Gets the (semantic) version of the library.
989
+ *
990
+ * @returns {string} SemVer string.
991
+ */
992
+ function getVersion() {
993
+ return require("../package.json").version;
994
+ }
995
+
988
996
  // Export a/synchronous/Promise APIs
989
997
  markdownlint.sync = markdownlintSync;
990
998
  markdownlint.readConfig = readConfig;
991
999
  markdownlint.readConfigSync = readConfigSync;
1000
+ markdownlint.getVersion = getVersion;
992
1001
  markdownlint.promises = {
993
1002
  "markdownlint": markdownlintPromise,
994
1003
  "readConfig": readConfigPromise
package/lib/md011.js CHANGED
@@ -20,17 +20,21 @@ module.exports = {
20
20
  const line = params.lines[lineNumber - 1];
21
21
  const column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
22
22
  const length = reversedLink.length;
23
+ const range = column ? [ column, length ] : null;
24
+ const fixInfo = column ?
25
+ {
26
+ "editColumn": column,
27
+ "deleteCount": length,
28
+ "insertText": `[${linkText}](${linkDestination})`
29
+ } :
30
+ null;
23
31
  addError(
24
32
  onError,
25
33
  lineNumber,
26
34
  reversedLink,
27
35
  null,
28
- [ column, length ],
29
- {
30
- "editColumn": column,
31
- "deleteCount": length,
32
- "insertText": `[${linkText}](${linkDestination})`
33
- }
36
+ range,
37
+ fixInfo
34
38
  );
35
39
  }
36
40
  });
package/lib/md031.js CHANGED
@@ -21,7 +21,11 @@ module.exports = {
21
21
  if ((includeListItems || !inItem) &&
22
22
  ((onTopFence && !isBlankLine(lines[i - 1])) ||
23
23
  (onBottomFence && !isBlankLine(lines[i + 1])))) {
24
- const [ , prefix ] = line.match(codeFencePrefixRe);
24
+ const [ , prefix ] = line.match(codeFencePrefixRe) || [];
25
+ const fixInfo = (prefix === undefined) ? null : {
26
+ "lineNumber": i + (onTopFence ? 1 : 2),
27
+ "insertText": `${prefix}\n`
28
+ };
25
29
  addErrorContext(
26
30
  onError,
27
31
  i + 1,
@@ -29,10 +33,7 @@ module.exports = {
29
33
  null,
30
34
  null,
31
35
  null,
32
- {
33
- "lineNumber": i + (onTopFence ? 1 : 2),
34
- "insertText": `${prefix}\n`
35
- });
36
+ fixInfo);
36
37
  }
37
38
  });
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint",
3
- "version": "0.21.0",
3
+ "version": "0.21.1",
4
4
  "description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
5
5
  "main": "lib/markdownlint.js",
6
6
  "types": "lib/markdownlint.d.ts",
@@ -20,7 +20,7 @@
20
20
  "lint": "eslint --max-warnings 0 lib helpers test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0, no-var: 0, unicorn/prefer-add-event-listener: 0, unicorn/prefer-query-selector: 0, unicorn/prefer-replace-all: 0\" demo && eslint --rule \"no-console: 0, no-invalid-this: 0, no-shadow: 0, object-property-newline: 0, node/no-missing-require: 0, node/no-extraneous-require: 0\" example",
21
21
  "ci": "npm run test-cover && npm run lint && npm run test-declaration",
22
22
  "build-config-schema": "node schema/build-config-schema.js",
23
- "build-declaration": "tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration",
23
+ "build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'",
24
24
  "build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && browserify ../lib-es3/helpers/helpers.js --standalone helpers >> markdownlint-rule-helpers-browser.js && uglifyjs markdownlint-browser.js markdownlint-rule-helpers-browser.js --compress --mangle --comments --output markdownlint-browser.min.js",
25
25
  "build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
26
26
  "example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
@@ -48,9 +48,9 @@
48
48
  "js-yaml": "~3.14.0",
49
49
  "make-dir-cli": "~2.0.0",
50
50
  "markdown-it-for-inline": "~0.1.1",
51
- "@iktakahiro/markdown-it-katex": "~4.0.0",
52
51
  "markdown-it-sub": "~1.0.0",
53
52
  "markdown-it-sup": "~1.0.0",
53
+ "markdown-it-texmath": "~0.8.0",
54
54
  "markdownlint-rule-helpers": "~0.11.0",
55
55
  "rimraf": "~3.0.2",
56
56
  "strip-json-comments": "~3.1.1",
@@ -38,7 +38,6 @@ const schema = {
38
38
  const tags = {};
39
39
 
40
40
  // Add rules
41
- // eslint-disable-next-line complexity
42
41
  rules.forEach(function forRule(rule) {
43
42
  rule.tags.forEach(function forTag(tag) {
44
43
  const tagRules = tags[tag] || [];