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

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 (67) hide show
  1. package/README.md +17 -1
  2. package/build/index.js +1072 -1016
  3. package/build/index.js.map +4 -4
  4. package/build/rules/enforce-bem-usage.js +5 -5
  5. package/build/rules/enforce-bem-usage.js.map +3 -3
  6. package/build/rules/no-deprecated-classes-slds2.js +2 -2
  7. package/build/rules/no-deprecated-classes-slds2.js.map +2 -2
  8. package/build/rules/v9/enforce-bem-usage.js +2 -2
  9. package/build/rules/v9/enforce-bem-usage.js.map +2 -2
  10. package/build/rules/v9/enforce-component-hook-naming-convention.js +2 -2
  11. package/build/rules/v9/enforce-component-hook-naming-convention.js.map +2 -2
  12. package/build/rules/v9/enforce-sds-to-slds-hooks.js +2 -2
  13. package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +2 -2
  14. package/build/rules/v9/lwc-token-to-slds-hook.js +42 -3
  15. package/build/rules/v9/lwc-token-to-slds-hook.js.map +4 -4
  16. package/build/rules/v9/no-deprecated-slds-classes.js +2 -2
  17. package/build/rules/v9/no-deprecated-slds-classes.js.map +2 -2
  18. package/build/rules/v9/no-deprecated-tokens-slds1.js +2 -2
  19. package/build/rules/v9/no-deprecated-tokens-slds1.js.map +2 -2
  20. package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +49 -54
  21. package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +3 -3
  22. package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +9 -2
  23. package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +3 -3
  24. package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +14 -3
  25. package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +3 -3
  26. package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +14 -3
  27. package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +3 -3
  28. package/build/rules/v9/no-hardcoded-values/handlers/index.js +86 -90
  29. package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +3 -3
  30. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +116 -96
  31. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +4 -4
  32. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +116 -96
  33. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +4 -4
  34. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +110 -92
  35. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +3 -3
  36. package/build/rules/v9/no-slds-class-overrides.js +2 -2
  37. package/build/rules/v9/no-slds-class-overrides.js.map +2 -2
  38. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +2 -2
  39. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +2 -2
  40. package/build/rules/v9/no-slds-var-without-fallback.js +121 -35
  41. package/build/rules/v9/no-slds-var-without-fallback.js.map +4 -4
  42. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +2 -2
  43. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +2 -2
  44. package/build/rules/v9/no-unsupported-hooks-slds2.js +2 -2
  45. package/build/rules/v9/no-unsupported-hooks-slds2.js.map +2 -2
  46. package/build/src/rules/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +3 -1
  47. package/build/src/rules/v9/no-slds-var-without-fallback.d.ts +4 -0
  48. package/build/src/utils/css-utils.d.ts +19 -0
  49. package/build/src/utils/rule-utils.d.ts +8 -0
  50. package/build/src/utils/value-utils.d.ts +3 -2
  51. package/build/types/index.js.map +1 -1
  52. package/build/utils/boxShadowValueParser.js +4 -1
  53. package/build/utils/boxShadowValueParser.js.map +2 -2
  54. package/build/utils/color-lib-utils.js.map +1 -1
  55. package/build/utils/css-utils.js +108 -0
  56. package/build/utils/css-utils.js.map +4 -4
  57. package/build/utils/hardcoded-shared-utils.js +5 -2
  58. package/build/utils/hardcoded-shared-utils.js.map +3 -3
  59. package/build/utils/property-matcher.js +1 -1
  60. package/build/utils/property-matcher.js.map +2 -2
  61. package/build/utils/rule-utils.js +46 -0
  62. package/build/utils/rule-utils.js.map +7 -0
  63. package/build/utils/styling-hook-utils.js +4 -1
  64. package/build/utils/styling-hook-utils.js.map +2 -2
  65. package/build/utils/value-utils.js +6 -1
  66. package/build/utils/value-utils.js.map +2 -2
  67. package/package.json +1 -1
package/build/index.js CHANGED
@@ -203,13 +203,13 @@ var require_rule_messages = __commonJS({
203
203
  });
204
204
 
205
205
  // src/rules/v9/enforce-bem-usage.ts
