@salesforce-ux/eslint-plugin-slds 1.0.7 → 1.0.9-internal
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/build/config/rule-messages.d.ts +2 -0
- package/build/config/rule-messages.js +197 -0
- package/build/config/rule-messages.js.map +7 -0
- package/build/index.js +40 -2332
- package/build/index.js.map +4 -4
- package/build/rules/enforce-bem-usage.js +18 -234
- package/build/rules/enforce-bem-usage.js.map +4 -4
- package/build/rules/modal-close-button-issue.js +11 -183
- package/build/rules/modal-close-button-issue.js.map +4 -4
- package/build/rules/no-deprecated-classes-slds2.js +6 -178
- package/build/rules/no-deprecated-classes-slds2.js.map +4 -4
- package/build/rules/v9/enforce-bem-usage.js +3 -163
- package/build/rules/v9/enforce-bem-usage.js.map +4 -4
- package/build/rules/v9/enforce-component-hook-naming-convention.js +3 -163
- package/build/rules/v9/enforce-component-hook-naming-convention.js.map +4 -4
- package/build/rules/v9/enforce-sds-to-slds-hooks.js +3 -163
- package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +4 -4
- package/build/rules/v9/lwc-token-to-slds-hook.js +6 -264
- package/build/rules/v9/lwc-token-to-slds-hook.js.map +4 -4
- package/build/rules/v9/no-deprecated-slds-classes.js +3 -163
- package/build/rules/v9/no-deprecated-slds-classes.js.map +4 -4
- package/build/rules/v9/no-deprecated-tokens-slds1.js +30 -169
- package/build/rules/v9/no-deprecated-tokens-slds1.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +29 -253
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +31 -289
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +23 -286
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +24 -316
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/handlers/index.js +8 -799
- package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +5 -1090
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +5 -1090
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +31 -882
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +4 -4
- package/build/rules/v9/no-hardcoded-values/ruleOptionsSchema.d.ts +40 -0
- package/build/rules/v9/no-hardcoded-values/ruleOptionsSchema.js +63 -0
- package/build/rules/v9/no-hardcoded-values/ruleOptionsSchema.js.map +7 -0
- package/build/rules/v9/no-slds-class-overrides.js +3 -163
- package/build/rules/v9/no-slds-class-overrides.js.map +4 -4
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +5 -254
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +4 -4
- package/build/rules/v9/no-slds-private-var.js +1 -161
- package/build/rules/v9/no-slds-private-var.js.map +4 -4
- package/build/rules/v9/no-slds-var-without-fallback.js +5 -257
- package/build/rules/v9/no-slds-var-without-fallback.js.map +4 -4
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +3 -163
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +4 -4
- package/build/rules/v9/no-unsupported-hooks-slds2.js +3 -163
- package/build/rules/v9/no-unsupported-hooks-slds2.js.map +4 -4
- package/build/rules/v9/reduce-annotations.js +1 -161
- package/build/rules/v9/reduce-annotations.js.map +4 -4
- package/build/types/index.d.ts +57 -0
- package/build/types/index.js.map +1 -1
- package/build/{src/utils → utils}/boxShadowValueParser.d.ts +1 -1
- package/build/utils/boxShadowValueParser.js +63 -93
- package/build/utils/boxShadowValueParser.js.map +4 -4
- package/build/utils/color-lib-utils.d.ts +25 -0
- package/build/utils/color-lib-utils.js +28 -79
- package/build/utils/color-lib-utils.js.map +3 -3
- package/build/{src/utils → utils}/css-utils.d.ts +7 -0
- package/build/utils/css-utils.js +10 -71
- package/build/utils/css-utils.js.map +4 -4
- package/build/utils/custom-mapping-utils.d.ts +9 -0
- package/build/utils/custom-mapping-utils.js +62 -0
- package/build/utils/custom-mapping-utils.js.map +7 -0
- package/build/{src/utils → utils}/hardcoded-shared-utils.d.ts +1 -0
- package/build/utils/hardcoded-shared-utils.js +46 -98
- package/build/utils/hardcoded-shared-utils.js.map +4 -4
- package/build/{src/utils → utils}/property-matcher.d.ts +3 -1
- package/build/utils/property-matcher.js +22 -8
- package/build/utils/property-matcher.js.map +2 -2
- package/build/utils/styling-hook-utils.js +16 -39
- package/build/utils/styling-hook-utils.js.map +3 -3
- package/build/{src/utils → utils}/value-utils.d.ts +2 -2
- package/build/utils/value-utils.js +8 -8
- package/build/utils/value-utils.js.map +2 -2
- package/package.json +6 -11
- package/build/src/types/index.d.ts +0 -26
- package/build/src/utils/color-lib-utils.d.ts +0 -18
- package/src/config/rule-messages.yml +0 -143
- /package/build/{src/index.d.ts → index.d.ts} +0 -0
- /package/build/{src/rules → rules}/enforce-bem-usage.d.ts +0 -0
- /package/build/{src/rules → rules}/modal-close-button-issue.d.ts +0 -0
- /package/build/{src/rules → rules}/no-deprecated-classes-slds2.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/enforce-bem-usage.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/enforce-component-hook-naming-convention.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/enforce-sds-to-slds-hooks.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/lwc-token-to-slds-hook.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-deprecated-slds-classes.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-deprecated-tokens-slds1.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/boxShadowHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/colorHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/densityHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/fontHandler.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/handlers/index.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/no-hardcoded-values-slds1.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/no-hardcoded-values-slds2.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-class-overrides.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-namespace-for-custom-hooks.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-private-var.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-slds-var-without-fallback.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-sldshook-fallback-for-lwctoken.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/no-unsupported-hooks-slds2.d.ts +0 -0
- /package/build/{src/rules → rules}/v9/reduce-annotations.d.ts +0 -0
- /package/build/{src/utils → utils}/css-functions.d.ts +0 -0
- /package/build/{src/utils → utils}/node.d.ts +0 -0
- /package/build/{src/utils → utils}/rule-utils.d.ts +0 -0
- /package/build/{src/utils → utils}/styling-hook-utils.d.ts +0 -0
|
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
7
|
var __export = (target, all) => {
|
|
11
8
|
for (var name in all)
|
|
12
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,1102 +26,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
26
|
));
|
|
30
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
28
|
|
|
32
|
-
// yaml-file:rule-messages.yml
|
|
33
|
-
var require_rule_messages = __commonJS({
|
|
34
|
-
"yaml-file:rule-messages.yml"(exports2, module2) {
|
|
35
|
-
module2.exports = {
|
|
36
|
-
"no-slds-class-overrides": {
|
|
37
|
-
"description": "Create new custom CSS classes instead of overriding SLDS selectors",
|
|
38
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides",
|
|
39
|
-
"type": "problem",
|
|
40
|
-
"messages": {
|
|
41
|
-
"sldsClassOverride": "Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button."
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"no-deprecated-slds-classes": {
|
|
45
|
-
"description": "Please replace the deprecated classes with a modern equivalent",
|
|
46
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes",
|
|
47
|
-
"type": "problem",
|
|
48
|
-
"messages": {
|
|
49
|
-
"deprecatedClass": "The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class."
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"no-deprecated-tokens-slds1": {
|
|
53
|
-
"description": "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.",
|
|
54
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1",
|
|
55
|
-
"type": "problem",
|
|
56
|
-
"messages": {
|
|
57
|
-
"deprecatedToken": "Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com.",
|
|
58
|
-
"noReplacement": "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com."
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"enforce-sds-to-slds-hooks": {
|
|
62
|
-
"description": "Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info.",
|
|
63
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks",
|
|
64
|
-
"type": "problem",
|
|
65
|
-
"messages": {
|
|
66
|
-
"replaceSdsWithSlds": "Replace {{oldValue}} with {{suggestedMatch}} styling hook."
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"enforce-bem-usage": {
|
|
70
|
-
"description": "Replace BEM double-dash syntax in class names with single underscore syntax",
|
|
71
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage",
|
|
72
|
-
"type": "problem",
|
|
73
|
-
"messages": {
|
|
74
|
-
"bemDoubleDash": "{{actual}} has been retired. Update it to the new name {{newValue}}.",
|
|
75
|
-
"fixBemNaming": "Update to correct BEM naming convention"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"modal-close-button-issue": {
|
|
79
|
-
"description": "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint",
|
|
80
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue",
|
|
81
|
-
"type": "problem",
|
|
82
|
-
"messages": {
|
|
83
|
-
"modalCloseButtonIssue": "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.",
|
|
84
|
-
"removeClass": "Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.",
|
|
85
|
-
"changeVariant": "Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.",
|
|
86
|
-
"removeVariant": "Remove the variant attribute from the <lightning-icon> component inside the <button> element.",
|
|
87
|
-
"ensureButtonClasses": "Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.",
|
|
88
|
-
"ensureSizeAttribute": "To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components."
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"no-deprecated-classes-slds2": {
|
|
92
|
-
"description": "Replace classes that aren't available with SLDS 2 classes",
|
|
93
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2",
|
|
94
|
-
"type": "problem",
|
|
95
|
-
"messages": {
|
|
96
|
-
"deprecatedClass": "The class {{className}} isn't available in SLDS 2. Update it to a class supported in SLDS 2. See lightningdesignsystem.com for more information.",
|
|
97
|
-
"updateToModernClass": "Replace deprecated class with modern equivalent",
|
|
98
|
-
"checkDocumentation": "See lightningdesignsystem.com for SLDS 2 class alternatives"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"lwc-token-to-slds-hook": {
|
|
102
|
-
"description": "Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info.",
|
|
103
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook",
|
|
104
|
-
"type": "problem",
|
|
105
|
-
"messages": {
|
|
106
|
-
"errorWithReplacement": "The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.",
|
|
107
|
-
"errorWithStyleHooks": "The '{{oldValue}}' design token is deprecated. Replace it with the SLDS 2 '{{newValue}}' styling hook and set the fallback to '{{oldValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.",
|
|
108
|
-
"errorWithNoRecommendation": "The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com."
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"no-sldshook-fallback-for-lwctoken": {
|
|
112
|
-
"description": "Avoid using --slds styling hooks as fallback values for --lwc tokens.",
|
|
113
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken",
|
|
114
|
-
"type": "problem",
|
|
115
|
-
"messages": {
|
|
116
|
-
"unsupportedFallback": "Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}."
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
"no-unsupported-hooks-slds2": {
|
|
120
|
-
"description": "Identifies styling hooks that aren't present in SLDS 2. They must be replaced with styling hooks that have a similar effect, or they must be removed.",
|
|
121
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2",
|
|
122
|
-
"type": "problem",
|
|
123
|
-
"messages": {
|
|
124
|
-
"deprecated": "The {{token}} styling hook isn't present in SLDS 2 and there's no equivalent replacement. Remove it or replace it with a styling hook with a similar effect."
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
"no-slds-var-without-fallback": {
|
|
128
|
-
"description": "Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable.",
|
|
129
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback",
|
|
130
|
-
"type": "problem",
|
|
131
|
-
"messages": {
|
|
132
|
-
"varWithoutFallback": "Your code uses the {{cssVar}} styling hook without a fallback value. Styling hooks are unavailable in some Salesforce environments. To render your component correctly in all environments, add this fallback value: var({{cssVar}}, {{recommendation}}). To make this fallback value brand-aware, use a branded design token instead of a static value. See Design Tokens on v1.lightningdesignsystem.com."
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
"no-slds-namespace-for-custom-hooks": {
|
|
136
|
-
"description": "To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace.",
|
|
137
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks",
|
|
138
|
-
"type": "problem",
|
|
139
|
-
"messages": {
|
|
140
|
-
"customHookNamespace": "Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"no-slds-private-var": {
|
|
144
|
-
"description": "Some SLDS styling hooks are private and reserved only for internal Salesforce use. Private SLDS styling hooks have prefixes --_slds- and --slds-s-. For more information, look up private CSS in lightningdesignsystem.com.",
|
|
145
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var",
|
|
146
|
-
"type": "problem",
|
|
147
|
-
"messages": {
|
|
148
|
-
"privateVar": "This styling hook is reserved for internal Salesforce use. Remove the --_slds- or \u2013slds-s private variable within selector {{prop}}. For more information, look up private CSS in lightningdesignsystem.com."
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
"enforce-component-hook-naming-convention": {
|
|
152
|
-
"description": "Replace component styling hooks that use a deprecated naming convention.",
|
|
153
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention",
|
|
154
|
-
"type": "problem",
|
|
155
|
-
"messages": {
|
|
156
|
-
"replace": "Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}."
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
"no-hardcoded-values-slds1": {
|
|
160
|
-
"description": "Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com.",
|
|
161
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value",
|
|
162
|
-
"type": "suggestion",
|
|
163
|
-
"messages": {
|
|
164
|
-
"hardcodedValue": "Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}.",
|
|
165
|
-
"noReplacement": "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
"no-hardcoded-values-slds2": {
|
|
169
|
-
"description": "Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.",
|
|
170
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-values-slds2",
|
|
171
|
-
"type": "suggestion",
|
|
172
|
-
"messages": {
|
|
173
|
-
"hardcodedValue": "Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.",
|
|
174
|
-
"noReplacement": "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
"reduce-annotations": {
|
|
178
|
-
"description": "Remove your annotations and update your code.",
|
|
179
|
-
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations",
|
|
180
|
-
"type": "problem",
|
|
181
|
-
"messages": {
|
|
182
|
-
"removeAnnotation": "Remove this annotation and update the code to SLDS best practices. For help, file an issue at https://github.com/salesforce-ux/slds-linter/"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
29
|
// src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.ts
|
|
190
30
|
var no_hardcoded_values_slds2_exports = {};
|
|
191
31
|
__export(no_hardcoded_values_slds2_exports, {
|
|
192
32
|
default: () => no_hardcoded_values_slds2_default
|
|
193
33
|
});
|
|
194
34
|
module.exports = __toCommonJS(no_hardcoded_values_slds2_exports);
|
|
195
|
-
var
|
|
196
|
-
var import_rule_messages = __toESM(
|
|
197
|
-
|
|
198
|
-
// src/utils/color-lib-utils.ts
|
|
199
|
-
var import_chroma_js = __toESM(require("chroma-js"));
|
|
200
|
-
var import_css_tree = require("@eslint/css-tree");
|
|
201
|
-
|
|
202
|
-
// src/utils/css-functions.ts
|
|
203
|
-
var CSS_FUNCTIONS = [
|
|
204
|
-
"attr",
|
|
205
|
-
"calc",
|
|
206
|
-
"color-mix",
|
|
207
|
-
"conic-gradient",
|
|
208
|
-
"counter",
|
|
209
|
-
"cubic-bezier",
|
|
210
|
-
"linear-gradient",
|
|
211
|
-
"max",
|
|
212
|
-
"min",
|
|
213
|
-
"radial-gradient",
|
|
214
|
-
"repeating-conic-gradient",
|
|
215
|
-
"repeating-linear-gradient",
|
|
216
|
-
"repeating-radial-gradient",
|
|
217
|
-
"var"
|
|
218
|
-
];
|
|
219
|
-
var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
|
|
220
|
-
var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
|
|
221
|
-
var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
|
|
222
|
-
var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
|
|
223
|
-
var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
|
|
224
|
-
function isCssFunction(value) {
|
|
225
|
-
return cssFunctionsExactRegex.test(value);
|
|
226
|
-
}
|
|
227
|
-
function isCssColorFunction(value) {
|
|
228
|
-
return RGB_COLOR_FUNCTIONS.includes(value);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// src/utils/color-lib-utils.ts
|
|
232
|
-
var LAB_THRESHOLD = 25;
|
|
233
|
-
var isHexCode = (color) => {
|
|
234
|
-
const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
|
|
235
|
-
return hexPattern.test(color);
|
|
236
|
-
};
|
|
237
|
-
var convertToHex = (color) => {
|
|
238
|
-
try {
|
|
239
|
-
return (0, import_chroma_js.default)(color).hex();
|
|
240
|
-
} catch (e) {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
var findClosestColorHook = (color, supportedColors, cssProperty) => {
|
|
245
|
-
const returnStylingHooks = [];
|
|
246
|
-
const closestHooksWithSameProperty = [];
|
|
247
|
-
const closestHooksWithoutSameProperty = [];
|
|
248
|
-
const closestHooksWithAllProperty = [];
|
|
249
|
-
const labColor = (0, import_chroma_js.default)(color).lab();
|
|
250
|
-
Object.entries(supportedColors).forEach(([sldsValue, data]) => {
|
|
251
|
-
if (sldsValue && isHexCode(sldsValue)) {
|
|
252
|
-
const hooks = data;
|
|
253
|
-
hooks.forEach((hook) => {
|
|
254
|
-
const labSupportedColor = (0, import_chroma_js.default)(sldsValue).lab();
|
|
255
|
-
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");
|
|
256
|
-
if (hook.properties.includes(cssProperty)) {
|
|
257
|
-
if (distance <= LAB_THRESHOLD) {
|
|
258
|
-
closestHooksWithSameProperty.push({ name: hook.name, distance });
|
|
259
|
-
}
|
|
260
|
-
} else if (hook.properties.includes("*")) {
|
|
261
|
-
if (distance <= LAB_THRESHOLD) {
|
|
262
|
-
closestHooksWithAllProperty.push({ name: hook.name, distance });
|
|
263
|
-
}
|
|
264
|
-
} else {
|
|
265
|
-
if (distance <= LAB_THRESHOLD) {
|
|
266
|
-
closestHooksWithoutSameProperty.push({ name: hook.name, distance });
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
const closesthookGroups = [
|
|
273
|
-
{ hooks: closestHooksWithSameProperty, distance: 0 },
|
|
274
|
-
{ hooks: closestHooksWithAllProperty, distance: 0 },
|
|
275
|
-
{ hooks: closestHooksWithSameProperty, distance: Infinity },
|
|
276
|
-
// For hooks with distance > 0
|
|
277
|
-
{ hooks: closestHooksWithAllProperty, distance: Infinity },
|
|
278
|
-
{ hooks: closestHooksWithoutSameProperty, distance: Infinity }
|
|
279
|
-
];
|
|
280
|
-
for (const group of closesthookGroups) {
|
|
281
|
-
const filteredHooks = group.hooks.filter(
|
|
282
|
-
(h) => group.distance === 0 ? h.distance === 0 : h.distance > 0
|
|
283
|
-
);
|
|
284
|
-
if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {
|
|
285
|
-
filteredHooks.sort((a, b) => a.distance - b.distance);
|
|
286
|
-
returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return Array.from(new Set(returnStylingHooks));
|
|
290
|
-
};
|
|
291
|
-
var isValidColor = (val) => import_chroma_js.default.valid(val);
|
|
292
|
-
var extractColorValue = (node) => {
|
|
293
|
-
let colorValue = null;
|
|
294
|
-
switch (node.type) {
|
|
295
|
-
case "Hash":
|
|
296
|
-
colorValue = `#${node.value}`;
|
|
297
|
-
break;
|
|
298
|
-
case "Identifier":
|
|
299
|
-
colorValue = node.name;
|
|
300
|
-
break;
|
|
301
|
-
case "Function":
|
|
302
|
-
if (isCssColorFunction(node.name)) {
|
|
303
|
-
colorValue = (0, import_css_tree.generate)(node);
|
|
304
|
-
}
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
return colorValue && isValidColor(colorValue) ? colorValue : null;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
// src/utils/property-matcher.ts
|
|
311
|
-
var DIRECTION_VALUES = "(?:top|right|bottom|left|inline|block|inline-start|inline-end|start|end|block-start|block-end)";
|
|
312
|
-
var CORNER_VALUES = "(?:top-left|top-right|bottom-right|bottom-left|start-start|start-end|end-start|end-end)";
|
|
313
|
-
var INSET_VALUES = "(?:inline|block|inline-start|inline-end|block-start|block-end)";
|
|
314
|
-
var BORDER_COLOR_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-color$`);
|
|
315
|
-
var BORDER_WIDTH_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-width$`);
|
|
316
|
-
var MARGIN_REGEX = new RegExp(`^margin(?:-${DIRECTION_VALUES})?$`);
|
|
317
|
-
var PADDING_REGEX = new RegExp(`^padding(?:-${DIRECTION_VALUES})?$`);
|
|
318
|
-
var BORDER_RADIUS_REGEX = new RegExp(`^border(?:-${CORNER_VALUES})?-radius$`);
|
|
319
|
-
var INSET_REGEX = new RegExp(`^inset(?:-${INSET_VALUES})?$`);
|
|
320
|
-
function isBorderColorProperty(cssProperty) {
|
|
321
|
-
return BORDER_COLOR_REGEX.test(cssProperty);
|
|
322
|
-
}
|
|
323
|
-
function isBorderWidthProperty(cssProperty) {
|
|
324
|
-
return BORDER_WIDTH_REGEX.test(cssProperty);
|
|
325
|
-
}
|
|
326
|
-
function isMarginProperty(cssProperty) {
|
|
327
|
-
return MARGIN_REGEX.test(cssProperty);
|
|
328
|
-
}
|
|
329
|
-
function isPaddingProperty(cssProperty) {
|
|
330
|
-
return PADDING_REGEX.test(cssProperty);
|
|
331
|
-
}
|
|
332
|
-
function isBorderRadius(cssProperty) {
|
|
333
|
-
return BORDER_RADIUS_REGEX.test(cssProperty);
|
|
334
|
-
}
|
|
335
|
-
function isDimensionProperty(cssProperty) {
|
|
336
|
-
return ["width", "height", "min-width", "max-width", "min-height", "max-height"].includes(cssProperty);
|
|
337
|
-
}
|
|
338
|
-
function isInsetProperty(cssProperty) {
|
|
339
|
-
return INSET_REGEX.test(cssProperty);
|
|
340
|
-
}
|
|
341
|
-
var fontProperties = [
|
|
342
|
-
"font",
|
|
343
|
-
"font-size",
|
|
344
|
-
"font-weight"
|
|
345
|
-
];
|
|
346
|
-
var colorProperties = [
|
|
347
|
-
"color",
|
|
348
|
-
"fill",
|
|
349
|
-
"background",
|
|
350
|
-
"background-color",
|
|
351
|
-
"stroke",
|
|
352
|
-
"border",
|
|
353
|
-
"border*",
|
|
354
|
-
"border*-color",
|
|
355
|
-
"outline",
|
|
356
|
-
"outline-color"
|
|
357
|
-
];
|
|
358
|
-
var densificationProperties = [
|
|
359
|
-
"border*",
|
|
360
|
-
"margin*",
|
|
361
|
-
"padding*",
|
|
362
|
-
"width",
|
|
363
|
-
"height",
|
|
364
|
-
"min-width",
|
|
365
|
-
"max-width",
|
|
366
|
-
"min-height",
|
|
367
|
-
"max-height",
|
|
368
|
-
"inset",
|
|
369
|
-
"top",
|
|
370
|
-
"right",
|
|
371
|
-
"left",
|
|
372
|
-
"bottom",
|
|
373
|
-
"outline",
|
|
374
|
-
"outline-width",
|
|
375
|
-
"line-height"
|
|
376
|
-
];
|
|
377
|
-
function toSelector(properties) {
|
|
378
|
-
const selectorParts = properties.map((prop) => {
|
|
379
|
-
if (prop.includes("*")) {
|
|
380
|
-
const regexPattern = prop.replace(/\*/g, ".*");
|
|
381
|
-
return `Declaration[property=/^${regexPattern}$/]`;
|
|
382
|
-
} else {
|
|
383
|
-
return `Declaration[property='${prop}']`;
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
return selectorParts.join(", ");
|
|
387
|
-
}
|
|
388
|
-
function resolvePropertyToMatch(cssProperty) {
|
|
389
|
-
const propertyToMatch = cssProperty.toLowerCase();
|
|
390
|
-
if (propertyToMatch === "outline" || propertyToMatch === "outline-width" || isBorderWidthProperty(propertyToMatch)) {
|
|
391
|
-
return "border-width";
|
|
392
|
-
} else if (isMarginProperty(propertyToMatch)) {
|
|
393
|
-
return "margin";
|
|
394
|
-
} else if (isPaddingProperty(propertyToMatch)) {
|
|
395
|
-
return "padding";
|
|
396
|
-
} else if (isBorderRadius(propertyToMatch)) {
|
|
397
|
-
return "border-radius";
|
|
398
|
-
} else if (isDimensionProperty(propertyToMatch)) {
|
|
399
|
-
return "width";
|
|
400
|
-
} else if (isInsetProperty(propertyToMatch)) {
|
|
401
|
-
return "top";
|
|
402
|
-
} else if (cssProperty === "background" || cssProperty === "background-color") {
|
|
403
|
-
return "background-color";
|
|
404
|
-
} else if (cssProperty === "outline" || cssProperty === "outline-color" || isBorderColorProperty(cssProperty)) {
|
|
405
|
-
return "border-color";
|
|
406
|
-
}
|
|
407
|
-
return propertyToMatch;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// src/utils/hardcoded-shared-utils.ts
|
|
411
|
-
var import_css_tree2 = require("@eslint/css-tree");
|
|
412
|
-
|
|
413
|
-
// src/utils/value-utils.ts
|
|
414
|
-
var ALLOWED_UNITS = ["px", "em", "rem", "%", "ch"];
|
|
415
|
-
function parseUnitValue(value) {
|
|
416
|
-
if (!value) return null;
|
|
417
|
-
const unitsPattern = ALLOWED_UNITS.join("|");
|
|
418
|
-
const regex = new RegExp(`^(-?\\d*\\.?\\d+)(${unitsPattern})?$`);
|
|
419
|
-
const match = value.match(regex);
|
|
420
|
-
if (!match) return null;
|
|
421
|
-
const number = parseFloat(match[1]);
|
|
422
|
-
const unit = match[2] ? match[2] : null;
|
|
423
|
-
if (isNaN(number)) return null;
|
|
424
|
-
return { number, unit };
|
|
425
|
-
}
|
|
426
|
-
function toAlternateUnitValue(numberVal, unitType) {
|
|
427
|
-
if (unitType === "px") {
|
|
428
|
-
let floatValue = parseFloat(`${numberVal / 16}`);
|
|
429
|
-
if (!isNaN(floatValue)) {
|
|
430
|
-
return {
|
|
431
|
-
unit: "rem",
|
|
432
|
-
number: parseFloat(floatValue.toFixed(4))
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
} else if (unitType === "rem") {
|
|
436
|
-
const intValue = parseInt(`${numberVal * 16}`);
|
|
437
|
-
if (!isNaN(intValue)) {
|
|
438
|
-
return {
|
|
439
|
-
unit: "px",
|
|
440
|
-
number: intValue
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
return null;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// src/utils/hardcoded-shared-utils.ts
|
|
448
|
-
var FONT_WEIGHTS = [
|
|
449
|
-
"normal",
|
|
450
|
-
"bold",
|
|
451
|
-
"bolder",
|
|
452
|
-
"lighter",
|
|
453
|
-
"100",
|
|
454
|
-
"200",
|
|
455
|
-
"300",
|
|
456
|
-
"400",
|
|
457
|
-
"500",
|
|
458
|
-
"600",
|
|
459
|
-
"700",
|
|
460
|
-
"800",
|
|
461
|
-
"900"
|
|
462
|
-
];
|
|
463
|
-
function isKnownFontWeight(value) {
|
|
464
|
-
const stringValue = value.toString();
|
|
465
|
-
return FONT_WEIGHTS.includes(stringValue.toLowerCase());
|
|
466
|
-
}
|
|
467
|
-
function handleShorthandAutoFix(declarationNode, context, valueText, replacements) {
|
|
468
|
-
const sortedReplacements = replacements.sort((a, b) => a.start - b.start);
|
|
469
|
-
const hasAnyHooks = sortedReplacements.some((r) => r.hasHook);
|
|
470
|
-
const canAutoFix = hasAnyHooks;
|
|
471
|
-
sortedReplacements.forEach(({ start, end, replacement, displayValue, hasHook }) => {
|
|
472
|
-
const originalValue = valueText.substring(start, end);
|
|
473
|
-
const valueStartColumn = declarationNode.value.loc.start.column;
|
|
474
|
-
const valueColumn = valueStartColumn + start;
|
|
475
|
-
const { loc: { start: locStart, end: locEnd } } = declarationNode.value;
|
|
476
|
-
const reportNode = {
|
|
477
|
-
...declarationNode.value,
|
|
478
|
-
loc: {
|
|
479
|
-
...declarationNode.value.loc,
|
|
480
|
-
start: {
|
|
481
|
-
...locStart,
|
|
482
|
-
column: valueColumn
|
|
483
|
-
},
|
|
484
|
-
end: {
|
|
485
|
-
...locEnd,
|
|
486
|
-
column: valueColumn + originalValue.length
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
if (hasHook) {
|
|
491
|
-
const fix = canAutoFix ? (fixer) => {
|
|
492
|
-
let newValue = valueText;
|
|
493
|
-
for (let i = sortedReplacements.length - 1; i >= 0; i--) {
|
|
494
|
-
const { start: rStart, end: rEnd, replacement: rReplacement } = sortedReplacements[i];
|
|
495
|
-
newValue = newValue.substring(0, rStart) + rReplacement + newValue.substring(rEnd);
|
|
496
|
-
}
|
|
497
|
-
return fixer.replaceText(declarationNode.value, newValue);
|
|
498
|
-
} : void 0;
|
|
499
|
-
context.context.report({
|
|
500
|
-
node: reportNode,
|
|
501
|
-
messageId: "hardcodedValue",
|
|
502
|
-
data: {
|
|
503
|
-
oldValue: originalValue,
|
|
504
|
-
newValue: displayValue
|
|
505
|
-
},
|
|
506
|
-
fix
|
|
507
|
-
});
|
|
508
|
-
} else {
|
|
509
|
-
context.context.report({
|
|
510
|
-
node: reportNode,
|
|
511
|
-
messageId: "noReplacement",
|
|
512
|
-
data: {
|
|
513
|
-
oldValue: originalValue
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
function forEachValue(valueText, extractValue, shouldSkipNode, callback) {
|
|
520
|
-
if (!valueText || typeof valueText !== "string") {
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
try {
|
|
524
|
-
const ast = (0, import_css_tree2.parse)(valueText, { context: "value", positions: true });
|
|
525
|
-
(0, import_css_tree2.walk)(ast, {
|
|
526
|
-
enter(node) {
|
|
527
|
-
if (shouldSkipNode(node)) {
|
|
528
|
-
return this.skip;
|
|
529
|
-
}
|
|
530
|
-
const value = extractValue(node);
|
|
531
|
-
if (value !== null) {
|
|
532
|
-
const positionInfo = {
|
|
533
|
-
start: node.loc?.start,
|
|
534
|
-
end: node.loc?.end
|
|
535
|
-
};
|
|
536
|
-
callback(value, positionInfo);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
} catch (error) {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
function shouldSkipColorNode(node) {
|
|
545
|
-
return node.type === "Function" && isCssFunction(node.name);
|
|
546
|
-
}
|
|
547
|
-
function shouldSkipDimensionNode(node) {
|
|
548
|
-
return node.type === "Function";
|
|
549
|
-
}
|
|
550
|
-
function extractDimensionValue(valueNode, cssProperty) {
|
|
551
|
-
if (!valueNode) return null;
|
|
552
|
-
switch (valueNode.type) {
|
|
553
|
-
case "Dimension":
|
|
554
|
-
const numValue = Number(valueNode.value);
|
|
555
|
-
if (numValue === 0) return null;
|
|
556
|
-
const unit = valueNode.unit.toLowerCase();
|
|
557
|
-
if (!ALLOWED_UNITS.includes(unit)) return null;
|
|
558
|
-
return {
|
|
559
|
-
number: numValue,
|
|
560
|
-
unit
|
|
561
|
-
};
|
|
562
|
-
case "Number":
|
|
563
|
-
const numberValue = Number(valueNode.value);
|
|
564
|
-
if (numberValue === 0) return null;
|
|
565
|
-
return {
|
|
566
|
-
number: numberValue,
|
|
567
|
-
unit: null
|
|
568
|
-
};
|
|
569
|
-
case "Percentage":
|
|
570
|
-
const percentValue = Number(valueNode.value);
|
|
571
|
-
if (percentValue === 0) return null;
|
|
572
|
-
return {
|
|
573
|
-
number: percentValue,
|
|
574
|
-
unit: "%"
|
|
575
|
-
};
|
|
576
|
-
case "Value":
|
|
577
|
-
return valueNode.children?.[0] ? extractDimensionValue(valueNode.children[0], cssProperty) : null;
|
|
578
|
-
}
|
|
579
|
-
return null;
|
|
580
|
-
}
|
|
581
|
-
function forEachColorValue(valueText, callback) {
|
|
582
|
-
forEachValue(valueText, extractColorValue, shouldSkipColorNode, callback);
|
|
583
|
-
}
|
|
584
|
-
function forEachDensityValue(valueText, cssProperty, callback) {
|
|
585
|
-
forEachValue(
|
|
586
|
-
valueText,
|
|
587
|
-
(node) => extractDimensionValue(node, cssProperty),
|
|
588
|
-
shouldSkipDimensionNode,
|
|
589
|
-
callback
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
function extractFontValue(node) {
|
|
593
|
-
if (!node) return null;
|
|
594
|
-
switch (node.type) {
|
|
595
|
-
case "Dimension":
|
|
596
|
-
const numValue = Number(node.value);
|
|
597
|
-
if (numValue <= 0) return null;
|
|
598
|
-
const unit = node.unit.toLowerCase();
|
|
599
|
-
if (!ALLOWED_UNITS.includes(unit)) return null;
|
|
600
|
-
return {
|
|
601
|
-
number: numValue,
|
|
602
|
-
unit
|
|
603
|
-
};
|
|
604
|
-
case "Number":
|
|
605
|
-
const numberValue = Number(node.value);
|
|
606
|
-
if (numberValue <= 0) {
|
|
607
|
-
return null;
|
|
608
|
-
}
|
|
609
|
-
if (!isKnownFontWeight(numberValue)) {
|
|
610
|
-
return null;
|
|
611
|
-
}
|
|
612
|
-
return {
|
|
613
|
-
number: numberValue,
|
|
614
|
-
unit: null
|
|
615
|
-
};
|
|
616
|
-
case "Identifier":
|
|
617
|
-
const namedValue = node.name.toLowerCase();
|
|
618
|
-
if (!isKnownFontWeight(namedValue)) {
|
|
619
|
-
return null;
|
|
620
|
-
}
|
|
621
|
-
if (namedValue === "normal") {
|
|
622
|
-
return { number: 400, unit: null };
|
|
623
|
-
}
|
|
624
|
-
return { number: namedValue, unit: null };
|
|
625
|
-
case "Percentage":
|
|
626
|
-
const percentValue = Number(node.value);
|
|
627
|
-
if (percentValue === 0) return null;
|
|
628
|
-
return {
|
|
629
|
-
number: percentValue,
|
|
630
|
-
unit: "%"
|
|
631
|
-
};
|
|
632
|
-
case "Value":
|
|
633
|
-
return node.children?.[0] ? extractFontValue(node.children[0]) : null;
|
|
634
|
-
}
|
|
635
|
-
return null;
|
|
636
|
-
}
|
|
637
|
-
function shouldSkipFontNode(node) {
|
|
638
|
-
return node.type === "Function";
|
|
639
|
-
}
|
|
640
|
-
function forEachFontValue(valueText, callback) {
|
|
641
|
-
forEachValue(valueText, extractFontValue, shouldSkipFontNode, callback);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// src/utils/css-utils.ts
|
|
645
|
-
function formatSuggestionHooks(hooks) {
|
|
646
|
-
if (hooks.length === 1) {
|
|
647
|
-
return `${hooks[0]}`;
|
|
648
|
-
}
|
|
649
|
-
return "\n" + hooks.map((hook, index) => `${index + 1}. ${hook}`).join("\n");
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// src/rules/v9/no-hardcoded-values/handlers/colorHandler.ts
|
|
653
|
-
var handleColorDeclaration = (node, context) => {
|
|
654
|
-
const cssProperty = node.property.toLowerCase();
|
|
655
|
-
const valueText = context.sourceCode.getText(node.value);
|
|
656
|
-
const replacements = [];
|
|
657
|
-
forEachColorValue(valueText, (colorValue, positionInfo) => {
|
|
658
|
-
if (colorValue !== "transparent" && isValidColor(colorValue)) {
|
|
659
|
-
const replacement = createColorReplacement(colorValue, cssProperty, context, positionInfo, valueText);
|
|
660
|
-
if (replacement) {
|
|
661
|
-
replacements.push(replacement);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
handleShorthandAutoFix(node, context, valueText, replacements);
|
|
666
|
-
};
|
|
667
|
-
function createColorReplacement(colorValue, cssProperty, context, positionInfo, originalValueText) {
|
|
668
|
-
if (!positionInfo?.start) {
|
|
669
|
-
return null;
|
|
670
|
-
}
|
|
671
|
-
const hexValue = convertToHex(colorValue);
|
|
672
|
-
if (!hexValue) {
|
|
673
|
-
return null;
|
|
674
|
-
}
|
|
675
|
-
const propToMatch = resolvePropertyToMatch(cssProperty);
|
|
676
|
-
const closestHooks = findClosestColorHook(hexValue, context.valueToStylinghook, propToMatch);
|
|
677
|
-
const start = positionInfo.start.offset;
|
|
678
|
-
const end = positionInfo.end.offset;
|
|
679
|
-
const originalValue = originalValueText ? originalValueText.substring(start, end) : colorValue;
|
|
680
|
-
if (closestHooks.length === 1) {
|
|
681
|
-
return {
|
|
682
|
-
start,
|
|
683
|
-
end,
|
|
684
|
-
replacement: `var(${closestHooks[0]}, ${colorValue})`,
|
|
685
|
-
displayValue: closestHooks[0],
|
|
686
|
-
hasHook: true
|
|
687
|
-
};
|
|
688
|
-
} else if (closestHooks.length > 1) {
|
|
689
|
-
return {
|
|
690
|
-
start,
|
|
691
|
-
end,
|
|
692
|
-
replacement: originalValue,
|
|
693
|
-
// Use original value to preserve spacing
|
|
694
|
-
displayValue: formatSuggestionHooks(closestHooks),
|
|
695
|
-
hasHook: true
|
|
696
|
-
};
|
|
697
|
-
} else {
|
|
698
|
-
return {
|
|
699
|
-
start,
|
|
700
|
-
end,
|
|
701
|
-
replacement: originalValue,
|
|
702
|
-
// Use original value to preserve spacing
|
|
703
|
-
displayValue: originalValue,
|
|
704
|
-
hasHook: false
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// src/utils/styling-hook-utils.ts
|
|
710
|
-
function isValueMatch(valueToMatch, sldsValue) {
|
|
711
|
-
if (!valueToMatch || !sldsValue) {
|
|
712
|
-
return false;
|
|
713
|
-
}
|
|
714
|
-
return valueToMatch.unit == sldsValue.unit && valueToMatch.number === sldsValue.number;
|
|
715
|
-
}
|
|
716
|
-
function getStylingHooksForDensityValue(parsedValue, supportedStylinghooks, cssProperty) {
|
|
717
|
-
if (!parsedValue) return [];
|
|
718
|
-
const alternateValue = toAlternateUnitValue(parsedValue.number, parsedValue.unit);
|
|
719
|
-
const matchedHooks = [];
|
|
720
|
-
for (const [sldsValue, hooks] of Object.entries(supportedStylinghooks)) {
|
|
721
|
-
const parsedSldsValue = parseUnitValue(sldsValue);
|
|
722
|
-
if (isValueMatch(parsedValue, parsedSldsValue) || alternateValue && isValueMatch(alternateValue, parsedSldsValue)) {
|
|
723
|
-
hooks.filter((hook) => hook.properties.includes(cssProperty)).forEach((hook) => matchedHooks.push(hook.name));
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
return matchedHooks;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// src/rules/v9/no-hardcoded-values/handlers/densityHandler.ts
|
|
730
|
-
var handleDensityDeclaration = (node, context) => {
|
|
731
|
-
const cssProperty = node.property.toLowerCase();
|
|
732
|
-
const valueText = context.sourceCode.getText(node.value);
|
|
733
|
-
const replacements = [];
|
|
734
|
-
forEachDensityValue(valueText, cssProperty, (parsedDimension, positionInfo) => {
|
|
735
|
-
if (parsedDimension) {
|
|
736
|
-
const replacement = createDimensionReplacement(parsedDimension, cssProperty, context, positionInfo);
|
|
737
|
-
if (replacement) {
|
|
738
|
-
replacements.push(replacement);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
handleShorthandAutoFix(node, context, valueText, replacements);
|
|
743
|
-
};
|
|
744
|
-
function createDimensionReplacement(parsedDimension, cssProperty, context, positionInfo) {
|
|
745
|
-
if (!parsedDimension || !positionInfo?.start) {
|
|
746
|
-
return null;
|
|
747
|
-
}
|
|
748
|
-
const rawValue = parsedDimension.unit ? `${parsedDimension.number}${parsedDimension.unit}` : parsedDimension.number.toString();
|
|
749
|
-
const propToMatch = resolvePropertyToMatch(cssProperty);
|
|
750
|
-
const closestHooks = getStylingHooksForDensityValue(parsedDimension, context.valueToStylinghook, propToMatch);
|
|
751
|
-
const start = positionInfo.start.offset;
|
|
752
|
-
const end = positionInfo.end.offset;
|
|
753
|
-
if (closestHooks.length === 1) {
|
|
754
|
-
return {
|
|
755
|
-
start,
|
|
756
|
-
end,
|
|
757
|
-
replacement: `var(${closestHooks[0]}, ${rawValue})`,
|
|
758
|
-
displayValue: closestHooks[0],
|
|
759
|
-
hasHook: true
|
|
760
|
-
};
|
|
761
|
-
} else if (closestHooks.length > 1) {
|
|
762
|
-
return {
|
|
763
|
-
start,
|
|
764
|
-
end,
|
|
765
|
-
replacement: rawValue,
|
|
766
|
-
displayValue: formatSuggestionHooks(closestHooks),
|
|
767
|
-
hasHook: true
|
|
768
|
-
};
|
|
769
|
-
} else {
|
|
770
|
-
return {
|
|
771
|
-
start,
|
|
772
|
-
end,
|
|
773
|
-
replacement: rawValue,
|
|
774
|
-
displayValue: rawValue,
|
|
775
|
-
hasHook: false
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
// src/rules/v9/no-hardcoded-values/handlers/fontHandler.ts
|
|
781
|
-
var handleFontDeclaration = (node, context) => {
|
|
782
|
-
const cssProperty = node.property.toLowerCase();
|
|
783
|
-
const valueText = context.sourceCode.getText(node.value);
|
|
784
|
-
const replacements = [];
|
|
785
|
-
forEachFontValue(valueText, (fontValue, positionInfo) => {
|
|
786
|
-
if (fontValue && isValidFontValue(fontValue, cssProperty)) {
|
|
787
|
-
const replacement = createFontReplacement(fontValue, cssProperty, context, positionInfo);
|
|
788
|
-
if (replacement) {
|
|
789
|
-
replacements.push(replacement);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
});
|
|
793
|
-
handleShorthandAutoFix(node, context, valueText, replacements);
|
|
794
|
-
};
|
|
795
|
-
function isValidFontValue(fontValue, cssProperty) {
|
|
796
|
-
if (cssProperty === "font-size") {
|
|
797
|
-
return !!fontValue.unit;
|
|
798
|
-
} else if (cssProperty === "font-weight") {
|
|
799
|
-
return !fontValue.unit && isKnownFontWeight(fontValue.number);
|
|
800
|
-
} else if (cssProperty === "font") {
|
|
801
|
-
if (!fontValue.unit && isKnownFontWeight(fontValue.number)) {
|
|
802
|
-
return true;
|
|
803
|
-
} else if (fontValue.unit) {
|
|
804
|
-
return true;
|
|
805
|
-
} else {
|
|
806
|
-
return false;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
return false;
|
|
810
|
-
}
|
|
811
|
-
function createFontReplacement(fontValue, cssProperty, context, positionInfo) {
|
|
812
|
-
if (!positionInfo?.start) {
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
815
|
-
const rawValue = fontValue.unit ? `${fontValue.number}${fontValue.unit}` : fontValue.number.toString();
|
|
816
|
-
const propToMatch = !fontValue.unit && isKnownFontWeight(fontValue.number) ? resolvePropertyToMatch("font-weight") : resolvePropertyToMatch("font-size");
|
|
817
|
-
const closestHooks = getStylingHooksForDensityValue(fontValue, context.valueToStylinghook, propToMatch);
|
|
818
|
-
const start = positionInfo.start.offset;
|
|
819
|
-
const end = positionInfo.end.offset;
|
|
820
|
-
if (closestHooks.length === 1) {
|
|
821
|
-
return {
|
|
822
|
-
start,
|
|
823
|
-
end,
|
|
824
|
-
replacement: `var(${closestHooks[0]}, ${rawValue})`,
|
|
825
|
-
displayValue: closestHooks[0],
|
|
826
|
-
hasHook: true
|
|
827
|
-
};
|
|
828
|
-
} else if (closestHooks.length > 1) {
|
|
829
|
-
return {
|
|
830
|
-
start,
|
|
831
|
-
end,
|
|
832
|
-
replacement: rawValue,
|
|
833
|
-
displayValue: formatSuggestionHooks(closestHooks),
|
|
834
|
-
hasHook: true
|
|
835
|
-
};
|
|
836
|
-
} else {
|
|
837
|
-
return {
|
|
838
|
-
start,
|
|
839
|
-
end,
|
|
840
|
-
replacement: rawValue,
|
|
841
|
-
displayValue: rawValue,
|
|
842
|
-
hasHook: false
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
// src/utils/boxShadowValueParser.ts
|
|
848
|
-
var import_css_tree3 = require("@eslint/css-tree");
|
|
849
|
-
function isColorValue(node) {
|
|
850
|
-
if (!node) return false;
|
|
851
|
-
switch (node.type) {
|
|
852
|
-
case "Hash":
|
|
853
|
-
return true;
|
|
854
|
-
// #hex colors
|
|
855
|
-
case "Identifier":
|
|
856
|
-
return isValidColor(node.name);
|
|
857
|
-
case "Function":
|
|
858
|
-
return isCssColorFunction(node.name.toLowerCase());
|
|
859
|
-
default:
|
|
860
|
-
return false;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
function isLengthValue(node) {
|
|
864
|
-
if (!node) return false;
|
|
865
|
-
switch (node.type) {
|
|
866
|
-
case "Dimension":
|
|
867
|
-
const dimensionStr = `${node.value}${node.unit}`;
|
|
868
|
-
return parseUnitValue(dimensionStr) !== null;
|
|
869
|
-
case "Number":
|
|
870
|
-
return Number(node.value) === 0;
|
|
871
|
-
default:
|
|
872
|
-
return false;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
function isInsetKeyword(node) {
|
|
876
|
-
return node?.type === "Identifier" && node.name.toLowerCase() === "inset";
|
|
877
|
-
}
|
|
878
|
-
function extractShadowParts(valueText) {
|
|
879
|
-
const shadows = [];
|
|
880
|
-
let currentShadow = {
|
|
881
|
-
lengthParts: [],
|
|
882
|
-
colorParts: [],
|
|
883
|
-
inset: false
|
|
884
|
-
};
|
|
885
|
-
try {
|
|
886
|
-
const ast = (0, import_css_tree3.parse)(valueText, { context: "value" });
|
|
887
|
-
(0, import_css_tree3.walk)(ast, {
|
|
888
|
-
enter(node) {
|
|
889
|
-
if (node.type === "Function") {
|
|
890
|
-
return this.skip;
|
|
891
|
-
}
|
|
892
|
-
if (isInsetKeyword(node)) {
|
|
893
|
-
currentShadow.inset = true;
|
|
894
|
-
} else if (isLengthValue(node)) {
|
|
895
|
-
currentShadow.lengthParts.push((0, import_css_tree3.generate)(node));
|
|
896
|
-
} else if (isColorValue(node)) {
|
|
897
|
-
currentShadow.colorParts.push((0, import_css_tree3.generate)(node));
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
if (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset) {
|
|
902
|
-
shadows.push(currentShadow);
|
|
903
|
-
}
|
|
904
|
-
} catch (error) {
|
|
905
|
-
return [];
|
|
906
|
-
}
|
|
907
|
-
return shadows;
|
|
908
|
-
}
|
|
909
|
-
function parseBoxShadowValue(value) {
|
|
910
|
-
const shadowStrings = value.split(",").map((s) => s.trim());
|
|
911
|
-
const allShadows = [];
|
|
912
|
-
for (const shadowString of shadowStrings) {
|
|
913
|
-
const shadows = extractShadowParts(shadowString);
|
|
914
|
-
const parsedShadows = shadows.map((shadow) => {
|
|
915
|
-
const shadowValue = {};
|
|
916
|
-
const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
|
|
917
|
-
lengthProps.forEach((prop, index) => {
|
|
918
|
-
if (shadow.lengthParts.length > index) {
|
|
919
|
-
shadowValue[prop] = shadow.lengthParts[index];
|
|
920
|
-
}
|
|
921
|
-
});
|
|
922
|
-
if (shadow.colorParts.length > 0) {
|
|
923
|
-
shadowValue.color = shadow.colorParts[0];
|
|
924
|
-
}
|
|
925
|
-
if (shadow.inset) {
|
|
926
|
-
shadowValue.inset = true;
|
|
927
|
-
}
|
|
928
|
-
return shadowValue;
|
|
929
|
-
});
|
|
930
|
-
allShadows.push(...parsedShadows);
|
|
931
|
-
}
|
|
932
|
-
return allShadows;
|
|
933
|
-
}
|
|
934
|
-
function normalizeLengthValue(value) {
|
|
935
|
-
if (!value) return "0px";
|
|
936
|
-
if (value === "0") return "0px";
|
|
937
|
-
return value;
|
|
938
|
-
}
|
|
939
|
-
function isBoxShadowMatch(parsedCssValue, parsedValueHook) {
|
|
940
|
-
if (parsedCssValue.length !== parsedValueHook.length) {
|
|
941
|
-
return false;
|
|
942
|
-
}
|
|
943
|
-
for (let i = 0; i < parsedCssValue.length; i++) {
|
|
944
|
-
const cssShadow = parsedCssValue[i];
|
|
945
|
-
const hookShadow = parsedValueHook[i];
|
|
946
|
-
if (cssShadow.color !== hookShadow.color || cssShadow.inset !== hookShadow.inset) {
|
|
947
|
-
return false;
|
|
948
|
-
}
|
|
949
|
-
const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
|
|
950
|
-
for (const prop of lengthProps) {
|
|
951
|
-
if (normalizeLengthValue(cssShadow[prop]) !== normalizeLengthValue(hookShadow[prop])) {
|
|
952
|
-
return false;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
return true;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
// src/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.ts
|
|
960
|
-
function toBoxShadowValue(cssValue) {
|
|
961
|
-
const parsedCssValue = parseBoxShadowValue(cssValue).filter((shadow) => Object.keys(shadow).length > 0);
|
|
962
|
-
if (parsedCssValue.length === 0) {
|
|
963
|
-
return null;
|
|
964
|
-
}
|
|
965
|
-
return parsedCssValue;
|
|
966
|
-
}
|
|
967
|
-
function shadowValueToHookEntries(supportedStylinghooks) {
|
|
968
|
-
return Object.entries(supportedStylinghooks).filter(([key, value]) => {
|
|
969
|
-
return value.some((hook) => hook.properties.includes("box-shadow"));
|
|
970
|
-
}).map(([key, value]) => {
|
|
971
|
-
return [key, value.map((hook) => hook.name)];
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
var handleBoxShadowDeclaration = (node, context) => {
|
|
975
|
-
const cssProperty = node.property.toLowerCase();
|
|
976
|
-
const valueText = context.sourceCode.getText(node.value);
|
|
977
|
-
const shadowHooks = shadowValueToHookEntries(context.valueToStylinghook);
|
|
978
|
-
const parsedCssValue = toBoxShadowValue(valueText);
|
|
979
|
-
if (!parsedCssValue) {
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
for (const [shadow, closestHooks] of shadowHooks) {
|
|
983
|
-
const parsedValueHook = toBoxShadowValue(shadow);
|
|
984
|
-
if (parsedValueHook && isBoxShadowMatch(parsedCssValue, parsedValueHook)) {
|
|
985
|
-
if (closestHooks.length > 0) {
|
|
986
|
-
const positionInfo = {
|
|
987
|
-
start: { offset: 0, line: 1, column: 1 },
|
|
988
|
-
end: { offset: valueText.length, line: 1, column: valueText.length + 1 }
|
|
989
|
-
};
|
|
990
|
-
const replacement = createBoxShadowReplacement(
|
|
991
|
-
valueText,
|
|
992
|
-
closestHooks,
|
|
993
|
-
context,
|
|
994
|
-
positionInfo
|
|
995
|
-
);
|
|
996
|
-
if (replacement) {
|
|
997
|
-
const replacements = [replacement];
|
|
998
|
-
handleShorthandAutoFix(node, context, valueText, replacements);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
function createBoxShadowReplacement(originalValue, hooks, context, positionInfo) {
|
|
1006
|
-
if (!positionInfo?.start) {
|
|
1007
|
-
return null;
|
|
1008
|
-
}
|
|
1009
|
-
const start = positionInfo.start.offset;
|
|
1010
|
-
const end = positionInfo.end.offset;
|
|
1011
|
-
if (hooks.length === 1) {
|
|
1012
|
-
return {
|
|
1013
|
-
start,
|
|
1014
|
-
end,
|
|
1015
|
-
replacement: `var(${hooks[0]}, ${originalValue})`,
|
|
1016
|
-
displayValue: hooks[0],
|
|
1017
|
-
hasHook: true
|
|
1018
|
-
};
|
|
1019
|
-
} else {
|
|
1020
|
-
return {
|
|
1021
|
-
start,
|
|
1022
|
-
end,
|
|
1023
|
-
replacement: originalValue,
|
|
1024
|
-
displayValue: formatSuggestionHooks(hooks),
|
|
1025
|
-
hasHook: true
|
|
1026
|
-
};
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
// src/utils/rule-utils.ts
|
|
1031
|
-
function isRuleEnabled(context, ruleName2) {
|
|
1032
|
-
try {
|
|
1033
|
-
const rules = context.settings?.sldsRules || {};
|
|
1034
|
-
if (ruleName2 in rules) {
|
|
1035
|
-
const ruleConfig2 = rules[ruleName2];
|
|
1036
|
-
if (Array.isArray(ruleConfig2)) {
|
|
1037
|
-
return ruleConfig2[0] === true;
|
|
1038
|
-
} else if (ruleConfig2 !== void 0 && ruleConfig2 !== null) {
|
|
1039
|
-
return true;
|
|
1040
|
-
} else if (ruleConfig2 === false) {
|
|
1041
|
-
return false;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
} catch (error) {
|
|
1045
|
-
return false;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
// src/rules/v9/no-hardcoded-values/noHardcodedValueRule.ts
|
|
1050
|
-
function defineNoHardcodedValueRule(config) {
|
|
1051
|
-
const { ruleConfig: ruleConfig2, ruleName: ruleName2 } = config;
|
|
1052
|
-
const { type: type2, description: description2, url: url2, messages: messages2 } = ruleConfig2;
|
|
1053
|
-
return {
|
|
1054
|
-
meta: {
|
|
1055
|
-
type: type2,
|
|
1056
|
-
docs: {
|
|
1057
|
-
description: description2,
|
|
1058
|
-
recommended: true,
|
|
1059
|
-
url: url2
|
|
1060
|
-
},
|
|
1061
|
-
fixable: "code",
|
|
1062
|
-
messages: messages2
|
|
1063
|
-
},
|
|
1064
|
-
create(context) {
|
|
1065
|
-
if (ruleName2 === "no-hardcoded-values-slds1" && isRuleEnabled(context, "@salesforce-ux/slds/no-hardcoded-values-slds2")) {
|
|
1066
|
-
return {};
|
|
1067
|
-
}
|
|
1068
|
-
const handlerContext = {
|
|
1069
|
-
valueToStylinghook: config.valueToStylinghook,
|
|
1070
|
-
context,
|
|
1071
|
-
sourceCode: context.sourceCode
|
|
1072
|
-
};
|
|
1073
|
-
const colorOnlySelector = toSelector(colorProperties);
|
|
1074
|
-
const densityOnlySelector = toSelector(densificationProperties);
|
|
1075
|
-
const fontDensitySelector = toSelector(fontProperties);
|
|
1076
|
-
const overlappingProperties = colorProperties.filter((colorProp) => {
|
|
1077
|
-
return densificationProperties.some((densityProp) => {
|
|
1078
|
-
if (densityProp === colorProp) {
|
|
1079
|
-
return true;
|
|
1080
|
-
}
|
|
1081
|
-
if (densityProp.includes("*")) {
|
|
1082
|
-
const regexPattern = new RegExp("^" + densityProp.replace(/\*/g, ".*") + "$");
|
|
1083
|
-
return regexPattern.test(colorProp);
|
|
1084
|
-
}
|
|
1085
|
-
return false;
|
|
1086
|
-
});
|
|
1087
|
-
});
|
|
1088
|
-
const overlappingSet = new Set(overlappingProperties);
|
|
1089
|
-
const colorOnlyProps = colorProperties.filter((prop) => !overlappingSet.has(prop));
|
|
1090
|
-
const densityOnlyProps = densificationProperties.filter((prop) => !overlappingSet.has(prop));
|
|
1091
|
-
const visitors = {};
|
|
1092
|
-
if (colorOnlyProps.length > 0) {
|
|
1093
|
-
const colorOnlySelector2 = toSelector(colorOnlyProps);
|
|
1094
|
-
visitors[colorOnlySelector2] = (node) => {
|
|
1095
|
-
handleColorDeclaration(node, handlerContext);
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
if (densityOnlyProps.length > 0) {
|
|
1099
|
-
const densityOnlySelector2 = toSelector(densityOnlyProps);
|
|
1100
|
-
visitors[densityOnlySelector2] = (node) => {
|
|
1101
|
-
handleDensityDeclaration(node, handlerContext);
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
|
-
visitors[fontDensitySelector] = (node) => {
|
|
1105
|
-
handleFontDeclaration(node, handlerContext);
|
|
1106
|
-
};
|
|
1107
|
-
visitors['Declaration[property="box-shadow"]'] = (node) => {
|
|
1108
|
-
handleBoxShadowDeclaration(node, handlerContext);
|
|
1109
|
-
};
|
|
1110
|
-
if (overlappingProperties.length > 0) {
|
|
1111
|
-
const overlappingSelector = toSelector(overlappingProperties);
|
|
1112
|
-
visitors[overlappingSelector] = (node) => {
|
|
1113
|
-
handleColorDeclaration(node, handlerContext);
|
|
1114
|
-
handleDensityDeclaration(node, handlerContext);
|
|
1115
|
-
};
|
|
1116
|
-
}
|
|
1117
|
-
return visitors;
|
|
1118
|
-
}
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
// src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.ts
|
|
35
|
+
var import_next = __toESM(require("@salesforce-ux/sds-metadata/next"));
|
|
36
|
+
var import_rule_messages = __toESM(require("../../../config/rule-messages"));
|
|
37
|
+
var import_noHardcodedValueRule = require("./noHardcodedValueRule");
|
|
1123
38
|
var ruleName = "no-hardcoded-values-slds2";
|
|
1124
39
|
var ruleConfig = import_rule_messages.default[ruleName];
|
|
1125
40
|
var { type, description, url, messages } = ruleConfig;
|
|
1126
|
-
var valueToStylinghook =
|
|
1127
|
-
var no_hardcoded_values_slds2_default = defineNoHardcodedValueRule({
|
|
41
|
+
var valueToStylinghook = import_next.default.valueToStylingHooksCosmos;
|
|
42
|
+
var no_hardcoded_values_slds2_default = (0, import_noHardcodedValueRule.defineNoHardcodedValueRule)({
|
|
1128
43
|
ruleConfig,
|
|
1129
44
|
valueToStylinghook,
|
|
1130
45
|
ruleName
|