@salesforce-ux/eslint-plugin-slds 0.5.2 → 1.0.0-internal-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +2309 -50
- package/build/index.js.map +4 -4
- package/build/rules/enforce-bem-usage.js +325 -85
- package/build/rules/enforce-bem-usage.js.map +4 -4
- package/build/rules/modal-close-button-issue.js +324 -179
- package/build/rules/modal-close-button-issue.js.map +4 -4
- package/build/rules/no-deprecated-classes-slds2.js +247 -53
- package/build/rules/no-deprecated-classes-slds2.js.map +4 -4
- package/build/rules/v9/enforce-bem-usage.js +236 -0
- package/build/rules/v9/enforce-bem-usage.js.map +7 -0
- package/build/rules/v9/enforce-component-hook-naming-convention.js +262 -0
- package/build/rules/v9/enforce-component-hook-naming-convention.js.map +7 -0
- package/build/rules/v9/enforce-sds-to-slds-hooks.js +260 -0
- package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +7 -0
- package/build/rules/v9/lwc-token-to-slds-hook.js +330 -0
- package/build/rules/v9/lwc-token-to-slds-hook.js.map +7 -0
- package/build/rules/v9/no-deprecated-slds-classes.js +227 -0
- package/build/rules/v9/no-deprecated-slds-classes.js.map +7 -0
- package/build/rules/v9/no-deprecated-tokens-slds1.js +270 -0
- package/build/rules/v9/no-deprecated-tokens-slds1.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +339 -0
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +348 -0
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +344 -0
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +388 -0
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/index.js +834 -0
- package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +1112 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +1112 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +945 -0
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +7 -0
- package/build/rules/v9/no-slds-class-overrides.js +233 -0
- package/build/rules/v9/no-slds-class-overrides.js.map +7 -0
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +250 -0
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +7 -0
- package/build/rules/v9/no-slds-private-var.js +230 -0
- package/build/rules/v9/no-slds-private-var.js.map +7 -0
- package/build/rules/v9/no-slds-var-without-fallback.js +253 -0
- package/build/rules/v9/no-slds-var-without-fallback.js.map +7 -0
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +253 -0
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +7 -0
- package/build/rules/v9/no-unsupported-hooks-slds2.js +243 -0
- package/build/rules/v9/no-unsupported-hooks-slds2.js.map +7 -0
- package/build/rules/v9/reduce-annotations.js +234 -0
- package/build/rules/v9/reduce-annotations.js.map +7 -0
- package/build/src/rules/enforce-bem-usage.d.ts +17 -0
- package/build/{rules → src/rules}/modal-close-button-issue.d.ts +2 -1
- package/build/{rules → src/rules}/no-deprecated-classes-slds2.d.ts +2 -1
- package/build/src/rules/v9/enforce-bem-usage.d.ts +3 -0
- package/build/src/rules/v9/enforce-component-hook-naming-convention.d.ts +3 -0
- package/build/src/rules/v9/enforce-sds-to-slds-hooks.d.ts +3 -0
- package/build/src/rules/v9/lwc-token-to-slds-hook.d.ts +3 -0
- package/build/src/rules/v9/no-deprecated-slds-classes.d.ts +3 -0
- package/build/src/rules/v9/no-deprecated-tokens-slds1.d.ts +3 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.d.ts +5 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/colorHandler.d.ts +7 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/densityHandler.d.ts +7 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/fontHandler.d.ts +6 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/index.d.ts +8 -0
- package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.d.ts +3 -0
- package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.d.ts +3 -0
- package/build/src/rules/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +9 -0
- package/build/src/rules/v9/no-slds-class-overrides.d.ts +8 -0
- package/build/src/rules/v9/no-slds-namespace-for-custom-hooks.d.ts +3 -0
- package/build/src/rules/v9/no-slds-private-var.d.ts +3 -0
- package/build/src/rules/v9/no-slds-var-without-fallback.d.ts +3 -0
- package/build/src/rules/v9/no-sldshook-fallback-for-lwctoken.d.ts +3 -0
- package/build/src/rules/v9/no-unsupported-hooks-slds2.d.ts +3 -0
- package/build/src/rules/v9/reduce-annotations.d.ts +3 -0
- package/build/src/types/index.d.ts +26 -0
- package/build/src/utils/boxShadowValueParser.d.ts +17 -0
- package/build/src/utils/color-lib-utils.d.ts +18 -0
- package/build/src/utils/css-functions.d.ts +7 -0
- package/build/src/utils/css-utils.d.ts +7 -0
- package/build/src/utils/hardcoded-shared-utils.d.ts +60 -0
- package/build/src/utils/property-matcher.d.ts +23 -0
- package/build/src/utils/styling-hook-utils.d.ts +7 -0
- package/build/src/utils/value-utils.d.ts +40 -0
- package/build/types/index.js +18 -0
- package/build/types/index.js.map +7 -0
- package/build/types/yaml.d.js +1 -0
- package/build/types/yaml.d.js.map +7 -0
- package/build/utils/boxShadowValueParser.js +197 -0
- package/build/utils/boxShadowValueParser.js.map +7 -0
- package/build/utils/color-lib-utils.js +160 -0
- package/build/utils/color-lib-utils.js.map +7 -0
- package/build/utils/css-functions.js +68 -0
- package/build/utils/css-functions.js.map +7 -0
- package/build/utils/css-utils.js +33 -0
- package/build/utils/css-utils.js.map +7 -0
- package/build/utils/hardcoded-shared-utils.js +300 -0
- package/build/utils/hardcoded-shared-utils.js.map +7 -0
- package/build/utils/node.js +158 -0
- package/build/{rules/utils → utils}/node.js.map +2 -2
- package/build/utils/property-matcher.js +159 -0
- package/build/utils/property-matcher.js.map +7 -0
- package/build/utils/styling-hook-utils.js +80 -0
- package/build/utils/styling-hook-utils.js.map +7 -0
- package/build/utils/value-utils.js +65 -0
- package/build/utils/value-utils.js.map +7 -0
- package/package.json +9 -4
- package/src/config/rule-messages.yml +143 -0
- package/build/rules/enforce-bem-usage.d.ts +0 -28
- package/build/rules/utils/node.js +0 -197
- package/build/rules/utils/rule.d.ts +0 -7
- package/build/rules/utils/rule.js +0 -10
- package/build/rules/utils/rule.js.map +0 -7
- /package/build/{index.d.ts → src/index.d.ts} +0 -0
- /package/build/{rules → src}/utils/node.d.ts +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/node.ts
|
|
20
|
+
var node_exports = {};
|
|
21
|
+
__export(node_exports, {
|
|
22
|
+
codeToLines: () => codeToLines,
|
|
23
|
+
findAttr: () => findAttr,
|
|
24
|
+
getLocBetween: () => getLocBetween,
|
|
25
|
+
getTemplateTokens: () => getTemplateTokens,
|
|
26
|
+
isAttributesEmpty: () => isAttributesEmpty,
|
|
27
|
+
isComment: () => isComment,
|
|
28
|
+
isExpressionInTemplate: () => isExpressionInTemplate,
|
|
29
|
+
isNodeTokensOnSameLine: () => isNodeTokensOnSameLine,
|
|
30
|
+
isOverlapWithTemplates: () => isOverlapWithTemplates,
|
|
31
|
+
isRangesOverlap: () => isRangesOverlap,
|
|
32
|
+
isTag: () => isTag,
|
|
33
|
+
isText: () => isText,
|
|
34
|
+
splitToLineNodes: () => splitToLineNodes
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(node_exports);
|
|
37
|
+
var import_parser = require("@html-eslint/parser");
|
|
38
|
+
function findAttr(node, key) {
|
|
39
|
+
return node.attributes.find(
|
|
40
|
+
(attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function isAttributesEmpty(node) {
|
|
44
|
+
return !node.attributes || node.attributes.length <= 0;
|
|
45
|
+
}
|
|
46
|
+
function isNodeTokensOnSameLine(node) {
|
|
47
|
+
return node.loc.start.line === node.loc.end.line;
|
|
48
|
+
}
|
|
49
|
+
function isRangesOverlap(rangeA, rangeB) {
|
|
50
|
+
return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];
|
|
51
|
+
}
|
|
52
|
+
function isOverlapWithTemplates(templates, range) {
|
|
53
|
+
return templates.filter((template) => template.isTemplate).some((template) => isRangesOverlap(template.range, range));
|
|
54
|
+
}
|
|
55
|
+
function splitToLineNodes(node) {
|
|
56
|
+
let start = node.range[0];
|
|
57
|
+
let line = node.loc.start.line;
|
|
58
|
+
const startCol = node.loc.start.column;
|
|
59
|
+
const lineNodes = [];
|
|
60
|
+
const templates = node.templates || [];
|
|
61
|
+
function shouldSkipIndentCheck(range) {
|
|
62
|
+
const overlappedTemplates = templates.filter(
|
|
63
|
+
(template) => template.isTemplate && isRangesOverlap(template.range, range)
|
|
64
|
+
);
|
|
65
|
+
const isLineInTemplate = overlappedTemplates.some((template) => {
|
|
66
|
+
return template.range[0] <= range[0] && template.range[1] >= range[1];
|
|
67
|
+
});
|
|
68
|
+
if (isLineInTemplate) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
const isLineBeforeTemplate = overlappedTemplates.some((template) => {
|
|
72
|
+
return template.range[0] <= range[0] && template.range[1] <= range[1];
|
|
73
|
+
});
|
|
74
|
+
if (isLineBeforeTemplate) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const isLineAfterTemplate = overlappedTemplates.some((template) => {
|
|
78
|
+
return template.range[1] <= range[0];
|
|
79
|
+
});
|
|
80
|
+
if (isLineAfterTemplate) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
node.value.split("\n").forEach((value, index) => {
|
|
86
|
+
const columnStart = index === 0 ? startCol : 0;
|
|
87
|
+
const range = [start, start + value.length];
|
|
88
|
+
const loc = {
|
|
89
|
+
start: {
|
|
90
|
+
line,
|
|
91
|
+
column: columnStart
|
|
92
|
+
},
|
|
93
|
+
end: {
|
|
94
|
+
line,
|
|
95
|
+
column: columnStart + value.length
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const lineNode = {
|
|
99
|
+
type: "Line",
|
|
100
|
+
value,
|
|
101
|
+
range,
|
|
102
|
+
loc,
|
|
103
|
+
skipIndentCheck: shouldSkipIndentCheck(range)
|
|
104
|
+
};
|
|
105
|
+
start += value.length + 1;
|
|
106
|
+
line += 1;
|
|
107
|
+
lineNodes.push(lineNode);
|
|
108
|
+
});
|
|
109
|
+
return lineNodes;
|
|
110
|
+
}
|
|
111
|
+
function getLocBetween(before, after) {
|
|
112
|
+
return {
|
|
113
|
+
start: before.loc.end,
|
|
114
|
+
end: after.loc.start
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function isExpressionInTemplate(node) {
|
|
118
|
+
if (node.type === import_parser.NODE_TYPES.AttributeValue) {
|
|
119
|
+
return node.value.indexOf("${") === 0;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function isTag(node) {
|
|
124
|
+
return node.type === import_parser.NODE_TYPES.Tag;
|
|
125
|
+
}
|
|
126
|
+
function isComment(node) {
|
|
127
|
+
return node.type === import_parser.NODE_TYPES.Comment;
|
|
128
|
+
}
|
|
129
|
+
function isText(node) {
|
|
130
|
+
return node.type === import_parser.NODE_TYPES.Text;
|
|
131
|
+
}
|
|
132
|
+
var lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
|
|
133
|
+
var lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
|
|
134
|
+
function codeToLines(source) {
|
|
135
|
+
return source.split(lineEndingPattern);
|
|
136
|
+
}
|
|
137
|
+
function getTemplateTokens(tokens) {
|
|
138
|
+
return [].concat(
|
|
139
|
+
...tokens.map((token) => token["templates"] || [])
|
|
140
|
+
).filter((token) => token.isTemplate);
|
|
141
|
+
}
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
codeToLines,
|
|
145
|
+
findAttr,
|
|
146
|
+
getLocBetween,
|
|
147
|
+
getTemplateTokens,
|
|
148
|
+
isAttributesEmpty,
|
|
149
|
+
isComment,
|
|
150
|
+
isExpressionInTemplate,
|
|
151
|
+
isNodeTokensOnSameLine,
|
|
152
|
+
isOverlapWithTemplates,
|
|
153
|
+
isRangesOverlap,
|
|
154
|
+
isTag,
|
|
155
|
+
isText,
|
|
156
|
+
splitToLineNodes
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
4
|
-
"sourcesContent": ["// THIS IS TAKEN FROM html-eslint\n\nimport { NODE_TYPES } from \"@html-eslint/parser\";\n\n\n/**\n * @param {TagNode | ScriptTagNode | StyleTagNode} node\n * @param {string} key\n * @returns {AttributeNode | undefined}\n */\nfunction findAttr(node, key) {\n return node.attributes.find(\n (attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase()\n );\n}\n\n/**\n * Checks whether a node's attributes is empty or not.\n * @param {TagNode | ScriptTagNode | StyleTagNode} node\n * @returns {boolean}\n */\nfunction isAttributesEmpty(node) {\n return !node.attributes || node.attributes.length <= 0;\n}\n\n/**\n * Checks whether a node's all tokens are on the same line or not.\n * @param {AnyNode} node A node to check\n * @returns {boolean} `true` if a node's tokens are on the same line, otherwise `false`.\n */\nfunction isNodeTokensOnSameLine(node) {\n return node.loc.start.line === node.loc.end.line;\n}\n\n/**\n *\n * @param {Range} rangeA\n * @param {Range} rangeB\n * @returns {boolean}\n */\nfunction isRangesOverlap(rangeA, rangeB) {\n return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];\n}\n\n/**\n * @param {(TextNode | CommentContentNode)['templates']} templates\n * @param {Range} range\n * @returns {boolean}\n */\nfunction isOverlapWithTemplates(templates, range) {\n return templates\n .filter((template) => template.isTemplate)\n .some((template) => isRangesOverlap(template.range, range));\n}\n\n/**\n *\n * @param {TextNode | CommentContentNode} node\n * @returns {LineNode[]}\n */\nfunction splitToLineNodes(node) {\n let start = node.range[0];\n let line = node.loc.start.line;\n const startCol = node.loc.start.column;\n /**\n * @type {LineNode[]}\n */\n const lineNodes = [];\n const templates = node.templates || [];\n /**\n *\n * @param {import(\"../../types\").Range} range\n */\n function shouldSkipIndentCheck(range) {\n const overlappedTemplates = templates.filter(\n (template) =>\n template.isTemplate && isRangesOverlap(template.range, range)\n );\n\n const isLineInTemplate = overlappedTemplates.some((template) => {\n return template.range[0] <= range[0] && template.range[1] >= range[1];\n });\n if (isLineInTemplate) {\n return true;\n }\n const isLineBeforeTemplate = overlappedTemplates.some((template) => {\n return template.range[0] <= range[0] && template.range[1] <= range[1];\n });\n if (isLineBeforeTemplate) {\n return true;\n }\n const isLineAfterTemplate = overlappedTemplates.some((template) => {\n return template.range[1] <= range[0];\n });\n if (isLineAfterTemplate) {\n return true;\n }\n return false;\n }\n\n node.value.split(\"\\n\").forEach((value, index) => {\n const columnStart = index === 0 ? startCol : 0;\n /**\n * @type {import(\"../../types\").Range}\n */\n const range = [start, start + value.length];\n const loc = {\n start: {\n line,\n column: columnStart,\n },\n end: {\n line,\n column: columnStart + value.length,\n },\n };\n /**\n * @type {LineNode}\n */\n const lineNode = {\n type: \"Line\",\n value,\n range,\n loc,\n skipIndentCheck: shouldSkipIndentCheck(range),\n };\n\n start += value.length + 1;\n line += 1;\n\n lineNodes.push(lineNode);\n });\n\n return lineNodes;\n}\n\n/**\n * Get location between two nodes.\n * @param {BaseNode} before A node placed in before\n * @param {BaseNode} after A node placed in after\n * @returns {Location} location between two nodes.\n */\nfunction getLocBetween(before, after) {\n return {\n start: before.loc.end,\n end: after.loc.start,\n };\n}\n\n/**\n * @param {AttributeValueNode} node\n * @return {boolean}\n */\nfunction isExpressionInTemplate(node) {\n if (node.type === NODE_TYPES.AttributeValue) {\n return node.value.indexOf(\"${\") === 0;\n }\n return false;\n}\n\n/**\n * @param {AnyNode} node\n * @returns {node is TagNode}\n */\nfunction isTag(node) {\n return node.type === NODE_TYPES.Tag;\n}\n\n/**\n * @param {AnyNode} node\n * @returns {node is CommentNode}\n */\nfunction isComment(node) {\n return node.type === NODE_TYPES.Comment;\n}\n\n/**\n * @param {AnyNode} node\n * @returns {node is TextNode}\n */\nfunction isText(node) {\n return node.type === NODE_TYPES.Text;\n}\n\nconst lineBreakPattern = /\\r\\n|[\\r\\n\\u2028\\u2029]/u;\nconst lineEndingPattern = new RegExp(lineBreakPattern.source, \"gu\");\n/**\n * @param {string} source\n * @returns {string[]}\n */\nfunction codeToLines(source) {\n return source.split(lineEndingPattern);\n}\n\n/**\n *\n * @param {AnyToken[]} tokens\n * @returns {((CommentContentNode | TextNode)['templates'][number])[]}\n */\nfunction getTemplateTokens(tokens) {\n return (\n []\n .concat(\n ...tokens\n // @ts-ignore\n .map((token) => token[\"templates\"] || [])\n )\n // @ts-ignore\n .filter((token) => token.isTemplate)\n );\n}\n\nexport {\n findAttr,\n isAttributesEmpty,\n isNodeTokensOnSameLine,\n splitToLineNodes,\n getLocBetween,\n isExpressionInTemplate,\n isTag,\n isComment,\n isText,\n isOverlapWithTemplates,\n codeToLines,\n isRangesOverlap,\n getTemplateTokens,\n}
|
|
3
|
+
"sources": ["../../src/utils/node.ts"],
|
|
4
|
+
"sourcesContent": ["// THIS IS TAKEN FROM html-eslint\n\nimport { NODE_TYPES } from \"@html-eslint/parser\";\n\n\n/**\n * @param {TagNode | ScriptTagNode | StyleTagNode} node\n * @param {string} key\n * @returns {AttributeNode | undefined}\n */\nfunction findAttr(node, key) {\n return node.attributes.find(\n (attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase()\n );\n}\n\n/**\n * Checks whether a node's attributes is empty or not.\n * @param {TagNode | ScriptTagNode | StyleTagNode} node\n * @returns {boolean}\n */\nfunction isAttributesEmpty(node) {\n return !node.attributes || node.attributes.length <= 0;\n}\n\n/**\n * Checks whether a node's all tokens are on the same line or not.\n * @param {AnyNode} node A node to check\n * @returns {boolean} `true` if a node's tokens are on the same line, otherwise `false`.\n */\nfunction isNodeTokensOnSameLine(node) {\n return node.loc.start.line === node.loc.end.line;\n}\n\n/**\n *\n * @param {Range} rangeA\n * @param {Range} rangeB\n * @returns {boolean}\n */\nfunction isRangesOverlap(rangeA, rangeB) {\n return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];\n}\n\n/**\n * @param {(TextNode | CommentContentNode)['templates']} templates\n * @param {Range} range\n * @returns {boolean}\n */\nfunction isOverlapWithTemplates(templates, range) {\n return templates\n .filter((template) => template.isTemplate)\n .some((template) => isRangesOverlap(template.range, range));\n}\n\n/**\n *\n * @param {TextNode | CommentContentNode} node\n * @returns {LineNode[]}\n */\nfunction splitToLineNodes(node) {\n let start = node.range[0];\n let line = node.loc.start.line;\n const startCol = node.loc.start.column;\n /**\n * @type {LineNode[]}\n */\n const lineNodes = [];\n const templates = node.templates || [];\n /**\n *\n * @param {import(\"../../types\").Range} range\n */\n function shouldSkipIndentCheck(range) {\n const overlappedTemplates = templates.filter(\n (template) =>\n template.isTemplate && isRangesOverlap(template.range, range)\n );\n\n const isLineInTemplate = overlappedTemplates.some((template) => {\n return template.range[0] <= range[0] && template.range[1] >= range[1];\n });\n if (isLineInTemplate) {\n return true;\n }\n const isLineBeforeTemplate = overlappedTemplates.some((template) => {\n return template.range[0] <= range[0] && template.range[1] <= range[1];\n });\n if (isLineBeforeTemplate) {\n return true;\n }\n const isLineAfterTemplate = overlappedTemplates.some((template) => {\n return template.range[1] <= range[0];\n });\n if (isLineAfterTemplate) {\n return true;\n }\n return false;\n }\n\n node.value.split(\"\\n\").forEach((value, index) => {\n const columnStart = index === 0 ? startCol : 0;\n /**\n * @type {import(\"../../types\").Range}\n */\n const range = [start, start + value.length];\n const loc = {\n start: {\n line,\n column: columnStart,\n },\n end: {\n line,\n column: columnStart + value.length,\n },\n };\n /**\n * @type {LineNode}\n */\n const lineNode = {\n type: \"Line\",\n value,\n range,\n loc,\n skipIndentCheck: shouldSkipIndentCheck(range),\n };\n\n start += value.length + 1;\n line += 1;\n\n lineNodes.push(lineNode);\n });\n\n return lineNodes;\n}\n\n/**\n * Get location between two nodes.\n * @param {BaseNode} before A node placed in before\n * @param {BaseNode} after A node placed in after\n * @returns {Location} location between two nodes.\n */\nfunction getLocBetween(before, after) {\n return {\n start: before.loc.end,\n end: after.loc.start,\n };\n}\n\n/**\n * @param {AttributeValueNode} node\n * @return {boolean}\n */\nfunction isExpressionInTemplate(node) {\n if (node.type === NODE_TYPES.AttributeValue) {\n return node.value.indexOf(\"${\") === 0;\n }\n return false;\n}\n\n/**\n * @param {AnyNode} node\n * @returns {node is TagNode}\n */\nfunction isTag(node) {\n return node.type === NODE_TYPES.Tag;\n}\n\n/**\n * @param {AnyNode} node\n * @returns {node is CommentNode}\n */\nfunction isComment(node) {\n return node.type === NODE_TYPES.Comment;\n}\n\n/**\n * @param {AnyNode} node\n * @returns {node is TextNode}\n */\nfunction isText(node) {\n return node.type === NODE_TYPES.Text;\n}\n\nconst lineBreakPattern = /\\r\\n|[\\r\\n\\u2028\\u2029]/u;\nconst lineEndingPattern = new RegExp(lineBreakPattern.source, \"gu\");\n/**\n * @param {string} source\n * @returns {string[]}\n */\nfunction codeToLines(source) {\n return source.split(lineEndingPattern);\n}\n\n/**\n *\n * @param {AnyToken[]} tokens\n * @returns {((CommentContentNode | TextNode)['templates'][number])[]}\n */\nfunction getTemplateTokens(tokens) {\n return (\n []\n .concat(\n ...tokens\n // @ts-ignore\n .map((token) => token[\"templates\"] || [])\n )\n // @ts-ignore\n .filter((token) => token.isTemplate)\n );\n}\n\nexport {\n findAttr,\n isAttributesEmpty,\n isNodeTokensOnSameLine,\n splitToLineNodes,\n getLocBetween,\n isExpressionInTemplate,\n isTag,\n isComment,\n isText,\n isOverlapWithTemplates,\n codeToLines,\n isRangesOverlap,\n getTemplateTokens,\n};"],
|
|
5
5
|
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/property-matcher.ts
|
|
20
|
+
var property_matcher_exports = {};
|
|
21
|
+
__export(property_matcher_exports, {
|
|
22
|
+
colorProperties: () => colorProperties,
|
|
23
|
+
densificationProperties: () => densificationProperties,
|
|
24
|
+
fontProperties: () => fontProperties,
|
|
25
|
+
isBorderColorProperty: () => isBorderColorProperty,
|
|
26
|
+
isBorderRadius: () => isBorderRadius,
|
|
27
|
+
isBorderWidthProperty: () => isBorderWidthProperty,
|
|
28
|
+
isDimensionProperty: () => isDimensionProperty,
|
|
29
|
+
isInsetProperty: () => isInsetProperty,
|
|
30
|
+
isMarginProperty: () => isMarginProperty,
|
|
31
|
+
isPaddingProperty: () => isPaddingProperty,
|
|
32
|
+
matchesCssProperty: () => matchesCssProperty,
|
|
33
|
+
resolvePropertyToMatch: () => resolvePropertyToMatch,
|
|
34
|
+
toSelector: () => toSelector
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(property_matcher_exports);
|
|
37
|
+
function matchesCssProperty(hookProperties, cssProperty) {
|
|
38
|
+
return hookProperties.some((propertyPattern) => {
|
|
39
|
+
const regexPattern = new RegExp(
|
|
40
|
+
"^" + propertyPattern.replace(/\*/g, ".*") + "$"
|
|
41
|
+
);
|
|
42
|
+
return regexPattern.test(cssProperty);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
var DIRECTION_VALUES = "(?:top|right|bottom|left|inline|block|inline-start|inline-end|start|end|block-start|block-end)";
|
|
46
|
+
var CORNER_VALUES = "(?:top-left|top-right|bottom-right|bottom-left|start-start|start-end|end-start|end-end)";
|
|
47
|
+
var INSET_VALUES = "(?:inline|block|inline-start|inline-end|block-start|block-end)";
|
|
48
|
+
var BORDER_COLOR_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-color$`);
|
|
49
|
+
var BORDER_WIDTH_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-width$`);
|
|
50
|
+
var MARGIN_REGEX = new RegExp(`^margin(?:-${DIRECTION_VALUES})?$`);
|
|
51
|
+
var PADDING_REGEX = new RegExp(`^padding(?:-${DIRECTION_VALUES})?$`);
|
|
52
|
+
var BORDER_RADIUS_REGEX = new RegExp(`^border(?:-${CORNER_VALUES})?-radius$`);
|
|
53
|
+
var INSET_REGEX = new RegExp(`^inset(?:-${INSET_VALUES})?$`);
|
|
54
|
+
function isBorderColorProperty(cssProperty) {
|
|
55
|
+
return BORDER_COLOR_REGEX.test(cssProperty);
|
|
56
|
+
}
|
|
57
|
+
function isBorderWidthProperty(cssProperty) {
|
|
58
|
+
return BORDER_WIDTH_REGEX.test(cssProperty);
|
|
59
|
+
}
|
|
60
|
+
function isMarginProperty(cssProperty) {
|
|
61
|
+
return MARGIN_REGEX.test(cssProperty);
|
|
62
|
+
}
|
|
63
|
+
function isPaddingProperty(cssProperty) {
|
|
64
|
+
return PADDING_REGEX.test(cssProperty);
|
|
65
|
+
}
|
|
66
|
+
function isBorderRadius(cssProperty) {
|
|
67
|
+
return BORDER_RADIUS_REGEX.test(cssProperty);
|
|
68
|
+
}
|
|
69
|
+
function isDimensionProperty(cssProperty) {
|
|
70
|
+
return ["width", "height", "min-width", "max-width", "min-height", "max-height"].includes(cssProperty);
|
|
71
|
+
}
|
|
72
|
+
function isInsetProperty(cssProperty) {
|
|
73
|
+
return INSET_REGEX.test(cssProperty);
|
|
74
|
+
}
|
|
75
|
+
var fontProperties = [
|
|
76
|
+
"font",
|
|
77
|
+
"font-size",
|
|
78
|
+
"font-weight"
|
|
79
|
+
];
|
|
80
|
+
var colorProperties = [
|
|
81
|
+
"color",
|
|
82
|
+
"fill",
|
|
83
|
+
"background",
|
|
84
|
+
"background-color",
|
|
85
|
+
"stroke",
|
|
86
|
+
"border",
|
|
87
|
+
"border*",
|
|
88
|
+
"border*-color",
|
|
89
|
+
"outline",
|
|
90
|
+
"outline-color"
|
|
91
|
+
];
|
|
92
|
+
var densificationProperties = [
|
|
93
|
+
"border*",
|
|
94
|
+
"margin*",
|
|
95
|
+
"padding*",
|
|
96
|
+
"width",
|
|
97
|
+
"height",
|
|
98
|
+
"min-width",
|
|
99
|
+
"max-width",
|
|
100
|
+
"min-height",
|
|
101
|
+
"max-height",
|
|
102
|
+
"inset",
|
|
103
|
+
"top",
|
|
104
|
+
"right",
|
|
105
|
+
"left",
|
|
106
|
+
"bottom",
|
|
107
|
+
"outline",
|
|
108
|
+
"outline-width",
|
|
109
|
+
"line-height"
|
|
110
|
+
];
|
|
111
|
+
function toSelector(properties) {
|
|
112
|
+
const selectorParts = properties.map((prop) => {
|
|
113
|
+
if (prop.includes("*")) {
|
|
114
|
+
const regexPattern = prop.replace(/\*/g, ".*");
|
|
115
|
+
return `Declaration[property=/${regexPattern}$/]`;
|
|
116
|
+
} else {
|
|
117
|
+
return `Declaration[property='${prop}']`;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return selectorParts.join(", ");
|
|
121
|
+
}
|
|
122
|
+
function resolvePropertyToMatch(cssProperty) {
|
|
123
|
+
const propertyToMatch = cssProperty.toLowerCase();
|
|
124
|
+
if (propertyToMatch === "outline" || propertyToMatch === "outline-width" || isBorderWidthProperty(propertyToMatch)) {
|
|
125
|
+
return "border-width";
|
|
126
|
+
} else if (isMarginProperty(propertyToMatch)) {
|
|
127
|
+
return "margin";
|
|
128
|
+
} else if (isPaddingProperty(propertyToMatch)) {
|
|
129
|
+
return "padding";
|
|
130
|
+
} else if (isBorderRadius(propertyToMatch)) {
|
|
131
|
+
return "border-radius";
|
|
132
|
+
} else if (isDimensionProperty(propertyToMatch)) {
|
|
133
|
+
return "width";
|
|
134
|
+
} else if (isInsetProperty(propertyToMatch)) {
|
|
135
|
+
return "top";
|
|
136
|
+
} else if (cssProperty === "background" || cssProperty === "background-color") {
|
|
137
|
+
return "background-color";
|
|
138
|
+
} else if (cssProperty === "outline" || cssProperty === "outline-color" || isBorderColorProperty(cssProperty)) {
|
|
139
|
+
return "border-color";
|
|
140
|
+
}
|
|
141
|
+
return propertyToMatch;
|
|
142
|
+
}
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
colorProperties,
|
|
146
|
+
densificationProperties,
|
|
147
|
+
fontProperties,
|
|
148
|
+
isBorderColorProperty,
|
|
149
|
+
isBorderRadius,
|
|
150
|
+
isBorderWidthProperty,
|
|
151
|
+
isDimensionProperty,
|
|
152
|
+
isInsetProperty,
|
|
153
|
+
isMarginProperty,
|
|
154
|
+
isPaddingProperty,
|
|
155
|
+
matchesCssProperty,
|
|
156
|
+
resolvePropertyToMatch,
|
|
157
|
+
toSelector
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=property-matcher.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/property-matcher.ts"],
|
|
4
|
+
"sourcesContent": ["///stylelint-sds/packages/stylelint-plugin-slds/src/utils/property-matcher.ts\n/**\n * Check if any of the hook properties match the provided cssProperty using wildcard matching.\n * @param hookProperties - Array of property patterns (can contain wildcards like `*`)\n * @param cssProperty - The CSS property to be checked\n * @returns true if a match is found, otherwise false\n */\nexport function matchesCssProperty(\n hookProperties: string[],\n cssProperty: string\n): boolean {\n return hookProperties.some((propertyPattern: string) => {\n const regexPattern = new RegExp(\n '^' + propertyPattern.replace(/\\*/g, '.*') + '$'\n );\n return regexPattern.test(cssProperty);\n });\n}\n\n// Directions & Corners\nconst DIRECTION_VALUES = '(?:top|right|bottom|left|inline|block|inline-start|inline-end|start|end|block-start|block-end)';\nconst CORNER_VALUES = '(?:top-left|top-right|bottom-right|bottom-left|start-start|start-end|end-start|end-end)';\nconst INSET_VALUES = '(?:inline|block|inline-start|inline-end|block-start|block-end)';\n\n\n// Pre-compiled regex patterns for better performance\nconst BORDER_COLOR_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-color$`);\nconst BORDER_WIDTH_REGEX = new RegExp(`^border(?:-${DIRECTION_VALUES})?-width$`);\nconst MARGIN_REGEX = new RegExp(`^margin(?:-${DIRECTION_VALUES})?$`);\nconst PADDING_REGEX = new RegExp(`^padding(?:-${DIRECTION_VALUES})?$`);\nconst BORDER_RADIUS_REGEX = new RegExp(`^border(?:-${CORNER_VALUES})?-radius$`);\nconst INSET_REGEX = new RegExp(`^inset(?:-${INSET_VALUES})?$`);\n\nexport function isBorderColorProperty(cssProperty: string): boolean {\n return BORDER_COLOR_REGEX.test(cssProperty);\n}\n\nexport function isBorderWidthProperty(cssProperty: string): boolean {\n return BORDER_WIDTH_REGEX.test(cssProperty);\n}\n\nexport function isMarginProperty(cssProperty: string): boolean {\n return MARGIN_REGEX.test(cssProperty);\n}\n\nexport function isPaddingProperty(cssProperty: string): boolean {\n return PADDING_REGEX.test(cssProperty);\n}\n\nexport function isBorderRadius(cssProperty: string): boolean {\n return BORDER_RADIUS_REGEX.test(cssProperty);\n}\n\nexport function isDimensionProperty(cssProperty: string): boolean {\n return ['width', 'height', 'min-width', 'max-width', 'min-height', 'max-height'].includes(cssProperty);\n}\n\nexport function isInsetProperty(cssProperty: string): boolean {\n return INSET_REGEX.test(cssProperty);\n}\n\nexport const fontProperties = [\n 'font',\n 'font-size', \n 'font-weight'\n];\n\nexport const colorProperties = [\n 'color',\n 'fill',\n 'background',\n 'background-color',\n 'stroke',\n 'border',\n 'border*',\n 'border*-color',\n 'outline',\n 'outline-color',\n];\n\nexport const densificationProperties = [\n 'border*',\n 'margin*',\n 'padding*',\n 'width',\n 'height',\n 'min-width',\n 'max-width',\n 'min-height',\n 'max-height',\n 'inset',\n 'top',\n 'right',\n 'left',\n 'bottom',\n 'outline',\n 'outline-width',\n 'line-height'\n]; \n\n/**\n * Convert property patterns to CSS AST selector patterns\n * Handles wildcards (*) and creates proper ESLint CSS selector syntax\n */\nexport function toSelector(properties: string[]): string {\n const selectorParts = properties.map(prop => {\n if (prop.includes('*')) {\n // Convert wildcards to regex patterns for CSS AST selectors\n const regexPattern = prop.replace(/\\*/g, '.*');\n return `Declaration[property=/${regexPattern}$/]`;\n } else {\n // Exact property match\n return `Declaration[property='${prop}']`;\n }\n });\n \n return selectorParts.join(', ');\n}\n\nexport function resolvePropertyToMatch(cssProperty:string){\n const propertyToMatch = cssProperty.toLowerCase();\n if(propertyToMatch === 'outline' || propertyToMatch === 'outline-width' || isBorderWidthProperty(propertyToMatch)){\n return 'border-width';\n } else if(isMarginProperty(propertyToMatch)){\n return 'margin';\n } else if(isPaddingProperty(propertyToMatch)){\n return 'padding';\n } else if(isBorderRadius(propertyToMatch)){\n return 'border-radius';\n } else if(isDimensionProperty(propertyToMatch)){\n // Stylinghooks includes only width as property to match, for all other dimensions we need to match width\n return 'width';\n } else if(isInsetProperty(propertyToMatch)){\n // Stylinghooks includes only top/left/right/bottom as property to match, for all other insets we need to match top\n return 'top';\n } else if(cssProperty === 'background' || cssProperty === 'background-color'){\n return 'background-color';\n } else if(cssProperty === 'outline' || cssProperty === 'outline-color' || isBorderColorProperty(cssProperty)){\n return 'border-color';\n }\n return propertyToMatch;\n}"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/styling-hook-utils.ts
|
|
20
|
+
var styling_hook_utils_exports = {};
|
|
21
|
+
__export(styling_hook_utils_exports, {
|
|
22
|
+
getStylingHooksForDensityValue: () => getStylingHooksForDensityValue
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(styling_hook_utils_exports);
|
|
25
|
+
|
|
26
|
+
// src/utils/value-utils.ts
|
|
27
|
+
function parseUnitValue(value) {
|
|
28
|
+
if (!value) return null;
|
|
29
|
+
const match = value.match(/^(-?\d*\.?\d+)(px|rem|%)?$/);
|
|
30
|
+
if (!match) return null;
|
|
31
|
+
const number = parseFloat(match[1]);
|
|
32
|
+
const unit = match[2] ? match[2] : null;
|
|
33
|
+
if (isNaN(number)) return null;
|
|
34
|
+
return { number, unit };
|
|
35
|
+
}
|
|
36
|
+
function toAlternateUnitValue(numberVal, unitType) {
|
|
37
|
+
if (unitType === "px") {
|
|
38
|
+
let floatValue = parseFloat(`${numberVal / 16}`);
|
|
39
|
+
if (!isNaN(floatValue)) {
|
|
40
|
+
return {
|
|
41
|
+
unit: "rem",
|
|
42
|
+
number: parseFloat(floatValue.toFixed(4))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
} else if (unitType === "rem") {
|
|
46
|
+
const intValue = parseInt(`${numberVal * 16}`);
|
|
47
|
+
if (!isNaN(intValue)) {
|
|
48
|
+
return {
|
|
49
|
+
unit: "px",
|
|
50
|
+
number: intValue
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/utils/styling-hook-utils.ts
|
|
58
|
+
function isValueMatch(valueToMatch, sldsValue) {
|
|
59
|
+
if (!valueToMatch || !sldsValue) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return valueToMatch.unit == sldsValue.unit && valueToMatch.number === sldsValue.number;
|
|
63
|
+
}
|
|
64
|
+
function getStylingHooksForDensityValue(parsedValue, supportedStylinghooks, cssProperty) {
|
|
65
|
+
if (!parsedValue) return [];
|
|
66
|
+
const alternateValue = toAlternateUnitValue(parsedValue.number, parsedValue.unit);
|
|
67
|
+
const matchedHooks = [];
|
|
68
|
+
for (const [sldsValue, hooks] of Object.entries(supportedStylinghooks)) {
|
|
69
|
+
const parsedSldsValue = parseUnitValue(sldsValue);
|
|
70
|
+
if (isValueMatch(parsedValue, parsedSldsValue) || alternateValue && isValueMatch(alternateValue, parsedSldsValue)) {
|
|
71
|
+
hooks.filter((hook) => hook.properties.includes(cssProperty)).forEach((hook) => matchedHooks.push(hook.name));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return matchedHooks;
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
getStylingHooksForDensityValue
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=styling-hook-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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/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\nexport type ParsedUnitValue = {\n unit: 'px' | 'rem' | '%' | null;\n number: number;\n} | null;\n\nexport function parseUnitValue(value: string): ParsedUnitValue {\n if (!value) return null;\n \n // Simple regex to parse number and unit\n const match = value.match(/^(-?\\d*\\.?\\d+)(px|rem|%)?$/);\n if (!match) return null;\n \n const number = parseFloat(match[1]);\n const unit = match[2] ? (match[2] as 'px' | 'rem' | '%') : 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' | '%' | 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 unitless values (font-weight, etc.), no alternate unit conversion\n return null;\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4CO,SAAS,eAAe,OAAgC;AAC7D,MAAI,CAAC,MAAO,QAAO;AAGnB,QAAM,QAAQ,MAAM,MAAM,4BAA4B;AACtD,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,SAAS,WAAW,MAAM,CAAC,CAAC;AAClC,QAAM,OAAO,MAAM,CAAC,IAAK,MAAM,CAAC,IAA2B;AAE3D,MAAI,MAAM,MAAM,EAAG,QAAO;AAE1B,SAAO,EAAE,QAAQ,KAAK;AACxB;AAEO,SAAS,qBAAqB,WAAmB,UAAsD;AAC1G,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;AAEA,SAAO;AACX;;;AD5EA,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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/value-utils.ts
|
|
20
|
+
var value_utils_exports = {};
|
|
21
|
+
__export(value_utils_exports, {
|
|
22
|
+
isGlobalValue: () => isGlobalValue,
|
|
23
|
+
parseUnitValue: () => parseUnitValue,
|
|
24
|
+
toAlternateUnitValue: () => toAlternateUnitValue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(value_utils_exports);
|
|
27
|
+
function isGlobalValue(value) {
|
|
28
|
+
return value === "initial" || value === "inherit" || value === "unset" || value === "revert" || value === "revert-layer";
|
|
29
|
+
}
|
|
30
|
+
function parseUnitValue(value) {
|
|
31
|
+
if (!value) return null;
|
|
32
|
+
const match = value.match(/^(-?\d*\.?\d+)(px|rem|%)?$/);
|
|
33
|
+
if (!match) return null;
|
|
34
|
+
const number = parseFloat(match[1]);
|
|
35
|
+
const unit = match[2] ? match[2] : null;
|
|
36
|
+
if (isNaN(number)) return null;
|
|
37
|
+
return { number, unit };
|
|
38
|
+
}
|
|
39
|
+
function toAlternateUnitValue(numberVal, unitType) {
|
|
40
|
+
if (unitType === "px") {
|
|
41
|
+
let floatValue = parseFloat(`${numberVal / 16}`);
|
|
42
|
+
if (!isNaN(floatValue)) {
|
|
43
|
+
return {
|
|
44
|
+
unit: "rem",
|
|
45
|
+
number: parseFloat(floatValue.toFixed(4))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
} else if (unitType === "rem") {
|
|
49
|
+
const intValue = parseInt(`${numberVal * 16}`);
|
|
50
|
+
if (!isNaN(intValue)) {
|
|
51
|
+
return {
|
|
52
|
+
unit: "px",
|
|
53
|
+
number: intValue
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
isGlobalValue,
|
|
62
|
+
parseUnitValue,
|
|
63
|
+
toAlternateUnitValue
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=value-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/value-utils.ts"],
|
|
4
|
+
"sourcesContent": ["// 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\nexport type ParsedUnitValue = {\n unit: 'px' | 'rem' | '%' | null;\n number: number;\n} | null;\n\nexport function parseUnitValue(value: string): ParsedUnitValue {\n if (!value) return null;\n \n // Simple regex to parse number and unit\n const match = value.match(/^(-?\\d*\\.?\\d+)(px|rem|%)?$/);\n if (!match) return null;\n \n const number = parseFloat(match[1]);\n const unit = match[2] ? (match[2] as 'px' | 'rem' | '%') : 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' | '%' | 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 unitless values (font-weight, etc.), no alternate unit conversion\n return null;\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCO,SAAS,cAAc,OAAwB;AAClD,SAAO,UAAU,aAAa,UAAU,aAAa,UAAU,WAAW,UAAU,YAAY,UAAU;AAC5G;AAOK,SAAS,eAAe,OAAgC;AAC7D,MAAI,CAAC,MAAO,QAAO;AAGnB,QAAM,QAAQ,MAAM,MAAM,4BAA4B;AACtD,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,SAAS,WAAW,MAAM,CAAC,CAAC;AAClC,QAAM,OAAO,MAAM,CAAC,IAAK,MAAM,CAAC,IAA2B;AAE3D,MAAI,MAAM,MAAM,EAAG,QAAO;AAE1B,SAAO,EAAE,QAAQ,KAAK;AACxB;AAEO,SAAS,qBAAqB,WAAmB,UAAsD;AAC1G,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;AAEA,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/eslint-plugin-slds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-internal-alpha.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
"./config": {
|
|
12
12
|
"import": "./eslint.config.mjs",
|
|
13
13
|
"require": "./eslint.config.mjs"
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
|
+
"./rule-messages.yml": "./src/config/rule-messages.yml"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"build/**",
|
|
18
19
|
"README.md",
|
|
19
20
|
"RULES.md",
|
|
20
|
-
"eslint.config.mjs"
|
|
21
|
+
"eslint.config.mjs",
|
|
22
|
+
"src/config/rule-messages.yml"
|
|
21
23
|
],
|
|
22
24
|
"engines": {
|
|
23
25
|
"node": ">=18.18.0"
|
|
@@ -32,9 +34,12 @@
|
|
|
32
34
|
"license": "ISC",
|
|
33
35
|
"description": "ESLint plugin provides custom linting rules specifically built for Salesforce Lightning Design System 2 (SLDS 2 beta)",
|
|
34
36
|
"dependencies": {
|
|
37
|
+
"@eslint/css": "^0.9.0",
|
|
38
|
+
"@eslint/css-tree": "^3.6.5",
|
|
35
39
|
"@html-eslint/eslint-plugin": "^0.34.0",
|
|
36
40
|
"@html-eslint/parser": "^0.34.0",
|
|
37
|
-
"@salesforce-ux/sds-metadata": "^0.3.3"
|
|
41
|
+
"@salesforce-ux/sds-metadata": "^0.3.3",
|
|
42
|
+
"chroma-js": "^3.1.2"
|
|
38
43
|
},
|
|
39
44
|
"peerDependencies": {
|
|
40
45
|
"eslint": "^8.0.0 || ^9.0.0"
|