@salesforce-ux/eslint-plugin-slds 1.0.8-internal → 1.0.9-internal
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/build/config/rule-messages.d.ts +2 -0
- package/build/config/rule-messages.js +197 -0
- package/build/config/rule-messages.js.map +7 -0
- package/build/index.js +40 -2471
- package/build/index.js.map +4 -4
- package/build/rules/enforce-bem-usage.js +16 -232
- package/build/rules/enforce-bem-usage.js.map +4 -4
- package/build/rules/modal-close-button-issue.js +11 -183
- package/build/rules/modal-close-button-issue.js.map +4 -4
- package/build/rules/no-deprecated-classes-slds2.js +4 -176
- package/build/rules/no-deprecated-classes-slds2.js.map +4 -4
- package/build/rules/v9/enforce-bem-usage.js +1 -161
- package/build/rules/v9/enforce-bem-usage.js.map +4 -4
- package/build/rules/v9/enforce-component-hook-naming-convention.js +1 -161
- package/build/rules/v9/enforce-component-hook-naming-convention.js.map +4 -4
- package/build/rules/v9/enforce-sds-to-slds-hooks.js +1 -161
- package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +4 -4
- package/build/rules/v9/lwc-token-to-slds-hook.js +4 -262
- package/build/rules/v9/lwc-token-to-slds-hook.js.map +4 -4
- package/build/rules/v9/no-deprecated-slds-classes.js +1 -161
- package/build/rules/v9/no-deprecated-slds-classes.js.map +4 -4
- package/build/rules/v9/no-deprecated-tokens-slds1.js +29 -168
- package/build/rules/v9/no-deprecated-tokens-slds1.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +9 -289
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +13 -283
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +12 -328
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +13 -309
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/index.js +8 -875
- package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +3 -1208
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +3 -1208
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +22 -993
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +4 -4
- package/build/rules/v9/no-slds-class-overrides.js +1 -161
- package/build/rules/v9/no-slds-class-overrides.js.map +4 -4
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +3 -252
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +4 -4
- package/build/rules/v9/no-slds-private-var.js +1 -161
- package/build/rules/v9/no-slds-private-var.js.map +4 -4
- package/build/rules/v9/no-slds-var-without-fallback.js +3 -255
- package/build/rules/v9/no-slds-var-without-fallback.js.map +4 -4
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +1 -161
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +4 -4
- package/build/rules/v9/no-unsupported-hooks-slds2.js +1 -161
- package/build/rules/v9/no-unsupported-hooks-slds2.js.map +4 -4
- package/build/rules/v9/reduce-annotations.js +1 -161
- package/build/rules/v9/reduce-annotations.js.map +4 -4
- package/build/{src/utils → utils}/boxShadowValueParser.d.ts +1 -1
- package/build/utils/boxShadowValueParser.js +63 -93
- package/build/utils/boxShadowValueParser.js.map +4 -4
- package/build/utils/color-lib-utils.js +2 -29
- package/build/utils/color-lib-utils.js.map +3 -3
- package/build/{src/utils → utils}/css-utils.d.ts +7 -0
- package/build/utils/css-utils.js +10 -71
- package/build/utils/css-utils.js.map +4 -4
- package/build/utils/hardcoded-shared-utils.js +17 -82
- package/build/utils/hardcoded-shared-utils.js.map +4 -4
- package/build/utils/property-matcher.js +2 -2
- package/build/utils/property-matcher.js.map +2 -2
- package/build/utils/styling-hook-utils.js +16 -39
- package/build/utils/styling-hook-utils.js.map +3 -3
- package/build/{src/utils → utils}/value-utils.d.ts +2 -2
- package/build/utils/value-utils.js +8 -8
- package/build/utils/value-utils.js.map +2 -2
- package/package.json +5 -10
- package/src/config/rule-messages.yml +0 -143
- /package/build/{src/index.d.ts → index.d.ts} +0 -0
- /package/build/{src/rules → rules}/enforce-bem-usage.d.ts +0 -0
- /package/build/{src/rules → rules}/modal-close-button-issue.d.ts +0 -0
- /package/build/{src/rules → rules}/no-deprecated-classes-slds2.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/enforce-bem-usage.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/enforce-component-hook-naming-convention.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/enforce-sds-to-slds-hooks.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/lwc-token-to-slds-hook.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-deprecated-slds-classes.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-deprecated-tokens-slds1.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/boxShadowHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/colorHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/densityHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/fontHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/index.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/no-hardcoded-values-slds1.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/no-hardcoded-values-slds2.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/ruleOptionsSchema.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-class-overrides.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-namespace-for-custom-hooks.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-private-var.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-var-without-fallback.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-sldshook-fallback-for-lwctoken.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-unsupported-hooks-slds2.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/reduce-annotations.d.ts +0 -0
- /package/build/{src/types → types}/index.d.ts +0 -0
- /package/build/{src/utils → utils}/color-lib-utils.d.ts +0 -0
- /package/build/{src/utils → utils}/css-functions.d.ts +0 -0
- /package/build/{src/utils → utils}/custom-mapping-utils.d.ts +0 -0
- /package/build/{src/utils → utils}/hardcoded-shared-utils.d.ts +0 -0
- /package/build/{src/utils → utils}/node.d.ts +0 -0
- /package/build/{src/utils → utils}/property-matcher.d.ts +0 -0
- /package/build/{src/utils → utils}/rule-utils.d.ts +0 -0
- /package/build/{src/utils → utils}/styling-hook-utils.d.ts +0 -0
|
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
7
|
var __export = (target, all) => {
|
|
11
8
|
for (var name in all)
|
|
12
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,170 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
26
|
));
|
|
30
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
28
|
|
|
32
|
-
// yaml-file:rule-messages.yml
|
|
33
|
-
var require_rule_messages = __commonJS({
|
|
34
|
-
"yaml-file:rule-messages.yml"(exports2, module2) {
|
|
35
|
-
module2.exports = {
|
|
36
|
-
"no-slds-class-overrides": {
|
|
37
|
-
"description": "Create new custom CSS classes instead of overriding SLDS selectors",
|
|
38
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides",
|
|
39
|
-
"type": "problem",
|
|
40
|
-
"messages": {
|
|
41
|
-
"sldsClassOverride": "Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button."
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"no-deprecated-slds-classes": {
|
|
45
|
-
"description": "Please replace the deprecated classes with a modern equivalent",
|
|
46
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes",
|
|
47
|
-
"type": "problem",
|
|
48
|
-
"messages": {
|
|
49
|
-
"deprecatedClass": "The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class."
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"no-deprecated-tokens-slds1": {
|
|
53
|
-
"description": "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.",
|
|
54
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1",
|
|
55
|
-
"type": "problem",
|
|
56
|
-
"messages": {
|
|
57
|
-
"deprecatedToken": "Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com.",
|
|
58
|
-
"noReplacement": "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com."
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"enforce-sds-to-slds-hooks": {
|
|
62
|
-
"description": "Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info.",
|
|
63
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks",
|
|
64
|
-
"type": "problem",
|
|
65
|
-
"messages": {
|
|
66
|
-
"replaceSdsWithSlds": "Replace {{oldValue}} with {{suggestedMatch}} styling hook."
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"enforce-bem-usage": {
|
|
70
|
-
"description": "Replace BEM double-dash syntax in class names with single underscore syntax",
|
|
71
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage",
|
|
72
|
-
"type": "problem",
|
|
73
|
-
"messages": {
|
|
74
|
-
"bemDoubleDash": "{{actual}} has been retired. Update it to the new name {{newValue}}.",
|
|
75
|
-
"fixBemNaming": "Update to correct BEM naming convention"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"modal-close-button-issue": {
|
|
79
|
-
"description": "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint",
|
|
80
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue",
|
|
81
|
-
"type": "problem",
|
|
82
|
-
"messages": {
|
|
83
|
-
"modalCloseButtonIssue": "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.",
|
|
84
|
-
"removeClass": "Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.",
|
|
85
|
-
"changeVariant": "Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.",
|
|
86
|
-
"removeVariant": "Remove the variant attribute from the <lightning-icon> component inside the <button> element.",
|
|
87
|
-
"ensureButtonClasses": "Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.",
|
|
88
|
-
"ensureSizeAttribute": "To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components."
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"no-deprecated-classes-slds2": {
|
|
92
|
-
"description": "Replace classes that aren't available with SLDS 2 classes",
|
|
93
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2",
|
|
94
|
-
"type": "problem",
|
|
95
|
-
"messages": {
|
|
96
|
-
"deprecatedClass": "The class {{className}} isn't available in SLDS 2. Update it to a class supported in SLDS 2. See lightningdesignsystem.com for more information.",
|
|
97
|
-
"updateToModernClass": "Replace deprecated class with modern equivalent",
|
|
98
|
-
"checkDocumentation": "See lightningdesignsystem.com for SLDS 2 class alternatives"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"lwc-token-to-slds-hook": {
|
|
102
|
-
"description": "Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info.",
|
|
103
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook",
|
|
104
|
-
"type": "problem",
|
|
105
|
-
"messages": {
|
|
106
|
-
"errorWithReplacement": "The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.",
|
|
107
|
-
"errorWithStyleHooks": "The '{{oldValue}}' design token is deprecated. Replace it with the SLDS 2 '{{newValue}}' styling hook and set the fallback to '{{oldValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.",
|
|
108
|
-
"errorWithNoRecommendation": "The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com."
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"no-sldshook-fallback-for-lwctoken": {
|
|
112
|
-
"description": "Avoid using --slds styling hooks as fallback values for --lwc tokens.",
|
|
113
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken",
|
|
114
|
-
"type": "problem",
|
|
115
|
-
"messages": {
|
|
116
|
-
"unsupportedFallback": "Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}."
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
"no-unsupported-hooks-slds2": {
|
|
120
|
-
"description": "Identifies styling hooks that aren't present in SLDS 2. They must be replaced with styling hooks that have a similar effect, or they must be removed.",
|
|
121
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2",
|
|
122
|
-
"type": "problem",
|
|
123
|
-
"messages": {
|
|
124
|
-
"deprecated": "The {{token}} styling hook isn't present in SLDS 2 and there's no equivalent replacement. Remove it or replace it with a styling hook with a similar effect."
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
"no-slds-var-without-fallback": {
|
|
128
|
-
"description": "Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable.",
|
|
129
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback",
|
|
130
|
-
"type": "problem",
|
|
131
|
-
"messages": {
|
|
132
|
-
"varWithoutFallback": "Your code uses the {{cssVar}} styling hook without a fallback value. Styling hooks are unavailable in some Salesforce environments. To render your component correctly in all environments, add this fallback value: var({{cssVar}}, {{recommendation}}). To make this fallback value brand-aware, use a branded design token instead of a static value. See Design Tokens on v1.lightningdesignsystem.com."
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
"no-slds-namespace-for-custom-hooks": {
|
|
136
|
-
"description": "To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace.",
|
|
137
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks",
|
|
138
|
-
"type": "problem",
|
|
139
|
-
"messages": {
|
|
140
|
-
"customHookNamespace": "Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"no-slds-private-var": {
|
|
144
|
-
"description": "Some SLDS styling hooks are private and reserved only for internal Salesforce use. Private SLDS styling hooks have prefixes --_slds- and --slds-s-. For more information, look up private CSS in lightningdesignsystem.com.",
|
|
145
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var",
|
|
146
|
-
"type": "problem",
|
|
147
|
-
"messages": {
|
|
148
|
-
"privateVar": "This styling hook is reserved for internal Salesforce use. Remove the --_slds- or \u2013slds-s private variable within selector {{prop}}. For more information, look up private CSS in lightningdesignsystem.com."
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
"enforce-component-hook-naming-convention": {
|
|
152
|
-
"description": "Replace component styling hooks that use a deprecated naming convention.",
|
|
153
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention",
|
|
154
|
-
"type": "problem",
|
|
155
|
-
"messages": {
|
|
156
|
-
"replace": "Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}."
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
"no-hardcoded-values-slds1": {
|
|
160
|
-
"description": "Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com.",
|
|
161
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value",
|
|
162
|
-
"type": "suggestion",
|
|
163
|
-
"messages": {
|
|
164
|
-
"hardcodedValue": "Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}.",
|
|
165
|
-
"noReplacement": "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
"no-hardcoded-values-slds2": {
|
|
169
|
-
"description": "Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.",
|
|
170
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-values-slds2",
|
|
171
|
-
"type": "suggestion",
|
|
172
|
-
"messages": {
|
|
173
|
-
"hardcodedValue": "Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.",
|
|
174
|
-
"noReplacement": "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
"reduce-annotations": {
|
|
178
|
-
"description": "Remove your annotations and update your code.",
|
|
179
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations",
|
|
180
|
-
"type": "problem",
|
|
181
|
-
"messages": {
|
|
182
|
-
"removeAnnotation": "Remove this annotation and update the code to SLDS best practices. For help, file an issue at https://github.com/salesforce-ux/slds-linter/"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
29
|
// src/rules/v9/reduce-annotations.ts
|
|
190
30
|
var reduce_annotations_exports = {};
|
|
191
31
|
__export(reduce_annotations_exports, {
|
|
192
32
|
default: () => reduce_annotations_default
|
|
193
33
|
});
|
|
194
34
|
module.exports = __toCommonJS(reduce_annotations_exports);
|
|
195
|
-
var import_rule_messages = __toESM(
|
|
35
|
+
var import_rule_messages = __toESM(require("../../config/rule-messages"));
|
|
196
36
|
var ruleConfig = import_rule_messages.default["reduce-annotations"];
|
|
197
37
|
var { type, description, url, messages } = ruleConfig;
|
|
198
38
|
var SLDS_ANNOTATIONS = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
4
|
-
"sourcesContent": ["module.exports = {\n \"no-slds-class-overrides\": {\n \"description\": \"Create new custom CSS classes instead of overriding SLDS selectors\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides\",\n \"type\": \"problem\",\n \"messages\": {\n \"sldsClassOverride\": \"Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button.\"\n }\n },\n \"no-deprecated-slds-classes\": {\n \"description\": \"Please replace the deprecated classes with a modern equivalent\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedClass\": \"The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class.\"\n }\n },\n \"no-deprecated-tokens-slds1\": {\n \"description\": \"Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedToken\": \"Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com.\",\n \"noReplacement\": \"Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.\"\n }\n },\n \"enforce-sds-to-slds-hooks\": {\n \"description\": \"Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks\",\n \"type\": \"problem\",\n \"messages\": {\n \"replaceSdsWithSlds\": \"Replace {{oldValue}} with {{suggestedMatch}} styling hook.\"\n }\n },\n \"enforce-bem-usage\": {\n \"description\": \"Replace BEM double-dash syntax in class names with single underscore syntax\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage\",\n \"type\": \"problem\",\n \"messages\": {\n \"bemDoubleDash\": \"{{actual}} has been retired. Update it to the new name {{newValue}}.\",\n \"fixBemNaming\": \"Update to correct BEM naming convention\"\n }\n },\n \"modal-close-button-issue\": {\n \"description\": \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue\",\n \"type\": \"problem\",\n \"messages\": {\n \"modalCloseButtonIssue\": \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.\",\n \"removeClass\": \"Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.\",\n \"changeVariant\": \"Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.\",\n \"removeVariant\": \"Remove the variant attribute from the <lightning-icon> component inside the <button> element.\",\n \"ensureButtonClasses\": \"Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.\",\n \"ensureSizeAttribute\": \"To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components.\"\n }\n },\n \"no-deprecated-classes-slds2\": {\n \"description\": \"Replace classes that aren't available with SLDS 2 classes\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedClass\": \"The class {{className}} isn't available in SLDS 2. Update it to a class supported in SLDS 2. See lightningdesignsystem.com for more information.\",\n \"updateToModernClass\": \"Replace deprecated class with modern equivalent\",\n \"checkDocumentation\": \"See lightningdesignsystem.com for SLDS 2 class alternatives\"\n }\n },\n \"lwc-token-to-slds-hook\": {\n \"description\": \"Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook\",\n \"type\": \"problem\",\n \"messages\": {\n \"errorWithReplacement\": \"The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.\",\n \"errorWithStyleHooks\": \"The '{{oldValue}}' design token is deprecated. Replace it with the SLDS 2 '{{newValue}}' styling hook and set the fallback to '{{oldValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.\",\n \"errorWithNoRecommendation\": \"The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com.\"\n }\n },\n \"no-sldshook-fallback-for-lwctoken\": {\n \"description\": \"Avoid using --slds styling hooks as fallback values for --lwc tokens.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken\",\n \"type\": \"problem\",\n \"messages\": {\n \"unsupportedFallback\": \"Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}.\"\n }\n },\n \"no-unsupported-hooks-slds2\": {\n \"description\": \"Identifies styling hooks that aren't present in SLDS 2. They must be replaced with styling hooks that have a similar effect, or they must be removed.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecated\": \"The {{token}} styling hook isn't present in SLDS 2 and there's no equivalent replacement. Remove it or replace it with a styling hook with a similar effect.\"\n }\n },\n \"no-slds-var-without-fallback\": {\n \"description\": \"Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback\",\n \"type\": \"problem\",\n \"messages\": {\n \"varWithoutFallback\": \"Your code uses the {{cssVar}} styling hook without a fallback value. Styling hooks are unavailable in some Salesforce environments. To render your component correctly in all environments, add this fallback value: var({{cssVar}}, {{recommendation}}). To make this fallback value brand-aware, use a branded design token instead of a static value. See Design Tokens on v1.lightningdesignsystem.com.\"\n }\n },\n \"no-slds-namespace-for-custom-hooks\": {\n \"description\": \"To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks\",\n \"type\": \"problem\",\n \"messages\": {\n \"customHookNamespace\": \"Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}\"\n }\n },\n \"no-slds-private-var\": {\n \"description\": \"Some SLDS styling hooks are private and reserved only for internal Salesforce use. Private SLDS styling hooks have prefixes --_slds- and --slds-s-. For more information, look up private CSS in lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var\",\n \"type\": \"problem\",\n \"messages\": {\n \"privateVar\": \"This styling hook is reserved for internal Salesforce use. Remove the --_slds- or \u2013slds-s private variable within selector {{prop}}. For more information, look up private CSS in lightningdesignsystem.com.\"\n }\n },\n \"enforce-component-hook-naming-convention\": {\n \"description\": \"Replace component styling hooks that use a deprecated naming convention.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention\",\n \"type\": \"problem\",\n \"messages\": {\n \"replace\": \"Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}.\"\n }\n },\n \"no-hardcoded-values-slds1\": {\n \"description\": \"Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value\",\n \"type\": \"suggestion\",\n \"messages\": {\n \"hardcodedValue\": \"Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}.\",\n \"noReplacement\": \"There's no replacement styling hook for the {{oldValue}} static value. Remove the static value.\"\n }\n },\n \"no-hardcoded-values-slds2\": {\n \"description\": \"Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-values-slds2\",\n \"type\": \"suggestion\",\n \"messages\": {\n \"hardcodedValue\": \"Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.\",\n \"noReplacement\": \"There's no replacement styling hook for the {{oldValue}} static value. Remove the static value.\"\n }\n },\n \"reduce-annotations\": {\n \"description\": \"Remove your annotations and update your code.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations\",\n \"type\": \"problem\",\n \"messages\": {\n \"removeAnnotation\": \"Remove this annotation and update the code to SLDS best practices. For help, file an issue at https://github.com/salesforce-ux/slds-linter/\"\n }\n }\n};", "import { Rule } from 'eslint';\nimport ruleMessages from '../../config/rule-messages.yml';\n\nconst ruleConfig = ruleMessages['reduce-annotations'];\nconst { type, description, url, messages } = ruleConfig;\n\n// SLDS validator annotations to detect and flag for removal\nconst SLDS_ANNOTATIONS = [\n \"@sldsValidatorIgnoreNextLine\", \n \"@sldsValidatorAllow\", \n \"@sldsValidatorIgnore\"\n];\n\nexport default {\n meta: {\n type,\n docs: {\n description,\n recommended: true,\n url,\n },\n messages,\n },\n \n create(context) {\n return {\n StyleSheet(node) {\n const sourceCode = context.sourceCode;\n \n let comments = (sourceCode as any)?.comments || [];\n\n comments.forEach(comment => {\n const commentContent = comment.value.trim();\n \n const matchingAnnotation = SLDS_ANNOTATIONS.find(annotation => \n commentContent.startsWith(annotation)\n );\n \n if (matchingAnnotation) {\n context.report({\n node: comment,\n messageId: 'removeAnnotation'\n });\n }\n });\n },\n };\n },\n} as Rule.RuleModule;\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/rules/v9/reduce-annotations.ts"],
|
|
4
|
+
"sourcesContent": ["import { Rule } from 'eslint';\nimport ruleMessages from '../../config/rule-messages';\n\nconst ruleConfig = ruleMessages['reduce-annotations'];\nconst { type, description, url, messages } = ruleConfig;\n\n// SLDS validator annotations to detect and flag for removal\nconst SLDS_ANNOTATIONS = [\n \"@sldsValidatorIgnoreNextLine\", \n \"@sldsValidatorAllow\", \n \"@sldsValidatorIgnore\"\n];\n\nexport default {\n meta: {\n type,\n docs: {\n description,\n recommended: true,\n url,\n },\n messages,\n },\n \n create(context) {\n return {\n StyleSheet(node) {\n const sourceCode = context.sourceCode;\n \n let comments = (sourceCode as any)?.comments || [];\n\n comments.forEach(comment => {\n const commentContent = comment.value.trim();\n \n const matchingAnnotation = SLDS_ANNOTATIONS.find(annotation => \n commentContent.startsWith(annotation)\n );\n \n if (matchingAnnotation) {\n context.report({\n node: comment,\n messageId: 'removeAnnotation'\n });\n }\n });\n },\n };\n },\n} as Rule.RuleModule;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAAyB;AAEzB,IAAM,aAAa,qBAAAA,QAAa,oBAAoB;AACpD,IAAM,EAAE,MAAM,aAAa,KAAK,SAAS,IAAI;AAG7C,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAO,6BAAQ;AAAA,EACb,MAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,MACJ;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAAA,EAEA,OAAO,SAAS;AACd,WAAO;AAAA,MACL,WAAW,MAAM;AACf,cAAM,aAAa,QAAQ;AAE3B,YAAI,WAAY,YAAoB,YAAY,CAAC;AAEjD,iBAAS,QAAQ,aAAW;AAC1B,gBAAM,iBAAiB,QAAQ,MAAM,KAAK;AAE1C,gBAAM,qBAAqB,iBAAiB;AAAA,YAAK,gBAC/C,eAAe,WAAW,UAAU;AAAA,UACtC;AAEA,cAAI,oBAAoB;AACtB,oBAAQ,OAAO;AAAA,cACb,MAAM;AAAA,cACN,WAAW;AAAA,YACb,CAAC;AAAA,UACH;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["ruleMessages"]
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ export interface BoxShadowValue {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Parse box-shadow value into structured format
|
|
11
|
-
*
|
|
11
|
+
* Uses CSS tree parser to properly handle comma-separated shadows and var() functions
|
|
12
12
|
*/
|
|
13
13
|
export declare function parseBoxShadowValue(value: string): BoxShadowValue[];
|
|
14
14
|
/**
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/utils/boxShadowValueParser.ts
|
|
@@ -33,56 +23,11 @@ __export(boxShadowValueParser_exports, {
|
|
|
33
23
|
parseBoxShadowValue: () => parseBoxShadowValue
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(boxShadowValueParser_exports);
|
|
36
|
-
var import_css_tree2 = require("@eslint/css-tree");
|
|
37
|
-
|
|
38
|
-
// src/utils/color-lib-utils.ts
|
|
39
|
-
var import_chroma_js = __toESM(require("chroma-js"));
|
|
40
26
|
var import_css_tree = require("@eslint/css-tree");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
"calc",
|
|
46
|
-
"color-mix",
|
|
47
|
-
"conic-gradient",
|
|
48
|
-
"counter",
|
|
49
|
-
"cubic-bezier",
|
|
50
|
-
"linear-gradient",
|
|
51
|
-
"max",
|
|
52
|
-
"min",
|
|
53
|
-
"radial-gradient",
|
|
54
|
-
"repeating-conic-gradient",
|
|
55
|
-
"repeating-linear-gradient",
|
|
56
|
-
"repeating-radial-gradient",
|
|
57
|
-
"var"
|
|
58
|
-
];
|
|
59
|
-
var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
|
|
60
|
-
var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
|
|
61
|
-
var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
|
|
62
|
-
var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
|
|
63
|
-
var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
|
|
64
|
-
function isCssColorFunction(value) {
|
|
65
|
-
return RGB_COLOR_FUNCTIONS.includes(value);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/utils/color-lib-utils.ts
|
|
69
|
-
var isValidColor = (val) => import_chroma_js.default.valid(val);
|
|
70
|
-
|
|
71
|
-
// src/utils/value-utils.ts
|
|
72
|
-
var ALLOWED_UNITS = ["px", "em", "rem", "%", "ch"];
|
|
73
|
-
function parseUnitValue(value) {
|
|
74
|
-
if (!value) return null;
|
|
75
|
-
const unitsPattern = ALLOWED_UNITS.join("|");
|
|
76
|
-
const regex = new RegExp(`^(-?\\d*\\.?\\d+)(${unitsPattern})?$`);
|
|
77
|
-
const match = value.match(regex);
|
|
78
|
-
if (!match) return null;
|
|
79
|
-
const number = parseFloat(match[1]);
|
|
80
|
-
const unit = match[2] ? match[2] : null;
|
|
81
|
-
if (isNaN(number)) return null;
|
|
82
|
-
return { number, unit };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/utils/boxShadowValueParser.ts
|
|
27
|
+
var import_color_lib_utils = require("./color-lib-utils");
|
|
28
|
+
var import_value_utils = require("./value-utils");
|
|
29
|
+
var import_css_functions = require("./css-functions");
|
|
30
|
+
var import_css_utils = require("./css-utils");
|
|
86
31
|
function isColorValue(node) {
|
|
87
32
|
if (!node) return false;
|
|
88
33
|
switch (node.type) {
|
|
@@ -90,9 +35,13 @@ function isColorValue(node) {
|
|
|
90
35
|
return true;
|
|
91
36
|
// #hex colors
|
|
92
37
|
case "Identifier":
|
|
93
|
-
return isValidColor(node.name);
|
|
38
|
+
return (0, import_color_lib_utils.isValidColor)(node.name);
|
|
94
39
|
case "Function":
|
|
95
|
-
|
|
40
|
+
if ((0, import_css_functions.isCssColorFunction)(node.name.toLowerCase())) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const varToken = (0, import_css_utils.getVarToken)(node);
|
|
44
|
+
return !!varToken.match(/^--slds-g-color/);
|
|
96
45
|
default:
|
|
97
46
|
return false;
|
|
98
47
|
}
|
|
@@ -102,9 +51,15 @@ function isLengthValue(node) {
|
|
|
102
51
|
switch (node.type) {
|
|
103
52
|
case "Dimension":
|
|
104
53
|
const dimensionStr = `${node.value}${node.unit}`;
|
|
105
|
-
return parseUnitValue(dimensionStr) !== null;
|
|
54
|
+
return (0, import_value_utils.parseUnitValue)(dimensionStr) !== null;
|
|
106
55
|
case "Number":
|
|
107
56
|
return Number(node.value) === 0;
|
|
57
|
+
case "Function":
|
|
58
|
+
if ((0, import_css_functions.isCssMathFunction)(node.name.toLowerCase())) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const varToken = (0, import_css_utils.getVarToken)(node);
|
|
62
|
+
return !!varToken.match(/^--slds-g-(spacing|sizing)/);
|
|
108
63
|
default:
|
|
109
64
|
return false;
|
|
110
65
|
}
|
|
@@ -112,43 +67,58 @@ function isLengthValue(node) {
|
|
|
112
67
|
function isInsetKeyword(node) {
|
|
113
68
|
return node?.type === "Identifier" && node.name.toLowerCase() === "inset";
|
|
114
69
|
}
|
|
115
|
-
function
|
|
70
|
+
function isCommaSeparator(node) {
|
|
71
|
+
return node?.type === "Operator" && node.value === ",";
|
|
72
|
+
}
|
|
73
|
+
function extractShadowParts(ast) {
|
|
116
74
|
const shadows = [];
|
|
117
|
-
let currentShadow =
|
|
118
|
-
|
|
119
|
-
colorParts
|
|
120
|
-
|
|
75
|
+
let currentShadow = null;
|
|
76
|
+
const finalizeShadow = () => {
|
|
77
|
+
if (currentShadow && (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset)) {
|
|
78
|
+
shadows.push(currentShadow);
|
|
79
|
+
}
|
|
80
|
+
currentShadow = null;
|
|
121
81
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
82
|
+
(0, import_css_tree.walk)(ast, {
|
|
83
|
+
enter(node) {
|
|
84
|
+
if (isCommaSeparator(node)) {
|
|
85
|
+
finalizeShadow();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (node.type === "WhiteSpace") {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
currentShadow = currentShadow || { lengthParts: [], colorParts: [], inset: false };
|
|
92
|
+
if (node.type === "Function") {
|
|
93
|
+
if (isColorValue(node)) {
|
|
94
|
+
currentShadow.colorParts.push((0, import_css_tree.generate)(node));
|
|
131
95
|
} else if (isLengthValue(node)) {
|
|
132
|
-
currentShadow.lengthParts.push((0,
|
|
133
|
-
} else if (isColorValue(node)) {
|
|
134
|
-
currentShadow.colorParts.push((0, import_css_tree2.generate)(node));
|
|
96
|
+
currentShadow.lengthParts.push((0, import_css_tree.generate)(node));
|
|
135
97
|
}
|
|
98
|
+
return this.skip;
|
|
99
|
+
}
|
|
100
|
+
if (isInsetKeyword(node)) {
|
|
101
|
+
currentShadow.inset = true;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (isLengthValue(node)) {
|
|
105
|
+
currentShadow.lengthParts.push((0, import_css_tree.generate)(node));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (isColorValue(node)) {
|
|
109
|
+
currentShadow.colorParts.push((0, import_css_tree.generate)(node));
|
|
110
|
+
return;
|
|
136
111
|
}
|
|
137
|
-
});
|
|
138
|
-
if (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset) {
|
|
139
|
-
shadows.push(currentShadow);
|
|
140
112
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
113
|
+
});
|
|
114
|
+
finalizeShadow();
|
|
144
115
|
return shadows;
|
|
145
116
|
}
|
|
146
117
|
function parseBoxShadowValue(value) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const parsedShadows = shadows.map((shadow) => {
|
|
118
|
+
try {
|
|
119
|
+
const ast = (0, import_css_tree.parse)(value, { context: "value" });
|
|
120
|
+
const shadowParts = extractShadowParts(ast);
|
|
121
|
+
return shadowParts.map((shadow) => {
|
|
152
122
|
const shadowValue = {};
|
|
153
123
|
const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
|
|
154
124
|
lengthProps.forEach((prop, index) => {
|
|
@@ -160,13 +130,13 @@ function parseBoxShadowValue(value) {
|
|
|
160
130
|
shadowValue.color = shadow.colorParts[0];
|
|
161
131
|
}
|
|
162
132
|
if (shadow.inset) {
|
|
163
|
-
shadowValue.inset =
|
|
133
|
+
shadowValue.inset = shadow.inset;
|
|
164
134
|
}
|
|
165
135
|
return shadowValue;
|
|
166
136
|
});
|
|
167
|
-
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return [];
|
|
168
139
|
}
|
|
169
|
-
return allShadows;
|
|
170
140
|
}
|
|
171
141
|
function normalizeLengthValue(value) {
|
|
172
142
|
if (!value) return "0px";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/boxShadowValueParser.ts"
|
|
4
|
-
"sourcesContent": ["import { parse, walk, generate } from '@eslint/css-tree';\nimport { isValidColor } from './color-lib-utils';\nimport { parseUnitValue, type ParsedUnitValue } from './value-utils';\nimport { isCssColorFunction } from './css-functions';\n\nexport interface BoxShadowValue {\n offsetX?: string;\n offsetY?: string;\n blurRadius?: string;\n spreadRadius?: string;\n color?: string;\n inset?: boolean;\n}\n\ninterface ShadowParts {\n lengthParts: string[];\n colorParts: string[];\n inset: boolean;\n}\n\n/**\n * Check if a CSS tree node represents a color value\n */\nfunction isColorValue(node: any): boolean {\n if (!node) return false;\n \n switch (node.type) {\n case 'Hash':\n return true; // #hex colors\n case 'Identifier':\n return isValidColor(node.name);\n case 'Function':\n return isCssColorFunction(node.name.toLowerCase());\n default:\n return false;\n }\n}\n\n/**\n * Check if a CSS tree node represents a length value\n */\nfunction isLengthValue(node: any): boolean {\n if (!node) return false;\n \n switch (node.type) {\n case 'Dimension':\n // Use existing unit parsing to validate the unit\n const dimensionStr = `${node.value}${node.unit}`;\n return parseUnitValue(dimensionStr) !== null;\n case 'Number':\n // Zero values without units are valid lengths\n return Number(node.value) === 0;\n default:\n return false;\n }\n}\n\n/**\n * Check if a CSS tree node represents the 'inset' keyword\n */\nfunction isInsetKeyword(node: any): boolean {\n return node?.type === 'Identifier' && node.name.toLowerCase() === 'inset';\n}\n\n/**\n * Extract shadow parts from CSS tree nodes\n */\nfunction extractShadowParts(valueText: string): ShadowParts[] {\n const shadows: ShadowParts[] = [];\n let currentShadow: ShadowParts = {\n lengthParts: [],\n colorParts: [],\n inset: false\n };\n\n try {\n const ast = parse(valueText, { context: 'value' as const });\n \n walk(ast, {\n enter(node: any) {\n // Skip nested function content for now\n if (node.type === 'Function') {\n return this.skip;\n }\n \n if (isInsetKeyword(node)) {\n currentShadow.inset = true;\n } else if (isLengthValue(node)) {\n currentShadow.lengthParts.push(generate(node));\n } else if (isColorValue(node)) {\n currentShadow.colorParts.push(generate(node));\n }\n }\n });\n \n // Add the current shadow if it has any content\n if (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset) {\n shadows.push(currentShadow);\n }\n \n } catch (error) {\n return [];\n }\n\n return shadows;\n}\n\n/**\n * Parse box-shadow value into structured format\n * Simplified version for ESLint v9 compatibility\n */\nexport function parseBoxShadowValue(value: string): BoxShadowValue[] {\n // Handle multiple shadows separated by commas\n const shadowStrings = value.split(',').map(s => s.trim());\n const allShadows: BoxShadowValue[] = [];\n \n for (const shadowString of shadowStrings) {\n const shadows = extractShadowParts(shadowString);\n \n const parsedShadows = shadows.map((shadow) => {\n /**\n * Box-shadow syntax:\n * Two, three, or four <length> values:\n * - offset-x offset-y [blur-radius] [spread-radius]\n * Optionally: inset keyword and color value\n */\n const shadowValue: BoxShadowValue = {};\n \n // Map length parts to shadow properties\n const lengthProps = ['offsetX', 'offsetY', 'blurRadius', 'spreadRadius'] as const;\n lengthProps.forEach((prop, index) => {\n if (shadow.lengthParts.length > index) {\n shadowValue[prop] = shadow.lengthParts[index];\n }\n });\n \n // Add color if present\n if (shadow.colorParts.length > 0) {\n shadowValue.color = shadow.colorParts[0];\n }\n \n // Add inset flag if present\n if (shadow.inset) {\n shadowValue.inset = true;\n }\n \n return shadowValue;\n });\n \n allShadows.push(...parsedShadows);\n }\n \n return allShadows;\n}\n\n/**\n * Normalize length value for comparison\n */\nfunction normalizeLengthValue(value: string | undefined): string {\n if (!value) return '0px';\n if (value === '0') return '0px';\n return value;\n}\n\n/**\n * Check if two parsed box-shadow values match\n */\nexport function isBoxShadowMatch(parsedCssValue: BoxShadowValue[], parsedValueHook: BoxShadowValue[]): boolean {\n // If the number of shadows doesn't match, they're not equal\n if (parsedCssValue.length !== parsedValueHook.length) {\n return false;\n }\n\n // Compare each shadow in the array\n for (let i = 0; i < parsedCssValue.length; i++) {\n const cssShadow = parsedCssValue[i];\n const hookShadow = parsedValueHook[i];\n\n // Compare color and inset properties\n if (cssShadow.color !== hookShadow.color || cssShadow.inset !== hookShadow.inset) {\n return false;\n }\n\n // Compare length properties\n const lengthProps = ['offsetX', 'offsetY', 'blurRadius', 'spreadRadius'] as const;\n for (const prop of lengthProps) {\n if (normalizeLengthValue(cssShadow[prop]) !== normalizeLengthValue(hookShadow[prop])) {\n return false;\n }\n }\n }\n\n return true;\n}\n", "import { ValueToStylingHooksMapping, ValueToStylingHookEntry } from '@salesforce-ux/sds-metadata/next';\nimport chroma from 'chroma-js';\nimport { generate } from '@eslint/css-tree';\nimport { isCssColorFunction } from './css-functions';\n\n/**\n * Perceptual color difference threshold (Delta E, CIEDE2000 via chroma.deltaE).\n * Lower values are stricter matches. Used to decide which hooks are \"close enough\".\n */\nconst DELTAE_THRESHOLD = 10;\n\n/**\n * Convert any valid CSS color (named, hex, rgb(a), hsl(a), etc.) to hex.\n * Returns null if the value is not a valid color.\n */\nconst convertToHex = (color: string): string | null => {\n try {\n // Try converting the color using chroma-js, which handles both named and hex colors\n return chroma(color).hex();\n } catch (e) {\n // If chroma can't process the color, it's likely invalid\n return null;\n }\n};\n\nconst isHookPropertyMatch = (hook: ValueToStylingHookEntry, cssProperty: string): boolean => {\n return hook.properties.includes(cssProperty) || hook.properties.includes(\"*\");\n}\n\nfunction getOrderByCssProp(cssProperty: string): string[] {\n if(cssProperty === 'color' || cssProperty === 'fill') {\n return [\"surface\", \"theme\", \"feedback\", \"reference\"];\n } else if(cssProperty.match(/background/)){\n return [\"surface\", \"surface-inverse\", \"theme\", \"feedback\", \"reference\"];\n } else if(cssProperty.match(/border/) || cssProperty.match(/outline/) || cssProperty.match(/stroke/)) {\n return [\"borders\", \"borders-inverse\", \"feedback\", \"theme\", \"reference\"];\n }\n return [\"surface\", \"surface-inverse\", \"borders\", \"borders-inverse\", \"theme\", \"feedback\", \"reference\"];\n}\n\n\n/**\n * Given an input color and the metadata mapping of supported colors to hooks,\n * suggest up to 5 styling hook names ordered by:\n * 1) Category priority: semantic -> system -> palette\n * 2) Perceptual distance (Delta E)\n * Also prioritizes exact color matches (distance 0).\n */\nconst findClosestColorHook = (\n color: string,\n supportedColors:ValueToStylingHooksMapping,\n cssProperty: string\n): string[] => {\n const closestHooks: Array<{distance: number, group: string, name: string}> = [];\n Object.entries(supportedColors).forEach(([sldsValue, data]) => {\n if (sldsValue && isValidColor(sldsValue)) {\n const hooks = data as ValueToStylingHookEntry[]; // Get the hooks for the sldsValue\n\n hooks.forEach((hook) => {\n // Exact match shortcut to avoid floating rounding noise\n const distance = (sldsValue.toLowerCase() === color.toLowerCase())\n ? 0\n : chroma.deltaE(sldsValue, color);\n \n // Check if the hook has the same property or universal selector\n if (isHookPropertyMatch(hook, cssProperty) && distance <= DELTAE_THRESHOLD) {\n // Add to same property hooks if within threshold\n closestHooks.push({ distance, group: hook.group, name: hook.name });\n }\n });\n }\n });\n\n const hooksByGroupMap:Record<string, string[]> = closestHooks.sort((a, b) => a.distance - b.distance).reduce((acc, hook) => {\n if (!acc[hook.group]) {\n acc[hook.group] = [];\n }\n acc[hook.group].push(hook.name);\n return acc;\n }, {});\n\n return getOrderByCssProp(cssProperty)\n .map(group => hooksByGroupMap[group]||[])\n .flat().slice(0, 5);\n};\n\n/**\n * Check if a value is any valid CSS color string (delegates to chroma-js).\n */\nconst isValidColor = (val:string):boolean => chroma.valid(val);\n\n/**\n * Extract a color string from a CSS AST node produced by @eslint/css-tree.\n * Supports Hash (#rrggbb), Identifier (named colors), and color Function nodes.\n * Returns null if the extracted value is not a valid color.\n */\nconst extractColorValue = (node: any): string | null => {\n let colorValue: string | null = null;\n \n switch (node.type) {\n case 'Hash':\n colorValue = `#${node.value}`;\n break;\n case 'Identifier':\n colorValue = node.name;\n break;\n case 'Function':\n // Only extract color functions\n if (isCssColorFunction(node.name)) {\n colorValue = generate(node);\n }\n break;\n }\n \n return colorValue && isValidColor(colorValue) ? colorValue : null;\n};\n\nexport { findClosestColorHook, convertToHex, isValidColor, extractColorValue };\n", "//stylelint-sds/packages/stylelint-plugin-slds/src/utils/css-functions.ts\n/**\n * Complete list of CSS functions that should be preserved/recognized\n */\nconst CSS_FUNCTIONS = [\n 'attr',\n 'calc',\n 'color-mix',\n 'conic-gradient',\n 'counter',\n 'cubic-bezier',\n 'linear-gradient',\n 'max',\n 'min',\n 'radial-gradient',\n 'repeating-conic-gradient',\n 'repeating-linear-gradient',\n 'repeating-radial-gradient',\n 'var'\n ];\n \n \n const CSS_MATH_FUNCTIONS = ['calc', 'min', 'max'];\n \n \n const RGB_COLOR_FUNCTIONS = ['rgb', 'rgba', 'hsl', 'hsla'];\n \n /**\n * Regex for matching any CSS function (for general detection)\n * Matches function names within other text\n */\n const cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join('|')})`);\n \n \n const cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join('|')})$`);\n \n \n const cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join('|')})$`);\n \n export function containsCssFunction(value: string): boolean {\n return cssFunctionsRegex.test(value);\n }\n \n /**\n * Check if a value is exactly a CSS function name\n */\n export function isCssFunction(value: string): boolean {\n return cssFunctionsExactRegex.test(value);\n }\n \n export function isCssMathFunction(value: string): boolean {\n return cssMathFunctionsRegex.test(value);\n }\n \n export function isCssColorFunction(value: string): boolean {\n return RGB_COLOR_FUNCTIONS.includes(value);\n }", "// Simplified value parsing\n\n/**\n * Checks if a value is a CSS global value.\n *\n * CSS global values are special keywords that can be used for any CSS property and have a universal meaning:\n * - initial: Resets the property to its initial value as defined by the CSS specification.\n * - inherit: Inherits the value from the parent element.\n * - unset: Acts as inherit if the property is inheritable, otherwise acts as initial.\n * - revert: Rolls back the property to the value established by the user-agent or user styles.\n * - revert-layer: Rolls back the property to the value established by the previous cascade layer.\n *\n * All CSS properties accept these global values, including but not limited to:\n * - color\n * - background\n * - font-size\n * - margin\n * - padding\n * - border\n * - display\n * - position\n * - z-index\n * - and many more\n *\n * These values are part of the CSS standard and are not considered violations, even if a rule would otherwise flag a value as invalid or non-design-token. They are always allowed for any property.\n *\n * @param value The CSS value to check.\n * @returns True if the value is a CSS global value, false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/unset\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert-layer\n */\nexport function isGlobalValue(value: string): boolean {\n return value === 'initial' || value === 'inherit' || value === 'unset' || value === 'revert' || value === 'revert-layer';\n }\n\n// Configurable list of allowed CSS units\nexport const ALLOWED_UNITS = ['px', 'em', 'rem', '%', 'ch'];\n\nexport type ParsedUnitValue = {\n unit: 'px' | 'rem' | '%' | 'em' | 'ch' | null;\n number: number;\n} | null;\n\nexport function parseUnitValue(value: string): ParsedUnitValue {\n if (!value) return null;\n \n // Create regex pattern from allowed units\n const unitsPattern = ALLOWED_UNITS.join('|');\n const regex = new RegExp(`^(-?\\\\d*\\\\.?\\\\d+)(${unitsPattern})?$`);\n const match = value.match(regex);\n if (!match) return null;\n \n const number = parseFloat(match[1]);\n const unit = match[2] ? (match[2] as 'px' | 'rem' | '%' | 'em' | 'ch') : null; // Keep unitless values as null\n \n if (isNaN(number)) return null;\n \n return { number, unit };\n}\n\nexport function toAlternateUnitValue(numberVal: number, unitType: 'px' | 'rem' | '%' | 'em' | 'ch' | null): ParsedUnitValue {\n if (unitType === 'px') {\n let floatValue = parseFloat(`${numberVal / 16}`);\n if (!isNaN(floatValue)) {\n return {\n unit: 'rem',\n number: parseFloat(floatValue.toFixed(4))\n }\n }\n } else if (unitType === 'rem') {\n const intValue = parseInt(`${numberVal * 16}`);\n if (!isNaN(intValue)) {\n return {\n unit: 'px',\n number: intValue\n }\n }\n }\n // For other units (%, em, ch) and unitless values, no alternate unit conversion available\n // These units are context-dependent and don't have standard conversion ratios\n return null;\n}"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../src/utils/boxShadowValueParser.ts"],
|
|
4
|
+
"sourcesContent": ["import { parse, walk, generate } from '@eslint/css-tree';\nimport { isValidColor } from './color-lib-utils';\nimport { parseUnitValue } from './value-utils';\nimport { isCssColorFunction, isCssMathFunction } from './css-functions';\nimport { getVarToken } from './css-utils';\n\nexport interface BoxShadowValue {\n offsetX?: string;\n offsetY?: string;\n blurRadius?: string;\n spreadRadius?: string;\n color?: string;\n inset?: boolean;\n}\n\ninterface ShadowParts {\n lengthParts: string[];\n colorParts: string[];\n inset: boolean;\n}\n\n/**\n * Check if a CSS tree node represents a color value\n */\nfunction isColorValue(node: any): boolean {\n if (!node) return false;\n \n switch (node.type) {\n case 'Hash':\n return true; // #hex colors\n case 'Identifier':\n return isValidColor(node.name);\n case 'Function':\n // Check for color functions (rgb, rgba, hsl, hsla)\n if (isCssColorFunction(node.name.toLowerCase())) {\n return true;\n }\n // Check for SLDS color vars: var(--slds-g-color-*)\n const varToken = getVarToken(node);\n return !!varToken.match(/^--slds-g-color/);\n default:\n return false;\n }\n}\n\n/**\n * Check if a CSS tree node represents a length value\n */\nfunction isLengthValue(node: any): boolean {\n if (!node) return false;\n \n switch (node.type) {\n case 'Dimension':\n // Use existing unit parsing to validate the unit\n const dimensionStr = `${node.value}${node.unit}`;\n return parseUnitValue(dimensionStr) !== null;\n case 'Number':\n // Zero values without units are valid lengths\n return Number(node.value) === 0;\n case 'Function':\n // Check for math functions (calc, min, max)\n if (isCssMathFunction(node.name.toLowerCase())) {\n return true;\n }\n // Check for SLDS spacing/sizing vars: var(--slds-g-spacing-*) or var(--slds-g-sizing-*)\n const varToken = getVarToken(node);\n return !!varToken.match(/^--slds-g-(spacing|sizing)/);\n default:\n return false;\n }\n}\n\n/**\n * Check if a CSS tree node represents the 'inset' keyword\n */\nfunction isInsetKeyword(node: any): boolean {\n return node?.type === 'Identifier' && node.name.toLowerCase() === 'inset';\n}\n\n/**\n * Check if a node is a comma separator (used to separate multiple shadows)\n */\nfunction isCommaSeparator(node: any): boolean {\n return node?.type === 'Operator' && node.value === ',';\n}\n\n/**\n * Extract shadow parts from CSS tree nodes\n * Properly handles comma-separated multiple shadows and var() functions\n */\nfunction extractShadowParts(ast: any): ShadowParts[] {\n const shadows: ShadowParts[] = [];\n let currentShadow: ShadowParts | null = null;\n\n // Helper to finalize current shadow\n const finalizeShadow = () => {\n if (currentShadow && (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset)) {\n shadows.push(currentShadow);\n }\n currentShadow = null;\n };\n\n walk(ast, {\n enter(node: any) {\n // Handle comma separator - finalize current shadow and start new one\n if (isCommaSeparator(node)) {\n finalizeShadow();\n return;\n }\n\n // Skip whitespace\n if (node.type === 'WhiteSpace') {\n return;\n }\n\n // Ensure current shadow exists for all value nodes\n currentShadow = currentShadow || { lengthParts: [], colorParts: [], inset: false };\n\n // Handle function nodes (var, calc, rgb, etc.)\n if (node.type === 'Function') {\n if (isColorValue(node)) {\n currentShadow.colorParts.push(generate(node));\n } else if (isLengthValue(node)) {\n currentShadow.lengthParts.push(generate(node));\n }\n // Skip children - we've handled the entire function\n return this.skip;\n }\n\n // Handle inset keyword\n if (isInsetKeyword(node)) {\n currentShadow.inset = true;\n return;\n }\n\n // Handle length values (Dimension, Number)\n if (isLengthValue(node)) {\n currentShadow.lengthParts.push(generate(node));\n return;\n }\n\n // Handle color values (Hash, Identifier)\n if (isColorValue(node)) {\n currentShadow.colorParts.push(generate(node));\n return;\n }\n }\n });\n\n // Finalize the last shadow\n finalizeShadow();\n\n return shadows;\n}\n\n/**\n * Parse box-shadow value into structured format\n * Uses CSS tree parser to properly handle comma-separated shadows and var() functions\n */\nexport function parseBoxShadowValue(value: string): BoxShadowValue[] {\n try {\n const ast = parse(value, { context: 'value' as const });\n const shadowParts = extractShadowParts(ast);\n\n return shadowParts.map((shadow) => {\n /**\n * Box-shadow syntax :\n * Two, three, or four <length> values.\n * If only two values are given, they are interpreted as <offset-x> and <offset-y> values.\n * If a third value is given, it is interpreted as a <blur-radius>.\n * If a fourth value is given, it is interpreted as a <spread-radius>.\n * Optionally, the inset keyword.\n * Optionally, a <color> value.\n */\n const shadowValue: BoxShadowValue = {};\n \n // Map length parts to shadow properties\n const lengthProps = ['offsetX', 'offsetY', 'blurRadius', 'spreadRadius'] as const;\n lengthProps.forEach((prop, index) => {\n if (shadow.lengthParts.length > index) {\n shadowValue[prop] = shadow.lengthParts[index];\n }\n });\n \n // Add color if present\n if (shadow.colorParts.length > 0) {\n shadowValue.color = shadow.colorParts[0];\n }\n \n // Add inset flag if present\n if (shadow.inset) {\n shadowValue.inset = shadow.inset;\n }\n \n return shadowValue;\n });\n } catch (error) {\n return [];\n }\n}\n\n/**\n * Normalize length value for comparison\n */\nfunction normalizeLengthValue(value: string | undefined): string {\n if (!value) return '0px';\n if (value === '0') return '0px';\n return value;\n}\n\n/**\n * Check if two parsed box-shadow values match\n */\nexport function isBoxShadowMatch(parsedCssValue: BoxShadowValue[], parsedValueHook: BoxShadowValue[]): boolean {\n // If the number of shadows doesn't match, they're not equal\n if (parsedCssValue.length !== parsedValueHook.length) {\n return false;\n }\n\n // Compare each shadow in the array\n for (let i = 0; i < parsedCssValue.length; i++) {\n const cssShadow = parsedCssValue[i];\n const hookShadow = parsedValueHook[i];\n\n // Compare color and inset properties\n if (cssShadow.color !== hookShadow.color || cssShadow.inset !== hookShadow.inset) {\n return false;\n }\n\n // Compare length properties\n const lengthProps = ['offsetX', 'offsetY', 'blurRadius', 'spreadRadius'] as const;\n for (const prop of lengthProps) {\n if (normalizeLengthValue(cssShadow[prop]) !== normalizeLengthValue(hookShadow[prop])) {\n return false;\n }\n }\n }\n\n return true;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -37,34 +37,7 @@ __export(color_lib_utils_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(color_lib_utils_exports);
|
|
38
38
|
var import_chroma_js = __toESM(require("chroma-js"));
|
|
39
39
|
var import_css_tree = require("@eslint/css-tree");
|
|
40
|
-
|
|
41
|
-
// src/utils/css-functions.ts
|
|
42
|
-
var CSS_FUNCTIONS = [
|
|
43
|
-
"attr",
|
|
44
|
-
"calc",
|
|
45
|
-
"color-mix",
|
|
46
|
-
"conic-gradient",
|
|
47
|
-
"counter",
|
|
48
|
-
"cubic-bezier",
|
|
49
|
-
"linear-gradient",
|
|
50
|
-
"max",
|
|
51
|
-
"min",
|
|
52
|
-
"radial-gradient",
|
|
53
|
-
"repeating-conic-gradient",
|
|
54
|
-
"repeating-linear-gradient",
|
|
55
|
-
"repeating-radial-gradient",
|
|
56
|
-
"var"
|
|
57
|
-
];
|
|
58
|
-
var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
|
|
59
|
-
var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
|
|
60
|
-
var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
|
|
61
|
-
var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
|
|
62
|
-
var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
|
|
63
|
-
function isCssColorFunction(value) {
|
|
64
|
-
return RGB_COLOR_FUNCTIONS.includes(value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/utils/color-lib-utils.ts
|
|
40
|
+
var import_css_functions = require("./css-functions");
|
|
68
41
|
var DELTAE_THRESHOLD = 10;
|
|
69
42
|
var convertToHex = (color) => {
|
|
70
43
|
try {
|
|
@@ -119,7 +92,7 @@ var extractColorValue = (node) => {
|
|
|
119
92
|
colorValue = node.name;
|
|
120
93
|
break;
|
|
121
94
|
case "Function":
|
|
122
|
-
if (isCssColorFunction(node.name)) {
|
|
95
|
+
if ((0, import_css_functions.isCssColorFunction)(node.name)) {
|
|
123
96
|
colorValue = (0, import_css_tree.generate)(node);
|
|
124
97
|
}
|
|
125
98
|
break;
|