@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,34 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, forEachLine } = require("../helpers");
|
|
6
|
-
const { lineMetadata } = require("./cache");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD018", "no-missing-space-atx" ],
|
|
10
|
-
"description": "No space after hash on atx style heading",
|
|
11
|
-
"tags": [ "headings", "atx", "spaces" ],
|
|
12
|
-
"function": function MD018(params, onError) {
|
|
13
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
14
|
-
if (!inCode &&
|
|
15
|
-
/^#+[^# \t]/.test(line) &&
|
|
16
|
-
!/#\s*$/.test(line) &&
|
|
17
|
-
!line.startsWith("#️⃣")) {
|
|
18
|
-
const hashCount = /^#+/.exec(line)[0].length;
|
|
19
|
-
addErrorContext(
|
|
20
|
-
onError,
|
|
21
|
-
lineIndex + 1,
|
|
22
|
-
line.trim(),
|
|
23
|
-
null,
|
|
24
|
-
null,
|
|
25
|
-
[ 1, hashCount + 1 ],
|
|
26
|
-
{
|
|
27
|
-
"editColumn": hashCount + 1,
|
|
28
|
-
"insertText": " "
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, filterTokens, headingStyleFor } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD019", "no-multiple-space-atx" ],
|
|
10
|
-
"description": "Multiple spaces after hash on atx style heading",
|
|
11
|
-
"tags": [ "headings", "atx", "spaces" ],
|
|
12
|
-
"function": function MD019(params, onError) {
|
|
13
|
-
filterTokens(params, "heading_open", (token) => {
|
|
14
|
-
if (headingStyleFor(token) === "atx") {
|
|
15
|
-
const { line, lineNumber } = token;
|
|
16
|
-
const match = /^(#+)([ \t]{2,})\S/.exec(line);
|
|
17
|
-
if (match) {
|
|
18
|
-
const [
|
|
19
|
-
,
|
|
20
|
-
{ "length": hashLength },
|
|
21
|
-
{ "length": spacesLength }
|
|
22
|
-
] = match;
|
|
23
|
-
addErrorContext(
|
|
24
|
-
onError,
|
|
25
|
-
lineNumber,
|
|
26
|
-
line.trim(),
|
|
27
|
-
null,
|
|
28
|
-
null,
|
|
29
|
-
[ 1, hashLength + spacesLength + 1 ],
|
|
30
|
-
{
|
|
31
|
-
"editColumn": hashLength + 1,
|
|
32
|
-
"deleteCount": spacesLength - 1
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, forEachLine } = require("../helpers");
|
|
6
|
-
const { lineMetadata } = require("./cache");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
|
10
|
-
"description": "No space inside hashes on closed atx style heading",
|
|
11
|
-
"tags": [ "headings", "atx_closed", "spaces" ],
|
|
12
|
-
"function": function MD020(params, onError) {
|
|
13
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
14
|
-
if (!inCode) {
|
|
15
|
-
const match =
|
|
16
|
-
/^(#+)([ \t]*)([^#]*?[^#\\])([ \t]*)((?:\\#)?)(#+)(\s*)$/.exec(line);
|
|
17
|
-
if (match) {
|
|
18
|
-
const [
|
|
19
|
-
,
|
|
20
|
-
leftHash,
|
|
21
|
-
{ "length": leftSpaceLength },
|
|
22
|
-
content,
|
|
23
|
-
{ "length": rightSpaceLength },
|
|
24
|
-
rightEscape,
|
|
25
|
-
rightHash,
|
|
26
|
-
{ "length": trailSpaceLength }
|
|
27
|
-
] = match;
|
|
28
|
-
const leftHashLength = leftHash.length;
|
|
29
|
-
const rightHashLength = rightHash.length;
|
|
30
|
-
const left = !leftSpaceLength;
|
|
31
|
-
const right = !rightSpaceLength || rightEscape;
|
|
32
|
-
const rightEscapeReplacement = rightEscape ? `${rightEscape} ` : "";
|
|
33
|
-
if (left || right) {
|
|
34
|
-
const range = left ?
|
|
35
|
-
[
|
|
36
|
-
1,
|
|
37
|
-
leftHashLength + 1
|
|
38
|
-
] :
|
|
39
|
-
[
|
|
40
|
-
line.length - trailSpaceLength - rightHashLength,
|
|
41
|
-
rightHashLength + 1
|
|
42
|
-
];
|
|
43
|
-
addErrorContext(
|
|
44
|
-
onError,
|
|
45
|
-
lineIndex + 1,
|
|
46
|
-
line.trim(),
|
|
47
|
-
left,
|
|
48
|
-
right,
|
|
49
|
-
range,
|
|
50
|
-
{
|
|
51
|
-
"editColumn": 1,
|
|
52
|
-
"deleteCount": line.length,
|
|
53
|
-
"insertText":
|
|
54
|
-
`${leftHash} ${content} ${rightEscapeReplacement}${rightHash}`
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, filterTokens, headingStyleFor } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
|
|
8
|
-
const closedAtxRe = /^(#+)([ \t]+)([^ \t]|[^ \t].*[^ \t])([ \t]+)(#+)(\s*)$/;
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
"names": [ "MD021", "no-multiple-space-closed-atx" ],
|
|
12
|
-
"description": "Multiple spaces inside hashes on closed atx style heading",
|
|
13
|
-
"tags": [ "headings", "atx_closed", "spaces" ],
|
|
14
|
-
"function": function MD021(params, onError) {
|
|
15
|
-
filterTokens(params, "heading_open", (token) => {
|
|
16
|
-
if (headingStyleFor(token) === "atx_closed") {
|
|
17
|
-
const { line, lineNumber } = token;
|
|
18
|
-
const match = closedAtxRe.exec(line);
|
|
19
|
-
if (match) {
|
|
20
|
-
const [
|
|
21
|
-
,
|
|
22
|
-
leftHash,
|
|
23
|
-
{ "length": leftSpaceLength },
|
|
24
|
-
content,
|
|
25
|
-
{ "length": rightSpaceLength },
|
|
26
|
-
rightHash,
|
|
27
|
-
{ "length": trailSpaceLength }
|
|
28
|
-
] = match;
|
|
29
|
-
const left = leftSpaceLength > 1;
|
|
30
|
-
const right = rightSpaceLength > 1;
|
|
31
|
-
if (left || right) {
|
|
32
|
-
const length = line.length;
|
|
33
|
-
const leftHashLength = leftHash.length;
|
|
34
|
-
const rightHashLength = rightHash.length;
|
|
35
|
-
const range = left ?
|
|
36
|
-
[
|
|
37
|
-
1,
|
|
38
|
-
leftHashLength + leftSpaceLength + 1
|
|
39
|
-
] :
|
|
40
|
-
[
|
|
41
|
-
length - trailSpaceLength - rightHashLength - rightSpaceLength,
|
|
42
|
-
rightSpaceLength + rightHashLength + 1
|
|
43
|
-
];
|
|
44
|
-
addErrorContext(
|
|
45
|
-
onError,
|
|
46
|
-
lineNumber,
|
|
47
|
-
line.trim(),
|
|
48
|
-
left,
|
|
49
|
-
right,
|
|
50
|
-
range,
|
|
51
|
-
{
|
|
52
|
-
"editColumn": 1,
|
|
53
|
-
"deleteCount": length,
|
|
54
|
-
"insertText": `${leftHash} ${content} ${rightHash}`
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, blockquotePrefixRe, isBlankLine } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
const { filterByTypes, getHeadingLevel, inHtmlFlow } =
|
|
8
|
-
require("../helpers/micromark.cjs");
|
|
9
|
-
|
|
10
|
-
const defaultLines = 1;
|
|
11
|
-
|
|
12
|
-
const getLinesFunction = (linesParam) => {
|
|
13
|
-
if (Array.isArray(linesParam)) {
|
|
14
|
-
const linesArray = new Array(6).fill(defaultLines);
|
|
15
|
-
for (const [ index, value ] of [ ...linesParam.entries() ].slice(0, 6)) {
|
|
16
|
-
linesArray[index] = value;
|
|
17
|
-
}
|
|
18
|
-
return (heading) => linesArray[getHeadingLevel(heading) - 1];
|
|
19
|
-
}
|
|
20
|
-
// Coerce linesParam to a number
|
|
21
|
-
const lines = (linesParam === undefined) ? defaultLines : Number(linesParam);
|
|
22
|
-
return () => lines;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getBlockQuote = (str, count) => (
|
|
26
|
-
(str || "")
|
|
27
|
-
.match(blockquotePrefixRe)[0]
|
|
28
|
-
.trimEnd()
|
|
29
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
30
|
-
.concat("\n")
|
|
31
|
-
.repeat(count)
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
"names": [ "MD022", "blanks-around-headings" ],
|
|
36
|
-
"description": "Headings should be surrounded by blank lines",
|
|
37
|
-
"tags": [ "headings", "blank_lines" ],
|
|
38
|
-
"function": function MD022(params, onError) {
|
|
39
|
-
const getLinesAbove = getLinesFunction(params.config.lines_above);
|
|
40
|
-
const getLinesBelow = getLinesFunction(params.config.lines_below);
|
|
41
|
-
const { lines, parsers } = params;
|
|
42
|
-
const headings = filterByTypes(
|
|
43
|
-
parsers.micromark.tokens,
|
|
44
|
-
[ "atxHeading", "setextHeading" ]
|
|
45
|
-
).filter((heading) => !inHtmlFlow(heading));
|
|
46
|
-
for (const heading of headings) {
|
|
47
|
-
const { startLine, endLine } = heading;
|
|
48
|
-
const line = lines[startLine - 1].trim();
|
|
49
|
-
|
|
50
|
-
// Check lines above
|
|
51
|
-
const linesAbove = getLinesAbove(heading);
|
|
52
|
-
if (linesAbove >= 0) {
|
|
53
|
-
let actualAbove = 0;
|
|
54
|
-
for (
|
|
55
|
-
let i = 0;
|
|
56
|
-
(i < linesAbove) && isBlankLine(lines[startLine - 2 - i]);
|
|
57
|
-
i++
|
|
58
|
-
) {
|
|
59
|
-
actualAbove++;
|
|
60
|
-
}
|
|
61
|
-
addErrorDetailIf(
|
|
62
|
-
onError,
|
|
63
|
-
startLine,
|
|
64
|
-
linesAbove,
|
|
65
|
-
actualAbove,
|
|
66
|
-
"Above",
|
|
67
|
-
line,
|
|
68
|
-
null,
|
|
69
|
-
{
|
|
70
|
-
"insertText": getBlockQuote(
|
|
71
|
-
lines[startLine - 2],
|
|
72
|
-
linesAbove - actualAbove
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Check lines below
|
|
79
|
-
const linesBelow = getLinesBelow(heading);
|
|
80
|
-
if (linesBelow >= 0) {
|
|
81
|
-
let actualBelow = 0;
|
|
82
|
-
for (
|
|
83
|
-
let i = 0;
|
|
84
|
-
(i < linesBelow) && isBlankLine(lines[endLine + i]);
|
|
85
|
-
i++
|
|
86
|
-
) {
|
|
87
|
-
actualBelow++;
|
|
88
|
-
}
|
|
89
|
-
addErrorDetailIf(
|
|
90
|
-
onError,
|
|
91
|
-
startLine,
|
|
92
|
-
linesBelow,
|
|
93
|
-
actualBelow,
|
|
94
|
-
"Below",
|
|
95
|
-
line,
|
|
96
|
-
null,
|
|
97
|
-
{
|
|
98
|
-
"lineNumber": endLine + 1,
|
|
99
|
-
"insertText": getBlockQuote(
|
|
100
|
-
lines[endLine],
|
|
101
|
-
linesBelow - actualBelow
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, filterTokens } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
const spaceBeforeHeadingRe = /^(\s+|[>\s]+\s\s)[^>\s]/;
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD023", "heading-start-left" ],
|
|
11
|
-
"description": "Headings must start at the beginning of the line",
|
|
12
|
-
"tags": [ "headings", "spaces" ],
|
|
13
|
-
"function": function MD023(params, onError) {
|
|
14
|
-
filterTokens(params, "heading_open", function forToken(token) {
|
|
15
|
-
const { lineNumber, line } = token;
|
|
16
|
-
const match = line.match(spaceBeforeHeadingRe);
|
|
17
|
-
if (match) {
|
|
18
|
-
const [ prefixAndFirstChar, prefix ] = match;
|
|
19
|
-
let deleteCount = prefix.length;
|
|
20
|
-
const prefixLengthNoSpace = prefix.trimEnd().length;
|
|
21
|
-
if (prefixLengthNoSpace) {
|
|
22
|
-
deleteCount -= prefixLengthNoSpace - 1;
|
|
23
|
-
}
|
|
24
|
-
addErrorContext(
|
|
25
|
-
onError,
|
|
26
|
-
lineNumber,
|
|
27
|
-
line,
|
|
28
|
-
null,
|
|
29
|
-
null,
|
|
30
|
-
[ 1, prefixAndFirstChar.length ],
|
|
31
|
-
{
|
|
32
|
-
"editColumn": prefixLengthNoSpace + 1,
|
|
33
|
-
"deleteCount": deleteCount
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, forEachHeading } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD024", "no-duplicate-heading" ],
|
|
9
|
-
"description": "Multiple headings with the same content",
|
|
10
|
-
"tags": [ "headings" ],
|
|
11
|
-
"function": function MD024(params, onError) {
|
|
12
|
-
const siblingsOnly = !!params.config.siblings_only ||
|
|
13
|
-
!!params.config.allow_different_nesting || false;
|
|
14
|
-
const knownContents = [ null, [] ];
|
|
15
|
-
let lastLevel = 1;
|
|
16
|
-
let knownContent = knownContents[lastLevel];
|
|
17
|
-
forEachHeading(params, (heading, content) => {
|
|
18
|
-
if (siblingsOnly) {
|
|
19
|
-
const newLevel = heading.tag.slice(1);
|
|
20
|
-
while (lastLevel < newLevel) {
|
|
21
|
-
lastLevel++;
|
|
22
|
-
knownContents[lastLevel] = [];
|
|
23
|
-
}
|
|
24
|
-
while (lastLevel > newLevel) {
|
|
25
|
-
knownContents[lastLevel] = [];
|
|
26
|
-
lastLevel--;
|
|
27
|
-
}
|
|
28
|
-
knownContent = knownContents[newLevel];
|
|
29
|
-
}
|
|
30
|
-
if (knownContent.includes(content)) {
|
|
31
|
-
addErrorContext(onError, heading.lineNumber,
|
|
32
|
-
heading.line.trim());
|
|
33
|
-
} else {
|
|
34
|
-
knownContent.push(content);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, filterTokens, frontMatterHasTitle } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD025", "single-title", "single-h1" ],
|
|
10
|
-
"description": "Multiple top-level headings in the same document",
|
|
11
|
-
"tags": [ "headings" ],
|
|
12
|
-
"function": function MD025(params, onError) {
|
|
13
|
-
const level = Number(params.config.level || 1);
|
|
14
|
-
const tag = "h" + level;
|
|
15
|
-
const foundFrontMatterTitle =
|
|
16
|
-
frontMatterHasTitle(
|
|
17
|
-
params.frontMatterLines,
|
|
18
|
-
params.config.front_matter_title
|
|
19
|
-
);
|
|
20
|
-
let hasTopLevelHeading = false;
|
|
21
|
-
filterTokens(params, "heading_open", function forToken(token) {
|
|
22
|
-
if (token.tag === tag) {
|
|
23
|
-
if (hasTopLevelHeading || foundFrontMatterTitle) {
|
|
24
|
-
addErrorContext(onError, token.lineNumber,
|
|
25
|
-
token.line.trim());
|
|
26
|
-
} else if (token.lineNumber === 1) {
|
|
27
|
-
hasTopLevelHeading = true;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
|
6
|
-
endOfLineHtmlEntityRe, escapeForRegExp } = require("../helpers");
|
|
7
|
-
const { filterByTypes } = require("../helpers/micromark.cjs");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
"names": [ "MD026", "no-trailing-punctuation" ],
|
|
12
|
-
"description": "Trailing punctuation in heading",
|
|
13
|
-
"tags": [ "headings" ],
|
|
14
|
-
"function": function MD026(params, onError) {
|
|
15
|
-
let punctuation = params.config.punctuation;
|
|
16
|
-
punctuation = String(
|
|
17
|
-
(punctuation === undefined) ? allPunctuationNoQuestion : punctuation
|
|
18
|
-
);
|
|
19
|
-
const trailingPunctuationRe =
|
|
20
|
-
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
|
|
21
|
-
const headings = filterByTypes(
|
|
22
|
-
params.parsers.micromark.tokens,
|
|
23
|
-
[ "atxHeadingText", "setextHeadingText" ]
|
|
24
|
-
);
|
|
25
|
-
for (const heading of headings) {
|
|
26
|
-
const { endLine, startColumn, text } = heading;
|
|
27
|
-
const match = trailingPunctuationRe.exec(text);
|
|
28
|
-
if (
|
|
29
|
-
match &&
|
|
30
|
-
!endOfLineHtmlEntityRe.test(text) &&
|
|
31
|
-
!endOfLineGemojiCodeRe.test(text)
|
|
32
|
-
) {
|
|
33
|
-
const fullMatch = match[0];
|
|
34
|
-
const column = startColumn + match.index;
|
|
35
|
-
const length = fullMatch.length;
|
|
36
|
-
addError(
|
|
37
|
-
onError,
|
|
38
|
-
endLine,
|
|
39
|
-
`Punctuation: '${fullMatch}'`,
|
|
40
|
-
undefined,
|
|
41
|
-
[ column, length ],
|
|
42
|
-
{
|
|
43
|
-
"editColumn": column,
|
|
44
|
-
"deleteCount": length
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, newLineRe } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
const spaceAfterBlockQuoteRe = /^((?:\s*>)+)(\s{2,})\S/;
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
|
11
|
-
"description": "Multiple spaces after blockquote symbol",
|
|
12
|
-
"tags": [ "blockquote", "whitespace", "indentation" ],
|
|
13
|
-
"function": function MD027(params, onError) {
|
|
14
|
-
let blockquoteNesting = 0;
|
|
15
|
-
let listItemNesting = 0;
|
|
16
|
-
for (const token of params.parsers.markdownit.tokens) {
|
|
17
|
-
const { content, lineNumber, type } = token;
|
|
18
|
-
if (type === "blockquote_open") {
|
|
19
|
-
blockquoteNesting++;
|
|
20
|
-
} else if (type === "blockquote_close") {
|
|
21
|
-
blockquoteNesting--;
|
|
22
|
-
} else if (type === "list_item_open") {
|
|
23
|
-
listItemNesting++;
|
|
24
|
-
} else if (type === "list_item_close") {
|
|
25
|
-
listItemNesting--;
|
|
26
|
-
} else if ((type === "inline") && blockquoteNesting) {
|
|
27
|
-
const lineCount = content.split(newLineRe).length;
|
|
28
|
-
for (let i = 0; i < lineCount; i++) {
|
|
29
|
-
const line = params.lines[lineNumber + i - 1];
|
|
30
|
-
const match = line.match(spaceAfterBlockQuoteRe);
|
|
31
|
-
if (match) {
|
|
32
|
-
const [
|
|
33
|
-
fullMatch,
|
|
34
|
-
{ "length": blockquoteLength },
|
|
35
|
-
{ "length": spaceLength }
|
|
36
|
-
] = match;
|
|
37
|
-
if (!listItemNesting || (fullMatch[fullMatch.length - 1] === ">")) {
|
|
38
|
-
addErrorContext(
|
|
39
|
-
onError,
|
|
40
|
-
lineNumber + i,
|
|
41
|
-
line,
|
|
42
|
-
null,
|
|
43
|
-
null,
|
|
44
|
-
[ 1, fullMatch.length ],
|
|
45
|
-
{
|
|
46
|
-
"editColumn": blockquoteLength + 1,
|
|
47
|
-
"deleteCount": spaceLength - 1
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD028", "no-blanks-blockquote" ],
|
|
9
|
-
"description": "Blank line inside blockquote",
|
|
10
|
-
"tags": [ "blockquote", "whitespace" ],
|
|
11
|
-
"function": function MD028(params, onError) {
|
|
12
|
-
let prevToken = {};
|
|
13
|
-
let prevLineNumber = null;
|
|
14
|
-
for (const token of params.parsers.markdownit.tokens) {
|
|
15
|
-
if ((token.type === "blockquote_open") &&
|
|
16
|
-
(prevToken.type === "blockquote_close")) {
|
|
17
|
-
for (
|
|
18
|
-
let lineNumber = prevLineNumber;
|
|
19
|
-
lineNumber < token.lineNumber;
|
|
20
|
-
lineNumber++) {
|
|
21
|
-
addError(onError, lineNumber);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
prevToken = token;
|
|
25
|
-
if (token.type === "blockquote_open") {
|
|
26
|
-
prevLineNumber = token.map[1] + 1;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, listItemMarkerRe, orderedListItemMarkerRe,
|
|
6
|
-
rangeFromRegExp } = require("../helpers");
|
|
7
|
-
const { flattenedLists } = require("./cache");
|
|
8
|
-
|
|
9
|
-
const listStyleExamples = {
|
|
10
|
-
"one": "1/1/1",
|
|
11
|
-
"ordered": "1/2/3",
|
|
12
|
-
"zero": "0/0/0"
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = {
|
|
16
|
-
"names": [ "MD029", "ol-prefix" ],
|
|
17
|
-
"description": "Ordered list item prefix",
|
|
18
|
-
"tags": [ "ol" ],
|
|
19
|
-
"function": function MD029(params, onError) {
|
|
20
|
-
const style = String(params.config.style || "one_or_ordered");
|
|
21
|
-
const filteredLists = flattenedLists().filter((list) => !list.unordered);
|
|
22
|
-
for (const list of filteredLists) {
|
|
23
|
-
const { items } = list;
|
|
24
|
-
let current = 1;
|
|
25
|
-
let incrementing = false;
|
|
26
|
-
// Check for incrementing number pattern 1/2/3 or 0/1/2
|
|
27
|
-
if (items.length >= 2) {
|
|
28
|
-
const first = orderedListItemMarkerRe.exec(items[0].line);
|
|
29
|
-
const second = orderedListItemMarkerRe.exec(items[1].line);
|
|
30
|
-
if (first && second) {
|
|
31
|
-
const [ , firstNumber ] = first;
|
|
32
|
-
const [ , secondNumber ] = second;
|
|
33
|
-
if ((secondNumber !== "1") || (firstNumber === "0")) {
|
|
34
|
-
incrementing = true;
|
|
35
|
-
if (firstNumber === "0") {
|
|
36
|
-
current = 0;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Determine effective style
|
|
42
|
-
let listStyle = style;
|
|
43
|
-
if (listStyle === "one_or_ordered") {
|
|
44
|
-
listStyle = incrementing ? "ordered" : "one";
|
|
45
|
-
}
|
|
46
|
-
// Force expected value for 0/0/0 and 1/1/1 patterns
|
|
47
|
-
if (listStyle === "zero") {
|
|
48
|
-
current = 0;
|
|
49
|
-
} else if (listStyle === "one") {
|
|
50
|
-
current = 1;
|
|
51
|
-
}
|
|
52
|
-
// Validate each list item marker
|
|
53
|
-
for (const item of items) {
|
|
54
|
-
const match = orderedListItemMarkerRe.exec(item.line);
|
|
55
|
-
if (match) {
|
|
56
|
-
addErrorDetailIf(onError, item.lineNumber,
|
|
57
|
-
String(current), match[1],
|
|
58
|
-
"Style: " + listStyleExamples[listStyle], null,
|
|
59
|
-
rangeFromRegExp(item.line, listItemMarkerRe));
|
|
60
|
-
if (listStyle === "ordered") {
|
|
61
|
-
current++;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
@@ -1,61 +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": [ "MD030", "list-marker-space" ],
|
|
10
|
-
"description": "Spaces after list markers",
|
|
11
|
-
"tags": [ "ol", "ul", "whitespace" ],
|
|
12
|
-
"function": function MD030(params, onError) {
|
|
13
|
-
const ulSingle = Number(params.config.ul_single || 1);
|
|
14
|
-
const olSingle = Number(params.config.ol_single || 1);
|
|
15
|
-
const ulMulti = Number(params.config.ul_multi || 1);
|
|
16
|
-
const olMulti = Number(params.config.ol_multi || 1);
|
|
17
|
-
const lists = filterByTypes(
|
|
18
|
-
params.parsers.micromark.tokens,
|
|
19
|
-
[ "listOrdered", "listUnordered" ]
|
|
20
|
-
);
|
|
21
|
-
for (const list of lists) {
|
|
22
|
-
const ordered = (list.type === "listOrdered");
|
|
23
|
-
const listItemPrefixes =
|
|
24
|
-
list.children.filter((token) => (token.type === "listItemPrefix"));
|
|
25
|
-
const allSingleLine =
|
|
26
|
-
(list.endLine - list.startLine + 1) === listItemPrefixes.length;
|
|
27
|
-
const expectedSpaces = ordered ?
|
|
28
|
-
(allSingleLine ? olSingle : olMulti) :
|
|
29
|
-
(allSingleLine ? ulSingle : ulMulti);
|
|
30
|
-
for (const listItemPrefix of listItemPrefixes) {
|
|
31
|
-
const range = [
|
|
32
|
-
listItemPrefix.startColumn,
|
|
33
|
-
listItemPrefix.endColumn - listItemPrefix.startColumn
|
|
34
|
-
];
|
|
35
|
-
const listItemPrefixWhitespaces = listItemPrefix.children.filter(
|
|
36
|
-
(token) => (token.type === "listItemPrefixWhitespace")
|
|
37
|
-
);
|
|
38
|
-
for (const listItemPrefixWhitespace of listItemPrefixWhitespaces) {
|
|
39
|
-
const { endColumn, startColumn, startLine } =
|
|
40
|
-
listItemPrefixWhitespace;
|
|
41
|
-
const actualSpaces = endColumn - startColumn;
|
|
42
|
-
const fixInfo = {
|
|
43
|
-
"editColumn": startColumn,
|
|
44
|
-
"deleteCount": actualSpaces,
|
|
45
|
-
"insertText": "".padEnd(expectedSpaces)
|
|
46
|
-
};
|
|
47
|
-
addErrorDetailIf(
|
|
48
|
-
onError,
|
|
49
|
-
startLine,
|
|
50
|
-
expectedSpaces,
|
|
51
|
-
actualSpaces,
|
|
52
|
-
null,
|
|
53
|
-
null,
|
|
54
|
-
range,
|
|
55
|
-
fixInfo
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|