@breadstone-infrastructure/token-linter 0.0.231
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.
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/cli/Cli.d.ts +10 -0
- package/cli/Cli.d.ts.map +1 -0
- package/cli/Cli.js +32 -0
- package/cli/Cli.js.map +1 -0
- package/cli/CliArgs.d.ts +2 -0
- package/cli/CliArgs.d.ts.map +1 -0
- package/cli/CliArgs.js +88 -0
- package/cli/CliArgs.js.map +1 -0
- package/cli/CliArgsConfig.d.ts +2 -0
- package/cli/CliArgsConfig.d.ts.map +1 -0
- package/cli/CliArgsConfig.js +12 -0
- package/cli/CliArgsConfig.js.map +1 -0
- package/cli/CliRun.d.ts +2 -0
- package/cli/CliRun.d.ts.map +1 -0
- package/cli/CliRun.js +34 -0
- package/cli/CliRun.js.map +1 -0
- package/cli/commands/LintCommand.d.ts +2 -0
- package/cli/commands/LintCommand.d.ts.map +1 -0
- package/cli/commands/LintCommand.js +66 -0
- package/cli/commands/LintCommand.js.map +1 -0
- package/cli/commands/LintCommandArgsConfig.d.ts +2 -0
- package/cli/commands/LintCommandArgsConfig.d.ts.map +1 -0
- package/cli/commands/LintCommandArgsConfig.js +46 -0
- package/cli/commands/LintCommandArgsConfig.js.map +1 -0
- package/cli/lint.d.ts +3 -0
- package/cli/lint.d.ts.map +1 -0
- package/cli/lint.js +55 -0
- package/cli/lint.js.map +1 -0
- package/config/TokenLinterConfigDiscovery.d.ts +16 -0
- package/config/TokenLinterConfigDiscovery.d.ts.map +1 -0
- package/config/TokenLinterConfigDiscovery.js +44 -0
- package/config/TokenLinterConfigDiscovery.js.map +1 -0
- package/config/defineConfig.d.ts +41 -0
- package/config/defineConfig.d.ts.map +1 -0
- package/config/defineConfig.js +37 -0
- package/config/defineConfig.js.map +1 -0
- package/core/interaction.d.ts +25 -0
- package/core/interaction.d.ts.map +1 -0
- package/core/interaction.js +45 -0
- package/core/interaction.js.map +1 -0
- package/core/loader.d.ts +21 -0
- package/core/loader.d.ts.map +1 -0
- package/core/loader.js +84 -0
- package/core/loader.js.map +1 -0
- package/core/rule-registry.d.ts +46 -0
- package/core/rule-registry.d.ts.map +1 -0
- package/core/rule-registry.js +73 -0
- package/core/rule-registry.js.map +1 -0
- package/core/rule.d.ts +46 -0
- package/core/rule.d.ts.map +1 -0
- package/core/rule.js +3 -0
- package/core/rule.js.map +1 -0
- package/core/runner.d.ts +23 -0
- package/core/runner.d.ts.map +1 -0
- package/core/runner.js +103 -0
- package/core/runner.js.map +1 -0
- package/index.d.ts +46 -0
- package/index.d.ts.map +1 -0
- package/index.js +47 -0
- package/index.js.map +1 -0
- package/models/lint-result.d.ts +14 -0
- package/models/lint-result.d.ts.map +1 -0
- package/models/lint-result.js +3 -0
- package/models/lint-result.js.map +1 -0
- package/models/rule-context.d.ts +18 -0
- package/models/rule-context.d.ts.map +1 -0
- package/models/rule-context.js +3 -0
- package/models/rule-context.js.map +1 -0
- package/models/rule-finding.d.ts +15 -0
- package/models/rule-finding.d.ts.map +1 -0
- package/models/rule-finding.js +3 -0
- package/models/rule-finding.js.map +1 -0
- package/models/rule-result.d.ts +11 -0
- package/models/rule-result.d.ts.map +1 -0
- package/models/rule-result.js +3 -0
- package/models/rule-result.js.map +1 -0
- package/models/rule-severity.d.ts +14 -0
- package/models/rule-severity.d.ts.map +1 -0
- package/models/rule-severity.js +10 -0
- package/models/rule-severity.js.map +1 -0
- package/models/token-entry.d.ts +11 -0
- package/models/token-entry.d.ts.map +1 -0
- package/models/token-entry.js +2 -0
- package/models/token-entry.js.map +1 -0
- package/models/token-linter-config.d.ts +30 -0
- package/models/token-linter-config.d.ts.map +1 -0
- package/models/token-linter-config.js +3 -0
- package/models/token-linter-config.js.map +1 -0
- package/orchestration/TokenLinterOrchestrator.d.ts +29 -0
- package/orchestration/TokenLinterOrchestrator.d.ts.map +1 -0
- package/orchestration/TokenLinterOrchestrator.js +98 -0
- package/orchestration/TokenLinterOrchestrator.js.map +1 -0
- package/package.json +20 -0
- package/presets/index.d.ts +2 -0
- package/presets/index.d.ts.map +1 -0
- package/presets/index.js +2 -0
- package/presets/index.js.map +1 -0
- package/presets/recommended.d.ts +23 -0
- package/presets/recommended.d.ts.map +1 -0
- package/presets/recommended.js +41 -0
- package/presets/recommended.js.map +1 -0
- package/reporters/console.reporter.d.ts +15 -0
- package/reporters/console.reporter.d.ts.map +1 -0
- package/reporters/console.reporter.js +75 -0
- package/reporters/console.reporter.js.map +1 -0
- package/reporters/json.reporter.d.ts +11 -0
- package/reporters/json.reporter.d.ts.map +1 -0
- package/reporters/json.reporter.js +37 -0
- package/reporters/json.reporter.js.map +1 -0
- package/reporters/reporter.d.ts +16 -0
- package/reporters/reporter.d.ts.map +1 -0
- package/reporters/reporter.js +3 -0
- package/reporters/reporter.js.map +1 -0
- package/reporters/summary.reporter.d.ts +12 -0
- package/reporters/summary.reporter.d.ts.map +1 -0
- package/reporters/summary.reporter.js +48 -0
- package/reporters/summary.reporter.js.map +1 -0
- package/rules/alphabetical-sort.rule.d.ts +19 -0
- package/rules/alphabetical-sort.rule.d.ts.map +1 -0
- package/rules/alphabetical-sort.rule.js +72 -0
- package/rules/alphabetical-sort.rule.js.map +1 -0
- package/rules/component-presence.rule.d.ts +29 -0
- package/rules/component-presence.rule.d.ts.map +1 -0
- package/rules/component-presence.rule.js +102 -0
- package/rules/component-presence.rule.js.map +1 -0
- package/rules/duplicate-value.rule.d.ts +17 -0
- package/rules/duplicate-value.rule.d.ts.map +1 -0
- package/rules/duplicate-value.rule.js +49 -0
- package/rules/duplicate-value.rule.js.map +1 -0
- package/rules/empty-json.rule.d.ts +52 -0
- package/rules/empty-json.rule.d.ts.map +1 -0
- package/rules/empty-json.rule.js +100 -0
- package/rules/empty-json.rule.js.map +1 -0
- package/rules/forbidden-key.rule.d.ts +57 -0
- package/rules/forbidden-key.rule.d.ts.map +1 -0
- package/rules/forbidden-key.rule.js +118 -0
- package/rules/forbidden-key.rule.js.map +1 -0
- package/rules/forbidden-value.rule.d.ts +53 -0
- package/rules/forbidden-value.rule.d.ts.map +1 -0
- package/rules/forbidden-value.rule.js +130 -0
- package/rules/forbidden-value.rule.js.map +1 -0
- package/rules/includes-consistency.rule.d.ts +30 -0
- package/rules/includes-consistency.rule.d.ts.map +1 -0
- package/rules/includes-consistency.rule.js +153 -0
- package/rules/includes-consistency.rule.js.map +1 -0
- package/rules/index.d.ts +7 -0
- package/rules/index.d.ts.map +1 -0
- package/rules/index.js +47 -0
- package/rules/index.js.map +1 -0
- package/rules/key-consistency.rule.d.ts +38 -0
- package/rules/key-consistency.rule.d.ts.map +1 -0
- package/rules/key-consistency.rule.js +161 -0
- package/rules/key-consistency.rule.js.map +1 -0
- package/rules/missing-includes.rule.d.ts +19 -0
- package/rules/missing-includes.rule.d.ts.map +1 -0
- package/rules/missing-includes.rule.js +51 -0
- package/rules/missing-includes.rule.js.map +1 -0
- package/rules/mixin-reference.rule.d.ts +28 -0
- package/rules/mixin-reference.rule.d.ts.map +1 -0
- package/rules/mixin-reference.rule.js +104 -0
- package/rules/mixin-reference.rule.js.map +1 -0
- package/rules/naming-convention.rule.d.ts +29 -0
- package/rules/naming-convention.rule.d.ts.map +1 -0
- package/rules/naming-convention.rule.js +112 -0
- package/rules/naming-convention.rule.js.map +1 -0
- package/rules/nested-depth.rule.d.ts +42 -0
- package/rules/nested-depth.rule.d.ts.map +1 -0
- package/rules/nested-depth.rule.js +72 -0
- package/rules/nested-depth.rule.js.map +1 -0
- package/rules/required-includes.rule.d.ts +60 -0
- package/rules/required-includes.rule.d.ts.map +1 -0
- package/rules/required-includes.rule.js +118 -0
- package/rules/required-includes.rule.js.map +1 -0
- package/rules/rule-options.d.ts +158 -0
- package/rules/rule-options.d.ts.map +1 -0
- package/rules/rule-options.js +89 -0
- package/rules/rule-options.js.map +1 -0
- package/rules/value-consistency.rule.d.ts +17 -0
- package/rules/value-consistency.rule.d.ts.map +1 -0
- package/rules/value-consistency.rule.js +69 -0
- package/rules/value-consistency.rule.js.map +1 -0
- package/rules/value-schema.rule.d.ts +18 -0
- package/rules/value-schema.rule.d.ts.map +1 -0
- package/rules/value-schema.rule.js +108 -0
- package/rules/value-schema.rule.js.map +1 -0
- package/rules/value-type.rule.d.ts +71 -0
- package/rules/value-type.rule.d.ts.map +1 -0
- package/rules/value-type.rule.js +176 -0
- package/rules/value-type.rule.js.map +1 -0
- package/utils.d.ts +55 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +125 -0
- package/utils.js.map +1 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { TokenValueType } from './value-type.rule.js';
|
|
2
|
+
/**
|
|
3
|
+
* @description Base constraint for rule option objects.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IRuleOptionValues {
|
|
7
|
+
readonly [key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @description Shape returned by every rule-options factory function.
|
|
11
|
+
* Maps the rule name to its typed options object.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export type IRuleOptionsEntry = Readonly<Record<string, Readonly<IRuleOptionValues>>>;
|
|
15
|
+
/**
|
|
16
|
+
* @description Options for the `empty-json` rule.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export interface IEmptyJsonRuleOptions extends IRuleOptionValues {
|
|
20
|
+
/**
|
|
21
|
+
* @description When `true`, files that contain only `$includes` (but no token keys) are not flagged.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
readonly allowIncludes?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @description Options for the `forbidden-key` rule.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export interface IForbiddenKeyRuleOptions extends IRuleOptionValues {
|
|
31
|
+
/**
|
|
32
|
+
* @description Keys that are forbidden in component token files. Overrides the built-in default list.
|
|
33
|
+
* @default ['transition', 'shadow']
|
|
34
|
+
*/
|
|
35
|
+
readonly keys?: ReadonlyArray<string>;
|
|
36
|
+
/**
|
|
37
|
+
* @description If set, only these themes are checked for forbidden keys.
|
|
38
|
+
* @default undefined (all themes)
|
|
39
|
+
*/
|
|
40
|
+
readonly themes?: ReadonlyArray<string>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @description Options for the `forbidden-value` rule.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export interface IForbiddenValueRuleOptions extends IRuleOptionValues {
|
|
47
|
+
/**
|
|
48
|
+
* @description Values that are forbidden in token definitions. Overrides the built-in default list.
|
|
49
|
+
* @default ['unset', '0px', 'all']
|
|
50
|
+
*/
|
|
51
|
+
readonly values?: ReadonlyArray<string>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @description Options for the `nested-depth` rule.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export interface INestedDepthRuleOptions extends IRuleOptionValues {
|
|
58
|
+
/**
|
|
59
|
+
* @description Maximum allowed nesting depth for token objects.
|
|
60
|
+
* @default 2
|
|
61
|
+
*/
|
|
62
|
+
readonly maxDepth?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @description Options for the `required-includes` rule.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export interface IRequiredIncludesRuleOptions extends IRuleOptionValues {
|
|
69
|
+
/**
|
|
70
|
+
* @description List of mixin names that every component must include. Overrides the built-in default list.
|
|
71
|
+
* @default ['font', 'padding', 'gap', 'transition', 'translate', 'shadow']
|
|
72
|
+
*/
|
|
73
|
+
readonly includes?: ReadonlyArray<string>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @description Options for the `value-type` rule.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export interface IValueTypeRuleOptions extends IRuleOptionValues {
|
|
80
|
+
/**
|
|
81
|
+
* @description Mapping of token key names to their required value type. Overrides the built-in defaults.
|
|
82
|
+
* @default { transitionProperty: 'array', tooltipTransitionProperty: 'array' }
|
|
83
|
+
*/
|
|
84
|
+
readonly types?: Readonly<Record<string, TokenValueType>>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @description Creates typed rule options for the `empty-json` rule.
|
|
88
|
+
* @public
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```js
|
|
92
|
+
* ruleOptions: {
|
|
93
|
+
* ...emptyJsonOptions({ allowIncludes: true }),
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function emptyJsonOptions(options: IEmptyJsonRuleOptions): IRuleOptionsEntry;
|
|
98
|
+
/**
|
|
99
|
+
* @description Creates typed rule options for the `forbidden-key` rule.
|
|
100
|
+
* @public
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```js
|
|
104
|
+
* ruleOptions: {
|
|
105
|
+
* ...forbiddenKeyOptions({ keys: ['transition', 'shadow'], themes: ['joy'] }),
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function forbiddenKeyOptions(options: IForbiddenKeyRuleOptions): IRuleOptionsEntry;
|
|
110
|
+
/**
|
|
111
|
+
* @description Creates typed rule options for the `forbidden-value` rule.
|
|
112
|
+
* @public
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```js
|
|
116
|
+
* ruleOptions: {
|
|
117
|
+
* ...forbiddenValueOptions({ values: ['unset', '0px', 'none'] }),
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function forbiddenValueOptions(options: IForbiddenValueRuleOptions): IRuleOptionsEntry;
|
|
122
|
+
/**
|
|
123
|
+
* @description Creates typed rule options for the `nested-depth` rule.
|
|
124
|
+
* @public
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```js
|
|
128
|
+
* ruleOptions: {
|
|
129
|
+
* ...nestedDepthOptions({ maxDepth: 3 }),
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function nestedDepthOptions(options: INestedDepthRuleOptions): IRuleOptionsEntry;
|
|
134
|
+
/**
|
|
135
|
+
* @description Creates typed rule options for the `required-includes` rule.
|
|
136
|
+
* @public
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```js
|
|
140
|
+
* ruleOptions: {
|
|
141
|
+
* ...requiredIncludesOptions({ includes: ['font', 'padding', 'gap'] }),
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare function requiredIncludesOptions(options: IRequiredIncludesRuleOptions): IRuleOptionsEntry;
|
|
146
|
+
/**
|
|
147
|
+
* @description Creates typed rule options for the `value-type` rule.
|
|
148
|
+
* @public
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```js
|
|
152
|
+
* ruleOptions: {
|
|
153
|
+
* ...valueTypeOptions({ types: { transitionProperty: 'array' } }),
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare function valueTypeOptions(options: IValueTypeRuleOptions): IRuleOptionsEntry;
|
|
158
|
+
//# sourceMappingURL=rule-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-options.d.ts","sourceRoot":"","sources":["../../src/rules/rule-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAMtF;;;GAG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B,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CAEtF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,4BAA4B,GAAG,iBAAiB,CAEhG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAElF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
// #endregion
|
|
3
|
+
// #region Functions
|
|
4
|
+
/**
|
|
5
|
+
* @description Creates typed rule options for the `empty-json` rule.
|
|
6
|
+
* @public
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* ruleOptions: {
|
|
11
|
+
* ...emptyJsonOptions({ allowIncludes: true }),
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function emptyJsonOptions(options) {
|
|
16
|
+
return { 'empty-json': options };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @description Creates typed rule options for the `forbidden-key` rule.
|
|
20
|
+
* @public
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```js
|
|
24
|
+
* ruleOptions: {
|
|
25
|
+
* ...forbiddenKeyOptions({ keys: ['transition', 'shadow'], themes: ['joy'] }),
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function forbiddenKeyOptions(options) {
|
|
30
|
+
return { 'forbidden-key': options };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @description Creates typed rule options for the `forbidden-value` rule.
|
|
34
|
+
* @public
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```js
|
|
38
|
+
* ruleOptions: {
|
|
39
|
+
* ...forbiddenValueOptions({ values: ['unset', '0px', 'none'] }),
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function forbiddenValueOptions(options) {
|
|
44
|
+
return { 'forbidden-value': options };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @description Creates typed rule options for the `nested-depth` rule.
|
|
48
|
+
* @public
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```js
|
|
52
|
+
* ruleOptions: {
|
|
53
|
+
* ...nestedDepthOptions({ maxDepth: 3 }),
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function nestedDepthOptions(options) {
|
|
58
|
+
return { 'nested-depth': options };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @description Creates typed rule options for the `required-includes` rule.
|
|
62
|
+
* @public
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```js
|
|
66
|
+
* ruleOptions: {
|
|
67
|
+
* ...requiredIncludesOptions({ includes: ['font', 'padding', 'gap'] }),
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function requiredIncludesOptions(options) {
|
|
72
|
+
return { 'required-includes': options };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @description Creates typed rule options for the `value-type` rule.
|
|
76
|
+
* @public
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```js
|
|
80
|
+
* ruleOptions: {
|
|
81
|
+
* ...valueTypeOptions({ types: { transitionProperty: 'array' } }),
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export function valueTypeOptions(options) {
|
|
86
|
+
return { 'value-type': options };
|
|
87
|
+
}
|
|
88
|
+
// #endregion
|
|
89
|
+
//# sourceMappingURL=rule-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-options.js","sourceRoot":"","sources":["../../src/rules/rule-options.ts"],"names":[],"mappings":"AAAA,kBAAkB;AA+GlB,aAAa;AAEb,oBAAoB;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA8B;IAC3D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAiC;IACjE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAmC;IACrE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAgC;IAC/D,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAqC;IACzE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA8B;IAC3D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC;AAED,aAAa"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IRule } from '../core/rule.js';
|
|
2
|
+
import type { IRuleContext } from '../models/rule-context.js';
|
|
3
|
+
import type { IRuleResult } from '../models/rule-result.js';
|
|
4
|
+
import { RuleSeverity } from '../models/rule-severity.js';
|
|
5
|
+
/**
|
|
6
|
+
* @description Detects value pattern inconsistencies across themes, e.g. var() in most themes but hardcoded in one.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class ValueConsistencyRule implements IRule {
|
|
10
|
+
readonly name = "value-consistency";
|
|
11
|
+
readonly description = "Detects value pattern inconsistencies across themes (e.g., var() in most themes but hardcoded in one).";
|
|
12
|
+
readonly defaultSeverity: RuleSeverity;
|
|
13
|
+
readonly fixable = false;
|
|
14
|
+
readonly interactive = false;
|
|
15
|
+
run(context: IRuleContext): IRuleResult;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=value-consistency.rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-consistency.rule.d.ts","sourceRoot":"","sources":["../../src/rules/value-consistency.rule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAM1D;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,KAAK;IAI9C,SAAgB,IAAI,uBAAuB;IAC3C,SAAgB,WAAW,4GAA4G;IACvI,SAAgB,eAAe,EAAE,YAAY,CAAqB;IAClE,SAAgB,OAAO,SAAS;IAChC,SAAgB,WAAW,SAAS;IAM7B,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;CA+DjD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { RuleSeverity } from '../models/rule-severity.js';
|
|
3
|
+
import { flattenTokenEntries, groupByComponent } from '../utils.js';
|
|
4
|
+
// #endregion
|
|
5
|
+
/**
|
|
6
|
+
* @description Detects value pattern inconsistencies across themes, e.g. var() in most themes but hardcoded in one.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export class ValueConsistencyRule {
|
|
10
|
+
// #region Fields
|
|
11
|
+
name = 'value-consistency';
|
|
12
|
+
description = 'Detects value pattern inconsistencies across themes (e.g., var() in most themes but hardcoded in one).';
|
|
13
|
+
defaultSeverity = RuleSeverity.Info;
|
|
14
|
+
fixable = false;
|
|
15
|
+
interactive = false;
|
|
16
|
+
// #endregion
|
|
17
|
+
// #region Methods
|
|
18
|
+
run(context) {
|
|
19
|
+
const findings = [];
|
|
20
|
+
const grouped = groupByComponent(context.entries);
|
|
21
|
+
for (const [component, entries] of grouped.entries()) {
|
|
22
|
+
const allKeys = new Set();
|
|
23
|
+
const entryFlat = new Map();
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
const flat = flattenTokenEntries(entry.content);
|
|
26
|
+
const keyMap = new Map();
|
|
27
|
+
for (const { key, value } of flat) {
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
keyMap.set(key, value);
|
|
30
|
+
allKeys.add(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
entryFlat.set(entry.theme, keyMap);
|
|
34
|
+
}
|
|
35
|
+
for (const key of allKeys) {
|
|
36
|
+
const themeValues = new Map();
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const value = entryFlat.get(entry.theme)?.get(key);
|
|
39
|
+
if (value !== undefined) {
|
|
40
|
+
themeValues.set(entry.theme, value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (themeValues.size < 2) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const varCount = Array.from(themeValues.values()).filter(v => v.startsWith('var(')).length;
|
|
47
|
+
const literalCount = themeValues.size - varCount;
|
|
48
|
+
// Flag if most themes use var() but some use hardcoded values
|
|
49
|
+
if (varCount > 0 && literalCount > 0 && varCount > literalCount) {
|
|
50
|
+
for (const [theme, value] of themeValues.entries()) {
|
|
51
|
+
if (!value.startsWith('var(')) {
|
|
52
|
+
findings.push({
|
|
53
|
+
component,
|
|
54
|
+
theme,
|
|
55
|
+
key,
|
|
56
|
+
message: `Key '${key}' uses hardcoded value '${value}' while other themes use var() references.`,
|
|
57
|
+
severity: this.defaultSeverity,
|
|
58
|
+
filePath: entries.find(e => e.theme === theme)?.filePath,
|
|
59
|
+
fixed: false,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { ruleName: this.name, findings, duration: 0 };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=value-consistency.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-consistency.rule.js","sourceRoot":"","sources":["../../src/rules/value-consistency.rule.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAMlB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,aAAa;AAEb;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAE7B,iBAAiB;IAED,IAAI,GAAG,mBAAmB,CAAC;IAC3B,WAAW,GAAG,wGAAwG,CAAC;IACvH,eAAe,GAAiB,YAAY,CAAC,IAAI,CAAC;IAClD,OAAO,GAAG,KAAK,CAAC;IAChB,WAAW,GAAG,KAAK,CAAC;IAEpC,aAAa;IAEb,kBAAkB;IAEX,GAAG,CAAC,OAAqB;QAC5B,MAAM,QAAQ,GAAmB,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,gBAAgB,CAAc,OAAO,CAAC,OAAO,CAAC,CAAC;QAE/D,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;YAClC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;YAEzD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,IAAI,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;gBAEzC,KAAK,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC;oBAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;wBAC5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AC,IAAI,CAAC;gCACV,SAAS;gCACT,KAAK;gCACL,GAAG;gCACH,OAAO,EAAE,QAAQ,GAAG,2BAA2B,KAAK,4CAA4C;gCAChG,QAAQ,EAAE,IAAI,CAAC,eAAe;gCAC9B,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,QAAQ;gCACxD,KAAK,EAAE,KAAK;6BACf,CAAC,CAAC;wBACP,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC1D,CAAC;CAGJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IRule } from '../core/rule.js';
|
|
2
|
+
import type { IRuleContext } from '../models/rule-context.js';
|
|
3
|
+
import type { IRuleResult } from '../models/rule-result.js';
|
|
4
|
+
import { RuleSeverity } from '../models/rule-severity.js';
|
|
5
|
+
/**
|
|
6
|
+
* @description Validates token values follow expected CSS patterns (var(), calc(), units, colors).
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class ValueSchemaRule implements IRule {
|
|
10
|
+
readonly name = "value-schema";
|
|
11
|
+
readonly description = "Validates token values follow expected CSS patterns (var(), calc(), units, colors).";
|
|
12
|
+
readonly defaultSeverity: RuleSeverity;
|
|
13
|
+
readonly fixable = false;
|
|
14
|
+
readonly interactive = false;
|
|
15
|
+
run(context: IRuleContext): IRuleResult;
|
|
16
|
+
private isValidTokenValue;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=value-schema.rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-schema.rule.d.ts","sourceRoot":"","sources":["../../src/rules/value-schema.rule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AA6B1D;;;GAGG;AACH,qBAAa,eAAgB,YAAW,KAAK;IAIzC,SAAgB,IAAI,kBAAkB;IACtC,SAAgB,WAAW,yFAAyF;IACpH,SAAgB,eAAe,EAAE,YAAY,CAAqB;IAClE,SAAgB,OAAO,SAAS;IAChC,SAAgB,WAAW,SAAS;IAM7B,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;IA4B9C,OAAO,CAAC,iBAAiB;CA2D5B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { RuleSeverity } from '../models/rule-severity.js';
|
|
3
|
+
import { flattenTokenEntries } from '../utils.js';
|
|
4
|
+
// #endregion
|
|
5
|
+
// #region Constants
|
|
6
|
+
const CSS_VAR_PATTERN = /^var\(--[\w-]+\)$/;
|
|
7
|
+
const CSS_CALC_PATTERN = /^calc\(.+\)$/;
|
|
8
|
+
const CSS_COLOR_HEX_PATTERN = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
9
|
+
const CSS_UNIT_PATTERN = /^-?\d+(\.\d+)?(px|em|rem|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc|s|ms|deg|rad|turn|fr)$/;
|
|
10
|
+
const CSS_NUMBER_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
11
|
+
const SAFE_LITERAL_VALUES = [
|
|
12
|
+
'auto', 'none', 'inherit', 'initial', 'transparent', 'currentColor',
|
|
13
|
+
'solid', 'dashed', 'dotted', 'normal', 'bold', 'italic',
|
|
14
|
+
'underline', 'uppercase', 'lowercase', 'capitalize',
|
|
15
|
+
'nowrap', 'wrap', 'hidden', 'visible', 'scroll',
|
|
16
|
+
'flex', 'grid', 'block', 'inline', 'inline-block', 'inline-flex',
|
|
17
|
+
'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear',
|
|
18
|
+
'center', 'left', 'right', 'top', 'bottom', 'start', 'end',
|
|
19
|
+
'stretch', 'baseline', 'space-between', 'space-around', 'space-evenly',
|
|
20
|
+
'row', 'column', 'row-reverse', 'column-reverse',
|
|
21
|
+
'absolute', 'relative', 'fixed', 'sticky', 'static',
|
|
22
|
+
'pointer', 'default', 'not-allowed', 'grab', 'grabbing',
|
|
23
|
+
'unset', 'revert', 'all',
|
|
24
|
+
];
|
|
25
|
+
// #endregion
|
|
26
|
+
/**
|
|
27
|
+
* @description Validates token values follow expected CSS patterns (var(), calc(), units, colors).
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export class ValueSchemaRule {
|
|
31
|
+
// #region Fields
|
|
32
|
+
name = 'value-schema';
|
|
33
|
+
description = 'Validates token values follow expected CSS patterns (var(), calc(), units, colors).';
|
|
34
|
+
defaultSeverity = RuleSeverity.Info;
|
|
35
|
+
fixable = false;
|
|
36
|
+
interactive = false;
|
|
37
|
+
// #endregion
|
|
38
|
+
// #region Methods
|
|
39
|
+
run(context) {
|
|
40
|
+
const findings = [];
|
|
41
|
+
for (const entry of context.entries) {
|
|
42
|
+
const flatEntries = flattenTokenEntries(entry.content);
|
|
43
|
+
for (const { key, value } of flatEntries) {
|
|
44
|
+
if (typeof value !== 'string') {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (!this.isValidTokenValue(value.trim())) {
|
|
48
|
+
findings.push({
|
|
49
|
+
component: entry.component,
|
|
50
|
+
theme: entry.theme,
|
|
51
|
+
key,
|
|
52
|
+
message: `Value '${value}' for key '${key}' does not match known CSS patterns.`,
|
|
53
|
+
severity: this.defaultSeverity,
|
|
54
|
+
filePath: entry.filePath,
|
|
55
|
+
fixed: false,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { ruleName: this.name, findings, duration: 0 };
|
|
61
|
+
}
|
|
62
|
+
isValidTokenValue(value) {
|
|
63
|
+
if (value === '') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// Check exact patterns
|
|
67
|
+
if (CSS_VAR_PATTERN.test(value)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (CSS_CALC_PATTERN.test(value)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (CSS_COLOR_HEX_PATTERN.test(value)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (CSS_UNIT_PATTERN.test(value)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (CSS_NUMBER_PATTERN.test(value)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (SAFE_LITERAL_VALUES.includes(value)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
// Allow complex var() with fallbacks: var(--x, fallback)
|
|
86
|
+
if (value.startsWith('var(') && value.endsWith(')')) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
// Allow complex calc() expressions
|
|
90
|
+
if (value.startsWith('calc(') && value.endsWith(')')) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
// Allow CSS functions like rgb(), rgba(), hsl(), hsla(), url(), gradients
|
|
94
|
+
if (/^(rgb|rgba|hsl|hsla|url|linear-gradient|radial-gradient|conic-gradient)\(/.test(value)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
// Allow comma-separated font families
|
|
98
|
+
if (value.includes(',') && /^[\w\s,"-]+$/.test(value)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
// Allow quoted strings
|
|
102
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=value-schema.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-schema.rule.js","sourceRoot":"","sources":["../../src/rules/value-schema.rule.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAMlB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,aAAa;AAEb,oBAAoB;AAEpB,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,gBAAgB,GAAG,cAAc,CAAC;AACxC,MAAM,qBAAqB,GAAG,mDAAmD,CAAC;AAClF,MAAM,gBAAgB,GAAG,wFAAwF,CAAC;AAClH,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAC7C,MAAM,mBAAmB,GAA0B;IAC/C,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc;IACnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ;IACvD,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY;IACnD,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAC/C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa;IAChE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ;IACtD,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK;IAC1D,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;IACtE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB;IAChD,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,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KAAK,CAAC,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACnG,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAGJ"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IRule } from '../core/rule.js';
|
|
2
|
+
import type { IRuleContext } from '../models/rule-context.js';
|
|
3
|
+
import type { IRuleFinding } from '../models/rule-finding.js';
|
|
4
|
+
import type { IRuleResult } from '../models/rule-result.js';
|
|
5
|
+
import { RuleSeverity } from '../models/rule-severity.js';
|
|
6
|
+
import type { IRuleOptionValues, IRuleOptionsEntry } from '../models/token-linter-config.js';
|
|
7
|
+
/**
|
|
8
|
+
* @description Allowed value types for token values.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type TokenValueType = 'string' | 'array' | 'number';
|
|
12
|
+
/**
|
|
13
|
+
* @description Options for the `value-type` rule.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface IValueTypeRuleOptions extends IRuleOptionValues {
|
|
17
|
+
/**
|
|
18
|
+
* @description Mapping of token key names to their required value type. Overrides the built-in defaults.
|
|
19
|
+
* @default { transitionProperty: 'array', tooltipTransitionProperty: 'array' }
|
|
20
|
+
*/
|
|
21
|
+
readonly types?: Readonly<Record<string, TokenValueType>>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @description Creates typed rule options for the `value-type` rule.
|
|
25
|
+
* @public
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```js
|
|
29
|
+
* ruleOptions: {
|
|
30
|
+
* ...valueTypeRuleOptions({ types: { transitionProperty: 'array' } }),
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function valueTypeRuleOptions(options: IValueTypeRuleOptions): IRuleOptionsEntry;
|
|
35
|
+
/**
|
|
36
|
+
* @description Enforces that specific token keys have values of a required type (string, array, or number).
|
|
37
|
+
* When auto-fix is enabled, values are coerced to the expected type where possible
|
|
38
|
+
* (e.g. a string is wrapped into a single-element array).
|
|
39
|
+
*
|
|
40
|
+
* The type constraints default to `{ transitionProperty: 'array', tooltipTransitionProperty: 'array' }`
|
|
41
|
+
* and can be overridden via `ruleOptions`:
|
|
42
|
+
*
|
|
43
|
+
* @example Configuration
|
|
44
|
+
* ```js
|
|
45
|
+
* export default defineConfig({
|
|
46
|
+
* rules: { 'value-type': 'error' },
|
|
47
|
+
* ruleOptions: {
|
|
48
|
+
* 'value-type': {
|
|
49
|
+
* types: {
|
|
50
|
+
* transitionProperty: 'array',
|
|
51
|
+
* tooltipTransitionProperty: 'array',
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* },
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare class ValueTypeRule implements IRule {
|
|
61
|
+
readonly name = "value-type";
|
|
62
|
+
readonly description = "Enforces that specific token keys have values of a required type (string, array, number).";
|
|
63
|
+
readonly defaultSeverity: RuleSeverity;
|
|
64
|
+
readonly fixable = true;
|
|
65
|
+
readonly interactive = false;
|
|
66
|
+
run(context: IRuleContext): IRuleResult;
|
|
67
|
+
fix(context: IRuleContext, findings: ReadonlyArray<IRuleFinding>): IRuleFinding[];
|
|
68
|
+
private _getValueType;
|
|
69
|
+
private _coerceValue;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=value-type.rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-type.rule.d.ts","s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