@brnshkr/config 0.0.1-beta.2 → 0.0.1-beta.4
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/README.md +177 -228
- package/conf/.gitignore.dist +15 -0
- package/conf/Makefile +3778 -0
- package/conf/Makefile.dist +13 -0
- package/conf/bunfig.dist.toml +5 -0
- package/conf/commitlint.dist.mjs +1 -0
- package/conf/editorconfig.dist +19 -0
- package/conf/launch.dist.json +31 -0
- package/conf/markdownlint.dist.mjs +1 -0
- package/conf/spelling/defaults.json +185 -0
- package/conf/tsconfig.dist.json +3 -0
- package/conf/tsconfig.json +31 -27
- package/conf/vitest.dist.mjs +1 -0
- package/conf/vscode-css-custom-data.dist.json +95 -0
- package/conf/vscode-extensions.dist.json +21 -0
- package/conf/vscode-settings.dist.jsonc +338 -0
- package/dist/commitlint/index.d.mts +72 -0
- package/dist/commitlint/index.mjs +239 -0
- package/dist/eslint/index.d.mts +3897 -1383
- package/dist/eslint/index.mjs +2784 -419
- package/dist/markdownlint/index.d.mts +2304 -0
- package/dist/markdownlint/index.mjs +440 -0
- package/dist/shared.mjs +405 -65
- package/dist/spelling/index.d.mts +30 -0
- package/dist/spelling/index.mjs +2 -0
- package/dist/spelling/spelling.test.d.mts +1 -0
- package/dist/spelling/spelling.test.mjs +12 -0
- package/dist/stylelint/index.d.mts +47 -9
- package/dist/stylelint/index.mjs +145 -47
- package/dist/vitest/index.d.mts +73 -0
- package/dist/vitest/index.mjs +181 -0
- package/package.json +192 -105
- package/conf/tsconfig.json.example +0 -3
- package/dist/scripts/eslint.mjs +0 -16
- package/dist/scripts/stylelint.mjs +0 -29
- /package/conf/{eslint.config.mjs.example → eslint.dist.mjs} +0 -0
- /package/conf/{stylelint.config.mjs.example → stylelint.dist.mjs} +0 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import { E as objectKeys, f as createModuleState, g as resolvePackagesSharedSynchronously, m as isModuleEnabledByDefault, u as GLOB_IGNORES, w as objectEntries, y as MARKDOWNLINT_PACKAGES } from "../shared.mjs";
|
|
2
|
+
import { resolveModule } from "local-pkg";
|
|
3
|
+
//#region ../src/js/markdownlint/utils/config.ts
|
|
4
|
+
/**
|
|
5
|
+
* @internal @brnshkr/config/markdownlint
|
|
6
|
+
*/
|
|
7
|
+
const resolveCustomRule = (id) => resolveModule(id) ?? id;
|
|
8
|
+
const isValidGlobalAdditionalConfigKey = (key) => [
|
|
9
|
+
"$schema",
|
|
10
|
+
"config",
|
|
11
|
+
"customRules",
|
|
12
|
+
"fix",
|
|
13
|
+
"frontMatter",
|
|
14
|
+
"gitignore",
|
|
15
|
+
"globs",
|
|
16
|
+
"ignores",
|
|
17
|
+
"markdownItPlugins",
|
|
18
|
+
"modulePaths",
|
|
19
|
+
"noBanner",
|
|
20
|
+
"noInlineConfig",
|
|
21
|
+
"noProgress",
|
|
22
|
+
"outputFormatters",
|
|
23
|
+
"overrides",
|
|
24
|
+
"showFound"
|
|
25
|
+
].includes(key);
|
|
26
|
+
const getGlobalAdditionalConfig = (options) => {
|
|
27
|
+
const config = {};
|
|
28
|
+
for (const [key, value] of objectEntries(options)) if (isValidGlobalAdditionalConfigKey(key)) config[key] = value;
|
|
29
|
+
if (objectKeys(config).length === 0) return;
|
|
30
|
+
return config;
|
|
31
|
+
};
|
|
32
|
+
const getUserConfigs = (resolvedOptions, additionalConfigs) => [getGlobalAdditionalConfig(resolvedOptions), ...additionalConfigs].filter(Boolean);
|
|
33
|
+
const includeConfigs = (config, configsToInclude) => {
|
|
34
|
+
for (const configToInclude of configsToInclude) {
|
|
35
|
+
if (configToInclude.$schema !== void 0) config.$schema = configToInclude.$schema;
|
|
36
|
+
if (configToInclude.config !== void 0) config.config = {
|
|
37
|
+
...config.config,
|
|
38
|
+
...configToInclude.config
|
|
39
|
+
};
|
|
40
|
+
if (configToInclude.customRules !== void 0) config.customRules = [.../* @__PURE__ */ new Set([...config.customRules ?? [], ...configToInclude.customRules])];
|
|
41
|
+
if (configToInclude.fix !== void 0) config.fix = configToInclude.fix;
|
|
42
|
+
if (configToInclude.frontMatter !== void 0) config.frontMatter = configToInclude.frontMatter;
|
|
43
|
+
if (configToInclude.gitignore !== void 0) config.gitignore = configToInclude.gitignore;
|
|
44
|
+
if (configToInclude.globs !== void 0) config.globs = [.../* @__PURE__ */ new Set([...config.globs ?? [], ...configToInclude.globs])];
|
|
45
|
+
if (configToInclude.ignores !== void 0) config.ignores = [.../* @__PURE__ */ new Set([...config.ignores ?? [], ...configToInclude.ignores])];
|
|
46
|
+
if (configToInclude.markdownItPlugins !== void 0) config.markdownItPlugins = configToInclude.markdownItPlugins;
|
|
47
|
+
if (configToInclude.modulePaths !== void 0) config.modulePaths = [.../* @__PURE__ */ new Set([...config.modulePaths ?? [], ...configToInclude.modulePaths])];
|
|
48
|
+
if (configToInclude.noBanner !== void 0) config.noBanner = configToInclude.noBanner;
|
|
49
|
+
if (configToInclude.noInlineConfig !== void 0) config.noInlineConfig = configToInclude.noInlineConfig;
|
|
50
|
+
if (configToInclude.noProgress !== void 0) config.noProgress = configToInclude.noProgress;
|
|
51
|
+
if (configToInclude.outputFormatters !== void 0) config.outputFormatters = configToInclude.outputFormatters;
|
|
52
|
+
if (configToInclude.overrides !== void 0) config.overrides = [...config.overrides ?? [], ...configToInclude.overrides.map((override) => ({
|
|
53
|
+
combine: "merge",
|
|
54
|
+
...override
|
|
55
|
+
}))];
|
|
56
|
+
if (configToInclude.showFound !== void 0) config.showFound = configToInclude.showFound;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region ../src/js/markdownlint/utils/module.ts
|
|
61
|
+
/**
|
|
62
|
+
* @internal @brnshkr/config/markdownlint
|
|
63
|
+
*/
|
|
64
|
+
const MODULES = {
|
|
65
|
+
github: {
|
|
66
|
+
name: "github",
|
|
67
|
+
packages: { requiredAll: [MARKDOWNLINT_PACKAGES.MARKDOWNLINT_GITHUB] }
|
|
68
|
+
},
|
|
69
|
+
links: {
|
|
70
|
+
name: "links",
|
|
71
|
+
packages: { requiredAny: [MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_RELATIVE_LINKS, MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_NO_TRAILING_SLASH_IN_LINKS] }
|
|
72
|
+
},
|
|
73
|
+
search: {
|
|
74
|
+
name: "search",
|
|
75
|
+
packages: { requiredAll: [MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_SEARCH_REPLACE] }
|
|
76
|
+
},
|
|
77
|
+
style: {
|
|
78
|
+
name: "style",
|
|
79
|
+
packages: { requiredAll: [MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULES] }
|
|
80
|
+
},
|
|
81
|
+
tables: {
|
|
82
|
+
name: "tables",
|
|
83
|
+
packages: { requiredAll: [MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_TABLE_FORMAT] }
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const resolvePackages = resolvePackagesSharedSynchronously;
|
|
87
|
+
const { isModuleEnabled, setModuleEnabled } = createModuleState();
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region ../src/js/markdownlint/configs/github.ts
|
|
90
|
+
/**
|
|
91
|
+
* @internal @brnshkr/config/markdownlint
|
|
92
|
+
*/
|
|
93
|
+
const github = () => {
|
|
94
|
+
const { requiredAll: [isMarkdownlintGithubInstalled] } = resolvePackages(MODULES.github);
|
|
95
|
+
if (!isMarkdownlintGithubInstalled) return [];
|
|
96
|
+
return [{
|
|
97
|
+
customRules: [resolveCustomRule(MARKDOWNLINT_PACKAGES.MARKDOWNLINT_GITHUB)],
|
|
98
|
+
config: { "no-empty-alt-text": true }
|
|
99
|
+
}];
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../src/js/markdownlint/configs/ignores.ts
|
|
103
|
+
/**
|
|
104
|
+
* @internal @brnshkr/config/markdownlint
|
|
105
|
+
*/
|
|
106
|
+
const ignores = () => [{
|
|
107
|
+
gitignore: true,
|
|
108
|
+
ignores: GLOB_IGNORES
|
|
109
|
+
}];
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region ../src/js/markdownlint/configs/links.ts
|
|
112
|
+
/**
|
|
113
|
+
* @internal @brnshkr/config/markdownlint
|
|
114
|
+
*/
|
|
115
|
+
const NO_TRAILING_SLASH_IN_LINKS_RULE = `${MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_NO_TRAILING_SLASH_IN_LINKS}/src/no-trailing-slash-in-links.js`;
|
|
116
|
+
const links = () => {
|
|
117
|
+
const { requiredAny: [isMarkdownlintRuleRelativeLinksInstalled, isMarkdownlintRuleNoTrailingSlashInLinksInstalled] } = resolvePackages(MODULES.links);
|
|
118
|
+
const customRules = [...isMarkdownlintRuleRelativeLinksInstalled ? [MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_RELATIVE_LINKS] : [], ...isMarkdownlintRuleNoTrailingSlashInLinksInstalled ? [NO_TRAILING_SLASH_IN_LINKS_RULE] : []];
|
|
119
|
+
if (customRules.length === 0) return [];
|
|
120
|
+
return [{
|
|
121
|
+
customRules: customRules.map((id) => resolveCustomRule(id)),
|
|
122
|
+
config: { ...isMarkdownlintRuleRelativeLinksInstalled ? { "relative-links": { root_path: "." } } : void 0 }
|
|
123
|
+
}];
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region ../src/js/markdownlint/utils/constants.ts
|
|
127
|
+
/**
|
|
128
|
+
* @internal @brnshkr/config/markdownlint
|
|
129
|
+
*/
|
|
130
|
+
const TABLE_STYLE = "compact";
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region ../src/js/markdownlint/configs/markdown.ts
|
|
133
|
+
/**
|
|
134
|
+
* @internal @brnshkr/config/markdownlint
|
|
135
|
+
*/
|
|
136
|
+
const markdown = () => [{ config: {
|
|
137
|
+
default: true,
|
|
138
|
+
"code-block-style": { style: "fenced" },
|
|
139
|
+
"code-fence-style": { style: "backtick" },
|
|
140
|
+
"emphasis-style": { style: "underscore" },
|
|
141
|
+
"heading-style": { style: "atx" },
|
|
142
|
+
"hr-style": { style: "---" },
|
|
143
|
+
"line-length": {
|
|
144
|
+
line_length: 120,
|
|
145
|
+
code_blocks: false,
|
|
146
|
+
headings: false,
|
|
147
|
+
tables: false
|
|
148
|
+
},
|
|
149
|
+
"no-duplicate-heading": { siblings_only: true },
|
|
150
|
+
"no-inline-html": { allowed_elements: [
|
|
151
|
+
"a",
|
|
152
|
+
"br",
|
|
153
|
+
"dd",
|
|
154
|
+
"del",
|
|
155
|
+
"details",
|
|
156
|
+
"div",
|
|
157
|
+
"dl",
|
|
158
|
+
"dt",
|
|
159
|
+
"h1",
|
|
160
|
+
"img",
|
|
161
|
+
"ins",
|
|
162
|
+
"kbd",
|
|
163
|
+
"p",
|
|
164
|
+
"q",
|
|
165
|
+
"rp",
|
|
166
|
+
"rt",
|
|
167
|
+
"ruby",
|
|
168
|
+
"samp",
|
|
169
|
+
"sub",
|
|
170
|
+
"summary",
|
|
171
|
+
"sup",
|
|
172
|
+
"var"
|
|
173
|
+
] },
|
|
174
|
+
"ol-prefix": { style: "ordered" },
|
|
175
|
+
"strong-style": { style: "asterisk" },
|
|
176
|
+
"table-column-style": { style: TABLE_STYLE },
|
|
177
|
+
"table-pipe-style": { style: "leading_and_trailing" },
|
|
178
|
+
"ul-style": { style: "dash" }
|
|
179
|
+
} }, { overrides: [{
|
|
180
|
+
filter: [
|
|
181
|
+
"**/.github/PULL_REQUEST_TEMPLATE.md",
|
|
182
|
+
"**/.github/ISSUE_TEMPLATE/**",
|
|
183
|
+
"**/profile/README.md",
|
|
184
|
+
"**/AGENTS.md",
|
|
185
|
+
"**/CLAUDE.md"
|
|
186
|
+
],
|
|
187
|
+
config: { "first-line-heading": { allow_preamble: true } }
|
|
188
|
+
}, {
|
|
189
|
+
filter: ["**/README.md"],
|
|
190
|
+
config: { "heading-sentence-case": false }
|
|
191
|
+
}] }];
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region ../src/js/markdownlint/configs/search.ts
|
|
194
|
+
/**
|
|
195
|
+
* @internal @brnshkr/config/markdownlint
|
|
196
|
+
*/
|
|
197
|
+
const RULES = [
|
|
198
|
+
{
|
|
199
|
+
name: "ellipsis",
|
|
200
|
+
message: "Use an ellipsis rather than three dots.",
|
|
201
|
+
searchPattern: String.raw`/(?<!\]\([^)]*)\.\.\./gu`,
|
|
202
|
+
replace: "…",
|
|
203
|
+
searchScope: "text"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "em-dash",
|
|
207
|
+
message: "Use an em dash rather than two hyphens.",
|
|
208
|
+
searchPattern: "/(?<= )--(?= )/gu",
|
|
209
|
+
replace: "—",
|
|
210
|
+
searchScope: "text"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "https",
|
|
214
|
+
message: "Link over `https`.",
|
|
215
|
+
searchPattern: String.raw`/http:\/\/(?!(?:www\.)?w3\.org\/|localhost|127\.0\.0\.1)/gu`,
|
|
216
|
+
replace: "https://",
|
|
217
|
+
searchScope: "text"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "no-non-breaking-space",
|
|
221
|
+
message: "Use a regular space.",
|
|
222
|
+
searchPattern: String.raw`/\u00A0/gu`,
|
|
223
|
+
replace: " ",
|
|
224
|
+
searchScope: "all"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "no-todo-comments",
|
|
228
|
+
message: "Open work belongs in a backlog, not in a comment.",
|
|
229
|
+
searchPattern: String.raw`/\b(?:TODO|FIXME|XXX|HACK)\b/gu`,
|
|
230
|
+
searchScope: "text"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "no-zero-width-characters",
|
|
234
|
+
message: "Remove the zero-width character.",
|
|
235
|
+
searchPattern: String.raw`/[\u200B-\u200D\uFEFF]/gu`,
|
|
236
|
+
replace: "",
|
|
237
|
+
searchScope: "all"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "relative-link-prefix",
|
|
241
|
+
message: "Prefix a relative link with `./`.",
|
|
242
|
+
searchPattern: String.raw`/\]\((?![.#/]|[a-z][a-z0-9+.-]*:)/gu`,
|
|
243
|
+
replace: "](./",
|
|
244
|
+
searchScope: "text"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "scoped-package-names",
|
|
248
|
+
message: "Name an organization package by its scope.",
|
|
249
|
+
searchPattern: String.raw`/(?<![\w/@])brnshkr\/(?=[a-z])/gu`,
|
|
250
|
+
replace: "@brnshkr/",
|
|
251
|
+
searchScope: "text"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "straight-double-quotes",
|
|
255
|
+
message: "Use straight double quotes.",
|
|
256
|
+
searchPattern: "/[“”]/gu",
|
|
257
|
+
replace: "\"",
|
|
258
|
+
searchScope: "text"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "straight-single-quotes",
|
|
262
|
+
message: "Use straight single quotes.",
|
|
263
|
+
searchPattern: "/[‘’]/gu",
|
|
264
|
+
replace: "'",
|
|
265
|
+
searchScope: "text"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "tool-names",
|
|
269
|
+
message: "Spell a tool the way its own project spells it.",
|
|
270
|
+
search: [
|
|
271
|
+
"Javascript",
|
|
272
|
+
"Typescript",
|
|
273
|
+
"Github",
|
|
274
|
+
"Gitlab",
|
|
275
|
+
"Eslint",
|
|
276
|
+
"StyleLint",
|
|
277
|
+
"Markdownlint",
|
|
278
|
+
"Commitlint",
|
|
279
|
+
"Phpstan",
|
|
280
|
+
"PHPstan",
|
|
281
|
+
"Phpunit",
|
|
282
|
+
"PHPunit",
|
|
283
|
+
"VSCode",
|
|
284
|
+
"Vscode",
|
|
285
|
+
"Nodejs"
|
|
286
|
+
],
|
|
287
|
+
replace: [
|
|
288
|
+
"JavaScript",
|
|
289
|
+
"TypeScript",
|
|
290
|
+
"GitHub",
|
|
291
|
+
"GitLab",
|
|
292
|
+
"ESLint",
|
|
293
|
+
"Stylelint",
|
|
294
|
+
"markdownlint",
|
|
295
|
+
"commitlint",
|
|
296
|
+
"PHPStan",
|
|
297
|
+
"PHPStan",
|
|
298
|
+
"PHPUnit",
|
|
299
|
+
"PHPUnit",
|
|
300
|
+
"VS Code",
|
|
301
|
+
"VS Code",
|
|
302
|
+
"Node.js"
|
|
303
|
+
],
|
|
304
|
+
searchScope: "text"
|
|
305
|
+
}
|
|
306
|
+
];
|
|
307
|
+
const search = () => {
|
|
308
|
+
const { requiredAll: [isMarkdownlintRuleSearchReplaceInstalled] } = resolvePackages(MODULES.search);
|
|
309
|
+
if (!isMarkdownlintRuleSearchReplaceInstalled) return [];
|
|
310
|
+
return [{
|
|
311
|
+
customRules: [resolveCustomRule(MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_SEARCH_REPLACE)],
|
|
312
|
+
config: { "search-replace": { rules: RULES } }
|
|
313
|
+
}];
|
|
314
|
+
};
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region ../src/js/markdownlint/configs/style.ts
|
|
317
|
+
/**
|
|
318
|
+
* @internal @brnshkr/config/markdownlint
|
|
319
|
+
*/
|
|
320
|
+
const style = () => {
|
|
321
|
+
const { requiredAll: [isMarkdownlintRulesInstalled] } = resolvePackages(MODULES.style);
|
|
322
|
+
if (!isMarkdownlintRulesInstalled) return [];
|
|
323
|
+
return [{
|
|
324
|
+
customRules: [resolveCustomRule(MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULES)],
|
|
325
|
+
config: {
|
|
326
|
+
"list-item-marker-space": false,
|
|
327
|
+
"fenced-code-fence-length": false,
|
|
328
|
+
"reference-link-section-placement": false,
|
|
329
|
+
"heading-sentence-case": { allowed_words: [
|
|
330
|
+
"Composer",
|
|
331
|
+
"Doctrine",
|
|
332
|
+
"ESLint",
|
|
333
|
+
"Laravel",
|
|
334
|
+
"Makefile",
|
|
335
|
+
"PHPStan",
|
|
336
|
+
"PHPUnit",
|
|
337
|
+
"Pest",
|
|
338
|
+
"Rector",
|
|
339
|
+
"Stylelint",
|
|
340
|
+
"Symfony",
|
|
341
|
+
"Tempest",
|
|
342
|
+
"Twig",
|
|
343
|
+
"Xdebug"
|
|
344
|
+
] }
|
|
345
|
+
}
|
|
346
|
+
}];
|
|
347
|
+
};
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region ../src/js/markdownlint/configs/tables.ts
|
|
350
|
+
/**
|
|
351
|
+
* @internal @brnshkr/config/markdownlint
|
|
352
|
+
*/
|
|
353
|
+
const tables = () => {
|
|
354
|
+
const { requiredAll: [isMarkdownlintRuleTableFormatInstalled] } = resolvePackages(MODULES.tables);
|
|
355
|
+
if (!isMarkdownlintRuleTableFormatInstalled) return [];
|
|
356
|
+
return [{
|
|
357
|
+
customRules: [resolveCustomRule(MARKDOWNLINT_PACKAGES.MARKDOWNLINT_RULE_TABLE_FORMAT)],
|
|
358
|
+
config: { "table-format": { style: TABLE_STYLE } }
|
|
359
|
+
}];
|
|
360
|
+
};
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region ../src/js/markdownlint/configs/index.ts
|
|
363
|
+
/**
|
|
364
|
+
* @internal @brnshkr/config/markdownlint
|
|
365
|
+
*/
|
|
366
|
+
const configs = {
|
|
367
|
+
github,
|
|
368
|
+
ignores,
|
|
369
|
+
links,
|
|
370
|
+
markdown,
|
|
371
|
+
search,
|
|
372
|
+
style,
|
|
373
|
+
tables
|
|
374
|
+
};
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region ../src/js/markdownlint/index.ts
|
|
377
|
+
/**
|
|
378
|
+
* Build the `@brnshkr` markdownlint config object.
|
|
379
|
+
*
|
|
380
|
+
* The result is the shape `markdownlint-cli2` reads rather than the plain rule set, because `ignores` and
|
|
381
|
+
* `globs` exist only at that level — which is why a consumer needs a config file of its own instead of
|
|
382
|
+
* extending a shared rule set.
|
|
383
|
+
*
|
|
384
|
+
* @api
|
|
385
|
+
*
|
|
386
|
+
* @param optionsAndGlobalConfig per-module toggles and global markdownlint-cli2 fields merged with the defaults
|
|
387
|
+
* @param additionalConfigs extra config entries merged after the built-in ones
|
|
388
|
+
*
|
|
389
|
+
* @returns final config ready to be consumed by markdownlint-cli2
|
|
390
|
+
*
|
|
391
|
+
* @see https://github.com/brnshkr/config/blob/master/docs/js/markdownlint.md
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```js
|
|
395
|
+
* import { getConfig } from '@brnshkr/config/markdownlint';
|
|
396
|
+
*
|
|
397
|
+
* getConfig(undefined);
|
|
398
|
+
* getConfig({});
|
|
399
|
+
*
|
|
400
|
+
* getConfig({
|
|
401
|
+
* links: false,
|
|
402
|
+
* ignores: ['CHANGELOG.md'],
|
|
403
|
+
* }, {
|
|
404
|
+
* config: { 'no-bare-urls': false },
|
|
405
|
+
* });
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
const getConfig = (optionsAndGlobalConfig, ...additionalConfigs) => {
|
|
409
|
+
const resolvedOptions = {
|
|
410
|
+
github: isModuleEnabledByDefault(MODULES.github),
|
|
411
|
+
links: isModuleEnabledByDefault(MODULES.links),
|
|
412
|
+
search: isModuleEnabledByDefault(MODULES.search),
|
|
413
|
+
style: isModuleEnabledByDefault(MODULES.style),
|
|
414
|
+
tables: isModuleEnabledByDefault(MODULES.tables),
|
|
415
|
+
...optionsAndGlobalConfig
|
|
416
|
+
};
|
|
417
|
+
setModuleEnabled(MODULES.github, resolvedOptions.github);
|
|
418
|
+
setModuleEnabled(MODULES.links, resolvedOptions.links);
|
|
419
|
+
setModuleEnabled(MODULES.search, resolvedOptions.search);
|
|
420
|
+
setModuleEnabled(MODULES.style, resolvedOptions.style);
|
|
421
|
+
setModuleEnabled(MODULES.tables, resolvedOptions.tables);
|
|
422
|
+
const config = {};
|
|
423
|
+
includeConfigs(config, configs.ignores());
|
|
424
|
+
if (isModuleEnabled(MODULES.github)) includeConfigs(config, configs.github());
|
|
425
|
+
if (isModuleEnabled(MODULES.links)) includeConfigs(config, configs.links());
|
|
426
|
+
if (isModuleEnabled(MODULES.search)) includeConfigs(config, configs.search());
|
|
427
|
+
if (isModuleEnabled(MODULES.style)) includeConfigs(config, configs.style());
|
|
428
|
+
if (isModuleEnabled(MODULES.tables)) includeConfigs(config, configs.tables());
|
|
429
|
+
includeConfigs(config, configs.markdown());
|
|
430
|
+
includeConfigs(config, getUserConfigs(resolvedOptions, additionalConfigs));
|
|
431
|
+
return config;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Default-exported pre-built config for direct re-export from a Markdownlint config file.
|
|
435
|
+
*
|
|
436
|
+
* @api
|
|
437
|
+
*/
|
|
438
|
+
var markdownlint_default = getConfig();
|
|
439
|
+
//#endregion
|
|
440
|
+
export { markdownlint_default as default, getConfig };
|