@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
@@ -1,55 +1,55 @@
1
- import { resolve } from 'node:path';
2
- import type { Config } from 'stylelint';
3
- import stylelint from 'stylelint';
4
- import type { Awaitable } from 'vitest';
5
- import { describe, expect, it } from 'vitest';
6
- import type { UtilsPackages } from './mock';
7
- import { defineMockUtilsPackages } from './mock';
8
-
9
- type LintAndFixCase = {
10
- code: string;
11
- fixedCode?: string;
12
- isError?: boolean;
13
- ext?: 'css' | 'scss' | 'vue';
14
- debug?: boolean;
15
- } & UtilsPackages;
16
-
17
- export const testLintAndFix = (
18
- getConfig: Config | (() => Awaitable<Config>),
19
- testCases: LintAndFixCase[],
20
- ) =>
21
- describe('test lint and fix', () => {
22
- const mockUtilsPackages = defineMockUtilsPackages(testCases);
23
-
24
- const name = [
25
- ...(['hasTailwind', 'hasSass', 'hasVue', 'isError'] as const) //
26
- .filter(field => testCases.some(t => typeof t[field] === 'boolean')),
27
- ...(['code', 'fixedCode'] as const) //
28
- .filter(field => testCases.some(t => typeof t[field] === 'string')),
29
- ]
30
- .map(field => `${field} = $${field}`)
31
- .join(', ');
32
-
33
- it.each(testCases)(name, async options => {
34
- await mockUtilsPackages(options);
35
-
36
- const config =
37
- typeof getConfig === 'function' ? await getConfig() : getConfig;
38
- const result = await stylelint.lint({
39
- code: options.code,
40
- codeFilename: `filename.${options.ext ?? 'css'}`,
41
- config,
42
- fix: 'fixedCode' in options,
43
- configBasedir: resolve(__dirname, '..'),
44
- });
45
-
46
- if (options.debug) {
47
- /* eslint-disable no-console */
48
- console.log(result.results.flatMap(r => r.warnings));
49
- console.log(result.code);
50
- /* eslint-enable no-console */
51
- }
52
- if ('fixedCode' in options) expect(result.code).toBe(options.fixedCode);
53
- if ('isError' in options) expect(result.errored).toBe(options.isError);
54
- });
55
- });
1
+ import { resolve } from 'node:path';
2
+ import type { Config } from 'stylelint';
3
+ import stylelint from 'stylelint';
4
+ import type { Awaitable } from 'vitest';
5
+ import { describe, expect, it } from 'vitest';
6
+ import type { UtilsPackages } from './mock';
7
+ import { defineMockUtilsPackages } from './mock';
8
+
9
+ type LintAndFixCase = {
10
+ code: string;
11
+ fixedCode?: string;
12
+ isError?: boolean;
13
+ ext?: 'css' | 'scss' | 'vue';
14
+ debug?: boolean;
15
+ } & UtilsPackages;
16
+
17
+ export const testLintAndFix = (
18
+ getConfig: Config | (() => Awaitable<Config>),
19
+ testCases: LintAndFixCase[],
20
+ ) =>
21
+ describe('test lint and fix', () => {
22
+ const mockUtilsPackages = defineMockUtilsPackages(testCases);
23
+
24
+ const name = [
25
+ ...(['hasTailwind', 'hasSass', 'hasVue', 'isError'] as const) //
26
+ .filter(field => testCases.some(t => typeof t[field] === 'boolean')),
27
+ ...(['code', 'fixedCode'] as const) //
28
+ .filter(field => testCases.some(t => typeof t[field] === 'string')),
29
+ ]
30
+ .map(field => `${field} = $${field}`)
31
+ .join(', ');
32
+
33
+ it.each(testCases)(name, async options => {
34
+ await mockUtilsPackages(options);
35
+
36
+ const config =
37
+ typeof getConfig === 'function' ? await getConfig() : getConfig;
38
+ const result = await stylelint.lint({
39
+ code: options.code,
40
+ codeFilename: `filename.${options.ext ?? 'css'}`,
41
+ config,
42
+ fix: 'fixedCode' in options,
43
+ configBasedir: resolve(__dirname, '..'),
44
+ });
45
+
46
+ if (options.debug) {
47
+ /* eslint-disable no-console */
48
+ console.log(result.results.flatMap(r => r.warnings));
49
+ console.log(result.code);
50
+ /* eslint-enable no-console */
51
+ }
52
+ if ('fixedCode' in options) expect(result.code).toBe(options.fixedCode);
53
+ if ('isError' in options) expect(result.errored).toBe(options.isError);
54
+ });
55
+ });
@@ -1,68 +1,68 @@
1
- import type { Awaitable } from 'vitest';
2
- import { describe, it } from 'vitest';
3
- import type { Config, ConfigRuleSettings } from 'stylelint';
4
- import type { UtilsPackages } from './mock';
5
- import { defineMockUtilsPackages } from './mock';
6
-
7
- import type {
8
- ConfigRulePrimaryOption,
9
- ConfigRuleSecondaryOptions,
10
- } from '~/utils';
11
-
12
- type TArgs<TOptions extends object, TRuleOrConfig> = [
13
- getRuleOrConfig: (() => Awaitable<TRuleOrConfig>) | TRuleOrConfig,
14
- fn: (
15
- ruleOrConfig: TRuleOrConfig,
16
- options: UtilsPackages & TOptions,
17
- ) => Promise<void> | void,
18
- ];
19
-
20
- const testRuleOrConfigValue = <
21
- TBaseRuleOrConfig extends
22
- | ConfigRuleSettings<ConfigRulePrimaryOption, ConfigRuleSecondaryOptions>
23
- | Config,
24
- >(
25
- ruleOrConfig: 'rule' | 'config',
26
- ) => {
27
- return <
28
- TCase extends UtilsPackages & object,
29
- TRuleOrConfig extends TBaseRuleOrConfig,
30
- >(
31
- ...args:
32
- | [testCases: TCase[], ...TArgs<TCase, TRuleOrConfig>]
33
- | [...TArgs<TCase, TRuleOrConfig>]
34
- ) => {
35
- describe(ruleOrConfig, () => {
36
- const [testCases, getRuleOrConfig, fn] =
37
- args.length === 3
38
- ? [...args]
39
- : [[{} as UtilsPackages & TCase], ...args];
40
-
41
- const mockUtilsPackages = defineMockUtilsPackages(testCases);
42
-
43
- const name = (['hasTailwind', 'hasSass', 'hasVue'] as const)
44
- .filter(field => testCases.some(t => typeof t[field] === 'boolean'))
45
- .map(field => `${field} = $${field}`)
46
- .join(', ');
47
-
48
- it.each(testCases)(name, async options => {
49
- await mockUtilsPackages(options);
50
-
51
- const ruleOrConfig =
52
- typeof getRuleOrConfig === 'function'
53
- ? await getRuleOrConfig()
54
- : getRuleOrConfig;
55
-
56
- await fn(ruleOrConfig, options);
57
- });
58
- });
59
- };
60
- };
61
-
62
- export const testConfigValue = testRuleOrConfigValue<Config>('config');
63
- export const testRuleValue = testRuleOrConfigValue<
64
- ConfigRuleSettings<
65
- ConfigRulePrimaryOption, //
66
- ConfigRuleSecondaryOptions
67
- >
68
- >('rule');
1
+ import type { Awaitable } from 'vitest';
2
+ import { describe, it } from 'vitest';
3
+ import type { Config, ConfigRuleSettings } from 'stylelint';
4
+ import type { UtilsPackages } from './mock';
5
+ import { defineMockUtilsPackages } from './mock';
6
+
7
+ import type {
8
+ ConfigRulePrimaryOption,
9
+ ConfigRuleSecondaryOptions,
10
+ } from '~/utils';
11
+
12
+ type TArgs<TOptions extends object, TRuleOrConfig> = [
13
+ getRuleOrConfig: (() => Awaitable<TRuleOrConfig>) | TRuleOrConfig,
14
+ fn: (
15
+ ruleOrConfig: TRuleOrConfig,
16
+ options: UtilsPackages & TOptions,
17
+ ) => Promise<void> | void,
18
+ ];
19
+
20
+ const testRuleOrConfigValue = <
21
+ TBaseRuleOrConfig extends
22
+ | ConfigRuleSettings<ConfigRulePrimaryOption, ConfigRuleSecondaryOptions>
23
+ | Config,
24
+ >(
25
+ ruleOrConfig: 'rule' | 'config',
26
+ ) => {
27
+ return <
28
+ TCase extends UtilsPackages & object,
29
+ TRuleOrConfig extends TBaseRuleOrConfig,
30
+ >(
31
+ ...args:
32
+ | [testCases: TCase[], ...TArgs<TCase, TRuleOrConfig>]
33
+ | [...TArgs<TCase, TRuleOrConfig>]
34
+ ) => {
35
+ describe(ruleOrConfig, () => {
36
+ const [testCases, getRuleOrConfig, fn] =
37
+ args.length === 3
38
+ ? [...args]
39
+ : [[{} as UtilsPackages & TCase], ...args];
40
+
41
+ const mockUtilsPackages = defineMockUtilsPackages(testCases);
42
+
43
+ const name = (['hasTailwind', 'hasSass', 'hasVue'] as const)
44
+ .filter(field => testCases.some(t => typeof t[field] === 'boolean'))
45
+ .map(field => `${field} = $${field}`)
46
+ .join(', ');
47
+
48
+ it.each(testCases)(name, async options => {
49
+ await mockUtilsPackages(options);
50
+
51
+ const ruleOrConfig =
52
+ typeof getRuleOrConfig === 'function'
53
+ ? await getRuleOrConfig()
54
+ : getRuleOrConfig;
55
+
56
+ await fn(ruleOrConfig, options);
57
+ });
58
+ });
59
+ };
60
+ };
61
+
62
+ export const testConfigValue = testRuleOrConfigValue<Config>('config');
63
+ export const testRuleValue = testRuleOrConfigValue<
64
+ ConfigRuleSettings<
65
+ ConfigRulePrimaryOption, //
66
+ ConfigRuleSecondaryOptions
67
+ >
68
+ >('rule');
@@ -1,10 +1,10 @@
1
- import { assert, describe } from 'vitest';
2
- import { configCss } from './css';
3
- import { testConfigValue } from '~/__tests__';
4
-
5
- describe('css config', () => {
6
- testConfigValue(configCss, config => {
7
- assert(Array.isArray(config.extends));
8
- assert(Array.isArray(config.plugins));
9
- });
10
- });
1
+ import { assert, describe } from 'vitest';
2
+ import { configCss } from './css';
3
+ import { testConfigValue } from '~/__tests__';
4
+
5
+ describe('css config', () => {
6
+ testConfigValue(configCss, config => {
7
+ assert(Array.isArray(config.extends));
8
+ assert(Array.isArray(config.plugins));
9
+ });
10
+ });
@@ -1,16 +1,16 @@
1
- import type { Config } from 'stylelint';
2
- import { atRuleNoUnknownCSS } from '~/rules/at-rule-no-unknown';
3
- import { declarationBlockNoRedundantLonghandProperties } from '~/rules/declaration-block-no-redundant-longhand-properties';
4
- import { functionNoUnknown } from '~/rules/function-no-unknown';
5
- import { order } from '~/rules/order';
6
-
7
- export const configCss = (): Config => ({
8
- extends: ['stylelint-config-standard', 'stylelint-config-clean-order'],
9
- plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],
10
- rules: {
11
- ...atRuleNoUnknownCSS(),
12
- ...declarationBlockNoRedundantLonghandProperties,
13
- ...functionNoUnknown(),
14
- ...order(),
15
- },
16
- });
1
+ import type { Config } from 'stylelint';
2
+ import { atRuleNoUnknownCSS } from '~/rules/at-rule-no-unknown';
3
+ import { declarationBlockNoRedundantLonghandProperties } from '~/rules/declaration-block-no-redundant-longhand-properties';
4
+ import { functionNoUnknown } from '~/rules/function-no-unknown';
5
+ import { order } from '~/rules/order';
6
+
7
+ export const configCss = (): Config => ({
8
+ extends: ['stylelint-config-standard', 'stylelint-config-clean-order'],
9
+ plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'],
10
+ rules: {
11
+ ...atRuleNoUnknownCSS(),
12
+ ...declarationBlockNoRedundantLonghandProperties,
13
+ ...functionNoUnknown(),
14
+ ...order(),
15
+ },
16
+ });
@@ -1,9 +1,9 @@
1
- import { assert, describe } from 'vitest';
2
- import { configScss } from './scss';
3
- import { testConfigValue } from '~/__tests__';
4
-
5
- describe('scss config', () => {
6
- testConfigValue(configScss, config => {
7
- assert(Array.isArray(config.extends));
8
- });
9
- });
1
+ import { assert, describe } from 'vitest';
2
+ import { configScss } from './scss';
3
+ import { testConfigValue } from '~/__tests__';
4
+
5
+ describe('scss config', () => {
6
+ testConfigValue(configScss, config => {
7
+ assert(Array.isArray(config.extends));
8
+ });
9
+ });
@@ -1,11 +1,11 @@
1
- import type { Config } from 'stylelint';
2
- import { atRuleNoUnknownSCSS } from '~/rules/at-rule-no-unknown';
3
- import { dollarVariablePatternSCSS } from '~/rules/dollar-variable-pattern';
4
-
5
- export const configScss = (): Config => ({
6
- extends: ['stylelint-config-standard-scss'],
7
- rules: {
8
- ...atRuleNoUnknownSCSS(),
9
- ...dollarVariablePatternSCSS,
10
- },
11
- });
1
+ import type { Config } from 'stylelint';
2
+ import { atRuleNoUnknownSCSS } from '~/rules/at-rule-no-unknown';
3
+ import { dollarVariablePatternSCSS } from '~/rules/dollar-variable-pattern';
4
+
5
+ export const configScss = (): Config => ({
6
+ extends: ['stylelint-config-standard-scss'],
7
+ rules: {
8
+ ...atRuleNoUnknownSCSS(),
9
+ ...dollarVariablePatternSCSS,
10
+ },
11
+ });
@@ -1,9 +1,9 @@
1
- import { assert, describe } from 'vitest';
2
- import { configShared } from './shared';
3
- import { testConfigValue } from '~/__tests__';
4
-
5
- describe('shared config', () => {
6
- testConfigValue(configShared, config => {
7
- assert(Array.isArray(config.extends));
8
- });
9
- });
1
+ import { assert, describe } from 'vitest';
2
+ import { configShared } from './shared';
3
+ import { testConfigValue } from '~/__tests__';
4
+
5
+ describe('shared config', () => {
6
+ testConfigValue(configShared, config => {
7
+ assert(Array.isArray(config.extends));
8
+ });
9
+ });
@@ -1,5 +1,5 @@
1
- import type { Config } from 'stylelint';
2
-
3
- export const configShared = (): Config => ({
4
- extends: ['stylelint-config-html'],
5
- });
1
+ import type { Config } from 'stylelint';
2
+
3
+ export const configShared = (): Config => ({
4
+ extends: ['stylelint-config-html'],
5
+ });
@@ -1,18 +1,18 @@
1
- import { assert, describe } from 'vitest';
2
- import { configVue } from './vue';
3
- import { testConfigValue } from '~/__tests__';
4
-
5
- describe('vue config', () => {
6
- testConfigValue(
7
- [{ hasSass: true }, { hasSass: false }],
8
- configVue,
9
- (config, options) => {
10
- assert(Array.isArray(config.extends));
11
- config.extends.includes(
12
- options.hasSass
13
- ? 'stylelint-config-standard-vue/scss'
14
- : 'stylelint-config-standard-vue',
15
- );
16
- },
17
- );
18
- });
1
+ import { assert, describe } from 'vitest';
2
+ import { configVue } from './vue';
3
+ import { testConfigValue } from '~/__tests__';
4
+
5
+ describe('vue config', () => {
6
+ testConfigValue(
7
+ [{ hasSass: true }, { hasSass: false }],
8
+ configVue,
9
+ (config, options) => {
10
+ assert(Array.isArray(config.extends));
11
+ config.extends.includes(
12
+ options.hasSass
13
+ ? 'stylelint-config-standard-vue/scss'
14
+ : 'stylelint-config-standard-vue',
15
+ );
16
+ },
17
+ );
18
+ });
@@ -1,10 +1,10 @@
1
- import { hasSass } from '@culur/utils-packages';
2
- import type { Config } from 'stylelint';
3
-
4
- export const configVue = (): Config => ({
5
- extends: [
6
- hasSass()
7
- ? 'stylelint-config-standard-vue/scss'
8
- : 'stylelint-config-standard-vue',
9
- ],
10
- });
1
+ import { hasSass } from '@culur/utils-packages';
2
+ import type { Config } from 'stylelint';
3
+
4
+ export const configVue = (): Config => ({
5
+ extends: [
6
+ hasSass()
7
+ ? 'stylelint-config-standard-vue/scss'
8
+ : 'stylelint-config-standard-vue',
9
+ ],
10
+ });
@@ -1,15 +1,15 @@
1
- import { css, testLintAndFix } from './__tests__';
2
- import defineConfig from './factory';
3
-
4
- testLintAndFix(defineConfig, [
5
- {
6
- code: css`
7
- a {
8
- color: red;
9
- }
10
- `,
11
- hasSass: true,
12
- hasVue: true,
13
- isError: false,
14
- },
15
- ]);
1
+ import { css, testLintAndFix } from './__tests__';
2
+ import defineConfig from './factory';
3
+
4
+ testLintAndFix(defineConfig, [
5
+ {
6
+ code: css`
7
+ a {
8
+ color: red;
9
+ }
10
+ `,
11
+ hasSass: true,
12
+ hasVue: true,
13
+ isError: false,
14
+ },
15
+ ]);
package/src/factory.ts CHANGED
@@ -1,23 +1,23 @@
1
- import type { Packages } from '@culur/utils-packages';
2
- import { hasSass, hasVue, updateDefaultPackages } from '@culur/utils-packages';
3
- import type { Config } from 'stylelint';
4
- import { configCss } from './configs/css';
5
- import { configScss } from './configs/scss';
6
- import { configShared } from './configs/shared';
7
- import { configVue } from './configs/vue';
8
- import { mergeConfigs } from './utils';
9
-
10
- export default function defineConfig(
11
- options?: Partial<Packages>,
12
- config?: Config,
13
- ): Config {
14
- updateDefaultPackages(options);
15
-
16
- return mergeConfigs(
17
- configShared(),
18
- configCss(),
19
- hasSass() && configScss(),
20
- hasVue() && configVue(),
21
- config,
22
- );
23
- }
1
+ import type { Packages } from '@culur/utils-packages';
2
+ import { hasSass, hasVue, updateDefaultPackages } from '@culur/utils-packages';
3
+ import type { Config } from 'stylelint';
4
+ import { configCss } from './configs/css';
5
+ import { configScss } from './configs/scss';
6
+ import { configShared } from './configs/shared';
7
+ import { configVue } from './configs/vue';
8
+ import { mergeConfigs } from './utils';
9
+
10
+ export default function defineConfig(
11
+ options?: Partial<Packages>,
12
+ config?: Config,
13
+ ): Config {
14
+ updateDefaultPackages(options);
15
+
16
+ return mergeConfigs(
17
+ configShared(),
18
+ configCss(),
19
+ hasSass() && configScss(),
20
+ hasVue() && configVue(),
21
+ config,
22
+ );
23
+ }
package/src/index.test.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { describe, expectTypeOf, it } from 'vitest';
2
- import type { Config } from 'stylelint';
3
- import defineConfig from '.';
4
-
5
- describe('index', () => {
6
- it('root config', () => {
7
- expectTypeOf(defineConfig).toEqualTypeOf<Config>();
8
- });
9
- });
1
+ import { describe, expectTypeOf, it } from 'vitest';
2
+ import type { Config } from 'stylelint';
3
+ import defineConfig from '.';
4
+
5
+ describe('index', () => {
6
+ it('root config', () => {
7
+ expectTypeOf(defineConfig).toEqualTypeOf<Config>();
8
+ });
9
+ });
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- import defineConfig from './factory';
2
-
3
- export default defineConfig();
1
+ import defineConfig from './factory';
2
+
3
+ export default defineConfig();
@@ -1,43 +1,43 @@
1
- import { assert, expect } from 'vitest';
2
- import { syntaxScss, testLintAndFix } from '~/__tests__';
3
- import { testRuleValue } from '~/__tests__/test-rule-or-config-value';
4
-
5
- testRuleValue(
6
- [
7
- { hasTailwind: false, length: 0 },
8
- { hasTailwind: true, length: 7 },
9
- ],
10
- async () => {
11
- const module = await import('./at-rule-no-unknown');
12
- return module.atRuleNoUnknownRule();
13
- },
14
- (rule, options) => {
15
- assert(Array.isArray(rule));
16
- assert(typeof rule[1] === 'object');
17
- expect(rule[1].ignoreAtRules).toHaveLength(options.length);
18
- },
19
- );
20
-
21
- testLintAndFix(async () => {
22
- const module = await import('./at-rule-no-unknown');
23
- return {
24
- rules: module.atRuleNoUnknownCSS(),
25
- };
26
- }, [
27
- { hasTailwind: false, code: '@unknown {}', isError: true },
28
- { hasTailwind: false, code: '@media {}', isError: false },
29
- { hasTailwind: true, code: '@tailwind {}', isError: false },
30
- ]);
31
-
32
- testLintAndFix(async () => {
33
- const module = await import('./at-rule-no-unknown');
34
- return {
35
- plugins: ['stylelint-scss'],
36
- rules: module.atRuleNoUnknownSCSS(),
37
- overrides: [syntaxScss],
38
- };
39
- }, [
40
- { ext: 'scss', hasTailwind: false, code: '@unknown {}', isError: true },
41
- { ext: 'scss', hasTailwind: false, code: '@media {}', isError: false },
42
- { ext: 'scss', hasTailwind: true, code: '@tailwind {}', isError: false },
43
- ]);
1
+ import { assert, expect } from 'vitest';
2
+ import { syntaxScss, testLintAndFix } from '~/__tests__';
3
+ import { testRuleValue } from '~/__tests__/test-rule-or-config-value';
4
+
5
+ testRuleValue(
6
+ [
7
+ { hasTailwind: false, length: 0 },
8
+ { hasTailwind: true, length: 7 },
9
+ ],
10
+ async () => {
11
+ const module = await import('./at-rule-no-unknown');
12
+ return module.atRuleNoUnknownRule();
13
+ },
14
+ (rule, options) => {
15
+ assert(Array.isArray(rule));
16
+ assert(typeof rule[1] === 'object');
17
+ expect(rule[1].ignoreAtRules).toHaveLength(options.length);
18
+ },
19
+ );
20
+
21
+ testLintAndFix(async () => {
22
+ const module = await import('./at-rule-no-unknown');
23
+ return {
24
+ rules: module.atRuleNoUnknownCSS(),
25
+ };
26
+ }, [
27
+ { hasTailwind: false, code: '@unknown {}', isError: true },
28
+ { hasTailwind: false, code: '@media {}', isError: false },
29
+ { hasTailwind: true, code: '@tailwind {}', isError: false },
30
+ ]);
31
+
32
+ testLintAndFix(async () => {
33
+ const module = await import('./at-rule-no-unknown');
34
+ return {
35
+ plugins: ['stylelint-scss'],
36
+ rules: module.atRuleNoUnknownSCSS(),
37
+ overrides: [syntaxScss],
38
+ };
39
+ }, [
40
+ { ext: 'scss', hasTailwind: false, code: '@unknown {}', isError: true },
41
+ { ext: 'scss', hasTailwind: false, code: '@media {}', isError: false },
42
+ { ext: 'scss', hasTailwind: true, code: '@tailwind {}', isError: false },
43
+ ]);