@culur/config-stylelint 0.0.0-dev-20240527064403

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +122 -0
  3. package/dist/index.cjs +190 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +5 -0
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.js +188 -0
  8. package/dist/index.js.map +1 -0
  9. package/package.json +100 -0
  10. package/src/__tests__/dedent.ts +5 -0
  11. package/src/__tests__/index.ts +5 -0
  12. package/src/__tests__/mock.ts +36 -0
  13. package/src/__tests__/syntax.ts +11 -0
  14. package/src/__tests__/test-lint-and-fix.ts +55 -0
  15. package/src/__tests__/test-rule-or-config-value.ts +68 -0
  16. package/src/configs/css.test.ts +10 -0
  17. package/src/configs/css.ts +16 -0
  18. package/src/configs/scss.test.ts +9 -0
  19. package/src/configs/scss.ts +11 -0
  20. package/src/configs/shared.test.ts +9 -0
  21. package/src/configs/shared.ts +5 -0
  22. package/src/configs/vue.test.ts +18 -0
  23. package/src/configs/vue.ts +10 -0
  24. package/src/factory.test.ts +15 -0
  25. package/src/factory.ts +23 -0
  26. package/src/index.test.ts +9 -0
  27. package/src/index.ts +3 -0
  28. package/src/rules/at-rule-no-unknown.test.ts +43 -0
  29. package/src/rules/at-rule-no-unknown.ts +33 -0
  30. package/src/rules/declaration-block-no-redundant-longhand-properties.test.ts +38 -0
  31. package/src/rules/declaration-block-no-redundant-longhand-properties.ts +11 -0
  32. package/src/rules/dollar-variable-pattern.test.ts +27 -0
  33. package/src/rules/dollar-variable-pattern.ts +18 -0
  34. package/src/rules/function-no-unknown.test.ts +39 -0
  35. package/src/rules/function-no-unknown.ts +35 -0
  36. package/src/rules/order.test.ts +46 -0
  37. package/src/rules/order.ts +108 -0
  38. package/src/utils/index.ts +1 -0
  39. package/src/utils/utils.test.ts +46 -0
  40. package/src/utils/utils.ts +44 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # @culur/config-stylelint
