@salesforce-ux/eslint-plugin-slds 0.5.3 → 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/build/index.js +2365 -50
  2. package/build/index.js.map +4 -4
  3. package/build/rules/enforce-bem-usage.js +325 -85
  4. package/build/rules/enforce-bem-usage.js.map +4 -4
  5. package/build/rules/modal-close-button-issue.js +324 -179
  6. package/build/rules/modal-close-button-issue.js.map +4 -4
  7. package/build/rules/no-deprecated-classes-slds2.js +247 -53
  8. package/build/rules/no-deprecated-classes-slds2.js.map +4 -4
  9. package/build/rules/v9/enforce-bem-usage.js +236 -0
  10. package/build/rules/v9/enforce-bem-usage.js.map +7 -0
  11. package/build/rules/v9/enforce-component-hook-naming-convention.js +262 -0
  12. package/build/rules/v9/enforce-component-hook-naming-convention.js.map +7 -0
  13. package/build/rules/v9/enforce-sds-to-slds-hooks.js +260 -0
  14. package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +7 -0
  15. package/build/rules/v9/lwc-token-to-slds-hook.js +369 -0
  16. package/build/rules/v9/lwc-token-to-slds-hook.js.map +7 -0
  17. package/build/rules/v9/no-deprecated-slds-classes.js +227 -0
  18. package/build/rules/v9/no-deprecated-slds-classes.js.map +7 -0
  19. package/build/rules/v9/no-deprecated-tokens-slds1.js +270 -0
  20. package/build/rules/v9/no-deprecated-tokens-slds1.js.map +7 -0
  21. package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +334 -0
  22. package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +7 -0
  23. package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +355 -0
  24. package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +7 -0
  25. package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +355 -0
  26. package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +7 -0
  27. package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +399 -0
  28. package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +7 -0
  29. package/build/rules/v9/no-hardcoded-values/handlers/index.js +830 -0
  30. package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +7 -0
  31. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +1132 -0
  32. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +7 -0
  33. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +1132 -0
  34. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +7 -0
  35. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +963 -0
  36. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +7 -0
  37. package/build/rules/v9/no-slds-class-overrides.js +233 -0
  38. package/build/rules/v9/no-slds-class-overrides.js.map +7 -0
  39. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +250 -0
  40. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +7 -0
  41. package/build/rules/v9/no-slds-private-var.js +230 -0
  42. package/build/rules/v9/no-slds-private-var.js.map +7 -0
  43. package/build/rules/v9/no-slds-var-without-fallback.js +339 -0
  44. package/build/rules/v9/no-slds-var-without-fallback.js.map +7 -0
  45. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +253 -0
  46. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +7 -0
  47. package/build/rules/v9/no-unsupported-hooks-slds2.js +243 -0
  48. package/build/rules/v9/no-unsupported-hooks-slds2.js.map +7 -0
  49. package/build/rules/v9/reduce-annotations.js +234 -0
  50. package/build/rules/v9/reduce-annotations.js.map +7 -0
  51. package/build/src/rules/enforce-bem-usage.d.ts +17 -0
  52. package/build/{rules → src/rules}/modal-close-button-issue.d.ts +2 -1
  53. package/build/{rules → src/rules}/no-deprecated-classes-slds2.d.ts +2 -1
  54. package/build/src/rules/v9/enforce-bem-usage.d.ts +3 -0
  55. package/build/src/rules/v9/enforce-component-hook-naming-convention.d.ts +3 -0
  56. package/build/src/rules/v9/enforce-sds-to-slds-hooks.d.ts +3 -0
  57. package/build/src/rules/v9/lwc-token-to-slds-hook.d.ts +3 -0
  58. package/build/src/rules/v9/no-deprecated-slds-classes.d.ts +3 -0
  59. package/build/src/rules/v9/no-deprecated-tokens-slds1.d.ts +3 -0
  60. package/build/src/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.d.ts +5 -0
  61. package/build/src/rules/v9/no-hardcoded-values/handlers/colorHandler.d.ts +7 -0
  62. package/build/src/rules/v9/no-hardcoded-values/handlers/densityHandler.d.ts +7 -0
  63. package/build/src/rules/v9/no-hardcoded-values/handlers/fontHandler.d.ts +6 -0
  64. package/build/src/rules/v9/no-hardcoded-values/handlers/index.d.ts +8 -0
  65. package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.d.ts +3 -0
  66. package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.d.ts +3 -0
  67. package/build/src/rules/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +11 -0
  68. package/build/src/rules/v9/no-slds-class-overrides.d.ts +8 -0
  69. package/build/src/rules/v9/no-slds-namespace-for-custom-hooks.d.ts +3 -0
  70. package/build/src/rules/v9/no-slds-private-var.d.ts +3 -0
  71. package/build/src/rules/v9/no-slds-var-without-fallback.d.ts +7 -0
  72. package/build/src/rules/v9/no-sldshook-fallback-for-lwctoken.d.ts +3 -0
  73. package/build/src/rules/v9/no-unsupported-hooks-slds2.d.ts +3 -0
  74. package/build/src/rules/v9/reduce-annotations.d.ts +3 -0
  75. package/build/src/types/index.d.ts +26 -0
  76. package/build/src/utils/boxShadowValueParser.d.ts +17 -0
  77. package/build/src/utils/color-lib-utils.d.ts +18 -0
  78. package/build/src/utils/css-functions.d.ts +7 -0
  79. package/build/src/utils/css-utils.d.ts +26 -0
  80. package/build/src/utils/hardcoded-shared-utils.d.ts +60 -0
  81. package/build/src/utils/property-matcher.d.ts +23 -0
  82. package/build/src/utils/rule-utils.d.ts +8 -0
  83. package/build/src/utils/styling-hook-utils.d.ts +7 -0
  84. package/build/src/utils/value-utils.d.ts +41 -0
  85. package/build/types/index.js +18 -0
  86. package/build/types/index.js.map +7 -0
  87. package/build/types/yaml.d.js +1 -0
  88. package/build/types/yaml.d.js.map +7 -0
  89. package/build/utils/boxShadowValueParser.js +200 -0
  90. package/build/utils/boxShadowValueParser.js.map +7 -0
  91. package/build/utils/color-lib-utils.js +160 -0
  92. package/build/utils/color-lib-utils.js.map +7 -0
  93. package/build/utils/css-functions.js +68 -0
  94. package/build/utils/css-functions.js.map +7 -0
  95. package/build/utils/css-utils.js +141 -0
  96. package/build/utils/css-utils.js.map +7 -0
  97. package/build/utils/hardcoded-shared-utils.js +303 -0
  98. package/build/utils/hardcoded-shared-utils.js.map +7 -0
  99. package/build/utils/node.js +158 -0
  100. package/build/{rules/utils → utils}/node.js.map +2 -2
  101. package/build/utils/property-matcher.js +159 -0
  102. package/build/utils/property-matcher.js.map +7 -0
  103. package/build/utils/rule-utils.js +46 -0
  104. package/build/utils/rule-utils.js.map +7 -0
  105. package/build/utils/styling-hook-utils.js +83 -0
  106. package/build/utils/styling-hook-utils.js.map +7 -0
  107. package/build/utils/value-utils.js +70 -0
  108. package/build/utils/value-utils.js.map +7 -0
  109. package/package.json +9 -4
  110. package/src/config/rule-messages.yml +143 -0
  111. package/build/rules/enforce-bem-usage.d.ts +0 -28
  112. package/build/rules/utils/node.js +0 -197
  113. package/build/rules/utils/rule.d.ts +0 -7
  114. package/build/rules/utils/rule.js +0 -10
  115. package/build/rules/utils/rule.js.map +0 -7
  116. /package/build/{index.d.ts → src/index.d.ts} +0 -0
  117. /package/build/{rules → src}/utils/node.d.ts +0 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Check if any of the hook properties match the provided cssProperty using wildcard matching.