206
- var import_next, import_rule_messages, type, description, url, messages, bemMapping, enforce_bem_usage_default;
206
+ var import_sds_metadata, import_rule_messages, type, description, url, messages, bemMapping, enforce_bem_usage_default;
207
207
  var init_enforce_bem_usage = __esm({
208
208
  "src/rules/v9/enforce-bem-usage.ts"() {
209
- import_next = __toESM(require("@salesforce-ux/sds-metadata/next"));
209
+ import_sds_metadata = __toESM(require("@salesforce-ux/sds-metadata"));
210
210
  import_rule_messages = __toESM(require_rule_messages());
211
211
  ({ type, description, url, messages } = import_rule_messages.default["enforce-bem-usage"]);
212
- bemMapping = import_next.default.bemNaming;
212
+ bemMapping = import_sds_metadata.default.bemNaming;
213
213
  enforce_bem_usage_default = {
214
214
  meta: {
215
215
  type,
@@ -254,11 +254,11 @@ var init_enforce_bem_usage = __esm({
254
254
  var require_enforce_bem_usage = __commonJS({
255
255
  "src/rules/enforce-bem-usage.ts"(exports2, module2) {
256
256
  init_node();
257
- var import_next14 = __toESM(require("@salesforce-ux/sds-metadata/next"));
257
+ var import_sds_metadata14 = __toESM(require("@salesforce-ux/sds-metadata"));
258
258
  var import_rule_messages16 = __toESM(require_rule_messages());
259
259
  init_enforce_bem_usage();
260
- var bemMapping2 = import_next14.default.bemNaming;
261
- var deprecatedClasses2 = import_next14.default.deprecatedClasses;
260
+ var bemMapping2 = import_sds_metadata14.default.bemNaming;
261
+ var deprecatedClasses2 = import_sds_metadata14.default.deprecatedClasses;
262
262
  var ruleConfig14 = import_rule_messages16.default["enforce-bem-usage"];
263
263
  var { type: type15, description: description15, url: url15, messages: messages15 } = ruleConfig14;
264
264
  var isDeprecatedClass = (className) => {
@@ -349,9 +349,9 @@ var require_enforce_bem_usage = __commonJS({
349
349
  var require_no_deprecated_classes_slds2 = __commonJS({
350
350
  "src/rules/no-deprecated-classes-slds2.ts"(exports2, module2) {
351
351
  init_node();
352
- var import_next14 = __toESM(require("@salesforce-ux/sds-metadata/next"));
352
+ var import_sds_metadata14 = __toESM(require("@salesforce-ux/sds-metadata"));
353
353
  var import_rule_messages16 = __toESM(require_rule_messages());
354
- var deprecatedClasses2 = import_next14.default.deprecatedClasses;
354
+ var deprecatedClasses2 = import_sds_metadata14.default.deprecatedClasses;
355
355
  var ruleConfig14 = import_rule_messages16.default["no-deprecated-classes-slds2"];
356
356
  module2.exports = {
357
357
  meta: {
@@ -555,10 +555,10 @@ var import_no_deprecated_classes_slds2 = __toESM(require_no_deprecated_classes_s
555
555
  var import_modal_close_button_issue = __toESM(require_modal_close_button_issue());
556
556
 
557
557
  // src/rules/v9/no-slds-class-overrides.ts
558
- var import_next2 = __toESM(require("@salesforce-ux/sds-metadata/next"));
558
+ var import_sds_metadata2 = __toESM(require("@salesforce-ux/sds-metadata"));
559
559
  var import_rule_messages2 = __toESM(require_rule_messages());
560
560
  var ruleConfig = import_rule_messages2.default["no-slds-class-overrides"];
561
- var sldsClasses = import_next2.default.sldsPlusClasses;
561
+ var sldsClasses = import_sds_metadata2.default.sldsPlusClasses;
562
562
  var sldsClassesSet = new Set(sldsClasses);
563
563
  var no_slds_class_overrides_default = {
564
564
  meta: {
@@ -595,10 +595,10 @@ var no_slds_class_overrides_default = {
595
595
  };
596
596
 
597
597
  // src/rules/v9/no-deprecated-slds-classes.ts
598
- var import_next3 = __toESM(require("@salesforce-ux/sds-metadata/next"));
598
+ var import_sds_metadata3 = __toESM(require("@salesforce-ux/sds-metadata"));
599
599
  var import_rule_messages3 = __toESM(require_rule_messages());
600
600
  var { type: type2, description: description2, url: url2, messages: messages2 } = import_rule_messages3.default["no-deprecated-slds-classes"];
601
- var deprecatedClasses = import_next3.default.deprecatedClasses;
601
+ var deprecatedClasses = import_sds_metadata3.default.deprecatedClasses;
602
602
  var deprecatedClassesSet = new Set(deprecatedClasses);
603
603
  var no_deprecated_slds_classes_default = {
604
604
  meta: {
@@ -629,11 +629,11 @@ var no_deprecated_slds_classes_default = {
629
629
  };
630
630
 
631
631
  // src/rules/v9/no-deprecated-tokens-slds1.ts
632
- var import_next4 = __toESM(require("@salesforce-ux/sds-metadata/next"));
632
+ var import_sds_metadata4 = __toESM(require("@salesforce-ux/sds-metadata"));
633
633
  var import_rule_messages4 = __toESM(require_rule_messages());
634
634
  var ruleConfig2 = import_rule_messages4.default["no-deprecated-tokens-slds1"];
635
635
  var { type: type3, description: description3, url: url3, messages: messages3 } = ruleConfig2;
636
- var tokenMapping = import_next4.default.auraToLwcTokensMapping;
636
+ var tokenMapping = import_sds_metadata4.default.auraToLwcTokensMapping;
637
637
  var no_deprecated_tokens_slds1_default = {
638
638
  meta: {
639
639
  type: type3,
@@ -706,995 +706,1067 @@ var no_deprecated_tokens_slds1_default = {
706
706
  };
707
707
 
708
708
  // src/rules/v9/lwc-token-to-slds-hook.ts
709
- var import_next5 = __toESM(require("@salesforce-ux/sds-metadata/next"));
709
+ var import_sds_metadata5 = __toESM(require("@salesforce-ux/sds-metadata"));
710
710
  var import_rule_messages5 = __toESM(require_rule_messages());
711
- var ruleConfig3 = import_rule_messages5.default["lwc-token-to-slds-hook"];
712
- var { type: type4, description: description4, url: url4, messages: messages4 } = ruleConfig3;
713
- var lwcToSlds = import_next5.default.lwcToSlds;
714
- function shouldIgnoreDetection(lwcToken) {
715
- return !lwcToken.startsWith("--lwc-") || !(lwcToken in lwcToSlds) || lwcToSlds[lwcToken].continueToUse;
711
+
712
+ // src/utils/hardcoded-shared-utils.ts
713
+ var import_css_tree2 = require("@eslint/css-tree");
714
+
715
+ // src/utils/value-utils.ts
716
+ var ALLOWED_UNITS = ["px", "em", "rem", "%", "ch"];
717
+ function parseUnitValue(value) {
718
+ if (!value) return null;
719
+ const unitsPattern = ALLOWED_UNITS.join("|");
720
+ const regex = new RegExp(`^(-?\\d*\\.?\\d+)(${unitsPattern})?$`);
721
+ const match = value.match(regex);
722
+ if (!match) return null;
723
+ const number = parseFloat(match[1]);
724
+ const unit = match[2] ? match[2] : null;
725
+ if (isNaN(number)) return null;
726
+ return { number, unit };
716
727
  }
717
- function categorizeReplacement(recommendation) {
718
- if (!recommendation || recommendation === "--") {
719
- return "empty" /* EMPTY */;
720
- }
721
- if (Array.isArray(recommendation)) {
722
- return "array" /* ARRAY */;
723
- }
724
- if (typeof recommendation === "string" && recommendation.startsWith("--slds-")) {
725
- return "slds_token" /* SLDS_TOKEN */;
728
+ function toAlternateUnitValue(numberVal, unitType) {
729
+ if (unitType === "px") {
730
+ let floatValue = parseFloat(`${numberVal / 16}`);
731
+ if (!isNaN(floatValue)) {
732
+ return {
733
+ unit: "rem",
734
+ number: parseFloat(floatValue.toFixed(4))
735
+ };
736
+ }
737
+ } else if (unitType === "rem") {
738
+ const intValue = parseInt(`${numberVal * 16}`);
739
+ if (!isNaN(intValue)) {
740
+ return {
741
+ unit: "px",
742
+ number: intValue
743
+ };
744
+ }
726
745
  }
727
- return "raw_value" /* RAW_VALUE */;
746
+ return null;
728
747
  }
729
- function getRecommendation(lwcToken) {
730
- const oldValue = lwcToken;
731
- const recommendation = lwcToSlds[oldValue]?.replacement || "";
732
- const replacementCategory = categorizeReplacement(recommendation);
733
- const hasRecommendation = oldValue in lwcToSlds && replacementCategory !== "empty" /* EMPTY */;
734
- return { hasRecommendation, recommendation, replacementCategory };
748
+
749
+ // src/utils/color-lib-utils.ts
750
+ var import_chroma_js = __toESM(require("chroma-js"));
751
+ var import_css_tree = require("@eslint/css-tree");
752
+
753
+ // src/utils/css-functions.ts
754
+ var CSS_FUNCTIONS = [
755
+ "attr",
756
+ "calc",
757
+ "color-mix",
758
+ "conic-gradient",
759
+ "counter",
760
+ "cubic-bezier",
761
+ "linear-gradient",
762
+ "max",
763
+ "min",
764
+ "radial-gradient",
765
+ "repeating-conic-gradient",
766
+ "repeating-linear-gradient",
767
+ "repeating-radial-gradient",
768
+ "var"
769
+ ];
770
+ var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
771
+ var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
772
+ var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
773
+ var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
774
+ var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
775
+ function isCssFunction(value) {
776
+ return cssFunctionsExactRegex.test(value);
735
777
  }
736
- function getReportMessage(cssVar, replacementCategory, recommendation) {
737
- if (!recommendation) {
738
- return {
739
- messageId: "errorWithNoRecommendation",
740
- data: { oldValue: cssVar }
741
- };
742
- } else if (replacementCategory === "array" /* ARRAY */) {
743
- return {
744
- messageId: "errorWithStyleHooks",
745
- data: { oldValue: cssVar, newValue: recommendation.join(" or ") }
746
- };
747
- } else if (replacementCategory === "slds_token" /* SLDS_TOKEN */) {
748
- return {
749
- messageId: "errorWithStyleHooks",
750
- data: { oldValue: cssVar, newValue: recommendation }
751
- };
752
- } else {
753
- return {
754
- messageId: "errorWithReplacement",
755
- data: { oldValue: cssVar, newValue: recommendation }
756
- };
757
- }
778
+ function isCssColorFunction(value) {
779
+ return RGB_COLOR_FUNCTIONS.includes(value);
758
780
  }
759
- var lwc_token_to_slds_hook_default = {
760
- meta: {
761
- type: type4,
762
- docs: {
763
- description: description4,
764
- recommended: true,
765
- url: url4
766
- },
767
- fixable: "code",
768
- messages: messages4
769
- },
770
- create(context) {
771
- function reportAndFix(node, oldValue, suggestedMatch, messageId, data) {
772
- let fixFunction = null;
773
- if (suggestedMatch) {
774
- fixFunction = (fixer) => {
775
- if (node.type === "Declaration") {
776
- const sourceCode = context.sourceCode;
777
- const fullText = sourceCode.getText();
778
- const nodeOffset = node.loc.start.offset;
779
- const propertyStart = nodeOffset;
780
- const propertyEnd = propertyStart + oldValue.length;
781
- const textAtPosition = fullText.substring(propertyStart, propertyEnd);
782
- if (textAtPosition === oldValue) {
783
- return fixer.replaceTextRange([propertyStart, propertyEnd], suggestedMatch);
784
- }
785
- } else {
786
- const sourceCode = context.sourceCode;
787
- const fullText = sourceCode.getText();
788
- const varFunctionCall = `var(${oldValue})`;
789
- const nodeOffset = node.loc.start.offset;
790
- const searchStart = Math.max(0, nodeOffset - 4);
791
- const searchEnd = nodeOffset + oldValue.length + 1;
792
- const searchArea = fullText.substring(searchStart, searchEnd);
793
- const functionCallIndex = searchArea.indexOf(varFunctionCall);
794
- if (functionCallIndex !== -1) {
795
- const actualStart = searchStart + functionCallIndex;
796
- const actualEnd = actualStart + varFunctionCall.length;
797
- return fixer.replaceTextRange([actualStart, actualEnd], suggestedMatch);
798
- }
781
+
782
+ // src/utils/color-lib-utils.ts
783
+ var LAB_THRESHOLD = 25;
784
+ var isHexCode = (color) => {
785
+ const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
786
+ return hexPattern.test(color);
787
+ };
788
+ var convertToHex = (color) => {
789
+ try {
790
+ return (0, import_chroma_js.default)(color).hex();
791
+ } catch (e) {
792
+ return null;
793
+ }
794
+ };
795
+ var findClosestColorHook = (color, supportedColors, cssProperty) => {
796
+ const returnStylingHooks = [];
797
+ const closestHooksWithSameProperty = [];
798
+ const closestHooksWithoutSameProperty = [];
799
+ const closestHooksWithAllProperty = [];
800
+ const labColor = (0, import_chroma_js.default)(color).lab();
801
+ Object.entries(supportedColors).forEach(([sldsValue, data]) => {
802
+ if (sldsValue && isHexCode(sldsValue)) {
803
+ const hooks = data;
804
+ hooks.forEach((hook) => {
805
+ const labSupportedColor = (0, import_chroma_js.default)(sldsValue).lab();
806
+ 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");
807
+ if (hook.properties.includes(cssProperty)) {
808
+ if (distance <= LAB_THRESHOLD) {
809
+ closestHooksWithSameProperty.push({ name: hook.name, distance });
799
810
  }
800
- return null;
801
- };
802
- }
803
- context.report({
804
- node,
805
- messageId,
806
- data,
807
- fix: fixFunction
808
- });
809
- }
810
- return {
811
- // CSS custom property declarations: --lwc-* properties
812
- "Declaration[property=/^--lwc-/]"(node) {
813
- const property = node.property;
814
- if (shouldIgnoreDetection(property)) {
815
- return;
816
- }
817
- const { hasRecommendation, recommendation, replacementCategory } = getRecommendation(property);
818
- const { messageId, data } = getReportMessage(property, replacementCategory, recommendation);
819
- const suggestedMatch = hasRecommendation && replacementCategory === "slds_token" /* SLDS_TOKEN */ ? recommendation : null;
820
- reportAndFix(node, property, suggestedMatch, messageId, data);
821
- },
822
- // LWC tokens inside var() functions: var(--lwc-*)
823
- "Function[name='var'] Identifier[name=/^--lwc-/]"(node) {
824
- const tokenName = node.name;
825
- if (shouldIgnoreDetection(tokenName)) {
826
- return;
827
- }
828
- const { hasRecommendation, recommendation, replacementCategory } = getRecommendation(tokenName);
829
- const { messageId, data } = getReportMessage(tokenName, replacementCategory, recommendation);
830
- let suggestedMatch = null;
831
- if (hasRecommendation) {
832
- if (replacementCategory === "slds_token" /* SLDS_TOKEN */) {
833
- const originalVarCall = `var(${tokenName})`;
834
- suggestedMatch = `var(${recommendation}, ${originalVarCall})`;
835
- } else if (replacementCategory === "raw_value" /* RAW_VALUE */) {
836
- suggestedMatch = recommendation;
811
+ } else if (hook.properties.includes("*")) {
812
+ if (distance <= LAB_THRESHOLD) {
813
+ closestHooksWithAllProperty.push({ name: hook.name, distance });
814
+ }
815
+ } else {
816
+ if (distance <= LAB_THRESHOLD) {
817
+ closestHooksWithoutSameProperty.push({ name: hook.name, distance });
837
818
  }
838
819
  }
839
- reportAndFix(node, tokenName, suggestedMatch, messageId, data);
820
+ });
821
+ }
822
+ });
823
+ const closesthookGroups = [
824
+ { hooks: closestHooksWithSameProperty, distance: 0 },
825
+ { hooks: closestHooksWithAllProperty, distance: 0 },
826
+ { hooks: closestHooksWithSameProperty, distance: Infinity },
827
+ // For hooks with distance > 0
828
+ { hooks: closestHooksWithAllProperty, distance: Infinity },
829
+ { hooks: closestHooksWithoutSameProperty, distance: Infinity }
830
+ ];
831
+ for (const group of closesthookGroups) {
832
+ const filteredHooks = group.hooks.filter(
833
+ (h) => group.distance === 0 ? h.distance === 0 : h.distance > 0
834
+ );
835
+ if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {
836
+ filteredHooks.sort((a, b) => a.distance - b.distance);
837
+ returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));
838
+ }
839
+ }
840
+ return Array.from(new Set(returnStylingHooks));
841
+ };
842
+ var isValidColor = (val) => import_chroma_js.default.valid(val);
843
+ var extractColorValue = (node) => {
844
+ let colorValue = null;
845
+ switch (node.type) {
846
+ case "Hash":
847
+ colorValue = `#${node.value}`;
848
+ break;
849
+ case "Identifier":
850
+ colorValue = node.name;
851
+ break;
852
+ case "Function":
853
+ if (isCssColorFunction(node.name)) {
854
+ colorValue = (0, import_css_tree.generate)(node);
840
855
  }
841
- };
856
+ break;
842
857
  }
858
+ return colorValue && isValidColor(colorValue) ? colorValue : null;
843
859
  };
844
860
 
845
- // src/rules/v9/enforce-sds-to-slds-hooks.ts
846
- var import_next6 = __toESM(require("@salesforce-ux/sds-metadata/next"));
847
- var import_rule_messages6 = __toESM(require_rule_messages());
848
- var ruleConfig4 = import_rule_messages6.default["enforce-sds-to-slds-hooks"];
849
- var { type: type5, description: description5, url: url5, messages: messages5 } = ruleConfig4;
850
- var sldsPlusStylingHooks = import_next6.default.sldsPlusStylingHooks;
851
- var allSldsHooks = [...sldsPlusStylingHooks.global, ...sldsPlusStylingHooks.component];
852
- var toSldsToken = (sdsToken) => sdsToken.replace("--sds-", "--slds-");
853
- function shouldIgnoreDetection2(sdsToken) {
854
- return !sdsToken.startsWith("--sds-") || !allSldsHooks.includes(toSldsToken(sdsToken));
861
+ // src/utils/hardcoded-shared-utils.ts
862
+ var FONT_WEIGHTS = [
863
+ "normal",
864
+ "bold",
865
+ "bolder",
866
+ "lighter",
867
+ "100",
868
+ "200",
869
+ "300",
870
+ "400",
871
+ "500",
872
+ "600",
873
+ "700",
874
+ "800",
875
+ "900"
876
+ ];
877
+ function isKnownFontWeight(value) {
878
+ const stringValue = value.toString();
879
+ return FONT_WEIGHTS.includes(stringValue.toLowerCase());
855
880
  }
856
- var enforce_sds_to_slds_hooks_default = {
857
- meta: {
858
- type: type5,
859
- docs: {
860
- description: description5,
861
- recommended: true,
862
- url: url5
863
- },
864
- fixable: "code",
865
- messages: messages5
866
- },
867
- create(context) {
868
- function reportAndFix(node, oldValue, suggestedMatch) {
869
- context.report({
870
- node,
871
- messageId: "replaceSdsWithSlds",
872
- data: { oldValue, suggestedMatch },
873
- fix(fixer) {
874
- if (node.type === "Declaration") {
875
- const sourceCode = context.sourceCode;
876
- const fullText = sourceCode.getText();
877
- const nodeOffset = node.loc.start.offset;
878
- const propertyStart = nodeOffset;
879
- const propertyEnd = propertyStart + oldValue.length;
880
- const textAtPosition = fullText.substring(propertyStart, propertyEnd);
881
- if (textAtPosition === oldValue) {
882
- return fixer.replaceTextRange([propertyStart, propertyEnd], suggestedMatch);
883
- }
884
- }
885
- return fixer.replaceText(node, suggestedMatch);
886
- }
887
- });
888
- }
889
- return {
890
- // CSS custom property declarations: --sds-* properties
891
- "Declaration[property=/^--sds-/]"(node) {
892
- const property = node.property;
893
- if (shouldIgnoreDetection2(property)) {
894
- return;
895
- }
896
- const suggestedMatch = toSldsToken(property);
897
- reportAndFix(node, property, suggestedMatch);
898
- },
899
- // SDS tokens inside var() functions: var(--sds-*)
900
- "Function[name='var'] Identifier[name=/^--sds-/]"(node) {
901
- const tokenName = node.name;
902
- if (shouldIgnoreDetection2(tokenName)) {
903
- return;
881
+ function handleShorthandAutoFix(declarationNode, context, valueText, replacements) {
882
+ const sortedReplacements = replacements.sort((a, b) => a.start - b.start);
883
+ const hasAnyHooks = sortedReplacements.some((r) => r.hasHook);
884
+ const canAutoFix = hasAnyHooks;
885
+ sortedReplacements.forEach(({ start, end, replacement, displayValue, hasHook }) => {
886
+ const originalValue = valueText.substring(start, end);
887
+ const valueStartColumn = declarationNode.value.loc.start.column;
888
+ const valueColumn = valueStartColumn + start;
889
+ const { loc: { start: locStart, end: locEnd } } = declarationNode.value;
890
+ const reportNode = {
891
+ ...declarationNode.value,
892
+ loc: {
893
+ ...declarationNode.value.loc,
894
+ start: {
895
+ ...locStart,
896
+ column: valueColumn
897
+ },
898
+ end: {
899
+ ...locEnd,
900
+ column: valueColumn + originalValue.length
904
901
  }
905
- const suggestedMatch = toSldsToken(tokenName);
906
- reportAndFix(node, tokenName, suggestedMatch);
907
902
  }
908
903
  };
909
- }
910
- };
911
-
912
- // src/rules/v9/no-sldshook-fallback-for-lwctoken.ts
913
- var import_next7 = __toESM(require("@salesforce-ux/sds-metadata/next"));
914
- var import_rule_messages7 = __toESM(require_rule_messages());
915
- var ruleConfig5 = import_rule_messages7.default["no-sldshook-fallback-for-lwctoken"];
916
- var { type: type6, description: description6, url: url6, messages: messages6 } = ruleConfig5;
917
- var sldsPlusStylingHooks2 = import_next7.default.sldsPlusStylingHooks;
918
- var allSldsHooks2 = [...sldsPlusStylingHooks2.global, ...sldsPlusStylingHooks2.component];
919
- var allSldsHooksSet = new Set(allSldsHooks2);
920
- function hasUnsupportedFallback(lwcToken, sldsToken) {
921
- const normalizedSldsToken = sldsToken.replace("--sds-", "--slds-");
922
- return lwcToken.startsWith("--lwc-") && normalizedSldsToken.startsWith("--slds-") && allSldsHooksSet.has(normalizedSldsToken);
923
- }
924
- var no_sldshook_fallback_for_lwctoken_default = {
925
- meta: {
926
- type: type6,
927
- docs: {
928
- description: description6,
929
- recommended: true,
930
- url: url6
931
- },
932
- messages: messages6
933
- },
934
- create(context) {
935
- return {
936
- // Handle LWC tokens inside var() functions: var(--lwc-*, ...)
937
- "Function[name='var'] Identifier[name=/^--lwc-/]"(node) {
938
- const lwcToken = node.name;
939
- const varFunctionNode = context.sourceCode.getAncestors(node).at(-1);
940
- if (!varFunctionNode) return;
941
- const varFunctionChildren = varFunctionNode.children;
942
- if (!varFunctionChildren) return;
943
- let foundComma = false;
944
- let fallbackRawNode = null;
945
- for (const child of varFunctionChildren) {
946
- if (child.type === "Operator" && child.value === ",") {
947
- foundComma = true;
948
- continue;
949
- }
950
- if (foundComma && child.type === "Raw") {
951
- fallbackRawNode = child;
952
- break;
953
- }
904
+ if (hasHook) {
905
+ const fix = canAutoFix ? (fixer) => {
906
+ let newValue = valueText;
907
+ for (let i = sortedReplacements.length - 1; i >= 0; i--) {
908
+ const { start: rStart, end: rEnd, replacement: rReplacement } = sortedReplacements[i];
909
+ newValue = newValue.substring(0, rStart) + rReplacement + newValue.substring(rEnd);
954
910
  }
955
- if (!fallbackRawNode) return;
956
- const fallbackValue = fallbackRawNode.value.trim();
957
- const varMatch = fallbackValue.match(/var\(([^,)]+)/);
958
- if (!varMatch) return;
959
- const sldsToken = varMatch[1];
960
- if (hasUnsupportedFallback(lwcToken, sldsToken)) {
961
- context.report({
962
- node,
963
- messageId: "unsupportedFallback",
964
- data: { lwcToken, sldsToken }
965
- });
911
+ return fixer.replaceText(declarationNode.value, newValue);
912
+ } : void 0;
913
+ context.context.report({
914
+ node: reportNode,
915
+ messageId: "hardcodedValue",
916
+ data: {
917
+ oldValue: originalValue,
918
+ newValue: displayValue
919
+ },
920
+ fix
921
+ });
922
+ } else {
923
+ context.context.report({
924
+ node: reportNode,
925
+ messageId: "noReplacement",
926
+ data: {
927
+ oldValue: originalValue
966
928
  }
967
- }
968
- };
969
- }
970
- };
971
-
972
- // src/rules/v9/no-unsupported-hooks-slds2.ts
973
- var import_next8 = __toESM(require("@salesforce-ux/sds-metadata/next"));
974
- var import_rule_messages8 = __toESM(require_rule_messages());
975
- var ruleConfig6 = import_rule_messages8.default["no-unsupported-hooks-slds2"];
976
- var { type: type7, description: description7, url: url7, messages: messages7 } = ruleConfig6;
977
- var deprecatedHooks = new Set(import_next8.default.deprecatedStylingHooks);
978
- function shouldIgnoreDetection3(sldsHook) {
979
- return !deprecatedHooks.has(sldsHook);
980
- }
981
- var no_unsupported_hooks_slds2_default = {
982
- meta: {
983
- type: type7,
984
- docs: {
985
- description: description7,
986
- recommended: true,
987
- url: url7
988
- },
989
- messages: messages7
990
- },
991
- create(context) {
992
- function reportDeprecatedHook(node, token) {
993
- context.report({
994
- node,
995
- messageId: "deprecated",
996
- data: { token }
997
929
  });
998
930
  }
999
- return {
1000
- // Handle CSS custom property declarations (left-side usage): --slds-* properties
1001
- // Example: .THIS { --slds-g-link-color: #f73650; }
1002
- "Declaration[property=/^--s(lds|ds)-/]"(node) {
1003
- const property = node.property;
1004
- if (shouldIgnoreDetection3(property)) {
1005
- return;
931
+ });
932
+ }
933
+ function forEachValue(valueText, extractValue, shouldSkipNode, callback) {
934
+ if (!valueText || typeof valueText !== "string") {
935
+ return;
936
+ }
937
+ try {
938
+ const ast = (0, import_css_tree2.parse)(valueText, { context: "value", positions: true });
939
+ (0, import_css_tree2.walk)(ast, {
940
+ enter(node) {
941
+ if (shouldSkipNode(node)) {
942
+ return this.skip;
1006
943
  }
1007
- reportDeprecatedHook(node, property);
1008
- },
1009
- // Handle SLDS/SDS hooks inside var() functions (right-side usage): var(--slds-*)
1010
- // Example: .THIS .demo { border-top: 1px solid var(--slds-g-color-border-brand-1); }
1011
- "Function[name='var'] Identifier[name=/^--s(lds|ds)-/]"(node) {
1012
- const tokenName = node.name;
1013
- if (shouldIgnoreDetection3(tokenName)) {
1014
- return;
944
+ const value = extractValue(node);
945
+ if (value !== null) {
946
+ const positionInfo = {
947
+ start: node.loc?.start,
948
+ end: node.loc?.end
949
+ };
950
+ callback(value, positionInfo);
1015
951
  }
1016
- reportDeprecatedHook(node, tokenName);
1017
952
  }
1018
- };
953
+ });
954
+ } catch (error) {
955
+ return;
1019
956
  }
1020
- };
1021
-
1022
- // src/rules/v9/no-slds-var-without-fallback.ts
1023
- var import_next9 = __toESM(require("@salesforce-ux/sds-metadata/next"));
1024
- var import_rule_messages9 = __toESM(require_rule_messages());
1025
- var ruleConfig7 = import_rule_messages9.default["no-slds-var-without-fallback"];
1026
- var { type: type8, description: description8, url: url8, messages: messages8 } = ruleConfig7;
1027
- var sldsVariables = import_next9.default.slds1ExcludedVars || {};
1028
- function isSldsCssVariable(cssVar) {
1029
- return cssVar.startsWith("--slds-");
1030
957
  }
1031
- function hasFallbackValue(varFunctionNode) {
1032
- if (!varFunctionNode || !varFunctionNode.children) return false;
1033
- return varFunctionNode.children.some(
1034
- (child) => child.type === "Operator" && child.value === ","
1035
- );
958
+ function shouldSkipColorNode(node) {
959
+ return node.type === "Function" && isCssFunction(node.name);
1036
960
  }
1037
- var no_slds_var_without_fallback_default = {
1038
- meta: {
1039
- type: type8,
1040
- docs: {
1041
- description: description8,
1042
- recommended: true,
1043
- url: url8
1044
- },
1045
- fixable: "code",
1046
- messages: messages8
1047
- },
1048
- create(context) {
1049
- function reportAndFix(node, cssVar, fallbackValue) {
1050
- context.report({
1051
- node,
1052
- messageId: "varWithoutFallback",
1053
- data: { cssVar, recommendation: fallbackValue },
1054
- fix(fixer) {
1055
- const varFunctionNode = context.sourceCode.getAncestors(node).at(-1);
1056
- const varWithFallback = `var(${cssVar}, ${fallbackValue})`;
1057
- return fixer.replaceText(varFunctionNode, varWithFallback);
1058
- }
1059
- });
1060
- }
1061
- return {
1062
- // Handle SLDS tokens inside var() functions: var(--slds-*)
1063
- "Function[name='var'] Identifier[name=/^--slds-/]"(node) {
1064
- const cssVar = node.name;
1065
- if (!isSldsCssVariable(cssVar)) {
1066
- return;
1067
- }
1068
- const varFunctionNode = context.sourceCode.getAncestors(node).at(-1);
1069
- if (hasFallbackValue(varFunctionNode)) {
1070
- return;
1071
- }
1072
- const fallbackValue = sldsVariables[cssVar];
1073
- if (!fallbackValue) {
1074
- return;
1075
- }
1076
- reportAndFix(node, cssVar, fallbackValue);
961
+ function shouldSkipDimensionNode(node) {
962
+ return node.type === "Function";
963
+ }
964
+ function extractDimensionValue(valueNode, cssProperty) {
965
+ if (!valueNode) return null;
966
+ switch (valueNode.type) {
967
+ case "Dimension":
968
+ const numValue = Number(valueNode.value);
969
+ if (numValue === 0) return null;
970
+ const unit = valueNode.unit.toLowerCase();
971
+ if (!ALLOWED_UNITS.includes(unit)) return null;
972
+ return {
973
+ number: numValue,
974
+ unit
975
+ };
976
+ case "Number":
977
+ const numberValue = Number(valueNode.value);
978
+ if (numberValue === 0) return null;
979
+ return {
980
+ number: numberValue,
981
+ unit: null
982
+ };
983
+ case "Percentage":
984
+ const percentValue = Number(valueNode.value);
985
+ if (percentValue === 0) return null;
986
+ return {
987
+ number: percentValue,
988
+ unit: "%"
989
+ };
990
+ case "Value":
991
+ return valueNode.children?.[0] ? extractDimensionValue(valueNode.children[0], cssProperty) : null;
992
+ }
993
+ return null;
994
+ }
995
+ function forEachColorValue(valueText, callback) {
996
+ forEachValue(valueText, extractColorValue, shouldSkipColorNode, callback);
997
+ }
998
+ function forEachDensityValue(valueText, cssProperty, callback) {
999
+ forEachValue(
1000
+ valueText,
1001
+ (node) => extractDimensionValue(node, cssProperty),
1002
+ shouldSkipDimensionNode,
1003
+ callback
1004
+ );
1005
+ }
1006
+ function extractFontValue(node) {
1007
+ if (!node) return null;
1008
+ switch (node.type) {
1009
+ case "Dimension":
1010
+ const numValue = Number(node.value);
1011
+ if (numValue <= 0) return null;
1012
+ const unit = node.unit.toLowerCase();
1013
+ if (!ALLOWED_UNITS.includes(unit)) return null;
1014
+ return {
1015
+ number: numValue,
1016
+ unit
1017
+ };
1018
+ case "Number":
1019
+ const numberValue = Number(node.value);
1020
+ if (numberValue <= 0) {
1021
+ return null;
1077
1022
  }
1078
- };
1023
+ if (!isKnownFontWeight(numberValue)) {
1024
+ return null;
1025
+ }
1026
+ return {
1027
+ number: numberValue,
1028
+ unit: null
1029
+ };
1030
+ case "Identifier":
1031
+ const namedValue = node.name.toLowerCase();
1032
+ if (!isKnownFontWeight(namedValue)) {
1033
+ return null;
1034
+ }
1035
+ if (namedValue === "normal") {
1036
+ return { number: 400, unit: null };
1037
+ }
1038
+ return { number: namedValue, unit: null };
1039
+ case "Percentage":
1040
+ const percentValue = Number(node.value);
1041
+ if (percentValue === 0) return null;
1042
+ return {
1043
+ number: percentValue,
1044
+ unit: "%"
1045
+ };
1046
+ case "Value":
1047
+ return node.children?.[0] ? extractFontValue(node.children[0]) : null;
1079
1048
  }
1080
- };
1049
+ return null;
1050
+ }
1051
+ function shouldSkipFontNode(node) {
1052
+ return node.type === "Function";
1053
+ }
1054
+ function forEachFontValue(valueText, callback) {
1055
+ forEachValue(valueText, extractFontValue, shouldSkipFontNode, callback);
1056
+ }
1081
1057
 
1082
- // src/rules/v9/no-slds-namespace-for-custom-hooks.ts
1083
- var import_next10 = __toESM(require("@salesforce-ux/sds-metadata/next"));
1084
- var import_rule_messages10 = __toESM(require_rule_messages());
1085
- var ruleConfig8 = import_rule_messages10.default["no-slds-namespace-for-custom-hooks"];
1086
- var { type: type9, description: description9, url: url9, messages: messages9 } = ruleConfig8;
1087
- var sldsPlusStylingHooks3 = import_next10.default.sldsPlusStylingHooks;
1088
- var allSldsHooks3 = [...sldsPlusStylingHooks3.global, ...sldsPlusStylingHooks3.component];
1089
- var toSldsToken2 = (sdsToken) => sdsToken.replace("--sds-", "--slds-");
1090
- function shouldIgnoreDetection4(sdsToken) {
1091
- if (sdsToken.startsWith("--sds-") || sdsToken.startsWith("--slds-")) {
1092
- return allSldsHooks3.includes(toSldsToken2(sdsToken));
1058
+ // src/utils/css-utils.ts
1059
+ function extractSldsVariable(node) {
1060
+ if (!node || node.type !== "Function" || node.name !== "var") {
1061
+ return null;
1093
1062
  }
1094
- return true;
1063
+ if (!node.children) {
1064
+ return null;
1065
+ }
1066
+ const childrenArray = Array.from(node.children);
1067
+ if (childrenArray.length === 0) {
1068
+ return null;
1069
+ }
1070
+ const firstChild = childrenArray[0];
1071
+ if (!firstChild || firstChild.type !== "Identifier") {
1072
+ return null;
1073
+ }
1074
+ const variableName = firstChild.name;
1075
+ if (!variableName || !variableName.startsWith("--slds-")) {
1076
+ return null;
1077
+ }
1078
+ const hasFallback = childrenArray.some(
1079
+ (child) => child.type === "Operator" && child.value === ","
1080
+ );
1081
+ return {
1082
+ name: variableName,
1083
+ hasFallback
1084
+ };
1095
1085
  }
1096
- var no_slds_namespace_for_custom_hooks_default = {
1086
+ function forEachSldsVariable(valueText, callback) {
1087
+ forEachValue(valueText, extractSldsVariable, () => false, callback);
1088
+ }
1089
+ function formatSuggestionHooks(hooks) {
1090
+ if (hooks.length === 1) {
1091
+ return `${hooks[0]}`;
1092
+ }
1093
+ return "\n" + hooks.map((hook, index) => `${index + 1}. ${hook}`).join("\n");
1094
+ }
1095
+
1096
+ // src/rules/v9/lwc-token-to-slds-hook.ts
1097
+ var ruleConfig3 = import_rule_messages5.default["lwc-token-to-slds-hook"];
1098
+ var { type: type4, description: description4, url: url4, messages: messages4 } = ruleConfig3;
1099
+ var lwcToSlds = import_sds_metadata5.default.lwcToSlds;
1100
+ function shouldIgnoreDetection(lwcToken) {
1101
+ return !lwcToken.startsWith("--lwc-") || !(lwcToken in lwcToSlds) || lwcToSlds[lwcToken].continueToUse;
1102
+ }
1103
+ function categorizeReplacement(recommendation) {
1104
+ if (!recommendation || recommendation === "--") {
1105
+ return "empty" /* EMPTY */;
1106
+ }
1107
+ if (Array.isArray(recommendation)) {
1108
+ return "array" /* ARRAY */;
1109
+ }
1110
+ if (typeof recommendation === "string" && recommendation.startsWith("--slds-")) {
1111
+ return "slds_token" /* SLDS_TOKEN */;
1112
+ }
1113
+ return "raw_value" /* RAW_VALUE */;
1114
+ }
1115
+ function getRecommendation(lwcToken) {
1116
+ const oldValue = lwcToken;
1117
+ const recommendation = lwcToSlds[oldValue]?.replacement || "";
1118
+ const replacementCategory = categorizeReplacement(recommendation);
1119
+ const hasRecommendation = oldValue in lwcToSlds && replacementCategory !== "empty" /* EMPTY */;
1120
+ return { hasRecommendation, recommendation, replacementCategory };
1121
+ }
1122
+ function getReportMessage(cssVar, replacementCategory, recommendation) {
1123
+ if (!recommendation) {
1124
+ return {
1125
+ messageId: "errorWithNoRecommendation",
1126
+ data: { oldValue: cssVar }
1127
+ };
1128
+ } else if (replacementCategory === "array" /* ARRAY */) {
1129
+ return {
1130
+ messageId: "errorWithStyleHooks",
1131
+ data: { oldValue: cssVar, newValue: formatSuggestionHooks(recommendation) }
1132
+ };
1133
+ } else if (replacementCategory === "slds_token" /* SLDS_TOKEN */) {
1134
+ return {
1135
+ messageId: "errorWithStyleHooks",
1136
+ data: { oldValue: cssVar, newValue: recommendation }
1137
+ };
1138
+ } else {
1139
+ return {
1140
+ messageId: "errorWithReplacement",
1141
+ data: { oldValue: cssVar, newValue: recommendation }
1142
+ };
1143
+ }
1144
+ }
1145
+ var lwc_token_to_slds_hook_default = {
1097
1146
  meta: {
1098
- type: type9,
1147
+ type: type4,
1099
1148
  docs: {
1100
- description: description9,
1149
+ description: description4,
1101
1150
  recommended: true,
1102
- url: url9
1151
+ url: url4
1103
1152
  },
1104
- messages: messages9
1153
+ fixable: "code",
1154
+ messages: messages4
1105
1155
  },
1106
1156
  create(context) {
1107
- function reportViolation(node, token) {
1108
- const tokenWithoutNamespace = token.replace("--slds-", "").replace("--sds-", "");
1157
+ function reportAndFix(node, oldValue, suggestedMatch, messageId, data) {
1158
+ let fixFunction = null;
1159
+ if (suggestedMatch) {
1160
+ fixFunction = (fixer) => {
1161
+ if (node.type === "Declaration") {
1162
+ const sourceCode = context.sourceCode;
1163
+ const fullText = sourceCode.getText();
1164
+ const nodeOffset = node.loc.start.offset;
1165
+ const propertyStart = nodeOffset;
1166
+ const propertyEnd = propertyStart + oldValue.length;
1167
+ const textAtPosition = fullText.substring(propertyStart, propertyEnd);
1168
+ if (textAtPosition === oldValue) {
1169
+ return fixer.replaceTextRange([propertyStart, propertyEnd], suggestedMatch);
1170
+ }
1171
+ } else {
1172
+ const sourceCode = context.sourceCode;
1173
+ const fullText = sourceCode.getText();
1174
+ const varFunctionCall = `var(${oldValue})`;
1175
+ const nodeOffset = node.loc.start.offset;
1176
+ const searchStart = Math.max(0, nodeOffset - 4);
1177
+ const searchEnd = nodeOffset + oldValue.length + 1;
1178
+ const searchArea = fullText.substring(searchStart, searchEnd);
1179
+ const functionCallIndex = searchArea.indexOf(varFunctionCall);
1180
+ if (functionCallIndex !== -1) {
1181
+ const actualStart = searchStart + functionCallIndex;
1182
+ const actualEnd = actualStart + varFunctionCall.length;
1183
+ return fixer.replaceTextRange([actualStart, actualEnd], suggestedMatch);
1184
+ }
1185
+ }
1186
+ return null;
1187
+ };
1188
+ }
1109
1189
  context.report({
1110
1190
  node,
1111
- messageId: "customHookNamespace",
1112
- data: {
1113
- token,
1114
- tokenWithoutNamespace
1115
- }
1191
+ messageId,
1192
+ data,
1193
+ fix: fixFunction
1116
1194
  });
1117
1195
  }
1118
1196
  return {
1119
- // CSS custom property declarations: --slds-* and --sds-* properties
1120
- "Declaration[property=/^--s(lds|ds)-/]"(node) {
1197
+ // CSS custom property declarations: --lwc-* properties
1198
+ "Declaration[property=/^--lwc-/]"(node) {
1121
1199
  const property = node.property;
1122
- if (shouldIgnoreDetection4(property)) {
1200
+ if (shouldIgnoreDetection(property)) {
1123
1201
  return;
1124
1202
  }
1125
- reportViolation(node, property);
1203
+ const { hasRecommendation, recommendation, replacementCategory } = getRecommendation(property);
1204
+ const { messageId, data } = getReportMessage(property, replacementCategory, recommendation);
1205
+ const suggestedMatch = hasRecommendation && replacementCategory === "slds_token" /* SLDS_TOKEN */ ? recommendation : null;
1206
+ reportAndFix(node, property, suggestedMatch, messageId, data);
1126
1207
  },
1127
- // SLDS/SDS tokens inside var() functions: var(--slds-*) or var(--sds-*)
1128
- "Function[name='var'] Identifier[name=/^--s(lds|ds)-/]"(node) {
1208
+ // LWC tokens inside var() functions: var(--lwc-*)
1209
+ "Function[name='var'] Identifier[name=/^--lwc-/]"(node) {
1129
1210
  const tokenName = node.name;
1130
- if (shouldIgnoreDetection4(tokenName)) {
1211
+ if (shouldIgnoreDetection(tokenName)) {
1131
1212
  return;
1132
1213
  }
1133
- reportViolation(node, tokenName);
1214
+ const { hasRecommendation, recommendation, replacementCategory } = getRecommendation(tokenName);
1215
+ const { messageId, data } = getReportMessage(tokenName, replacementCategory, recommendation);
1216
+ let suggestedMatch = null;
1217
+ if (hasRecommendation) {
1218
+ if (replacementCategory === "slds_token" /* SLDS_TOKEN */) {
1219
+ const originalVarCall = `var(${tokenName})`;
1220
+ suggestedMatch = `var(${recommendation}, ${originalVarCall})`;
1221
+ } else if (replacementCategory === "raw_value" /* RAW_VALUE */) {
1222
+ suggestedMatch = recommendation;
1223
+ }
1224
+ }
1225
+ reportAndFix(node, tokenName, suggestedMatch, messageId, data);
1134
1226
  }
1135
1227
  };
1136
1228
  }
1137
1229
  };
1138
1230
 
1139
- // src/rules/v9/enforce-component-hook-naming-convention.ts
1140
- var import_next11 = __toESM(require("@salesforce-ux/sds-metadata/next"));
1141
- var import_rule_messages11 = __toESM(require_rule_messages());
1142
- var ruleConfig9 = import_rule_messages11.default["enforce-component-hook-naming-convention"];
1143
- var { type: type10, description: description10, url: url10, messages: messages10 } = ruleConfig9;
1144
- var slds1DeprecatedComponentHooks = import_next11.default.slds1DeprecatedComponentHooks;
1145
- function shouldIgnoreDetection5(hook) {
1146
- return !hook.startsWith("--slds-c-") || !(hook in slds1DeprecatedComponentHooks);
1231
+ // src/rules/v9/enforce-sds-to-slds-hooks.ts
1232
+ var import_sds_metadata6 = __toESM(require("@salesforce-ux/sds-metadata"));
1233
+ var import_rule_messages6 = __toESM(require_rule_messages());
1234
+ var ruleConfig4 = import_rule_messages6.default["enforce-sds-to-slds-hooks"];
1235
+ var { type: type5, description: description5, url: url5, messages: messages5 } = ruleConfig4;
1236
+ var sldsPlusStylingHooks = import_sds_metadata6.default.sldsPlusStylingHooks;
1237
+ var allSldsHooks = [...sldsPlusStylingHooks.global, ...sldsPlusStylingHooks.component];
1238
+ var toSldsToken = (sdsToken) => sdsToken.replace("--sds-", "--slds-");
1239
+ function shouldIgnoreDetection2(sdsToken) {
1240
+ return !sdsToken.startsWith("--sds-") || !allSldsHooks.includes(toSldsToken(sdsToken));
1147
1241
  }
1148
- var enforce_component_hook_naming_convention_default = {
1242
+ var enforce_sds_to_slds_hooks_default = {
1149
1243
  meta: {
1150
- type: type10,
1244
+ type: type5,
1151
1245
  docs: {
1152
- description: description10,
1246
+ description: description5,
1153
1247
  recommended: true,
1154
- url: url10
1248
+ url: url5
1155
1249
  },
1156
1250
  fixable: "code",
1157
- messages: messages10
1251
+ messages: messages5
1158
1252
  },
1159
1253
  create(context) {
1254
+ function reportAndFix(node, oldValue, suggestedMatch) {
1255
+ context.report({
1256
+ node,
1257
+ messageId: "replaceSdsWithSlds",
1258
+ data: { oldValue, suggestedMatch },
1259
+ fix(fixer) {
1260
+ if (node.type === "Declaration") {
1261
+ const sourceCode = context.sourceCode;
1262
+ const fullText = sourceCode.getText();
1263
+ const nodeOffset = node.loc.start.offset;
1264
+ const propertyStart = nodeOffset;
1265
+ const propertyEnd = propertyStart + oldValue.length;
1266
+ const textAtPosition = fullText.substring(propertyStart, propertyEnd);
1267
+ if (textAtPosition === oldValue) {
1268
+ return fixer.replaceTextRange([propertyStart, propertyEnd], suggestedMatch);
1269
+ }
1270
+ }
1271
+ return fixer.replaceText(node, suggestedMatch);
1272
+ }
1273
+ });
1274
+ }
1160
1275
  return {
1161
- /*
1162
- * Handle component hooks in CSS declarations
1163
- * Limitation: For example:
1164
- * .testClass{
1165
- * --slds-c-accordion-section-color-background: var(--slds-c-accordion-section-color-border);
1166
- * }
1167
- * var in value is not detected, because eslint treats above statement as custom property assignment
1168
- * and value treated as raw string, not parsed into function nodes
1169
- */
1170
- "Declaration[property=/^--slds-c-/], Function[name='var'] Identifier[name=/^--slds-c-/]"(node) {
1171
- let hookName;
1172
- let reportNode = node;
1173
- if (node.type === "Declaration") {
1174
- hookName = node.property;
1175
- } else if (node.type === "Identifier") {
1176
- hookName = node.name;
1177
- } else {
1276
+ // CSS custom property declarations: --sds-* properties
1277
+ "Declaration[property=/^--sds-/]"(node) {
1278
+ const property = node.property;
1279
+ if (shouldIgnoreDetection2(property)) {
1178
1280
  return;
1179
1281
  }
1180
- if (shouldIgnoreDetection5(hookName)) {
1282
+ const suggestedMatch = toSldsToken(property);
1283
+ reportAndFix(node, property, suggestedMatch);
1284
+ },
1285
+ // SDS tokens inside var() functions: var(--sds-*)
1286
+ "Function[name='var'] Identifier[name=/^--sds-/]"(node) {
1287
+ const tokenName = node.name;
1288
+ if (shouldIgnoreDetection2(tokenName)) {
1181
1289
  return;
1182
1290
  }
1183
- const suggestedMatch = slds1DeprecatedComponentHooks[hookName];
1184
- context.report({
1185
- node: reportNode,
1186
- messageId: "replace",
1187
- data: {
1188
- oldValue: hookName,
1189
- suggestedMatch
1190
- },
1191
- fix(fixer) {
1192
- if (node.type === "Declaration") {
1193
- const originalText = context.sourceCode.getText(node);
1194
- const colonIndex = originalText.indexOf(":");
1195
- const valuePartWithColon = originalText.substring(colonIndex);
1196
- return fixer.replaceText(node, `${suggestedMatch}${valuePartWithColon}`);
1197
- } else if (node.type === "Identifier") {
1198
- return fixer.replaceText(node, suggestedMatch);
1199
- }
1200
- return null;
1201
- }
1202
- });
1291
+ const suggestedMatch = toSldsToken(tokenName);
1292
+ reportAndFix(node, tokenName, suggestedMatch);
1203
1293
  }
1204
1294
  };
1205
1295
  }
1206
1296
  };
1207
1297
 
1208
- // src/rules/v9/reduce-annotations.ts
1209
- var import_rule_messages12 = __toESM(require_rule_messages());
1210
- var ruleConfig10 = import_rule_messages12.default["reduce-annotations"];
1211
- var { type: type11, description: description11, url: url11, messages: messages11 } = ruleConfig10;
1212
- var SLDS_ANNOTATIONS = [
1213
- "@sldsValidatorIgnoreNextLine",
1214
- "@sldsValidatorAllow",
1215
- "@sldsValidatorIgnore"
1216
- ];
1217
- var reduce_annotations_default = {
1298
+ // src/rules/v9/no-sldshook-fallback-for-lwctoken.ts
1299
+ var import_sds_metadata7 = __toESM(require("@salesforce-ux/sds-metadata"));
1300
+ var import_rule_messages7 = __toESM(require_rule_messages());
1301
+ var ruleConfig5 = import_rule_messages7.default["no-sldshook-fallback-for-lwctoken"];
1302
+ var { type: type6, description: description6, url: url6, messages: messages6 } = ruleConfig5;
1303
+ var sldsPlusStylingHooks2 = import_sds_metadata7.default.sldsPlusStylingHooks;
1304
+ var allSldsHooks2 = [...sldsPlusStylingHooks2.global, ...sldsPlusStylingHooks2.component];
1305
+ var allSldsHooksSet = new Set(allSldsHooks2);
1306
+ function hasUnsupportedFallback(lwcToken, sldsToken) {
1307
+ const normalizedSldsToken = sldsToken.replace("--sds-", "--slds-");
1308
+ return lwcToken.startsWith("--lwc-") && normalizedSldsToken.startsWith("--slds-") && allSldsHooksSet.has(normalizedSldsToken);
1309
+ }
1310
+ var no_sldshook_fallback_for_lwctoken_default = {
1218
1311
  meta: {
1219
- type: type11,
1312
+ type: type6,
1220
1313
  docs: {
1221
- description: description11,
1314
+ description: description6,
1222
1315
  recommended: true,
1223
- url: url11
1316
+ url: url6
1224
1317
  },
1225
- messages: messages11
1318
+ messages: messages6
1226
1319
  },
1227
1320
  create(context) {
1228
1321
  return {
1229
- StyleSheet(node) {
1230
- const sourceCode = context.sourceCode;
1231
- let comments = sourceCode?.comments || [];
1232
- comments.forEach((comment) => {
1233
- const commentContent = comment.value.trim();
1234
- const matchingAnnotation = SLDS_ANNOTATIONS.find(
1235
- (annotation) => commentContent.startsWith(annotation)
1236
- );
1237
- if (matchingAnnotation) {
1238
- context.report({
1239
- node: comment,
1240
- messageId: "removeAnnotation"
1241
- });
1322
+ // Handle LWC tokens inside var() functions: var(--lwc-*, ...)
1323
+ "Function[name='var'] Identifier[name=/^--lwc-/]"(node) {
1324
+ const lwcToken = node.name;
1325
+ const varFunctionNode = context.sourceCode.getAncestors(node).at(-1);
1326
+ if (!varFunctionNode) return;
1327
+ const varFunctionChildren = varFunctionNode.children;
1328
+ if (!varFunctionChildren) return;
1329
+ let foundComma = false;
1330
+ let fallbackRawNode = null;
1331
+ for (const child of varFunctionChildren) {
1332
+ if (child.type === "Operator" && child.value === ",") {
1333
+ foundComma = true;
1334
+ continue;
1242
1335
  }
1243
- });
1336
+ if (foundComma && child.type === "Raw") {
1337
+ fallbackRawNode = child;
1338
+ break;
1339
+ }
1340
+ }
1341
+ if (!fallbackRawNode) return;
1342
+ const fallbackValue = fallbackRawNode.value.trim();
1343
+ const varMatch = fallbackValue.match(/var\(([^,)]+)/);
1344
+ if (!varMatch) return;
1345
+ const sldsToken = varMatch[1];
1346
+ if (hasUnsupportedFallback(lwcToken, sldsToken)) {
1347
+ context.report({
1348
+ node,
1349
+ messageId: "unsupportedFallback",
1350
+ data: { lwcToken, sldsToken }
1351
+ });
1352
+ }
1244
1353
  }
1245
1354
  };
1246
1355
  }
1247
1356
  };
1248
1357
 
1249
- // src/rules/v9/no-slds-private-var.ts
1250
- var import_rule_messages13 = __toESM(require_rule_messages());
1251
- var ruleConfig11 = import_rule_messages13.default["no-slds-private-var"];
1252
- var { type: type12, description: description12, url: url12, messages: messages12 } = ruleConfig11;
1253
- var no_slds_private_var_default = {
1358
+ // src/rules/v9/no-unsupported-hooks-slds2.ts
1359
+ var import_sds_metadata8 = __toESM(require("@salesforce-ux/sds-metadata"));
1360
+ var import_rule_messages8 = __toESM(require_rule_messages());
1361
+ var ruleConfig6 = import_rule_messages8.default["no-unsupported-hooks-slds2"];
1362
+ var { type: type7, description: description7, url: url7, messages: messages7 } = ruleConfig6;
1363
+ var deprecatedHooks = new Set(import_sds_metadata8.default.deprecatedStylingHooks);
1364
+ function shouldIgnoreDetection3(sldsHook) {
1365
+ return !deprecatedHooks.has(sldsHook);
1366
+ }
1367
+ var no_unsupported_hooks_slds2_default = {
1254
1368
  meta: {
1255
- type: type12,
1369
+ type: type7,
1256
1370
  docs: {
1257
- description: description12,
1371
+ description: description7,
1258
1372
  recommended: true,
1259
- url: url12
1373
+ url: url7
1260
1374
  },
1261
- fixable: "code",
1262
- messages: messages12
1375
+ messages: messages7
1263
1376
  },
1264
1377
  create(context) {
1378
+ function reportDeprecatedHook(node, token) {
1379
+ context.report({
1380
+ node,
1381
+ messageId: "deprecated",
1382
+ data: { token }
1383
+ });
1384
+ }
1265
1385
  return {
1266
- // Handle CSS custom properties (declarations starting with --)
1267
- "Declaration"(node) {
1268
- if (node.property && typeof node.property === "string" && node.property.startsWith("--_slds-")) {
1269
- context.report({
1270
- node,
1271
- messageId: "privateVar",
1272
- data: { prop: node.property },
1273
- fix(fixer) {
1274
- const newProperty = node.property.replace("--_slds-", "--slds-");
1275
- const sourceCode = context.sourceCode.getText(node);
1276
- const fixedCode = sourceCode.replace(node.property, newProperty);
1277
- return fixer.replaceText(node, fixedCode);
1278
- }
1279
- });
1386
+ // Handle CSS custom property declarations (left-side usage): --slds-* properties
1387
+ // Example: .THIS { --slds-g-link-color: #f73650; }
1388
+ "Declaration[property=/^--s(lds|ds)-/]"(node) {
1389
+ const property = node.property;
1390
+ if (shouldIgnoreDetection3(property)) {
1391
+ return;
1392
+ }
1393
+ reportDeprecatedHook(node, property);
1394
+ },
1395
+ // Handle SLDS/SDS hooks inside var() functions (right-side usage): var(--slds-*)
1396
+ // Example: .THIS .demo { border-top: 1px solid var(--slds-g-color-border-brand-1); }
1397
+ "Function[name='var'] Identifier[name=/^--s(lds|ds)-/]"(node) {
1398
+ const tokenName = node.name;
1399
+ if (shouldIgnoreDetection3(tokenName)) {
1400
+ return;
1280
1401
  }
1402
+ reportDeprecatedHook(node, tokenName);
1281
1403
  }
1282
1404
  };
1283
1405
  }
1284
1406
  };
1285
1407
 
1286
- // src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.ts
1287
- var import_next12 = __toESM(require("@salesforce-ux/sds-metadata/next"));
1288
- var import_rule_messages14 = __toESM(require_rule_messages());
1289
-
1290
- // src/utils/color-lib-utils.ts
1291
- var import_chroma_js = __toESM(require("chroma-js"));
1292
- var import_css_tree = require("@eslint/css-tree");
1293
-
1294
- // src/utils/css-functions.ts
1295
- var CSS_FUNCTIONS = [
1296
- "attr",
1297
- "calc",
1298
- "color-mix",
1299
- "conic-gradient",
1300
- "counter",
1301
- "cubic-bezier",
1302
- "linear-gradient",
1303
- "max",
1304
- "min",
1305
- "radial-gradient",
1306
- "repeating-conic-gradient",
1307
- "repeating-linear-gradient",
1308
- "repeating-radial-gradient",
1309
- "var"
1310
- ];
1311
- var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
1312
- var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
1313
- var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
1314
- var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
1315
- var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
1316
- function isCssFunction(value) {
1317
- return cssFunctionsExactRegex.test(value);
1318
- }
1319
- function isCssColorFunction(value) {
1320
- return RGB_COLOR_FUNCTIONS.includes(value);
1321
- }
1322
-
1323
- // src/utils/color-lib-utils.ts
1324
- var LAB_THRESHOLD = 25;
1325
- var isHexCode = (color) => {
1326
- const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
1327
- return hexPattern.test(color);
1328
- };
1329
- var convertToHex = (color) => {
1330
- try {
1331
- return (0, import_chroma_js.default)(color).hex();
1332
- } catch (e) {
1333
- return null;
1408
+ // src/rules/v9/no-slds-var-without-fallback.ts
1409
+ var import_sds_metadata9 = __toESM(require("@salesforce-ux/sds-metadata"));
1410
+ var import_rule_messages9 = __toESM(require_rule_messages());
1411
+ var ruleConfig7 = import_rule_messages9.default["no-slds-var-without-fallback"];
1412
+ var { type: type8, description: description8, url: url8, messages: messages8 } = ruleConfig7;
1413
+ var sldsVariables = import_sds_metadata9.default.slds1ExcludedVars || {};
1414
+ var no_slds_var_without_fallback_default = {
1415
+ meta: {
1416
+ type: type8,
1417
+ docs: {
1418
+ description: description8,
1419
+ recommended: true,
1420
+ url: url8
1421
+ },
1422
+ fixable: "code",
1423
+ messages: messages8
1424
+ },
1425
+ create(context) {
1426
+ return {
1427
+ "Declaration"(node) {
1428
+ const valueText = context.sourceCode.getText(node.value);
1429
+ if (!valueText) return;
1430
+ const variablesNeedingFallback = [];
1431
+ forEachSldsVariable(valueText, (variableInfo, positionInfo) => {
1432
+ const { name: cssVar, hasFallback } = variableInfo;
1433
+ if (hasFallback) return;
1434
+ const fallbackValue = sldsVariables[cssVar];
1435
+ if (!fallbackValue) return;
1436
+ variablesNeedingFallback.push({
1437
+ cssVar,
1438
+ fallbackValue,
1439
+ start: positionInfo.start?.offset || 0,
1440
+ end: positionInfo.end?.offset || 0
1441
+ });
1442
+ });
1443
+ if (variablesNeedingFallback.length > 0) {
1444
+ let newValue = valueText;
1445
+ const sortedVariables = variablesNeedingFallback.sort((a, b) => b.start - a.start);
1446
+ sortedVariables.forEach(({ cssVar, fallbackValue, start, end }) => {
1447
+ const replacement = `var(${cssVar}, ${fallbackValue})`;
1448
+ newValue = newValue.substring(0, start) + replacement + newValue.substring(end);
1449
+ });
1450
+ variablesNeedingFallback.forEach(({ cssVar, fallbackValue }) => {
1451
+ context.report({
1452
+ node,
1453
+ messageId: "varWithoutFallback",
1454
+ data: { cssVar, recommendation: fallbackValue },
1455
+ fix: (fixer) => fixer.replaceText(node.value, newValue)
1456
+ });
1457
+ });
1458
+ }
1459
+ }
1460
+ };
1334
1461
  }
1335
1462
  };
1336
- var findClosestColorHook = (color, supportedColors, cssProperty) => {
1337
- const returnStylingHooks = [];
1338
- const closestHooksWithSameProperty = [];
1339
- const closestHooksWithoutSameProperty = [];
1340
- const closestHooksWithAllProperty = [];
1341
- const labColor = (0, import_chroma_js.default)(color).lab();
1342
- Object.entries(supportedColors).forEach(([sldsValue, data]) => {
1343
- if (sldsValue && isHexCode(sldsValue)) {
1344
- const hooks = data;
1345
- hooks.forEach((hook) => {
1346
- const labSupportedColor = (0, import_chroma_js.default)(sldsValue).lab();
1347
- 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");
1348
- if (hook.properties.includes(cssProperty)) {
1349
- if (distance <= LAB_THRESHOLD) {
1350
- closestHooksWithSameProperty.push({ name: hook.name, distance });
1351
- }
1352
- } else if (hook.properties.includes("*")) {
1353
- if (distance <= LAB_THRESHOLD) {
1354
- closestHooksWithAllProperty.push({ name: hook.name, distance });
1355
- }
1356
- } else {
1357
- if (distance <= LAB_THRESHOLD) {
1358
- closestHooksWithoutSameProperty.push({ name: hook.name, distance });
1359
- }
1463
+
1464
+ // src/rules/v9/no-slds-namespace-for-custom-hooks.ts
1465
+ var import_sds_metadata10 = __toESM(require("@salesforce-ux/sds-metadata"));
1466
+ var import_rule_messages10 = __toESM(require_rule_messages());
1467
+ var ruleConfig8 = import_rule_messages10.default["no-slds-namespace-for-custom-hooks"];
1468
+ var { type: type9, description: description9, url: url9, messages: messages9 } = ruleConfig8;
1469
+ var sldsPlusStylingHooks3 = import_sds_metadata10.default.sldsPlusStylingHooks;
1470
+ var allSldsHooks3 = [...sldsPlusStylingHooks3.global, ...sldsPlusStylingHooks3.component];
1471
+ var toSldsToken2 = (sdsToken) => sdsToken.replace("--sds-", "--slds-");
1472
+ function shouldIgnoreDetection4(sdsToken) {
1473
+ if (sdsToken.startsWith("--sds-") || sdsToken.startsWith("--slds-")) {
1474
+ return allSldsHooks3.includes(toSldsToken2(sdsToken));
1475
+ }
1476
+ return true;
1477
+ }
1478
+ var no_slds_namespace_for_custom_hooks_default = {
1479
+ meta: {
1480
+ type: type9,
1481
+ docs: {
1482
+ description: description9,
1483
+ recommended: true,
1484
+ url: url9
1485
+ },
1486
+ messages: messages9
1487
+ },
1488
+ create(context) {
1489
+ function reportViolation(node, token) {
1490
+ const tokenWithoutNamespace = token.replace("--slds-", "").replace("--sds-", "");
1491
+ context.report({
1492
+ node,
1493
+ messageId: "customHookNamespace",
1494
+ data: {
1495
+ token,
1496
+ tokenWithoutNamespace
1360
1497
  }
1361
1498
  });
1362
1499
  }
1363
- });
1364
- const closesthookGroups = [
1365
- { hooks: closestHooksWithSameProperty, distance: 0 },
1366
- { hooks: closestHooksWithAllProperty, distance: 0 },
1367
- { hooks: closestHooksWithSameProperty, distance: Infinity },
1368
- // For hooks with distance > 0
1369
- { hooks: closestHooksWithAllProperty, distance: Infinity },
1370
- { hooks: closestHooksWithoutSameProperty, distance: Infinity }
1371
- ];
1372
- for (const group of closesthookGroups) {
1373
- const filteredHooks = group.hooks.filter(
1374
- (h) => group.distance === 0 ? h.distance === 0 : h.distance > 0
1375
- );
1376
- if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {
1377
- filteredHooks.sort((a, b) => a.distance - b.distance);
1378
- returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));
1379
- }
1500
+ return {
1501
+ // CSS custom property declarations: --slds-* and --sds-* properties
1502
+ "Declaration[property=/^--s(lds|ds)-/]"(node) {
1503
+ const property = node.property;
1504
+ if (shouldIgnoreDetection4(property)) {
1505
+ return;
1506
+ }
1507
+ reportViolation(node, property);
1508
+ },
1509
+ // SLDS/SDS tokens inside var() functions: var(--slds-*) or var(--sds-*)
1510
+ "Function[name='var'] Identifier[name=/^--s(lds|ds)-/]"(node) {
1511
+ const tokenName = node.name;
1512
+ if (shouldIgnoreDetection4(tokenName)) {
1513
+ return;
1514
+ }
1515
+ reportViolation(node, tokenName);
1516
+ }
1517
+ };
1380
1518
  }
1381
- return Array.from(new Set(returnStylingHooks));
1382
1519
  };
1383
- var isValidColor = (val) => import_chroma_js.default.valid(val);
1384
- var extractColorValue = (node) => {
1385
- let colorValue = null;
1386
- switch (node.type) {
1387
- case "Hash":
1388
- colorValue = `#${node.value}`;
1389
- break;
1390
- case "Identifier":
1391
- colorValue = node.name;
1392
- break;
1393
- case "Function":
1394
- if (isCssColorFunction(node.name)) {
1395
- colorValue = (0, import_css_tree.generate)(node);
1520
+
1521
+ // src/rules/v9/enforce-component-hook-naming-convention.ts
1522
+ var import_sds_metadata11 = __toESM(require("@salesforce-ux/sds-metadata"));
1523
+ var import_rule_messages11 = __toESM(require_rule_messages());
1524
+ var ruleConfig9 = import_rule_messages11.default["enforce-component-hook-naming-convention"];
1525
+ var { type: type10, description: description10, url: url10, messages: messages10 } = ruleConfig9;
1526
+ var slds1DeprecatedComponentHooks = import_sds_metadata11.default.slds1DeprecatedComponentHooks;
1527
+ function shouldIgnoreDetection5(hook) {
1528
+ return !hook.startsWith("--slds-c-") || !(hook in slds1DeprecatedComponentHooks);
1529
+ }
1530
+ var enforce_component_hook_naming_convention_default = {
1531
+ meta: {
1532
+ type: type10,
1533
+ docs: {
1534
+ description: description10,
1535
+ recommended: true,
1536
+ url: url10
1537
+ },
1538
+ fixable: "code",
1539
+ messages: messages10
1540
+ },
1541
+ create(context) {
1542
+ return {
1543
+ /*
1544
+ * Handle component hooks in CSS declarations
1545
+ * Limitation: For example:
1546
+ * .testClass{
1547
+ * --slds-c-accordion-section-color-background: var(--slds-c-accordion-section-color-border);
1548
+ * }
1549
+ * var in value is not detected, because eslint treats above statement as custom property assignment
1550
+ * and value treated as raw string, not parsed into function nodes
1551
+ */
1552
+ "Declaration[property=/^--slds-c-/], Function[name='var'] Identifier[name=/^--slds-c-/]"(node) {
1553
+ let hookName;
1554
+ let reportNode = node;
1555
+ if (node.type === "Declaration") {
1556
+ hookName = node.property;
1557
+ } else if (node.type === "Identifier") {
1558
+ hookName = node.name;
1559
+ } else {
1560
+ return;
1561
+ }
1562
+ if (shouldIgnoreDetection5(hookName)) {
1563
+ return;
1564
+ }
1565
+ const suggestedMatch = slds1DeprecatedComponentHooks[hookName];
1566
+ context.report({
1567
+ node: reportNode,
1568
+ messageId: "replace",
1569
+ data: {
1570
+ oldValue: hookName,
1571
+ suggestedMatch
1572
+ },
1573
+ fix(fixer) {
1574
+ if (node.type === "Declaration") {
1575
+ const originalText = context.sourceCode.getText(node);
1576
+ const colonIndex = originalText.indexOf(":");
1577
+ const valuePartWithColon = originalText.substring(colonIndex);
1578
+ return fixer.replaceText(node, `${suggestedMatch}${valuePartWithColon}`);
1579
+ } else if (node.type === "Identifier") {
1580
+ return fixer.replaceText(node, suggestedMatch);
1581
+ }
1582
+ return null;
1583
+ }
1584
+ });
1396
1585
  }
1397
- break;
1586
+ };
1398
1587
  }
1399
- return colorValue && isValidColor(colorValue) ? colorValue : null;
1400
1588
  };
1401
1589
 
1402
- // src/utils/property-matcher.ts
1403
- var DIRECTION_VALUES = "(?:top|right|bottom|left|inline|block|inline-start|inline-end|start|end|block-start|block-end)";
1404
- var CORNER_VALUES = "(?:top-left|top-right|bottom-right|bottom-left|start-start|start-end|end-start|end-end)";
1405
- var INSET_VALUES = "(?:inline|block|inline-start|inline-end|block-start|block-end)";
1406
- var BORDER_COLOR_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-color$`);
1407
- var BORDER_WIDTH_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-width$`);
1408
- var MARGIN_REGEX = new RegExp(`^margin(?:-${DIRECTION_VALUES})?$`);
1409
- var PADDING_REGEX = new RegExp(`^padding(?:-${DIRECTION_VALUES})?$`);
1410
- var BORDER_RADIUS_REGEX = new RegExp(`^border(?:-${CORNER_VALUES})?-radius$`);
1411
- var INSET_REGEX = new RegExp(`^inset(?:-${INSET_VALUES})?$`);
1412
- function isBorderColorProperty(cssProperty) {
1413
- return BORDER_COLOR_REGEX.test(cssProperty);
1414
- }
1415
- function isBorderWidthProperty(cssProperty) {
1416
- return BORDER_WIDTH_REGEX.test(cssProperty);
1417
- }
1418
- function isMarginProperty(cssProperty) {
1419
- return MARGIN_REGEX.test(cssProperty);
1420
- }
1421
- function isPaddingProperty(cssProperty) {
1422
- return PADDING_REGEX.test(cssProperty);
1423
- }
1424
- function isBorderRadius(cssProperty) {
1425
- return BORDER_RADIUS_REGEX.test(cssProperty);
1426
- }
1427
- function isDimensionProperty(cssProperty) {
1428
- return ["width", "height", "min-width", "max-width", "min-height", "max-height"].includes(cssProperty);
1429
- }
1430
- function isInsetProperty(cssProperty) {
1431
- return INSET_REGEX.test(cssProperty);
1432
- }
1433
- var fontProperties = [
1434
- "font",
1435
- "font-size",
1436
- "font-weight"
1437
- ];
1438
- var colorProperties = [
1439
- "color",
1440
- "fill",
1441
- "background",
1442
- "background-color",
1443
- "stroke",
1444
- "border",
1445
- "border*",
1446
- "border*-color",
1447
- "outline",
1448
- "outline-color"
1449
- ];
1450
- var densificationProperties = [
1451
- "border*",
1452
- "margin*",
1453
- "padding*",
1454
- "width",
1455
- "height",
1456
- "min-width",
1457
- "max-width",
1458
- "min-height",
1459
- "max-height",
1460
- "inset",
1461
- "top",
1462
- "right",
1463
- "left",
1464
- "bottom",
1465
- "outline",
1466
- "outline-width",
1467
- "line-height"
1468
- ];
1469
- function toSelector(properties) {
1470
- const selectorParts = properties.map((prop) => {
1471
- if (prop.includes("*")) {
1472
- const regexPattern = prop.replace(/\*/g, ".*");
1473
- return `Declaration[property=/${regexPattern}$/]`;
1474
- } else {
1475
- return `Declaration[property='${prop}']`;
1476
- }
1477
- });
1478
- return selectorParts.join(", ");
1479
- }
1480
- function resolvePropertyToMatch(cssProperty) {
1481
- const propertyToMatch = cssProperty.toLowerCase();
1482
- if (propertyToMatch === "outline" || propertyToMatch === "outline-width" || isBorderWidthProperty(propertyToMatch)) {
1483
- return "border-width";
1484
- } else if (isMarginProperty(propertyToMatch)) {
1485
- return "margin";
1486
- } else if (isPaddingProperty(propertyToMatch)) {
1487
- return "padding";
1488
- } else if (isBorderRadius(propertyToMatch)) {
1489
- return "border-radius";
1490
- } else if (isDimensionProperty(propertyToMatch)) {
1491
- return "width";
1492
- } else if (isInsetProperty(propertyToMatch)) {
1493
- return "top";
1494
- } else if (cssProperty === "background" || cssProperty === "background-color") {
1495
- return "background-color";
1496
- } else if (cssProperty === "outline" || cssProperty === "outline-color" || isBorderColorProperty(cssProperty)) {
1497
- return "border-color";
1498
- }
1499
- return propertyToMatch;
1500
- }
1501
-
1502
- // src/utils/hardcoded-shared-utils.ts
1503
- var import_css_tree2 = require("@eslint/css-tree");
1504
- var FONT_WEIGHTS = [
1505
- "normal",
1506
- "bold",
1507
- "bolder",
1508
- "lighter",
1509
- "100",
1510
- "200",
1511
- "300",
1512
- "400",
1513
- "500",
1514
- "600",
1515
- "700",
1516
- "800",
1517
- "900"
1590
+ // src/rules/v9/reduce-annotations.ts
1591
+ var import_rule_messages12 = __toESM(require_rule_messages());
1592
+ var ruleConfig10 = import_rule_messages12.default["reduce-annotations"];
1593
+ var { type: type11, description: description11, url: url11, messages: messages11 } = ruleConfig10;
1594
+ var SLDS_ANNOTATIONS = [
1595
+ "@sldsValidatorIgnoreNextLine",
1596
+ "@sldsValidatorAllow",
1597
+ "@sldsValidatorIgnore"
1518
1598
  ];
1519
- function isKnownFontWeight(value) {
1520
- const stringValue = value.toString();
1521
- return FONT_WEIGHTS.includes(stringValue.toLowerCase());
1522
- }
1523
- function handleShorthandAutoFix(declarationNode, context, valueText, replacements) {
1524
- const sortedReplacements = replacements.sort((a, b) => a.start - b.start);
1525
- const hasAnyHooks = sortedReplacements.some((r) => r.hasHook);
1526
- const canAutoFix = hasAnyHooks;
1527
- sortedReplacements.forEach(({ start, end, replacement, displayValue, hasHook }) => {
1528
- const originalValue = valueText.substring(start, end);
1529
- const valueStartColumn = declarationNode.value.loc.start.column;
1530
- const valueColumn = valueStartColumn + start;
1531
- const { loc: { start: locStart, end: locEnd } } = declarationNode.value;
1532
- const reportNode = {
1533
- ...declarationNode.value,
1534
- loc: {
1535
- ...declarationNode.value.loc,
1536
- start: {
1537
- ...locStart,
1538
- column: valueColumn
1539
- },
1540
- end: {
1541
- ...locEnd,
1542
- column: valueColumn + originalValue.length
1543
- }
1599
+ var reduce_annotations_default = {
1600
+ meta: {
1601
+ type: type11,
1602
+ docs: {
1603
+ description: description11,
1604
+ recommended: true,
1605
+ url: url11
1606
+ },
1607
+ messages: messages11
1608
+ },
1609
+ create(context) {
1610
+ return {
1611
+ StyleSheet(node) {
1612
+ const sourceCode = context.sourceCode;
1613
+ let comments = sourceCode?.comments || [];
1614
+ comments.forEach((comment) => {
1615
+ const commentContent = comment.value.trim();
1616
+ const matchingAnnotation = SLDS_ANNOTATIONS.find(
1617
+ (annotation) => commentContent.startsWith(annotation)
1618
+ );
1619
+ if (matchingAnnotation) {
1620
+ context.report({
1621
+ node: comment,
1622
+ messageId: "removeAnnotation"
1623
+ });
1624
+ }
1625
+ });
1544
1626
  }
1545
1627
  };
1546
- if (hasHook) {
1547
- const fix = canAutoFix ? (fixer) => {
1548
- let newValue = valueText;
1549
- for (let i = sortedReplacements.length - 1; i >= 0; i--) {
1550
- const { start: rStart, end: rEnd, replacement: rReplacement } = sortedReplacements[i];
1551
- newValue = newValue.substring(0, rStart) + rReplacement + newValue.substring(rEnd);
1552
- }
1553
- return fixer.replaceText(declarationNode.value, newValue);
1554
- } : void 0;
1555
- context.context.report({
1556
- node: reportNode,
1557
- messageId: "hardcodedValue",
1558
- data: {
1559
- oldValue: originalValue,
1560
- newValue: displayValue
1561
- },
1562
- fix
1563
- });
1564
- } else {
1565
- context.context.report({
1566
- node: reportNode,
1567
- messageId: "noReplacement",
1568
- data: {
1569
- oldValue: originalValue
1570
- }
1571
- });
1572
- }
1573
- });
1574
- }
1575
- function forEachValue(valueText, extractValue, shouldSkipNode, callback) {
1576
- if (!valueText || typeof valueText !== "string") {
1577
- return;
1578
- }
1579
- try {
1580
- const ast = (0, import_css_tree2.parse)(valueText, { context: "value", positions: true });
1581
- (0, import_css_tree2.walk)(ast, {
1582
- enter(node) {
1583
- if (shouldSkipNode(node)) {
1584
- return this.skip;
1585
- }
1586
- const value = extractValue(node);
1587
- if (value !== null) {
1588
- const positionInfo = {
1589
- start: node.loc?.start,
1590
- end: node.loc?.end
1591
- };
1592
- callback(value, positionInfo);
1593
- }
1594
- }
1595
- });
1596
- } catch (error) {
1597
- return;
1598
1628
  }
1599
- }
1600
- function shouldSkipColorNode(node) {
1601
- return node.type === "Function" && isCssFunction(node.name);
1602
- }
1603
- function shouldSkipDimensionNode(node) {
1604
- return node.type === "Function";
1605
- }
1606
- function extractDimensionValue(valueNode, cssProperty) {
1607
- if (!valueNode) return null;
1608
- switch (valueNode.type) {
1609
- case "Dimension":
1610
- const numValue = Number(valueNode.value);
1611
- if (numValue === 0) return null;
1612
- const unit = valueNode.unit.toLowerCase();
1613
- if (unit !== "px" && unit !== "rem" && unit !== "%") return null;
1614
- return {
1615
- number: numValue,
1616
- unit
1617
- };
1618
- case "Number":
1619
- const numberValue = Number(valueNode.value);
1620
- if (numberValue === 0) return null;
1621
- return {
1622
- number: numberValue,
1623
- unit: null
1624
- };
1625
- case "Percentage":
1626
- const percentValue = Number(valueNode.value);
1627
- if (percentValue === 0) return null;
1628
- return {
1629
- number: percentValue,
1630
- unit: "%"
1631
- };
1632
- case "Value":
1633
- return valueNode.children?.[0] ? extractDimensionValue(valueNode.children[0], cssProperty) : null;
1629
+ };
1630
+
1631
+ // src/rules/v9/no-slds-private-var.ts
1632
+ var import_rule_messages13 = __toESM(require_rule_messages());
1633
+ var ruleConfig11 = import_rule_messages13.default["no-slds-private-var"];
1634
+ var { type: type12, description: description12, url: url12, messages: messages12 } = ruleConfig11;
1635
+ var no_slds_private_var_default = {
1636
+ meta: {
1637
+ type: type12,
1638
+ docs: {
1639
+ description: description12,
1640
+ recommended: true,
1641
+ url: url12
1642
+ },
1643
+ fixable: "code",
1644
+ messages: messages12
1645
+ },
1646
+ create(context) {
1647
+ return {
1648
+ // Handle CSS custom properties (declarations starting with --)
1649
+ "Declaration"(node) {
1650
+ if (node.property && typeof node.property === "string" && node.property.startsWith("--_slds-")) {
1651
+ context.report({
1652
+ node,
1653
+ messageId: "privateVar",
1654
+ data: { prop: node.property },
1655
+ fix(fixer) {
1656
+ const newProperty = node.property.replace("--_slds-", "--slds-");
1657
+ const sourceCode = context.sourceCode.getText(node);
1658
+ const fixedCode = sourceCode.replace(node.property, newProperty);
1659
+ return fixer.replaceText(node, fixedCode);
1660
+ }
1661
+ });
1662
+ }
1663
+ }
1664
+ };
1634
1665
  }
1635
- return null;
1666
+ };
1667
+
1668
+ // src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.ts
1669
+ var import_sds_metadata12 = __toESM(require("@salesforce-ux/sds-metadata"));
1670
+ var import_rule_messages14 = __toESM(require_rule_messages());
1671
+
1672
+ // src/utils/property-matcher.ts
1673
+ var DIRECTION_VALUES = "(?:top|right|bottom|left|inline|block|inline-start|inline-end|start|end|block-start|block-end)";
1674
+ var CORNER_VALUES = "(?:top-left|top-right|bottom-right|bottom-left|start-start|start-end|end-start|end-end)";
1675
+ var INSET_VALUES = "(?:inline|block|inline-start|inline-end|block-start|block-end)";
1676
+ var BORDER_COLOR_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-color$`);
1677
+ var BORDER_WIDTH_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-width$`);
1678
+ var MARGIN_REGEX = new RegExp(`^margin(?:-${DIRECTION_VALUES})?$`);
1679
+ var PADDING_REGEX = new RegExp(`^padding(?:-${DIRECTION_VALUES})?$`);
1680
+ var BORDER_RADIUS_REGEX = new RegExp(`^border(?:-${CORNER_VALUES})?-radius$`);
1681
+ var INSET_REGEX = new RegExp(`^inset(?:-${INSET_VALUES})?$`);
1682
+ function isBorderColorProperty(cssProperty) {
1683
+ return BORDER_COLOR_REGEX.test(cssProperty);
1636
1684
  }
1637
- function forEachColorValue(valueText, callback) {
1638
- forEachValue(valueText, extractColorValue, shouldSkipColorNode, callback);
1685
+ function isBorderWidthProperty(cssProperty) {
1686
+ return BORDER_WIDTH_REGEX.test(cssProperty);
1639
1687
  }
1640
- function forEachDensityValue(valueText, cssProperty, callback) {
1641
- forEachValue(
1642
- valueText,
1643
- (node) => extractDimensionValue(node, cssProperty),
1644
- shouldSkipDimensionNode,
1645
- callback
1646
- );
1688
+ function isMarginProperty(cssProperty) {
1689
+ return MARGIN_REGEX.test(cssProperty);
1647
1690
  }
1648
- function extractFontValue(node) {
1649
- if (!node) return null;
1650
- switch (node.type) {
1651
- case "Dimension":
1652
- const numValue = Number(node.value);
1653
- if (numValue <= 0) return null;
1654
- const unit = node.unit.toLowerCase();
1655
- if (unit !== "px" && unit !== "rem" && unit !== "%") return null;
1656
- return {
1657
- number: numValue,
1658
- unit
1659
- };
1660
- case "Number":
1661
- const numberValue = Number(node.value);
1662
- if (numberValue <= 0) {
1663
- return null;
1664
- }
1665
- if (!isKnownFontWeight(numberValue)) {
1666
- return null;
1667
- }
1668
- return {
1669
- number: numberValue,
1670
- unit: null
1671
- };
1672
- case "Identifier":
1673
- const namedValue = node.name.toLowerCase();
1674
- if (!isKnownFontWeight(namedValue)) {
1675
- return null;
1676
- }
1677
- if (namedValue === "normal") {
1678
- return { number: 400, unit: null };
1679
- }
1680
- return { number: namedValue, unit: null };
1681
- case "Percentage":
1682
- const percentValue = Number(node.value);
1683
- if (percentValue === 0) return null;
1684
- return {
1685
- number: percentValue,
1686
- unit: "%"
1687
- };
1688
- case "Value":
1689
- return node.children?.[0] ? extractFontValue(node.children[0]) : null;
1690
- }
1691
- return null;
1691
+ function isPaddingProperty(cssProperty) {
1692
+ return PADDING_REGEX.test(cssProperty);
1692
1693
  }
1693
- function shouldSkipFontNode(node) {
1694
- return node.type === "Function";
1694
+ function isBorderRadius(cssProperty) {
1695
+ return BORDER_RADIUS_REGEX.test(cssProperty);
1695
1696
  }
1696
- function forEachFontValue(valueText, callback) {
1697
- forEachValue(valueText, extractFontValue, shouldSkipFontNode, callback);
1697
+ function isDimensionProperty(cssProperty) {
1698
+ return ["width", "height", "min-width", "max-width", "min-height", "max-height"].includes(cssProperty);
1699
+ }
1700
+ function isInsetProperty(cssProperty) {
1701
+ return INSET_REGEX.test(cssProperty);
1702
+ }
1703
+ var fontProperties = [
1704
+ "font",
1705
+ "font-size",
1706
+ "font-weight"
1707
+ ];
1708
+ var colorProperties = [
1709
+ "color",
1710
+ "fill",
1711
+ "background",
1712
+ "background-color",
1713
+ "stroke",
1714
+ "border",
1715
+ "border*",
1716
+ "border*-color",
1717
+ "outline",
1718
+ "outline-color"
1719
+ ];
1720
+ var densificationProperties = [
1721
+ "border*",
1722
+ "margin*",
1723
+ "padding*",
1724
+ "width",
1725
+ "height",
1726
+ "min-width",
1727
+ "max-width",
1728
+ "min-height",
1729
+ "max-height",
1730
+ "inset",
1731
+ "top",
1732
+ "right",
1733
+ "left",
1734
+ "bottom",
1735
+ "outline",
1736
+ "outline-width",
1737
+ "line-height"
1738
+ ];
1739
+ function toSelector(properties) {
1740
+ const selectorParts = properties.map((prop) => {
1741
+ if (prop.includes("*")) {
1742
+ const regexPattern = prop.replace(/\*/g, ".*");
1743
+ return `Declaration[property=/^${regexPattern}$/]`;
1744
+ } else {
1745
+ return `Declaration[property='${prop}']`;
1746
+ }
1747
+ });
1748
+ return selectorParts.join(", ");
1749
+ }
1750
+ function resolvePropertyToMatch(cssProperty) {
1751
+ const propertyToMatch = cssProperty.toLowerCase();
1752
+ if (propertyToMatch === "outline" || propertyToMatch === "outline-width" || isBorderWidthProperty(propertyToMatch)) {
1753
+ return "border-width";
1754
+ } else if (isMarginProperty(propertyToMatch)) {
1755
+ return "margin";
1756
+ } else if (isPaddingProperty(propertyToMatch)) {
1757
+ return "padding";
1758
+ } else if (isBorderRadius(propertyToMatch)) {
1759
+ return "border-radius";
1760
+ } else if (isDimensionProperty(propertyToMatch)) {
1761
+ return "width";
1762
+ } else if (isInsetProperty(propertyToMatch)) {
1763
+ return "top";
1764
+ } else if (cssProperty === "background" || cssProperty === "background-color") {
1765
+ return "background-color";
1766
+ } else if (cssProperty === "outline" || cssProperty === "outline-color" || isBorderColorProperty(cssProperty)) {
1767
+ return "border-color";
1768
+ }
1769
+ return propertyToMatch;
1698
1770
  }
1699
1771
 
1700
1772
  // src/rules/v9/no-hardcoded-values/handlers/colorHandler.ts
@@ -1739,9 +1811,8 @@ function createColorReplacement(colorValue, cssProperty, context, positionInfo,
1739
1811
  end,
1740
1812
  replacement: originalValue,
1741
1813
  // Use original value to preserve spacing
1742
- displayValue: closestHooks.join(", "),
1814
+ displayValue: formatSuggestionHooks(closestHooks),
1743
1815
  hasHook: true
1744
- // ← THE FIX: Multiple hooks still means "has hooks"
1745
1816
  };
1746
1817
  } else {
1747
1818
  return {
@@ -1755,37 +1826,6 @@ function createColorReplacement(colorValue, cssProperty, context, positionInfo,
1755
1826
  }
1756
1827
  }
1757
1828
 
1758
- // src/utils/value-utils.ts
1759
- function parseUnitValue(value) {
1760
- if (!value) return null;
1761
- const match = value.match(/^(-?\d*\.?\d+)(px|rem|%)?$/);
1762
- if (!match) return null;
1763
- const number = parseFloat(match[1]);
1764
- const unit = match[2] ? match[2] : null;
1765
- if (isNaN(number)) return null;
1766
- return { number, unit };
1767
- }
1768
- function toAlternateUnitValue(numberVal, unitType) {
1769
- if (unitType === "px") {
1770
- let floatValue = parseFloat(`${numberVal / 16}`);
1771
- if (!isNaN(floatValue)) {
1772
- return {
1773
- unit: "rem",
1774
- number: parseFloat(floatValue.toFixed(4))
1775
- };
1776
- }
1777
- } else if (unitType === "rem") {
1778
- const intValue = parseInt(`${numberVal * 16}`);
1779
- if (!isNaN(intValue)) {
1780
- return {
1781
- unit: "px",
1782
- number: intValue
1783
- };
1784
- }
1785
- }
1786
- return null;
1787
- }
1788
-
1789
1829
  // src/utils/styling-hook-utils.ts
1790
1830
  function isValueMatch(valueToMatch, sldsValue) {
1791
1831
  if (!valueToMatch || !sldsValue) {
@@ -1843,7 +1883,7 @@ function createDimensionReplacement(parsedDimension, cssProperty, context, posit
1843
1883
  start,
1844
1884
  end,
1845
1885
  replacement: rawValue,
1846
- displayValue: closestHooks.join(", "),
1886
+ displayValue: formatSuggestionHooks(closestHooks),
1847
1887
  hasHook: true
1848
1888
  };
1849
1889
  } else {
@@ -1910,7 +1950,7 @@ function createFontReplacement(fontValue, cssProperty, context, positionInfo) {
1910
1950
  start,
1911
1951
  end,
1912
1952
  replacement: rawValue,
1913
- displayValue: closestHooks.join(", "),
1953
+ displayValue: formatSuggestionHooks(closestHooks),
1914
1954
  hasHook: true
1915
1955
  };
1916
1956
  } else {
@@ -2037,59 +2077,51 @@ function isBoxShadowMatch(parsedCssValue, parsedValueHook) {
2037
2077
  }
2038
2078
 
2039
2079
  // src/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.ts
2040
- function containsCssVariable(valueText) {
2041
- return valueText.includes("var(");
2042
- }
2043
- var handleBoxShadowDeclaration = (node, context) => {
2044
- const cssProperty = node.property.toLowerCase();
2045
- const valueText = context.sourceCode.getText(node.value);
2046
- if (containsCssVariable(valueText)) {
2047
- return;
2048
- }
2049
- const replacements = [];
2050
- const parsedCssValue = parseAndValidateBoxShadow(valueText);
2051
- if (parsedCssValue) {
2052
- const shadowHooks = getBoxShadowHooks(context.valueToStylinghook);
2053
- const closestHooks = findMatchingBoxShadowHooks(parsedCssValue, shadowHooks);
2054
- const positionInfo = {
2055
- start: { offset: 0, line: 1, column: 1 },
2056
- end: { offset: valueText.length, line: 1, column: valueText.length + 1 }
2057
- };
2058
- const replacement = createBoxShadowReplacement(
2059
- valueText,
2060
- closestHooks,
2061
- context,
2062
- positionInfo
2063
- );
2064
- if (replacement) {
2065
- replacements.push(replacement);
2066
- }
2080
+ function toBoxShadowValue(cssValue) {
2081
+ const parsedCssValue = parseBoxShadowValue(cssValue).filter((shadow) => Object.keys(shadow).length > 0);
2082
+ if (parsedCssValue.length === 0) {
2083
+ return null;
2067
2084
  }
2068
- handleShorthandAutoFix(node, context, valueText, replacements);
2069
- };
2070
- function getBoxShadowHooks(supportedStylinghooks) {
2085
+ return parsedCssValue;
2086
+ }
2087
+ function shadowValueToHookEntries(supportedStylinghooks) {
2071
2088
  return Object.entries(supportedStylinghooks).filter(([key, value]) => {
2072
2089
  return value.some((hook) => hook.properties.includes("box-shadow"));
2073
2090
  }).map(([key, value]) => {
2074
2091
  return [key, value.map((hook) => hook.name)];
2075
2092
  });
2076
2093
  }
2077
- function parseAndValidateBoxShadow(cssValue) {
2078
- const parsedCssValue = parseBoxShadowValue(cssValue).filter((shadow) => Object.keys(shadow).length > 0);
2079
- if (parsedCssValue.length === 0) {
2080
- return null;
2094
+ var handleBoxShadowDeclaration = (node, context) => {
2095
+ const cssProperty = node.property.toLowerCase();
2096
+ const valueText = context.sourceCode.getText(node.value);
2097
+ const shadowHooks = shadowValueToHookEntries(context.valueToStylinghook);
2098
+ const parsedCssValue = toBoxShadowValue(valueText);
2099
+ if (!parsedCssValue) {
2100
+ return;
2081
2101
  }
2082
- return parsedCssValue;
2083
- }
2084
- function findMatchingBoxShadowHooks(parsedCssValue, shadowHooks) {
2085
- for (const [shadowHookValue, closestHooks] of shadowHooks) {
2086
- const parsedHookValue = parseAndValidateBoxShadow(shadowHookValue);
2087
- if (parsedHookValue && isBoxShadowMatch(parsedCssValue, parsedHookValue)) {
2088
- return closestHooks;
2102
+ for (const [shadow, closestHooks] of shadowHooks) {
2103
+ const parsedValueHook = toBoxShadowValue(shadow);
2104
+ if (parsedValueHook && isBoxShadowMatch(parsedCssValue, parsedValueHook)) {
2105
+ if (closestHooks.length > 0) {
2106
+ const positionInfo = {
2107
+ start: { offset: 0, line: 1, column: 1 },
2108
+ end: { offset: valueText.length, line: 1, column: valueText.length + 1 }
2109
+ };
2110
+ const replacement = createBoxShadowReplacement(
2111
+ valueText,
2112
+ closestHooks,
2113
+ context,
2114
+ positionInfo
2115
+ );
2116
+ if (replacement) {
2117
+ const replacements = [replacement];
2118
+ handleShorthandAutoFix(node, context, valueText, replacements);
2119
+ }
2120
+ }
2121
+ return;
2089
2122
  }
2090
2123
  }
2091
- return [];
2092
- }
2124
+ };
2093
2125
  function createBoxShadowReplacement(originalValue, hooks, context, positionInfo) {
2094
2126
  if (!positionInfo?.start) {
2095
2127
  return null;
@@ -2104,28 +2136,39 @@ function createBoxShadowReplacement(originalValue, hooks, context, positionInfo)
2104
2136
  displayValue: hooks[0],
2105
2137
  hasHook: true
2106
2138
  };
2107
- } else if (hooks.length > 1) {
2108
- return {
2109
- start,
2110
- end,
2111
- replacement: originalValue,
2112
- displayValue: hooks.join(", "),
2113
- hasHook: true
2114
- };
2115
2139
  } else {
2116
2140
  return {
2117
2141
  start,
2118
2142
  end,
2119
2143
  replacement: originalValue,
2120
- displayValue: originalValue,
2121
- hasHook: false
2144
+ displayValue: formatSuggestionHooks(hooks),
2145
+ hasHook: true
2122
2146
  };
2123
2147
  }
2124
2148
  }
2125
2149
 
2150
+ // src/utils/rule-utils.ts
2151
+ function isRuleEnabled(context, ruleName3) {
2152
+ try {
2153
+ const rules2 = context.settings?.sldsRules || {};
2154
+ if (ruleName3 in rules2) {
2155
+ const ruleConfig14 = rules2[ruleName3];
2156
+ if (Array.isArray(ruleConfig14)) {
2157
+ return ruleConfig14[0] === true;
2158
+ } else if (ruleConfig14 !== void 0 && ruleConfig14 !== null) {
2159
+ return true;
2160
+ } else if (ruleConfig14 === false) {
2161
+ return false;
2162
+ }
2163
+ }
2164
+ } catch (error) {
2165
+ return false;
2166
+ }
2167
+ }
2168
+
2126
2169
  // src/rules/v9/no-hardcoded-values/noHardcodedValueRule.ts
2127
2170
  function defineNoHardcodedValueRule(config) {
2128
- const { ruleConfig: ruleConfig14 } = config;
2171
+ const { ruleConfig: ruleConfig14, ruleName: ruleName3 } = config;
2129
2172
  const { type: type15, description: description15, url: url15, messages: messages15 } = ruleConfig14;
2130
2173
  return {
2131
2174
  meta: {
@@ -2139,6 +2182,9 @@ function defineNoHardcodedValueRule(config) {
2139
2182
  messages: messages15
2140
2183
  },
2141
2184
  create(context) {
2185
+ if (ruleName3 === "no-hardcoded-values-slds1" && isRuleEnabled(context, "@salesforce-ux/slds/no-hardcoded-values-slds2")) {
2186
+ return {};
2187
+ }
2142
2188
  const handlerContext = {
2143
2189
  valueToStylinghook: config.valueToStylinghook,
2144
2190
  context,
@@ -2194,36 +2240,38 @@ function defineNoHardcodedValueRule(config) {
2194
2240
  }
2195
2241
 
2196
2242
  // src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.ts
2197
- var ruleConfig12 = import_rule_messages14.default["no-hardcoded-values-slds1"];
2243
+ var ruleName = "no-hardcoded-values-slds1";
2244
+ var ruleConfig12 = import_rule_messages14.default[ruleName];
2198
2245
  var { type: type13, description: description13, url: url13, messages: messages13 } = ruleConfig12;
2199
- var valueToStylinghook = import_next12.default.valueToStylingHooksSlds;
2246
+ var valueToStylinghook = import_sds_metadata12.default.valueToStylingHooksSlds;
2200
2247
  var no_hardcoded_values_slds1_default = defineNoHardcodedValueRule({
2201
2248
  ruleConfig: ruleConfig12,
2202
- valueToStylinghook
2249
+ valueToStylinghook,
2250
+ ruleName
2203
2251
  });
2204
2252
 
2205
2253
  // src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.ts
2206
- var import_next13 = __toESM(require("@salesforce-ux/sds-metadata/next"));
2254
+ var import_sds_metadata13 = __toESM(require("@salesforce-ux/sds-metadata"));
2207
2255
  var import_rule_messages15 = __toESM(require_rule_messages());
2208
- var ruleConfig13 = import_rule_messages15.default["no-hardcoded-values-slds2"];
2256
+ var ruleName2 = "no-hardcoded-values-slds2";
2257
+ var ruleConfig13 = import_rule_messages15.default[ruleName2];
2209
2258
  var { type: type14, description: description14, url: url14, messages: messages14 } = ruleConfig13;
2210
- var valueToStylinghook2 = import_next13.default.valueToStylingHooksCosmos;
2259
+ var valueToStylinghook2 = import_sds_metadata13.default.valueToStylingHooksCosmos;
2211
2260
  var no_hardcoded_values_slds2_default = defineNoHardcodedValueRule({
2212
2261
  ruleConfig: ruleConfig13,
2213
- valueToStylinghook: valueToStylinghook2
2262
+ valueToStylinghook: valueToStylinghook2,
2263
+ ruleName: ruleName2
2214
2264
  });
2215
2265
 
2216
2266
  // src/index.ts
2217
2267
  var import_parser2 = __toESM(require("@html-eslint/parser"));
2218
2268
  var import_css = __toESM(require("@eslint/css"));
2219
2269
 
2220
- // eslint.rules.internal.json
2221
- var eslint_rules_internal_default = {
2270
+ // eslint.rules.json
2271
+ var eslint_rules_default = {
2222
2272
  css: {
2223
2273
  "@salesforce-ux/slds/no-slds-class-overrides": "warn",
2224
2274
  "@salesforce-ux/slds/no-deprecated-slds-classes": "warn",
2225
- "@salesforce-ux/slds/no-deprecated-tokens-slds1": "error",
2226
- "@salesforce-ux/slds/lwc-token-to-slds-hook": "error",
2227
2275
  "@salesforce-ux/slds/enforce-sds-to-slds-hooks": "warn",
2228
2276
  "@salesforce-ux/slds/no-sldshook-fallback-for-lwctoken": "warn",
2229
2277
  "@salesforce-ux/slds/no-unsupported-hooks-slds2": "warn",
@@ -2231,7 +2279,6 @@ var eslint_rules_internal_default = {
2231
2279
  "@salesforce-ux/slds/no-slds-namespace-for-custom-hooks": "warn",
2232
2280
  "@salesforce-ux/slds/enforce-component-hook-naming-convention": "error",
2233
2281
  "@salesforce-ux/slds/no-slds-private-var": "warn",
2234
- "@salesforce-ux/slds/no-hardcoded-values-slds1": "error",
2235
2282
  "@salesforce-ux/slds/no-hardcoded-values-slds2": "warn",
2236
2283
  "@salesforce-ux/slds/reduce-annotations": "warn"
2237
2284
  },
@@ -2265,47 +2312,56 @@ var rules = {
2265
2312
  var plugin = {
2266
2313
  meta: {
2267
2314
  name: "@salesforce-ux/eslint-plugin-slds",
2268
- version: "1.0.0-internal-alpha.0"
2315
+ version: "1.0.1"
2269
2316
  },
2270
2317
  rules,
2271
2318
  configs: {}
2272
2319
  };
2273
- Object.assign(plugin.configs, {
2274
- // Flat config for ESLint v9+
2275
- "flat/recommended": [
2276
- // HTML/Component config
2277
- {
2278
- files: ["**/*.html", "**/*.cmp"],
2279
- languageOptions: {
2280
- parser: import_parser2.default,
2281
- ecmaVersion: 2021,
2282
- sourceType: "module"
2283
- },
2284
- plugins: {
2285
- "@salesforce-ux/slds": plugin
2286
- },
2287
- rules: eslint_rules_internal_default.html
2320
+ var cssConfigArray = [
2321
+ // CSS config - Standard CSS files
2322
+ {
2323
+ files: ["**/*.{css,scss}"],
2324
+ language: "css/css",
2325
+ ...import_css.default.configs.recommended,
2326
+ languageOptions: {
2327
+ tolerant: true
2328
+ // Allow recoverable parsing errors for SCSS syntax
2288
2329
  },
2289
- // CSS config - Standard CSS files
2290
- {
2291
- files: ["**/*.{css,scss}"],
2292
- language: "css/css",
2293
- ...import_css.default.configs.recommended,
2294
- languageOptions: {
2295
- tolerant: true
2296
- // Allow recoverable parsing errors for SCSS syntax
2297
- },
2298
- plugins: {
2299
- css: import_css.default,
2300
- "@salesforce-ux/slds": plugin
2301
- },
2302
- rules: eslint_rules_internal_default.css
2330
+ plugins: {
2331
+ css: import_css.default,
2332
+ "@salesforce-ux/slds": plugin
2333
+ },
2334
+ rules: eslint_rules_default.css,
2335
+ settings: {
2336
+ // Pass rules configuration to context for runtime access
2337
+ sldsRules: { ...eslint_rules_default.css }
2303
2338
  }
2304
- ],
2339
+ }
2340
+ ];
2341
+ var htmlConfigArray = [
2342
+ // HTML/Component config
2343
+ {
2344
+ files: ["**/*.html", "**/*.cmp"],
2345
+ languageOptions: {
2346
+ parser: import_parser2.default,
2347
+ ecmaVersion: 2021,
2348
+ sourceType: "module"
2349
+ },
2350
+ plugins: {
2351
+ "@salesforce-ux/slds": plugin
2352
+ },
2353
+ rules: eslint_rules_default.html
2354
+ }
2355
+ ];
2356
+ Object.assign(plugin.configs, {
2357
+ // Flat config for ESLint v9+
2358
+ "flat/recommended-css": cssConfigArray,
2359
+ "flat/recommended-html": htmlConfigArray,
2360
+ "flat/recommended": [...cssConfigArray, ...htmlConfigArray],
2305
2361
  // legacy config for ESLint v8-
2306
2362
  recommended: {
2307
2363
  plugins: ["@salesforce-ux/slds"],
2308
- rules: eslint_rules_internal_default.html,
2364
+ rules: eslint_rules_default.html,
2309
2365
  parser: import_parser2.default,
2310
2366
  parserOptions: {
2311
2367
  ecmaVersion: 2021,