@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,40 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, forEachLine, isBlankLine } = require("../helpers");
|
|
6
|
-
const { lineMetadata } = require("./cache");
|
|
7
|
-
|
|
8
|
-
const codeFencePrefixRe = /^(.*?)[`~]/;
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
"names": [ "MD031", "blanks-around-fences" ],
|
|
12
|
-
"description": "Fenced code blocks should be surrounded by blank lines",
|
|
13
|
-
"tags": [ "code", "blank_lines" ],
|
|
14
|
-
"function": function MD031(params, onError) {
|
|
15
|
-
const listItems = params.config.list_items;
|
|
16
|
-
const includeListItems = (listItems === undefined) ? true : !!listItems;
|
|
17
|
-
const { lines } = params;
|
|
18
|
-
forEachLine(lineMetadata(), (line, i, inCode, onFence, inTable, inItem) => {
|
|
19
|
-
const onTopFence = (onFence > 0);
|
|
20
|
-
const onBottomFence = (onFence < 0);
|
|
21
|
-
if ((includeListItems || !inItem) &&
|
|
22
|
-
((onTopFence && !isBlankLine(lines[i - 1])) ||
|
|
23
|
-
(onBottomFence && !isBlankLine(lines[i + 1])))) {
|
|
24
|
-
const [ , prefix ] = line.match(codeFencePrefixRe) || [];
|
|
25
|
-
const fixInfo = (prefix === undefined) ? null : {
|
|
26
|
-
"lineNumber": i + (onTopFence ? 1 : 2),
|
|
27
|
-
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
|
28
|
-
};
|
|
29
|
-
addErrorContext(
|
|
30
|
-
onError,
|
|
31
|
-
i + 1,
|
|
32
|
-
lines[i].trim(),
|
|
33
|
-
null,
|
|
34
|
-
null,
|
|
35
|
-
null,
|
|
36
|
-
fixInfo);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, blockquotePrefixRe, isBlankLine } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
const { filterByPredicate } = require("../helpers/micromark.cjs");
|
|
8
|
-
|
|
9
|
-
const nonContentTokens = new Set([
|
|
10
|
-
"blockQuoteMarker",
|
|
11
|
-
"blockQuotePrefix",
|
|
12
|
-
"blockQuotePrefixWhitespace",
|
|
13
|
-
"lineEnding",
|
|
14
|
-
"lineEndingBlank",
|
|
15
|
-
"linePrefix",
|
|
16
|
-
"listItemIndent"
|
|
17
|
-
]);
|
|
18
|
-
const isList = (token) => (
|
|
19
|
-
(token.type === "listOrdered") || (token.type === "listUnordered")
|
|
20
|
-
);
|
|
21
|
-
const addBlankLineError = (onError, lines, lineIndex, lineNumber) => {
|
|
22
|
-
const line = lines[lineIndex];
|
|
23
|
-
const quotePrefix = line.match(blockquotePrefixRe)[0].trimEnd();
|
|
24
|
-
addErrorContext(
|
|
25
|
-
onError,
|
|
26
|
-
lineIndex + 1,
|
|
27
|
-
line.trim(),
|
|
28
|
-
null,
|
|
29
|
-
null,
|
|
30
|
-
null,
|
|
31
|
-
{
|
|
32
|
-
lineNumber,
|
|
33
|
-
"insertText": `${quotePrefix}\n`
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
module.exports = {
|
|
39
|
-
"names": [ "MD032", "blanks-around-lists" ],
|
|
40
|
-
"description": "Lists should be surrounded by blank lines",
|
|
41
|
-
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
|
42
|
-
"function": function MD032(params, onError) {
|
|
43
|
-
const { lines, parsers } = params;
|
|
44
|
-
|
|
45
|
-
// For every top-level list...
|
|
46
|
-
const topLevelLists = filterByPredicate(
|
|
47
|
-
parsers.micromark.tokens,
|
|
48
|
-
isList,
|
|
49
|
-
(token) => (
|
|
50
|
-
(isList(token) || (token.type === "htmlFlow")) ? [] : token.children
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
for (const list of topLevelLists) {
|
|
54
|
-
|
|
55
|
-
// Look for a blank line above the list
|
|
56
|
-
const firstIndex = list.startLine - 1;
|
|
57
|
-
if (!isBlankLine(lines[firstIndex - 1])) {
|
|
58
|
-
addBlankLineError(onError, lines, firstIndex);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Find the "visual" end of the list
|
|
62
|
-
let endLine = list.endLine;
|
|
63
|
-
const flattenedChildren = filterByPredicate(list.children);
|
|
64
|
-
for (const child of flattenedChildren.reverse()) {
|
|
65
|
-
if (!nonContentTokens.has(child.type)) {
|
|
66
|
-
endLine = child.endLine;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Look for a blank line below the list
|
|
72
|
-
const lastIndex = endLine - 1;
|
|
73
|
-
if (!isBlankLine(lines[lastIndex + 1])) {
|
|
74
|
-
addBlankLineError(onError, lines, lastIndex, lastIndex + 2);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, nextLinesRe } = require("../helpers");
|
|
6
|
-
const { filterByTypes, getHtmlTagInfo } =
|
|
7
|
-
require("../helpers/micromark.cjs");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD033", "no-inline-html" ],
|
|
11
|
-
"description": "Inline HTML",
|
|
12
|
-
"tags": [ "html" ],
|
|
13
|
-
"function": function MD033(params, onError) {
|
|
14
|
-
let allowedElements = params.config.allowed_elements;
|
|
15
|
-
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
|
16
|
-
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
|
17
|
-
const { tokens } = params.parsers.micromark;
|
|
18
|
-
for (const token of filterByTypes(tokens, [ "htmlText" ])) {
|
|
19
|
-
const htmlTagInfo = getHtmlTagInfo(token);
|
|
20
|
-
if (
|
|
21
|
-
htmlTagInfo &&
|
|
22
|
-
!htmlTagInfo.close &&
|
|
23
|
-
!allowedElements.includes(htmlTagInfo.name.toLowerCase())
|
|
24
|
-
) {
|
|
25
|
-
const range = [
|
|
26
|
-
token.startColumn,
|
|
27
|
-
token.text.replace(nextLinesRe, "").length
|
|
28
|
-
];
|
|
29
|
-
addError(
|
|
30
|
-
onError,
|
|
31
|
-
token.startLine,
|
|
32
|
-
"Element: " + htmlTagInfo.name,
|
|
33
|
-
undefined,
|
|
34
|
-
range
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext } = require("../helpers");
|
|
6
|
-
const { filterByPredicate, filterByTypes, getHtmlTagInfo, inHtmlFlow, parse } =
|
|
7
|
-
require("../helpers/micromark.cjs");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD034", "no-bare-urls" ],
|
|
11
|
-
"description": "Bare URL used",
|
|
12
|
-
"tags": [ "links", "url" ],
|
|
13
|
-
"function": function MD034(params, onError) {
|
|
14
|
-
const literalAutolinks = (tokens) => (
|
|
15
|
-
filterByPredicate(
|
|
16
|
-
tokens,
|
|
17
|
-
(token) => (token.type === "literalAutolink") && !inHtmlFlow(token),
|
|
18
|
-
(token) => {
|
|
19
|
-
const { children } = token;
|
|
20
|
-
const result = [];
|
|
21
|
-
for (let i = 0; i < children.length; i++) {
|
|
22
|
-
const current = children[i];
|
|
23
|
-
const openTagInfo = getHtmlTagInfo(current);
|
|
24
|
-
if (openTagInfo && !openTagInfo.close) {
|
|
25
|
-
let count = 1;
|
|
26
|
-
for (let j = i + 1; j < children.length; j++) {
|
|
27
|
-
const candidate = children[j];
|
|
28
|
-
const closeTagInfo = getHtmlTagInfo(candidate);
|
|
29
|
-
if (closeTagInfo && (openTagInfo.name === closeTagInfo.name)) {
|
|
30
|
-
if (closeTagInfo.close) {
|
|
31
|
-
count--;
|
|
32
|
-
if (count === 0) {
|
|
33
|
-
i = j;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
count++;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
result.push(current);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
);
|
|
49
|
-
const autoLinks = filterByTypes(
|
|
50
|
-
params.parsers.micromark.tokens,
|
|
51
|
-
[ "literalAutolink" ]
|
|
52
|
-
);
|
|
53
|
-
if (autoLinks.length > 0) {
|
|
54
|
-
// Re-parse with correct link/image reference definition handling
|
|
55
|
-
const document = params.lines.join("\n");
|
|
56
|
-
const tokens = parse(document, undefined, false);
|
|
57
|
-
for (const token of literalAutolinks(tokens)) {
|
|
58
|
-
const range = [
|
|
59
|
-
token.startColumn,
|
|
60
|
-
token.endColumn - token.startColumn
|
|
61
|
-
];
|
|
62
|
-
const fixInfo = {
|
|
63
|
-
"editColumn": range[0],
|
|
64
|
-
"deleteCount": range[1],
|
|
65
|
-
"insertText": `<${token.text}>`
|
|
66
|
-
};
|
|
67
|
-
addErrorContext(
|
|
68
|
-
onError,
|
|
69
|
-
token.startLine,
|
|
70
|
-
token.text,
|
|
71
|
-
null,
|
|
72
|
-
null,
|
|
73
|
-
range,
|
|
74
|
-
fixInfo
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
-
const { filterByTypes } = require("../helpers/micromark.cjs");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD035", "hr-style" ],
|
|
10
|
-
"description": "Horizontal rule style",
|
|
11
|
-
"tags": [ "hr" ],
|
|
12
|
-
"function": function MD035(params, onError) {
|
|
13
|
-
let style = String(params.config.style || "consistent").trim();
|
|
14
|
-
const thematicBreaks =
|
|
15
|
-
filterByTypes(params.parsers.micromark.tokens, [ "thematicBreak" ]);
|
|
16
|
-
for (const token of thematicBreaks) {
|
|
17
|
-
const { startLine, text } = token;
|
|
18
|
-
if (style === "consistent") {
|
|
19
|
-
style = text;
|
|
20
|
-
}
|
|
21
|
-
addErrorDetailIf(onError, startLine, style, text);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, allPunctuation } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD036", "no-emphasis-as-heading" ],
|
|
9
|
-
"description": "Emphasis used instead of a heading",
|
|
10
|
-
"tags": [ "headings", "emphasis" ],
|
|
11
|
-
"function": function MD036(params, onError) {
|
|
12
|
-
let punctuation = params.config.punctuation;
|
|
13
|
-
punctuation =
|
|
14
|
-
String((punctuation === undefined) ? allPunctuation : punctuation);
|
|
15
|
-
const re = new RegExp("[" + punctuation + "]$");
|
|
16
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
17
|
-
function base(token) {
|
|
18
|
-
if (token.type === "paragraph_open") {
|
|
19
|
-
return function inParagraph(t) {
|
|
20
|
-
// Always paragraph_open/inline/paragraph_close,
|
|
21
|
-
const children = t.children.filter(function notEmptyText(child) {
|
|
22
|
-
return (child.type !== "text") || (child.content !== "");
|
|
23
|
-
});
|
|
24
|
-
if ((children.length === 3) &&
|
|
25
|
-
((children[0].type === "strong_open") ||
|
|
26
|
-
(children[0].type === "em_open")) &&
|
|
27
|
-
(children[1].type === "text") &&
|
|
28
|
-
!re.test(children[1].content)) {
|
|
29
|
-
addErrorContext(onError, t.lineNumber,
|
|
30
|
-
children[1].content);
|
|
31
|
-
}
|
|
32
|
-
return base;
|
|
33
|
-
};
|
|
34
|
-
} else if (token.type === "blockquote_open") {
|
|
35
|
-
return function inBlockquote(t) {
|
|
36
|
-
if (t.type !== "blockquote_close") {
|
|
37
|
-
return inBlockquote;
|
|
38
|
-
}
|
|
39
|
-
return base;
|
|
40
|
-
};
|
|
41
|
-
} else if (token.type === "list_item_open") {
|
|
42
|
-
return function inListItem(t) {
|
|
43
|
-
if (t.type !== "list_item_close") {
|
|
44
|
-
return inListItem;
|
|
45
|
-
}
|
|
46
|
-
return base;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return base;
|
|
50
|
-
}
|
|
51
|
-
let state = base;
|
|
52
|
-
for (const token of params.parsers.markdownit.tokens) {
|
|
53
|
-
state = state(token);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError } = require("../helpers");
|
|
6
|
-
const { filterByPredicate, inHtmlFlow } = require("../helpers/micromark.cjs");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD037", "no-space-in-emphasis" ],
|
|
10
|
-
"description": "Spaces inside emphasis markers",
|
|
11
|
-
"tags": [ "whitespace", "emphasis" ],
|
|
12
|
-
"function": function MD037(params, onError) {
|
|
13
|
-
|
|
14
|
-
// Initialize variables
|
|
15
|
-
const { lines, parsers } = params;
|
|
16
|
-
const emphasisTokensByMarker = new Map();
|
|
17
|
-
for (const marker of [ "_", "__", "___", "*", "**", "***" ]) {
|
|
18
|
-
emphasisTokensByMarker.set(marker, []);
|
|
19
|
-
}
|
|
20
|
-
const tokens = filterByPredicate(
|
|
21
|
-
parsers.micromark.tokens,
|
|
22
|
-
(token) => token.children.some((child) => child.type === "data")
|
|
23
|
-
);
|
|
24
|
-
for (const token of tokens) {
|
|
25
|
-
|
|
26
|
-
// Build lists of bare tokens for each emphasis marker type
|
|
27
|
-
for (const emphasisTokens of emphasisTokensByMarker.values()) {
|
|
28
|
-
emphasisTokens.length = 0;
|
|
29
|
-
}
|
|
30
|
-
for (const child of token.children) {
|
|
31
|
-
const { text, type } = child;
|
|
32
|
-
if ((type === "data") && (text.length <= 3)) {
|
|
33
|
-
const emphasisTokens = emphasisTokensByMarker.get(text);
|
|
34
|
-
if (emphasisTokens && !inHtmlFlow(child)) {
|
|
35
|
-
emphasisTokens.push(child);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Process bare tokens for each emphasis marker type
|
|
41
|
-
for (const entry of emphasisTokensByMarker.entries()) {
|
|
42
|
-
const [ marker, emphasisTokens ] = entry;
|
|
43
|
-
for (let i = 0; i + 1 < emphasisTokens.length; i += 2) {
|
|
44
|
-
|
|
45
|
-
// Process start token of start/end pair
|
|
46
|
-
const startToken = emphasisTokens[i];
|
|
47
|
-
const startLine = lines[startToken.startLine - 1];
|
|
48
|
-
const startSlice = startLine.slice(startToken.endColumn - 1);
|
|
49
|
-
const startMatch = startSlice.match(/^\s+\S/);
|
|
50
|
-
if (startMatch) {
|
|
51
|
-
const [ startSpaceCharacter ] = startMatch;
|
|
52
|
-
const startContext = `${marker}${startSpaceCharacter}`;
|
|
53
|
-
addError(
|
|
54
|
-
onError,
|
|
55
|
-
startToken.startLine,
|
|
56
|
-
undefined,
|
|
57
|
-
startContext,
|
|
58
|
-
[ startToken.startColumn, startContext.length ],
|
|
59
|
-
{
|
|
60
|
-
"editColumn": startToken.endColumn,
|
|
61
|
-
"deleteCount": startSpaceCharacter.length - 1
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Process end token of start/end pair
|
|
67
|
-
const endToken = emphasisTokens[i + 1];
|
|
68
|
-
const endLine = lines[endToken.startLine - 1];
|
|
69
|
-
const endSlice = endLine.slice(0, endToken.startColumn - 1);
|
|
70
|
-
const endMatch = endSlice.match(/\S\s+$/);
|
|
71
|
-
if (endMatch) {
|
|
72
|
-
const [ endSpaceCharacter ] = endMatch;
|
|
73
|
-
const endContext = `${endSpaceCharacter}${marker}`;
|
|
74
|
-
addError(
|
|
75
|
-
onError,
|
|
76
|
-
endToken.startLine,
|
|
77
|
-
undefined,
|
|
78
|
-
endContext,
|
|
79
|
-
[ endToken.endColumn - endContext.length, endContext.length ],
|
|
80
|
-
{
|
|
81
|
-
"editColumn":
|
|
82
|
-
endToken.startColumn - (endSpaceCharacter.length - 1),
|
|
83
|
-
"deleteCount": endSpaceCharacter.length - 1
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext } = require("../helpers");
|
|
6
|
-
const { filterByTypes, inHtmlFlow, tokenIfType } =
|
|
7
|
-
require("../helpers/micromark.cjs");
|
|
8
|
-
|
|
9
|
-
const leftSpaceRe = /^\s(?:[^`]|$)/;
|
|
10
|
-
const rightSpaceRe = /[^`]\s$/;
|
|
11
|
-
const trimCodeText = (text, start, end) => {
|
|
12
|
-
text = text.replace(/^\s+$/, "");
|
|
13
|
-
if (start) {
|
|
14
|
-
text = text.replace(/^\s+?(\s`|\S)/, "$1");
|
|
15
|
-
}
|
|
16
|
-
if (end) {
|
|
17
|
-
text = text.replace(/(`\s|\S)\s+$/, "$1");
|
|
18
|
-
}
|
|
19
|
-
return text;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
module.exports = {
|
|
23
|
-
"names": [ "MD038", "no-space-in-code" ],
|
|
24
|
-
"description": "Spaces inside code span elements",
|
|
25
|
-
"tags": [ "whitespace", "code" ],
|
|
26
|
-
"function": function MD038(params, onError) {
|
|
27
|
-
const codeTexts =
|
|
28
|
-
filterByTypes(params.parsers.micromark.tokens, [ "codeText" ])
|
|
29
|
-
.filter((codeText) => !inHtmlFlow(codeText));
|
|
30
|
-
for (const codeText of codeTexts) {
|
|
31
|
-
const { children } = codeText;
|
|
32
|
-
const first = 0;
|
|
33
|
-
const last = children.length - 1;
|
|
34
|
-
const startSequence = tokenIfType(children[first], "codeTextSequence");
|
|
35
|
-
const endSequence = tokenIfType(children[last], "codeTextSequence");
|
|
36
|
-
const startData =
|
|
37
|
-
tokenIfType(children[first + 1], "codeTextData") ||
|
|
38
|
-
tokenIfType(children[first + 2], "codeTextData");
|
|
39
|
-
const endData =
|
|
40
|
-
tokenIfType(children[last - 1], "codeTextData") ||
|
|
41
|
-
tokenIfType(children[last - 2], "codeTextData");
|
|
42
|
-
if (startSequence && endSequence && startData && endData) {
|
|
43
|
-
const spaceLeft = leftSpaceRe.test(startData.text);
|
|
44
|
-
const spaceRight = !spaceLeft && rightSpaceRe.test(endData.text);
|
|
45
|
-
if (spaceLeft || spaceRight) {
|
|
46
|
-
let lineNumber = startSequence.startLine;
|
|
47
|
-
let range = null;
|
|
48
|
-
let fixInfo = null;
|
|
49
|
-
if (startSequence.startLine === endSequence.endLine) {
|
|
50
|
-
range = [
|
|
51
|
-
startSequence.startColumn,
|
|
52
|
-
endSequence.endColumn - startSequence.startColumn
|
|
53
|
-
];
|
|
54
|
-
fixInfo = {
|
|
55
|
-
"editColumn": startSequence.endColumn,
|
|
56
|
-
"deleteCount": endSequence.startColumn - startSequence.endColumn,
|
|
57
|
-
"insertText": trimCodeText(startData.text, true, true)
|
|
58
|
-
};
|
|
59
|
-
} else if (spaceLeft) {
|
|
60
|
-
range = [
|
|
61
|
-
startSequence.startColumn,
|
|
62
|
-
startData.endColumn - startSequence.startColumn
|
|
63
|
-
];
|
|
64
|
-
fixInfo = {
|
|
65
|
-
"editColumn": startSequence.endColumn,
|
|
66
|
-
"deleteCount": startData.endColumn - startData.startColumn,
|
|
67
|
-
"insertText": trimCodeText(startData.text, true, false)
|
|
68
|
-
};
|
|
69
|
-
} else {
|
|
70
|
-
lineNumber = endSequence.endLine;
|
|
71
|
-
range = [
|
|
72
|
-
endData.startColumn,
|
|
73
|
-
endSequence.endColumn - endData.startColumn
|
|
74
|
-
];
|
|
75
|
-
fixInfo = {
|
|
76
|
-
"editColumn": endData.startColumn,
|
|
77
|
-
"deleteCount": endData.endColumn - endData.startColumn,
|
|
78
|
-
"insertText": trimCodeText(endData.text, false, true)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const context = params
|
|
82
|
-
.lines[lineNumber - 1]
|
|
83
|
-
.substring(range[0] - 1, range[0] - 1 + range[1]);
|
|
84
|
-
addErrorContext(
|
|
85
|
-
onError,
|
|
86
|
-
lineNumber,
|
|
87
|
-
context,
|
|
88
|
-
spaceLeft,
|
|
89
|
-
spaceRight,
|
|
90
|
-
range,
|
|
91
|
-
fixInfo
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, filterTokens } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
const spaceInLinkRe =
|
|
8
|
-
/\[(?:\s[^\]]*|[^\]]*?\s)\](?=(\([^)]*\)|\[[^\]]*\]))/;
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
"names": [ "MD039", "no-space-in-links" ],
|
|
12
|
-
"description": "Spaces inside link text",
|
|
13
|
-
"tags": [ "whitespace", "links" ],
|
|
14
|
-
"function": function MD039(params, onError) {
|
|
15
|
-
filterTokens(params, "inline", (token) => {
|
|
16
|
-
const { children } = token;
|
|
17
|
-
let { lineNumber } = token;
|
|
18
|
-
let inLink = false;
|
|
19
|
-
let linkText = "";
|
|
20
|
-
let lineIndex = 0;
|
|
21
|
-
for (const child of children) {
|
|
22
|
-
const { content, markup, type } = child;
|
|
23
|
-
if (type === "link_open") {
|
|
24
|
-
inLink = true;
|
|
25
|
-
linkText = "";
|
|
26
|
-
} else if (type === "link_close") {
|
|
27
|
-
inLink = false;
|
|
28
|
-
const left = linkText.trimStart().length !== linkText.length;
|
|
29
|
-
const right = linkText.trimEnd().length !== linkText.length;
|
|
30
|
-
if (left || right) {
|
|
31
|
-
const line = params.lines[lineNumber - 1];
|
|
32
|
-
let range = null;
|
|
33
|
-
let fixInfo = null;
|
|
34
|
-
const match = line.slice(lineIndex).match(spaceInLinkRe);
|
|
35
|
-
if (match) {
|
|
36
|
-
const column = match.index + lineIndex + 1;
|
|
37
|
-
const length = match[0].length;
|
|
38
|
-
range = [ column, length ];
|
|
39
|
-
fixInfo = {
|
|
40
|
-
"editColumn": column + 1,
|
|
41
|
-
"deleteCount": length - 2,
|
|
42
|
-
"insertText": linkText.trim()
|
|
43
|
-
};
|
|
44
|
-
lineIndex = column + length - 1;
|
|
45
|
-
}
|
|
46
|
-
addErrorContext(
|
|
47
|
-
onError,
|
|
48
|
-
lineNumber,
|
|
49
|
-
`[${linkText}]`,
|
|
50
|
-
left,
|
|
51
|
-
right,
|
|
52
|
-
range,
|
|
53
|
-
fixInfo
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
} else if ((type === "softbreak") || (type === "hardbreak")) {
|
|
57
|
-
lineNumber++;
|
|
58
|
-
lineIndex = 0;
|
|
59
|
-
} else if (inLink) {
|
|
60
|
-
linkText += type.endsWith("_inline") ?
|
|
61
|
-
`${markup}${content}${markup}` :
|
|
62
|
-
(content || markup);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, addErrorContext, filterTokens } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD040", "fenced-code-language" ],
|
|
9
|
-
"description": "Fenced code blocks should have a language specified",
|
|
10
|
-
"tags": [ "code", "language" ],
|
|
11
|
-
"function": function MD040(params, onError) {
|
|
12
|
-
let allowed = params.config.allowed_languages;
|
|
13
|
-
allowed = Array.isArray(allowed) ? allowed : [];
|
|
14
|
-
const languageOnly = !!params.config.language_only;
|
|
15
|
-
|
|
16
|
-
filterTokens(params, "fence", function forToken(token) {
|
|
17
|
-
const lang = token.info.trim().split(/\s+/u).shift();
|
|
18
|
-
if (lang === "") {
|
|
19
|
-
addErrorContext(onError, token.lineNumber, token.line);
|
|
20
|
-
} else if ((allowed.length > 0) && !allowed.includes(lang)) {
|
|
21
|
-
addError(
|
|
22
|
-
onError,
|
|
23
|
-
token.lineNumber,
|
|
24
|
-
`"${lang}" is not allowed`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (languageOnly && (token.info !== lang)) {
|
|
29
|
-
addError(
|
|
30
|
-
onError,
|
|
31
|
-
token.lineNumber,
|
|
32
|
-
`Info string contains more than language: "${token.info}"`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, frontMatterHasTitle } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD041", "first-line-heading", "first-line-h1" ],
|
|
9
|
-
"description": "First line in a file should be a top-level heading",
|
|
10
|
-
"tags": [ "headings" ],
|
|
11
|
-
"function": function MD041(params, onError) {
|
|
12
|
-
const level = Number(params.config.level || 1);
|
|
13
|
-
const tag = "h" + level;
|
|
14
|
-
const foundFrontMatterTitle =
|
|
15
|
-
frontMatterHasTitle(
|
|
16
|
-
params.frontMatterLines,
|
|
17
|
-
params.config.front_matter_title
|
|
18
|
-
);
|
|
19
|
-
if (!foundFrontMatterTitle) {
|
|
20
|
-
const htmlHeadingRe = new RegExp(`^<h${level}[ />]`, "i");
|
|
21
|
-
params.parsers.markdownit.tokens.every((token) => {
|
|
22
|
-
let isError = false;
|
|
23
|
-
if (token.type === "html_block") {
|
|
24
|
-
if (token.content.startsWith("<!--")) {
|
|
25
|
-
// Ignore leading HTML comments
|
|
26
|
-
return true;
|
|
27
|
-
} else if (!htmlHeadingRe.test(token.content)) {
|
|
28
|
-
// Something other than an HTML heading
|
|
29
|
-
isError = true;
|
|
30
|
-
}
|
|
31
|
-
} else if ((token.type !== "heading_open") || (token.tag !== tag)) {
|
|
32
|
-
// Something other than a Markdown heading
|
|
33
|
-
isError = true;
|
|
34
|
-
}
|
|
35
|
-
if (isError) {
|
|
36
|
-
addErrorContext(onError, token.lineNumber, token.line);
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|