@salesforce-ux/eslint-plugin-slds 1.0.7 → 1.0.8-internal

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +62 -0
  2. package/build/index.js +280 -141
  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 +2 -2
  15. package/build/rules/v9/lwc-token-to-slds-hook.js.map +2 -2
  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 +86 -30
  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 +116 -104
  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 +83 -30
  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 +78 -74
  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 +175 -99
  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 +223 -103
  31. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +3 -3
  32. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +223 -103
  33. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +3 -3
  34. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +221 -101
  35. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +3 -3
  36. package/build/rules/v9/no-hardcoded-values/ruleOptionsSchema.js +63 -0
  37. package/build/rules/v9/no-hardcoded-values/ruleOptionsSchema.js.map +7 -0
  38. package/build/rules/v9/no-slds-class-overrides.js +2 -2
  39. package/build/rules/v9/no-slds-class-overrides.js.map +2 -2
  40. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +2 -2
  41. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +2 -2
  42. package/build/rules/v9/no-slds-var-without-fallback.js +2 -2
  43. package/build/rules/v9/no-slds-var-without-fallback.js.map +2 -2
  44. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +2 -2
  45. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +2 -2
  46. package/build/rules/v9/no-unsupported-hooks-slds2.js +2 -2
  47. package/build/rules/v9/no-unsupported-hooks-slds2.js.map +2 -2
  48. package/build/src/rules/v9/no-hardcoded-values/ruleOptionsSchema.d.ts +40 -0
  49. package/build/src/types/index.d.ts +31 -0
  50. package/build/src/utils/color-lib-utils.d.ts +16 -9
  51. package/build/src/utils/custom-mapping-utils.d.ts +9 -0
  52. package/build/src/utils/hardcoded-shared-utils.d.ts +1 -0
  53. package/build/src/utils/property-matcher.d.ts +3 -1
  54. package/build/types/index.js.map +1 -1
  55. package/build/utils/boxShadowValueParser.js.map +2 -2
  56. package/build/utils/color-lib-utils.js +26 -50
  57. package/build/utils/color-lib-utils.js.map +2 -2
  58. package/build/utils/css-utils.js.map +2 -2
  59. package/build/utils/custom-mapping-utils.js +62 -0
  60. package/build/utils/custom-mapping-utils.js.map +7 -0
  61. package/build/utils/hardcoded-shared-utils.js +29 -16
  62. package/build/utils/hardcoded-shared-utils.js.map +2 -2
  63. package/build/utils/property-matcher.js +20 -6
  64. package/build/utils/property-matcher.js.map +2 -2
  65. package/build/utils/styling-hook-utils.js.map +1 -1
  66. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/styling-hook-utils.ts", "../../src/utils/value-utils.ts"],
