@kitschpatrol/remark-config 4.7.12 → 5.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/bin/cli.js +6219 -58
- package/dist/index.d.ts +23 -0
- package/dist/index.js +260 -0
- package/init/.remarkrc.js +2 -11
- package/license.txt +1 -1
- package/package.json +66 -64
- package/readme.md +64 -17
- package/remark.config.js +0 -155
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PluggableList, Preset as RemarkConfig } from 'unified';
|
|
2
|
+
import 'remark-stringify';
|
|
3
|
+
declare const remarkSharedConfig: RemarkConfig;
|
|
4
|
+
/**
|
|
5
|
+
* **Remark Shared Configuration**
|
|
6
|
+
* @see [@kitschpatrol/remark-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/remark-config)
|
|
7
|
+
* @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* export default remarkConfig({
|
|
11
|
+
* rules: [
|
|
12
|
+
* ['remark-lint-first-heading-level', 2],
|
|
13
|
+
* ['remarkValidateLinks', { repository: false }],
|
|
14
|
+
* ],
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function remarkConfig(options?: {
|
|
19
|
+
plugins?: PluggableList | undefined;
|
|
20
|
+
rules?: Array<[string, unknown]>;
|
|
21
|
+
settings?: RemarkConfig['settings'];
|
|
22
|
+
}): RemarkConfig;
|
|
23
|
+
export default remarkSharedConfig;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { defaultHandlers as mdastToTextHandlers } from 'mdast-util-to-markdown';
|
|
2
|
+
import remarkDirective from 'remark-directive';
|
|
3
|
+
import remarkFrontmatter from 'remark-frontmatter';
|
|
4
|
+
import remarkGfm from 'remark-gfm';
|
|
5
|
+
import remarkLint from 'remark-lint';
|
|
6
|
+
import remarkValidateLinks from 'remark-validate-links';
|
|
7
|
+
// export { commandDefinition } from './command.js'
|
|
8
|
+
// Necessary for side-effect type definitions?
|
|
9
|
+
import 'remark-stringify';
|
|
10
|
+
// See https://github.com/remarkjs/remark-lint?tab=readme-ov-file#rules
|
|
11
|
+
// Official
|
|
12
|
+
import remarkLintCheckboxContentIndent from 'remark-lint-checkbox-content-indent'; // Warn when too much whitespace follows list item checkboxes
|
|
13
|
+
// import remarkLintCorrectMediaSyntax from 'remark-lint-correct-media-syntax' // Check for accidental bracket and paren mixup for images and links
|
|
14
|
+
// import remarkLintDefinitionSort from 'remark-lint-definition-sort' // Check definition order
|
|
15
|
+
// import remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort' // Check directive attribute order
|
|
16
|
+
// import remarkLintDirectiveCollapsedAttribute from 'remark-lint-directive-collapsed-attribute' // Check that collapsed attributes are used in directives
|
|
17
|
+
// import remarkLintDirectiveQuoteStyle from 'remark-lint-directive-quote-style' // Check quotes of directive attributes
|
|
18
|
+
// import remarkLintDirectiveShortcutAttribute from 'remark-lint-directive-shortcut-attribute' // Check that shortcut attributes are used in directives
|
|
19
|
+
// import remarkLintDirectiveUniqueAttributeName from 'remark-lint-directive-unique-attribute-name' // Check that attribute names are unique
|
|
20
|
+
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag'; // Warn when fenced code blocks occur without language flag
|
|
21
|
+
// import remarkLintFileExtension from 'remark-lint-file-extension' // (Crashes with "Cannot use 'in' operator to search for 'start' in undefined") Warn when the file’s extension violates the given style
|
|
22
|
+
import remarkLintFinalDefinition from 'remark-lint-final-definition'; // Warn when definitions are not placed at the end of the file
|
|
23
|
+
import remarkLintFirstHeadingLevel from 'remark-lint-first-heading-level'; // Warn when the first heading has a level other than a specified value
|
|
24
|
+
import remarkLintHeadingIncrement from 'remark-lint-heading-increment'; // Warn when headings increment with more than 1 level at a time
|
|
25
|
+
import remarkLintLinebreakStyle from 'remark-lint-linebreak-style'; // Warn when linebreaks violate a given or detected style
|
|
26
|
+
import remarkLintMaximumHeadingLength from 'remark-lint-maximum-heading-length'; // Warn when headings are too long
|
|
27
|
+
// import remarkLintMdxJsxAttributeSort from 'remark-lint-mdx-jsx-attribute-sort' // Check mdx jsx attribute order
|
|
28
|
+
// import remarkLintMdxJsxNoVoidChildren from 'remark-lint-mdx-jsx-no-void-children' // Check mdx jsx quotes
|
|
29
|
+
// import remarkLintMdxJsxQuoteStyle from 'remark-lint-mdx-jsx-quote-style' // Check mdx jsx quotes
|
|
30
|
+
// import remarkLintMdxJsxSelfClose from 'remark-lint-mdx-jsx-self-close' // Check that self-closing tags are used when possible
|
|
31
|
+
// import remarkLintMdxJsxShorthandAttribute from 'remark-lint-mdx-jsx-shorthand-attribute' // Check that shorthand attributes are used in MDX JSX
|
|
32
|
+
// import remarkLintMdxJsxUniqueAttributeName from 'remark-lint-mdx-jsx-unique-attribute-name' // Check that mdx jsx attributes are unique
|
|
33
|
+
// import remarkLintMediaStyle from 'remark-lint-media-style' // Check whether references or resources are used
|
|
34
|
+
import remarkLintNoDuplicateDefinedUrls from 'remark-lint-no-duplicate-defined-urls'; // Warn on definitions that define the same urls
|
|
35
|
+
import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'; // Warn on duplicate definitions
|
|
36
|
+
import remarkLintNoDuplicateHeadings from 'remark-lint-no-duplicate-headings'; // Warn on duplicate headings
|
|
37
|
+
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section'; // Warn on duplicate headings in a section
|
|
38
|
+
// import remarkLintNoEmphasisAsHeading from 'remark-lint-no-emphasis-as-heading' // Warn when emphasis or importance is used instead of a heading
|
|
39
|
+
import remarkLintNoEmptyUrl from 'remark-lint-no-empty-url'; // Warn on empty URLs in links and images
|
|
40
|
+
import remarkLintNoFileNameArticles from 'remark-lint-no-file-name-articles'; // Warn when file name start with an article
|
|
41
|
+
import remarkLintNoFileNameConsecutiveDashes from 'remark-lint-no-file-name-consecutive-dashes'; // Warn when file names contain consecutive dashes
|
|
42
|
+
import remarkLintNoFileNameIrregularCharacters from 'remark-lint-no-file-name-irregular-characters'; // Warn when file names contain irregular characters
|
|
43
|
+
// import remarkLintNoFileNameMixedCase from 'remark-lint-no-file-name-mixed-case' // (Crashes with "Cannot use 'in' operator to search for 'start' in undefined") Warn when file names use mixed case
|
|
44
|
+
import remarkLintNoFileNameOuterDashes from 'remark-lint-no-file-name-outer-dashes'; // Warn when file names contain initial or final dashes
|
|
45
|
+
import remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'; // Warn when headings are indented
|
|
46
|
+
import remarkLintNoHeadingLikeParagraph from 'remark-lint-no-heading-like-paragraph'; // For too many hashes (h7+ “headings”)
|
|
47
|
+
// import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation' // Warn when headings end in illegal characters
|
|
48
|
+
// import remarkLintNoHiddenTableCell from 'remark-lint-no-hidden-table-cell' // Check superfluous table cells
|
|
49
|
+
// import remarkLintNoHtml from 'remark-lint-no-html' // Warn when HTML nodes are used
|
|
50
|
+
// import remarkLintNoLiteralUrls from 'remark-lint-no-literal-urls' // Warn when URLs without angle brackets are used
|
|
51
|
+
// import remarkLintNoMissingBlankLines from 'remark-lint-no-missing-blank-lines' // Warn when missing blank lines
|
|
52
|
+
import remarkLintNoMultipleToplevelHeadings from 'remark-lint-no-multiple-toplevel-headings'; // Warn when multiple top level headings are used
|
|
53
|
+
import remarkLintNoParagraphContentIndent from 'remark-lint-no-paragraph-content-indent'; // Warn when the content in paragraphs are indented
|
|
54
|
+
import remarkLintNoReferenceLikeUrl from 'remark-lint-no-reference-like-url'; // Warn when URLs are also defined identifiers
|
|
55
|
+
import remarkLintNoShellDollars from 'remark-lint-no-shell-dollars'; // Warn when shell code is prefixed by dollars
|
|
56
|
+
import remarkLintNoShortcutReferenceImage from 'remark-lint-no-shortcut-reference-image'; // Warn when shortcut reference images are used
|
|
57
|
+
import remarkLintNoShortcutReferenceLink from 'remark-lint-no-shortcut-reference-link'; // Warn when shortcut reference links are used
|
|
58
|
+
import remarkLintNoTabs from 'remark-lint-no-tabs'; // Warn when hard tabs are used instead of spaces
|
|
59
|
+
import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references'; // Warn when references to undefined definitions are found
|
|
60
|
+
import remarkLintNoUnneededFullReferenceImage from 'remark-lint-no-unneeded-full-reference-image'; // Check that full reference images can be collapsed
|
|
61
|
+
import remarkLintNoUnneededFullReferenceLink from 'remark-lint-no-unneeded-full-reference-link'; // Check that full reference links can be collapsed
|
|
62
|
+
import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'; // Warn when unused definitions are found
|
|
63
|
+
import remarkLintStrikethroughMarker from 'remark-lint-strikethrough-marker'; // Warn when strikethrough markers violate the given style
|
|
64
|
+
// Official rules with Prettier conflicts
|
|
65
|
+
// Maintained manually via https://github.com/un-ts/remark-preset-prettier?tab=readme-ov-file#disabled-remark-lint-plugins
|
|
66
|
+
// import remarkLintBlockquoteIndentation from 'remark-lint-blockquote-indentation' // Check whitespace after block quote markers
|
|
67
|
+
// import remarkLintCheckboxCharacterStyle from 'remark-lint-checkbox-character-style' // Check list item checkbox characters
|
|
68
|
+
// import remarkLintCodeBlockStyle from 'remark-lint-code-block-style' // Warn when code blocks do not adhere to a given style
|
|
69
|
+
// import remarkLintDefinitionCase from 'remark-lint-definition-case' // Warn when definition labels are not lowercase
|
|
70
|
+
// import remarkLintDefinitionSpacing from 'remark-lint-definition-spacing' // Warn when consecutive whitespace is used in a definition
|
|
71
|
+
// import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker' // Warn when emphasis markers violate the given style
|
|
72
|
+
// import remarkLintFencedCodeMarker from 'remark-lint-fenced-code-marker' // Warn when fenced code markers violate the given style
|
|
73
|
+
// import remarkLintFinalNewline from 'remark-lint-final-newline' // Warn when a newline at the end of a file is missing
|
|
74
|
+
// import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces' // Warn when too many spaces are used to create a hard break
|
|
75
|
+
// import remarkLintHeadingStyle from 'remark-lint-heading-style' // Warn when heading style violates the given style
|
|
76
|
+
// import remarkLintBlankLines102 from 'remark-lint-blank-lines-1-0-2' // Ensure a specific number of lines between blocks
|
|
77
|
+
// import remarkLintHeadingWhitespace from 'remark-lint-heading-whitespace' // Ensure heading parsing is not broken by weird whitespace
|
|
78
|
+
// import remarkLintLinkTitleStyle from 'remark-lint-link-title-style' // Warn when link and definition titles occur with incorrect quotes
|
|
79
|
+
// import remarkLintListItemBulletIndent from 'remark-lint-list-item-bullet-indent' // Warn when list item bullets are indented
|
|
80
|
+
// import remarkLintListItemContentIndent from 'remark-lint-list-item-content-indent' // Warn when the content of a list item has mixed indentation
|
|
81
|
+
// import remarkLintListItemIndent from 'remark-lint-list-item-indent' // Check the spacing between list item bullets and content
|
|
82
|
+
// import remarkLintListItemSpacing from 'remark-lint-list-item-spacing' // Warn when list looseness is incorrect
|
|
83
|
+
// import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length' // Warn when lines are too long
|
|
84
|
+
// import remarkLintNoBlockquoteWithoutMarker from 'remark-lint-no-blockquote-without-marker' // Warn when block quotes have blank lines without markers
|
|
85
|
+
// import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines' // Warn for too many consecutive blank lines
|
|
86
|
+
// import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent' // Warn when heading content is indented
|
|
87
|
+
// import remarkLintNoTableIndentation from 'remark-lint-no-table-indentation' // Warn when tables are indented
|
|
88
|
+
// import remarkLintOrderedListMarkerStyle from 'remark-lint-ordered-list-marker-style' // Warn when the markers of ordered lists violate a given style
|
|
89
|
+
// import remarkLintOrderedListMarkerValue from 'remark-lint-ordered-list-marker-value' // Check the marker value of ordered lists
|
|
90
|
+
// import remarkLintRuleStyle from 'remark-lint-rule-style' // Warn when horizontal rules violate a given style
|
|
91
|
+
// import remarkLintStrongMarker from 'remark-lint-strong-marker' // Warn when importance (strong) markers violate the given style
|
|
92
|
+
// import remarkLintTableCellPadding from 'remark-lint-table-cell-padding' // Warn when table cells are incorrectly padded
|
|
93
|
+
// import remarkLintTablePipeAlignment from 'remark-lint-table-pipe-alignment' // Warn when table pipes are not aligned
|
|
94
|
+
// import remarkLintTablePipes from 'remark-lint-table-pipes' // Warn when table rows are not fenced with pipes
|
|
95
|
+
// import remarkLintUnorderedListMarkerStyle from 'remark-lint-unordered-list-marker-style' // Warn when markers of unordered lists violate a given style
|
|
96
|
+
// Community maintained rules
|
|
97
|
+
// import remarkLintAlphabetizeLists from 'remark-lint-alphabetize-lists' // Ensure list items are in alphabetical order
|
|
98
|
+
// import remarkLintAppropriateHeading from 'remark-lint-appropriate-heading' // Check that the top level heading matches the directory name
|
|
99
|
+
// import remarkLintAreLinksValid from 'remark-lint-are-links-valid' // Check if your links are reachable and/or unique
|
|
100
|
+
// import remarkLintCheckToc from 'remark-lint-check-toc' // Ensure TOC is correct
|
|
101
|
+
// import remarkLintCode from 'remark-lint-code' // Lint fenced code blocks by corresponding language tags, currently supporting ESLint
|
|
102
|
+
// import remarkLintCodeBlockSplitList from 'remark-lint-code-block-split-list' // Ensure code block inside list doesn't split the list
|
|
103
|
+
// import remarkLintDoubleLink from 'remark-lint-double-link' // Ensure the same URL is not linked multiple times.
|
|
104
|
+
// import remarkLintEmojiLimit from 'remark-lint-emoji-limit' // Enforce a limit of emoji per paragraph
|
|
105
|
+
// import remarkLintFencedCodeFlagCase from 'remark-lint-fenced-code-flag-case' // Warn when fenced code blocks have improperly cased language flags
|
|
106
|
+
// import remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema' // Validate YAML frontmatter against a JSON schema
|
|
107
|
+
// import remarkLintHeadingCapitalization from 'remark-lint-heading-capitalization' // Ensure headings capitalization is correct
|
|
108
|
+
// import remarkLintHeadingLength from 'remark-lint-heading-length' // Ensure headings have the appropriate length
|
|
109
|
+
// import remarkLintHeadingWordLength from 'remark-lint-heading-word-length' // Warn when headings have too many or too few words with unicode support
|
|
110
|
+
// import remarkLintListItemStyle from 'remark-lint-list-item-style' // Warn when list items violate a given capitalization or punctuation style
|
|
111
|
+
// import remarkLintMatchPunctuation from 'remark-lint-match-punctuation' // Ensures punctuations are used in pairs if necessary.
|
|
112
|
+
// import remarkLintMdashStyle from 'remark-lint-mdash-style' // Ensure em-dash (—) style follows a standard format
|
|
113
|
+
// import remarkLintNoChinesePunctuationInNumber from 'remark-lint-no-chinese-punctuation-in-number' // Ensures that Chinese punctuation’s not used in numbers
|
|
114
|
+
// import remarkLintNoDeadUrls from 'remark-lint-no-dead-urls' // Check that external links are alive
|
|
115
|
+
// import remarkLintNoEmptySections from 'remark-lint-no-empty-sections' // Ensure every heading is followed by content (forming a section)
|
|
116
|
+
// import remarkLintNoRepeatPunctuation from 'remark-lint-no-repeat-punctuation' // Ensures punctuation is not repeated
|
|
117
|
+
// import remarkLintNoUrlTrailingSlash from 'remark-lint-no-url-trailing-slash' // Ensure that the href of links has no trailing slash
|
|
118
|
+
// import remarkLintWriteGood from 'remark-lint-write-good' // Wrapper for write-good
|
|
119
|
+
// Community maintained rules with Prettier conflicts
|
|
120
|
+
// Maintained manually via https://github.com/un-ts/remark-preset-prettier?tab=readme-ov-file#disabled-remark-lint-plugins
|
|
121
|
+
// import remarkLintBooksLinks from 'remark-lint-books-links' // Ensure links in lists of books follow a standard format
|
|
122
|
+
// import remarkLintNoLongCode from 'remark-lint-no-long-code' // Ensures that each line in code block won't be too long.
|
|
123
|
+
// import remarkLintSpacesAroundNumber from 'remark-lint-spaces-around-number' // Ensures there are spaces around number and Chinese.
|
|
124
|
+
// import remarkLintSpacesAroundWord from 'remark-lint-spaces-around-word' // Ensures there are spaces around English word and Chinese.
|
|
125
|
+
const remarkSharedConfig = {
|
|
126
|
+
plugins: [
|
|
127
|
+
remarkLint,
|
|
128
|
+
remarkFrontmatter,
|
|
129
|
+
remarkGfm,
|
|
130
|
+
remarkDirective,
|
|
131
|
+
remarkLintCheckboxContentIndent,
|
|
132
|
+
[remarkLintFencedCodeFlag, { allowEmpty: false }],
|
|
133
|
+
remarkLintFinalDefinition,
|
|
134
|
+
remarkLintFirstHeadingLevel,
|
|
135
|
+
remarkLintHeadingIncrement,
|
|
136
|
+
remarkLintLinebreakStyle,
|
|
137
|
+
remarkLintMaximumHeadingLength,
|
|
138
|
+
remarkLintNoDuplicateDefinedUrls,
|
|
139
|
+
remarkLintNoDuplicateDefinitions,
|
|
140
|
+
remarkLintNoDuplicateHeadings,
|
|
141
|
+
remarkLintNoDuplicateHeadingsInSection,
|
|
142
|
+
remarkLintNoEmptyUrl,
|
|
143
|
+
remarkLintNoFileNameArticles,
|
|
144
|
+
remarkLintNoFileNameConsecutiveDashes,
|
|
145
|
+
remarkLintNoFileNameIrregularCharacters,
|
|
146
|
+
remarkLintNoFileNameOuterDashes,
|
|
147
|
+
remarkLintNoHeadingIndent,
|
|
148
|
+
remarkLintNoHeadingLikeParagraph,
|
|
149
|
+
remarkLintNoMultipleToplevelHeadings,
|
|
150
|
+
remarkLintNoParagraphContentIndent,
|
|
151
|
+
remarkLintNoReferenceLikeUrl,
|
|
152
|
+
remarkLintNoShellDollars,
|
|
153
|
+
remarkLintNoShortcutReferenceImage,
|
|
154
|
+
remarkLintNoShortcutReferenceLink,
|
|
155
|
+
remarkLintNoTabs,
|
|
156
|
+
[
|
|
157
|
+
remarkLintNoUndefinedReferences,
|
|
158
|
+
{
|
|
159
|
+
allow: [
|
|
160
|
+
'…',
|
|
161
|
+
'...',
|
|
162
|
+
// GitHub Alerts / Admonitions
|
|
163
|
+
// https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
|
|
164
|
+
// See also the custom text handler below in settings
|
|
165
|
+
'!NOTE',
|
|
166
|
+
'!TIP',
|
|
167
|
+
'!IMPORTANT',
|
|
168
|
+
'!WARNING',
|
|
169
|
+
'!CAUTION',
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
remarkLintNoUnneededFullReferenceImage,
|
|
174
|
+
remarkLintNoUnneededFullReferenceLink,
|
|
175
|
+
remarkLintNoUnusedDefinitions,
|
|
176
|
+
remarkLintNoUnusedDefinitions,
|
|
177
|
+
remarkLintStrikethroughMarker,
|
|
178
|
+
remarkValidateLinks,
|
|
179
|
+
],
|
|
180
|
+
// Prettier will enforce some of these?
|
|
181
|
+
settings: {
|
|
182
|
+
bullet: '-',
|
|
183
|
+
emphasis: '_',
|
|
184
|
+
handlers: {
|
|
185
|
+
// Prevent escaping GFM alerts / admonitions
|
|
186
|
+
// https://github.com/Xunnamius/symbiote/blob/main/src/assets/transformers/_.remarkrc.mjs.ts
|
|
187
|
+
// This is necessary in addition to the remark-lint-no-undefined-references rule customization below.
|
|
188
|
+
text(node, parent, state, info) {
|
|
189
|
+
// Call the default text handler, then strip the leading "\" from GFM alerts
|
|
190
|
+
// Case insensitivity is important!
|
|
191
|
+
const markdownString = mdastToTextHandlers.text(node, parent, state, info);
|
|
192
|
+
return markdownString.replace(/^\\(?=\[!(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION)\])/i, '');
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
rule: '-',
|
|
196
|
+
strong: '*',
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Overrides specific rules in a set of plugins.
|
|
201
|
+
*
|
|
202
|
+
* This function searches through an array of plugins to find and override
|
|
203
|
+
* multiple plugins by their names, replacing their arguments with new ones.
|
|
204
|
+
*
|
|
205
|
+
* See this link for why we need this:
|
|
206
|
+
* https://github.com/remarkjs/remark-lint/issues/165
|
|
207
|
+
*
|
|
208
|
+
*/
|
|
209
|
+
function overrideRules(plugins, rules) {
|
|
210
|
+
plugins ??= [];
|
|
211
|
+
for (let [ruleName, newArguments] of rules) {
|
|
212
|
+
// Internally, function names are different from the package names
|
|
213
|
+
ruleName = ruleName.replace(/^remark-lint-/, 'remark-lint:');
|
|
214
|
+
let ruleFunction;
|
|
215
|
+
const index = plugins.findIndex((plugin) => {
|
|
216
|
+
if (Array.isArray(plugin)) {
|
|
217
|
+
if (plugin[0].name === ruleName) {
|
|
218
|
+
ruleFunction = plugin[0];
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if ('name' in plugin && plugin.name === ruleName) {
|
|
223
|
+
ruleFunction = plugin;
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
});
|
|
228
|
+
if (index !== -1) {
|
|
229
|
+
plugins.splice(index, 1, [ruleFunction, newArguments]);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return plugins;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* **Remark Shared Configuration**
|
|
236
|
+
* @see [@kitschpatrol/remark-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/remark-config)
|
|
237
|
+
* @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
|
|
238
|
+
* @example
|
|
239
|
+
* ```js
|
|
240
|
+
* export default remarkConfig({
|
|
241
|
+
* rules: [
|
|
242
|
+
* ['remark-lint-first-heading-level', 2],
|
|
243
|
+
* ['remarkValidateLinks', { repository: false }],
|
|
244
|
+
* ],
|
|
245
|
+
* })
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
export function remarkConfig(options) {
|
|
249
|
+
const { plugins = [], rules = [], settings, } = options ?? {
|
|
250
|
+
plugins: undefined,
|
|
251
|
+
rules: undefined,
|
|
252
|
+
settings: undefined,
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
...remarkSharedConfig,
|
|
256
|
+
plugins: overrideRules([...(remarkSharedConfig.plugins ?? []), ...plugins], rules),
|
|
257
|
+
settings: { ...remarkSharedConfig.settings, ...settings },
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export default remarkSharedConfig;
|
package/init/.remarkrc.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { remarkConfig } from '@kitschpatrol/remark-config'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
...sharedConfig,
|
|
5
|
-
// Overrides are a special case, working as below (set `false` as the second element to disable):
|
|
6
|
-
// plugins: overrideRules(sharedConfig.plugins, [
|
|
7
|
-
// ['remark-lint-first-heading-level', 2],
|
|
8
|
-
// ['remarkValidateLinks', { repository: false }],
|
|
9
|
-
// ]),
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default localConfig
|
|
3
|
+
export default remarkConfig()
|
package/license.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,97 +1,99 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/remark-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "5.0.0",
|
|
5
4
|
"description": "Markdown and MDX linting for @kitschpatrol/shared-config.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"shared-config",
|
|
7
|
+
"remark-config",
|
|
8
|
+
"remark-lint",
|
|
9
|
+
"remark",
|
|
10
|
+
"cli",
|
|
11
|
+
"kpi",
|
|
12
|
+
"kpi-remark"
|
|
13
|
+
],
|
|
14
|
+
"bugs": "https://github.com/kitschpatrol/shared-config/issues",
|
|
6
15
|
"repository": {
|
|
7
16
|
"type": "git",
|
|
8
17
|
"url": "git+https://github.com/kitschpatrol/shared-config/cli.git",
|
|
9
18
|
"directory": "packages/remark-config"
|
|
10
19
|
},
|
|
11
|
-
"
|
|
20
|
+
"license": "MIT",
|
|
12
21
|
"author": {
|
|
13
22
|
"name": "Eric Mika",
|
|
14
23
|
"email": "eric@ericmika.com",
|
|
15
24
|
"url": "https://ericmika.com"
|
|
16
25
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts"
|
|
31
|
+
}
|
|
21
32
|
},
|
|
33
|
+
"main": "dist/index.js",
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
22
35
|
"bin": {
|
|
23
|
-
"remark
|
|
36
|
+
"kpi-remark": "bin/cli.js"
|
|
24
37
|
},
|
|
25
|
-
"main": "remark.config.js",
|
|
26
38
|
"files": [
|
|
27
39
|
"bin/*",
|
|
40
|
+
"dist/*",
|
|
28
41
|
"init/*"
|
|
29
42
|
],
|
|
30
|
-
"keywords": [
|
|
31
|
-
"shared-config",
|
|
32
|
-
"remark-config",
|
|
33
|
-
"remark-lint",
|
|
34
|
-
"remark",
|
|
35
|
-
"cli"
|
|
36
|
-
],
|
|
37
43
|
"dependencies": {
|
|
38
44
|
"@pinojs/json-colorizer": "^4.0.0",
|
|
45
|
+
"@types/mdast": "^4.0.4",
|
|
39
46
|
"cosmiconfig": "^9.0.0",
|
|
40
|
-
"execa": "^
|
|
41
|
-
"fs-extra": "^11.
|
|
42
|
-
"
|
|
43
|
-
"remark-directive": "^3.0.
|
|
47
|
+
"execa": "^9.5.2",
|
|
48
|
+
"fs-extra": "^11.3.0",
|
|
49
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
50
|
+
"remark-directive": "^3.0.1",
|
|
44
51
|
"remark-frontmatter": "^5.0.0",
|
|
45
52
|
"remark-gfm": "^4.0.0",
|
|
46
|
-
"remark-lint": "^10.0.
|
|
47
|
-
"remark-lint-checkbox-
|
|
48
|
-
"remark-lint-
|
|
49
|
-
"remark-lint-
|
|
50
|
-
"remark-lint-
|
|
51
|
-
"remark-lint-
|
|
52
|
-
"remark-lint-
|
|
53
|
-
"remark-lint-
|
|
54
|
-
"remark-lint-
|
|
55
|
-
"remark-lint-
|
|
56
|
-
"remark-lint-
|
|
57
|
-
"remark-lint-
|
|
58
|
-
"remark-lint-no-
|
|
59
|
-
"remark-lint-no-
|
|
60
|
-
"remark-lint-no-
|
|
61
|
-
"remark-lint-no-
|
|
62
|
-
"remark-lint-no-
|
|
63
|
-
"remark-lint-no-
|
|
64
|
-
"remark-lint-no-
|
|
65
|
-
"remark-lint-no-
|
|
66
|
-
"remark-lint-no-
|
|
67
|
-
"remark-lint-no-
|
|
68
|
-
"remark-lint-no-
|
|
69
|
-
"remark-lint-no-
|
|
70
|
-
"remark-lint-no-
|
|
71
|
-
"remark-lint-no-
|
|
72
|
-
"remark-lint-no-
|
|
73
|
-
"remark-lint-no-
|
|
74
|
-
"remark-lint-no-
|
|
75
|
-
"remark-lint-no-
|
|
76
|
-
"remark-lint-
|
|
77
|
-
"remark-
|
|
78
|
-
"remark-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"remark-lint-strong-marker": "^4.0.0",
|
|
85
|
-
"remark-lint-table-cell-padding": "^5.0.0",
|
|
86
|
-
"remark-lint-unordered-list-marker-style": "^4.0.0",
|
|
87
|
-
"remark-preset-prettier": "^2.0.1",
|
|
88
|
-
"remark-validate-links": "^13.0.2"
|
|
53
|
+
"remark-lint": "^10.0.1",
|
|
54
|
+
"remark-lint-checkbox-content-indent": "^5.0.1",
|
|
55
|
+
"remark-lint-fenced-code-flag": "^4.1.1",
|
|
56
|
+
"remark-lint-final-definition": "^4.0.2",
|
|
57
|
+
"remark-lint-first-heading-level": "^4.0.1",
|
|
58
|
+
"remark-lint-heading-increment": "^4.0.1",
|
|
59
|
+
"remark-lint-linebreak-style": "^4.0.1",
|
|
60
|
+
"remark-lint-maximum-heading-length": "^4.1.1",
|
|
61
|
+
"remark-lint-no-duplicate-defined-urls": "^3.0.1",
|
|
62
|
+
"remark-lint-no-duplicate-definitions": "^4.0.1",
|
|
63
|
+
"remark-lint-no-duplicate-headings": "^4.0.1",
|
|
64
|
+
"remark-lint-no-duplicate-headings-in-section": "^4.0.1",
|
|
65
|
+
"remark-lint-no-empty-url": "^4.0.1",
|
|
66
|
+
"remark-lint-no-file-name-articles": "^3.0.1",
|
|
67
|
+
"remark-lint-no-file-name-consecutive-dashes": "^3.0.1",
|
|
68
|
+
"remark-lint-no-file-name-irregular-characters": "^3.0.1",
|
|
69
|
+
"remark-lint-no-file-name-outer-dashes": "^3.0.1",
|
|
70
|
+
"remark-lint-no-heading-indent": "^5.0.1",
|
|
71
|
+
"remark-lint-no-heading-like-paragraph": "^4.0.1",
|
|
72
|
+
"remark-lint-no-multiple-toplevel-headings": "^4.0.1",
|
|
73
|
+
"remark-lint-no-paragraph-content-indent": "^5.0.1",
|
|
74
|
+
"remark-lint-no-reference-like-url": "^4.0.1",
|
|
75
|
+
"remark-lint-no-shell-dollars": "^4.0.1",
|
|
76
|
+
"remark-lint-no-shortcut-reference-image": "^4.0.1",
|
|
77
|
+
"remark-lint-no-shortcut-reference-link": "^4.0.1",
|
|
78
|
+
"remark-lint-no-tabs": "^4.0.1",
|
|
79
|
+
"remark-lint-no-undefined-references": "^5.0.1",
|
|
80
|
+
"remark-lint-no-unneeded-full-reference-image": "^4.0.1",
|
|
81
|
+
"remark-lint-no-unneeded-full-reference-link": "^4.0.1",
|
|
82
|
+
"remark-lint-no-unused-definitions": "^4.0.1",
|
|
83
|
+
"remark-lint-strikethrough-marker": "^3.0.1",
|
|
84
|
+
"remark-stringify": "^11.0.0",
|
|
85
|
+
"remark-validate-links": "^13.0.2",
|
|
86
|
+
"unified": "^11.0.5"
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=22.0.0",
|
|
90
|
+
"pnpm": ">=10.0.0"
|
|
89
91
|
},
|
|
90
92
|
"publishConfig": {
|
|
91
93
|
"access": "public"
|
|
92
94
|
},
|
|
93
95
|
"scripts": {
|
|
94
|
-
"build": "../../scripts/build.ts
|
|
96
|
+
"build": "tsc && ../../scripts/build.ts",
|
|
95
97
|
"cli": "node ./bin/cli.js"
|
|
96
98
|
}
|
|
97
99
|
}
|
package/readme.md
CHANGED
|
@@ -21,9 +21,17 @@
|
|
|
21
21
|
|
|
22
22
|
## Overview
|
|
23
23
|
|
|
24
|
-
It's a shared [Remark](https://github.com/remarkjs/remark/blob/main/packages/remark-cli/readme.md#example-config-files-json-yaml-js) config for linting.
|
|
24
|
+
It's a shared [Remark](https://github.com/remarkjs/remark/blob/main/packages/remark-cli/readme.md#example-config-files-json-yaml-js) config for linting Markdown and MDX files, plus a command-line tool `kpi-remark` to streamline project initialization. Note that linting and fixing is provided separately through [@kitschpatrol/eslint-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/eslint-config).
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
<!-- recommendation -->
|
|
27
|
+
|
|
28
|
+
> [!Important]
|
|
29
|
+
>
|
|
30
|
+
> **You can use this package on its own, but it's recommended to use [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config) instead for a single-dependency and single-package approach to linting and fixing your project.**
|
|
31
|
+
>
|
|
32
|
+
> This package is included as a dependency in [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config), which also automatically invokes the command line functionality in this package via its `kpi` command
|
|
33
|
+
|
|
34
|
+
<!-- /recommendation -->
|
|
27
35
|
|
|
28
36
|
## Setup
|
|
29
37
|
|
|
@@ -32,7 +40,7 @@ To use just this Remark config in isolation:
|
|
|
32
40
|
1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior:
|
|
33
41
|
|
|
34
42
|
```sh
|
|
35
|
-
pnpm dlx @kitschpatrol/repo-config
|
|
43
|
+
pnpm dlx @kitschpatrol/repo-config init
|
|
36
44
|
```
|
|
37
45
|
|
|
38
46
|
2. Add the package:
|
|
@@ -44,20 +52,22 @@ To use just this Remark config in isolation:
|
|
|
44
52
|
3. Add the starter `.remarkrc.js` and files to your project root, and add any customizations you'd like:
|
|
45
53
|
|
|
46
54
|
```sh
|
|
47
|
-
pnpm exec remark
|
|
55
|
+
pnpm exec kpi-remark init
|
|
48
56
|
```
|
|
49
57
|
|
|
50
58
|
## Usage
|
|
51
59
|
|
|
52
60
|
The Remark binary should be picked up automatically by VS Code plugins.
|
|
53
61
|
|
|
54
|
-
You can call it directly, but it's recommended to use the script bundled with the shared
|
|
62
|
+
You can call it directly, but it's recommended to use the `kpi` script bundled with the [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) instead to invoke the Remark lint rules through ESLint. The [`eslint-mdx`](https://github.com/mdx-js/eslint-mdx) plugin is used to bridge these rules into ESLint and the VS Code ESLint plugin.
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
If you really want to call it directly, you can integrate a command to the underlying `remark` CLI tool with your `package.json` scripts as you see fit, for example:
|
|
57
65
|
|
|
58
66
|
```json
|
|
59
|
-
|
|
60
|
-
"
|
|
67
|
+
{
|
|
68
|
+
"scripts": {
|
|
69
|
+
"lint": "pnpm remark . --quiet --frail"
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
72
|
```
|
|
63
73
|
|
|
@@ -65,22 +75,59 @@ Integrate with your `package.json` scripts as you see fit, for example:
|
|
|
65
75
|
|
|
66
76
|
<!-- cli-help -->
|
|
67
77
|
|
|
68
|
-
#### Command: `remark
|
|
78
|
+
#### Command: `kpi-remark`
|
|
79
|
+
|
|
80
|
+
Kitschpatrol's Remark and Remark Lint shared configuration tools. (Actual linting and fixing is managed through @kitschpatrol/eslint-config.)
|
|
81
|
+
|
|
82
|
+
This section lists top-level commands for `kpi-remark`.
|
|
83
|
+
|
|
84
|
+
Usage:
|
|
85
|
+
|
|
86
|
+
```txt
|
|
87
|
+
kpi-remark <command>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Command | Description |
|
|
91
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `init` | Initialize by copying starter config files to your project root. |
|
|
93
|
+
| `print-config` | Print the effective Remark configuration. Package-scoped. Searches up to the root of a monorepo if necessary. |
|
|
94
|
+
|
|
95
|
+
| Option | Description | Type |
|
|
96
|
+
| ------------------- | ------------------- | --------- |
|
|
97
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
98
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
99
|
+
|
|
100
|
+
_See the sections below for more information on each subcommand._
|
|
101
|
+
|
|
102
|
+
#### Subcommand: `kpi-remark init`
|
|
103
|
+
|
|
104
|
+
Initialize by copying starter config files to your project root.
|
|
105
|
+
|
|
106
|
+
Usage:
|
|
107
|
+
|
|
108
|
+
```txt
|
|
109
|
+
kpi-remark init
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Option | Description | Type |
|
|
113
|
+
| ------------------- | ------------------- | --------- |
|
|
114
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
115
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
116
|
+
|
|
117
|
+
#### Subcommand: `kpi-remark print-config`
|
|
69
118
|
|
|
70
|
-
|
|
119
|
+
Print the effective Remark configuration. Package-scoped. Searches up to the root of a monorepo if necessary.
|
|
71
120
|
|
|
72
121
|
Usage:
|
|
73
122
|
|
|
74
123
|
```txt
|
|
75
|
-
remark-config
|
|
124
|
+
kpi-remark print-config
|
|
76
125
|
```
|
|
77
126
|
|
|
78
|
-
| Option
|
|
79
|
-
|
|
|
80
|
-
| `--
|
|
81
|
-
| `--
|
|
82
|
-
| `--help`<br>`-h` | | Print this help info. |
|
|
83
|
-
| `--version`<br>`-v` | | Print the package version. |
|
|
127
|
+
| Option | Description | Type |
|
|
128
|
+
| ------------------- | ------------------- | --------- |
|
|
129
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
130
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
84
131
|
|
|
85
132
|
<!-- /cli-help -->
|
|
86
133
|
|