@culur/config-stylelint 0.0.0-dev-20240527064403 → 1.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +12 -21
  2. package/README.md +122 -122
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/package.json +5 -5
  6. package/src/__tests__/dedent.ts +5 -5
  7. package/src/__tests__/index.ts +5 -5
  8. package/src/__tests__/mock.ts +36 -36
  9. package/src/__tests__/syntax.ts +11 -11
  10. package/src/__tests__/test-lint-and-fix.ts +55 -55
  11. package/src/__tests__/test-rule-or-config-value.ts +68 -68
  12. package/src/configs/css.test.ts +10 -10
  13. package/src/configs/css.ts +16 -16
  14. package/src/configs/scss.test.ts +9 -9
  15. package/src/configs/scss.ts +11 -11
  16. package/src/configs/shared.test.ts +9 -9
  17. package/src/configs/shared.ts +5 -5
  18. package/src/configs/vue.test.ts +18 -18
  19. package/src/configs/vue.ts +10 -10
  20. package/src/factory.test.ts +15 -15
  21. package/src/factory.ts +23 -23
  22. package/src/index.test.ts +9 -9
  23. package/src/index.ts +3 -3
  24. package/src/rules/at-rule-no-unknown.test.ts +43 -43
  25. package/src/rules/at-rule-no-unknown.ts +33 -33
  26. package/src/rules/declaration-block-no-redundant-longhand-properties.test.ts +38 -38
  27. package/src/rules/declaration-block-no-redundant-longhand-properties.ts +11 -11
  28. package/src/rules/dollar-variable-pattern.test.ts +27 -27
  29. package/src/rules/dollar-variable-pattern.ts +18 -18
  30. package/src/rules/function-no-unknown.test.ts +39 -39
  31. package/src/rules/function-no-unknown.ts +35 -35
  32. package/src/rules/order.test.ts +46 -46
  33. package/src/rules/order.ts +108 -108
  34. package/src/utils/index.ts +1 -1
  35. package/src/utils/utils.test.ts +46 -46
  36. package/src/utils/utils.ts +44 -44
