@alexlit/lint-kit 107.3.0 → 108.0.0
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.cjs +7 -1
- package/.linthtmlrc.cjs +3 -1
- package/{.commitlintrc.cjs → commitlint.config.js} +1 -1
- package/package.json +5 -5
- package/packages/config-commitlint/LICENSE +20 -0
- package/packages/config-commitlint/README.md +5 -9
- package/packages/config-commitlint/index.js +1 -1
- package/packages/config-commitlint/package.json +4 -3
- package/packages/config-eslint/LICENSE +20 -0
- package/packages/config-eslint/index.js +12 -2
- package/packages/config-eslint/package.json +25 -25
- package/packages/config-eslint/plugins/typescript/index.js +1 -1
- package/packages/config-eslint/plugins/unicorn.js +2 -0
- package/packages/config-eslint/plugins/vue.js +34 -2
- package/packages/config-hooks/LICENSE +20 -0
- package/packages/config-hooks/README.md +18 -12
- package/packages/config-hooks/index.js +2 -0
- package/packages/config-hooks/lint-staged.js +1 -1
- package/packages/config-hooks/package.json +6 -5
- package/packages/config-htmllint/LICENSE +20 -0
- package/packages/config-markdownlint/LICENSE +20 -0
- package/packages/config-markdownlint/package.json +3 -3
- package/packages/config-npmlint/LICENSE +20 -0
- package/packages/config-npmlint/package.json +2 -2
- package/packages/config-prettier/LICENSE +20 -0
- package/packages/config-prettier/README.md +8 -3
- package/packages/config-prettier/index.js +14 -10
- package/packages/config-prettier/package.json +16 -12
- package/packages/config-prettier/plugins/jsdoc.js +1 -1
- package/packages/config-prettier/plugins/pug.js +1 -1
- package/packages/config-prettier/plugins/sort-json.js +1 -1
- package/packages/config-prettier/plugins/svelte.js +1 -1
- package/packages/config-prettier/plugins/tailwindcss.js +1 -1
- package/packages/config-prettier/plugins/xml.js +1 -1
- package/packages/config-stylelint/LICENSE +20 -0
- package/packages/config-stylelint/README.md +5 -4
- package/packages/config-stylelint/index.js +22 -25
- package/packages/config-stylelint/package.json +22 -18
- package/packages/config-stylelint/plugins/a11y.js +1 -1
- package/packages/config-stylelint/plugins/at-rule-no-children.js +1 -1
- package/packages/config-stylelint/plugins/color-format.js +1 -1
- package/packages/config-stylelint/plugins/declaration-block-no-ignored-properties.js +1 -1
- package/packages/config-stylelint/plugins/high-performance-animation.js +1 -1
- package/packages/config-stylelint/plugins/no-nested-media.js +1 -1
- package/packages/config-stylelint/plugins/no-unresolved-module.js +1 -1
- package/packages/config-stylelint/plugins/no-unsupported-browser-features.js +1 -1
- package/packages/config-stylelint/plugins/optional/gamut.js +1 -1
- package/packages/config-stylelint/plugins/optional/logical-css.js +1 -1
- package/packages/config-stylelint/plugins/optional/no-indistinguishable-colors.js +1 -1
- package/packages/config-stylelint/plugins/order.js +1 -1
- package/packages/config-stylelint/plugins/prettier.js +1 -1
- package/packages/config-stylelint/plugins/scss.js +1 -1
- package/packages/config-stylelint/plugins/selector-no-empty.js +1 -1
- package/packages/config-stylelint/plugins/use-nesting.js +1 -1
- package/packages/config-stylelint/plugins/vue.js +1 -1
- package/prettier.config.js +5 -0
- package/stylelint.config.js +14 -0
- package/.huskyrc.cjs +0 -3
- package/.lintstagedrc.cjs +0 -3
- package/.prettierrc.cjs +0 -3
- package/.stylelintrc.cjs +0 -4
- package/packages/config-hooks/husky.js +0 -6
- package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +0 -22
- package/packages/config-markdownlint/node_modules/markdown-it/README.md +0 -309
- package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +0 -117
- package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +0 -8441
- package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
- package/packages/config-markdownlint/node_modules/markdown-it/index.js +0 -4
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +0 -6
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +0 -70
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +0 -28
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +0 -317
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +0 -7
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +0 -80
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +0 -48
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +0 -55
- package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +0 -582
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +0 -131
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +0 -61
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +0 -192
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +0 -81
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +0 -41
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +0 -63
- package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +0 -341
- package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +0 -352
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +0 -226
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +0 -34
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +0 -98
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +0 -55
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +0 -45
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +0 -74
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +0 -83
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +0 -362
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +0 -51
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +0 -198
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +0 -231
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +0 -221
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +0 -16
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +0 -13
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +0 -142
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +0 -21
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +0 -105
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +0 -201
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +0 -20
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +0 -45
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +0 -76
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +0 -63
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +0 -130
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +0 -130
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +0 -55
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +0 -71
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +0 -41
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +0 -58
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +0 -152
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +0 -150
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +0 -62
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +0 -46
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +0 -158
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +0 -130
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +0 -89
- package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +0 -201
- package/packages/config-markdownlint/node_modules/markdown-it/package.json +0 -87
- package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -428
- package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -92
- package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1026
- package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +0 -6814
- package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -376
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +0 -20
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +0 -2335
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +0 -59
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +0 -53
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +0 -51
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +0 -57
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +0 -54
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +0 -29
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +0 -31
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +0 -24
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +0 -98
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +0 -82
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +0 -55
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +0 -69
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +0 -35
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +0 -34
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +0 -41
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -61
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +0 -100
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -70
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +0 -1025
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +0 -426
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +0 -26
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +0 -10
- package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +0 -1152
- package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +0 -14
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +0 -406
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +0 -1476
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +0 -22
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +0 -76
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +0 -73
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +0 -86
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +0 -86
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +0 -60
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +0 -46
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +0 -96
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +0 -53
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +0 -34
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +0 -62
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +0 -62
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +0 -108
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +0 -61
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +0 -78
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +0 -79
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +0 -24
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +0 -91
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +0 -97
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +0 -64
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +0 -107
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +0 -60
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +0 -89
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +0 -172
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +0 -59
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +0 -125
- package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +0 -65
- package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -109
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -297
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -266
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -1762
- package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +0 -5
- package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +0 -22
- package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +0 -26
- package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +0 -12
- /package/packages/config-eslint/plugins/{security.js → optional/security.js} +0 -0
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const {
|
|
7
|
-
gfmAutolinkLiteral, gfmFootnote, gfmTable, math, parse, postprocess,
|
|
8
|
-
preprocess
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
} = require("markdownlint-micromark");
|
|
11
|
-
const { newLineRe } = require("./shared.js");
|
|
12
|
-
|
|
13
|
-
const flatTokensSymbol = Symbol("flat-tokens");
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Markdown token.
|
|
17
|
-
*
|
|
18
|
-
* @typedef {Object} Token
|
|
19
|
-
* @property {string} type Token type.
|
|
20
|
-
* @property {number} startLine Start line (1-based).
|
|
21
|
-
* @property {number} startColumn Start column (1-based).
|
|
22
|
-
* @property {number} endLine End line (1-based).
|
|
23
|
-
* @property {number} endColumn End column (1-based).
|
|
24
|
-
* @property {string} text Token text.
|
|
25
|
-
* @property {Token[]} children Child tokens.
|
|
26
|
-
* @property {Token | null} parent Parent token.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns whether a token is an htmlFlow type containing an HTML comment.
|
|
31
|
-
*
|
|
32
|
-
* @param {Token} token Micromark token.
|
|
33
|
-
* @returns {boolean} True iff token is htmlFlow containing a comment.
|
|
34
|
-
*/
|
|
35
|
-
function isHtmlFlowComment(token) {
|
|
36
|
-
const { text, type } = token;
|
|
37
|
-
if (
|
|
38
|
-
(type === "htmlFlow") &&
|
|
39
|
-
text.startsWith("<!--") &&
|
|
40
|
-
text.endsWith("-->")
|
|
41
|
-
) {
|
|
42
|
-
const comment = text.slice(4, -3);
|
|
43
|
-
return (
|
|
44
|
-
!comment.startsWith(">") &&
|
|
45
|
-
!comment.startsWith("->") &&
|
|
46
|
-
!comment.endsWith("-")
|
|
47
|
-
// The following condition from the CommonMark specification is commented
|
|
48
|
-
// to avoid parsing HTML comments that include "--" because that is NOT a
|
|
49
|
-
// condition of the HTML specification.
|
|
50
|
-
// https://spec.commonmark.org/0.30/#raw-html
|
|
51
|
-
// https://html.spec.whatwg.org/multipage/syntax.html#comments
|
|
52
|
-
// && !comment.includes("--")
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Parses a Markdown document and returns Micromark events.
|
|
60
|
-
*
|
|
61
|
-
* @param {string} markdown Markdown document.
|
|
62
|
-
* @param {Object} [micromarkOptions] Options for micromark.
|
|
63
|
-
* @param {boolean} [referencesDefined] Treat references as defined.
|
|
64
|
-
* @returns {Object[]} Micromark events.
|
|
65
|
-
*/
|
|
66
|
-
function getMicromarkEvents(
|
|
67
|
-
markdown,
|
|
68
|
-
micromarkOptions = {},
|
|
69
|
-
referencesDefined = true
|
|
70
|
-
) {
|
|
71
|
-
|
|
72
|
-
// Customize options object to add useful extensions
|
|
73
|
-
micromarkOptions.extensions = micromarkOptions.extensions || [];
|
|
74
|
-
micromarkOptions.extensions.push(
|
|
75
|
-
gfmAutolinkLiteral(),
|
|
76
|
-
gfmFootnote(),
|
|
77
|
-
gfmTable(),
|
|
78
|
-
math()
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
// Use micromark to parse document into Events
|
|
82
|
-
const encoding = undefined;
|
|
83
|
-
const eol = true;
|
|
84
|
-
const parseContext = parse(micromarkOptions);
|
|
85
|
-
if (referencesDefined) {
|
|
86
|
-
// Customize ParseContext to treat all references as defined
|
|
87
|
-
parseContext.defined.includes = (searchElement) => searchElement.length > 0;
|
|
88
|
-
}
|
|
89
|
-
const chunks = preprocess()(markdown, encoding, eol);
|
|
90
|
-
const events = postprocess(parseContext.document().write(chunks));
|
|
91
|
-
return events;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Parses a Markdown document and returns (frozen) tokens.
|
|
96
|
-
*
|
|
97
|
-
* @param {string} markdown Markdown document.
|
|
98
|
-
* @param {Object} micromarkOptions Options for micromark.
|
|
99
|
-
* @param {boolean} referencesDefined Treat references as defined.
|
|
100
|
-
* @param {number} lineDelta Offset to apply to start/end line.
|
|
101
|
-
* @param {Token} [ancestor] Parent of top-most tokens.
|
|
102
|
-
* @returns {Token[]} Micromark tokens (frozen).
|
|
103
|
-
*/
|
|
104
|
-
function micromarkParseWithOffset(
|
|
105
|
-
markdown,
|
|
106
|
-
micromarkOptions,
|
|
107
|
-
referencesDefined,
|
|
108
|
-
lineDelta,
|
|
109
|
-
ancestor
|
|
110
|
-
) {
|
|
111
|
-
// Use micromark to parse document into Events
|
|
112
|
-
const events = getMicromarkEvents(
|
|
113
|
-
markdown, micromarkOptions, referencesDefined
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
// Create Token objects
|
|
117
|
-
const document = [];
|
|
118
|
-
let flatTokens = [];
|
|
119
|
-
/** @type {Token} */
|
|
120
|
-
const root = {
|
|
121
|
-
"type": "ROOT",
|
|
122
|
-
"startLine": -1,
|
|
123
|
-
"startColumn": -1,
|
|
124
|
-
"endLine": -1,
|
|
125
|
-
"endColumn": -1,
|
|
126
|
-
"text": "ROOT",
|
|
127
|
-
"children": document,
|
|
128
|
-
"parent": null
|
|
129
|
-
};
|
|
130
|
-
const history = [ root ];
|
|
131
|
-
let current = root;
|
|
132
|
-
let reparseOptions = null;
|
|
133
|
-
let lines = null;
|
|
134
|
-
let skipHtmlFlowChildren = false;
|
|
135
|
-
for (const event of events) {
|
|
136
|
-
const [ kind, token, context ] = event;
|
|
137
|
-
const { type, start, end } = token;
|
|
138
|
-
const { "column": startColumn, "line": startLine } = start;
|
|
139
|
-
const { "column": endColumn, "line": endLine } = end;
|
|
140
|
-
const text = context.sliceSerialize(token);
|
|
141
|
-
if ((kind === "enter") && !skipHtmlFlowChildren) {
|
|
142
|
-
const previous = current;
|
|
143
|
-
history.push(previous);
|
|
144
|
-
current = {
|
|
145
|
-
type,
|
|
146
|
-
"startLine": startLine + lineDelta,
|
|
147
|
-
startColumn,
|
|
148
|
-
"endLine": endLine + lineDelta,
|
|
149
|
-
endColumn,
|
|
150
|
-
text,
|
|
151
|
-
"children": [],
|
|
152
|
-
"parent": ((previous === root) ? (ancestor || null) : previous)
|
|
153
|
-
};
|
|
154
|
-
previous.children.push(current);
|
|
155
|
-
flatTokens.push(current);
|
|
156
|
-
if ((current.type === "htmlFlow") && !isHtmlFlowComment(current)) {
|
|
157
|
-
skipHtmlFlowChildren = true;
|
|
158
|
-
if (!reparseOptions || !lines) {
|
|
159
|
-
reparseOptions = {
|
|
160
|
-
...micromarkOptions,
|
|
161
|
-
"extensions": [
|
|
162
|
-
{
|
|
163
|
-
"disable": {
|
|
164
|
-
"null": [ "codeIndented", "htmlFlow" ]
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
};
|
|
169
|
-
lines = markdown.split(newLineRe);
|
|
170
|
-
}
|
|
171
|
-
const reparseMarkdown = lines
|
|
172
|
-
.slice(current.startLine - 1, current.endLine)
|
|
173
|
-
.join("\n");
|
|
174
|
-
const tokens = micromarkParseWithOffset(
|
|
175
|
-
reparseMarkdown,
|
|
176
|
-
reparseOptions,
|
|
177
|
-
referencesDefined,
|
|
178
|
-
current.startLine - 1,
|
|
179
|
-
current
|
|
180
|
-
);
|
|
181
|
-
current.children = tokens;
|
|
182
|
-
// Avoid stack overflow of Array.push(...spread)
|
|
183
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
184
|
-
flatTokens = flatTokens.concat(tokens[flatTokensSymbol]);
|
|
185
|
-
}
|
|
186
|
-
} else if (kind === "exit") {
|
|
187
|
-
if (type === "htmlFlow") {
|
|
188
|
-
skipHtmlFlowChildren = false;
|
|
189
|
-
}
|
|
190
|
-
if (!skipHtmlFlowChildren) {
|
|
191
|
-
Object.freeze(current.children);
|
|
192
|
-
Object.freeze(current);
|
|
193
|
-
// @ts-ignore
|
|
194
|
-
current = history.pop();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Return document
|
|
200
|
-
Object.defineProperty(document, flatTokensSymbol, { "value": flatTokens });
|
|
201
|
-
Object.freeze(document);
|
|
202
|
-
return document;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Parses a Markdown document and returns (frozen) tokens.
|
|
207
|
-
*
|
|
208
|
-
* @param {string} markdown Markdown document.
|
|
209
|
-
* @param {Object} [micromarkOptions] Options for micromark.
|
|
210
|
-
* @param {boolean} [referencesDefined] Treat references as defined.
|
|
211
|
-
* @returns {Token[]} Micromark tokens (frozen).
|
|
212
|
-
*/
|
|
213
|
-
function micromarkParse(
|
|
214
|
-
markdown,
|
|
215
|
-
micromarkOptions = {},
|
|
216
|
-
referencesDefined = true
|
|
217
|
-
) {
|
|
218
|
-
return micromarkParseWithOffset(
|
|
219
|
-
markdown,
|
|
220
|
-
micromarkOptions,
|
|
221
|
-
referencesDefined,
|
|
222
|
-
0
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* @callback AllowedPredicate
|
|
228
|
-
* @param {Token} token Micromark token.
|
|
229
|
-
* @returns {boolean} True iff allowed.
|
|
230
|
-
*/
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @callback TransformPredicate
|
|
234
|
-
* @param {Token} token Micromark token.
|
|
235
|
-
* @returns {Token[]} Child tokens.
|
|
236
|
-
*/
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Filter a list of Micromark tokens by predicate.
|
|
240
|
-
*
|
|
241
|
-
* @param {Token[]} tokens Micromark tokens.
|
|
242
|
-
* @param {AllowedPredicate} [allowed] Allowed token predicate.
|
|
243
|
-
* @param {TransformPredicate} [transformChildren] Transform predicate.
|
|
244
|
-
* @returns {Token[]} Filtered tokens.
|
|
245
|
-
*/
|
|
246
|
-
function filterByPredicate(tokens, allowed, transformChildren) {
|
|
247
|
-
allowed = allowed || (() => true);
|
|
248
|
-
const result = [];
|
|
249
|
-
const queue = [
|
|
250
|
-
{
|
|
251
|
-
"array": tokens,
|
|
252
|
-
"index": 0
|
|
253
|
-
}
|
|
254
|
-
];
|
|
255
|
-
while (queue.length > 0) {
|
|
256
|
-
const current = queue[queue.length - 1];
|
|
257
|
-
const { array, index } = current;
|
|
258
|
-
if (index < array.length) {
|
|
259
|
-
const token = array[current.index++];
|
|
260
|
-
if (allowed(token)) {
|
|
261
|
-
result.push(token);
|
|
262
|
-
}
|
|
263
|
-
const { children } = token;
|
|
264
|
-
if (children.length > 0) {
|
|
265
|
-
const transformed =
|
|
266
|
-
transformChildren ? transformChildren(token) : children;
|
|
267
|
-
queue.push(
|
|
268
|
-
{
|
|
269
|
-
"array": transformed,
|
|
270
|
-
"index": 0
|
|
271
|
-
}
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
} else {
|
|
275
|
-
queue.pop();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return result;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Filter a list of Micromark tokens by type.
|
|
283
|
-
*
|
|
284
|
-
* @param {Token[]} tokens Micromark tokens.
|
|
285
|
-
* @param {string[]} types Types to allow.
|
|
286
|
-
* @returns {Token[]} Filtered tokens.
|
|
287
|
-
*/
|
|
288
|
-
function filterByTypes(tokens, types) {
|
|
289
|
-
const predicate = (token) => types.includes(token.type);
|
|
290
|
-
const flatTokens = tokens[flatTokensSymbol];
|
|
291
|
-
if (flatTokens) {
|
|
292
|
-
return flatTokens.filter(predicate);
|
|
293
|
-
}
|
|
294
|
-
return filterByPredicate(tokens, predicate);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Gets the heading level of a Micromark heading tokan.
|
|
299
|
-
*
|
|
300
|
-
* @param {Token} heading Micromark heading token.
|
|
301
|
-
* @returns {number} Heading level.
|
|
302
|
-
*/
|
|
303
|
-
function getHeadingLevel(heading) {
|
|
304
|
-
const headingSequence = filterByTypes(
|
|
305
|
-
heading.children,
|
|
306
|
-
[ "atxHeadingSequence", "setextHeadingLineSequence" ]
|
|
307
|
-
);
|
|
308
|
-
let level = 1;
|
|
309
|
-
const { text } = headingSequence[0];
|
|
310
|
-
if (text[0] === "#") {
|
|
311
|
-
level = Math.min(text.length, 6);
|
|
312
|
-
} else if (text[0] === "-") {
|
|
313
|
-
level = 2;
|
|
314
|
-
}
|
|
315
|
-
return level;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Gets information about the tag in an HTML token.
|
|
320
|
-
*
|
|
321
|
-
* @param {Token} token Micromark token.
|
|
322
|
-
* @returns {Object | null} HTML tag information.
|
|
323
|
-
*/
|
|
324
|
-
function getHtmlTagInfo(token) {
|
|
325
|
-
const htmlTagNameRe = /^<([^!>][^/\s>]*)/;
|
|
326
|
-
if (token.type === "htmlText") {
|
|
327
|
-
const match = htmlTagNameRe.exec(token.text);
|
|
328
|
-
if (match) {
|
|
329
|
-
const name = match[1];
|
|
330
|
-
const close = name.startsWith("/");
|
|
331
|
-
return {
|
|
332
|
-
close,
|
|
333
|
-
"name": close ? name.slice(1) : name
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Gets the nearest parent of the specified type for a Micromark token.
|
|
342
|
-
*
|
|
343
|
-
* @param {Token} token Micromark token.
|
|
344
|
-
* @param {string[]} types Types to allow.
|
|
345
|
-
* @returns {Token | null} Parent token.
|
|
346
|
-
*/
|
|
347
|
-
function getTokenParentOfType(token, types) {
|
|
348
|
-
/** @type {Token | null} */
|
|
349
|
-
let current = token;
|
|
350
|
-
while ((current = current.parent) && !types.includes(current.type)) {
|
|
351
|
-
// Empty
|
|
352
|
-
}
|
|
353
|
-
return current;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Get the text of the first match from a list of Micromark tokens by type.
|
|
358
|
-
*
|
|
359
|
-
* @param {Token[]} tokens Micromark tokens.
|
|
360
|
-
* @param {string} type Types to match.
|
|
361
|
-
* @returns {string | null} Text of token.
|
|
362
|
-
*/
|
|
363
|
-
function getTokenTextByType(tokens, type) {
|
|
364
|
-
const filtered = tokens.filter((token) => token.type === type);
|
|
365
|
-
return (filtered.length > 0) ? filtered[0].text : null;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Determines if a Micromark token has an htmlFlow-type parent.
|
|
370
|
-
*
|
|
371
|
-
* @param {Token} token Micromark token.
|
|
372
|
-
* @returns {boolean} True iff the token has an htmlFlow-type parent.
|
|
373
|
-
*/
|
|
374
|
-
function inHtmlFlow(token) {
|
|
375
|
-
return getTokenParentOfType(token, [ "htmlFlow" ]) !== null;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Determines a list of Micromark tokens matches and returns a subset.
|
|
380
|
-
*
|
|
381
|
-
* @param {Token[]} tokens Micromark tokens.
|
|
382
|
-
* @param {string[]} matchTypes Types to match.
|
|
383
|
-
* @param {string[]} [resultTypes] Types to return.
|
|
384
|
-
* @returns {Token[] | null} Matching tokens.
|
|
385
|
-
*/
|
|
386
|
-
function matchAndGetTokensByType(tokens, matchTypes, resultTypes) {
|
|
387
|
-
if (tokens.length !== matchTypes.length) {
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
resultTypes = resultTypes || matchTypes;
|
|
391
|
-
const result = [];
|
|
392
|
-
// eslint-disable-next-line unicorn/no-for-loop
|
|
393
|
-
for (let i = 0; i < matchTypes.length; i++) {
|
|
394
|
-
if (tokens[i].type !== matchTypes[i]) {
|
|
395
|
-
return null;
|
|
396
|
-
} else if (resultTypes.includes(matchTypes[i])) {
|
|
397
|
-
result.push(tokens[i]);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return result;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Returns the specified token iff it is of the desired type.
|
|
405
|
-
*
|
|
406
|
-
* @param {Token} token Micromark token candidate.
|
|
407
|
-
* @param {string} type Desired type.
|
|
408
|
-
* @returns {Token | null} Token instance.
|
|
409
|
-
*/
|
|
410
|
-
function tokenIfType(token, type) {
|
|
411
|
-
return (token && (token.type === type)) ? token : null;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
module.exports = {
|
|
415
|
-
"parse": micromarkParse,
|
|
416
|
-
filterByPredicate,
|
|
417
|
-
filterByTypes,
|
|
418
|
-
getHeadingLevel,
|
|
419
|
-
getHtmlTagInfo,
|
|
420
|
-
getMicromarkEvents,
|
|
421
|
-
getTokenParentOfType,
|
|
422
|
-
getTokenTextByType,
|
|
423
|
-
inHtmlFlow,
|
|
424
|
-
matchAndGetTokensByType,
|
|
425
|
-
tokenIfType
|
|
426
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "markdownlint-rule-helpers",
|
|
3
|
-
"version": "0.23.0",
|
|
4
|
-
"description": "A collection of markdownlint helper functions for custom rules",
|
|
5
|
-
"main": "./helpers.js",
|
|
6
|
-
"exports": "./helpers.js",
|
|
7
|
-
"author": "David Anson (https://dlaa.me/)",
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"homepage": "https://github.com/DavidAnson/markdownlint",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/DavidAnson/markdownlint.git"
|
|
13
|
-
},
|
|
14
|
-
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
|
15
|
-
"funding": "https://github.com/sponsors/DavidAnson",
|
|
16
|
-
"engines": {
|
|
17
|
-
"node": ">=16"
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"markdownlint-micromark": "0.1.2"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"markdownlint",
|
|
24
|
-
"markdownlint-rule"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
// Regular expression for matching common newline characters
|
|
6
|
-
// See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
|
|
7
|
-
module.exports.newLineRe = /\r\n?|\n/g;
|
|
8
|
-
|
|
9
|
-
// Regular expression for matching next lines
|
|
10
|
-
module.exports.nextLinesRe = /[\r\n][\s\S]*$/;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const map = new Map();
|
|
6
|
-
|
|
7
|
-
module.exports.set = (keyValuePairs) => {
|
|
8
|
-
for (const [ key, value ] of Object.entries(keyValuePairs)) {
|
|
9
|
-
map.set(key, value);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
module.exports.clear = () => map.clear();
|
|
13
|
-
|
|
14
|
-
module.exports.codeBlockAndSpanRanges =
|
|
15
|
-
() => map.get("codeBlockAndSpanRanges");
|
|
16
|
-
module.exports.flattenedLists =
|
|
17
|
-
() => map.get("flattenedLists");
|
|
18
|
-
module.exports.lineMetadata =
|
|
19
|
-
() => map.get("lineMetadata");
|
|
20
|
-
module.exports.referenceLinkImageData =
|
|
21
|
-
() => map.get("referenceLinkImageData");
|