2
+
3
+ ## 0.0.0-dev-20240527064403
4
+
5
+ ### Patch Changes
6
+
7
+ - [#18](https://github.com/culur/culur/pull/18) [`622888f`](https://github.com/culur/culur/commit/622888fa6d4a31ac275b435a74c29cd0b986f974) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update dependencies version
8
+
9
+ - Updated dependencies [[`622888f`](https://github.com/culur/culur/commit/622888fa6d4a31ac275b435a74c29cd0b986f974)]:
10
+ - @culur/utils-packages@0.0.0-dev-20240527064403
11
+
12
+ ## 1.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [`a83892c`](https://github.com/culur/culur/commit/a83892c01bc3a49cd21b79a1abd5443147fff0c4) Thanks [@phamhongphuc](https://github.com/phamhongphuc)! - First release
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`e3492d2`](https://github.com/culur/culur/commit/e3492d20a29bee15bbabab0a60277ed36944cd7a)]:
21
+ - @culur/utils-packages@1.0.0
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # `@culur/config-stylelint`
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@culur/config-stylelint?logo=npm)](https://www.npmjs.com/package/@culur/config-stylelint)
4
+ [![NPM Download](https://img.shields.io/npm/dm/@culur/config-stylelint?logo=npm)](https://www.npmjs.com/package/@culur/config-stylelint)
5
+ [![NPM License](https://img.shields.io/npm/l/@culur/config-stylelint)](../../LICENSE)
6
+
7
+ [![CodeFactor](https://www.codefactor.io/repository/github/culur/culur/badge)](https://www.codefactor.io/repository/github/culur/culur)
8
+ [![Codecov](https://img.shields.io/codecov/c/github/culur/culur)](https://app.codecov.io/gh/culur/culur)
9
+ [![Build and release](https://github.com/culur/culur/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/culur/culur/actions/workflows/build-and-release.yml)
10
+
11
+ > Sharing [Stylelint](https://stylelint.io) configurations.
12
+
13
+ ## 💿 Installation
14
+
15
+ Add `@culur/config-stylelint` dependency to your project.
16
+
17
+ ```bash
18
+ # Using npm
19
+ npm install @culur/config-stylelint --save-dev
20
+
21
+ # Using yarn
22
+ yarn add @culur/config-stylelint --dev
23
+ ```
24
+
25
+ Other packages:
26
+
27
+ - Use need to install `stylelint` package in devDependencies.
28
+
29
+ ## 📖 Usage
30
+
31
+ ### 1. Extending config
32
+
33
+ Set your `.stylelintrc.json` to:
34
+
35
+ ```json
36
+ {
37
+ "extends": ["@culur/config-stylelint"]
38
+ }
39
+ ```
40
+
41
+ You can also define which environments are enabled via the `defineConfig` function.
42
+
43
+ ```js
44
+ // .stylelintrc.mjs
45
+ import { defineConfig } from '@culur/config-stylelint/factory';
46
+
47
+ export default defineConfig(
48
+ {
49
+ tailwind: true,
50
+ sass: false,
51
+ vue: false,
52
+ },
53
+ {
54
+ extends: [],
55
+ plugins: [],
56
+ rules: {},
57
+ },
58
+ );
59
+ ```
60
+
61
+ ### 2. Ignoring Code
62
+
63
+ `Stylelint` use `.stylelintignore` file to ignore specific files. You can use the following command to copy our default `.stylelintignore` to your project root folder:
64
+
65
+ ```bash
66
+ # unix
67
+ cp "node_modules\@culur\config-stylelint\.stylelintignore" ".stylelintignore"
68
+
69
+ # windows
70
+ copy "node_modules\@culur\config-stylelint\.stylelintignore" ".stylelintignore"
71
+ ```
72
+
73
+ ## 📜 Scripts
74
+
75
+ Some commonly used scripts in `package.json`.
76
+
77
+ ```json
78
+ {
79
+ "scripts": {
80
+ "fix:css": "stylelint '**/*.{vue,tsx,css,scss}' --allow-empty-input --fix",
81
+ "lint:css": "stylelint '**/*.{vue,tsx,css,scss}' --allow-empty-input"
82
+ }
83
+ }
84
+ ```
85
+
86
+ ## ✨ Features
87
+
88
+ **The** library is a shareable Stylelint configuration. It has some key features as follows:
89
+
90
+ ### Auto detect environment
91
+
92
+ The config will check whether the following packages are installed or not to change plugins and rules.
93
+
94
+ | Environment | Packages |
95
+ | ----------- | ------------------------------------ |
96
+ | Tailwind | `tailwindcss` |
97
+ | SCSS | `sass` or `dart-sass` or `node-sass` |
98
+ | Vue | `vue` |
99
+
100
+ ### Extends
101
+
102
+ - The config extends:
103
+ - Configs from:
104
+ - [`stylelint-config-standard`](https://github.com/stylelint/stylelint-config-standard) - The standard shareable config for Stylelint.
105
+ - [`stylelint-config-standard-scss`](https://github.com/stylelint-scss/stylelint-config-standard-scss) - The standard shareable SCSS config for Stylelint.
106
+ - [`stylelint-config-standard-vue`](https://github.com/ota-meshi/stylelint-config-standard-vue) - The recommended shareable Vue config for Stylelint.
107
+ - [`stylelint-config-html`](https://github.com/ota-meshi/stylelint-config-html) - The shareable HTML config for Stylelint.
108
+ - [`stylelint-config-clean-order`](https://github.com/kutsan/stylelint-config-clean-order) - A clean and complete config for stylelint-order.
109
+ - Plugins from:
110
+ - [`stylelint-order`](https://github.com/hudochenkov/stylelint-order) - A plugin pack of order related linting rules for stylelint.
111
+ - [`stylelint-scss`](https://github.com/kristerkari/stylelint-scss) - A collection of SCSS specific linting rules for stylelint.
112
+ - [`stylelint-selector-bem-pattern`](https://github.com/simonsmith/stylelint-selector-bem-pattern) - Stylelint plugin that incorporates postcss-bem-linter
113
+ - And it also has custom rules for `Tailwind`, `SCSS` and `Vue`.
114
+ - This config bundles the above packages, you don't need to install them yourself.
115
+
116
+ ## 🗃️ Changelog
117
+
118
+ See [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
119
+
120
+ ## 🔒 License
121
+
122
+ See [LICENSE](../../LICENSE) for license rights and limitations (MIT).
package/dist/index.cjs ADDED
@@ -0,0 +1,190 @@
1
+ 'use strict';
2
+
3
+ var utilsPackages = require('@culur/utils-packages');
4
+
5
+ // src/factory.ts
6
+
7
+ // src/utils/utils.ts
8
+ var defineRule = (rule) => rule;
9
+ var defineRules = (rule) => rule;
10
+ var mergeConfigs = (...configsOrNull) => {
11
+ const configs = configsOrNull.filter((c) => !!c);
12
+ return {
13
+ plugins: [...new Set(configs.flatMap((c) => c.plugins ?? []))],
14
+ overrides: [...new Set(configs.flatMap((c) => c.overrides ?? []))],
15
+ extends: configs.flatMap((c) => c.extends ?? []).filter((item, index, arr) => arr.lastIndexOf(item) === index),
16
+ rules: configs.reduce(
17
+ (acc, config) => ({ ...acc, ...config.rules }),
18
+ {}
19
+ ),
20
+ ...configs.reduce(
21
+ (acc, { plugins: _p, overrides: _o, extends: _e, rules: _r, ...config }) => ({ ...acc, ...config }),
22
+ {}
23
+ )
24
+ };
25
+ };
26
+
27
+ // src/rules/at-rule-no-unknown.ts
28
+ var directives = [
29
+ "tailwind",
30
+ "layer",
31
+ "apply",
32
+ "config",
33
+ // https://v2.tailwindcss.com/docs/functions-and-directives
34
+ // backwards compatible for v2
35
+ "variants",
36
+ "responsive",
37
+ "screen"
38
+ ];
39
+ var atRuleNoUnknownRule = () => defineRule([
40
+ true,
41
+ { ignoreAtRules: utilsPackages.hasTailwind() ? directives : [] }
42
+ ]);
43
+ var atRuleNoUnknownCSS = () => defineRules({
44
+ "at-rule-no-unknown": atRuleNoUnknownRule()
45
+ });
46
+ var atRuleNoUnknownSCSS = () => defineRules({
47
+ "at-rule-no-unknown": null,
48
+ "scss/at-rule-no-unknown": atRuleNoUnknownRule()
49
+ });
50
+
51
+ // src/rules/declaration-block-no-redundant-longhand-properties.ts
52
+ var declarationBlockNoRedundantLonghandPropertiesRule = defineRule([true, { ignoreShorthands: ["grid-template"] }]);
53
+ var declarationBlockNoRedundantLonghandProperties = defineRules({
54
+ "declaration-block-no-redundant-longhand-properties": declarationBlockNoRedundantLonghandPropertiesRule
55
+ });
56
+ var functionNoUnknownRule = () => {
57
+ const ignoreFunctions = [
58
+ // https://tailwindcss.com/docs/functions-and-directives#functions
59
+ ...utilsPackages.hasTailwind() ? ["theme", "screen"] : [],
60
+ // https://sass-lang.com/documentation/modules/list
61
+ // https://sass-lang.com/documentation/modules/math
62
+ // https://sass-lang.com/documentation/modules/color
63
+ ...utilsPackages.hasSass() ? [/^(list|math|color)\..+/] : [],
64
+ // https://vuejs.org/api/sfc-css-features.html#v-bind-in-css
65
+ ...utilsPackages.hasVue() ? ["v-bind"] : []
66
+ ];
67
+ return defineRule([
68
+ true,
69
+ ignoreFunctions.length > 0 ? { ignoreFunctions } : { ignoreFunctions: void 0 }
70
+ ]);
71
+ };
72
+ var functionNoUnknown = () => defineRules({
73
+ "function-no-unknown": functionNoUnknownRule()
74
+ });
75
+ var atRuleScssImport = [
76
+ { type: "at-rule", name: "use" },
77
+ { type: "at-rule", name: "forward" },
78
+ { type: "at-rule", name: "import" }
79
+ ];
80
+ var atRuleScss = [
81
+ { type: "at-rule", name: "function" },
82
+ { type: "at-rule", name: "mixin" },
83
+ { type: "at-rule", name: "extend" },
84
+ { type: "at-rule", name: "include" },
85
+ { type: "at-rule", name: "at-root" }
86
+ ];
87
+ var variables = [
88
+ "dollar-variables",
89
+ // $variable
90
+ "at-variables",
91
+ // @variable
92
+ "custom-properties"
93
+ // --property: 10px
94
+ ];
95
+ var atRuleTailwind = [
96
+ { type: "at-rule", name: "tailwind" },
97
+ { type: "at-rule", name: "layer" },
98
+ { type: "at-rule", name: "apply" },
99
+ { type: "at-rule", name: "config" }
100
+ ];
101
+ var atRuleTailwindV2 = [
102
+ { type: "at-rule", name: "variants" },
103
+ { type: "at-rule", name: "responsive" },
104
+ { type: "at-rule", name: "screen" }
105
+ ];
106
+ var rules = [
107
+ {
108
+ type: "rule",
109
+ selector: /^&::[\w-]+/
110
+ },
111
+ "rules"
112
+ ];
113
+ var orderRule = () => defineRule([
114
+ [
115
+ ...utilsPackages.hasSass() ? atRuleScssImport : [],
116
+ ...utilsPackages.hasTailwind() ? atRuleTailwind : [],
117
+ ...variables,
118
+ ...utilsPackages.hasSass() ? atRuleScss : [],
119
+ ...utilsPackages.hasTailwind() ? atRuleTailwindV2 : [],
120
+ "at-rules",
121
+ "less-mixins",
122
+ "declarations",
123
+ ...rules
124
+ ],
125
+ {
126
+ unspecified: "bottom"
127
+ }
128
+ ]);
129
+ var order = () => defineRules({
130
+ "order/order": orderRule()
131
+ });
132
+
133
+ // src/configs/css.ts
134
+ var configCss = () => ({
135
+ extends: ["stylelint-config-standard", "stylelint-config-clean-order"],
136
+ plugins: ["stylelint-order", "stylelint-selector-bem-pattern"],
137
+ rules: {
138
+ ...atRuleNoUnknownCSS(),
139
+ ...declarationBlockNoRedundantLonghandProperties,
140
+ ...functionNoUnknown(),
141
+ ...order()
142
+ }
143
+ });
144
+
145
+ // src/rules/dollar-variable-pattern.ts
146
+ var dollarVariablePatternRule = defineRule([
147
+ "^(-{0,2}?[a-z][a-z0-9]*)(-[a-z0-9]+)*$",
148
+ { message: "Expected variable to be kebab-case" }
149
+ ]);
150
+ var dollarVariablePatternSCSS = defineRules({
151
+ "scss/dollar-variable-pattern": dollarVariablePatternRule
152
+ });
153
+
154
+ // src/configs/scss.ts
155
+ var configScss = () => ({
156
+ extends: ["stylelint-config-standard-scss"],
157
+ rules: {
158
+ ...atRuleNoUnknownSCSS(),
159
+ ...dollarVariablePatternSCSS
160
+ }
161
+ });
162
+
163
+ // src/configs/shared.ts
164
+ var configShared = () => ({
165
+ extends: ["stylelint-config-html"]
166
+ });
167
+ var configVue = () => ({
168
+ extends: [
169
+ utilsPackages.hasSass() ? "stylelint-config-standard-vue/scss" : "stylelint-config-standard-vue"
170
+ ]
171
+ });
172
+
173
+ // src/factory.ts
174
+ function defineConfig(options, config) {
175
+ utilsPackages.updateDefaultPackages(options);
176
+ return mergeConfigs(
177
+ configShared(),
178
+ configCss(),
179
+ utilsPackages.hasSass() && configScss(),
180
+ utilsPackages.hasVue() && configVue(),
181
+ config
182
+ );
183
+ }
184
+
185
+ // src/index.ts
186
+ var src_default = defineConfig();
187
+
188
+ module.exports = src_default;
189
+ //# sourceMappingURL=out.js.map
190
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/factory.ts","../src/rules/at-rule-no-unknown.ts","../src/utils/utils.ts","../src/rules/declaration-block-no-redundant-longhand-properties.ts","../src/rules/function-no-unknown.ts","../src/rules/order.ts","../src/configs/css.ts","../src/rules/dollar-variable-pattern.ts","../src/configs/scss.ts","../src/configs/shared.ts","../src/configs/vue.ts","../src/index.ts"],"names":["hasSass","hasVue","hasTailwind"],"mappings":";AACA,SAAS,WAAAA,UAAS,UAAAC,SAAQ,6BAA6B;;;ACDvD,SAAS,mBAAmB;;;ACSrB,IAAM,aAAa,CAIxB,SACG;AAEE,IAAM,cAAc,CAAiC,SAC1D;AAGK,IAAM,eAAe,IACvB,kBACA;AACH,QAAM,UAAU,cAAc,OAAO,CAAC,MAAmB,CAAC,CAAC,CAAC;AAE5D,SAAO;AAAA,IACL,SAAS,CAAC,GAAG,IAAI,IAAI,QAAQ,QAAQ,OAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AAAA,IAC3D,WAAW,CAAC,GAAG,IAAI,IAAI,QAAQ,QAAQ,OAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA,IAC/D,SAAS,QACN,QAAQ,OAAK,EAAE,WAAW,CAAC,CAAC,EAC5B,OAAO,CAAC,MAAM,OAAO,QAAQ,IAAI,YAAY,IAAI,MAAM,KAAK;AAAA,IAC/D,OAAO,QAAQ;AAAA,MACb,CAAC,KAAK,YAAY,EAAE,GAAG,KAAK,GAAG,OAAO,MAAM;AAAA,MAC5C,CAAC;AAAA,IACH;AAAA,IACA,GAAG,QAAQ;AAAA,MACT,CACE,KACA,EAAE,SAAS,IAAI,WAAW,IAAI,SAAS,IAAI,OAAO,IAAI,GAAG,OAAO,OAC5D,EAAE,GAAG,KAAK,GAAG,OAAO;AAAA,MAC1B,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;ADvCA,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,sBAAsB,MACjC,WAA4D;AAAA,EAC1D;AAAA,EACA,EAAE,eAAe,YAAY,IA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;;ACRO,IAAM,4BAA4B,WAGvC;AAAA,EACA;AAAA,EACA,EAAE,SAAS,qCAAqC;AAClD,CAAC;AAEM,IAAM,4BAA4B,YAAY;AAAA,EACnD,gCAAgC;AAClC,CAAC;;;ACbM,IAAM,aAAa,OAAe;AAAA,EACvC,SAAS,CAAC,gCAAgC;AAAA,EAC1C,OAAO;AAAA,IACL,GAAG,oBAAoB;AAAA,IACvB,GAAG;AAAA,EACL;AACF;;;ACRO,IAAM,eAAe,OAAe;AAAA,EACzC,SAAS,CAAC,uBAAuB;AACnC;;;ACJA,SAAS,WAAAF,gBAAe;AAGjB,IAAM,YAAY,OAAe;AAAA,EACtC,SAAS;AAAA,IACPA,SAAQ,IACJ,uCACA;AAAA,EACN;AACF;;;AVAe,SAAR,aACL,SACA,QACQ;AACR,wBAAsB,OAAO;AAE7B,SAAO;AAAA,IACL,aAAa;AAAA,IACb,UAAU;AAAA,IACVA,SAAQ,KAAK,WAAW;AAAA,IACxBC,QAAO,KAAK,UAAU;AAAA,IACtB;AAAA,EACF;AACF;;;AWpBA,IAAO,cAAQ,aAAa","sourcesContent":["import type { Packages } from '@culur/utils-packages';\nimport { hasSass, hasVue, updateDefaultPackages } from '@culur/utils-packages';\nimport type { Config } from 'stylelint';\nimport { configCss } from './configs/css';\nimport { configScss } from './configs/scss';\nimport { configShared } from './configs/shared';\nimport { configVue } from './configs/vue';\nimport { mergeConfigs } from './utils';\n\nexport default function defineConfig(\n options?: Partial<Packages>,\n config?: Config,\n): Config {\n updateDefaultPackages(options);\n\n return mergeConfigs(\n configShared(),\n configCss(),\n hasSass() && configScss(),\n hasVue() && configVue(),\n config,\n );\n}\n","import { hasTailwind } from '@culur/utils-packages';\nimport { defineRule, defineRules } from '~/utils';\n\n// https://tailwindcss.com/docs/functions-and-directives\nconst directives = [\n 'tailwind',\n 'layer',\n 'apply',\n 'config',\n\n // https://v2.tailwindcss.com/docs/functions-and-directives\n // backwards compatible for v2\n 'variants',\n 'responsive',\n 'screen',\n];\n\nexport const atRuleNoUnknownRule = () =>\n defineRule<boolean, { ignoreAtRules: (string | RegExp)[] }>([\n true,\n { ignoreAtRules: hasTailwind() ? directives : [] },\n ]);\n\nexport const atRuleNoUnknownCSS = () =>\n defineRules({\n 'at-rule-no-unknown': atRuleNoUnknownRule(),\n });\n\nexport const atRuleNoUnknownSCSS = () =>\n defineRules({\n 'at-rule-no-unknown': null,\n 'scss/at-rule-no-unknown': atRuleNoUnknownRule(),\n });\n","import type { Config, ConfigRuleSettings } from 'stylelint';\n\nexport type ConfigRulePrimaryOption =\n | boolean\n | number\n | string\n | Array<boolean | number | string | object>;\nexport type ConfigRuleSecondaryOptions = object;\n\nexport const defineRule = <\n PrimaryOption extends ConfigRulePrimaryOption,\n SecondaryOptions extends ConfigRuleSecondaryOptions,\n>(\n rule: ConfigRuleSettings<PrimaryOption, SecondaryOptions>,\n) => rule;\n\nexport const defineRules = <TRules extends Config['rules']>(rule: TRules) =>\n rule;\n\n// clone function mergeConfigs from stylelint repository\nexport const mergeConfigs = (\n ...configsOrNull: (Config | undefined | null | false)[]\n) => {\n const configs = configsOrNull.filter((c): c is Config => !!c);\n\n return {\n plugins: [...new Set(configs.flatMap(c => c.plugins ?? []))],\n overrides: [...new Set(configs.flatMap(c => c.overrides ?? []))],\n extends: configs\n .flatMap(c => c.extends ?? [])\n .filter((item, index, arr) => arr.lastIndexOf(item) === index),\n rules: configs.reduce(\n (acc, config) => ({ ...acc, ...config.rules }),\n {} as Config['rules'],\n ),\n ...configs.reduce(\n (\n acc,\n { plugins: _p, overrides: _o, extends: _e, rules: _r, ...config },\n ) => ({ ...acc, ...config }),\n {} as Config,\n ),\n };\n};\n","import { defineRule, defineRules } from '~/utils';\n\nexport const declarationBlockNoRedundantLonghandPropertiesRule = defineRule<\n true,\n { ignoreShorthands?: (string | RegExp)[] }\n>([true, { ignoreShorthands: ['grid-template'] }]);\n\nexport const declarationBlockNoRedundantLonghandProperties = defineRules({\n 'declaration-block-no-redundant-longhand-properties':\n declarationBlockNoRedundantLonghandPropertiesRule,\n});\n","import { hasSass, hasTailwind, hasVue } from '@culur/utils-packages';\nimport { defineRule, defineRules } from '~/utils';\n\nexport const functionNoUnknownRule = () => {\n const ignoreFunctions = [\n // https://tailwindcss.com/docs/functions-and-directives#functions\n ...(hasTailwind() //\n ? ['theme', 'screen']\n : []),\n\n // https://sass-lang.com/documentation/modules/list\n // https://sass-lang.com/documentation/modules/math\n // https://sass-lang.com/documentation/modules/color\n ...(hasSass() //\n ? [/^(list|math|color)\\..+/]\n : []),\n\n // https://vuejs.org/api/sfc-css-features.html#v-bind-in-css\n ...(hasVue() //\n ? ['v-bind']\n : []),\n ];\n\n return defineRule<boolean, { ignoreFunctions?: (string | RegExp)[] }>([\n true,\n ignoreFunctions.length > 0\n ? { ignoreFunctions }\n : { ignoreFunctions: undefined },\n ]);\n};\n\nexport const functionNoUnknown = () =>\n defineRules({\n 'function-no-unknown': functionNoUnknownRule(),\n });\n","import { hasSass, hasTailwind } from '@culur/utils-packages';\nimport { defineRule, defineRules } from '~/utils';\n\n// https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md#options\n\ntype Keyword =\n | 'custom-properties' /**/ // Custom properties (e.g. --property: 10px;)\n | 'dollar-variables' /***/ // Dollar variables (e.g. $variable)\n | 'at-variables' /*******/ // At-variables (e.g. @variable available in Less syntax)\n | 'declarations' /*******/ // CSS declarations (e.g. display: block)\n | 'rules' /**************/ // Nested rules (e.g. a { span {} })\n | 'at-rules' /***********/ // Nested at-rules (e.g. div { @media () {} })\n | 'less-mixins'; /*******/ // Mixins in Less syntax (e.g. .mixin();)\n\ninterface AtRule {\n type: 'at-rule';\n name?: string;\n parameter?: string | RegExp;\n hasBlock?: boolean;\n}\n\ninterface Rule {\n type: 'rule';\n selector?: string | RegExp;\n name?: string;\n}\n\ntype PrimaryOption = Array<Keyword | AtRule | Rule>;\ninterface SecondaryOptions {\n unspecified?: 'top' | 'bottom' | 'ignore';\n}\n\n/**\n * https://sass-lang.com/documentation/at-rules\n */\nconst atRuleScssImport: PrimaryOption = [\n { type: 'at-rule', name: 'use' },\n { type: 'at-rule', name: 'forward' },\n { type: 'at-rule', name: 'import' },\n];\nconst atRuleScss: PrimaryOption = [\n { type: 'at-rule', name: 'function' },\n { type: 'at-rule', name: 'mixin' },\n { type: 'at-rule', name: 'extend' },\n { type: 'at-rule', name: 'include' },\n { type: 'at-rule', name: 'at-root' },\n];\n\nconst variables: PrimaryOption = [\n 'dollar-variables', // $variable\n 'at-variables', // @variable\n 'custom-properties', // --property: 10px\n];\n\n/**\n * https://tailwindcss.com/docs/functions-and-directives\n */\nconst atRuleTailwind: PrimaryOption = [\n { type: 'at-rule', name: 'tailwind' },\n { type: 'at-rule', name: 'layer' },\n { type: 'at-rule', name: 'apply' },\n { type: 'at-rule', name: 'config' },\n];\n\n/**\n * https://v2.tailwindcss.com/docs/functions-and-directives\n *\n * backwards compatible for v2\n */\nconst atRuleTailwindV2: PrimaryOption = [\n { type: 'at-rule', name: 'variants' },\n { type: 'at-rule', name: 'responsive' },\n { type: 'at-rule', name: 'screen' },\n];\n\n/**\n * Nested rules (e.g. a { span {} })\n */\nconst rules: PrimaryOption = [\n {\n type: 'rule',\n selector: /^&::[\\w-]+/,\n },\n 'rules',\n];\n\nexport const orderRule = () =>\n defineRule<PrimaryOption, SecondaryOptions>([\n [\n ...(hasSass() ? atRuleScssImport : []),\n ...(hasTailwind() ? atRuleTailwind : []),\n ...variables,\n ...(hasSass() ? atRuleScss : []),\n ...(hasTailwind() ? atRuleTailwindV2 : []),\n 'at-rules',\n 'less-mixins',\n 'declarations',\n ...rules,\n ],\n {\n unspecified: 'bottom',\n },\n ]);\n\nexport const order = () =>\n defineRules({\n 'order/order': orderRule(),\n });\n","import type { Config } from 'stylelint';\nimport { atRuleNoUnknownCSS } from '~/rules/at-rule-no-unknown';\nimport { declarationBlockNoRedundantLonghandProperties } from '~/rules/declaration-block-no-redundant-longhand-properties';\nimport { functionNoUnknown } from '~/rules/function-no-unknown';\nimport { order } from '~/rules/order';\n\nexport const configCss = (): Config => ({\n extends: ['stylelint-config-standard', 'stylelint-config-clean-order'],\n plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],\n rules: {\n ...atRuleNoUnknownCSS(),\n ...declarationBlockNoRedundantLonghandProperties,\n ...functionNoUnknown(),\n ...order(),\n },\n});\n","import { defineRule, defineRules } from '~/utils';\n\ntype PrimaryOption = string;\ninterface SecondaryOptions {\n message: string;\n}\n\nexport const dollarVariablePatternRule = defineRule<\n PrimaryOption,\n SecondaryOptions\n>([\n '^(-{0,2}?[a-z][a-z0-9]*)(-[a-z0-9]+)*$',\n { message: 'Expected variable to be kebab-case' },\n]);\n\nexport const dollarVariablePatternSCSS = defineRules({\n 'scss/dollar-variable-pattern': dollarVariablePatternRule,\n});\n","import type { Config } from 'stylelint';\nimport { atRuleNoUnknownSCSS } from '~/rules/at-rule-no-unknown';\nimport { dollarVariablePatternSCSS } from '~/rules/dollar-variable-pattern';\n\nexport const configScss = (): Config => ({\n extends: ['stylelint-config-standard-scss'],\n rules: {\n ...atRuleNoUnknownSCSS(),\n ...dollarVariablePatternSCSS,\n },\n});\n","import type { Config } from 'stylelint';\n\nexport const configShared = (): Config => ({\n extends: ['stylelint-config-html'],\n});\n","import { hasSass } from '@culur/utils-packages';\nimport type { Config } from 'stylelint';\n\nexport const configVue = (): Config => ({\n extends: [\n hasSass()\n ? 'stylelint-config-standard-vue/scss'\n : 'stylelint-config-standard-vue',\n ],\n});\n","import defineConfig from './factory';\n\nexport default defineConfig();\n"]}
@@ -0,0 +1,5 @@
1
+ import * as node_modules_stylelint_types_stylelint from 'node_modules/stylelint/types/stylelint';
2
+
3
+ declare const _default: node_modules_stylelint_types_stylelint.Config;
4
+
5
+ export { _default as default };
@@ -0,0 +1,5 @@
1
+ import * as node_modules_stylelint_types_stylelint from 'node_modules/stylelint/types/stylelint';
2
+
3
+ declare const _default: node_modules_stylelint_types_stylelint.Config;
4
+
5
+ export { _default as default };
package/dist/index.js ADDED
@@ -0,0 +1,188 @@
1
+ import { updateDefaultPackages, hasVue, hasSass, hasTailwind } from '@culur/utils-packages';
2
+
3
+ // src/factory.ts
4
+
5
+ // src/utils/utils.ts
6
+ var defineRule = (rule) => rule;
7
+ var defineRules = (rule) => rule;
8
+ var mergeConfigs = (...configsOrNull) => {
9
+ const configs = configsOrNull.filter((c) => !!c);
10
+ return {
11
+ plugins: [...new Set(configs.flatMap((c) => c.plugins ?? []))],
12
+ overrides: [...new Set(configs.flatMap((c) => c.overrides ?? []))],
13
+ extends: configs.flatMap((c) => c.extends ?? []).filter((item, index, arr) => arr.lastIndexOf(item) === index),
14
+ rules: configs.reduce(
15
+ (acc, config) => ({ ...acc, ...config.rules }),
16
+ {}
17
+ ),
18
+ ...configs.reduce(
19
+ (acc, { plugins: _p, overrides: _o, extends: _e, rules: _r, ...config }) => ({ ...acc, ...config }),
20
+ {}
21
+ )
22
+ };
23
+ };
24
+
25
+ // src/rules/at-rule-no-unknown.ts
26
+ var directives = [
27
+ "tailwind",
28
+ "layer",
29
+ "apply",
30
+ "config",
31
+ // https://v2.tailwindcss.com/docs/functions-and-directives
32
+ // backwards compatible for v2
33
+ "variants",
34
+ "responsive",
35
+ "screen"
36
+ ];
37
+ var atRuleNoUnknownRule = () => defineRule([
38
+ true,
39
+ { ignoreAtRules: hasTailwind() ? directives : [] }
40
+ ]);
41
+ var atRuleNoUnknownCSS = () => defineRules({
42
+ "at-rule-no-unknown": atRuleNoUnknownRule()
43
+ });
44
+ var atRuleNoUnknownSCSS = () => defineRules({
45
+ "at-rule-no-unknown": null,
46
+ "scss/at-rule-no-unknown": atRuleNoUnknownRule()
47
+ });
48
+
49
+ // src/rules/declaration-block-no-redundant-longhand-properties.ts
50
+ var declarationBlockNoRedundantLonghandPropertiesRule = defineRule([true, { ignoreShorthands: ["grid-template"] }]);
51
+ var declarationBlockNoRedundantLonghandProperties = defineRules({
52
+ "declaration-block-no-redundant-longhand-properties": declarationBlockNoRedundantLonghandPropertiesRule
53
+ });
54
+ var functionNoUnknownRule = () => {
55
+ const ignoreFunctions = [
56
+ // https://tailwindcss.com/docs/functions-and-directives#functions
57
+ ...hasTailwind() ? ["theme", "screen"] : [],
58
+ // https://sass-lang.com/documentation/modules/list
59
+ // https://sass-lang.com/documentation/modules/math
60
+ // https://sass-lang.com/documentation/modules/color
61
+ ...hasSass() ? [/^(list|math|color)\..+/] : [],
62
+ // https://vuejs.org/api/sfc-css-features.html#v-bind-in-css
63
+ ...hasVue() ? ["v-bind"] : []
64
+ ];
65
+ return defineRule([
66
+ true,
67
+ ignoreFunctions.length > 0 ? { ignoreFunctions } : { ignoreFunctions: void 0 }
68
+ ]);
69
+ };
70
+ var functionNoUnknown = () => defineRules({
71
+ "function-no-unknown": functionNoUnknownRule()
72
+ });
73
+ var atRuleScssImport = [
74
+ { type: "at-rule", name: "use" },
75
+ { type: "at-rule", name: "forward" },
76
+ { type: "at-rule", name: "import" }
77
+ ];
78
+ var atRuleScss = [
79
+ { type: "at-rule", name: "function" },
80
+ { type: "at-rule", name: "mixin" },
81
+ { type: "at-rule", name: "extend" },
82
+ { type: "at-rule", name: "include" },
83
+ { type: "at-rule", name: "at-root" }
84
+ ];
85
+ var variables = [
86
+ "dollar-variables",
87
+ // $variable
88
+ "at-variables",
89
+ // @variable
90
+ "custom-properties"
91
+ // --property: 10px
92
+ ];
93
+ var atRuleTailwind = [
94
+ { type: "at-rule", name: "tailwind" },
95
+ { type: "at-rule", name: "layer" },
96
+ { type: "at-rule", name: "apply" },
97
+ { type: "at-rule", name: "config" }
98
+ ];
99
+ var atRuleTailwindV2 = [
100
+ { type: "at-rule", name: "variants" },
101
+ { type: "at-rule", name: "responsive" },
102
+ { type: "at-rule", name: "screen" }
103
+ ];
104
+ var rules = [
105
+ {
106
+ type: "rule",
107
+ selector: /^&::[\w-]+/
108
+ },
109
+ "rules"
110
+ ];
111
+ var orderRule = () => defineRule([
112
+ [
113
+ ...hasSass() ? atRuleScssImport : [],
114
+ ...hasTailwind() ? atRuleTailwind : [],
115
+ ...variables,
116
+ ...hasSass() ? atRuleScss : [],
117
+ ...hasTailwind() ? atRuleTailwindV2 : [],
118
+ "at-rules",
119
+ "less-mixins",
120
+ "declarations",
121
+ ...rules
122
+ ],
123
+ {
124
+ unspecified: "bottom"
125
+ }
126
+ ]);
127
+ var order = () => defineRules({
128
+ "order/order": orderRule()
129
+ });
130
+
131
+ // src/configs/css.ts
132
+ var configCss = () => ({
133
+ extends: ["stylelint-config-standard", "stylelint-config-clean-order"],
134
+ plugins: ["stylelint-order", "stylelint-selector-bem-pattern"],
135
+ rules: {
136
+ ...atRuleNoUnknownCSS(),
137
+ ...declarationBlockNoRedundantLonghandProperties,
138
+ ...functionNoUnknown(),
139
+ ...order()
140
+ }
141
+ });
142
+
143
+ // src/rules/dollar-variable-pattern.ts
144
+ var dollarVariablePatternRule = defineRule([
145
+ "^(-{0,2}?[a-z][a-z0-9]*)(-[a-z0-9]+)*$",
146
+ { message: "Expected variable to be kebab-case" }
147
+ ]);
148
+ var dollarVariablePatternSCSS = defineRules({
149
+ "scss/dollar-variable-pattern": dollarVariablePatternRule
150
+ });
151
+
152
+ // src/configs/scss.ts
153
+ var configScss = () => ({
154
+ extends: ["stylelint-config-standard-scss"],
155
+ rules: {
156
+ ...atRuleNoUnknownSCSS(),
157
+ ...dollarVariablePatternSCSS
158
+ }
159
+ });
160
+
161
+ // src/configs/shared.ts
162
+ var configShared = () => ({
163
+ extends: ["stylelint-config-html"]
164
+ });
165
+ var configVue = () => ({
166
+ extends: [
167
+ hasSass() ? "stylelint-config-standard-vue/scss" : "stylelint-config-standard-vue"
168
+ ]
169
+ });
170
+
171
+ // src/factory.ts
172
+ function defineConfig(options, config) {
173
+ updateDefaultPackages(options);
174
+ return mergeConfigs(
175
+ configShared(),
176
+ configCss(),
177
+ hasSass() && configScss(),
178
+ hasVue() && configVue(),
179
+ config
180
+ );
181
+ }
182
+
183
+ // src/index.ts
184
+ var src_default = defineConfig();
185
+
186
+ export { src_default as default };
187
+ //# sourceMappingURL=out.js.map
188
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/factory.ts","../src/rules/at-rule-no-unknown.ts","../src/utils/utils.ts","../src/rules/declaration-block-no-redundant-longhand-properties.ts","../src/rules/function-no-unknown.ts","../src/rules/order.ts","../src/configs/css.ts","../src/rules/dollar-variable-pattern.ts","../src/configs/scss.ts","../src/configs/shared.ts","../src/configs/vue.ts","../src/index.ts"],"names":["hasSass","hasVue","hasTailwind"],"mappings":";AACA,SAAS,WAAAA,UAAS,UAAAC,SAAQ,6BAA6B;;;ACDvD,SAAS,mBAAmB;;;ACSrB,IAAM,aAAa,CAIxB,SACG;AAEE,IAAM,cAAc,CAAiC,SAC1D;AAGK,IAAM,eAAe,IACvB,kBACA;AACH,QAAM,UAAU,cAAc,OAAO,CAAC,MAAmB,CAAC,CAAC,CAAC;AAE5D,SAAO;AAAA,IACL,SAAS,CAAC,GAAG,IAAI,IAAI,QAAQ,QAAQ,OAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AAAA,IAC3D,WAAW,CAAC,GAAG,IAAI,IAAI,QAAQ,QAAQ,OAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA,IAC/D,SAAS,QACN,QAAQ,OAAK,EAAE,WAAW,CAAC,CAAC,EAC5B,OAAO,CAAC,MAAM,OAAO,QAAQ,IAAI,YAAY,IAAI,MAAM,KAAK;AAAA,IAC/D,OAAO,QAAQ;AAAA,MACb,CAAC,KAAK,YAAY,EAAE,GAAG,KAAK,GAAG,OAAO,MAAM;AAAA,MAC5C,CAAC;AAAA,IACH;AAAA,IACA,GAAG,QAAQ;AAAA,MACT,CACE,KACA,EAAE,SAAS,IAAI,WAAW,IAAI,SAAS,IAAI,OAAO,IAAI,GAAG,OAAO,OAC5D,EAAE,GAAG,KAAK,GAAG,OAAO;AAAA,MAC1B,CAAC;AAAA,IACH;AAAA,EACF;AACF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AAS,CAAC,6BAA6B,8BAA8B;AAAA,EACrE,SAAS,CAAC,mBAAmB,gCAAgC;AAAA,EAC7D,OAAO;AAAA,IACL,GAAG,mBAAmB;AAAA,IACtB,GAAG;AAAA,IACH,GAAG,kBAAkB;AAAA,IACrB,GAAG,MAAM;AAAA,EACX;AACF;;;ACRO,IAAM,4BAA4B,WAGvC;AAAA,EACA;AAAA,EACA,EAAE,SAAS,qCAAqC;AAClD,CAAC;AAEM,IAAM,4BAA4B,YAAY;AAAA,EACnD,gCAAgC;AAClC,CAAC;;;ACbM,IAAM,aAAa,OAAe;AAAA,EACvC,SAAS,CAAC,gCAAgC;AAAA,EAC1C,OAAO;AAAA,IACL,GAAG,oBAAoB;AAAA,IACvB,GAAG;AAAA,EACL;AACF;;;ACRO,IAAM,eAAe,OAAe;AAAA,EACzC,SAAS,CAAC,uBAAuB;AACnC;;;ACJA,SAAS,WAAAF,gBAAe;AAGjB,IAAM,YAAY,OAAe;AAAA,EACtC,SAAS;AAAA,IACPA,SAAQ,IACJ,uCACA;AAAA,EACN;AACF;;;AVAe,SAAR,aACL,SACA,QACQ;AACR,wBAAsB,OAAO;AAE7B,SAAO;AAAA,IACL,aAAa;AAAA,IACb,UAAU;AAAA,IACVA,SAAQ,KAAK,WAAW;AAAA,IACxBC,QAAO,KAAK,UAAU;AAAA,IACtB;AAAA,EACF;AACF;;;AWpBA,IAAO,cAAQ,aAAa","sourcesContent":["import type { Packages } from '@culur/utils-packages';\nimport { hasSass, hasVue, updateDefaultPackages } from '@culur/utils-packages';\nimport type { Config } from 'stylelint';\nimport { configCss } from './configs/css';\nimport { configScss } from './configs/scss';\nimport { configShared } from './configs/shared';\nimport { configVue } from './configs/vue';\nimport { mergeConfigs } from './utils';\n\nexport default function defineConfig(\n options?: Partial<Packages>,\n config?: Config,\n): Config {\n updateDefaultPackages(options);\n\n return mergeConfigs(\n configShared(),\n configCss(),\n hasSass() && configScss(),\n hasVue() && configVue(),\n config,\n );\n}\n","import { hasTailwind } from '@culur/utils-packages';\nimport { defineRule, defineRules } from '~/utils';\n\n// https://tailwindcss.com/docs/functions-and-directives\nconst directives = [\n 'tailwind',\n 'layer',\n 'apply',\n 'config',\n\n // https://v2.tailwindcss.com/docs/functions-and-directives\n // backwards compatible for v2\n 'variants',\n 'responsive',\n 'screen',\n];\n\nexport const atRuleNoUnknownRule = () =>\n defineRule<boolean, { ignoreAtRules: (string | RegExp)[] }>([\n true,\n { ignoreAtRules: hasTailwind() ? directives : [] },\n ]);\n\nexport const atRuleNoUnknownCSS = () =>\n defineRules({\n 'at-rule-no-unknown': atRuleNoUnknownRule(),\n });\n\nexport const atRuleNoUnknownSCSS = () =>\n defineRules({\n 'at-rule-no-unknown': null,\n 'scss/at-rule-no-unknown': atRuleNoUnknownRule(),\n });\n","import type { Config, ConfigRuleSettings } from 'stylelint';\n\nexport type ConfigRulePrimaryOption =\n | boolean\n | number\n | string\n | Array<boolean | number | string | object>;\nexport type ConfigRuleSecondaryOptions = object;\n\nexport const defineRule = <\n PrimaryOption extends ConfigRulePrimaryOption,\n SecondaryOptions extends ConfigRuleSecondaryOptions,\n>(\n rule: ConfigRuleSettings<PrimaryOption, SecondaryOptions>,\n) => rule;\n\nexport const defineRules = <TRules extends Config['rules']>(rule: TRules) =>\n rule;\n\n// clone function mergeConfigs from stylelint repository\nexport const mergeConfigs = (\n ...configsOrNull: (Config | undefined | null | false)[]\n) => {\n const configs = configsOrNull.filter((c): c is Config => !!c);\n\n return {\n plugins: [...new Set(configs.flatMap(c => c.plugins ?? []))],\n overrides: [...new Set(configs.flatMap(c => c.overrides ?? []))],\n extends: configs\n .flatMap(c => c.extends ?? [])\n .filter((item, index, arr) => arr.lastIndexOf(item) === index),\n rules: configs.reduce(\n (acc, config) => ({ ...acc, ...config.rules }),\n {} as Config['rules'],\n ),\n ...configs.reduce(\n (\n acc,\n { plugins: _p, overrides: _o, extends: _e, rules: _r, ...config },\n ) => ({ ...acc, ...config }),\n {} as Config,\n ),\n };\n};\n","import { defineRule, defineRules } from '~/utils';\n\nexport const declarationBlockNoRedundantLonghandPropertiesRule = defineRule<\n true,\n { ignoreShorthands?: (string | RegExp)[] }\n>([true, { ignoreShorthands: ['grid-template'] }]);\n\nexport const declarationBlockNoRedundantLonghandProperties = defineRules({\n 'declaration-block-no-redundant-longhand-properties':\n declarationBlockNoRedundantLonghandPropertiesRule,\n});\n","import { hasSass, hasTailwind, hasVue } from '@culur/utils-packages';\nimport { defineRule, defineRules } from '~/utils';\n\nexport const functionNoUnknownRule = () => {\n const ignoreFunctions = [\n // https://tailwindcss.com/docs/functions-and-directives#functions\n ...(hasTailwind() //\n ? ['theme', 'screen']\n : []),\n\n // https://sass-lang.com/documentation/modules/list\n // https://sass-lang.com/documentation/modules/math\n // https://sass-lang.com/documentation/modules/color\n ...(hasSass() //\n ? [/^(list|math|color)\\..+/]\n : []),\n\n // https://vuejs.org/api/sfc-css-features.html#v-bind-in-css\n ...(hasVue() //\n ? ['v-bind']\n : []),\n ];\n\n return defineRule<boolean, { ignoreFunctions?: (string | RegExp)[] }>([\n true,\n ignoreFunctions.length > 0\n ? { ignoreFunctions }\n : { ignoreFunctions: undefined },\n ]);\n};\n\nexport const functionNoUnknown = () =>\n defineRules({\n 'function-no-unknown': functionNoUnknownRule(),\n });\n","import { hasSass, hasTailwind } from '@culur/utils-packages';\nimport { defineRule, defineRules } from '~/utils';\n\n// https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md#options\n\ntype Keyword =\n | 'custom-properties' /**/ // Custom properties (e.g. --property: 10px;)\n | 'dollar-variables' /***/ // Dollar variables (e.g. $variable)\n | 'at-variables' /*******/ // At-variables (e.g. @variable available in Less syntax)\n | 'declarations' /*******/ // CSS declarations (e.g. display: block)\n | 'rules' /**************/ // Nested rules (e.g. a { span {} })\n | 'at-rules' /***********/ // Nested at-rules (e.g. div { @media () {} })\n | 'less-mixins'; /*******/ // Mixins in Less syntax (e.g. .mixin();)\n\ninterface AtRule {\n type: 'at-rule';\n name?: string;\n parameter?: string | RegExp;\n hasBlock?: boolean;\n}\n\ninterface Rule {\n type: 'rule';\n selector?: string | RegExp;\n name?: string;\n}\n\ntype PrimaryOption = Array<Keyword | AtRule | Rule>;\ninterface SecondaryOptions {\n unspecified?: 'top' | 'bottom' | 'ignore';\n}\n\n/**\n * https://sass-lang.com/documentation/at-rules\n */\nconst atRuleScssImport: PrimaryOption = [\n { type: 'at-rule', name: 'use' },\n { type: 'at-rule', name: 'forward' },\n { type: 'at-rule', name: 'import' },\n];\nconst atRuleScss: PrimaryOption = [\n { type: 'at-rule', name: 'function' },\n { type: 'at-rule', name: 'mixin' },\n { type: 'at-rule', name: 'extend' },\n { type: 'at-rule', name: 'include' },\n { type: 'at-rule', name: 'at-root' },\n];\n\nconst variables: PrimaryOption = [\n 'dollar-variables', // $variable\n 'at-variables', // @variable\n 'custom-properties', // --property: 10px\n];\n\n/**\n * https://tailwindcss.com/docs/functions-and-directives\n */\nconst atRuleTailwind: PrimaryOption = [\n { type: 'at-rule', name: 'tailwind' },\n { type: 'at-rule', name: 'layer' },\n { type: 'at-rule', name: 'apply' },\n { type: 'at-rule', name: 'config' },\n];\n\n/**\n * https://v2.tailwindcss.com/docs/functions-and-directives\n *\n * backwards compatible for v2\n */\nconst atRuleTailwindV2: PrimaryOption = [\n { type: 'at-rule', name: 'variants' },\n { type: 'at-rule', name: 'responsive' },\n { type: 'at-rule', name: 'screen' },\n];\n\n/**\n * Nested rules (e.g. a { span {} })\n */\nconst rules: PrimaryOption = [\n {\n type: 'rule',\n selector: /^&::[\\w-]+/,\n },\n 'rules',\n];\n\nexport const orderRule = () =>\n defineRule<PrimaryOption, SecondaryOptions>([\n [\n ...(hasSass() ? atRuleScssImport : []),\n ...(hasTailwind() ? atRuleTailwind : []),\n ...variables,\n ...(hasSass() ? atRuleScss : []),\n ...(hasTailwind() ? atRuleTailwindV2 : []),\n 'at-rules',\n 'less-mixins',\n 'declarations',\n ...rules,\n ],\n {\n unspecified: 'bottom',\n },\n ]);\n\nexport const order = () =>\n defineRules({\n 'order/order': orderRule(),\n });\n","import type { Config } from 'stylelint';\nimport { atRuleNoUnknownCSS } from '~/rules/at-rule-no-unknown';\nimport { declarationBlockNoRedundantLonghandProperties } from '~/rules/declaration-block-no-redundant-longhand-properties';\nimport { functionNoUnknown } from '~/rules/function-no-unknown';\nimport { order } from '~/rules/order';\n\nexport const configCss = (): Config => ({\n extends: ['stylelint-config-standard', 'stylelint-config-clean-order'],\n plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],\n rules: {\n ...atRuleNoUnknownCSS(),\n ...declarationBlockNoRedundantLonghandProperties,\n ...functionNoUnknown(),\n ...order(),\n },\n});\n","import { defineRule, defineRules } from '~/utils';\n\ntype PrimaryOption = string;\ninterface SecondaryOptions {\n message: string;\n}\n\nexport const dollarVariablePatternRule = defineRule<\n PrimaryOption,\n SecondaryOptions\n>([\n '^(-{0,2}?[a-z][a-z0-9]*)(-[a-z0-9]+)*$',\n { message: 'Expected variable to be kebab-case' },\n]);\n\nexport const dollarVariablePatternSCSS = defineRules({\n 'scss/dollar-variable-pattern': dollarVariablePatternRule,\n});\n","import type { Config } from 'stylelint';\nimport { atRuleNoUnknownSCSS } from '~/rules/at-rule-no-unknown';\nimport { dollarVariablePatternSCSS } from '~/rules/dollar-variable-pattern';\n\nexport const configScss = (): Config => ({\n extends: ['stylelint-config-standard-scss'],\n rules: {\n ...atRuleNoUnknownSCSS(),\n ...dollarVariablePatternSCSS,\n },\n});\n","import type { Config } from 'stylelint';\n\nexport const configShared = (): Config => ({\n extends: ['stylelint-config-html'],\n});\n","import { hasSass } from '@culur/utils-packages';\nimport type { Config } from 'stylelint';\n\nexport const configVue = (): Config => ({\n extends: [\n hasSass()\n ? 'stylelint-config-standard-vue/scss'\n : 'stylelint-config-standard-vue',\n ],\n});\n","import defineConfig from './factory';\n\nexport default defineConfig();\n"]}