package/CHANGELOG.md CHANGED
@@ -1,21 +1,12 @@
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
1
+ # @culur/config-stylelint
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`a83892c`](https://github.com/culur/culur/commit/a83892c01bc3a49cd21b79a1abd5443147fff0c4) Thanks [@phamhongphuc](https://github.com/phamhongphuc)! - First release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`e3492d2`](https://github.com/culur/culur/commit/e3492d20a29bee15bbabab0a60277ed36944cd7a)]:
12
+ - @culur/utils-packages@1.0.0
package/README.md CHANGED
@@ -1,122 +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).
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).
@@ -1 +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,I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BAA6B,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"]}
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,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AG,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';\r\nimport { hasSass, hasVue, updateDefaultPackages } from '@culur/utils-packages';\r\nimport type { Config } from 'stylelint';\r\nimport { configCss } from './configs/css';\r\nimport { configScss } from './configs/scss';\r\nimport { configShared } from './configs/shared';\r\nimport { configVue } from './configs/vue';\r\nimport { mergeConfigs } from './utils';\r\n\r\nexport default function defineConfig(\r\n options?: Partial<Packages>,\r\n config?: Config,\r\n): Config {\r\n updateDefaultPackages(options);\r\n\r\n return mergeConfigs(\r\n configShared(),\r\n configCss(),\r\n hasSass() && configScss(),\r\n hasVue() && configVue(),\r\n config,\r\n );\r\n}\r\n","import { hasTailwind } from '@culur/utils-packages';\r\nimport { defineRule, defineRules } from '~/utils';\r\n\r\n// https://tailwindcss.com/docs/functions-and-directives\r\nconst directives = [\r\n 'tailwind',\r\n 'layer',\r\n 'apply',\r\n 'config',\r\n\r\n // https://v2.tailwindcss.com/docs/functions-and-directives\r\n // backwards compatible for v2\r\n 'variants',\r\n 'responsive',\r\n 'screen',\r\n];\r\n\r\nexport const atRuleNoUnknownRule = () =>\r\n defineRule<boolean, { ignoreAtRules: (string | RegExp)[] }>([\r\n true,\r\n { ignoreAtRules: hasTailwind() ? directives : [] },\r\n ]);\r\n\r\nexport const atRuleNoUnknownCSS = () =>\r\n defineRules({\r\n 'at-rule-no-unknown': atRuleNoUnknownRule(),\r\n });\r\n\r\nexport const atRuleNoUnknownSCSS = () =>\r\n defineRules({\r\n 'at-rule-no-unknown': null,\r\n 'scss/at-rule-no-unknown': atRuleNoUnknownRule(),\r\n });\r\n","import type { Config, ConfigRuleSettings } from 'stylelint';\r\n\r\nexport type ConfigRulePrimaryOption =\r\n | boolean\r\n | number\r\n | string\r\n | Array<boolean | number | string | object>;\r\nexport type ConfigRuleSecondaryOptions = object;\r\n\r\nexport const defineRule = <\r\n PrimaryOption extends ConfigRulePrimaryOption,\r\n SecondaryOptions extends ConfigRuleSecondaryOptions,\r\n>(\r\n rule: ConfigRuleSettings<PrimaryOption, SecondaryOptions>,\r\n) => rule;\r\n\r\nexport const defineRules = <TRules extends Config['rules']>(rule: TRules) =>\r\n rule;\r\n\r\n// clone function mergeConfigs from stylelint repository\r\nexport const mergeConfigs = (\r\n ...configsOrNull: (Config | undefined | null | false)[]\r\n) => {\r\n const configs = configsOrNull.filter((c): c is Config => !!c);\r\n\r\n return {\r\n plugins: [...new Set(configs.flatMap(c => c.plugins ?? []))],\r\n overrides: [...new Set(configs.flatMap(c => c.overrides ?? []))],\r\n extends: configs\r\n .flatMap(c => c.extends ?? [])\r\n .filter((item, index, arr) => arr.lastIndexOf(item) === index),\r\n rules: configs.reduce(\r\n (acc, config) => ({ ...acc, ...config.rules }),\r\n {} as Config['rules'],\r\n ),\r\n ...configs.reduce(\r\n (\r\n acc,\r\n { plugins: _p, overrides: _o, extends: _e, rules: _r, ...config },\r\n ) => ({ ...acc, ...config }),\r\n {} as Config,\r\n ),\r\n };\r\n};\r\n","import { defineRule, defineRules } from '~/utils';\r\n\r\nexport const declarationBlockNoRedundantLonghandPropertiesRule = defineRule<\r\n true,\r\n { ignoreShorthands?: (string | RegExp)[] }\r\n>([true, { ignoreShorthands: ['grid-template'] }]);\r\n\r\nexport const declarationBlockNoRedundantLonghandProperties = defineRules({\r\n 'declaration-block-no-redundant-longhand-properties':\r\n declarationBlockNoRedundantLonghandPropertiesRule,\r\n});\r\n","import { hasSass, hasTailwind, hasVue } from '@culur/utils-packages';\r\nimport { defineRule, defineRules } from '~/utils';\r\n\r\nexport const functionNoUnknownRule = () => {\r\n const ignoreFunctions = [\r\n // https://tailwindcss.com/docs/functions-and-directives#functions\r\n ...(hasTailwind() //\r\n ? ['theme', 'screen']\r\n : []),\r\n\r\n // https://sass-lang.com/documentation/modules/list\r\n // https://sass-lang.com/documentation/modules/math\r\n // https://sass-lang.com/documentation/modules/color\r\n ...(hasSass() //\r\n ? [/^(list|math|color)\\..+/]\r\n : []),\r\n\r\n // https://vuejs.org/api/sfc-css-features.html#v-bind-in-css\r\n ...(hasVue() //\r\n ? ['v-bind']\r\n : []),\r\n ];\r\n\r\n return defineRule<boolean, { ignoreFunctions?: (string | RegExp)[] }>([\r\n true,\r\n ignoreFunctions.length > 0\r\n ? { ignoreFunctions }\r\n : { ignoreFunctions: undefined },\r\n ]);\r\n};\r\n\r\nexport const functionNoUnknown = () =>\r\n defineRules({\r\n 'function-no-unknown': functionNoUnknownRule(),\r\n });\r\n","import { hasSass, hasTailwind } from '@culur/utils-packages';\r\nimport { defineRule, defineRules } from '~/utils';\r\n\r\n// https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md#options\r\n\r\ntype Keyword =\r\n | 'custom-properties' /**/ // Custom properties (e.g. --property: 10px;)\r\n | 'dollar-variables' /***/ // Dollar variables (e.g. $variable)\r\n | 'at-variables' /*******/ // At-variables (e.g. @variable available in Less syntax)\r\n | 'declarations' /*******/ // CSS declarations (e.g. display: block)\r\n | 'rules' /**************/ // Nested rules (e.g. a { span {} })\r\n | 'at-rules' /***********/ // Nested at-rules (e.g. div { @media () {} })\r\n | 'less-mixins'; /*******/ // Mixins in Less syntax (e.g. .mixin();)\r\n\r\ninterface AtRule {\r\n type: 'at-rule';\r\n name?: string;\r\n parameter?: string | RegExp;\r\n hasBlock?: boolean;\r\n}\r\n\r\ninterface Rule {\r\n type: 'rule';\r\n selector?: string | RegExp;\r\n name?: string;\r\n}\r\n\r\ntype PrimaryOption = Array<Keyword | AtRule | Rule>;\r\ninterface SecondaryOptions {\r\n unspecified?: 'top' | 'bottom' | 'ignore';\r\n}\r\n\r\n/**\r\n * https://sass-lang.com/documentation/at-rules\r\n */\r\nconst atRuleScssImport: PrimaryOption = [\r\n { type: 'at-rule', name: 'use' },\r\n { type: 'at-rule', name: 'forward' },\r\n { type: 'at-rule', name: 'import' },\r\n];\r\nconst atRuleScss: PrimaryOption = [\r\n { type: 'at-rule', name: 'function' },\r\n { type: 'at-rule', name: 'mixin' },\r\n { type: 'at-rule', name: 'extend' },\r\n { type: 'at-rule', name: 'include' },\r\n { type: 'at-rule', name: 'at-root' },\r\n];\r\n\r\nconst variables: PrimaryOption = [\r\n 'dollar-variables', // $variable\r\n 'at-variables', // @variable\r\n 'custom-properties', // --property: 10px\r\n];\r\n\r\n/**\r\n * https://tailwindcss.com/docs/functions-and-directives\r\n */\r\nconst atRuleTailwind: PrimaryOption = [\r\n { type: 'at-rule', name: 'tailwind' },\r\n { type: 'at-rule', name: 'layer' },\r\n { type: 'at-rule', name: 'apply' },\r\n { type: 'at-rule', name: 'config' },\r\n];\r\n\r\n/**\r\n * https://v2.tailwindcss.com/docs/functions-and-directives\r\n *\r\n * backwards compatible for v2\r\n */\r\nconst atRuleTailwindV2: PrimaryOption = [\r\n { type: 'at-rule', name: 'variants' },\r\n { type: 'at-rule', name: 'responsive' },\r\n { type: 'at-rule', name: 'screen' },\r\n];\r\n\r\n/**\r\n * Nested rules (e.g. a { span {} })\r\n */\r\nconst rules: PrimaryOption = [\r\n {\r\n type: 'rule',\r\n selector: /^&::[\\w-]+/,\r\n },\r\n 'rules',\r\n];\r\n\r\nexport const orderRule = () =>\r\n defineRule<PrimaryOption, SecondaryOptions>([\r\n [\r\n ...(hasSass() ? atRuleScssImport : []),\r\n ...(hasTailwind() ? atRuleTailwind : []),\r\n ...variables,\r\n ...(hasSass() ? atRuleScss : []),\r\n ...(hasTailwind() ? atRuleTailwindV2 : []),\r\n 'at-rules',\r\n 'less-mixins',\r\n 'declarations',\r\n ...rules,\r\n ],\r\n {\r\n unspecified: 'bottom',\r\n },\r\n ]);\r\n\r\nexport const order = () =>\r\n defineRules({\r\n 'order/order': orderRule(),\r\n });\r\n","import type { Config } from 'stylelint';\r\nimport { atRuleNoUnknownCSS } from '~/rules/at-rule-no-unknown';\r\nimport { declarationBlockNoRedundantLonghandProperties } from '~/rules/declaration-block-no-redundant-longhand-properties';\r\nimport { functionNoUnknown } from '~/rules/function-no-unknown';\r\nimport { order } from '~/rules/order';\r\n\r\nexport const configCss = (): Config => ({\r\n extends: ['stylelint-config-standard', 'stylelint-config-clean-order'],\r\n plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],\r\n rules: {\r\n ...atRuleNoUnknownCSS(),\r\n ...declarationBlockNoRedundantLonghandProperties,\r\n ...functionNoUnknown(),\r\n ...order(),\r\n },\r\n});\r\n","import { defineRule, defineRules } from '~/utils';\r\n\r\ntype PrimaryOption = string;\r\ninterface SecondaryOptions {\r\n message: string;\r\n}\r\n\r\nexport const dollarVariablePatternRule = defineRule<\r\n PrimaryOption,\r\n SecondaryOptions\r\n>([\r\n '^(-{0,2}?[a-z][a-z0-9]*)(-[a-z0-9]+)*$',\r\n { message: 'Expected variable to be kebab-case' },\r\n]);\r\n\r\nexport const dollarVariablePatternSCSS = defineRules({\r\n 'scss/dollar-variable-pattern': dollarVariablePatternRule,\r\n});\r\n","import type { Config } from 'stylelint';\r\nimport { atRuleNoUnknownSCSS } from '~/rules/at-rule-no-unknown';\r\nimport { dollarVariablePatternSCSS } from '~/rules/dollar-variable-pattern';\r\n\r\nexport const configScss = (): Config => ({\r\n extends: ['stylelint-config-standard-scss'],\r\n rules: {\r\n ...atRuleNoUnknownSCSS(),\r\n ...dollarVariablePatternSCSS,\r\n },\r\n});\r\n","import type { Config } from 'stylelint';\r\n\r\nexport const configShared = (): Config => ({\r\n extends: ['stylelint-config-html'],\r\n});\r\n","import { hasSass } from '@culur/utils-packages';\r\nimport type { Config } from 'stylelint';\r\n\r\nexport const configVue = (): Config => ({\r\n extends: [\r\n hasSass()\r\n ? 'stylelint-config-standard-vue/scss'\r\n : 'stylelint-config-standard-vue',\r\n ],\r\n});\r\n","import defineConfig from './factory';\r\n\r\nexport default defineConfig();\r\n"]}
package/dist/index.js.map CHANGED
@@ -1 +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,CA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A,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"]}
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,I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Vue, updateDefaultPackages } from '@culur/utils-packages';\r\nimport type { Config } from 'stylelint';\r\nimport { configCss } from './configs/css';\r\nimport { configScss } from './configs/scss';\r\nimport { configShared } from './configs/shared';\r\nimport { configVue } from './configs/vue';\r\nimport { mergeConfigs } from './utils';\r\n\r\nexport default function defineConfig(\r\n options?: Partial<Packages>,\r\n config?: Config,\r\n): Config {\r\n updateDefaultPackages(options);\r\n\r\n return mergeConfigs(\r\n configShared(),\r\n configCss(),\r\n hasSass() && configScss(),\r\n hasVue() && configVue(),\r\n config,\r\n );\r\n}\r\n","import { hasTailwind } from '@culur/utils-packages';\r\nimport { defineRule, defineRules } from '~/utils';\r\n\r\n// https://tailwindcss.com/docs/functions-and-directives\r\nconst directives = [\r\n 'tailwind',\r\n 'layer',\r\n 'apply',\r\n 'config',\r\n\r\n // https://v2.tailwindcss.com/docs/functions-and-directives\r\n // backwards compatible for v2\r\n 'variants',\r\n 'responsive',\r\n 'screen',\r\n];\r\n\r\nexport const atRuleNoUnknownRule = () =>\r\n defineRule<boolean, { ignoreAtRules: (string | RegExp)[] }>([\r\n true,\r\n { ignoreAtRules: hasTailwind() ? directives : [] },\r\n ]);\r\n\r\nexport const atRuleNoUnknownCSS = () =>\r\n defineRules({\r\n 'at-rule-no-unknown': atRuleNoUnknownRule(),\r\n });\r\n\r\nexport const atRuleNoUnknownSCSS = () =>\r\n defineRules({\r\n 'at-rule-no-unknown': null,\r\n 'scss/at-rule-no-unknown': atRuleNoUnknownRule(),\r\n });\r\n","import type { Config, ConfigRuleSettings } from 'stylelint';\r\n\r\nexport type ConfigRulePrimaryOption =\r\n | boolean\r\n | number\r\n | string\r\n | Array<boolean | number | string | object>;\r\nexport type ConfigRuleSecondaryOptions = object;\r\n\r\nexport const defineRule = <\r\n PrimaryOption extends ConfigRulePrimaryOption,\r\n SecondaryOptions extends ConfigRuleSecondaryOptions,\r\n>(\r\n rule: ConfigRuleSettings<PrimaryOption, SecondaryOptions>,\r\n) => rule;\r\n\r\nexport const defineRules = <TRules extends Config['rules']>(rule: TRules) =>\r\n rule;\r\n\r\n// clone function mergeConfigs from stylelint repository\r\nexport const mergeConfigs = (\r\n ...configsOrNull: (Config | undefined | null | false)[]\r\n) => {\r\n const configs = configsOrNull.filter((c): c is Config => !!c);\r\n\r\n return {\r\n plugins: [...new Set(configs.flatMap(c => c.plugins ?? []))],\r\n overrides: [...new Set(configs.flatMap(c => c.overrides ?? []))],\r\n extends: configs\r\n .flatMap(c => c.extends ?? [])\r\n .filter((item, index, arr) => arr.lastIndexOf(item) === index),\r\n rules: configs.reduce(\r\n (acc, config) => ({ ...acc, ...config.rules }),\r\n {} as Config['rules'],\r\n ),\r\n ...configs.reduce(\r\n (\r\n acc,\r\n { plugins: _p, overrides: _o, extends: _e, rules: _r, ...config },\r\n ) => ({ ...acc, ...config }),\r\n {} as Config,\r\n ),\r\n };\r\n};\r\n","import { defineRule, defineRules } from '~/utils';\r\n\r\nexport const declarationBlockNoRedundantLonghandPropertiesRule = defineRule<\r\n true,\r\n { ignoreShorthands?: (string | RegExp)[] }\r\n>([true, { ignoreShorthands: ['grid-template'] }]);\r\n\r\nexport const declarationBlockNoRedundantLonghandProperties = defineRules({\r\n 'declaration-block-no-redundant-longhand-properties':\r\n declarationBlockNoRedundantLonghandPropertiesRule,\r\n});\r\n","import { hasSass, hasTailwind, hasVue } from '@culur/utils-packages';\r\nimport { defineRule, defineRules } from '~/utils';\r\n\r\nexport const functionNoUnknownRule = () => {\r\n const ignoreFunctions = [\r\n // https://tailwindcss.com/docs/functions-and-directives#functions\r\n ...(hasTailwind() //\r\n ? ['theme', 'screen']\r\n : []),\r\n\r\n // https://sass-lang.com/documentation/modules/list\r\n // https://sass-lang.com/documentation/modules/math\r\n // https://sass-lang.com/documentation/modules/color\r\n ...(hasSass() //\r\n ? [/^(list|math|color)\\..+/]\r\n : []),\r\n\r\n // https://vuejs.org/api/sfc-css-features.html#v-bind-in-css\r\n ...(hasVue() //\r\n ? ['v-bind']\r\n : []),\r\n ];\r\n\r\n return defineRule<boolean, { ignoreFunctions?: (string | RegExp)[] }>([\r\n true,\r\n ignoreFunctions.length > 0\r\n ? { ignoreFunctions }\r\n : { ignoreFunctions: undefined },\r\n ]);\r\n};\r\n\r\nexport const functionNoUnknown = () =>\r\n defineRules({\r\n 'function-no-unknown': functionNoUnknownRule(),\r\n });\r\n","import { hasSass, hasTailwind } from '@culur/utils-packages';\r\nimport { defineRule, defineRules } from '~/utils';\r\n\r\n// https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md#options\r\n\r\ntype Keyword =\r\n | 'custom-properties' /**/ // Custom properties (e.g. --property: 10px;)\r\n | 'dollar-variables' /***/ // Dollar variables (e.g. $variable)\r\n | 'at-variables' /*******/ // At-variables (e.g. @variable available in Less syntax)\r\n | 'declarations' /*******/ // CSS declarations (e.g. display: block)\r\n | 'rules' /**************/ // Nested rules (e.g. a { span {} })\r\n | 'at-rules' /***********/ // Nested at-rules (e.g. div { @media () {} })\r\n | 'less-mixins'; /*******/ // Mixins in Less syntax (e.g. .mixin();)\r\n\r\ninterface AtRule {\r\n type: 'at-rule';\r\n name?: string;\r\n parameter?: string | RegExp;\r\n hasBlock?: boolean;\r\n}\r\n\r\ninterface Rule {\r\n type: 'rule';\r\n selector?: string | RegExp;\r\n name?: string;\r\n}\r\n\r\ntype PrimaryOption = Array<Keyword | AtRule | Rule>;\r\ninterface SecondaryOptions {\r\n unspecified?: 'top' | 'bottom' | 'ignore';\r\n}\r\n\r\n/**\r\n * https://sass-lang.com/documentation/at-rules\r\n */\r\nconst atRuleScssImport: PrimaryOption = [\r\n { type: 'at-rule', name: 'use' },\r\n { type: 'at-rule', name: 'forward' },\r\n { type: 'at-rule', name: 'import' },\r\n];\r\nconst atRuleScss: PrimaryOption = [\r\n { type: 'at-rule', name: 'function' },\r\n { type: 'at-rule', name: 'mixin' },\r\n { type: 'at-rule', name: 'extend' },\r\n { type: 'at-rule', name: 'include' },\r\n { type: 'at-rule', name: 'at-root' },\r\n];\r\n\r\nconst variables: PrimaryOption = [\r\n 'dollar-variables', // $variable\r\n 'at-variables', // @variable\r\n 'custom-properties', // --property: 10px\r\n];\r\n\r\n/**\r\n * https://tailwindcss.com/docs/functions-and-directives\r\n */\r\nconst atRuleTailwind: PrimaryOption = [\r\n { type: 'at-rule', name: 'tailwind' },\r\n { type: 'at-rule', name: 'layer' },\r\n { type: 'at-rule', name: 'apply' },\r\n { type: 'at-rule', name: 'config' },\r\n];\r\n\r\n/**\r\n * https://v2.tailwindcss.com/docs/functions-and-directives\r\n *\r\n * backwards compatible for v2\r\n */\r\nconst atRuleTailwindV2: PrimaryOption = [\r\n { type: 'at-rule', name: 'variants' },\r\n { type: 'at-rule', name: 'responsive' },\r\n { type: 'at-rule', name: 'screen' },\r\n];\r\n\r\n/**\r\n * Nested rules (e.g. a { span {} })\r\n */\r\nconst rules: PrimaryOption = [\r\n {\r\n type: 'rule',\r\n selector: /^&::[\\w-]+/,\r\n },\r\n 'rules',\r\n];\r\n\r\nexport const orderRule = () =>\r\n defineRule<PrimaryOption, SecondaryOptions>([\r\n [\r\n ...(hasSass() ? atRuleScssImport : []),\r\n ...(hasTailwind() ? atRuleTailwind : []),\r\n ...variables,\r\n ...(hasSass() ? atRuleScss : []),\r\n ...(hasTailwind() ? atRuleTailwindV2 : []),\r\n 'at-rules',\r\n 'less-mixins',\r\n 'declarations',\r\n ...rules,\r\n ],\r\n {\r\n unspecified: 'bottom',\r\n },\r\n ]);\r\n\r\nexport const order = () =>\r\n defineRules({\r\n 'order/order': orderRule(),\r\n });\r\n","import type { Config } from 'stylelint';\r\nimport { atRuleNoUnknownCSS } from '~/rules/at-rule-no-unknown';\r\nimport { declarationBlockNoRedundantLonghandProperties } from '~/rules/declaration-block-no-redundant-longhand-properties';\r\nimport { functionNoUnknown } from '~/rules/function-no-unknown';\r\nimport { order } from '~/rules/order';\r\n\r\nexport const configCss = (): Config => ({\r\n extends: ['stylelint-config-standard', 'stylelint-config-clean-order'],\r\n plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],\r\n rules: {\r\n ...atRuleNoUnknownCSS(),\r\n ...declarationBlockNoRedundantLonghandProperties,\r\n ...functionNoUnknown(),\r\n ...order(),\r\n },\r\n});\r\n","import { defineRule, defineRules } from '~/utils';\r\n\r\ntype PrimaryOption = string;\r\ninterface SecondaryOptions {\r\n message: string;\r\n}\r\n\r\nexport const dollarVariablePatternRule = defineRule<\r\n PrimaryOption,\r\n SecondaryOptions\r\n>([\r\n '^(-{0,2}?[a-z][a-z0-9]*)(-[a-z0-9]+)*$',\r\n { message: 'Expected variable to be kebab-case' },\r\n]);\r\n\r\nexport const dollarVariablePatternSCSS = defineRules({\r\n 'scss/dollar-variable-pattern': dollarVariablePatternRule,\r\n});\r\n","import type { Config } from 'stylelint';\r\nimport { atRuleNoUnknownSCSS } from '~/rules/at-rule-no-unknown';\r\nimport { dollarVariablePatternSCSS } from '~/rules/dollar-variable-pattern';\r\n\r\nexport const configScss = (): Config => ({\r\n extends: ['stylelint-config-standard-scss'],\r\n rules: {\r\n ...atRuleNoUnknownSCSS(),\r\n ...dollarVariablePatternSCSS,\r\n },\r\n});\r\n","import type { Config } from 'stylelint';\r\n\r\nexport const configShared = (): Config => ({\r\n extends: ['stylelint-config-html'],\r\n});\r\n","import { hasSass } from '@culur/utils-packages';\r\nimport type { Config } from 'stylelint';\r\n\r\nexport const configVue = (): Config => ({\r\n extends: [\r\n hasSass()\r\n ? 'stylelint-config-standard-vue/scss'\r\n : 'stylelint-config-standard-vue',\r\n ],\r\n});\r\n","import defineConfig from './factory';\r\n\r\nexport default defineConfig();\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@culur/config-stylelint",
3
- "version": "0.0.0-dev-20240527064403",
3
+ "version": "1.0.0",
4
4
  "description": "Culur's stylelint configuration",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -66,7 +66,7 @@
