@alexlit/lint-kit 107.2.2 → 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 +9 -0
- package/.linthtmlrc.cjs +5 -0
- package/{.commitlintrc.js → commitlint.config.js} +1 -1
- package/package.json +11 -10
- 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/dictionaries/index.js +2 -1
- package/packages/config-eslint/index.js +14 -3
- 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 +4 -4
- 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/README.md +5 -5
- package/packages/config-markdownlint/index.json +17 -0
- package/packages/config-markdownlint/package.json +5 -5
- 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/scripts/lint.eslint.sh +1 -1
- package/scripts/lint.markdownlint.sh +1 -1
- package/stylelint.config.js +14 -0
- package/.eslintrc.js +0 -3
- package/.huskyrc.js +0 -3
- package/.linthtmlrc.js +0 -3
- package/.lintstagedrc.js +0 -3
- package/.markdownlintrc.js +0 -3
- package/.prettierrc.js +0 -3
- package/.stylelintrc.js +0 -4
- package/packages/config-hooks/husky.js +0 -6
- package/packages/config-markdownlint/index.js +0 -17
- 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,22 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, filterTokens } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD001", "heading-increment" ],
|
|
9
|
-
"description": "Heading levels should only increment by one level at a time",
|
|
10
|
-
"tags": [ "headings" ],
|
|
11
|
-
"function": function MD001(params, onError) {
|
|
12
|
-
let prevLevel = 0;
|
|
13
|
-
filterTokens(params, "heading_open", function forToken(token) {
|
|
14
|
-
const level = Number.parseInt(token.tag.slice(1), 10);
|
|
15
|
-
if (prevLevel && (level > prevLevel)) {
|
|
16
|
-
addErrorDetailIf(onError, token.lineNumber,
|
|
17
|
-
"h" + (prevLevel + 1), "h" + level);
|
|
18
|
-
}
|
|
19
|
-
prevLevel = level;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, filterTokens, headingStyleFor } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD003", "heading-style" ],
|
|
10
|
-
"description": "Heading style",
|
|
11
|
-
"tags": [ "headings" ],
|
|
12
|
-
"function": function MD003(params, onError) {
|
|
13
|
-
let style = String(params.config.style || "consistent");
|
|
14
|
-
filterTokens(params, "heading_open", function forToken(token) {
|
|
15
|
-
const styleForToken = headingStyleFor(token);
|
|
16
|
-
if (style === "consistent") {
|
|
17
|
-
style = styleForToken;
|
|
18
|
-
}
|
|
19
|
-
if (styleForToken !== style) {
|
|
20
|
-
const h12 = /h[12]/.test(token.tag);
|
|
21
|
-
const setextWithAtx =
|
|
22
|
-
(style === "setext_with_atx") &&
|
|
23
|
-
((h12 && (styleForToken === "setext")) ||
|
|
24
|
-
(!h12 && (styleForToken === "atx")));
|
|
25
|
-
const setextWithAtxClosed =
|
|
26
|
-
(style === "setext_with_atx_closed") &&
|
|
27
|
-
((h12 && (styleForToken === "setext")) ||
|
|
28
|
-
(!h12 && (styleForToken === "atx_closed")));
|
|
29
|
-
if (!setextWithAtx && !setextWithAtxClosed) {
|
|
30
|
-
let expected = style;
|
|
31
|
-
if (style === "setext_with_atx") {
|
|
32
|
-
expected = h12 ? "setext" : "atx";
|
|
33
|
-
} else if (style === "setext_with_atx_closed") {
|
|
34
|
-
expected = h12 ? "setext" : "atx_closed";
|
|
35
|
-
}
|
|
36
|
-
addErrorDetailIf(onError, token.lineNumber,
|
|
37
|
-
expected, styleForToken);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, listItemMarkerRe, unorderedListStyleFor } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
const { flattenedLists } = require("./cache");
|
|
8
|
-
|
|
9
|
-
const expectedStyleToMarker = {
|
|
10
|
-
"dash": "-",
|
|
11
|
-
"plus": "+",
|
|
12
|
-
"asterisk": "*"
|
|
13
|
-
};
|
|
14
|
-
const differentItemStyle = {
|
|
15
|
-
"dash": "plus",
|
|
16
|
-
"plus": "asterisk",
|
|
17
|
-
"asterisk": "dash"
|
|
18
|
-
};
|
|
19
|
-
const validStyles = Object.keys(expectedStyleToMarker);
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
"names": [ "MD004", "ul-style" ],
|
|
23
|
-
"description": "Unordered list style",
|
|
24
|
-
"tags": [ "bullet", "ul" ],
|
|
25
|
-
"function": function MD004(params, onError) {
|
|
26
|
-
const style = String(params.config.style || "consistent");
|
|
27
|
-
let expectedStyle = style;
|
|
28
|
-
const nestingStyles = [];
|
|
29
|
-
for (const list of flattenedLists()) {
|
|
30
|
-
if (list.unordered) {
|
|
31
|
-
if (expectedStyle === "consistent") {
|
|
32
|
-
expectedStyle = unorderedListStyleFor(list.items[0]);
|
|
33
|
-
}
|
|
34
|
-
for (const item of list.items) {
|
|
35
|
-
const itemStyle = unorderedListStyleFor(item);
|
|
36
|
-
if (style === "sublist") {
|
|
37
|
-
const nesting = list.nesting;
|
|
38
|
-
if (!nestingStyles[nesting]) {
|
|
39
|
-
nestingStyles[nesting] =
|
|
40
|
-
(itemStyle === nestingStyles[nesting - 1]) ?
|
|
41
|
-
differentItemStyle[itemStyle] :
|
|
42
|
-
itemStyle;
|
|
43
|
-
}
|
|
44
|
-
expectedStyle = nestingStyles[nesting];
|
|
45
|
-
}
|
|
46
|
-
if (!validStyles.includes(expectedStyle)) {
|
|
47
|
-
expectedStyle = validStyles[0];
|
|
48
|
-
}
|
|
49
|
-
let range = null;
|
|
50
|
-
let fixInfo = null;
|
|
51
|
-
const match = item.line.match(listItemMarkerRe);
|
|
52
|
-
if (match) {
|
|
53
|
-
const column = match.index + 1;
|
|
54
|
-
const length = match[0].length;
|
|
55
|
-
range = [ column, length ];
|
|
56
|
-
fixInfo = {
|
|
57
|
-
"editColumn": match[1].length + 1,
|
|
58
|
-
"deleteCount": 1,
|
|
59
|
-
"insertText": expectedStyleToMarker[expectedStyle]
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
addErrorDetailIf(
|
|
63
|
-
onError,
|
|
64
|
-
item.lineNumber,
|
|
65
|
-
expectedStyle,
|
|
66
|
-
itemStyle,
|
|
67
|
-
null,
|
|
68
|
-
null,
|
|
69
|
-
range,
|
|
70
|
-
fixInfo
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, addErrorDetailIf } = require("../helpers");
|
|
6
|
-
const { filterByTypes, inHtmlFlow } = require("../helpers/micromark.cjs");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD005", "list-indent" ],
|
|
10
|
-
"description": "Inconsistent indentation for list items at the same level",
|
|
11
|
-
"tags": [ "bullet", "ul", "indentation" ],
|
|
12
|
-
"function": function MD005(params, onError) {
|
|
13
|
-
const lists = filterByTypes(
|
|
14
|
-
params.parsers.micromark.tokens,
|
|
15
|
-
[ "listOrdered", "listUnordered" ]
|
|
16
|
-
).filter((list) => !inHtmlFlow(list));
|
|
17
|
-
for (const list of lists) {
|
|
18
|
-
const expectedIndent = list.startColumn - 1;
|
|
19
|
-
let expectedEnd = 0;
|
|
20
|
-
let endMatching = false;
|
|
21
|
-
const listItemPrefixes =
|
|
22
|
-
list.children.filter((token) => (token.type === "listItemPrefix"));
|
|
23
|
-
for (const listItemPrefix of listItemPrefixes) {
|
|
24
|
-
const lineNumber = listItemPrefix.startLine;
|
|
25
|
-
const actualIndent = listItemPrefix.startColumn - 1;
|
|
26
|
-
const markerLength = listItemPrefix.text.trim().length;
|
|
27
|
-
const range = [ 1, listItemPrefix.startColumn + markerLength ];
|
|
28
|
-
if (list.type === "listUnordered") {
|
|
29
|
-
addErrorDetailIf(
|
|
30
|
-
onError,
|
|
31
|
-
lineNumber,
|
|
32
|
-
expectedIndent,
|
|
33
|
-
actualIndent,
|
|
34
|
-
null,
|
|
35
|
-
null,
|
|
36
|
-
range
|
|
37
|
-
// No fixInfo; MD007 handles this scenario better
|
|
38
|
-
);
|
|
39
|
-
} else {
|
|
40
|
-
const actualEnd = range[1] - 1;
|
|
41
|
-
expectedEnd = expectedEnd || actualEnd;
|
|
42
|
-
if ((expectedIndent !== actualIndent) || endMatching) {
|
|
43
|
-
if (expectedEnd === actualEnd) {
|
|
44
|
-
endMatching = true;
|
|
45
|
-
} else {
|
|
46
|
-
const detail = endMatching ?
|
|
47
|
-
`Expected: (${expectedEnd}); Actual: (${actualEnd})` :
|
|
48
|
-
`Expected: ${expectedIndent}; Actual: ${actualIndent}`;
|
|
49
|
-
const expected = endMatching ?
|
|
50
|
-
expectedEnd - markerLength :
|
|
51
|
-
expectedIndent;
|
|
52
|
-
const actual = endMatching ?
|
|
53
|
-
actualEnd - markerLength :
|
|
54
|
-
actualIndent;
|
|
55
|
-
addError(
|
|
56
|
-
onError,
|
|
57
|
-
lineNumber,
|
|
58
|
-
detail,
|
|
59
|
-
undefined,
|
|
60
|
-
range,
|
|
61
|
-
{
|
|
62
|
-
"editColumn": Math.min(actual, expected) + 1,
|
|
63
|
-
"deleteCount": Math.max(actual - expected, 0),
|
|
64
|
-
"insertText": "".padEnd(Math.max(expected - actual, 0))
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
-
const { filterByTypes, getTokenParentOfType, inHtmlFlow } =
|
|
7
|
-
require("../helpers/micromark.cjs");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {import("../helpers/micromark.cjs").Token} Token
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const unorderedListTypes =
|
|
14
|
-
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
|
15
|
-
const unorderedParentTypes =
|
|
16
|
-
[ "blockQuote", "listOrdered", "listUnordered" ];
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
"names": [ "MD007", "ul-indent" ],
|
|
20
|
-
"description": "Unordered list indentation",
|
|
21
|
-
"tags": [ "bullet", "ul", "indentation" ],
|
|
22
|
-
"function": function MD007(params, onError) {
|
|
23
|
-
const indent = Number(params.config.indent || 2);
|
|
24
|
-
const startIndented = !!params.config.start_indented;
|
|
25
|
-
const startIndent = Number(params.config.start_indent || indent);
|
|
26
|
-
const unorderedListNesting = new Map();
|
|
27
|
-
let lastBlockQuotePrefix = null;
|
|
28
|
-
const tokens = filterByTypes(
|
|
29
|
-
params.parsers.micromark.tokens,
|
|
30
|
-
unorderedListTypes
|
|
31
|
-
);
|
|
32
|
-
for (const token of tokens) {
|
|
33
|
-
const { parent, startColumn, startLine, type } = token;
|
|
34
|
-
if (type === "blockQuotePrefix") {
|
|
35
|
-
lastBlockQuotePrefix = token;
|
|
36
|
-
} else if (type === "listUnordered") {
|
|
37
|
-
let nesting = 0;
|
|
38
|
-
/** @type {Token | null} */
|
|
39
|
-
let current = token;
|
|
40
|
-
while (
|
|
41
|
-
(current = getTokenParentOfType(current, unorderedParentTypes))
|
|
42
|
-
) {
|
|
43
|
-
if (current.type === "listUnordered") {
|
|
44
|
-
nesting++;
|
|
45
|
-
continue;
|
|
46
|
-
} else if (current.type === "listOrdered") {
|
|
47
|
-
nesting = -1;
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
if (nesting >= 0) {
|
|
52
|
-
unorderedListNesting.set(token, nesting);
|
|
53
|
-
}
|
|
54
|
-
} else if (!inHtmlFlow(token)) {
|
|
55
|
-
// listItemPrefix
|
|
56
|
-
const nesting = unorderedListNesting.get(parent);
|
|
57
|
-
if (nesting !== undefined) {
|
|
58
|
-
// listItemPrefix for listUnordered
|
|
59
|
-
const expectedIndent =
|
|
60
|
-
(startIndented ? startIndent : 0) + (nesting * indent);
|
|
61
|
-
const blockQuoteAdjustment =
|
|
62
|
-
(lastBlockQuotePrefix?.endLine === startLine) ?
|
|
63
|
-
(lastBlockQuotePrefix.endColumn - 1) :
|
|
64
|
-
0;
|
|
65
|
-
const actualIndent = startColumn - 1 - blockQuoteAdjustment;
|
|
66
|
-
const range = [ 1, startColumn + 1 ];
|
|
67
|
-
const fixInfo = {
|
|
68
|
-
"editColumn": startColumn - actualIndent,
|
|
69
|
-
"deleteCount": Math.max(actualIndent - expectedIndent, 0),
|
|
70
|
-
"insertText": "".padEnd(Math.max(expectedIndent - actualIndent, 0))
|
|
71
|
-
};
|
|
72
|
-
addErrorDetailIf(
|
|
73
|
-
onError,
|
|
74
|
-
startLine,
|
|
75
|
-
expectedIndent,
|
|
76
|
-
actualIndent,
|
|
77
|
-
undefined,
|
|
78
|
-
undefined,
|
|
79
|
-
range,
|
|
80
|
-
fixInfo
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, filterTokens, forEachLine, includesSorted,
|
|
6
|
-
numericSortAscending } = require("../helpers");
|
|
7
|
-
const { lineMetadata } = require("./cache");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD009", "no-trailing-spaces" ],
|
|
11
|
-
"description": "Trailing spaces",
|
|
12
|
-
"tags": [ "whitespace" ],
|
|
13
|
-
"function": function MD009(params, onError) {
|
|
14
|
-
let brSpaces = params.config.br_spaces;
|
|
15
|
-
brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces);
|
|
16
|
-
const listItemEmptyLines = !!params.config.list_item_empty_lines;
|
|
17
|
-
const strict = !!params.config.strict;
|
|
18
|
-
const listItemLineNumbers = [];
|
|
19
|
-
if (listItemEmptyLines) {
|
|
20
|
-
filterTokens(params, "list_item_open", (token) => {
|
|
21
|
-
for (let i = token.map[0]; i < token.map[1]; i++) {
|
|
22
|
-
listItemLineNumbers.push(i + 1);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
listItemLineNumbers.sort(numericSortAscending);
|
|
26
|
-
}
|
|
27
|
-
const paragraphLineNumbers = [];
|
|
28
|
-
const codeInlineLineNumbers = [];
|
|
29
|
-
if (strict) {
|
|
30
|
-
filterTokens(params, "paragraph_open", (token) => {
|
|
31
|
-
for (let i = token.map[0]; i < token.map[1] - 1; i++) {
|
|
32
|
-
paragraphLineNumbers.push(i + 1);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const addLineNumberRange = (start, end) => {
|
|
36
|
-
for (let i = start; i < end; i++) {
|
|
37
|
-
codeInlineLineNumbers.push(i);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
filterTokens(params, "inline", (token) => {
|
|
41
|
-
let start = 0;
|
|
42
|
-
for (const child of token.children) {
|
|
43
|
-
if (start > 0) {
|
|
44
|
-
addLineNumberRange(start, child.lineNumber);
|
|
45
|
-
start = 0;
|
|
46
|
-
}
|
|
47
|
-
if (child.type === "code_inline") {
|
|
48
|
-
start = child.lineNumber;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (start > 0) {
|
|
52
|
-
addLineNumberRange(start, token.map[1]);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
const expected = (brSpaces < 2) ? 0 : brSpaces;
|
|
57
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
58
|
-
const lineNumber = lineIndex + 1;
|
|
59
|
-
const trailingSpaces = line.length - line.trimEnd().length;
|
|
60
|
-
if (
|
|
61
|
-
trailingSpaces &&
|
|
62
|
-
!inCode &&
|
|
63
|
-
!includesSorted(listItemLineNumbers, lineNumber) &&
|
|
64
|
-
(
|
|
65
|
-
(expected !== trailingSpaces) ||
|
|
66
|
-
(strict &&
|
|
67
|
-
(!includesSorted(paragraphLineNumbers, lineNumber) ||
|
|
68
|
-
includesSorted(codeInlineLineNumbers, lineNumber)))
|
|
69
|
-
)
|
|
70
|
-
) {
|
|
71
|
-
const column = line.length - trailingSpaces + 1;
|
|
72
|
-
addError(
|
|
73
|
-
onError,
|
|
74
|
-
lineNumber,
|
|
75
|
-
"Expected: " + (expected === 0 ? "" : "0 or ") +
|
|
76
|
-
expected + "; Actual: " + trailingSpaces,
|
|
77
|
-
undefined,
|
|
78
|
-
[ column, trailingSpaces ],
|
|
79
|
-
{
|
|
80
|
-
"editColumn": column,
|
|
81
|
-
"deleteCount": trailingSpaces
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, filterTokens, forEachLine, withinAnyRange } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
|
8
|
-
|
|
9
|
-
const tabRe = /\t+/g;
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
"names": [ "MD010", "no-hard-tabs" ],
|
|
13
|
-
"description": "Hard tabs",
|
|
14
|
-
"tags": [ "whitespace", "hard_tab" ],
|
|
15
|
-
"function": function MD010(params, onError) {
|
|
16
|
-
const codeBlocks = params.config.code_blocks;
|
|
17
|
-
const includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
18
|
-
const ignoreCodeLanguages = new Set(
|
|
19
|
-
(params.config.ignore_code_languages || [])
|
|
20
|
-
.map((language) => language.toLowerCase())
|
|
21
|
-
);
|
|
22
|
-
const spacesPerTab = params.config.spaces_per_tab;
|
|
23
|
-
const spaceMultiplier = (spacesPerTab === undefined) ?
|
|
24
|
-
1 :
|
|
25
|
-
Math.max(0, Number(spacesPerTab));
|
|
26
|
-
const exclusions = includeCode ? [] : codeBlockAndSpanRanges();
|
|
27
|
-
filterTokens(params, "fence", (token) => {
|
|
28
|
-
const language = token.info.trim().toLowerCase();
|
|
29
|
-
if (ignoreCodeLanguages.has(language)) {
|
|
30
|
-
for (let i = token.map[0] + 1; i < token.map[1] - 1; i++) {
|
|
31
|
-
exclusions.push([ i, 0, params.lines[i].length ]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
36
|
-
if (includeCode || !inCode) {
|
|
37
|
-
let match = null;
|
|
38
|
-
while ((match = tabRe.exec(line)) !== null) {
|
|
39
|
-
const { index } = match;
|
|
40
|
-
const column = index + 1;
|
|
41
|
-
const length = match[0].length;
|
|
42
|
-
if (!withinAnyRange(exclusions, lineIndex, index, length)) {
|
|
43
|
-
addError(
|
|
44
|
-
onError,
|
|
45
|
-
lineIndex + 1,
|
|
46
|
-
"Column: " + column,
|
|
47
|
-
null,
|
|
48
|
-
[ column, length ],
|
|
49
|
-
{
|
|
50
|
-
"editColumn": column,
|
|
51
|
-
"deleteCount": length,
|
|
52
|
-
"insertText": "".padEnd(length * spaceMultiplier)
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, forEachLine, withinAnyRange } = require("../helpers");
|
|
6
|
-
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
|
7
|
-
|
|
8
|
-
const reversedLinkRe =
|
|
9
|
-
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
"names": [ "MD011", "no-reversed-links" ],
|
|
13
|
-
"description": "Reversed link syntax",
|
|
14
|
-
"tags": [ "links" ],
|
|
15
|
-
"function": function MD011(params, onError) {
|
|
16
|
-
const exclusions = codeBlockAndSpanRanges();
|
|
17
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {
|
|
18
|
-
if (!inCode && !onFence) {
|
|
19
|
-
let match = null;
|
|
20
|
-
while ((match = reversedLinkRe.exec(line)) !== null) {
|
|
21
|
-
const [ reversedLink, preChar, linkText, linkDestination ] = match;
|
|
22
|
-
const index = match.index + preChar.length;
|
|
23
|
-
const length = match[0].length - preChar.length;
|
|
24
|
-
if (
|
|
25
|
-
!linkText.endsWith("\\") &&
|
|
26
|
-
!linkDestination.endsWith("\\") &&
|
|
27
|
-
!withinAnyRange(exclusions, lineIndex, index, length)
|
|
28
|
-
) {
|
|
29
|
-
addError(
|
|
30
|
-
onError,
|
|
31
|
-
lineIndex + 1,
|
|
32
|
-
reversedLink.slice(preChar.length),
|
|
33
|
-
undefined,
|
|
34
|
-
[ index + 1, length ],
|
|
35
|
-
{
|
|
36
|
-
"editColumn": index + 1,
|
|
37
|
-
"deleteCount": length,
|
|
38
|
-
"insertText": `[${linkText}](${linkDestination})`
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, forEachLine } = require("../helpers");
|
|
6
|
-
const { lineMetadata } = require("./cache");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD012", "no-multiple-blanks" ],
|
|
10
|
-
"description": "Multiple consecutive blank lines",
|
|
11
|
-
"tags": [ "whitespace", "blank_lines" ],
|
|
12
|
-
"function": function MD012(params, onError) {
|
|
13
|
-
const maximum = Number(params.config.maximum || 1);
|
|
14
|
-
let count = 0;
|
|
15
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
16
|
-
count = (inCode || (line.trim().length > 0)) ? 0 : count + 1;
|
|
17
|
-
if (maximum < count) {
|
|
18
|
-
addErrorDetailIf(
|
|
19
|
-
onError,
|
|
20
|
-
lineIndex + 1,
|
|
21
|
-
maximum,
|
|
22
|
-
count,
|
|
23
|
-
null,
|
|
24
|
-
null,
|
|
25
|
-
null,
|
|
26
|
-
{
|
|
27
|
-
"deleteCount": -1
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, filterTokens, forEachHeading, forEachLine,
|
|
6
|
-
includesSorted } = require("../helpers");
|
|
7
|
-
const { lineMetadata, referenceLinkImageData } = require("./cache");
|
|
8
|
-
|
|
9
|
-
const longLineRePrefix = "^.{";
|
|
10
|
-
const longLineRePostfixRelaxed = "}.*\\s.*$";
|
|
11
|
-
const longLineRePostfixStrict = "}.+$";
|
|
12
|
-
const linkOrImageOnlyLineRe = /^[es]*(?:lT?L|I)[ES]*$/;
|
|
13
|
-
const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
|
|
14
|
-
const tokenTypeMap = {
|
|
15
|
-
"em_open": "e",
|
|
16
|
-
"em_close": "E",
|
|
17
|
-
"image": "I",
|
|
18
|
-
"link_open": "l",
|
|
19
|
-
"link_close": "L",
|
|
20
|
-
"strong_open": "s",
|
|
21
|
-
"strong_close": "S",
|
|
22
|
-
"text": "T"
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
"names": [ "MD013", "line-length" ],
|
|
27
|
-
"description": "Line length",
|
|
28
|
-
"tags": [ "line_length" ],
|
|
29
|
-
"function": function MD013(params, onError) {
|
|
30
|
-
const lineLength = Number(params.config.line_length || 80);
|
|
31
|
-
const headingLineLength =
|
|
32
|
-
Number(params.config.heading_line_length || lineLength);
|
|
33
|
-
const codeLineLength =
|
|
34
|
-
Number(params.config.code_block_line_length || lineLength);
|
|
35
|
-
const strict = !!params.config.strict;
|
|
36
|
-
const stern = !!params.config.stern;
|
|
37
|
-
const longLineRePostfix =
|
|
38
|
-
(strict || stern) ? longLineRePostfixStrict : longLineRePostfixRelaxed;
|
|
39
|
-
const longLineRe =
|
|
40
|
-
new RegExp(longLineRePrefix + lineLength + longLineRePostfix);
|
|
41
|
-
const longHeadingLineRe =
|
|
42
|
-
new RegExp(longLineRePrefix + headingLineLength + longLineRePostfix);
|
|
43
|
-
const longCodeLineRe =
|
|
44
|
-
new RegExp(longLineRePrefix + codeLineLength + longLineRePostfix);
|
|
45
|
-
const codeBlocks = params.config.code_blocks;
|
|
46
|
-
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
47
|
-
const tables = params.config.tables;
|
|
48
|
-
const includeTables = (tables === undefined) ? true : !!tables;
|
|
49
|
-
const headings = params.config.headings;
|
|
50
|
-
const includeHeadings = (headings === undefined) ? true : !!headings;
|
|
51
|
-
const headingLineNumbers = [];
|
|
52
|
-
forEachHeading(params, (heading) => {
|
|
53
|
-
headingLineNumbers.push(heading.lineNumber);
|
|
54
|
-
});
|
|
55
|
-
const linkOnlyLineNumbers = [];
|
|
56
|
-
filterTokens(params, "inline", (token) => {
|
|
57
|
-
let childTokenTypes = "";
|
|
58
|
-
for (const child of token.children) {
|
|
59
|
-
if (child.type !== "text" || child.content !== "") {
|
|
60
|
-
childTokenTypes += tokenTypeMap[child.type] || "x";
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (linkOrImageOnlyLineRe.test(childTokenTypes)) {
|
|
64
|
-
linkOnlyLineNumbers.push(token.lineNumber);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
const { definitionLineIndices } = referenceLinkImageData();
|
|
68
|
-
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence, inTable) => {
|
|
69
|
-
const lineNumber = lineIndex + 1;
|
|
70
|
-
const isHeading = includesSorted(headingLineNumbers, lineNumber);
|
|
71
|
-
const length = inCode ?
|
|
72
|
-
codeLineLength :
|
|
73
|
-
(isHeading ? headingLineLength : lineLength);
|
|
74
|
-
const lengthRe = inCode ?
|
|
75
|
-
longCodeLineRe :
|
|
76
|
-
(isHeading ? longHeadingLineRe : longLineRe);
|
|
77
|
-
if ((includeCodeBlocks || !inCode) &&
|
|
78
|
-
(includeTables || !inTable) &&
|
|
79
|
-
(includeHeadings || !isHeading) &&
|
|
80
|
-
!includesSorted(definitionLineIndices, lineIndex) &&
|
|
81
|
-
(strict ||
|
|
82
|
-
(!(stern && sternModeRe.test(line)) &&
|
|
83
|
-
!includesSorted(linkOnlyLineNumbers, lineNumber))) &&
|
|
84
|
-
lengthRe.test(line)) {
|
|
85
|
-
addErrorDetailIf(
|
|
86
|
-
onError,
|
|
87
|
-
lineNumber,
|
|
88
|
-
length,
|
|
89
|
-
line.length,
|
|
90
|
-
null,
|
|
91
|
-
null,
|
|
92
|
-
[ length + 1, line.length - length ]);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorContext, filterTokens } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD014", "commands-show-output" ],
|
|
11
|
-
"description": "Dollar signs used before commands without showing output",
|
|
12
|
-
"tags": [ "code" ],
|
|
13
|
-
"function": function MD014(params, onError) {
|
|
14
|
-
for (const type of [ "code_block", "fence" ]) {
|
|
15
|
-
filterTokens(params, type, (token) => {
|
|
16
|
-
const margin = (token.type === "fence") ? 1 : 0;
|
|
17
|
-
const dollarInstances = [];
|
|
18
|
-
let allDollars = true;
|
|
19
|
-
for (let i = token.map[0] + margin; i < token.map[1] - margin; i++) {
|
|
20
|
-
const line = params.lines[i];
|
|
21
|
-
const lineTrim = line.trim();
|
|
22
|
-
if (lineTrim) {
|
|
23
|
-
const match = dollarCommandRe.exec(line);
|
|
24
|
-
if (match) {
|
|
25
|
-
const column = match[1].length + 1;
|
|
26
|
-
const length = match[2].length;
|
|
27
|
-
dollarInstances.push([ i, lineTrim, column, length ]);
|
|
28
|
-
} else {
|
|
29
|
-
allDollars = false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (allDollars) {
|
|
34
|
-
for (const instance of dollarInstances) {
|
|
35
|
-
const [ i, lineTrim, column, length ] = instance;
|
|
36
|
-
addErrorContext(
|
|
37
|
-
onError,
|
|
38
|
-
i + 1,
|
|
39
|
-
lineTrim,
|
|
40
|
-
null,
|
|
41
|
-
null,
|
|
42
|
-
[ column, length ],
|
|
43
|
-
{
|
|
44
|
-
"editColumn": column,
|
|
45
|
-
"deleteCount": length
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|