@culur/config-stylelint 1.1.0 → 1.2.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 (31) hide show
  1. package/.stylelintignore +71 -0
  2. package/CHANGELOG.md +34 -0
  3. package/LICENSE +21 -0
  4. package/README.md +3 -0
  5. package/dist/{magic-string.es-KHKLXHFY.js → magic-string.es-UBX3LPHW.js} +67 -53
  6. package/dist/magic-string.es-UBX3LPHW.js.map +1 -0
  7. package/dist/{magic-string.es-Y5KWYA2U.cjs → magic-string.es-WYIO6UMX.cjs} +67 -53
  8. package/dist/magic-string.es-WYIO6UMX.cjs.map +1 -0
  9. package/package.json +15 -24
  10. package/src/__tests__/describe-lint-and-fix.ts +3 -3
  11. package/src/__tests__/syntax.ts +1 -1
  12. package/dist/magic-string.es-KHKLXHFY.js.map +0 -1
  13. package/dist/magic-string.es-Y5KWYA2U.cjs.map +0 -1
  14. package/dist/shareable-configs/shareable-configs.test.cjs +0 -15579
  15. package/dist/shareable-configs/shareable-configs.test.cjs.map +0 -1
  16. package/dist/shareable-configs/shareable-configs.test.d.cts +0 -2
  17. package/dist/shareable-configs/shareable-configs.test.d.ts +0 -2
  18. package/dist/shareable-configs/shareable-configs.test.js +0 -15577
  19. package/dist/shareable-configs/shareable-configs.test.js.map +0 -1
  20. package/src/configs/css.test.ts +0 -8
  21. package/src/configs/scss.test.ts +0 -7
  22. package/src/configs/shared.test.ts +0 -7
  23. package/src/configs/vue.test.ts +0 -17
  24. package/src/factory.test.ts +0 -30
  25. package/src/rules/at-rule-no-unknown.test.ts +0 -42
  26. package/src/rules/declaration-block-no-redundant-longhand-properties.test.ts +0 -36
  27. package/src/rules/dollar-variable-pattern.test.ts +0 -27
  28. package/src/rules/function-no-unknown.test.ts +0 -40
  29. package/src/rules/order.test.ts +0 -44
  30. package/src/shareable-configs/shareable-configs.test.ts +0 -21
  31. package/src/utils/utils.test.ts +0 -46