66
66
  "node": ">=20"
67
67
  },
68
68
  "dependencies": {
69
- "@culur/utils-packages": "workspace:*",
69
+ "@culur/utils-packages": "*",
70
70
  "stylelint-config-clean-order": "^5.4.2",
71
71
  "stylelint-config-html": "^1.1.0",
72
72
  "stylelint-config-standard": "^36.0.0",
@@ -77,9 +77,9 @@
77
77
  "stylelint-selector-bem-pattern": "^4.0.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@culur/config-tsup": "workspace:*",
81
- "@culur/config-typescript": "workspace:*",
82
- "@culur/config-vite": "workspace:*",
80
+ "@culur/config-tsup": "*",
81
+ "@culur/config-typescript": "*",
82
+ "@culur/config-vite": "*",
83
83
  "@types/node": "^20.12.12",
84
84
  "@vitest/coverage-v8": "^1.6.0",
85
85
  "@vitest/ui": "^1.6.0",
@@ -1,5 +1,5 @@
1
- import dedent from 'dedent';
2
-
3
- export const css = dedent;
4
- export const scss = dedent;
5
- export const html = dedent;
1
+ import dedent from 'dedent';
2
+
3
+ export const css = dedent;
4
+ export const scss = dedent;
5
+ export const html = dedent;
@@ -1,5 +1,5 @@
1
- export * from './dedent';
2
- export * from './mock';
3
- export * from './syntax';
4
- export * from './test-rule-or-config-value';
5
- export * from './test-lint-and-fix';
1
+ export * from './dedent';
2
+ export * from './mock';
3
+ export * from './syntax';
4
+ export * from './test-rule-or-config-value';
5
+ export * from './test-lint-and-fix';
@@ -1,36 +1,36 @@
1
- import { vi } from 'vitest';
2
-
3
- export type UtilsPackages = Partial<{
4
- hasTailwind: boolean;
5
- hasSass: boolean;
6
- hasVue: boolean;
7
- }>;
8
-
9
- export const defineMockUtilsPackages = (testCases: UtilsPackages[]) => {
10
- const shouldMockUtilsPackages = testCases.some(
11
- t =>
12
- typeof t.hasTailwind === 'boolean' ||
13
- typeof t.hasSass === 'boolean' ||
14
- typeof t.hasVue === 'boolean',
15
- );
16
-
17
- if (shouldMockUtilsPackages) {
18
- vi.mock('@culur/utils-packages');
19
- }
20
-
21
- return async ({ hasTailwind, hasSass, hasVue }: UtilsPackages) => {
22
- if (shouldMockUtilsPackages) {
23
- const utilsPackages = await import('@culur/utils-packages');
24
-
25
- if (typeof hasTailwind === 'boolean') {
26
- utilsPackages.hasTailwind = vi.fn().mockReturnValue(hasTailwind);
27
- }
28
- if (typeof hasSass === 'boolean') {
29
- utilsPackages.hasSass = vi.fn().mockReturnValue(hasSass);
30
- }
31
- if (typeof hasVue === 'boolean') {
32
- utilsPackages.hasVue = vi.fn().mockReturnValue(hasVue);
33
- }
34
- }
35
- };
36
- };
1
+ import { vi } from 'vitest';
2
+
3
+ export type UtilsPackages = Partial<{
4
+ hasTailwind: boolean;
5
+ hasSass: boolean;
6
+ hasVue: boolean;
7
+ }>;
8
+
9
+ export const defineMockUtilsPackages = (testCases: UtilsPackages[]) => {
10
+ const shouldMockUtilsPackages = testCases.some(
11
+ t =>
12
+ typeof t.hasTailwind === 'boolean' ||
13
+ typeof t.hasSass === 'boolean' ||
14
+ typeof t.hasVue === 'boolean',
15
+ );
16
+
17
+ if (shouldMockUtilsPackages) {
18
+ vi.mock('@culur/utils-packages');
19
+ }
20
+
21
+ return async ({ hasTailwind, hasSass, hasVue }: UtilsPackages) => {
22
+ if (shouldMockUtilsPackages) {
23
+ const utilsPackages = await import('@culur/utils-packages');
24
+
25
+ if (typeof hasTailwind === 'boolean') {
26
+ utilsPackages.hasTailwind = vi.fn().mockReturnValue(hasTailwind);
27
+ }
28
+ if (typeof hasSass === 'boolean') {
29
+ utilsPackages.hasSass = vi.fn().mockReturnValue(hasSass);
30
+ }
31
+ if (typeof hasVue === 'boolean') {
32
+ utilsPackages.hasVue = vi.fn().mockReturnValue(hasVue);
33
+ }
34
+ }
35
+ };
36
+ };
@@ -1,11 +1,11 @@
1
- import type { Config } from 'stylelint';
2
- import postcssScss from 'postcss-scss';
3
-
4
- type OverrideSyntax = Config['overrides'] extends (infer T)[] | undefined
5
- ? T
6
- : never;
7
-
8
- export const syntaxScss: OverrideSyntax = {
9
- files: ['*.scss', '**/*.scss'],
10
- customSyntax: postcssScss,
11
- };
1
+ import type { Config } from 'stylelint';
2
+ import postcssScss from 'postcss-scss';
3
+
4
+ type OverrideSyntax = Config['overrides'] extends (infer T)[] | undefined
5
+ ? T
6
+ : never;
7
+
8
+ export const syntaxScss: OverrideSyntax = {
9
+ files: ['*.scss', '**/*.scss'],
10
+ customSyntax: postcssScss,
11
+ };