4
- "sourcesContent": ["import type { ValueToStylingHookEntry, ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata';\nimport { ParsedUnitValue, parseUnitValue, toAlternateUnitValue } from './value-utils';\n\nfunction isValueMatch(valueToMatch: ParsedUnitValue, sldsValue: ParsedUnitValue): boolean {\n if (!valueToMatch || !sldsValue) {\n return false;\n }\n return valueToMatch.unit == sldsValue.unit && valueToMatch.number === sldsValue.number;\n}\n\n/**\n * Get styling hooks for a density value using structured data from CSS AST\n * Eliminates regex parsing by accepting pre-parsed dimension data\n */\nexport function getStylingHooksForDensityValue(\n parsedValue: ParsedUnitValue,\n supportedStylinghooks: ValueToStylingHooksMapping,\n cssProperty: string\n): string[] {\n if (!parsedValue) return [];\n \n const alternateValue = toAlternateUnitValue(parsedValue.number, parsedValue.unit);\n const matchedHooks = [];\n\n for (const [sldsValue, hooks] of Object.entries(supportedStylinghooks)) {\n // parsing SLDS metadata values\n const parsedSldsValue = parseUnitValue(sldsValue);\n if (isValueMatch(parsedValue, parsedSldsValue) || (alternateValue && isValueMatch(alternateValue, parsedSldsValue))) {\n hooks\n .filter((hook: ValueToStylingHookEntry) => hook.properties.includes(cssProperty))\n .forEach((hook) => matchedHooks.push(hook.name));\n }\n }\n return matchedHooks;\n}", "// Simplified value parsing\n\n/**\n * Checks if a value is a CSS global value.\n *\n * CSS global values are special keywords that can be used for any CSS property and have a universal meaning:\n * - initial: Resets the property to its initial value as defined by the CSS specification.\n * - inherit: Inherits the value from the parent element.\n * - unset: Acts as inherit if the property is inheritable, otherwise acts as initial.\n * - revert: Rolls back the property to the value established by the user-agent or user styles.\n * - revert-layer: Rolls back the property to the value established by the previous cascade layer.\n *\n * All CSS properties accept these global values, including but not limited to:\n * - color\n * - background\n * - font-size\n * - margin\n * - padding\n * - border\n * - display\n * - position\n * - z-index\n * - and many more\n *\n * These values are part of the CSS standard and are not considered violations, even if a rule would otherwise flag a value as invalid or non-design-token. They are always allowed for any property.\n *\n * @param value The CSS value to check.\n * @returns True if the value is a CSS global value, false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/unset\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert-layer\n */\nexport function isGlobalValue(value: string): boolean {\n return value === 'initial' || value === 'inherit' || value === 'unset' || value === 'revert' || value === 'revert-layer';\n }\n\n// Configurable list of allowed CSS units\nexport const ALLOWED_UNITS = ['px', 'em', 'rem', '%', 'ch'];\n\nexport type ParsedUnitValue = {\n unit: 'px' | 'rem' | '%' | 'em' | 'ch' | null;\n number: number;\n} | null;\n\nexport function parseUnitValue(value: string): ParsedUnitValue {\n if (!value) return null;\n \n // Create regex pattern from allowed units\n const unitsPattern = ALLOWED_UNITS.join('|');\n const regex = new RegExp(`^(-?\\\\d*\\\\.?\\\\d+)(${unitsPattern})?$`);\n const match = value.match(regex);\n if (!match) return null;\n \n const number = parseFloat(match[1]);\n const unit = match[2] ? (match[2] as 'px' | 'rem' | '%' | 'em' | 'ch') : null; // Keep unitless values as null\n \n if (isNaN(number)) return null;\n \n return { number, unit };\n}\n\nexport function toAlternateUnitValue(numberVal: number, unitType: 'px' | 'rem' | '%' | 'em' | 'ch' | null): ParsedUnitValue {\n if (unitType === 'px') {\n let floatValue = parseFloat(`${numberVal / 16}`);\n if (!isNaN(floatValue)) {\n return {\n unit: 'rem',\n number: parseFloat(floatValue.toFixed(4))\n }\n }\n } else if (unitType === 'rem') {\n const intValue = parseInt(`${numberVal * 16}`);\n if (!isNaN(intValue)) {\n return {\n unit: 'px',\n number: intValue\n }\n }\n }\n // For other units (%, em, ch) and unitless values, no alternate unit conversion available\n // These units are context-dependent and don't have standard conversion ratios\n return null;\n}"],
4
+ "sourcesContent": ["import type { ValueToStylingHookEntry, ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata/next';\nimport { ParsedUnitValue, parseUnitValue, toAlternateUnitValue } from './value-utils';\n\nfunction isValueMatch(valueToMatch: ParsedUnitValue, sldsValue: ParsedUnitValue): boolean {\n if (!valueToMatch || !sldsValue) {\n return false;\n }\n return valueToMatch.unit == sldsValue.unit && valueToMatch.number === sldsValue.number;\n}\n\n/**\n * Get styling hooks for a density value using structured data from CSS AST\n * Eliminates regex parsing by accepting pre-parsed dimension data\n */\nexport function getStylingHooksForDensityValue(\n parsedValue: ParsedUnitValue,\n supportedStylinghooks: ValueToStylingHooksMapping,\n cssProperty: string\n): string[] {\n if (!parsedValue) return [];\n \n const alternateValue = toAlternateUnitValue(parsedValue.number, parsedValue.unit);\n const matchedHooks = [];\n\n for (const [sldsValue, hooks] of Object.entries(supportedStylinghooks)) {\n // parsing SLDS metadata values\n const parsedSldsValue = parseUnitValue(sldsValue);\n if (isValueMatch(parsedValue, parsedSldsValue) || (alternateValue && isValueMatch(alternateValue, parsedSldsValue))) {\n hooks\n .filter((hook: ValueToStylingHookEntry) => hook.properties.includes(cssProperty))\n .forEach((hook) => matchedHooks.push(hook.name));\n }\n }\n return matchedHooks;\n}", "// Simplified value parsing\n\n/**\n * Checks if a value is a CSS global value.\n *\n * CSS global values are special keywords that can be used for any CSS property and have a universal meaning:\n * - initial: Resets the property to its initial value as defined by the CSS specification.\n * - inherit: Inherits the value from the parent element.\n * - unset: Acts as inherit if the property is inheritable, otherwise acts as initial.\n * - revert: Rolls back the property to the value established by the user-agent or user styles.\n * - revert-layer: Rolls back the property to the value established by the previous cascade layer.\n *\n * All CSS properties accept these global values, including but not limited to:\n * - color\n * - background\n * - font-size\n * - margin\n * - padding\n * - border\n * - display\n * - position\n * - z-index\n * - and many more\n *\n * These values are part of the CSS standard and are not considered violations, even if a rule would otherwise flag a value as invalid or non-design-token. They are always allowed for any property.\n *\n * @param value The CSS value to check.\n * @returns True if the value is a CSS global value, false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/unset\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert-layer\n */\nexport function isGlobalValue(value: string): boolean {\n return value === 'initial' || value === 'inherit' || value === 'unset' || value === 'revert' || value === 'revert-layer';\n }\n\n// Configurable list of allowed CSS units\nexport const ALLOWED_UNITS = ['px', 'em', 'rem', '%', 'ch'];\n\nexport type ParsedUnitValue = {\n unit: 'px' | 'rem' | '%' | 'em' | 'ch' | null;\n number: number;\n} | null;\n\nexport function parseUnitValue(value: string): ParsedUnitValue {\n if (!value) return null;\n \n // Create regex pattern from allowed units\n const unitsPattern = ALLOWED_UNITS.join('|');\n const regex = new RegExp(`^(-?\\\\d*\\\\.?\\\\d+)(${unitsPattern})?$`);\n const match = value.match(regex);\n if (!match) return null;\n \n const number = parseFloat(match[1]);\n const unit = match[2] ? (match[2] as 'px' | 'rem' | '%' | 'em' | 'ch') : null; // Keep unitless values as null\n \n if (isNaN(number)) return null;\n \n return { number, unit };\n}\n\nexport function toAlternateUnitValue(numberVal: number, unitType: 'px' | 'rem' | '%' | 'em' | 'ch' | null): ParsedUnitValue {\n if (unitType === 'px') {\n let floatValue = parseFloat(`${numberVal / 16}`);\n if (!isNaN(floatValue)) {\n return {\n unit: 'rem',\n number: parseFloat(floatValue.toFixed(4))\n }\n }\n } else if (unitType === 'rem') {\n const intValue = parseInt(`${numberVal * 16}`);\n if (!isNaN(intValue)) {\n return {\n unit: 'px',\n number: intValue\n }\n }\n }\n // For other units (%, em, ch) and unitless values, no alternate unit conversion available\n // These units are context-dependent and don't have standard conversion ratios\n return null;\n}"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwCO,IAAM,gBAAgB,CAAC,MAAM,MAAM,OAAO,KAAK,IAAI;AAOnD,SAAS,eAAe,OAAgC;AAC7D,MAAI,CAAC,MAAO,QAAO;AAGnB,QAAM,eAAe,cAAc,KAAK,GAAG;AAC3C,QAAM,QAAQ,IAAI,OAAO,qBAAqB,YAAY,KAAK;AAC/D,QAAM,QAAQ,MAAM,MAAM,KAAK;AAC/B,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,SAAS,WAAW,MAAM,CAAC,CAAC;AAClC,QAAM,OAAO,MAAM,CAAC,IAAK,MAAM,CAAC,IAAyC;AAEzE,MAAI,MAAM,MAAM,EAAG,QAAO;AAE1B,SAAO,EAAE,QAAQ,KAAK;AACxB;AAEO,SAAS,qBAAqB,WAAmB,UAAoE;AACxH,MAAI,aAAa,MAAM;AACrB,QAAI,aAAa,WAAW,GAAG,YAAY,EAAE,EAAE;AAC/C,QAAI,CAAC,MAAM,UAAU,GAAG;AACtB,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ,WAAW,WAAW,QAAQ,CAAC,CAAC;AAAA,MAC1C;AAAA,IACF;AAAA,EACF,WAAW,aAAa,OAAO;AAC7B,UAAM,WAAW,SAAS,GAAG,YAAY,EAAE,EAAE;AAC7C,QAAI,CAAC,MAAM,QAAQ,GAAG;AACpB,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAGA,SAAO;AACX;;;ADlFA,SAAS,aAAa,cAA+B,WAAqC;AACxF,MAAI,CAAC,gBAAgB,CAAC,WAAW;AAC/B,WAAO;AAAA,EACT;AACA,SAAO,aAAa,QAAQ,UAAU,QAAQ,aAAa,WAAW,UAAU;AAClF;AAMO,SAAS,+BACd,aACA,uBACA,aACU;AACV,MAAI,CAAC,YAAa,QAAO,CAAC;AAE1B,QAAM,iBAAiB,qBAAqB,YAAY,QAAQ,YAAY,IAAI;AAChF,QAAM,eAAe,CAAC;AAEtB,aAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,qBAAqB,GAAG;AAEtE,UAAM,kBAAkB,eAAe,SAAS;AAChD,QAAI,aAAa,aAAa,eAAe,KAAM,kBAAkB,aAAa,gBAAgB,eAAe,GAAI;AACnH,YACG,OAAO,CAAC,SAAkC,KAAK,WAAW,SAAS,WAAW,CAAC,EAC/E,QAAQ,CAAC,SAAS,aAAa,KAAK,KAAK,IAAI,CAAC;AAAA,IACnD;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/eslint-plugin-slds",
3
- "version": "1.0.7",
3
+ "version": "1.0.8-internal",
4
4
  "main": "build/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -38,7 +38,7 @@
38
38
  "@eslint/css-tree": "^3.6.5",
39
39
  "@html-eslint/eslint-plugin": "^0.34.0",
40
40
  "@html-eslint/parser": "^0.34.0",
41
- "@salesforce-ux/sds-metadata": "^1.1.0",
41
+ "@salesforce-ux/sds-metadata": "^1.2.1",
42
42
  "chroma-js": "^3.1.2"
43
43
  },
44
44
  "peerDependencies": {