|
1 | 1 | import type { LintIssue, PickierPlugin, RuleContext, RuleModule } from '../types' |
2 | 2 |
|
3 | | -// Helper function to wrap markdown rules so they only run on .md files |
4 | | -function markdownOnly(rule: RuleModule): RuleModule { |
5 | | - return { |
6 | | - meta: rule.meta, |
7 | | - check: (content: string, context: RuleContext): LintIssue[] => { |
8 | | - // Only run on .md files |
9 | | - if (!context.filePath.endsWith('.md')) |
10 | | - return [] |
11 | | - return rule.check(content, context) |
12 | | - }, |
13 | | - fix: rule.fix |
14 | | - ? (content: string, context: RuleContext): string => { |
15 | | - // Only run on .md files |
16 | | - if (!context.filePath.endsWith('.md')) |
17 | | - return content |
18 | | - return rule.fix!(content, context) |
19 | | - } |
20 | | - : undefined, |
21 | | - } |
22 | | -} |
| 3 | +import { blanksAroundFencesRule } from '../rules/markdown/blanks-around-fences' |
| 4 | +import { blanksAroundHeadingsRule } from '../rules/markdown/blanks-around-headings' |
| 5 | +import { blanksAroundListsRule } from '../rules/markdown/blanks-around-lists' |
| 6 | +import { blanksAroundTablesRule } from '../rules/markdown/blanks-around-tables' |
| 7 | +import { codeBlockStyleRule } from '../rules/markdown/code-block-style' |
| 8 | +import { codeFenceStyleRule } from '../rules/markdown/code-fence-style' |
| 9 | +import { commandsShowOutputRule } from '../rules/markdown/commands-show-output' |
| 10 | +import { descriptiveLinkTextRule } from '../rules/markdown/descriptive-link-text' |
| 11 | +import { emphasisStyleRule } from '../rules/markdown/emphasis-style' |
| 12 | +import { fencedCodeLanguageRule } from '../rules/markdown/fenced-code-language' |
| 13 | +import { firstLineHeadingRule } from '../rules/markdown/first-line-heading' |
23 | 14 |
|
24 | 15 | // Heading rules |
25 | 16 | import { headingIncrementRule } from '../rules/markdown/heading-increment' |
26 | | -import { headingStyleRule } from '../rules/markdown/heading-style' |
27 | | -import { noMissingSpaceAtxRule } from '../rules/markdown/no-missing-space-atx' |
28 | | -import { noMultipleSpaceAtxRule } from '../rules/markdown/no-multiple-space-atx' |
29 | | -import { noMissingSpaceClosedAtxRule } from '../rules/markdown/no-missing-space-closed-atx' |
30 | | -import { noMultipleSpaceClosedAtxRule } from '../rules/markdown/no-multiple-space-closed-atx' |
31 | | -import { blanksAroundHeadingsRule } from '../rules/markdown/blanks-around-headings' |
32 | 17 | import { headingStartLeftRule } from '../rules/markdown/heading-start-left' |
33 | | -import { noDuplicateHeadingRule } from '../rules/markdown/no-duplicate-heading' |
34 | | -import { singleTitleRule } from '../rules/markdown/single-title' |
35 | | -import { noTrailingPunctuationRule } from '../rules/markdown/no-trailing-punctuation' |
| 18 | +import { headingStyleRule } from '../rules/markdown/heading-style' |
| 19 | +import { hrStyleRule } from '../rules/markdown/hr-style' |
| 20 | +// Code rules |
| 21 | +import { lineLengthRule } from '../rules/markdown/line-length' |
| 22 | +import { linkFragmentsRule } from '../rules/markdown/link-fragments' |
36 | 23 |
|
37 | | -// List rules |
38 | | -import { ulStyleRule } from '../rules/markdown/ul-style' |
| 24 | +import { linkImageReferenceDefinitionsRule } from '../rules/markdown/link-image-reference-definitions' |
| 25 | +import { linkImageStyleRule } from '../rules/markdown/link-image-style' |
39 | 26 | import { listIndentRule } from '../rules/markdown/list-indent' |
40 | | -import { ulIndentRule } from '../rules/markdown/ul-indent' |
41 | | -import { olPrefixRule } from '../rules/markdown/ol-prefix' |
42 | 27 | import { listMarkerSpaceRule } from '../rules/markdown/list-marker-space' |
43 | | -import { blanksAroundListsRule } from '../rules/markdown/blanks-around-lists' |
| 28 | +import { noAltTextRule } from '../rules/markdown/no-alt-text' |
| 29 | +import { noBareUrlsRule } from '../rules/markdown/no-bare-urls' |
| 30 | +import { noBlanksBlockquoteRule } from '../rules/markdown/no-blanks-blockquote' |
| 31 | +import { noDuplicateHeadingRule } from '../rules/markdown/no-duplicate-heading' |
44 | 32 |
|
45 | | -// Whitespace rules |
46 | | -import { noTrailingSpacesRule } from '../rules/markdown/no-trailing-spaces' |
| 33 | +// Emphasis/Strong rules |
| 34 | +import { noEmphasisAsHeadingRule } from '../rules/markdown/no-emphasis-as-heading' |
| 35 | +import { noEmptyLinksRule } from '../rules/markdown/no-empty-links' |
47 | 36 | import { noHardTabsRule } from '../rules/markdown/no-hard-tabs' |
| 37 | +// HTML and other rules |
| 38 | +import { noInlineHtmlRule } from '../rules/markdown/no-inline-html' |
| 39 | +import { noMissingSpaceAtxRule } from '../rules/markdown/no-missing-space-atx' |
| 40 | +import { noMissingSpaceClosedAtxRule } from '../rules/markdown/no-missing-space-closed-atx' |
48 | 41 | import { noMultipleBlanksRule } from '../rules/markdown/no-multiple-blanks' |
| 42 | +import { noMultipleSpaceAtxRule } from '../rules/markdown/no-multiple-space-atx' |
49 | 43 | import { noMultipleSpaceBlockquoteRule } from '../rules/markdown/no-multiple-space-blockquote' |
50 | | -import { noBlanksBlockquoteRule } from '../rules/markdown/no-blanks-blockquote' |
51 | | -import { blanksAroundFencesRule } from '../rules/markdown/blanks-around-fences' |
52 | | -import { singleTrailingNewlineRule } from '../rules/markdown/single-trailing-newline' |
53 | | -import { blanksAroundTablesRule } from '../rules/markdown/blanks-around-tables' |
54 | 44 |
|
| 45 | +import { noMultipleSpaceClosedAtxRule } from '../rules/markdown/no-multiple-space-closed-atx' |
55 | 46 | // Link rules |
56 | 47 | import { noReversedLinksRule } from '../rules/markdown/no-reversed-links' |
57 | | -import { noBareUrlsRule } from '../rules/markdown/no-bare-urls' |
| 48 | +import { noSpaceInCodeRule } from '../rules/markdown/no-space-in-code' |
| 49 | +import { noSpaceInEmphasisRule } from '../rules/markdown/no-space-in-emphasis' |
58 | 50 | import { noSpaceInLinksRule } from '../rules/markdown/no-space-in-links' |
59 | | -import { noEmptyLinksRule } from '../rules/markdown/no-empty-links' |
60 | | -import { linkFragmentsRule } from '../rules/markdown/link-fragments' |
61 | | -import { referenceLinksImagesRule } from '../rules/markdown/reference-links-images' |
62 | | -import { linkImageReferenceDefinitionsRule } from '../rules/markdown/link-image-reference-definitions' |
63 | | -import { linkImageStyleRule } from '../rules/markdown/link-image-style' |
64 | | -import { descriptiveLinkTextRule } from '../rules/markdown/descriptive-link-text' |
65 | | - |
66 | | -// Code rules |
67 | | -import { lineLengthRule } from '../rules/markdown/line-length' |
68 | | -import { commandsShowOutputRule } from '../rules/markdown/commands-show-output' |
69 | | -import { fencedCodeLanguageRule } from '../rules/markdown/fenced-code-language' |
70 | | -import { codeBlockStyleRule } from '../rules/markdown/code-block-style' |
71 | | -import { codeFenceStyleRule } from '../rules/markdown/code-fence-style' |
72 | 51 |
|
73 | | -// Emphasis/Strong rules |
74 | | -import { noEmphasisAsHeadingRule } from '../rules/markdown/no-emphasis-as-heading' |
75 | | -import { noSpaceInEmphasisRule } from '../rules/markdown/no-space-in-emphasis' |
76 | | -import { noSpaceInCodeRule } from '../rules/markdown/no-space-in-code' |
77 | | -import { emphasisStyleRule } from '../rules/markdown/emphasis-style' |
78 | | -import { strongStyleRule } from '../rules/markdown/strong-style' |
| 52 | +import { noTrailingPunctuationRule } from '../rules/markdown/no-trailing-punctuation' |
| 53 | +// Whitespace rules |
| 54 | +import { noTrailingSpacesRule } from '../rules/markdown/no-trailing-spaces' |
| 55 | +import { olPrefixRule } from '../rules/markdown/ol-prefix' |
| 56 | +import { properNamesRule } from '../rules/markdown/proper-names' |
| 57 | +import { referenceLinksImagesRule } from '../rules/markdown/reference-links-images' |
79 | 58 |
|
80 | | -// HTML and other rules |
81 | | -import { noInlineHtmlRule } from '../rules/markdown/no-inline-html' |
82 | | -import { hrStyleRule } from '../rules/markdown/hr-style' |
83 | | -import { firstLineHeadingRule } from '../rules/markdown/first-line-heading' |
84 | 59 | import { requiredHeadingsRule } from '../rules/markdown/required-headings' |
85 | | -import { properNamesRule } from '../rules/markdown/proper-names' |
86 | | -import { noAltTextRule } from '../rules/markdown/no-alt-text' |
| 60 | +import { singleTitleRule } from '../rules/markdown/single-title' |
| 61 | +import { singleTrailingNewlineRule } from '../rules/markdown/single-trailing-newline' |
| 62 | +import { strongStyleRule } from '../rules/markdown/strong-style' |
| 63 | +import { tableColumnCountRule } from '../rules/markdown/table-column-count' |
| 64 | +import { tableColumnStyleRule } from '../rules/markdown/table-column-style' |
87 | 65 |
|
88 | 66 | // Table rules |
89 | 67 | import { tablePipeStyleRule } from '../rules/markdown/table-pipe-style' |
90 | | -import { tableColumnCountRule } from '../rules/markdown/table-column-count' |
91 | | -import { tableColumnStyleRule } from '../rules/markdown/table-column-style' |
| 68 | +import { ulIndentRule } from '../rules/markdown/ul-indent' |
| 69 | +// List rules |
| 70 | +import { ulStyleRule } from '../rules/markdown/ul-style' |
| 71 | + |
| 72 | +// Helper function to wrap markdown rules so they only run on .md files |
| 73 | +function markdownOnly(rule: RuleModule): RuleModule { |
| 74 | + return { |
| 75 | + meta: rule.meta, |
| 76 | + check: (content: string, context: RuleContext): LintIssue[] => { |
| 77 | + // Only run on .md files |
| 78 | + if (!context.filePath.endsWith('.md')) |
| 79 | + return [] |
| 80 | + return rule.check(content, context) |
| 81 | + }, |
| 82 | + fix: rule.fix |
| 83 | + ? (content: string, context: RuleContext): string => { |
| 84 | + // Only run on .md files |
| 85 | + if (!context.filePath.endsWith('.md')) |
| 86 | + return content |
| 87 | + return rule.fix!(content, context) |
| 88 | + } |
| 89 | + : undefined, |
| 90 | + } |
| 91 | +} |
92 | 92 |
|
93 | 93 | export const markdownPlugin: PickierPlugin = { |
94 | 94 | name: 'markdown', |
|
0 commit comments