-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlint.js
88 lines (80 loc) · 3.82 KB
/
lint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import remarkLint from 'remark-lint'
import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references'
import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'
import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'
import remarkLintNoInlinePadding from 'remark-lint-no-inline-padding'
import remarkLintBlockquoteIndentation from 'remark-lint-blockquote-indentation'
import remarkLintCheckboxContentIndent from 'remark-lint-checkbox-content-indent'
import remarkLintFinalNewline from 'remark-lint-final-newline'
import remarkLintListItemBulletIndent from 'remark-lint-list-item-bullet-indent'
import remarkLintListItemIndent from 'remark-lint-list-item-indent'
import remarkLintNoAutoLinkWithoutProtocol from 'remark-lint-no-auto-link-without-protocol'
import remarkLintNoBlockquoteWithoutMarker from 'remark-lint-no-blockquote-without-marker'
import remarkLintNoLiteralUrls from 'remark-lint-no-literal-urls'
import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent'
import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'
import remarkLintCodeBlockStyle from 'remark-lint-code-block-style'
import remarkLintTableCellPadding from 'remark-lint-table-cell-padding'
import remarkLintTablePipes from 'remark-lint-table-pipes'
import remarkLintCheckboxCharacterStyle from 'remark-lint-checkbox-character-style'
import remarkLintDefinitionCase from 'remark-lint-definition-case'
import remarkValidateLinks from 'remark-validate-links'
import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker'
import remarkLintStrongMarker from 'remark-lint-strong-marker'
import remarkLintUnorderedListMarkerStyle from 'remark-lint-unordered-list-marker-style'
import remarkLintFencedCodeMarker from 'remark-lint-fenced-code-marker'
import remarkLintRuleStyle from 'remark-lint-rule-style'
export default function ({ fix, repository, paddedTable, validateLinks }) {
const preset = {
plugins: [
remarkLint,
// These are not automatically fixed by remark-stringify
remarkLintNoUndefinedReferences,
remarkLintNoUnusedDefinitions,
remarkLintNoDuplicateDefinitions,
remarkLintNoInlinePadding,
[remarkLintBlockquoteIndentation, 2], // Means 1 space.
remarkLintCheckboxContentIndent
// TBD
// require('remark-lint-no-shortcut-reference-image'),
// require('remark-lint-no-shortcut-reference-link')
]
}
if (!fix) {
preset.plugins.push(
[remarkLintEmphasisMarker, '_'],
[remarkLintStrongMarker, '*'],
remarkLintFinalNewline,
[remarkLintUnorderedListMarkerStyle, '-'],
remarkLintListItemBulletIndent,
[remarkLintListItemIndent, 'space'],
[remarkLintFencedCodeMarker, '`'],
[remarkLintRuleStyle, '---'],
remarkLintNoAutoLinkWithoutProtocol,
remarkLintNoBlockquoteWithoutMarker,
remarkLintNoLiteralUrls,
remarkLintNoHeadingContentIndent,
remarkLintHardBreakSpaces,
[remarkLintCodeBlockStyle, 'fenced'],
// TODO: support fixed-width columns (https://github.com/remarkjs/remark-lint/issues/217)
paddedTable ? [remarkLintTableCellPadding, 'padded'] : null,
remarkLintTablePipes,
[remarkLintCheckboxCharacterStyle, {
checked: 'x', unchecked: ' '
}],
remarkLintDefinitionCase
)
}
// Temporarily allow skipping link validation, because remark does not parse
// HTML anchors - as used in various Level readme's. Those readme's should be
// updated to use markdown only.
if (validateLinks) {
preset.plugins.push([remarkValidateLinks, {
// If we don't pass this, remark-validate-links tries to get the repo url
// from `git remote -v` which is not desirable for forks.
repository: repository || false
}])
}
preset.plugins = preset.plugins.filter(Boolean)
return preset
}