@@ -1,8 +0,0 @@
1
- import { assert } from 'vitest';
2
- import { configCss } from './css';
3
- import { describeConfig } from '~/__tests__';
4
-
5
- describeConfig(configCss, config => {
6
- assert(Array.isArray(config.extends));
7
- assert(Array.isArray(config.plugins));
8
- });
@@ -1,7 +0,0 @@
1
- import { assert } from 'vitest';
2
- import { configScss } from './scss';
3
- import { describeConfig } from '~/__tests__';
4
-
5
- describeConfig(configScss, config => {
6
- assert(Array.isArray(config.extends));
7
- });
@@ -1,7 +0,0 @@
1
- import { assert } from 'vitest';
2
- import { configShared } from './shared';
3
- import { describeConfig } from '~/__tests__';
4
-
5
- describeConfig(configShared, config => {
6
- assert(Array.isArray(config.extends));
7
- });
@@ -1,17 +0,0 @@
1
- import { assert } from 'vitest';
2
- import { configVue } from './vue';
3
- import { describeConfig } from '~/__tests__';
4
-
5
- describeConfig(
6
- configVue,
7
- [{ sass: true }, { sass: false }],
8
- (config, testCase) => {
9
- assert(Array.isArray(config.extends));
10
- assert(Array.isArray(config.extends));
11
- config.extends.includes(
12
- testCase.sass
13
- ? 'stylelint-config-standard-vue/scss'
14
- : 'stylelint-config-standard-vue',
15
- );
16
- },
17
- );
@@ -1,30 +0,0 @@
1
- import { css, describeLintAndFix } from './__tests__';
2
- import defineConfig from './factory';
3
-
4
- describeLintAndFix(
5
- () => defineConfig({ vue: true, sass: true }),
6
- [
7
- {
8
- code: css`
9
- a {
10
- color: red;
11
- }
12
- `,
13
- isError: false,
14
- },
15
- ],
16
- );
17
-
18
- describeLintAndFix(
19
- () => defineConfig(),
20
- [
21
- {
22
- code: css`
23
- a {
24
- color: red;
25
- }
26
- `,
27
- isError: false,
28
- },
29
- ],
30
- );
@@ -1,42 +0,0 @@
1
- import { assert, expect } from 'vitest';
2
- import {
3
- atRuleNoUnknownCSS,
4
- atRuleNoUnknownRule,
5
- atRuleNoUnknownSCSS,
6
- } from './at-rule-no-unknown';
7
- import { describeLintAndFix, describeRule, syntaxScss } from '~/__tests__';
8
-
9
- describeRule(
10
- atRuleNoUnknownRule,
11
- [
12
- { tailwind: false, length: 0 },
13
- { tailwind: true, length: 7 },
14
- ],
15
- (rule, testCase) => {
16
- assert(Array.isArray(rule));
17
- assert(typeof rule[1] === 'object');
18
- expect(rule[1].ignoreAtRules).toHaveLength(testCase.length);
19
- },
20
- );
21
-
22
- describeLintAndFix(
23
- o => ({ rules: atRuleNoUnknownCSS(o) }),
24
- [
25
- { tailwind: false, code: '@unknown {}', isError: true },
26
- { tailwind: false, code: '@media {}', isError: false },
27
- { tailwind: true, code: '@tailwind {}', isError: false },
28
- ],
29
- );
30
-
31
- describeLintAndFix(
32
- o => ({
33
- plugins: ['stylelint-scss'],
34
- rules: atRuleNoUnknownSCSS(o),
35
- overrides: [syntaxScss],
36
- }),
37
- [
38
- { ext: 'scss', tailwind: false, code: '@unknown {}', isError: true },
39
- { ext: 'scss', tailwind: false, code: '@media {}', isError: false },
40
- { ext: 'scss', tailwind: true, code: '@tailwind {}', isError: false },
41
- ],
42
- );
@@ -1,36 +0,0 @@
1
- import { assert, expect } from 'vitest';
2
- import {
3
- declarationBlockNoRedundantLonghandProperties,
4
- declarationBlockNoRedundantLonghandPropertiesRule,
5
- } from './declaration-block-no-redundant-longhand-properties';
6
- import { css, describeLintAndFix, describeRule } from '~/__tests__';
7
-
8
- describeRule(
9
- declarationBlockNoRedundantLonghandPropertiesRule, //
10
- rule => {
11
- assert(Array.isArray(rule));
12
- assert(typeof rule[1] === 'object');
13
- expect(rule[1].ignoreShorthands).toHaveLength(1);
14
- },
15
- );
16
-
17
- describeLintAndFix(
18
- { rules: declarationBlockNoRedundantLonghandProperties }, //
19
- [
20
- {
21
- code: css`
22
- a {
23
- margin-top: 1px;
24
- margin-right: 2px;
25
- margin-bottom: 3px;
26
- margin-left: 4px;
27
- }
28
- `,
29
- fixedCode: css`
30
- a {
31
- margin: 1px 2px 3px 4px;
32
- }
33
- `,
34
- },
35
- ],
36
- );
@@ -1,27 +0,0 @@
1
- import { assert, expectTypeOf } from 'vitest';
2
- import {
3
- dollarVariablePatternRule,
4
- dollarVariablePatternSCSS,
5
- } from './dollar-variable-pattern';
6
- import { describeLintAndFix, describeRule, scss } from '~/__tests__';
7
-
8
- describeRule(
9
- dollarVariablePatternRule, //
10
- rule => {
11
- assert(Array.isArray(rule));
12
- assert(typeof rule[1] === 'object');
13
- expectTypeOf(rule[1].message).toBeString();
14
- },
15
- );
16
-
17
- describeLintAndFix(
18
- {
19
- extends: ['stylelint-config-standard-scss'],
20
- rules: dollarVariablePatternSCSS,
21
- },
22
- [
23
- { isError: false, code: scss`a { $kebab-case: 123; }` },
24
- { isError: true, code: scss`a { $snake_case: 123; }` },
25
- { isError: true, code: scss`a { $camelCase: 123; }` },
26
- ],
27
- );
@@ -1,40 +0,0 @@
1
- import { assert, expect } from 'vitest';
2
- import {
3
- functionNoUnknown,
4
- functionNoUnknownRule,
5
- } from './function-no-unknown';
6
- import { describeLintAndFix, describeRule } from '~/__tests__';
7
-
8
- describeRule(
9
- functionNoUnknownRule,
10
- [
11
- { tailwind: true, sass: false, vue: false, length: 2 },
12
- { tailwind: false, sass: true, vue: false, length: 1 },
13
- { tailwind: false, sass: false, vue: true, length: 1 },
14
- ],
15
- (rule, options) => {
16
- assert(Array.isArray(rule));
17
- assert(typeof rule[1] === 'object');
18
- expect(rule[1].ignoreFunctions).toHaveLength(options.length);
19
- },
20
- );
21
-
22
- describeLintAndFix(
23
- o => ({ rules: functionNoUnknown(o) }),
24
- [
25
- {
26
- isError: true,
27
- code: 'a { color: unknown(1); }',
28
- },
29
- {
30
- tailwind: true,
31
- isError: false,
32
- code: 'a { color: theme(colors.blue.500); }',
33
- },
34
- {
35
- vue: true,
36
- isError: false,
37
- code: 'a { color: v-bind(colors); }',
38
- },
39
- ],
40
- );
@@ -1,44 +0,0 @@
1
- import { assert, expect } from 'vitest';
2
- import { order, orderRule } from './order';
3
- import { describeLintAndFix, describeRule, scss } from '~/__tests__';
4
-
5
- describeRule(
6
- orderRule,
7
- [
8
- { tailwind: false, sass: false, length: 8 },
9
- { tailwind: true, sass: false, length: 15 },
10
- { tailwind: false, sass: true, length: 16 },
11
- { tailwind: true, sass: true, length: 23 },
12
- ],
13
- (rule, testCase) => {
14
- assert(Array.isArray(rule));
15
-
16
- assert(Array.isArray(rule[0]));
17
- expect(rule[0]).toHaveLength(testCase.length);
18
-
19
- assert(typeof rule[1] === 'object');
20
- expect(rule[1]).toStrictEqual({ unspecified: 'bottom' });
21
- },
22
- );
23
-
24
- describeLintAndFix(
25
- o => ({
26
- plugins: ['stylelint-order'],
27
- rules: order(o),
28
- }),
29
- [
30
- {
31
- tailwind: false,
32
- sass: false,
33
- code: scss`
34
- a {
35
- $variable: 1px;
36
- --property: 3px;
37
- @variable: 2px;
38
- width: 4px;
39
- }
40
- `,
41
- isError: false,
42
- },
43
- ],
44
- );
@@ -1,21 +0,0 @@
1
- import { expectTypeOf, it } from 'vitest';
2
- import type { Config } from 'stylelint';
3
- import autoConfig from './auto';
4
- import noneConfig from './none';
5
- import sassVueConfig from './sass-vue';
6
- import sassConfig from './sass';
7
- import tailwindSassVueConfig from './tailwind-sass-vue';
8
- import tailwindSassConfig from './tailwind-sass';
9
- import tailwindConfig from './tailwind';
10
- import vueConfig from './vue';
11
-
12
- it('shareable configs', () => {
13
- expectTypeOf(autoConfig).toEqualTypeOf<Config>();
14
- expectTypeOf(noneConfig).toEqualTypeOf<Config>();
15
- expectTypeOf(sassVueConfig).toEqualTypeOf<Config>();
16
- expectTypeOf(sassConfig).toEqualTypeOf<Config>();
17
- expectTypeOf(tailwindSassVueConfig).toEqualTypeOf<Config>();
18
- expectTypeOf(tailwindSassConfig).toEqualTypeOf<Config>();
19
- expectTypeOf(tailwindConfig).toEqualTypeOf<Config>();
20
- expectTypeOf(vueConfig).toEqualTypeOf<Config>();
21
- });
@@ -1,46 +0,0 @@
1
- import { assert, describe, expect, expectTypeOf, it } from 'vitest';
2
- import { defineRule, defineRules, mergeConfigs } from './utils';
3
-
4
- describe('rules', () => {
5
- it('defineRule & rules', () => {
6
- type PrimaryOption = true;
7
- interface SecondaryOptions {
8
- ignore: ['comments'];
9
- }
10
-
11
- const blockNoEmptyRule = defineRule<PrimaryOption, SecondaryOptions>([
12
- true,
13
- { ignore: ['comments'] },
14
- ]);
15
- const blockNoEmpty = defineRules({ 'block-no-empty': blockNoEmptyRule });
16
-
17
- assert(Array.isArray(blockNoEmptyRule));
18
- expectTypeOf(blockNoEmpty).toBeObject();
19
- });
20
- });
21
-
22
- describe('merge configs', () => {
23
- it('should merge plugins', () => {
24
- const mergedConfigs = mergeConfigs(
25
- { plugins: ['plugin-a'] }, //
26
- { plugins: ['plugin-b'] },
27
- { plugins: [] },
28
- {},
29
- );
30
-
31
- assert(Array.isArray(mergedConfigs.plugins));
32
- expect(mergedConfigs.plugins).toHaveLength(2);
33
- });
34
-
35
- it('should merge overrides', () => {
36
- const mergedConfigs = mergeConfigs(
37
- { overrides: [{ files: 'a.css' }] },
38
- { overrides: [{ files: 'b.css' }] },
39
- { overrides: [] },
40
- {},
41
- );
42
-
43
- assert(Array.isArray(mergedConfigs.overrides));
44
- expect(mergedConfigs.overrides).toHaveLength(2);
45
- });
46
- });