@alexlit/lint-kit 112.3.3 → 112.3.4
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/package.json +1 -1
- package/packages/config-markdownlint/node_modules/entities/LICENSE +0 -11
- package/packages/config-markdownlint/node_modules/entities/lib/decode.d.ts +0 -211
- package/packages/config-markdownlint/node_modules/entities/lib/decode.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/decode.js +0 -536
- package/packages/config-markdownlint/node_modules/entities/lib/decode.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
- package/packages/config-markdownlint/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/decode_codepoint.js +0 -76
- package/packages/config-markdownlint/node_modules/entities/lib/decode_codepoint.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/encode.d.ts +0 -22
- package/packages/config-markdownlint/node_modules/entities/lib/encode.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/encode.js +0 -77
- package/packages/config-markdownlint/node_modules/entities/lib/encode.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/escape.d.ts +0 -43
- package/packages/config-markdownlint/node_modules/entities/lib/escape.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/escape.js +0 -122
- package/packages/config-markdownlint/node_modules/entities/lib/escape.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode.d.ts +0 -211
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode.js +0 -496
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
- package/packages/config-markdownlint/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/encode.d.ts +0 -22
- package/packages/config-markdownlint/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/encode.js +0 -69
- package/packages/config-markdownlint/node_modules/entities/lib/esm/encode.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/escape.d.ts +0 -43
- package/packages/config-markdownlint/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/escape.js +0 -116
- package/packages/config-markdownlint/node_modules/entities/lib/esm/escape.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
- package/packages/config-markdownlint/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/index.d.ts +0 -96
- package/packages/config-markdownlint/node_modules/entities/lib/esm/index.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/index.js +0 -99
- package/packages/config-markdownlint/node_modules/entities/lib/esm/index.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/esm/package.json +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-html.js +0 -9
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
- package/packages/config-markdownlint/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
- package/packages/config-markdownlint/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/generated/encode-html.js +0 -12
- package/packages/config-markdownlint/node_modules/entities/lib/generated/encode-html.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/index.d.ts +0 -96
- package/packages/config-markdownlint/node_modules/entities/lib/index.d.ts.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/lib/index.js +0 -126
- package/packages/config-markdownlint/node_modules/entities/lib/index.js.map +0 -1
- package/packages/config-markdownlint/node_modules/entities/package.json +0 -90
- package/packages/config-markdownlint/node_modules/entities/readme.md +0 -122
- package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +0 -22
- package/packages/config-markdownlint/node_modules/markdown-it/README.md +0 -324
- package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.mjs +0 -107
- package/packages/config-markdownlint/node_modules/markdown-it/dist/index.cjs.js +0 -5540
- package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +0 -6963
- package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +0 -2
- package/packages/config-markdownlint/node_modules/markdown-it/index.mjs +0 -1
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
- package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.mjs +0 -304
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
- package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
- package/packages/config-markdownlint/node_modules/markdown-it/lib/index.mjs +0 -565
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.mjs +0 -134
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.mjs +0 -62
- package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.mjs +0 -47
- package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
- package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.mjs +0 -322
- package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.mjs +0 -340
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -69
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -82
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -46
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -193
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -69
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -56
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -123
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
- package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
- package/packages/config-markdownlint/node_modules/markdown-it/lib/token.mjs +0 -191
- package/packages/config-markdownlint/node_modules/markdown-it/package.json +0 -92
- package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -446
- package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -93
- package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1032
- package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +0 -7116
- package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -383
- 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 -2462
- 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 -58
- 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 -44
- 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 -35
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -35
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -87
- 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/doc/md055.md +0 -54
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md056.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -72
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +0 -1025
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +0 -445
- 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 -1178
- package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +0 -14
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +0 -479
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +0 -1550
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +0 -25
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +0 -79
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +0 -81
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +0 -92
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +0 -89
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +0 -63
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +0 -35
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +0 -99
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +0 -57
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +0 -65
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +0 -65
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +0 -116
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +0 -41
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +0 -35
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +0 -54
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +0 -70
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +0 -66
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +0 -43
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +0 -76
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +0 -46
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +0 -105
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +0 -31
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +0 -99
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +0 -106
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +0 -71
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +0 -53
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +0 -115
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +0 -31
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +0 -43
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +0 -108
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +0 -176
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +0 -62
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +0 -130
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md055.js +0 -80
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md056.js +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -103
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -304
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -272
- package/packages/config-markdownlint/node_modules/markdownlint/schema/ValidatingConfiguration.md +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -1814
- 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-markdownlint/node_modules/markdownlint-micromark/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/README.md +0 -10
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark-browser.js +0 -2
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark-html-browser.js +0 -2
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark.cjs +0 -1
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark.d.ts +0 -1751
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/package.json +0 -46
|
@@ -1,1550 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
const { promisify } = require("node:util");
|
|
7
|
-
const markdownit = require("markdown-it");
|
|
8
|
-
const micromark = require("../helpers/micromark.cjs");
|
|
9
|
-
// const { deprecatedRuleNames } = require("./constants");
|
|
10
|
-
const rules = require("./rules");
|
|
11
|
-
const helpers = require("../helpers");
|
|
12
|
-
const cache = require("./cache");
|
|
13
|
-
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
// eslint-disable-next-line camelcase, no-inline-comments, no-undef
|
|
16
|
-
const dynamicRequire = (typeof __non_webpack_require__ === "undefined") ? require : /* c8 ignore next */ __non_webpack_require__;
|
|
17
|
-
// Capture native require implementation for dynamic loading of modules
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Validate the list of rules for structure and reuse.
|
|
21
|
-
*
|
|
22
|
-
* @param {Rule[]} ruleList List of rules.
|
|
23
|
-
* @param {boolean} synchronous Whether to execute synchronously.
|
|
24
|
-
* @returns {Error | null} Error message if validation fails.
|
|
25
|
-
*/
|
|
26
|
-
function validateRuleList(ruleList, synchronous) {
|
|
27
|
-
let result = null;
|
|
28
|
-
if (ruleList.length === rules.length) {
|
|
29
|
-
// No need to validate if only using built-in rules
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
const allIds = {};
|
|
33
|
-
for (const [ index, rule ] of ruleList.entries()) {
|
|
34
|
-
const customIndex = index - rules.length;
|
|
35
|
-
// eslint-disable-next-line no-inner-declarations, jsdoc/require-jsdoc
|
|
36
|
-
function newError(property, value) {
|
|
37
|
-
return new Error(
|
|
38
|
-
`Property '${property}' of custom rule at index ${customIndex} is incorrect: '${value}'.`);
|
|
39
|
-
}
|
|
40
|
-
for (const property of [ "names", "tags" ]) {
|
|
41
|
-
const value = rule[property];
|
|
42
|
-
if (!result &&
|
|
43
|
-
(!value || !Array.isArray(value) || (value.length === 0) ||
|
|
44
|
-
!value.every(helpers.isString) || value.some(helpers.isEmptyString))) {
|
|
45
|
-
result = newError(property, value);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
for (const propertyInfo of [
|
|
49
|
-
[ "description", "string" ],
|
|
50
|
-
[ "function", "function" ]
|
|
51
|
-
]) {
|
|
52
|
-
const property = propertyInfo[0];
|
|
53
|
-
const value = rule[property];
|
|
54
|
-
if (!result && (!value || (typeof value !== propertyInfo[1]))) {
|
|
55
|
-
result = newError(property, value);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (
|
|
59
|
-
!result &&
|
|
60
|
-
(rule.parser !== undefined) &&
|
|
61
|
-
(rule.parser !== "markdownit") &&
|
|
62
|
-
!((customIndex < 0) && (rule.parser === "micromark")) &&
|
|
63
|
-
(rule.parser !== "none")
|
|
64
|
-
) {
|
|
65
|
-
result = newError("parser", rule.parser);
|
|
66
|
-
}
|
|
67
|
-
if (
|
|
68
|
-
!result &&
|
|
69
|
-
rule.information &&
|
|
70
|
-
!helpers.isUrl(rule.information)
|
|
71
|
-
) {
|
|
72
|
-
result = newError("information", rule.information);
|
|
73
|
-
}
|
|
74
|
-
if (
|
|
75
|
-
!result &&
|
|
76
|
-
(rule.asynchronous !== undefined) &&
|
|
77
|
-
(typeof rule.asynchronous !== "boolean")
|
|
78
|
-
) {
|
|
79
|
-
result = newError("asynchronous", rule.asynchronous);
|
|
80
|
-
}
|
|
81
|
-
if (!result && rule.asynchronous && synchronous) {
|
|
82
|
-
result = new Error(
|
|
83
|
-
"Custom rule " + rule.names.join("/") + " at index " + customIndex +
|
|
84
|
-
" is asynchronous and can not be used in a synchronous context."
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
if (!result) {
|
|
88
|
-
for (const name of rule.names) {
|
|
89
|
-
const nameUpper = name.toUpperCase();
|
|
90
|
-
if (!result && (allIds[nameUpper] !== undefined)) {
|
|
91
|
-
result = new Error("Name '" + name + "' of custom rule at index " +
|
|
92
|
-
customIndex + " is already used as a name or tag.");
|
|
93
|
-
}
|
|
94
|
-
allIds[nameUpper] = true;
|
|
95
|
-
}
|
|
96
|
-
for (const tag of rule.tags) {
|
|
97
|
-
const tagUpper = tag.toUpperCase();
|
|
98
|
-
if (!result && allIds[tagUpper]) {
|
|
99
|
-
result = new Error("Tag '" + tag + "' of custom rule at index " +
|
|
100
|
-
customIndex + " is already used as a name.");
|
|
101
|
-
}
|
|
102
|
-
allIds[tagUpper] = false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Creates a LintResults instance with toString for pretty display.
|
|
111
|
-
*
|
|
112
|
-
* @param {Rule[]} ruleList List of rules.
|
|
113
|
-
* @returns {LintResults} New LintResults instance.
|
|
114
|
-
*/
|
|
115
|
-
function newResults(ruleList) {
|
|
116
|
-
const lintResults = {};
|
|
117
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
118
|
-
function toString(useAlias) {
|
|
119
|
-
let ruleNameToRule = null;
|
|
120
|
-
const results = [];
|
|
121
|
-
const keys = Object.keys(lintResults);
|
|
122
|
-
keys.sort();
|
|
123
|
-
for (const file of keys) {
|
|
124
|
-
const fileResults = lintResults[file];
|
|
125
|
-
if (Array.isArray(fileResults)) {
|
|
126
|
-
for (const result of fileResults) {
|
|
127
|
-
const ruleMoniker = result.ruleNames ?
|
|
128
|
-
result.ruleNames.join("/") :
|
|
129
|
-
(result.ruleName + "/" + result.ruleAlias);
|
|
130
|
-
results.push(
|
|
131
|
-
file + ": " +
|
|
132
|
-
result.lineNumber + ": " +
|
|
133
|
-
ruleMoniker + " " +
|
|
134
|
-
result.ruleDescription +
|
|
135
|
-
(result.errorDetail ?
|
|
136
|
-
" [" + result.errorDetail + "]" :
|
|
137
|
-
"") +
|
|
138
|
-
(result.errorContext ?
|
|
139
|
-
" [Context: \"" + result.errorContext + "\"]" :
|
|
140
|
-
""));
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
if (!ruleNameToRule) {
|
|
144
|
-
ruleNameToRule = {};
|
|
145
|
-
for (const rule of ruleList) {
|
|
146
|
-
const ruleName = rule.names[0].toUpperCase();
|
|
147
|
-
ruleNameToRule[ruleName] = rule;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
for (const [ ruleName, ruleResults ] of Object.entries(fileResults)) {
|
|
151
|
-
const rule = ruleNameToRule[ruleName.toUpperCase()];
|
|
152
|
-
for (const lineNumber of ruleResults) {
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
const nameIndex = Math.min(useAlias ? 1 : 0, rule.names.length - 1);
|
|
155
|
-
const result =
|
|
156
|
-
file + ": " +
|
|
157
|
-
lineNumber + ": " +
|
|
158
|
-
// @ts-ignore
|
|
159
|
-
rule.names[nameIndex] + " " +
|
|
160
|
-
// @ts-ignore
|
|
161
|
-
rule.description;
|
|
162
|
-
results.push(result);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return results.join("\n");
|
|
168
|
-
}
|
|
169
|
-
Object.defineProperty(lintResults, "toString", { "value": toString });
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
return lintResults;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Remove front matter (if present at beginning of content).
|
|
176
|
-
*
|
|
177
|
-
* @param {string} content Markdown content.
|
|
178
|
-
* @param {RegExp | null} frontMatter Regular expression to match front matter.
|
|
179
|
-
* @returns {Object} Trimmed content and front matter lines.
|
|
180
|
-
*/
|
|
181
|
-
function removeFrontMatter(content, frontMatter) {
|
|
182
|
-
let frontMatterLines = [];
|
|
183
|
-
if (frontMatter) {
|
|
184
|
-
const frontMatterMatch = content.match(frontMatter);
|
|
185
|
-
if (frontMatterMatch && !frontMatterMatch.index) {
|
|
186
|
-
const contentMatched = frontMatterMatch[0];
|
|
187
|
-
content = content.slice(contentMatched.length);
|
|
188
|
-
frontMatterLines = contentMatched.split(helpers.newLineRe);
|
|
189
|
-
if ((frontMatterLines.length > 0) &&
|
|
190
|
-
(frontMatterLines[frontMatterLines.length - 1] === "")) {
|
|
191
|
-
frontMatterLines.length--;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
"content": content,
|
|
197
|
-
"frontMatterLines": frontMatterLines
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Freeze all freeze-able members of a token and its children.
|
|
203
|
-
*
|
|
204
|
-
* @param {MarkdownItToken} token A markdown-it token.
|
|
205
|
-
* @returns {void}
|
|
206
|
-
*/
|
|
207
|
-
function freezeToken(token) {
|
|
208
|
-
if (token.attrs) {
|
|
209
|
-
for (const attr of token.attrs) {
|
|
210
|
-
Object.freeze(attr);
|
|
211
|
-
}
|
|
212
|
-
Object.freeze(token.attrs);
|
|
213
|
-
}
|
|
214
|
-
if (token.children) {
|
|
215
|
-
for (const child of token.children) {
|
|
216
|
-
freezeToken(child);
|
|
217
|
-
}
|
|
218
|
-
Object.freeze(token.children);
|
|
219
|
-
}
|
|
220
|
-
if (token.map) {
|
|
221
|
-
Object.freeze(token.map);
|
|
222
|
-
}
|
|
223
|
-
Object.freeze(token);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Annotate tokens with line/lineNumber and freeze them.
|
|
228
|
-
*
|
|
229
|
-
* @param {MarkdownItToken[]} tokens Array of markdown-it tokens.
|
|
230
|
-
* @param {string[]} lines Lines of Markdown content.
|
|
231
|
-
* @returns {void}
|
|
232
|
-
*/
|
|
233
|
-
function annotateAndFreezeTokens(tokens, lines) {
|
|
234
|
-
let trMap = null;
|
|
235
|
-
for (const token of tokens) {
|
|
236
|
-
// Provide missing maps for table content
|
|
237
|
-
if (token.type === "tr_open") {
|
|
238
|
-
trMap = token.map;
|
|
239
|
-
} else if (token.type === "tr_close") {
|
|
240
|
-
trMap = null;
|
|
241
|
-
}
|
|
242
|
-
if (!token.map && trMap) {
|
|
243
|
-
token.map = [ ...trMap ];
|
|
244
|
-
}
|
|
245
|
-
// Update token metadata
|
|
246
|
-
if (token.map) {
|
|
247
|
-
token.line = lines[token.map[0]];
|
|
248
|
-
token.lineNumber = token.map[0] + 1;
|
|
249
|
-
// Trim bottom of token to exclude whitespace lines
|
|
250
|
-
while (token.map[1] && !((lines[token.map[1] - 1] || "").trim())) {
|
|
251
|
-
token.map[1]--;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
// Annotate children with lineNumber
|
|
255
|
-
if (token.children) {
|
|
256
|
-
const codeSpanExtraLines = [];
|
|
257
|
-
if (token.children.some((child) => child.type === "code_inline")) {
|
|
258
|
-
helpers.forEachInlineCodeSpan(token.content, (code) => {
|
|
259
|
-
codeSpanExtraLines.push(code.split(helpers.newLineRe).length - 1);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
let lineNumber = token.lineNumber;
|
|
263
|
-
for (const child of token.children) {
|
|
264
|
-
child.lineNumber = lineNumber;
|
|
265
|
-
child.line = lines[lineNumber - 1];
|
|
266
|
-
if ((child.type === "softbreak") || (child.type === "hardbreak")) {
|
|
267
|
-
lineNumber++;
|
|
268
|
-
} else if (child.type === "code_inline") {
|
|
269
|
-
lineNumber += codeSpanExtraLines.shift();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
freezeToken(token);
|
|
274
|
-
}
|
|
275
|
-
Object.freeze(tokens);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Map rule names/tags to canonical rule name.
|
|
280
|
-
*
|
|
281
|
-
* @param {Rule[]} ruleList List of rules.
|
|
282
|
-
* @returns {Object.<string, string[]>} Map of alias to rule name.
|
|
283
|
-
*/
|
|
284
|
-
function mapAliasToRuleNames(ruleList) {
|
|
285
|
-
const aliasToRuleNames = {};
|
|
286
|
-
// const tagToRuleNames = {};
|
|
287
|
-
for (const rule of ruleList) {
|
|
288
|
-
const ruleName = rule.names[0].toUpperCase();
|
|
289
|
-
// The following is useful for updating README.md:
|
|
290
|
-
// console.log(
|
|
291
|
-
// "* **[" + ruleName + "](doc/Rules.md#" + ruleName.toLowerCase() +
|
|
292
|
-
// ")** *" + rule.names.slice(1).join("/") + "* - " + rule.description);
|
|
293
|
-
for (const name of rule.names) {
|
|
294
|
-
const nameUpper = name.toUpperCase();
|
|
295
|
-
aliasToRuleNames[nameUpper] = [ ruleName ];
|
|
296
|
-
}
|
|
297
|
-
for (const tag of rule.tags) {
|
|
298
|
-
const tagUpper = tag.toUpperCase();
|
|
299
|
-
const ruleNames = aliasToRuleNames[tagUpper] || [];
|
|
300
|
-
ruleNames.push(ruleName);
|
|
301
|
-
aliasToRuleNames[tagUpper] = ruleNames;
|
|
302
|
-
// tagToRuleNames[tag] = ruleName;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
// The following is useful for updating README.md:
|
|
306
|
-
// Object.keys(tagToRuleNames).sort().forEach(function forTag(tag) {
|
|
307
|
-
// console.log("* **" + tag + "** - " +
|
|
308
|
-
// aliasToRuleNames[tag.toUpperCase()].join(", "));
|
|
309
|
-
// });
|
|
310
|
-
// @ts-ignore
|
|
311
|
-
return aliasToRuleNames;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Apply (and normalize) configuration object.
|
|
316
|
-
*
|
|
317
|
-
* @param {Rule[]} ruleList List of rules.
|
|
318
|
-
* @param {Configuration} config Configuration object.
|
|
319
|
-
* @param {Object.<string, string[]>} aliasToRuleNames Map of alias to rule
|
|
320
|
-
* names.
|
|
321
|
-
* @returns {Configuration} Effective configuration.
|
|
322
|
-
*/
|
|
323
|
-
function getEffectiveConfig(ruleList, config, aliasToRuleNames) {
|
|
324
|
-
const defaultKey = Object.keys(config).filter(
|
|
325
|
-
(key) => key.toUpperCase() === "DEFAULT"
|
|
326
|
-
);
|
|
327
|
-
const ruleDefault = (defaultKey.length === 0) || !!config[defaultKey[0]];
|
|
328
|
-
/** @type {Configuration} */
|
|
329
|
-
const effectiveConfig = {};
|
|
330
|
-
for (const rule of ruleList) {
|
|
331
|
-
const ruleName = rule.names[0].toUpperCase();
|
|
332
|
-
effectiveConfig[ruleName] = ruleDefault;
|
|
333
|
-
}
|
|
334
|
-
// for (const ruleName of deprecatedRuleNames) {
|
|
335
|
-
// effectiveConfig[ruleName] = false;
|
|
336
|
-
// }
|
|
337
|
-
for (const key of Object.keys(config)) {
|
|
338
|
-
let value = config[key];
|
|
339
|
-
if (value) {
|
|
340
|
-
if (!(value instanceof Object)) {
|
|
341
|
-
value = {};
|
|
342
|
-
}
|
|
343
|
-
} else {
|
|
344
|
-
value = false;
|
|
345
|
-
}
|
|
346
|
-
const keyUpper = key.toUpperCase();
|
|
347
|
-
for (const ruleName of (aliasToRuleNames[keyUpper] || [])) {
|
|
348
|
-
effectiveConfig[ruleName] = value;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
return effectiveConfig;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Parse the content of a configuration file.
|
|
356
|
-
*
|
|
357
|
-
* @param {string} name Name of the configuration file.
|
|
358
|
-
* @param {string} content Configuration content.
|
|
359
|
-
* @param {ConfigurationParser[] | null} [parsers] Parsing function(s).
|
|
360
|
-
* @returns {Object} Configuration object and error message.
|
|
361
|
-
*/
|
|
362
|
-
function parseConfiguration(name, content, parsers) {
|
|
363
|
-
let config = null;
|
|
364
|
-
let message = "";
|
|
365
|
-
const errors = [];
|
|
366
|
-
let index = 0;
|
|
367
|
-
// Try each parser
|
|
368
|
-
(parsers || [ JSON.parse ]).every((parser) => {
|
|
369
|
-
try {
|
|
370
|
-
config = parser(content);
|
|
371
|
-
} catch (error) {
|
|
372
|
-
errors.push(`Parser ${index++}: ${error.message}`);
|
|
373
|
-
}
|
|
374
|
-
return !config;
|
|
375
|
-
});
|
|
376
|
-
// Message if unable to parse
|
|
377
|
-
if (!config) {
|
|
378
|
-
errors.unshift(`Unable to parse '${name}'`);
|
|
379
|
-
message = errors.join("; ");
|
|
380
|
-
}
|
|
381
|
-
return {
|
|
382
|
-
config,
|
|
383
|
-
message
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Create a mapping of enabled rules per line.
|
|
389
|
-
*
|
|
390
|
-
* @param {Rule[]} ruleList List of rules.
|
|
391
|
-
* @param {string[]} lines List of content lines.
|
|
392
|
-
* @param {string[]} frontMatterLines List of front matter lines.
|
|
393
|
-
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
|
394
|
-
* @param {Configuration} config Configuration object.
|
|
395
|
-
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
|
396
|
-
* @param {Object.<string, string[]>} aliasToRuleNames Map of alias to rule
|
|
397
|
-
* names.
|
|
398
|
-
* @returns {Object} Effective configuration and enabled rules per line number.
|
|
399
|
-
*/
|
|
400
|
-
function getEnabledRulesPerLineNumber(
|
|
401
|
-
ruleList,
|
|
402
|
-
lines,
|
|
403
|
-
frontMatterLines,
|
|
404
|
-
noInlineConfig,
|
|
405
|
-
config,
|
|
406
|
-
configParsers,
|
|
407
|
-
aliasToRuleNames) {
|
|
408
|
-
// Shared variables
|
|
409
|
-
let enabledRules = {};
|
|
410
|
-
let capturedRules = {};
|
|
411
|
-
const allRuleNames = [];
|
|
412
|
-
const enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length);
|
|
413
|
-
// Helper functions
|
|
414
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
415
|
-
function handleInlineConfig(input, forEachMatch, forEachLine) {
|
|
416
|
-
for (const [ lineIndex, line ] of input.entries()) {
|
|
417
|
-
if (!noInlineConfig) {
|
|
418
|
-
let match = null;
|
|
419
|
-
while ((match = helpers.inlineCommentStartRe.exec(line))) {
|
|
420
|
-
const action = match[2].toUpperCase();
|
|
421
|
-
const startIndex = match.index + match[1].length;
|
|
422
|
-
const endIndex = line.indexOf("-->", startIndex);
|
|
423
|
-
if (endIndex === -1) {
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
const parameter = line.slice(startIndex, endIndex);
|
|
427
|
-
forEachMatch(action, parameter, lineIndex + 1);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (forEachLine) {
|
|
431
|
-
forEachLine();
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
436
|
-
function configureFile(action, parameter) {
|
|
437
|
-
if (action === "CONFIGURE-FILE") {
|
|
438
|
-
const { "config": parsed } = parseConfiguration(
|
|
439
|
-
"CONFIGURE-FILE", parameter, configParsers
|
|
440
|
-
);
|
|
441
|
-
if (parsed) {
|
|
442
|
-
config = {
|
|
443
|
-
...config,
|
|
444
|
-
...parsed
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
450
|
-
function applyEnableDisable(action, parameter, state) {
|
|
451
|
-
state = { ...state };
|
|
452
|
-
const enabled = (action.startsWith("ENABLE"));
|
|
453
|
-
const trimmed = parameter && parameter.trim();
|
|
454
|
-
const items = trimmed ? trimmed.toUpperCase().split(/\s+/) : allRuleNames;
|
|
455
|
-
for (const nameUpper of items) {
|
|
456
|
-
for (const ruleName of (aliasToRuleNames[nameUpper] || [])) {
|
|
457
|
-
state[ruleName] = enabled;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
return state;
|
|
461
|
-
}
|
|
462
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
463
|
-
function enableDisableFile(action, parameter) {
|
|
464
|
-
if ((action === "ENABLE-FILE") || (action === "DISABLE-FILE")) {
|
|
465
|
-
enabledRules = applyEnableDisable(action, parameter, enabledRules);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
469
|
-
function captureRestoreEnableDisable(action, parameter) {
|
|
470
|
-
if (action === "CAPTURE") {
|
|
471
|
-
capturedRules = enabledRules;
|
|
472
|
-
} else if (action === "RESTORE") {
|
|
473
|
-
enabledRules = capturedRules;
|
|
474
|
-
} else if ((action === "ENABLE") || (action === "DISABLE")) {
|
|
475
|
-
enabledRules = applyEnableDisable(action, parameter, enabledRules);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
479
|
-
function updateLineState() {
|
|
480
|
-
enabledRulesPerLineNumber.push(enabledRules);
|
|
481
|
-
}
|
|
482
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
483
|
-
function disableLineNextLine(action, parameter, lineNumber) {
|
|
484
|
-
const disableLine = (action === "DISABLE-LINE");
|
|
485
|
-
const disableNextLine = (action === "DISABLE-NEXT-LINE");
|
|
486
|
-
if (disableLine || disableNextLine) {
|
|
487
|
-
const nextLineNumber =
|
|
488
|
-
frontMatterLines.length + lineNumber + (disableNextLine ? 1 : 0);
|
|
489
|
-
enabledRulesPerLineNumber[nextLineNumber] =
|
|
490
|
-
applyEnableDisable(
|
|
491
|
-
action,
|
|
492
|
-
parameter,
|
|
493
|
-
enabledRulesPerLineNumber[nextLineNumber]
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
// Handle inline comments
|
|
498
|
-
handleInlineConfig([ lines.join("\n") ], configureFile);
|
|
499
|
-
const effectiveConfig = getEffectiveConfig(
|
|
500
|
-
ruleList, config, aliasToRuleNames);
|
|
501
|
-
for (const rule of ruleList) {
|
|
502
|
-
const ruleName = rule.names[0].toUpperCase();
|
|
503
|
-
allRuleNames.push(ruleName);
|
|
504
|
-
enabledRules[ruleName] = !!effectiveConfig[ruleName];
|
|
505
|
-
}
|
|
506
|
-
capturedRules = enabledRules;
|
|
507
|
-
handleInlineConfig(lines, enableDisableFile);
|
|
508
|
-
handleInlineConfig(lines, captureRestoreEnableDisable, updateLineState);
|
|
509
|
-
handleInlineConfig(lines, disableLineNextLine);
|
|
510
|
-
// Return results
|
|
511
|
-
return {
|
|
512
|
-
effectiveConfig,
|
|
513
|
-
enabledRulesPerLineNumber
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Lints a string containing Markdown content.
|
|
519
|
-
*
|
|
520
|
-
* @param {Rule[]} ruleList List of rules.
|
|
521
|
-
* @param {Object.<string, string[]>} aliasToRuleNames Map of alias to rule
|
|
522
|
-
* names.
|
|
523
|
-
* @param {string} name Identifier for the content.
|
|
524
|
-
* @param {string} content Markdown content.
|
|
525
|
-
* @param {Object} md Instance of markdown-it.
|
|
526
|
-
* @param {Configuration} config Configuration object.
|
|
527
|
-
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
|
528
|
-
* @param {RegExp | null} frontMatter Regular expression for front matter.
|
|
529
|
-
* @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
|
|
530
|
-
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
|
531
|
-
* @param {number} resultVersion Version of the LintResults object to return.
|
|
532
|
-
* @param {LintContentCallback} callback Callback (err, result) function.
|
|
533
|
-
* @returns {void}
|
|
534
|
-
*/
|
|
535
|
-
function lintContent(
|
|
536
|
-
ruleList,
|
|
537
|
-
aliasToRuleNames,
|
|
538
|
-
name,
|
|
539
|
-
content,
|
|
540
|
-
md,
|
|
541
|
-
config,
|
|
542
|
-
configParsers,
|
|
543
|
-
frontMatter,
|
|
544
|
-
handleRuleFailures,
|
|
545
|
-
noInlineConfig,
|
|
546
|
-
resultVersion,
|
|
547
|
-
callback) {
|
|
548
|
-
// Remove UTF-8 byte order marker (if present)
|
|
549
|
-
content = content.replace(/^\uFEFF/, "");
|
|
550
|
-
// Remove front matter
|
|
551
|
-
const removeFrontMatterResult = removeFrontMatter(content, frontMatter);
|
|
552
|
-
const { frontMatterLines } = removeFrontMatterResult;
|
|
553
|
-
content = removeFrontMatterResult.content;
|
|
554
|
-
// Get enabled rules per line (with HTML comments present)
|
|
555
|
-
const { effectiveConfig, enabledRulesPerLineNumber } =
|
|
556
|
-
getEnabledRulesPerLineNumber(
|
|
557
|
-
ruleList,
|
|
558
|
-
content.split(helpers.newLineRe),
|
|
559
|
-
frontMatterLines,
|
|
560
|
-
noInlineConfig,
|
|
561
|
-
config,
|
|
562
|
-
configParsers,
|
|
563
|
-
aliasToRuleNames
|
|
564
|
-
);
|
|
565
|
-
// Parse content into parser tokens
|
|
566
|
-
const markdownitTokens = md.parse(content, {});
|
|
567
|
-
const micromarkTokens = micromark.parse(content);
|
|
568
|
-
// Hide the content of HTML comments from rules
|
|
569
|
-
content = helpers.clearHtmlCommentText(content);
|
|
570
|
-
// Parse content into lines and update markdown-it tokens
|
|
571
|
-
const lines = content.split(helpers.newLineRe);
|
|
572
|
-
annotateAndFreezeTokens(markdownitTokens, lines);
|
|
573
|
-
// Create (frozen) parameters for rules
|
|
574
|
-
/** @type {MarkdownParsers} */
|
|
575
|
-
// @ts-ignore
|
|
576
|
-
const parsersMarkdownIt = Object.freeze({
|
|
577
|
-
"markdownit": Object.freeze({
|
|
578
|
-
"tokens": markdownitTokens
|
|
579
|
-
})
|
|
580
|
-
});
|
|
581
|
-
/** @type {MarkdownParsers} */
|
|
582
|
-
// @ts-ignore
|
|
583
|
-
const parsersMicromark = Object.freeze({
|
|
584
|
-
"micromark": Object.freeze({
|
|
585
|
-
"tokens": micromarkTokens
|
|
586
|
-
})
|
|
587
|
-
});
|
|
588
|
-
/** @type {MarkdownParsers} */
|
|
589
|
-
// @ts-ignore
|
|
590
|
-
const parsersNone = Object.freeze({});
|
|
591
|
-
const paramsBase = {
|
|
592
|
-
name,
|
|
593
|
-
"parsers": parsersMarkdownIt,
|
|
594
|
-
"lines": Object.freeze(lines),
|
|
595
|
-
"frontMatterLines": Object.freeze(frontMatterLines)
|
|
596
|
-
};
|
|
597
|
-
const lineMetadata =
|
|
598
|
-
helpers.getLineMetadata(paramsBase);
|
|
599
|
-
const codeBlockAndSpanRanges =
|
|
600
|
-
helpers.codeBlockAndSpanRanges(paramsBase, lineMetadata);
|
|
601
|
-
const flattenedLists =
|
|
602
|
-
helpers.flattenLists(markdownitTokens);
|
|
603
|
-
const referenceLinkImageData =
|
|
604
|
-
helpers.getReferenceLinkImageData(micromarkTokens);
|
|
605
|
-
cache.set({
|
|
606
|
-
codeBlockAndSpanRanges,
|
|
607
|
-
flattenedLists,
|
|
608
|
-
lineMetadata,
|
|
609
|
-
referenceLinkImageData
|
|
610
|
-
});
|
|
611
|
-
// Function to run for each rule
|
|
612
|
-
let results = [];
|
|
613
|
-
/**
|
|
614
|
-
* @param {Rule} rule Rule.
|
|
615
|
-
* @returns {Promise<void> | null} Promise.
|
|
616
|
-
*/
|
|
617
|
-
const forRule = (rule) => {
|
|
618
|
-
// Configure rule
|
|
619
|
-
const ruleName = rule.names[0].toUpperCase();
|
|
620
|
-
const tokens = {};
|
|
621
|
-
let parsers = parsersNone;
|
|
622
|
-
if (rule.parser === undefined) {
|
|
623
|
-
tokens.tokens = markdownitTokens;
|
|
624
|
-
parsers = parsersMarkdownIt;
|
|
625
|
-
} else if (rule.parser === "markdownit") {
|
|
626
|
-
parsers = parsersMarkdownIt;
|
|
627
|
-
} else if (rule.parser === "micromark") {
|
|
628
|
-
parsers = parsersMicromark;
|
|
629
|
-
}
|
|
630
|
-
const params = {
|
|
631
|
-
...paramsBase,
|
|
632
|
-
...tokens,
|
|
633
|
-
parsers,
|
|
634
|
-
"config": effectiveConfig[ruleName]
|
|
635
|
-
};
|
|
636
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
637
|
-
function throwError(property) {
|
|
638
|
-
throw new Error(
|
|
639
|
-
`Value of '${property}' passed to onError by '${ruleName}' is incorrect for '${name}'.`);
|
|
640
|
-
}
|
|
641
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
642
|
-
function onError(errorInfo) {
|
|
643
|
-
if (!errorInfo ||
|
|
644
|
-
!helpers.isNumber(errorInfo.lineNumber) ||
|
|
645
|
-
(errorInfo.lineNumber < 1) ||
|
|
646
|
-
(errorInfo.lineNumber > lines.length)) {
|
|
647
|
-
throwError("lineNumber");
|
|
648
|
-
}
|
|
649
|
-
const lineNumber = errorInfo.lineNumber + frontMatterLines.length;
|
|
650
|
-
if (!enabledRulesPerLineNumber[lineNumber][ruleName]) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
if (errorInfo.detail &&
|
|
654
|
-
!helpers.isString(errorInfo.detail)) {
|
|
655
|
-
throwError("detail");
|
|
656
|
-
}
|
|
657
|
-
if (errorInfo.context &&
|
|
658
|
-
!helpers.isString(errorInfo.context)) {
|
|
659
|
-
throwError("context");
|
|
660
|
-
}
|
|
661
|
-
if (errorInfo.information &&
|
|
662
|
-
!helpers.isUrl(errorInfo.information)) {
|
|
663
|
-
throwError("information");
|
|
664
|
-
}
|
|
665
|
-
if (errorInfo.range &&
|
|
666
|
-
(!Array.isArray(errorInfo.range) ||
|
|
667
|
-
(errorInfo.range.length !== 2) ||
|
|
668
|
-
!helpers.isNumber(errorInfo.range[0]) ||
|
|
669
|
-
(errorInfo.range[0] < 1) ||
|
|
670
|
-
!helpers.isNumber(errorInfo.range[1]) ||
|
|
671
|
-
(errorInfo.range[1] < 1) ||
|
|
672
|
-
((errorInfo.range[0] + errorInfo.range[1] - 1) >
|
|
673
|
-
lines[errorInfo.lineNumber - 1].length))) {
|
|
674
|
-
throwError("range");
|
|
675
|
-
}
|
|
676
|
-
const fixInfo = errorInfo.fixInfo;
|
|
677
|
-
const cleanFixInfo = {};
|
|
678
|
-
if (fixInfo) {
|
|
679
|
-
if (!helpers.isObject(fixInfo)) {
|
|
680
|
-
throwError("fixInfo");
|
|
681
|
-
}
|
|
682
|
-
if (fixInfo.lineNumber !== undefined) {
|
|
683
|
-
if ((!helpers.isNumber(fixInfo.lineNumber) ||
|
|
684
|
-
(fixInfo.lineNumber < 1) ||
|
|
685
|
-
(fixInfo.lineNumber > lines.length))) {
|
|
686
|
-
throwError("fixInfo.lineNumber");
|
|
687
|
-
}
|
|
688
|
-
cleanFixInfo.lineNumber =
|
|
689
|
-
fixInfo.lineNumber + frontMatterLines.length;
|
|
690
|
-
}
|
|
691
|
-
const effectiveLineNumber = fixInfo.lineNumber || errorInfo.lineNumber;
|
|
692
|
-
if (fixInfo.editColumn !== undefined) {
|
|
693
|
-
if ((!helpers.isNumber(fixInfo.editColumn) ||
|
|
694
|
-
(fixInfo.editColumn < 1) ||
|
|
695
|
-
(fixInfo.editColumn >
|
|
696
|
-
lines[effectiveLineNumber - 1].length + 1))) {
|
|
697
|
-
throwError("fixInfo.editColumn");
|
|
698
|
-
}
|
|
699
|
-
cleanFixInfo.editColumn = fixInfo.editColumn;
|
|
700
|
-
}
|
|
701
|
-
if (fixInfo.deleteCount !== undefined) {
|
|
702
|
-
if ((!helpers.isNumber(fixInfo.deleteCount) ||
|
|
703
|
-
(fixInfo.deleteCount < -1) ||
|
|
704
|
-
(fixInfo.deleteCount >
|
|
705
|
-
lines[effectiveLineNumber - 1].length))) {
|
|
706
|
-
throwError("fixInfo.deleteCount");
|
|
707
|
-
}
|
|
708
|
-
cleanFixInfo.deleteCount = fixInfo.deleteCount;
|
|
709
|
-
}
|
|
710
|
-
if (fixInfo.insertText !== undefined) {
|
|
711
|
-
if (!helpers.isString(fixInfo.insertText)) {
|
|
712
|
-
throwError("fixInfo.insertText");
|
|
713
|
-
}
|
|
714
|
-
cleanFixInfo.insertText = fixInfo.insertText;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
const information = errorInfo.information || rule.information;
|
|
718
|
-
results.push({
|
|
719
|
-
lineNumber,
|
|
720
|
-
"ruleName": rule.names[0],
|
|
721
|
-
"ruleNames": rule.names,
|
|
722
|
-
"ruleDescription": rule.description,
|
|
723
|
-
"ruleInformation": information ? information.href : null,
|
|
724
|
-
"errorDetail": errorInfo.detail || null,
|
|
725
|
-
"errorContext": errorInfo.context || null,
|
|
726
|
-
"errorRange": errorInfo.range ? [ ...errorInfo.range ] : null,
|
|
727
|
-
"fixInfo": fixInfo ? cleanFixInfo : null
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
// Call (possibly external) rule function to report errors
|
|
731
|
-
const catchCallsOnError = (error) => onError({
|
|
732
|
-
"lineNumber": 1,
|
|
733
|
-
"detail": `This rule threw an exception: ${error.message || error}`
|
|
734
|
-
});
|
|
735
|
-
const invokeRuleFunction = () => rule.function(params, onError);
|
|
736
|
-
if (rule.asynchronous) {
|
|
737
|
-
// Asynchronous rule, ensure it returns a Promise
|
|
738
|
-
const ruleFunctionPromise =
|
|
739
|
-
Promise.resolve().then(invokeRuleFunction);
|
|
740
|
-
return handleRuleFailures ?
|
|
741
|
-
ruleFunctionPromise.catch(catchCallsOnError) :
|
|
742
|
-
ruleFunctionPromise;
|
|
743
|
-
}
|
|
744
|
-
// Synchronous rule
|
|
745
|
-
try {
|
|
746
|
-
invokeRuleFunction();
|
|
747
|
-
} catch (error) {
|
|
748
|
-
if (handleRuleFailures) {
|
|
749
|
-
catchCallsOnError(error);
|
|
750
|
-
} else {
|
|
751
|
-
throw error;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
return null;
|
|
755
|
-
};
|
|
756
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
757
|
-
function formatResults() {
|
|
758
|
-
// Sort results by rule name by line number
|
|
759
|
-
results.sort((a, b) => (
|
|
760
|
-
a.ruleName.localeCompare(b.ruleName) ||
|
|
761
|
-
a.lineNumber - b.lineNumber
|
|
762
|
-
));
|
|
763
|
-
if (resultVersion < 3) {
|
|
764
|
-
// Remove fixInfo and multiple errors for the same rule and line number
|
|
765
|
-
const noPrevious = {
|
|
766
|
-
"ruleName": null,
|
|
767
|
-
"lineNumber": -1
|
|
768
|
-
};
|
|
769
|
-
results = results.filter((error, index, array) => {
|
|
770
|
-
delete error.fixInfo;
|
|
771
|
-
const previous = array[index - 1] || noPrevious;
|
|
772
|
-
return (
|
|
773
|
-
(error.ruleName !== previous.ruleName) ||
|
|
774
|
-
(error.lineNumber !== previous.lineNumber)
|
|
775
|
-
);
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
if (resultVersion === 0) {
|
|
779
|
-
// Return a dictionary of rule->[line numbers]
|
|
780
|
-
const dictionary = {};
|
|
781
|
-
for (const error of results) {
|
|
782
|
-
const ruleLines = dictionary[error.ruleName] || [];
|
|
783
|
-
ruleLines.push(error.lineNumber);
|
|
784
|
-
dictionary[error.ruleName] = ruleLines;
|
|
785
|
-
}
|
|
786
|
-
// @ts-ignore
|
|
787
|
-
results = dictionary;
|
|
788
|
-
} else if (resultVersion === 1) {
|
|
789
|
-
// Use ruleAlias instead of ruleNames
|
|
790
|
-
for (const error of results) {
|
|
791
|
-
error.ruleAlias = error.ruleNames[1] || error.ruleName;
|
|
792
|
-
delete error.ruleNames;
|
|
793
|
-
}
|
|
794
|
-
} else {
|
|
795
|
-
// resultVersion 2 or 3: Remove unwanted ruleName
|
|
796
|
-
for (const error of results) {
|
|
797
|
-
delete error.ruleName;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return results;
|
|
801
|
-
}
|
|
802
|
-
// Run all rules
|
|
803
|
-
const ruleListAsync = ruleList.filter((rule) => rule.asynchronous);
|
|
804
|
-
const ruleListSync = ruleList.filter((rule) => !rule.asynchronous);
|
|
805
|
-
const ruleListAsyncFirst = [
|
|
806
|
-
...ruleListAsync,
|
|
807
|
-
...ruleListSync
|
|
808
|
-
];
|
|
809
|
-
const callbackSuccess = () => callback(null, formatResults());
|
|
810
|
-
const callbackError =
|
|
811
|
-
(error) => callback(error instanceof Error ? error : new Error(error));
|
|
812
|
-
try {
|
|
813
|
-
const ruleResults = ruleListAsyncFirst.map(forRule);
|
|
814
|
-
if (ruleListAsync.length > 0) {
|
|
815
|
-
Promise.all(ruleResults.slice(0, ruleListAsync.length))
|
|
816
|
-
.then(callbackSuccess)
|
|
817
|
-
.catch(callbackError);
|
|
818
|
-
} else {
|
|
819
|
-
callbackSuccess();
|
|
820
|
-
}
|
|
821
|
-
} catch (error) {
|
|
822
|
-
callbackError(error);
|
|
823
|
-
} finally {
|
|
824
|
-
cache.clear();
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Lints a file containing Markdown content.
|
|
830
|
-
*
|
|
831
|
-
* @param {Rule[]} ruleList List of rules.
|
|
832
|
-
* @param {Object.<string, string[]>} aliasToRuleNames Map of alias to rule
|
|
833
|
-
* names.
|
|
834
|
-
* @param {string} file Path of file to lint.
|
|
835
|
-
* @param {Object} md Instance of markdown-it.
|
|
836
|
-
* @param {Configuration} config Configuration object.
|
|
837
|
-
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
|
838
|
-
* @param {RegExp | null} frontMatter Regular expression for front matter.
|
|
839
|
-
* @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
|
|
840
|
-
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
|
841
|
-
* @param {number} resultVersion Version of the LintResults object to return.
|
|
842
|
-
* @param {Object} fs File system implementation.
|
|
843
|
-
* @param {boolean} synchronous Whether to execute synchronously.
|
|
844
|
-
* @param {LintContentCallback} callback Callback (err, result) function.
|
|
845
|
-
* @returns {void}
|
|
846
|
-
*/
|
|
847
|
-
function lintFile(
|
|
848
|
-
ruleList,
|
|
849
|
-
aliasToRuleNames,
|
|
850
|
-
file,
|
|
851
|
-
md,
|
|
852
|
-
config,
|
|
853
|
-
configParsers,
|
|
854
|
-
frontMatter,
|
|
855
|
-
handleRuleFailures,
|
|
856
|
-
noInlineConfig,
|
|
857
|
-
resultVersion,
|
|
858
|
-
fs,
|
|
859
|
-
synchronous,
|
|
860
|
-
callback) {
|
|
861
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
862
|
-
function lintContentWrapper(err, content) {
|
|
863
|
-
if (err) {
|
|
864
|
-
return callback(err);
|
|
865
|
-
}
|
|
866
|
-
return lintContent(
|
|
867
|
-
ruleList,
|
|
868
|
-
aliasToRuleNames,
|
|
869
|
-
file,
|
|
870
|
-
content,
|
|
871
|
-
md,
|
|
872
|
-
config,
|
|
873
|
-
configParsers,
|
|
874
|
-
frontMatter,
|
|
875
|
-
handleRuleFailures,
|
|
876
|
-
noInlineConfig,
|
|
877
|
-
resultVersion,
|
|
878
|
-
callback
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
// Make a/synchronous call to read file
|
|
882
|
-
if (synchronous) {
|
|
883
|
-
lintContentWrapper(null, fs.readFileSync(file, "utf8"));
|
|
884
|
-
} else {
|
|
885
|
-
fs.readFile(file, "utf8", lintContentWrapper);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Lint files and strings specified in the Options object.
|
|
891
|
-
*
|
|
892
|
-
* @param {Options | null} options Options object.
|
|
893
|
-
* @param {boolean} synchronous Whether to execute synchronously.
|
|
894
|
-
* @param {LintCallback} callback Callback (err, result) function.
|
|
895
|
-
* @returns {void}
|
|
896
|
-
*/
|
|
897
|
-
function lintInput(options, synchronous, callback) {
|
|
898
|
-
// Normalize inputs
|
|
899
|
-
options = options || {};
|
|
900
|
-
callback = callback || function noop() {};
|
|
901
|
-
const customRuleList =
|
|
902
|
-
[ options.customRules || [] ]
|
|
903
|
-
.flat()
|
|
904
|
-
.map((rule) => ({
|
|
905
|
-
"names": helpers.cloneIfArray(rule.names),
|
|
906
|
-
"description": rule.description,
|
|
907
|
-
"information": helpers.cloneIfUrl(rule.information),
|
|
908
|
-
"tags": helpers.cloneIfArray(rule.tags),
|
|
909
|
-
"parser": rule.parser,
|
|
910
|
-
"asynchronous": rule.asynchronous,
|
|
911
|
-
"function": rule.function
|
|
912
|
-
}));
|
|
913
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
914
|
-
const ruleList = rules.concat(customRuleList);
|
|
915
|
-
const ruleErr = validateRuleList(ruleList, synchronous);
|
|
916
|
-
if (ruleErr) {
|
|
917
|
-
callback(ruleErr);
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
let files = [];
|
|
921
|
-
if (Array.isArray(options.files)) {
|
|
922
|
-
files = [ ...options.files ];
|
|
923
|
-
} else if (options.files) {
|
|
924
|
-
files = [ String(options.files) ];
|
|
925
|
-
}
|
|
926
|
-
const strings = options.strings || {};
|
|
927
|
-
const stringsKeys = Object.keys(strings);
|
|
928
|
-
const config = options.config || { "default": true };
|
|
929
|
-
const configParsers = options.configParsers || null;
|
|
930
|
-
const frontMatter = (options.frontMatter === undefined) ?
|
|
931
|
-
helpers.frontMatterRe : options.frontMatter;
|
|
932
|
-
const handleRuleFailures = !!options.handleRuleFailures;
|
|
933
|
-
const noInlineConfig = !!options.noInlineConfig;
|
|
934
|
-
const resultVersion = (options.resultVersion === undefined) ?
|
|
935
|
-
3 : options.resultVersion;
|
|
936
|
-
const md = markdownit({ "html": true });
|
|
937
|
-
const markdownItPlugins = options.markdownItPlugins || [];
|
|
938
|
-
for (const plugin of markdownItPlugins) {
|
|
939
|
-
// @ts-ignore
|
|
940
|
-
md.use(...plugin);
|
|
941
|
-
}
|
|
942
|
-
const fs = options.fs || require("node:fs");
|
|
943
|
-
const aliasToRuleNames = mapAliasToRuleNames(ruleList);
|
|
944
|
-
const results = newResults(ruleList);
|
|
945
|
-
let done = false;
|
|
946
|
-
let concurrency = 0;
|
|
947
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
948
|
-
function lintWorker() {
|
|
949
|
-
let currentItem = null;
|
|
950
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
951
|
-
function lintWorkerCallback(err, result) {
|
|
952
|
-
concurrency--;
|
|
953
|
-
if (err) {
|
|
954
|
-
done = true;
|
|
955
|
-
return callback(err);
|
|
956
|
-
}
|
|
957
|
-
results[currentItem] = result;
|
|
958
|
-
if (!synchronous) {
|
|
959
|
-
lintWorker();
|
|
960
|
-
}
|
|
961
|
-
return null;
|
|
962
|
-
}
|
|
963
|
-
if (done) {
|
|
964
|
-
// Abort for error or nothing left to do
|
|
965
|
-
} else if (files.length > 0) {
|
|
966
|
-
// Lint next file
|
|
967
|
-
concurrency++;
|
|
968
|
-
currentItem = files.shift();
|
|
969
|
-
lintFile(
|
|
970
|
-
ruleList,
|
|
971
|
-
aliasToRuleNames,
|
|
972
|
-
currentItem,
|
|
973
|
-
md,
|
|
974
|
-
config,
|
|
975
|
-
configParsers,
|
|
976
|
-
frontMatter,
|
|
977
|
-
handleRuleFailures,
|
|
978
|
-
noInlineConfig,
|
|
979
|
-
resultVersion,
|
|
980
|
-
fs,
|
|
981
|
-
synchronous,
|
|
982
|
-
lintWorkerCallback
|
|
983
|
-
);
|
|
984
|
-
} else if ((currentItem = stringsKeys.shift())) {
|
|
985
|
-
// Lint next string
|
|
986
|
-
concurrency++;
|
|
987
|
-
lintContent(
|
|
988
|
-
ruleList,
|
|
989
|
-
aliasToRuleNames,
|
|
990
|
-
currentItem,
|
|
991
|
-
strings[currentItem] || "",
|
|
992
|
-
md,
|
|
993
|
-
config,
|
|
994
|
-
configParsers,
|
|
995
|
-
frontMatter,
|
|
996
|
-
handleRuleFailures,
|
|
997
|
-
noInlineConfig,
|
|
998
|
-
resultVersion,
|
|
999
|
-
lintWorkerCallback
|
|
1000
|
-
);
|
|
1001
|
-
} else if (concurrency === 0) {
|
|
1002
|
-
// Finish
|
|
1003
|
-
done = true;
|
|
1004
|
-
return callback(null, results);
|
|
1005
|
-
}
|
|
1006
|
-
return null;
|
|
1007
|
-
}
|
|
1008
|
-
if (synchronous) {
|
|
1009
|
-
while (!done) {
|
|
1010
|
-
lintWorker();
|
|
1011
|
-
}
|
|
1012
|
-
} else {
|
|
1013
|
-
// Testing on a Raspberry Pi 4 Model B with an artificial 5ms file access
|
|
1014
|
-
// delay suggests that a concurrency factor of 8 can eliminate the impact
|
|
1015
|
-
// of that delay (i.e., total time is the same as with no delay).
|
|
1016
|
-
lintWorker();
|
|
1017
|
-
lintWorker();
|
|
1018
|
-
lintWorker();
|
|
1019
|
-
lintWorker();
|
|
1020
|
-
lintWorker();
|
|
1021
|
-
lintWorker();
|
|
1022
|
-
lintWorker();
|
|
1023
|
-
lintWorker();
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
* Lint specified Markdown files.
|
|
1029
|
-
*
|
|
1030
|
-
* @param {Options | null} options Configuration options.
|
|
1031
|
-
* @param {LintCallback} callback Callback (err, result) function.
|
|
1032
|
-
* @returns {void}
|
|
1033
|
-
*/
|
|
1034
|
-
function markdownlint(options, callback) {
|
|
1035
|
-
return lintInput(options, false, callback);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
const markdownlintPromisify = promisify && promisify(markdownlint);
|
|
1039
|
-
|
|
1040
|
-
/**
|
|
1041
|
-
* Lint specified Markdown files.
|
|
1042
|
-
*
|
|
1043
|
-
* @param {Options} options Configuration options.
|
|
1044
|
-
* @returns {Promise<LintResults>} Results object.
|
|
1045
|
-
*/
|
|
1046
|
-
function markdownlintPromise(options) {
|
|
1047
|
-
// @ts-ignore
|
|
1048
|
-
return markdownlintPromisify(options);
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
/**
|
|
1052
|
-
* Lint specified Markdown files synchronously.
|
|
1053
|
-
*
|
|
1054
|
-
* @param {Options | null} options Configuration options.
|
|
1055
|
-
* @returns {LintResults} Results object.
|
|
1056
|
-
*/
|
|
1057
|
-
function markdownlintSync(options) {
|
|
1058
|
-
let results = null;
|
|
1059
|
-
lintInput(options, true, function callback(error, res) {
|
|
1060
|
-
if (error) {
|
|
1061
|
-
throw error;
|
|
1062
|
-
}
|
|
1063
|
-
results = res;
|
|
1064
|
-
});
|
|
1065
|
-
// @ts-ignore
|
|
1066
|
-
return results;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Resolve referenced "extends" path in a configuration file
|
|
1071
|
-
* using path.resolve() with require.resolve() as a fallback.
|
|
1072
|
-
*
|
|
1073
|
-
* @param {string} configFile Configuration file name.
|
|
1074
|
-
* @param {string} referenceId Referenced identifier to resolve.
|
|
1075
|
-
* @param {Object} fs File system implementation.
|
|
1076
|
-
* @param {ResolveConfigExtendsCallback} callback Callback (err, result)
|
|
1077
|
-
* function.
|
|
1078
|
-
* @returns {void}
|
|
1079
|
-
*/
|
|
1080
|
-
function resolveConfigExtends(configFile, referenceId, fs, callback) {
|
|
1081
|
-
const configFileDirname = path.dirname(configFile);
|
|
1082
|
-
const resolvedExtendsFile = path.resolve(configFileDirname, referenceId);
|
|
1083
|
-
fs.access(resolvedExtendsFile, (err) => {
|
|
1084
|
-
if (err) {
|
|
1085
|
-
// Not a file, try require.resolve
|
|
1086
|
-
try {
|
|
1087
|
-
return callback(null, dynamicRequire.resolve(
|
|
1088
|
-
referenceId,
|
|
1089
|
-
{ "paths": [ configFileDirname ] }
|
|
1090
|
-
));
|
|
1091
|
-
} catch {
|
|
1092
|
-
// Unable to resolve, use resolvedExtendsFile
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
return callback(null, resolvedExtendsFile);
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
/**
|
|
1100
|
-
* Resolve referenced "extends" path in a configuration file
|
|
1101
|
-
* using path.resolve() with require.resolve() as a fallback.
|
|
1102
|
-
*
|
|
1103
|
-
* @param {string} configFile Configuration file name.
|
|
1104
|
-
* @param {string} referenceId Referenced identifier to resolve.
|
|
1105
|
-
* @param {Object} fs File system implementation.
|
|
1106
|
-
* @returns {string} Resolved path to file.
|
|
1107
|
-
*/
|
|
1108
|
-
function resolveConfigExtendsSync(configFile, referenceId, fs) {
|
|
1109
|
-
const configFileDirname = path.dirname(configFile);
|
|
1110
|
-
const resolvedExtendsFile = path.resolve(configFileDirname, referenceId);
|
|
1111
|
-
try {
|
|
1112
|
-
fs.accessSync(resolvedExtendsFile);
|
|
1113
|
-
return resolvedExtendsFile;
|
|
1114
|
-
} catch {
|
|
1115
|
-
// Not a file, try require.resolve
|
|
1116
|
-
}
|
|
1117
|
-
try {
|
|
1118
|
-
return dynamicRequire.resolve(
|
|
1119
|
-
referenceId,
|
|
1120
|
-
{ "paths": [ configFileDirname ] }
|
|
1121
|
-
);
|
|
1122
|
-
} catch {
|
|
1123
|
-
// Unable to resolve, return resolvedExtendsFile
|
|
1124
|
-
}
|
|
1125
|
-
return resolvedExtendsFile;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
/**
|
|
1129
|
-
* Extend specified configuration object.
|
|
1130
|
-
*
|
|
1131
|
-
* @param {Configuration} config Configuration object.
|
|
1132
|
-
* @param {string} file Configuration file name.
|
|
1133
|
-
* @param {ConfigurationParser[]} parsers Parsing
|
|
1134
|
-
* function(s).
|
|
1135
|
-
* @param {Object} fs File system implementation.
|
|
1136
|
-
* @param {ReadConfigCallback} callback Callback (err, result) function.
|
|
1137
|
-
* @returns {void}
|
|
1138
|
-
*/
|
|
1139
|
-
function extendConfig(config, file, parsers, fs, callback) {
|
|
1140
|
-
const configExtends = config.extends;
|
|
1141
|
-
if (configExtends) {
|
|
1142
|
-
return resolveConfigExtends(
|
|
1143
|
-
file,
|
|
1144
|
-
helpers.expandTildePath(configExtends, require("node:os")),
|
|
1145
|
-
fs,
|
|
1146
|
-
// eslint-disable-next-line no-use-before-define
|
|
1147
|
-
(_, resolvedExtends) => readConfig(
|
|
1148
|
-
// @ts-ignore
|
|
1149
|
-
resolvedExtends,
|
|
1150
|
-
parsers,
|
|
1151
|
-
fs,
|
|
1152
|
-
(err, extendsConfig) => {
|
|
1153
|
-
if (err) {
|
|
1154
|
-
return callback(err);
|
|
1155
|
-
}
|
|
1156
|
-
const result = {
|
|
1157
|
-
...extendsConfig,
|
|
1158
|
-
...config
|
|
1159
|
-
};
|
|
1160
|
-
delete result.extends;
|
|
1161
|
-
return callback(null, result);
|
|
1162
|
-
}
|
|
1163
|
-
)
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1166
|
-
return callback(null, config);
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
const extendConfigPromisify = promisify && promisify(extendConfig);
|
|
1170
|
-
|
|
1171
|
-
/**
|
|
1172
|
-
* Extend specified configuration object.
|
|
1173
|
-
*
|
|
1174
|
-
* @param {Configuration} config Configuration object.
|
|
1175
|
-
* @param {string} file Configuration file name.
|
|
1176
|
-
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
1177
|
-
* @param {Object} [fs] File system implementation.
|
|
1178
|
-
* @returns {Promise<Configuration>} Configuration object.
|
|
1179
|
-
*/
|
|
1180
|
-
function extendConfigPromise(config, file, parsers, fs) {
|
|
1181
|
-
// @ts-ignore
|
|
1182
|
-
return extendConfigPromisify(config, file, parsers, fs);
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
/**
|
|
1186
|
-
* Read specified configuration file.
|
|
1187
|
-
*
|
|
1188
|
-
* @param {string} file Configuration file name.
|
|
1189
|
-
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
|
1190
|
-
* function(s).
|
|
1191
|
-
* @param {Object} [fs] File system implementation.
|
|
1192
|
-
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
|
1193
|
-
* @returns {void}
|
|
1194
|
-
*/
|
|
1195
|
-
function readConfig(file, parsers, fs, callback) {
|
|
1196
|
-
if (!callback) {
|
|
1197
|
-
if (fs) {
|
|
1198
|
-
callback = fs;
|
|
1199
|
-
fs = null;
|
|
1200
|
-
} else {
|
|
1201
|
-
// @ts-ignore
|
|
1202
|
-
callback = parsers;
|
|
1203
|
-
// @ts-ignore
|
|
1204
|
-
parsers = null;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
if (!fs) {
|
|
1208
|
-
fs = require("node:fs");
|
|
1209
|
-
}
|
|
1210
|
-
// Read file
|
|
1211
|
-
file = helpers.expandTildePath(file, require("node:os"));
|
|
1212
|
-
fs.readFile(file, "utf8", (err, content) => {
|
|
1213
|
-
if (err) {
|
|
1214
|
-
// @ts-ignore
|
|
1215
|
-
return callback(err);
|
|
1216
|
-
}
|
|
1217
|
-
// Try to parse file
|
|
1218
|
-
// @ts-ignore
|
|
1219
|
-
const { config, message } = parseConfiguration(file, content, parsers);
|
|
1220
|
-
if (!config) {
|
|
1221
|
-
// @ts-ignore
|
|
1222
|
-
return callback(new Error(message));
|
|
1223
|
-
}
|
|
1224
|
-
// Extend configuration
|
|
1225
|
-
// @ts-ignore
|
|
1226
|
-
return extendConfig(config, file, parsers, fs, callback);
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
const readConfigPromisify = promisify && promisify(readConfig);
|
|
1231
|
-
|
|
1232
|
-
/**
|
|
1233
|
-
* Read specified configuration file.
|
|
1234
|
-
*
|
|
1235
|
-
* @param {string} file Configuration file name.
|
|
1236
|
-
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
1237
|
-
* @param {Object} [fs] File system implementation.
|
|
1238
|
-
* @returns {Promise<Configuration>} Configuration object.
|
|
1239
|
-
*/
|
|
1240
|
-
function readConfigPromise(file, parsers, fs) {
|
|
1241
|
-
// @ts-ignore
|
|
1242
|
-
return readConfigPromisify(file, parsers, fs);
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
* Read specified configuration file synchronously.
|
|
1247
|
-
*
|
|
1248
|
-
* @param {string} file Configuration file name.
|
|
1249
|
-
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
1250
|
-
* @param {Object} [fs] File system implementation.
|
|
1251
|
-
* @returns {Configuration} Configuration object.
|
|
1252
|
-
* @throws An Error if processing fails.
|
|
1253
|
-
*/
|
|
1254
|
-
function readConfigSync(file, parsers, fs) {
|
|
1255
|
-
if (!fs) {
|
|
1256
|
-
fs = require("node:fs");
|
|
1257
|
-
}
|
|
1258
|
-
// Read file
|
|
1259
|
-
const os = require("node:os");
|
|
1260
|
-
file = helpers.expandTildePath(file, os);
|
|
1261
|
-
const content = fs.readFileSync(file, "utf8");
|
|
1262
|
-
// Try to parse file
|
|
1263
|
-
const { config, message } = parseConfiguration(file, content, parsers);
|
|
1264
|
-
if (!config) {
|
|
1265
|
-
throw new Error(message);
|
|
1266
|
-
}
|
|
1267
|
-
// Extend configuration
|
|
1268
|
-
const configExtends = config.extends;
|
|
1269
|
-
if (configExtends) {
|
|
1270
|
-
delete config.extends;
|
|
1271
|
-
const resolvedExtends = resolveConfigExtendsSync(
|
|
1272
|
-
file,
|
|
1273
|
-
helpers.expandTildePath(configExtends, os),
|
|
1274
|
-
fs
|
|
1275
|
-
);
|
|
1276
|
-
return {
|
|
1277
|
-
...readConfigSync(resolvedExtends, parsers, fs),
|
|
1278
|
-
...config
|
|
1279
|
-
};
|
|
1280
|
-
}
|
|
1281
|
-
return config;
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
/**
|
|
1285
|
-
* Gets the (semantic) version of the library.
|
|
1286
|
-
*
|
|
1287
|
-
* @returns {string} SemVer string.
|
|
1288
|
-
*/
|
|
1289
|
-
function getVersion() {
|
|
1290
|
-
return require("./constants").version;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
// Export a/synchronous/Promise APIs
|
|
1294
|
-
markdownlint.sync = markdownlintSync;
|
|
1295
|
-
markdownlint.readConfig = readConfig;
|
|
1296
|
-
markdownlint.readConfigSync = readConfigSync;
|
|
1297
|
-
markdownlint.getVersion = getVersion;
|
|
1298
|
-
markdownlint.promises = {
|
|
1299
|
-
"markdownlint": markdownlintPromise,
|
|
1300
|
-
"extendConfig": extendConfigPromise,
|
|
1301
|
-
"readConfig": readConfigPromise
|
|
1302
|
-
};
|
|
1303
|
-
module.exports = markdownlint;
|
|
1304
|
-
|
|
1305
|
-
// Type declarations
|
|
1306
|
-
|
|
1307
|
-
/**
|
|
1308
|
-
* Function to implement rule logic.
|
|
1309
|
-
*
|
|
1310
|
-
* @callback RuleFunction
|
|
1311
|
-
* @param {RuleParams} params Rule parameters.
|
|
1312
|
-
* @param {RuleOnError} onError Error-reporting callback.
|
|
1313
|
-
* @returns {void}
|
|
1314
|
-
*/
|
|
1315
|
-
|
|
1316
|
-
/* eslint-disable jsdoc/valid-types */
|
|
1317
|
-
|
|
1318
|
-
/**
|
|
1319
|
-
* Rule parameters.
|
|
1320
|
-
*
|
|
1321
|
-
* @typedef {Object} RuleParams
|
|
1322
|
-
* @property {string} name File/string name.
|
|
1323
|
-
* @property {MarkdownParsers} parsers Markdown parser data.
|
|
1324
|
-
* @property {readonly string[]} lines File/string lines.
|
|
1325
|
-
* @property {readonly string[]} frontMatterLines Front matter lines.
|
|
1326
|
-
* @property {RuleConfiguration} config Rule configuration.
|
|
1327
|
-
*/
|
|
1328
|
-
|
|
1329
|
-
/* eslint-enable jsdoc/valid-types */
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* Markdown parser data.
|
|
1333
|
-
*
|
|
1334
|
-
* @typedef {Object} MarkdownParsers
|
|
1335
|
-
* @property {ParserMarkdownIt} markdownit Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
|
|
1336
|
-
* @property {ParserMicromark} micromark Markdown parser data from micromark (only present when Rule.parser is "micromark").
|
|
1337
|
-
*/
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* Markdown parser data from markdown-it.
|
|
1341
|
-
*
|
|
1342
|
-
* @typedef {Object} ParserMarkdownIt
|
|
1343
|
-
* @property {MarkdownItToken[]} tokens Token objects from markdown-it.
|
|
1344
|
-
*/
|
|
1345
|
-
|
|
1346
|
-
/**
|
|
1347
|
-
* Markdown parser data from micromark.
|
|
1348
|
-
*
|
|
1349
|
-
* @typedef {Object} ParserMicromark
|
|
1350
|
-
* @property {MicromarkToken[]} tokens Token objects from micromark.
|
|
1351
|
-
*/
|
|
1352
|
-
|
|
1353
|
-
/**
|
|
1354
|
-
* markdown-it token.
|
|
1355
|
-
*
|
|
1356
|
-
* @typedef {Object} MarkdownItToken
|
|
1357
|
-
* @property {string[][]} attrs HTML attributes.
|
|
1358
|
-
* @property {boolean} block Block-level token.
|
|
1359
|
-
* @property {MarkdownItToken[]} children Child nodes.
|
|
1360
|
-
* @property {string} content Tag contents.
|
|
1361
|
-
* @property {boolean} hidden Ignore element.
|
|
1362
|
-
* @property {string} info Fence info.
|
|
1363
|
-
* @property {number} level Nesting level.
|
|
1364
|
-
* @property {number[]} map Beginning/ending line numbers.
|
|
1365
|
-
* @property {string} markup Markup text.
|
|
1366
|
-
* @property {Object} meta Arbitrary data.
|
|
1367
|
-
* @property {number} nesting Level change.
|
|
1368
|
-
* @property {string} tag HTML tag name.
|
|
1369
|
-
* @property {string} type Token type.
|
|
1370
|
-
* @property {number} lineNumber Line number (1-based).
|
|
1371
|
-
* @property {string} line Line content.
|
|
1372
|
-
*/
|
|
1373
|
-
|
|
1374
|
-
/** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
|
|
1375
|
-
|
|
1376
|
-
/**
|
|
1377
|
-
* micromark token.
|
|
1378
|
-
*
|
|
1379
|
-
* @typedef {Object} MicromarkToken
|
|
1380
|
-
* @property {MicromarkTokenType} type Token type.
|
|
1381
|
-
* @property {number} startLine Start line (1-based).
|
|
1382
|
-
* @property {number} startColumn Start column (1-based).
|
|
1383
|
-
* @property {number} endLine End line (1-based).
|
|
1384
|
-
* @property {number} endColumn End column (1-based).
|
|
1385
|
-
* @property {string} text Token text.
|
|
1386
|
-
* @property {MicromarkToken[]} children Child tokens.
|
|
1387
|
-
* @property {MicromarkToken | null} parent Parent token.
|
|
1388
|
-
*/
|
|
1389
|
-
|
|
1390
|
-
/**
|
|
1391
|
-
* Error-reporting callback.
|
|
1392
|
-
*
|
|
1393
|
-
* @callback RuleOnError
|
|
1394
|
-
* @param {RuleOnErrorInfo} onErrorInfo Error information.
|
|
1395
|
-
* @returns {void}
|
|
1396
|
-
*/
|
|
1397
|
-
|
|
1398
|
-
/**
|
|
1399
|
-
* Fix information for RuleOnError callback.
|
|
1400
|
-
*
|
|
1401
|
-
* @typedef {Object} RuleOnErrorInfo
|
|
1402
|
-
* @property {number} lineNumber Line number (1-based).
|
|
1403
|
-
* @property {string} [detail] Detail about the error.
|
|
1404
|
-
* @property {string} [context] Context for the error.
|
|
1405
|
-
* @property {URL} [information] Link to more information.
|
|
1406
|
-
* @property {number[]} [range] Column number (1-based) and length.
|
|
1407
|
-
* @property {RuleOnErrorFixInfo} [fixInfo] Fix information.
|
|
1408
|
-
*/
|
|
1409
|
-
|
|
1410
|
-
/**
|
|
1411
|
-
* Fix information for RuleOnErrorInfo.
|
|
1412
|
-
*
|
|
1413
|
-
* @typedef {Object} RuleOnErrorFixInfo
|
|
1414
|
-
* @property {number} [lineNumber] Line number (1-based).
|
|
1415
|
-
* @property {number} [editColumn] Column of the fix (1-based).
|
|
1416
|
-
* @property {number} [deleteCount] Count of characters to delete.
|
|
1417
|
-
* @property {string} [insertText] Text to insert (after deleting).
|
|
1418
|
-
*/
|
|
1419
|
-
|
|
1420
|
-
/**
|
|
1421
|
-
* Rule definition.
|
|
1422
|
-
*
|
|
1423
|
-
* @typedef {Object} Rule
|
|
1424
|
-
* @property {string[]} names Rule name(s).
|
|
1425
|
-
* @property {string} description Rule description.
|
|
1426
|
-
* @property {URL} [information] Link to more information.
|
|
1427
|
-
* @property {string[]} tags Rule tag(s).
|
|
1428
|
-
* @property {"markdownit" | "micromark" | "none"} parser Parser used.
|
|
1429
|
-
* @property {boolean} [asynchronous] True if asynchronous.
|
|
1430
|
-
* @property {RuleFunction} function Rule implementation.
|
|
1431
|
-
*/
|
|
1432
|
-
|
|
1433
|
-
/**
|
|
1434
|
-
* Configuration options.
|
|
1435
|
-
*
|
|
1436
|
-
* @typedef {Object} Options
|
|
1437
|
-
* @property {Configuration} [config] Configuration object.
|
|
1438
|
-
* @property {ConfigurationParser[]} [configParsers] Configuration parsers.
|
|
1439
|
-
* @property {Rule[] | Rule} [customRules] Custom rules.
|
|
1440
|
-
* @property {string[] | string} [files] Files to lint.
|
|
1441
|
-
* @property {RegExp | null} [frontMatter] Front matter pattern.
|
|
1442
|
-
* @property {Object} [fs] File system implementation.
|
|
1443
|
-
* @property {boolean} [handleRuleFailures] True to catch exceptions.
|
|
1444
|
-
* @property {Plugin[]} [markdownItPlugins] Additional plugins.
|
|
1445
|
-
* @property {boolean} [noInlineConfig] True to ignore HTML directives.
|
|
1446
|
-
* @property {number} [resultVersion] Results object version.
|
|
1447
|
-
* @property {Object.<string, string>} [strings] Strings to lint.
|
|
1448
|
-
*/
|
|
1449
|
-
|
|
1450
|
-
/**
|
|
1451
|
-
* A markdown-it plugin.
|
|
1452
|
-
*
|
|
1453
|
-
* @typedef {Array} Plugin
|
|
1454
|
-
*/
|
|
1455
|
-
|
|
1456
|
-
/**
|
|
1457
|
-
* Function to pretty-print lint results.
|
|
1458
|
-
*
|
|
1459
|
-
* @callback ToStringCallback
|
|
1460
|
-
* @param {boolean} [ruleAliases] True to use rule aliases.
|
|
1461
|
-
* @returns {string}
|
|
1462
|
-
*/
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
* Lint results (for resultVersion 3).
|
|
1466
|
-
*
|
|
1467
|
-
* @typedef {Object.<string, LintError[]>} LintResults
|
|
1468
|
-
* @property {ToStringCallback} toString String representation.
|
|
1469
|
-
*/
|
|
1470
|
-
|
|
1471
|
-
/**
|
|
1472
|
-
* Lint error.
|
|
1473
|
-
*
|
|
1474
|
-
* @typedef {Object} LintError
|
|
1475
|
-
* @property {number} lineNumber Line number (1-based).
|
|
1476
|
-
* @property {string[]} ruleNames Rule name(s).
|
|
1477
|
-
* @property {string} ruleDescription Rule description.
|
|
1478
|
-
* @property {string} ruleInformation Link to more information.
|
|
1479
|
-
* @property {string} errorDetail Detail about the error.
|
|
1480
|
-
* @property {string} errorContext Context for the error.
|
|
1481
|
-
* @property {number[]} errorRange Column number (1-based) and length.
|
|
1482
|
-
* @property {FixInfo} [fixInfo] Fix information.
|
|
1483
|
-
*/
|
|
1484
|
-
|
|
1485
|
-
/**
|
|
1486
|
-
* Fix information.
|
|
1487
|
-
*
|
|
1488
|
-
* @typedef {Object} FixInfo
|
|
1489
|
-
* @property {number} [lineNumber] Line number (1-based).
|
|
1490
|
-
* @property {number} [editColumn] Column of the fix (1-based).
|
|
1491
|
-
* @property {number} [deleteCount] Count of characters to delete.
|
|
1492
|
-
* @property {string} [insertText] Text to insert (after deleting).
|
|
1493
|
-
*/
|
|
1494
|
-
|
|
1495
|
-
/**
|
|
1496
|
-
* Called with the result of linting a string or document.
|
|
1497
|
-
*
|
|
1498
|
-
* @callback LintContentCallback
|
|
1499
|
-
* @param {Error | null} error Error iff failed.
|
|
1500
|
-
* @param {LintError[]} [result] Result iff successful.
|
|
1501
|
-
* @returns {void}
|
|
1502
|
-
*/
|
|
1503
|
-
|
|
1504
|
-
/**
|
|
1505
|
-
* Called with the result of the lint function.
|
|
1506
|
-
*
|
|
1507
|
-
* @callback LintCallback
|
|
1508
|
-
* @param {Error | null} error Error object iff failed.
|
|
1509
|
-
* @param {LintResults} [results] Lint results iff succeeded.
|
|
1510
|
-
* @returns {void}
|
|
1511
|
-
*/
|
|
1512
|
-
|
|
1513
|
-
/**
|
|
1514
|
-
* Configuration object for linting rules. For the JSON schema, see
|
|
1515
|
-
* {@link ../schema/markdownlint-config-schema.json}.
|
|
1516
|
-
*
|
|
1517
|
-
* @typedef {import("./configuration").Configuration} Configuration
|
|
1518
|
-
*/
|
|
1519
|
-
|
|
1520
|
-
/**
|
|
1521
|
-
* Rule configuration object.
|
|
1522
|
-
*
|
|
1523
|
-
* @typedef {boolean | Object} RuleConfiguration Rule configuration.
|
|
1524
|
-
*/
|
|
1525
|
-
|
|
1526
|
-
/**
|
|
1527
|
-
* Parses a configuration string and returns a configuration object.
|
|
1528
|
-
*
|
|
1529
|
-
* @callback ConfigurationParser
|
|
1530
|
-
* @param {string} text Configuration string.
|
|
1531
|
-
* @returns {Configuration}
|
|
1532
|
-
*/
|
|
1533
|
-
|
|
1534
|
-
/**
|
|
1535
|
-
* Called with the result of the readConfig function.
|
|
1536
|
-
*
|
|
1537
|
-
* @callback ReadConfigCallback
|
|
1538
|
-
* @param {Error | null} err Error object or null.
|
|
1539
|
-
* @param {Configuration} [config] Configuration object.
|
|
1540
|
-
* @returns {void}
|
|
1541
|
-
*/
|
|
1542
|
-
|
|
1543
|
-
/**
|
|
1544
|
-
* Called with the result of the resolveConfigExtends function.
|
|
1545
|
-
*
|
|
1546
|
-
* @callback ResolveConfigExtendsCallback
|
|
1547
|
-
* @param {Error | null} err Error object or null.
|
|
1548
|
-
* @param {string} [path] Resolved path to file.
|
|
1549
|
-
* @returns {void}
|
|
1550
|
-
*/
|