@brnshkr/config 0.0.1-alpha.10

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.
@@ -0,0 +1,409 @@
1
+ import { a as isModuleEnabledByDefault, b as packageOrganization, d as MODULES, f as PACKAGES, h as setModuleEnabled, i as GLOB_IGNORES, m as resolvePackages, n as MAX_LEN, p as isModuleEnabled, r as QUOTES, s as objectEntries, t as INDENT } from "../shared.mjs";
2
+
3
+ //#region src/js/stylelint/configs/baseline.ts
4
+ const baseline = () => {
5
+ const { requiredAll: [isStylelintPluginUseBaselineInstalled] } = resolvePackages(MODULES.baseline);
6
+ if (!isStylelintPluginUseBaselineInstalled) return [];
7
+ return [{
8
+ plugins: PACKAGES.STYLELINT_PLUGIN_USE_BASELINE,
9
+ rules: { "plugin/use-baseline": true }
10
+ }];
11
+ };
12
+
13
+ //#endregion
14
+ //#region src/js/stylelint/configs/css.ts
15
+ const css = () => [{
16
+ extends: "stylelint-config-standard",
17
+ reportDescriptionlessDisables: true,
18
+ reportInvalidScopeDisables: true,
19
+ reportNeedlessDisables: true,
20
+ reportUnscopedDisables: true,
21
+ rules: {
22
+ "at-rule-disallowed-list": ["debug"],
23
+ "at-rule-property-required-list": { "font-face": [
24
+ "font-display",
25
+ "font-family",
26
+ "font-style",
27
+ "font-weight",
28
+ "src"
29
+ ] },
30
+ "color-hex-length": "long",
31
+ "color-named": "never",
32
+ "color-no-invalid-hex": true,
33
+ "comment-word-disallowed-list": [new RegExp(`^${["TO", "DO"].join("")}`, "v")],
34
+ "declaration-no-important": true,
35
+ "declaration-property-value-disallowed-list": {
36
+ border: ["none"],
37
+ "border-top": ["none"],
38
+ "border-right": ["none"],
39
+ "border-bottom": ["none"],
40
+ "border-left": ["none"]
41
+ },
42
+ "declaration-property-unit-allowed-list": {
43
+ "/^animation/": "ms",
44
+ "/^transition/": "ms",
45
+ "font-size": ["em", "rem"],
46
+ "line-height": []
47
+ },
48
+ "font-family-name-quotes": "always-unless-keyword",
49
+ "font-weight-notation": "numeric",
50
+ "function-linear-gradient-no-nonstandard-direction": true,
51
+ "function-no-unknown": true,
52
+ "function-url-no-scheme-relative": true,
53
+ "function-url-scheme-allowed-list": ["data", "https"],
54
+ "max-nesting-depth": 3,
55
+ "no-unknown-animations": true,
56
+ "no-unknown-custom-media": true,
57
+ "no-unknown-custom-properties": true,
58
+ "selector-class-pattern": ["^[a-z]([-]?[a-z0-9]+)*(__[a-z0-9]([-]?[a-z0-9]+)*)?(--[a-z0-9]([-]?[a-z0-9]+)*)?$", {
59
+ resolveNestedSelectors: true,
60
+ message: (value) => `Expected class selector "${value}" to match BEM methodology (https://getbem.com/). Selector validation tool: https://regexr.com/3apms`
61
+ }],
62
+ "string-no-newline": true,
63
+ "unit-no-unknown": true,
64
+ "value-keyword-case": ["lower", {
65
+ camelCaseSvgKeywords: true,
66
+ ignoreKeywords: [/^geometricPrecision$/v]
67
+ }]
68
+ }
69
+ }];
70
+
71
+ //#endregion
72
+ //#region src/js/stylelint/configs/defensive.ts
73
+ const defensive = () => {
74
+ const { requiredAll: [isStylelintPluginDefensiveCssInstalled] } = resolvePackages(MODULES.defensive);
75
+ if (!isStylelintPluginDefensiveCssInstalled) return [];
76
+ return [{
77
+ plugins: PACKAGES.STYLELINT_PLUGIN_DEFENSIVE_CSS,
78
+ rules: { "plugin/use-defensive-css": [true, {
79
+ "accidental-hover": true,
80
+ "background-repeat": true,
81
+ "flex-wrapping": true,
82
+ "scroll-chaining": true,
83
+ "scrollbar-gutter": true,
84
+ "vendor-prefix-grouping": true
85
+ }] }
86
+ }];
87
+ };
88
+
89
+ //#endregion
90
+ //#region src/js/stylelint/types/overrides.ts
91
+ const OVERRIDES = {
92
+ SCSS: "scss",
93
+ SVELTE: "svelte"
94
+ };
95
+
96
+ //#endregion
97
+ //#region src/js/stylelint/utils/config.ts
98
+ const buildOverrideName = (override) => [packageOrganization, override].filter(Boolean).join("/");
99
+ const isValidGlobalAdditionalConfigKey = (key) => [
100
+ "extends",
101
+ "plugins",
102
+ "pluginFunctions",
103
+ "ignoreFiles",
104
+ "rules",
105
+ "quiet",
106
+ "formatter",
107
+ "defaultSeverity",
108
+ "ignoreDisables",
109
+ "reportNeedlessDisables",
110
+ "reportInvalidScopeDisables",
111
+ "reportDescriptionlessDisables",
112
+ "reportUnscopedDisables",
113
+ "configurationComment",
114
+ "overrides",
115
+ "customSyntax",
116
+ "processors",
117
+ "languageOptions",
118
+ "allowEmptyInput",
119
+ "cache",
120
+ "fix",
121
+ "computeEditInfo",
122
+ "validate"
123
+ ].includes(key);
124
+ const getGlobalAdditionalConfig = (options) => {
125
+ const config = {};
126
+ for (const [key, value] of objectEntries(options)) if (isValidGlobalAdditionalConfigKey(key)) config[key] = value;
127
+ if (Object.keys(config).length === 0) return;
128
+ return config;
129
+ };
130
+ const getUserConfigs = (resolvedOptions, additionalConfigs) => [getGlobalAdditionalConfig(resolvedOptions), ...additionalConfigs].filter(Boolean);
131
+ const includeConfigs = (config, configsToInclude) => {
132
+ for (const configToInclude of configsToInclude) {
133
+ if (configToInclude.extends !== void 0) config.extends = [...new Set([...Array.isArray(config.extends) ? config.extends ?? [] : [config.extends].filter(Boolean), ...Array.isArray(configToInclude.extends) ? configToInclude.extends ?? [] : [configToInclude.extends].filter(Boolean)])];
134
+ if (configToInclude.plugins !== void 0) config.plugins = [...new Set([...Array.isArray(config.plugins) ? config.plugins ?? [] : [config.plugins].filter(Boolean), ...Array.isArray(configToInclude.plugins) ? configToInclude.plugins ?? [] : [configToInclude.plugins].filter(Boolean)])];
135
+ if (configToInclude.pluginFunctions !== void 0) config.pluginFunctions = {
136
+ ...config.pluginFunctions,
137
+ ...configToInclude.pluginFunctions
138
+ };
139
+ if (configToInclude.ignoreFiles !== void 0) config.ignoreFiles = [...new Set([...Array.isArray(config.ignoreFiles) ? config.ignoreFiles ?? [] : [config.ignoreFiles].filter(Boolean), ...Array.isArray(configToInclude.ignoreFiles) ? configToInclude.ignoreFiles ?? [] : [configToInclude.ignoreFiles].filter(Boolean)])];
140
+ if (configToInclude.rules !== void 0) config.rules = {
141
+ ...config.rules,
142
+ ...configToInclude.rules
143
+ };
144
+ if (configToInclude.quiet !== void 0) config.quiet = configToInclude.quiet;
145
+ if (configToInclude.formatter !== void 0) config.formatter = configToInclude.formatter;
146
+ if (configToInclude.defaultSeverity !== void 0) config.defaultSeverity = configToInclude.defaultSeverity;
147
+ if (configToInclude.ignoreDisables !== void 0) config.ignoreDisables = configToInclude.ignoreDisables;
148
+ if (configToInclude.reportNeedlessDisables !== void 0) config.reportNeedlessDisables = configToInclude.reportNeedlessDisables;
149
+ if (configToInclude.reportInvalidScopeDisables !== void 0) config.reportInvalidScopeDisables = configToInclude.reportInvalidScopeDisables;
150
+ if (configToInclude.reportDescriptionlessDisables !== void 0) config.reportDescriptionlessDisables = configToInclude.reportDescriptionlessDisables;
151
+ if (configToInclude.reportUnscopedDisables !== void 0) config.reportUnscopedDisables = configToInclude.reportUnscopedDisables;
152
+ if (configToInclude.configurationComment !== void 0) config.configurationComment = configToInclude.configurationComment;
153
+ if (configToInclude.overrides !== void 0) {
154
+ const overridesToIncude = configToInclude.overrides;
155
+ config.overrides = [...(config.overrides ?? []).filter((existingOverride) => !overridesToIncude.some((overrideToIncude) => overrideToIncude.name !== void 0 && overrideToIncude.name === existingOverride.name)), ...overridesToIncude];
156
+ }
157
+ if (configToInclude.customSyntax !== void 0) config.customSyntax = configToInclude.customSyntax;
158
+ if (configToInclude.processors !== void 0) config.processors = [...new Set([...config.processors ?? [], ...configToInclude.processors])];
159
+ if (configToInclude.languageOptions !== void 0) config.languageOptions = {
160
+ ...config.languageOptions,
161
+ ...configToInclude.languageOptions,
162
+ syntax: {
163
+ atRules: {
164
+ ...config.languageOptions?.syntax?.atRules,
165
+ ...configToInclude.languageOptions.syntax?.atRules
166
+ },
167
+ cssWideKeywords: [...new Set([...config.languageOptions?.syntax?.cssWideKeywords ?? [], ...configToInclude.languageOptions.syntax?.cssWideKeywords ?? []])],
168
+ properties: {
169
+ ...config.languageOptions?.syntax?.properties,
170
+ ...configToInclude.languageOptions.syntax?.properties
171
+ },
172
+ types: {
173
+ ...config.languageOptions?.syntax?.types,
174
+ ...configToInclude.languageOptions.syntax?.types
175
+ }
176
+ }
177
+ };
178
+ if (configToInclude.allowEmptyInput !== void 0) config.allowEmptyInput = configToInclude.allowEmptyInput;
179
+ if (configToInclude.cache !== void 0) config.cache = configToInclude.cache;
180
+ if (configToInclude.fix !== void 0) config.fix = configToInclude.fix;
181
+ if (configToInclude.computeEditInfo !== void 0) config.computeEditInfo = configToInclude.computeEditInfo;
182
+ if (configToInclude.validate !== void 0) config.validate = configToInclude.validate;
183
+ }
184
+ };
185
+
186
+ //#endregion
187
+ //#region src/js/stylelint/configs/html.ts
188
+ const html = () => {
189
+ const { requiredAll: [isPostcssHtmlInstalled, isStylelintConfigHtmlInstalled] } = resolvePackages(MODULES.html);
190
+ if (!isPostcssHtmlInstalled || !isStylelintConfigHtmlInstalled) return [];
191
+ return [{
192
+ extends: PACKAGES.STYLELINT_CONFIG_HTML,
193
+ overrides: [{
194
+ name: buildOverrideName(OVERRIDES.SVELTE),
195
+ files: ["**/*.svelte"],
196
+ rules: {
197
+ "keyframes-name-pattern": ["^(-global-)?([a-z][a-z0-9]*)(-[a-z0-9]+)*$", { message: (name) => `Expected keyframe name "${name}" to be kebab-case` }],
198
+ "selector-pseudo-class-no-unknown": [true, { ignorePseudoClasses: ["global"] }]
199
+ }
200
+ }]
201
+ }];
202
+ };
203
+
204
+ //#endregion
205
+ //#region src/js/stylelint/configs/ignores.ts
206
+ const ignores = () => [{ ignoreFiles: GLOB_IGNORES.map((glob) => glob.replace(/^\*\*/v, process.cwd())) }];
207
+
208
+ //#endregion
209
+ //#region src/js/stylelint/configs/logical.ts
210
+ const logical = () => {
211
+ const { requiredAll: [isStylelintPluginLogicalCssInstalled] } = resolvePackages(MODULES.logical);
212
+ if (!isStylelintPluginLogicalCssInstalled) return [];
213
+ return [{
214
+ plugins: PACKAGES.STYLELINT_PLUGIN_LOGICAL_CSS,
215
+ rules: {
216
+ "plugin/use-logical-properties-and-values": true,
217
+ "plugin/use-logical-units": true
218
+ }
219
+ }];
220
+ };
221
+
222
+ //#endregion
223
+ //#region src/js/stylelint/configs/modules.ts
224
+ const modules = () => {
225
+ const { requiredAll: [isStylelintConfigCssModulesInstalled] } = resolvePackages(MODULES.modules);
226
+ if (!isStylelintConfigCssModulesInstalled) return [];
227
+ return [{ extends: PACKAGES.STYLELINT_CONFIG_CSS_MODULES }];
228
+ };
229
+
230
+ //#endregion
231
+ //#region src/js/stylelint/configs/nesting.ts
232
+ const nesting = () => {
233
+ const { requiredAll: [isStylelintUseNestingInstalled] } = resolvePackages(MODULES.nesting);
234
+ if (!isStylelintUseNestingInstalled) return [];
235
+ return [{
236
+ plugins: PACKAGES.STYLELINT_USE_NESTING,
237
+ rules: { "csstools/use-nesting": ["always", { syntax: isModuleEnabled(MODULES.scss) ? "scss" : "css" }] }
238
+ }];
239
+ };
240
+
241
+ //#endregion
242
+ //#region src/js/stylelint/configs/order.ts
243
+ const order = () => {
244
+ const { requiredAll: [isStylelintConfigRecessOrderInstalled] } = resolvePackages(MODULES.order);
245
+ if (!isStylelintConfigRecessOrderInstalled) return [];
246
+ return [{ extends: PACKAGES.STYLELINT_CONFIG_RECESS_ORDER }];
247
+ };
248
+
249
+ //#endregion
250
+ //#region src/js/stylelint/configs/scss.ts
251
+ const scss = () => {
252
+ const { requiredAll: [isStylelintConfigStandardScssInstalled], optional: [isStylelintPluginUseBaselineInstalled] } = resolvePackages(MODULES.scss);
253
+ if (!isStylelintConfigStandardScssInstalled) return [];
254
+ return [{
255
+ extends: PACKAGES.STYLELINT_CONFIG_STANDARD_SCSS,
256
+ rules: {
257
+ "scss/at-each-key-value-single-line": true,
258
+ "scss/at-mixin-argumentless-call-parentheses": "always",
259
+ "scss/at-mixin-no-risky-nesting-selector": true,
260
+ "scss/at-root-no-redundant": true,
261
+ "scss/at-use-no-redundant-alias": true,
262
+ "scss/block-no-redundant-nesting": true,
263
+ "scss/declaration-nested-properties": "never",
264
+ "scss/dimension-no-non-numeric-values": true,
265
+ "scss/dollar-variable-first-in-block": [true, {
266
+ ignore: ["comments", "imports"],
267
+ except: [
268
+ "function",
269
+ "mixin",
270
+ "if-else",
271
+ "loops"
272
+ ]
273
+ }],
274
+ "scss/dollar-variable-no-namespaced-assignment": true,
275
+ "scss/double-slash-comment-inline": "never",
276
+ "scss/function-color-channel": true,
277
+ "scss/function-color-relative": true,
278
+ "scss/map-keys-quotes": "always",
279
+ "scss/no-duplicate-dollar-variables": [true, {
280
+ ignoreInsideAtRules: ["if", "mixin"],
281
+ ignoreDefaults: false
282
+ }],
283
+ "scss/no-duplicate-load-rules": true,
284
+ "scss/no-unused-private-members": true,
285
+ "scss/partial-no-import": true,
286
+ "scss/at-import-partial-extension-disallowed-list": ["scss"],
287
+ "property-no-unknown": null,
288
+ "scss/property-no-unknown": true,
289
+ "scss/selector-no-redundant-nesting-selector": true
290
+ },
291
+ overrides: [{
292
+ name: buildOverrideName(OVERRIDES.SCSS),
293
+ files: ["**/*.scss"],
294
+ rules: {
295
+ "scss/comment-no-loud": true,
296
+ ...isStylelintPluginUseBaselineInstalled ? { "plugin/use-baseline": [true, { ignoreAtRules: ["function"] }] } : void 0
297
+ }
298
+ }]
299
+ }];
300
+ };
301
+
302
+ //#endregion
303
+ //#region src/js/stylelint/configs/strict.ts
304
+ const strict = () => {
305
+ const { requiredAll: [isStylelintDeclarationStrictValueInstalled] } = resolvePackages(MODULES.strict);
306
+ if (!isStylelintDeclarationStrictValueInstalled) return [];
307
+ return [{
308
+ plugins: PACKAGES.STYLELINT_DECLARATION_STRICT_VALUE,
309
+ rules: { "scale-unlimited/declaration-strict-value": [
310
+ "/color$/",
311
+ "font-size",
312
+ "z-index"
313
+ ] }
314
+ }];
315
+ };
316
+
317
+ //#endregion
318
+ //#region src/js/stylelint/configs/style.ts
319
+ const style = () => {
320
+ const { requiredAll: [isStylisticStylelintConfigInstalled] } = resolvePackages(MODULES.style);
321
+ if (!isStylisticStylelintConfigInstalled) return [];
322
+ return [{
323
+ extends: PACKAGES.STYLISTIC_STYLELINT_CONFIG,
324
+ rules: {
325
+ "@stylistic/at-rule-name-newline-after": "always-multi-line",
326
+ "@stylistic/at-rule-semicolon-space-before": "never",
327
+ "@stylistic/block-closing-brace-newline-before": "always",
328
+ "@stylistic/block-opening-brace-newline-after": "always",
329
+ "@stylistic/declaration-block-semicolon-newline-after": "always",
330
+ "@stylistic/function-comma-newline-before": "never-multi-line",
331
+ "@stylistic/function-comma-space-before": "never-single-line",
332
+ "@stylistic/indentation": INDENT,
333
+ "@stylistic/linebreaks": "unix",
334
+ "@stylistic/max-line-length": MAX_LEN,
335
+ "@stylistic/media-query-list-comma-newline-after": "always",
336
+ "@stylistic/media-query-list-comma-newline-before": "never-multi-line",
337
+ "@stylistic/named-grid-areas-alignment": [true, { alignQuotes: true }],
338
+ "@stylistic/selector-list-comma-newline-before": "never-multi-line",
339
+ "@stylistic/string-quotes": QUOTES,
340
+ "@stylistic/unicode-bom": "never",
341
+ "@stylistic/value-list-comma-newline-before": "never-multi-line",
342
+ "@stylistic/value-list-comma-space-before": "never-single-line"
343
+ }
344
+ }];
345
+ };
346
+
347
+ //#endregion
348
+ //#region src/js/stylelint/configs/index.ts
349
+ const configs = {
350
+ baseline,
351
+ css,
352
+ defensive,
353
+ html,
354
+ ignores,
355
+ logical,
356
+ modules,
357
+ nesting,
358
+ order,
359
+ scss,
360
+ strict,
361
+ style
362
+ };
363
+
364
+ //#endregion
365
+ //#region src/js/stylelint/index.ts
366
+ const getConfig = (optionsAndGlobalConfig, ...additionalConfigs) => {
367
+ const resolvedOptions = {
368
+ baseline: isModuleEnabledByDefault(MODULES.baseline),
369
+ defensive: isModuleEnabledByDefault(MODULES.defensive),
370
+ html: isModuleEnabledByDefault(MODULES.html),
371
+ logical: isModuleEnabledByDefault(MODULES.logical),
372
+ modules: isModuleEnabledByDefault(MODULES.modules),
373
+ nesting: isModuleEnabledByDefault(MODULES.nesting),
374
+ order: isModuleEnabledByDefault(MODULES.order),
375
+ scss: isModuleEnabledByDefault(MODULES.scss),
376
+ strict: isModuleEnabledByDefault(MODULES.strict),
377
+ style: isModuleEnabledByDefault(MODULES.style),
378
+ ...optionsAndGlobalConfig
379
+ };
380
+ setModuleEnabled(MODULES.baseline, resolvedOptions.baseline);
381
+ setModuleEnabled(MODULES.defensive, resolvedOptions.defensive);
382
+ setModuleEnabled(MODULES.html, resolvedOptions.html);
383
+ setModuleEnabled(MODULES.logical, resolvedOptions.logical);
384
+ setModuleEnabled(MODULES.modules, resolvedOptions.modules);
385
+ setModuleEnabled(MODULES.nesting, resolvedOptions.nesting);
386
+ setModuleEnabled(MODULES.order, resolvedOptions.order);
387
+ setModuleEnabled(MODULES.scss, resolvedOptions.scss);
388
+ setModuleEnabled(MODULES.strict, resolvedOptions.strict);
389
+ setModuleEnabled(MODULES.style, resolvedOptions.style);
390
+ const config = {};
391
+ includeConfigs(config, configs.ignores());
392
+ includeConfigs(config, configs.css());
393
+ if (isModuleEnabled(MODULES.baseline)) includeConfigs(config, configs.baseline());
394
+ if (isModuleEnabled(MODULES.defensive)) includeConfigs(config, configs.defensive());
395
+ if (isModuleEnabled(MODULES.logical)) includeConfigs(config, configs.logical());
396
+ if (isModuleEnabled(MODULES.nesting)) includeConfigs(config, configs.nesting());
397
+ if (isModuleEnabled(MODULES.order)) includeConfigs(config, configs.order());
398
+ if (isModuleEnabled(MODULES.scss)) includeConfigs(config, configs.scss());
399
+ if (isModuleEnabled(MODULES.html)) includeConfigs(config, configs.html());
400
+ if (isModuleEnabled(MODULES.modules)) includeConfigs(config, configs.modules());
401
+ if (isModuleEnabled(MODULES.strict)) includeConfigs(config, configs.strict());
402
+ if (isModuleEnabled(MODULES.style)) includeConfigs(config, configs.style());
403
+ includeConfigs(config, getUserConfigs(resolvedOptions, additionalConfigs));
404
+ return config;
405
+ };
406
+ var stylelint_default = getConfig();
407
+
408
+ //#endregion
409
+ export { stylelint_default as default, getConfig };