3
+ * @param hookProperties - Array of property patterns (can contain wildcards like `*`)
4
+ * @param cssProperty - The CSS property to be checked
5
+ * @returns true if a match is found, otherwise false
6
+ */
7
+ export declare function matchesCssProperty(hookProperties: string[], cssProperty: string): boolean;
8
+ export declare function isBorderColorProperty(cssProperty: string): boolean;
9
+ export declare function isBorderWidthProperty(cssProperty: string): boolean;
10
+ export declare function isMarginProperty(cssProperty: string): boolean;
11
+ export declare function isPaddingProperty(cssProperty: string): boolean;
12
+ export declare function isBorderRadius(cssProperty: string): boolean;
13
+ export declare function isDimensionProperty(cssProperty: string): boolean;
14
+ export declare function isInsetProperty(cssProperty: string): boolean;
15
+ export declare const fontProperties: string[];
16
+ export declare const colorProperties: string[];
17
+ export declare const densificationProperties: string[];
18
+ /**
19
+ * Convert property patterns to CSS AST selector patterns
20
+ * Handles wildcards (*) and creates proper ESLint CSS selector syntax
21
+ */
22
+ export declare function toSelector(properties: string[]): string;
23
+ export declare function resolvePropertyToMatch(cssProperty: string): string;
@@ -0,0 +1,8 @@
1
+ import { Rule } from 'eslint';
2
+ /**
3
+ * Check if a specific ESLint rule is enabled in the current configuration
4
+ * @param context - ESLint rule context
5
+ * @param ruleName - rule name
6
+ * @returns true if the rule is enabled, false otherwise
7
+ */
8
+ export declare function isRuleEnabled(context: Rule.RuleContext, ruleName: string): boolean;
@@ -0,0 +1,7 @@
1
+ import type { ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata';
2
+ import { ParsedUnitValue } from './value-utils';
3
+ /**
4
+ * Get styling hooks for a density value using structured data from CSS AST
5
+ * Eliminates regex parsing by accepting pre-parsed dimension data
6
+ */
7
+ export declare function getStylingHooksForDensityValue(parsedValue: ParsedUnitValue, supportedStylinghooks: ValueToStylingHooksMapping, cssProperty: string): string[];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Checks if a value is a CSS global value.
3
+ *
4
+ * CSS global values are special keywords that can be used for any CSS property and have a universal meaning:
5
+ * - initial: Resets the property to its initial value as defined by the CSS specification.
6
+ * - inherit: Inherits the value from the parent element.
7
+ * - unset: Acts as inherit if the property is inheritable, otherwise acts as initial.
8
+ * - revert: Rolls back the property to the value established by the user-agent or user styles.
9
+ * - revert-layer: Rolls back the property to the value established by the previous cascade layer.
10
+ *
11
+ * All CSS properties accept these global values, including but not limited to:
12
+ * - color
13
+ * - background
14
+ * - font-size
15
+ * - margin
16
+ * - padding
17
+ * - border
18
+ * - display
19
+ * - position
20
+ * - z-index
21
+ * - and many more
22
+ *
23
+ * 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.
24
+ *
25
+ * @param value The CSS value to check.
26
+ * @returns True if the value is a CSS global value, false otherwise.
27
+ *
28
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
29
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
30
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/unset
31
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert
32
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert-layer
33
+ */
34
+ export declare function isGlobalValue(value: string): boolean;
35
+ export declare const ALLOWED_UNITS: string[];
36
+ export type ParsedUnitValue = {
37
+ unit: 'px' | 'rem' | '%' | 'em' | 'ch' | null;
38
+ number: number;
39
+ } | null;
40
+ export declare function parseUnitValue(value: string): ParsedUnitValue;
41
+ export declare function toAlternateUnitValue(numberVal: number, unitType: 'px' | 'rem' | '%' | 'em' | 'ch' | null): ParsedUnitValue;
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/types/index.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types/index.ts"],
4
+ "sourcesContent": ["import { Rule } from 'eslint';\nimport type { ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata';\n\n/**\n * Context interface for handlers to access necessary dependencies\n */\nexport interface HandlerContext {\n valueToStylinghook: ValueToStylingHooksMapping;\n context: Rule.RuleContext;\n sourceCode: any;\n}\n\n\n\n/**\n * Configuration for creating the rule\n */\nexport interface RuleConfig {\n ruleConfig: {\n type: 'problem' | 'suggestion' | 'layout';\n description: string;\n url?: string;\n messages: Record<string, string>;\n };\n valueToStylinghook: ValueToStylingHooksMapping;\n}\n\n/**\n * Handler function signature for CSS declarations\n */\nexport type DeclarationHandler = (node: any, context: HandlerContext) => void;"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=yaml.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,200 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/utils/boxShadowValueParser.ts
30
+ var boxShadowValueParser_exports = {};
31
+ __export(boxShadowValueParser_exports, {
32
+ isBoxShadowMatch: () => isBoxShadowMatch,
33
+ parseBoxShadowValue: () => parseBoxShadowValue
34
+ });
35
+ 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
+ var import_css_tree = require("@eslint/css-tree");
41
+
42
+ // src/utils/css-functions.ts
43
+ var CSS_FUNCTIONS = [
44
+ "attr",
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
86
+ function isColorValue(node) {
87
+ if (!node) return false;
88
+ switch (node.type) {
89
+ case "Hash":
90
+ return true;
91
+ // #hex colors
92
+ case "Identifier":
93
+ return isValidColor(node.name);
94
+ case "Function":
95
+ return isCssColorFunction(node.name.toLowerCase());
96
+ default:
97
+ return false;
98
+ }
99
+ }
100
+ function isLengthValue(node) {
101
+ if (!node) return false;
102
+ switch (node.type) {
103
+ case "Dimension":
104
+ const dimensionStr = `${node.value}${node.unit}`;
105
+ return parseUnitValue(dimensionStr) !== null;
106
+ case "Number":
107
+ return Number(node.value) === 0;
108
+ default:
109
+ return false;
110
+ }
111
+ }
112
+ function isInsetKeyword(node) {
113
+ return node?.type === "Identifier" && node.name.toLowerCase() === "inset";
114
+ }
115
+ function extractShadowParts(valueText) {
116
+ const shadows = [];
117
+ let currentShadow = {
118
+ lengthParts: [],
119
+ colorParts: [],
120
+ inset: false
121
+ };
122
+ try {
123
+ const ast = (0, import_css_tree2.parse)(valueText, { context: "value" });
124
+ (0, import_css_tree2.walk)(ast, {
125
+ enter(node) {
126
+ if (node.type === "Function") {
127
+ return this.skip;
128
+ }
129
+ if (isInsetKeyword(node)) {
130
+ currentShadow.inset = true;
131
+ } else if (isLengthValue(node)) {
132
+ currentShadow.lengthParts.push((0, import_css_tree2.generate)(node));
133
+ } else if (isColorValue(node)) {
134
+ currentShadow.colorParts.push((0, import_css_tree2.generate)(node));
135
+ }
136
+ }
137
+ });
138
+ if (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset) {
139
+ shadows.push(currentShadow);
140
+ }
141
+ } catch (error) {
142
+ return [];
143
+ }
144
+ return shadows;
145
+ }
146
+ function parseBoxShadowValue(value) {
147
+ const shadowStrings = value.split(",").map((s) => s.trim());
148
+ const allShadows = [];
149
+ for (const shadowString of shadowStrings) {
150
+ const shadows = extractShadowParts(shadowString);
151
+ const parsedShadows = shadows.map((shadow) => {
152
+ const shadowValue = {};
153
+ const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
154
+ lengthProps.forEach((prop, index) => {
155
+ if (shadow.lengthParts.length > index) {
156
+ shadowValue[prop] = shadow.lengthParts[index];
157
+ }
158
+ });
159
+ if (shadow.colorParts.length > 0) {
160
+ shadowValue.color = shadow.colorParts[0];
161
+ }
162
+ if (shadow.inset) {
163
+ shadowValue.inset = true;
164
+ }
165
+ return shadowValue;
166
+ });
167
+ allShadows.push(...parsedShadows);
168
+ }
169
+ return allShadows;
170
+ }
171
+ function normalizeLengthValue(value) {
172
+ if (!value) return "0px";
173
+ if (value === "0") return "0px";
174
+ return value;
175
+ }
176
+ function isBoxShadowMatch(parsedCssValue, parsedValueHook) {
177
+ if (parsedCssValue.length !== parsedValueHook.length) {
178
+ return false;
179
+ }
180
+ for (let i = 0; i < parsedCssValue.length; i++) {
181
+ const cssShadow = parsedCssValue[i];
182
+ const hookShadow = parsedValueHook[i];
183
+ if (cssShadow.color !== hookShadow.color || cssShadow.inset !== hookShadow.inset) {
184
+ return false;
185
+ }
186
+ const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
187
+ for (const prop of lengthProps) {
188
+ if (normalizeLengthValue(cssShadow[prop]) !== normalizeLengthValue(hookShadow[prop])) {
189
+ return false;
190
+ }
191
+ }
192
+ }
193
+ return true;
194
+ }
195
+ // Annotate the CommonJS export names for ESM import in node:
196
+ 0 && (module.exports = {
197
+ isBoxShadowMatch,
198
+ parseBoxShadowValue
199
+ });
200
+ //# sourceMappingURL=boxShadowValueParser.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/boxShadowValueParser.ts", "../../src/utils/color-lib-utils.ts", "../../src/utils/css-functions.ts", "../../src/utils/value-utils.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", "//stylelint-sds/packages/stylelint-plugin-slds/src/utils/color-lib-utils.ts\nimport { ValueToStylingHooksMapping, ValueToStylingHookEntry } from '@salesforce-ux/sds-metadata';\nimport chroma from 'chroma-js';\nimport { generate } from '@eslint/css-tree';\nimport { isCssColorFunction } from './css-functions';\n\nconst LAB_THRESHOLD = 25; // Adjust this to set how strict the matching should be\n\nconst isHardCodedColor = (color: string): boolean => {\n const colorRegex =\n /\\b(rgb|rgba)\\((\\s*\\d{1,3}\\s*,\\s*){2,3}\\s*(0|1|0?\\.\\d+)\\s*\\)|#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\\b|[a-zA-Z]+/g;\n return colorRegex.test(color);\n};\n\nconst isHexCode = (color: string): boolean => {\n const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/; // Pattern for #RGB or #RRGGBB\n return hexPattern.test(color);\n};\n\n// Convert a named color or hex code into a hex format using chroma-js\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\n// Find the closest color hook using LAB distance\nconst findClosestColorHook = (\n color: string,\n supportedColors:ValueToStylingHooksMapping,\n cssProperty: string\n): string[] => {\n const returnStylingHooks: string[] = [];\n const closestHooksWithSameProperty: { name: string; distance: number }[] = [];\n const closestHooksWithoutSameProperty: { name: string; distance: number }[] =\n [];\n const closestHooksWithAllProperty: { name: string; distance: number }[] =\n [];\n const labColor = chroma(color).lab();\n\n Object.entries(supportedColors).forEach(([sldsValue, data]) => {\n if (sldsValue && isHexCode(sldsValue)) {\n const hooks = data as ValueToStylingHookEntry[]; // Get the hooks for the sldsValue\n\n hooks.forEach((hook) => {\n const labSupportedColor = chroma(sldsValue).lab();\n const distance = (JSON.stringify(labColor) === JSON.stringify(labSupportedColor)) ? 0\n : chroma.distance(chroma.lab(...labColor), chroma.lab(...labSupportedColor), \"lab\");\n // Check if the hook has the same property\n if (hook.properties.includes(cssProperty)) {\n // Add to same property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithSameProperty.push({ name: hook.name, distance });\n }\n } \n // Check for the universal selector\n else if ( hook.properties.includes(\"*\") ){\n // Add to same property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithAllProperty.push({ name: hook.name, distance });\n }\n }\n else {\n // Add to different property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithoutSameProperty.push({ name: hook.name, distance });\n }\n }\n });\n }\n });\n\n// Group hooks by their priority\nconst closesthookGroups = [\n { hooks: closestHooksWithSameProperty, distance: 0 },\n { hooks: closestHooksWithAllProperty, distance: 0 },\n { hooks: closestHooksWithSameProperty, distance: Infinity }, // For hooks with distance > 0\n { hooks: closestHooksWithAllProperty, distance: Infinity },\n { hooks: closestHooksWithoutSameProperty, distance: Infinity },\n];\n\nfor (const group of closesthookGroups) {\n // Filter hooks based on the distance condition\n const filteredHooks = group.hooks.filter(h => \n group.distance === 0 ? h.distance === 0 : h.distance > 0\n );\n\n if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {\n filteredHooks.sort((a, b) => a.distance - b.distance);\n returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));\n }\n}\n\n\n return Array.from(new Set(returnStylingHooks));\n};\n\n/**\n * This method is usefull to identify all possible css color values.\n * - names colors\n * - 6,8 digit hex\n * - rgb and rgba\n * - hsl and hsla\n */\nconst isValidColor = (val:string):boolean => chroma.valid(val);\n\n/**\n * Extract color value from CSS AST node\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, isHexCode, isHardCodedColor, 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAsC;;;ACEtC,uBAAmB;AACnB,sBAAyB;;;ACCzB,IAAM,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,qBAAqB,CAAC,QAAQ,OAAO,KAAK;AAGhD,IAAM,sBAAsB,CAAC,OAAO,QAAQ,OAAO,MAAM;AAMzD,IAAM,oBAAoB,IAAI,OAAO,MAAM,cAAc,KAAK,GAAG,CAAC,GAAG;AAGrE,IAAM,yBAAyB,IAAI,OAAO,OAAO,cAAc,KAAK,GAAG,CAAC,IAAI;AAG5E,IAAM,wBAAwB,IAAI,OAAO,OAAO,mBAAmB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D,UAAI,OAAO,WAAW,SAAS,GAAG;AAChC,oBAAY,QAAQ,OAAO,WAAW,CAAC;AAAA,MACzC;AAGA,UAAI,OAAO,OAAO;AAChB,oBAAY,QAAQ;AAAA,MACtB;AAEA,aAAO;AAAA,IACT,CAAC;AAED,eAAW,KAAK,GAAG,aAAa;AAAA,EAClC;AAEA,SAAO;AACT;AAKA,SAAS,qBAAqB,OAAmC;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,UAAU,IAAK,QAAO;AAC1B,SAAO;AACT;AAKO,SAAS,iBAAiB,gBAAkC,iBAA4C;AAE7G,MAAI,eAAe,WAAW,gBAAgB,QAAQ;AACpD,WAAO;AAAA,EACT;AAGA,WAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC9C,UAAM,YAAY,eAAe,CAAC;AAClC,UAAM,aAAa,gBAAgB,CAAC;AAGpC,QAAI,UAAU,UAAU,WAAW,SAAS,UAAU,UAAU,WAAW,OAAO;AAChF,aAAO;AAAA,IACT;AAGA,UAAM,cAAc,CAAC,WAAW,WAAW,cAAc,cAAc;AACvE,eAAW,QAAQ,aAAa;AAC9B,UAAI,qBAAqB,UAAU,IAAI,CAAC,MAAM,qBAAqB,WAAW,IAAI,CAAC,GAAG;AACpF,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": ["import_css_tree", "chroma"]
7
+ }
@@ -0,0 +1,160 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/utils/color-lib-utils.ts
30
+ var color_lib_utils_exports = {};
31
+ __export(color_lib_utils_exports, {
32
+ convertToHex: () => convertToHex,
33
+ extractColorValue: () => extractColorValue,
34
+ findClosestColorHook: () => findClosestColorHook,
35
+ isHardCodedColor: () => isHardCodedColor,
36
+ isHexCode: () => isHexCode,
37
+ isValidColor: () => isValidColor
38
+ });
39
+ module.exports = __toCommonJS(color_lib_utils_exports);
40
+ var import_chroma_js = __toESM(require("chroma-js"));
41
+ var import_css_tree = require("@eslint/css-tree");
42
+
43
+ // src/utils/css-functions.ts
44
+ var CSS_FUNCTIONS = [
45
+ "attr",
46
+ "calc",
47
+ "color-mix",
48
+ "conic-gradient",
49
+ "counter",
50
+ "cubic-bezier",
51
+ "linear-gradient",
52
+ "max",
53
+ "min",
54
+ "radial-gradient",
55
+ "repeating-conic-gradient",
56
+ "repeating-linear-gradient",
57
+ "repeating-radial-gradient",
58
+ "var"
59
+ ];
60
+ var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
61
+ var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
62
+ var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
63
+ var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
64
+ var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
65
+ function isCssColorFunction(value) {
66
+ return RGB_COLOR_FUNCTIONS.includes(value);
67
+ }
68
+
69
+ // src/utils/color-lib-utils.ts
70
+ var LAB_THRESHOLD = 25;
71
+ var isHardCodedColor = (color) => {
72
+ const colorRegex = /\b(rgb|rgba)\((\s*\d{1,3}\s*,\s*){2,3}\s*(0|1|0?\.\d+)\s*\)|#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b|[a-zA-Z]+/g;
73
+ return colorRegex.test(color);
74
+ };
75
+ var isHexCode = (color) => {
76
+ const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
77
+ return hexPattern.test(color);
78
+ };
79
+ var convertToHex = (color) => {
80
+ try {
81
+ return (0, import_chroma_js.default)(color).hex();
82
+ } catch (e) {
83
+ return null;
84
+ }
85
+ };
86
+ var findClosestColorHook = (color, supportedColors, cssProperty) => {
87
+ const returnStylingHooks = [];
88
+ const closestHooksWithSameProperty = [];
89
+ const closestHooksWithoutSameProperty = [];
90
+ const closestHooksWithAllProperty = [];
91
+ const labColor = (0, import_chroma_js.default)(color).lab();
92
+ Object.entries(supportedColors).forEach(([sldsValue, data]) => {
93
+ if (sldsValue && isHexCode(sldsValue)) {
94
+ const hooks = data;
95
+ hooks.forEach((hook) => {
96
+ const labSupportedColor = (0, import_chroma_js.default)(sldsValue).lab();
97
+ const distance = JSON.stringify(labColor) === JSON.stringify(labSupportedColor) ? 0 : import_chroma_js.default.distance(import_chroma_js.default.lab(...labColor), import_chroma_js.default.lab(...labSupportedColor), "lab");
98
+ if (hook.properties.includes(cssProperty)) {
99
+ if (distance <= LAB_THRESHOLD) {
100
+ closestHooksWithSameProperty.push({ name: hook.name, distance });
101
+ }
102
+ } else if (hook.properties.includes("*")) {
103
+ if (distance <= LAB_THRESHOLD) {
104
+ closestHooksWithAllProperty.push({ name: hook.name, distance });
105
+ }
106
+ } else {
107
+ if (distance <= LAB_THRESHOLD) {
108
+ closestHooksWithoutSameProperty.push({ name: hook.name, distance });
109
+ }
110
+ }
111
+ });
112
+ }
113
+ });
114
+ const closesthookGroups = [
115
+ { hooks: closestHooksWithSameProperty, distance: 0 },
116
+ { hooks: closestHooksWithAllProperty, distance: 0 },
117
+ { hooks: closestHooksWithSameProperty, distance: Infinity },
118
+ // For hooks with distance > 0
119
+ { hooks: closestHooksWithAllProperty, distance: Infinity },
120
+ { hooks: closestHooksWithoutSameProperty, distance: Infinity }
121
+ ];
122
+ for (const group of closesthookGroups) {
123
+ const filteredHooks = group.hooks.filter(
124
+ (h) => group.distance === 0 ? h.distance === 0 : h.distance > 0
125
+ );
126
+ if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {
127
+ filteredHooks.sort((a, b) => a.distance - b.distance);
128
+ returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));
129
+ }
130
+ }
131
+ return Array.from(new Set(returnStylingHooks));
132
+ };
133
+ var isValidColor = (val) => import_chroma_js.default.valid(val);
134
+ var extractColorValue = (node) => {
135
+ let colorValue = null;
136
+ switch (node.type) {
137
+ case "Hash":
138
+ colorValue = `#${node.value}`;
139
+ break;
140
+ case "Identifier":
141
+ colorValue = node.name;
142
+ break;
143
+ case "Function":
144
+ if (isCssColorFunction(node.name)) {
145
+ colorValue = (0, import_css_tree.generate)(node);
146
+ }
147
+ break;
148
+ }
149
+ return colorValue && isValidColor(colorValue) ? colorValue : null;
150
+ };
151
+ // Annotate the CommonJS export names for ESM import in node:
152
+ 0 && (module.exports = {
153
+ convertToHex,
154
+ extractColorValue,
155
+ findClosestColorHook,
156
+ isHardCodedColor,
157
+ isHexCode,
158
+ isValidColor
159
+ });
160
+ //# sourceMappingURL=color-lib-utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/color-lib-utils.ts", "../../src/utils/css-functions.ts"],
4
+ "sourcesContent": ["//stylelint-sds/packages/stylelint-plugin-slds/src/utils/color-lib-utils.ts\nimport { ValueToStylingHooksMapping, ValueToStylingHookEntry } from '@salesforce-ux/sds-metadata';\nimport chroma from 'chroma-js';\nimport { generate } from '@eslint/css-tree';\nimport { isCssColorFunction } from './css-functions';\n\nconst LAB_THRESHOLD = 25; // Adjust this to set how strict the matching should be\n\nconst isHardCodedColor = (color: string): boolean => {\n const colorRegex =\n /\\b(rgb|rgba)\\((\\s*\\d{1,3}\\s*,\\s*){2,3}\\s*(0|1|0?\\.\\d+)\\s*\\)|#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\\b|[a-zA-Z]+/g;\n return colorRegex.test(color);\n};\n\nconst isHexCode = (color: string): boolean => {\n const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/; // Pattern for #RGB or #RRGGBB\n return hexPattern.test(color);\n};\n\n// Convert a named color or hex code into a hex format using chroma-js\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\n// Find the closest color hook using LAB distance\nconst findClosestColorHook = (\n color: string,\n supportedColors:ValueToStylingHooksMapping,\n cssProperty: string\n): string[] => {\n const returnStylingHooks: string[] = [];\n const closestHooksWithSameProperty: { name: string; distance: number }[] = [];\n const closestHooksWithoutSameProperty: { name: string; distance: number }[] =\n [];\n const closestHooksWithAllProperty: { name: string; distance: number }[] =\n [];\n const labColor = chroma(color).lab();\n\n Object.entries(supportedColors).forEach(([sldsValue, data]) => {\n if (sldsValue && isHexCode(sldsValue)) {\n const hooks = data as ValueToStylingHookEntry[]; // Get the hooks for the sldsValue\n\n hooks.forEach((hook) => {\n const labSupportedColor = chroma(sldsValue).lab();\n const distance = (JSON.stringify(labColor) === JSON.stringify(labSupportedColor)) ? 0\n : chroma.distance(chroma.lab(...labColor), chroma.lab(...labSupportedColor), \"lab\");\n // Check if the hook has the same property\n if (hook.properties.includes(cssProperty)) {\n // Add to same property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithSameProperty.push({ name: hook.name, distance });\n }\n } \n // Check for the universal selector\n else if ( hook.properties.includes(\"*\") ){\n // Add to same property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithAllProperty.push({ name: hook.name, distance });\n }\n }\n else {\n // Add to different property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithoutSameProperty.push({ name: hook.name, distance });\n }\n }\n });\n }\n });\n\n// Group hooks by their priority\nconst closesthookGroups = [\n { hooks: closestHooksWithSameProperty, distance: 0 },\n { hooks: closestHooksWithAllProperty, distance: 0 },\n { hooks: closestHooksWithSameProperty, distance: Infinity }, // For hooks with distance > 0\n { hooks: closestHooksWithAllProperty, distance: Infinity },\n { hooks: closestHooksWithoutSameProperty, distance: Infinity },\n];\n\nfor (const group of closesthookGroups) {\n // Filter hooks based on the distance condition\n const filteredHooks = group.hooks.filter(h => \n group.distance === 0 ? h.distance === 0 : h.distance > 0\n );\n\n if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {\n filteredHooks.sort((a, b) => a.distance - b.distance);\n returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));\n }\n}\n\n\n return Array.from(new Set(returnStylingHooks));\n};\n\n/**\n * This method is usefull to identify all possible css color values.\n * - names colors\n * - 6,8 digit hex\n * - rgb and rgba\n * - hsl and hsla\n */\nconst isValidColor = (val:string):boolean => chroma.valid(val);\n\n/**\n * Extract color value from CSS AST node\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, isHexCode, isHardCodedColor, 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 }"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAmB;AACnB,sBAAyB;;;ACCzB,IAAM,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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AAC;AAC/C;AASA,IAAM,eAAe,CAAC,QAAuB,iBAAAA,QAAO,MAAM,GAAG;AAK7D,IAAM,oBAAoB,CAAC,SAA6B;AACtD,MAAI,aAA4B;AAEhC,UAAQ,KAAK,MAAM;AAAA,IACjB,KAAK;AACH,mBAAa,IAAI,KAAK,KAAK;AAC3B;AAAA,IACF,KAAK;AACH,mBAAa,KAAK;AAClB;AAAA,IACF,KAAK;AAEH,UAAI,mBAAmB,KAAK,IAAI,GAAG;AACjC,yBAAa,0BAAS,IAAI;AAAA,MAC5B;AACA;AAAA,EACJ;AAEA,SAAO,cAAc,aAAa,UAAU,IAAI,aAAa;AAC/D;",
6
+ "names": ["chroma"]
7
+ }
@@ -0,0 +1,68 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/css-functions.ts
20
+ var css_functions_exports = {};
21
+ __export(css_functions_exports, {
22
+ containsCssFunction: () => containsCssFunction,
23
+ isCssColorFunction: () => isCssColorFunction,
24
+ isCssFunction: () => isCssFunction,
25
+ isCssMathFunction: () => isCssMathFunction
26
+ });
27
+ module.exports = __toCommonJS(css_functions_exports);
28
+ var CSS_FUNCTIONS = [
29
+ "attr",
30
+ "calc",
31
+ "color-mix",
32
+ "conic-gradient",
33
+ "counter",
34
+ "cubic-bezier",
35
+ "linear-gradient",
36
+ "max",
37
+ "min",
38
+ "radial-gradient",
39
+ "repeating-conic-gradient",
40
+ "repeating-linear-gradient",
41
+ "repeating-radial-gradient",
42
+ "var"
43
+ ];
44
+ var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
45
+ var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
46
+ var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
47
+ var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
48
+ var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
49
+ function containsCssFunction(value) {
50
+ return cssFunctionsRegex.test(value);
51
+ }
52
+ function isCssFunction(value) {
53
+ return cssFunctionsExactRegex.test(value);
54
+ }
55
+ function isCssMathFunction(value) {
56
+ return cssMathFunctionsRegex.test(value);
57
+ }
58
+ function isCssColorFunction(value) {
59
+ return RGB_COLOR_FUNCTIONS.includes(value);
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ containsCssFunction,
64
+ isCssColorFunction,
65
+ isCssFunction,
66
+ isCssMathFunction
67
+ });
68
+ //# sourceMappingURL=css-functions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/css-functions.ts"],
4
+ "sourcesContent": ["//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 }"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAM,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,qBAAqB,CAAC,QAAQ,OAAO,KAAK;AAGhD,IAAM,sBAAsB,CAAC,OAAO,QAAQ,OAAO,MAAM;AAMzD,IAAM,oBAAoB,IAAI,OAAO,MAAM,cAAc,KAAK,GAAG,CAAC,GAAG;AAGrE,IAAM,yBAAyB,IAAI,OAAO,OAAO,cAAc,KAAK,GAAG,CAAC,IAAI;AAG5E,IAAM,wBAAwB,IAAI,OAAO,OAAO,mBAAmB,KAAK,GAAG,CAAC,IAAI;AAEzE,SAAS,oBAAoB,OAAwB;AAC1D,SAAO,kBAAkB,KAAK,KAAK;AACrC;AAKO,SAAS,cAAc,OAAwB;AACpD,SAAO,uBAAuB,KAAK,KAAK;AAC1C;AAEO,SAAS,kBAAkB,OAAwB;AACxD,SAAO,sBAAsB,KAAK,KAAK;AACzC;AAEO,SAAS,mBAAmB,OAAwB;AACzD,SAAO,oBAAoB,SAAS,KAAK;AAC3C;",
6
+ "names": []
7
+ }