@salesforce-ux/eslint-plugin-slds 0.5.3 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +2365 -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 +369 -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 +334 -0
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +355 -0
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +355 -0
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +399 -0
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/index.js +830 -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 +1132 -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 +1132 -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 +963 -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 +339 -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 +11 -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 +7 -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 +26 -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/rule-utils.d.ts +8 -0
- package/build/src/utils/styling-hook-utils.d.ts +7 -0
- package/build/src/utils/value-utils.d.ts +41 -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 +200 -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 +141 -0
- package/build/utils/css-utils.js.map +7 -0
- package/build/utils/hardcoded-shared-utils.js +303 -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/rule-utils.js +46 -0
- package/build/utils/rule-utils.js.map +7 -0
- package/build/utils/styling-hook-utils.js +83 -0
- package/build/utils/styling-hook-utils.js.map +7 -0
- package/build/utils/value-utils.js +70 -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
|
@@ -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};\n", "export const messages= {\n removeClass:\n \"Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.\",\n changeVariant:\n \"Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.\",\n removeVariant:\n \"Remove the variant attribute from the <lightning-icon> component inside the <button> element.\",\n ensureButtonClasses:\n \"Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.\",\n ensureSizeAttribute:\n \"To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components.\",\n }", "import { findAttr, isAttributesEmpty } from \"./utils/node\";\nimport { messages } from \"./utils/rule\";\n\n// This rule specific to CVS, find more details here https://issues.salesforce.com/issue/a028c00000zh1iqAAA/modal-close-button-is-not-visible-with-the-new-white-background-after-winter-25-release\nexport = {\n meta: {\n type: \"problem\",\n docs: {\n category: \"Best Practices\",\n recommended: true,\n description: \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.\",\n url: \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue\"\n },\n fixable: \"code\",\n schema: [],\n },\n\n create(context) {\n function check(node) {\n if (isAttributesEmpty(node)) {\n return;\n }\n\n const tagName = node.name;\n\n // \u2705 Scenario 1: Remove 'slds-button_icon-inverse' from <button> \n // (optional) when the parent of the button has class name `slds-modal`\n // and also button should have class `slds-modal__close`\n if (tagName === \"button\") {\n const classAttr = findAttr(node, \"class\");\n if (classAttr && classAttr.value) {\n const classList = classAttr.value.value.split(/\\s+/);\n\n // \u2705 Ensure button has \"slds-modal__close\" before proceeding\n if (!classList.includes(\"slds-modal__close\")) {\n return; // Stop execution if the class is missing\n }\n\n if (classList.includes(\"slds-button_icon-inverse\") || classList.includes(\"slds-button--icon-inverse\")) {\n const newClassList = classList\n .filter((cls) => (cls !== \"slds-button_icon-inverse\" && cls !== \"slds-button--icon-inverse\"))\n .join(\" \");\n context.report({\n node,\n loc: classAttr.loc,\n message: messages[\"removeClass\"],\n fix(fixer) { \n return fixer.replaceText(classAttr, // Replace the full attribute\n `class=\"${newClassList}\"` // Updated class list\n );\n },\n });\n }\n }\n }\n\n // \u2705 Scenario 2: Fix <lightning-button-icon> and this should have class `slds-modal__close`\n if (tagName === \"lightning-button-icon\" || tagName === \"lightning:buttonIcon\") {\n const variantAttr = findAttr(node, \"variant\");\n const sizeAttr = findAttr(node, \"size\");\n const classAttr = findAttr(node, \"class\");\n const iconClassAttr = findAttr(node, \"icon-class\"); // \uD83D\uDD0D Check for icon-class attribute\n \n function validateClassAttr(attribute, attrName) {\n if (attribute && attribute.value) {\n const classList = attribute.value.value.split(/\\s+/);\n\n // Irrespective of whether we are checking for class or icon-class we need to check whether the attribute is present or not.\n // \u2705 Ensure \"slds-modal__close\" exists before proceeding\n if(!classAttr?.value?.value?.includes(\"slds-modal__close\"))\n {\n return;\n }\n \n // \u2705 Ensure \"slds-modal__close\" exists before proceeding\n // if (!classList.includes(\"slds-modal__close\")) {\n // return; // Stop execution if the class is missing\n // }\n \n // Remove inverse classes\n if (classList.includes(\"slds-button_icon-inverse\") || classList.includes(\"slds-button--icon-inverse\")) {\n const newClassList = classList\n .filter((cls) => cls !== \"slds-button_icon-inverse\" && cls !== \"slds-button--icon-inverse\")\n .join(\" \");\n context.report({\n node,\n loc: attribute.loc,\n message: messages[\"removeClass\"],\n fix(fixer) {\n return fixer.replaceText(attribute, // Replace the full attribute\n `${attrName}=\"${newClassList}\"` // Correctly modifies the respective attribute\n );\n },\n });\n }\n \n // Ensure 'slds-button' and 'slds-button_icon' exist\n if (!classList.includes(\"slds-button\") || !classList.includes(\"slds-button_icon\")) {\n let newClassList;\n if(attrName === 'icon-class'){\n newClassList = [\n ...classList.filter((cls) => cls !== \"slds-button_icon-inverse\"),\n ].join(\" \");\n }else{\n newClassList = [\n \"slds-button\",\n \"slds-button_icon\",\n ...classList.filter((cls) => cls !== \"slds-button_icon-inverse\"),\n ].join(\" \");\n }\n context.report({\n node: attribute,\n loc: attribute.value.loc,\n message: messages[\"ensureButtonClasses\"],\n fix(fixer) {\n return fixer.replaceText(attribute.value, `${newClassList}`);\n },\n });}\n \n // Fix variant=\"bare-inverse\" to \"bare\"\n if (variantAttr && variantAttr.value && variantAttr.value.value === \"bare-inverse\") {\n context.report({\n node: variantAttr,\n message: messages[\"changeVariant\"],\n loc: variantAttr.value.loc,\n fix(fixer) {\n return fixer.replaceText(variantAttr.value, `bare`);\n },\n });\n }\n \n // Ensure size=\"large\" exists\n // if (!sizeAttr) {\n // context.report({\n // node,\n // message: messages[\"ensureSizeAttribute\"],\n // fix(fixer) {\n // if (variantAttr) {\n // return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size=\"large\"');\n // }\n // },\n // });\n // }\n }\n }\n \n // \u2705 Validate `class` and `icon-class` separately, maintaining their own attribute names\n validateClassAttr(classAttr, \"class\");\n validateClassAttr(iconClassAttr, \"icon-class\");\n }\n\n // \u2705 Scenario 3: Fix <lightning-icon> inside <button> & the class name of the parent name as button and it should have `slds-modal__close`\n if ((tagName === \"lightning-icon\" || tagName === \"lightning:icon\") && node.parent?.name === \"button\") {\n const parentClassAttr = findAttr(node.parent, \"class\");\n if (parentClassAttr && parentClassAttr.value) {\n const parentClassList = parentClassAttr.value.value.split(/\\s+/);\n\n // \u2705 Ensure the parent <button> has \"slds-modal__close\" before proceeding\n if (!parentClassList.includes(\"slds-modal__close\")) {\n return; // Stop execution if the class is missing\n }\n const variantAttr = findAttr(node, \"variant\");\n const sizeAttr = findAttr(node, \"size\");\n\n // Fix variant=\"bare-inverse\" to \"bare\"\n if (variantAttr && variantAttr.value && variantAttr.value.value === \"bare-inverse\") {\n context.report({\n node: variantAttr,\n message: messages[\"changeVariant\"],\n loc: variantAttr.value.loc,\n fix(fixer) {\n return fixer.replaceText(variantAttr.value, `bare`);\n },\n });\n }\n\n // // Remove variant attribute completely\n // if (variantAttr) {\n // context.report({\n // node: variantAttr,\n // messageId: \"removeVariant\",\n // fix(fixer) {\n // return fixer.remove(variantAttr);\n // },\n // });\n // }\n\n //Ensure size=\"large\" is set\n // if (!sizeAttr) {\n // context.report({\n // node,\n // message: messages[\"ensureSizeAttribute\"],\n // fix(fixer) {\n // //return fixer.insertTextAfter(node, ' size=\"large\"');\n // if(variantAttr)\n // {\n // return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size=\"large\"')\n // }\n // },\n // });\n // }\n }\n }\n }\n return {\n Tag: check,\n };\n },\n};"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["yaml-file:/Users/ritesh.kumar2/Documents/projects/stylelint-sds/packages/eslint-plugin-slds/src/config/rule-messages.yml", "../../src/utils/node.ts", "../../src/rules/modal-close-button-issue.ts"],
|
|
4
|
+
"sourcesContent": ["module.exports = {\n \"no-slds-class-overrides\": {\n \"description\": \"Create new custom CSS classes instead of overriding SLDS selectors\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides\",\n \"type\": \"problem\",\n \"messages\": {\n \"sldsClassOverride\": \"Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button.\"\n }\n },\n \"no-deprecated-slds-classes\": {\n \"description\": \"Please replace the deprecated classes with a modern equivalent\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedClass\": \"The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class.\"\n }\n },\n \"no-deprecated-tokens-slds1\": {\n \"description\": \"Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedToken\": \"Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com.\",\n \"noReplacement\": \"Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.\"\n }\n },\n \"enforce-sds-to-slds-hooks\": {\n \"description\": \"Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks\",\n \"type\": \"problem\",\n \"messages\": {\n \"replaceSdsWithSlds\": \"Replace {{oldValue}} with {{suggestedMatch}} styling hook.\"\n }\n },\n \"enforce-bem-usage\": {\n \"description\": \"Replace BEM double-dash syntax in class names with single underscore syntax\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage\",\n \"type\": \"problem\",\n \"messages\": {\n \"bemDoubleDash\": \"{{actual}} has been retired. Update it to the new name {{newValue}}.\",\n \"fixBemNaming\": \"Update to correct BEM naming convention\"\n }\n },\n \"modal-close-button-issue\": {\n \"description\": \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue\",\n \"type\": \"problem\",\n \"messages\": {\n \"modalCloseButtonIssue\": \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.\",\n \"removeClass\": \"Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.\",\n \"changeVariant\": \"Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.\",\n \"removeVariant\": \"Remove the variant attribute from the <lightning-icon> component inside the <button> element.\",\n \"ensureButtonClasses\": \"Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.\",\n \"ensureSizeAttribute\": \"To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components.\"\n }\n },\n \"no-deprecated-classes-slds2\": {\n \"description\": \"Replace classes that aren't available with SLDS 2 classes\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\",\n \"updateToModernClass\": \"Replace deprecated class with modern equivalent\",\n \"checkDocumentation\": \"See lightningdesignsystem.com for SLDS 2 class alternatives\"\n }\n },\n \"lwc-token-to-slds-hook\": {\n \"description\": \"Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook\",\n \"type\": \"problem\",\n \"messages\": {\n \"errorWithReplacement\": \"The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.\",\n \"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.\",\n \"errorWithNoRecommendation\": \"The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com.\"\n }\n },\n \"no-sldshook-fallback-for-lwctoken\": {\n \"description\": \"Avoid using --slds styling hooks as fallback values for --lwc tokens.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken\",\n \"type\": \"problem\",\n \"messages\": {\n \"unsupportedFallback\": \"Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}.\"\n }\n },\n \"no-unsupported-hooks-slds2\": {\n \"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.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\"\n }\n },\n \"no-slds-var-without-fallback\": {\n \"description\": \"Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\"\n }\n },\n \"no-slds-namespace-for-custom-hooks\": {\n \"description\": \"To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks\",\n \"type\": \"problem\",\n \"messages\": {\n \"customHookNamespace\": \"Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}\"\n }\n },\n \"no-slds-private-var\": {\n \"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.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\"\n }\n },\n \"enforce-component-hook-naming-convention\": {\n \"description\": \"Replace component styling hooks that use a deprecated naming convention.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention\",\n \"type\": \"problem\",\n \"messages\": {\n \"replace\": \"Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}.\"\n }\n },\n \"no-hardcoded-values-slds1\": {\n \"description\": \"Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value\",\n \"type\": \"suggestion\",\n \"messages\": {\n \"hardcodedValue\": \"Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}.\",\n \"noReplacement\": \"There's no replacement styling hook for the {{oldValue}} static value. Remove the static value.\"\n }\n },\n \"no-hardcoded-values-slds2\": {\n \"description\": \"Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value\",\n \"type\": \"suggestion\",\n \"messages\": {\n \"hardcodedValue\": \"Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.\",\n \"noReplacement\": \"There's no replacement styling hook for the {{oldValue}} static value. Remove the static value.\"\n }\n },\n \"reduce-annotations\": {\n \"description\": \"Remove your annotations and update your code.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations\",\n \"type\": \"problem\",\n \"messages\": {\n \"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/\"\n }\n }\n};", "// 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};", "import { Rule } from 'eslint';\nimport { findAttr, isAttributesEmpty } from \"../utils/node\";\nimport ruleMessages from '../config/rule-messages.yml';\n\nconst ruleConfig = ruleMessages['modal-close-button-issue'];\n\n// This rule specific to CVS, find more details here https://issues.salesforce.com/issue/a028c00000zh1iqAAA/modal-close-button-is-not-visible-with-the-new-white-background-after-winter-25-release\nexport = {\n meta: {\n type: ruleConfig.type,\n docs: {\n category: \"Best Practices\",\n recommended: true,\n description: ruleConfig.description,\n url: ruleConfig.url\n },\n fixable: \"code\",\n schema: [],\n messages: ruleConfig.messages,\n },\n\n create(context) {\n function check(node) {\n if (isAttributesEmpty(node)) {\n return;\n }\n\n const tagName = node.name;\n\n // \u2705 Scenario 1: Remove 'slds-button_icon-inverse' from <button> \n // (optional) when the parent of the button has class name `slds-modal`\n // and also button should have class `slds-modal__close`\n if (tagName === \"button\") {\n const classAttr = findAttr(node, \"class\");\n if (classAttr && classAttr.value) {\n const classList = classAttr.value.value.split(/\\s+/);\n\n // \u2705 Ensure button has \"slds-modal__close\" before proceeding\n if (!classList.includes(\"slds-modal__close\")) {\n return; // Stop execution if the class is missing\n }\n\n if (classList.includes(\"slds-button_icon-inverse\") || classList.includes(\"slds-button--icon-inverse\")) {\n const newClassList = classList\n .filter((cls) => (cls !== \"slds-button_icon-inverse\" && cls !== \"slds-button--icon-inverse\"))\n .join(\" \");\n context.report({\n node,\n loc: classAttr.loc,\n messageId: \"removeClass\",\n fix(fixer) { \n return fixer.replaceText(classAttr, // Replace the full attribute\n `class=\"${newClassList}\"` // Updated class list\n );\n },\n });\n }\n }\n }\n\n // \u2705 Scenario 2: Fix <lightning-button-icon> and this should have class `slds-modal__close`\n if (tagName === \"lightning-button-icon\" || tagName === \"lightning:buttonIcon\") {\n const variantAttr = findAttr(node, \"variant\");\n const sizeAttr = findAttr(node, \"size\");\n const classAttr = findAttr(node, \"class\");\n const iconClassAttr = findAttr(node, \"icon-class\"); // \uD83D\uDD0D Check for icon-class attribute\n \n function validateClassAttr(attribute, attrName) {\n if (attribute && attribute.value) {\n const classList = attribute.value.value.split(/\\s+/);\n\n // Irrespective of whether we are checking for class or icon-class we need to check whether the attribute is present or not.\n // \u2705 Ensure \"slds-modal__close\" exists before proceeding\n if(!classAttr?.value?.value?.includes(\"slds-modal__close\"))\n {\n return;\n }\n \n // \u2705 Ensure \"slds-modal__close\" exists before proceeding\n // if (!classList.includes(\"slds-modal__close\")) {\n // return; // Stop execution if the class is missing\n // }\n \n // Remove inverse classes\n if (classList.includes(\"slds-button_icon-inverse\") || classList.includes(\"slds-button--icon-inverse\")) {\n const newClassList = classList\n .filter((cls) => cls !== \"slds-button_icon-inverse\" && cls !== \"slds-button--icon-inverse\")\n .join(\" \");\n context.report({\n node,\n loc: attribute.loc,\n messageId: \"removeClass\",\n fix(fixer) {\n return fixer.replaceText(attribute, // Replace the full attribute\n `${attrName}=\"${newClassList}\"` // Correctly modifies the respective attribute\n );\n },\n });\n }\n \n // Ensure 'slds-button' and 'slds-button_icon' exist\n if (!classList.includes(\"slds-button\") || !classList.includes(\"slds-button_icon\")) {\n let newClassList;\n if(attrName === 'icon-class'){\n newClassList = [\n ...classList.filter((cls) => cls !== \"slds-button_icon-inverse\"),\n ].join(\" \");\n }else{\n newClassList = [\n \"slds-button\",\n \"slds-button_icon\",\n ...classList.filter((cls) => cls !== \"slds-button_icon-inverse\"),\n ].join(\" \");\n }\n context.report({\n node: attribute,\n loc: attribute.value.loc,\n messageId: \"ensureButtonClasses\",\n fix(fixer) {\n return fixer.replaceText(attribute.value, `${newClassList}`);\n },\n });}\n \n // Fix variant=\"bare-inverse\" to \"bare\"\n if (variantAttr && variantAttr.value && variantAttr.value.value === \"bare-inverse\") {\n context.report({\n node: variantAttr,\n messageId: \"changeVariant\",\n loc: variantAttr.value.loc,\n fix(fixer) {\n return fixer.replaceText(variantAttr.value, `bare`);\n },\n });\n }\n \n // Ensure size=\"large\" exists\n // if (!sizeAttr) {\n // context.report({\n // node,\n // message: messages[\"ensureSizeAttribute\"],\n // fix(fixer) {\n // if (variantAttr) {\n // return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size=\"large\"');\n // }\n // },\n // });\n // }\n }\n }\n \n // \u2705 Validate `class` and `icon-class` separately, maintaining their own attribute names\n validateClassAttr(classAttr, \"class\");\n validateClassAttr(iconClassAttr, \"icon-class\");\n }\n\n // \u2705 Scenario 3: Fix <lightning-icon> inside <button> & the class name of the parent name as button and it should have `slds-modal__close`\n if ((tagName === \"lightning-icon\" || tagName === \"lightning:icon\") && node.parent?.name === \"button\") {\n const parentClassAttr = findAttr(node.parent, \"class\");\n if (parentClassAttr && parentClassAttr.value) {\n const parentClassList = parentClassAttr.value.value.split(/\\s+/);\n\n // \u2705 Ensure the parent <button> has \"slds-modal__close\" before proceeding\n if (!parentClassList.includes(\"slds-modal__close\")) {\n return; // Stop execution if the class is missing\n }\n const variantAttr = findAttr(node, \"variant\");\n const sizeAttr = findAttr(node, \"size\");\n\n // Fix variant=\"bare-inverse\" to \"bare\"\n if (variantAttr && variantAttr.value && variantAttr.value.value === \"bare-inverse\") {\n context.report({\n node: variantAttr,\n messageId: \"changeVariant\",\n loc: variantAttr.value.loc,\n fix(fixer) {\n return fixer.replaceText(variantAttr.value, `bare`);\n },\n });\n }\n\n // // Remove variant attribute completely\n // if (variantAttr) {\n // context.report({\n // node: variantAttr,\n // messageId: \"removeVariant\",\n // fix(fixer) {\n // return fixer.remove(variantAttr);\n // },\n // });\n // }\n\n //Ensure size=\"large\" is set\n // if (!sizeAttr) {\n // context.report({\n // node,\n // message: messages[\"ensureSizeAttribute\"],\n // fix(fixer) {\n // //return fixer.insertTextAfter(node, ' size=\"large\"');\n // if(variantAttr)\n // {\n // return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size=\"large\"')\n // }\n // },\n // });\n // }\n }\n }\n }\n return {\n Tag: check,\n };\n },\n};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X,KAAK,YAAY,MAAM;AAAA,cACvB,IAAI,OAAO;AACP,uBAAO,MAAM,YAAY,YAAY,OAAO,MAAM;AAAA,cACtD;AAAA,YACJ,CAAC;AAAA,UACD;AAAA,QA2BF;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["exports", "module", "ruleMessages"]
|
|
7
7
|
}
|
|
@@ -1,57 +1,251 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// yaml-file:/Users/ritesh.kumar2/Documents/projects/stylelint-sds/packages/eslint-plugin-slds/src/config/rule-messages.yml
|
|
28
|
+
var require_rule_messages = __commonJS({
|
|
29
|
+
"yaml-file:/Users/ritesh.kumar2/Documents/projects/stylelint-sds/packages/eslint-plugin-slds/src/config/rule-messages.yml"(exports2, module2) {
|
|
30
|
+
module2.exports = {
|
|
31
|
+
"no-slds-class-overrides": {
|
|
32
|
+
"description": "Create new custom CSS classes instead of overriding SLDS selectors",
|
|
33
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides",
|
|
34
|
+
"type": "problem",
|
|
35
|
+
"messages": {
|
|
36
|
+
"sldsClassOverride": "Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button."
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"no-deprecated-slds-classes": {
|
|
40
|
+
"description": "Please replace the deprecated classes with a modern equivalent",
|
|
41
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes",
|
|
42
|
+
"type": "problem",
|
|
43
|
+
"messages": {
|
|
44
|
+
"deprecatedClass": "The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class."
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"no-deprecated-tokens-slds1": {
|
|
48
|
+
"description": "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.",
|
|
49
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1",
|
|
50
|
+
"type": "problem",
|
|
51
|
+
"messages": {
|
|
52
|
+
"deprecatedToken": "Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com.",
|
|
53
|
+
"noReplacement": "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com."
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"enforce-sds-to-slds-hooks": {
|
|
57
|
+
"description": "Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info.",
|
|
58
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks",
|
|
59
|
+
"type": "problem",
|
|
60
|
+
"messages": {
|
|
61
|
+
"replaceSdsWithSlds": "Replace {{oldValue}} with {{suggestedMatch}} styling hook."
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"enforce-bem-usage": {
|
|
65
|
+
"description": "Replace BEM double-dash syntax in class names with single underscore syntax",
|
|
66
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage",
|
|
67
|
+
"type": "problem",
|
|
68
|
+
"messages": {
|
|
69
|
+
"bemDoubleDash": "{{actual}} has been retired. Update it to the new name {{newValue}}.",
|
|
70
|
+
"fixBemNaming": "Update to correct BEM naming convention"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"modal-close-button-issue": {
|
|
74
|
+
"description": "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint",
|
|
75
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue",
|
|
76
|
+
"type": "problem",
|
|
77
|
+
"messages": {
|
|
78
|
+
"modalCloseButtonIssue": "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.",
|
|
79
|
+
"removeClass": "Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.",
|
|
80
|
+
"changeVariant": "Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.",
|
|
81
|
+
"removeVariant": "Remove the variant attribute from the <lightning-icon> component inside the <button> element.",
|
|
82
|
+
"ensureButtonClasses": "Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.",
|
|
83
|
+
"ensureSizeAttribute": "To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components."
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"no-deprecated-classes-slds2": {
|
|
87
|
+
"description": "Replace classes that aren't available with SLDS 2 classes",
|
|
88
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2",
|
|
89
|
+
"type": "problem",
|
|
90
|
+
"messages": {
|
|
91
|
+
"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.",
|
|
92
|
+
"updateToModernClass": "Replace deprecated class with modern equivalent",
|
|
93
|
+
"checkDocumentation": "See lightningdesignsystem.com for SLDS 2 class alternatives"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"lwc-token-to-slds-hook": {
|
|
97
|
+
"description": "Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info.",
|
|
98
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook",
|
|
99
|
+
"type": "problem",
|
|
100
|
+
"messages": {
|
|
101
|
+
"errorWithReplacement": "The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.",
|
|
102
|
+
"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.",
|
|
103
|
+
"errorWithNoRecommendation": "The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com."
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"no-sldshook-fallback-for-lwctoken": {
|
|
107
|
+
"description": "Avoid using --slds styling hooks as fallback values for --lwc tokens.",
|
|
108
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken",
|
|
109
|
+
"type": "problem",
|
|
110
|
+
"messages": {
|
|
111
|
+
"unsupportedFallback": "Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}."
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"no-unsupported-hooks-slds2": {
|
|
115
|
+
"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.",
|
|
116
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2",
|
|
117
|
+
"type": "problem",
|
|
118
|
+
"messages": {
|
|
119
|
+
"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."
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"no-slds-var-without-fallback": {
|
|
123
|
+
"description": "Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable.",
|
|
124
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback",
|
|
125
|
+
"type": "problem",
|
|
126
|
+
"messages": {
|
|
127
|
+
"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."
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"no-slds-namespace-for-custom-hooks": {
|
|
131
|
+
"description": "To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace.",
|
|
132
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks",
|
|
133
|
+
"type": "problem",
|
|
134
|
+
"messages": {
|
|
135
|
+
"customHookNamespace": "Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"no-slds-private-var": {
|
|
139
|
+
"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.",
|
|
140
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var",
|
|
141
|
+
"type": "problem",
|
|
142
|
+
"messages": {
|
|
143
|
+
"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."
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"enforce-component-hook-naming-convention": {
|
|
147
|
+
"description": "Replace component styling hooks that use a deprecated naming convention.",
|
|
148
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention",
|
|
149
|
+
"type": "problem",
|
|
150
|
+
"messages": {
|
|
151
|
+
"replace": "Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}."
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"no-hardcoded-values-slds1": {
|
|
155
|
+
"description": "Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com.",
|
|
156
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value",
|
|
157
|
+
"type": "suggestion",
|
|
158
|
+
"messages": {
|
|
159
|
+
"hardcodedValue": "Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}.",
|
|
160
|
+
"noReplacement": "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"no-hardcoded-values-slds2": {
|
|
164
|
+
"description": "Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.",
|
|
165
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value",
|
|
166
|
+
"type": "suggestion",
|
|
167
|
+
"messages": {
|
|
168
|
+
"hardcodedValue": "Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.",
|
|
169
|
+
"noReplacement": "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"reduce-annotations": {
|
|
173
|
+
"description": "Remove your annotations and update your code.",
|
|
174
|
+
"url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations",
|
|
175
|
+
"type": "problem",
|
|
176
|
+
"messages": {
|
|
177
|
+
"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/"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// src/utils/node.ts
|
|
185
|
+
var import_parser = require("@html-eslint/parser");
|
|
186
|
+
function findAttr(node, key) {
|
|
187
|
+
return node.attributes.find(
|
|
188
|
+
(attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase()
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
function isAttributesEmpty(node) {
|
|
192
|
+
return !node.attributes || node.attributes.length <= 0;
|
|
193
|
+
}
|
|
194
|
+
var lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
|
|
195
|
+
var lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
|
|
196
|
+
|
|
197
|
+
// src/rules/no-deprecated-classes-slds2.ts
|
|
198
|
+
var import_sds_metadata = __toESM(require("@salesforce-ux/sds-metadata"));
|
|
199
|
+
var import_rule_messages = __toESM(require_rule_messages());
|
|
200
|
+
var deprecatedClasses = import_sds_metadata.default.deprecatedClasses;
|
|
201
|
+
var ruleConfig = import_rule_messages.default["no-deprecated-classes-slds2"];
|
|
8
202
|
module.exports = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
schema: [], // No additional options needed
|
|
18
|
-
},
|
|
19
|
-
create(context) {
|
|
20
|
-
function check(node) {
|
|
21
|
-
if ((0, node_1.isAttributesEmpty)(node)) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const classAttr = (0, node_1.findAttr)(node, "class");
|
|
25
|
-
if (classAttr && classAttr.value) {
|
|
26
|
-
const classNames = classAttr.value.value.split(/\s+/);
|
|
27
|
-
classNames.forEach((className) => {
|
|
28
|
-
if (className && deprecatedClasses.includes(className)) {
|
|
29
|
-
// Find the exact location of the problematic class name
|
|
30
|
-
const classNameStart = classAttr.value.value.indexOf(className) + 7; // 7 here is for `class= "`
|
|
31
|
-
const classNameEnd = classNameStart + className.length;
|
|
32
|
-
// Use the loc property to get line and column from the class attribute
|
|
33
|
-
const startLoc = {
|
|
34
|
-
line: classAttr.loc.start.line,
|
|
35
|
-
column: classAttr.loc.start.column + classNameStart,
|
|
36
|
-
};
|
|
37
|
-
const endLoc = {
|
|
38
|
-
line: classAttr.loc.start.line,
|
|
39
|
-
column: classAttr.loc.start.column + classNameEnd,
|
|
40
|
-
};
|
|
41
|
-
context.report({
|
|
42
|
-
node,
|
|
43
|
-
loc: { start: startLoc, end: endLoc },
|
|
44
|
-
data: {
|
|
45
|
-
className,
|
|
46
|
-
},
|
|
47
|
-
message: "The class {{className}} isn't available in SLDS 2. Update it to a class supported in SLDS 2. See lightningdesignsystem.com for more information.",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
Tag: check,
|
|
55
|
-
};
|
|
203
|
+
meta: {
|
|
204
|
+
type: ruleConfig.type,
|
|
205
|
+
docs: {
|
|
206
|
+
category: "Best Practices",
|
|
207
|
+
recommended: true,
|
|
208
|
+
description: ruleConfig.description,
|
|
209
|
+
url: ruleConfig.url
|
|
56
210
|
},
|
|
211
|
+
schema: [],
|
|
212
|
+
messages: ruleConfig.messages
|
|
213
|
+
},
|
|
214
|
+
create(context) {
|
|
215
|
+
function check(node) {
|
|
216
|
+
if (isAttributesEmpty(node)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const classAttr = findAttr(node, "class");
|
|
220
|
+
if (classAttr && classAttr.value) {
|
|
221
|
+
const classNames = classAttr.value.value.split(/\s+/);
|
|
222
|
+
classNames.forEach((className) => {
|
|
223
|
+
if (className && deprecatedClasses.includes(className)) {
|
|
224
|
+
const classNameStart = classAttr.value.value.indexOf(className) + 7;
|
|
225
|
+
const classNameEnd = classNameStart + className.length;
|
|
226
|
+
const startLoc = {
|
|
227
|
+
line: classAttr.loc.start.line,
|
|
228
|
+
column: classAttr.loc.start.column + classNameStart
|
|
229
|
+
};
|
|
230
|
+
const endLoc = {
|
|
231
|
+
line: classAttr.loc.start.line,
|
|
232
|
+
column: classAttr.loc.start.column + classNameEnd
|
|
233
|
+
};
|
|
234
|
+
context.report({
|
|
235
|
+
node,
|
|
236
|
+
loc: { start: startLoc, end: endLoc },
|
|
237
|
+
messageId: "deprecatedClass",
|
|
238
|
+
data: {
|
|
239
|
+
className
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
Tag: check
|
|
248
|
+
};
|
|
249
|
+
}
|
|
57
250
|
};
|
|
251
|
+
//# sourceMappingURL=no-deprecated-classes-slds2.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
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};\n", "import { findAttr, isAttributesEmpty } from \"./utils/node\";\nimport metadata from '@salesforce-ux/sds-metadata';\nconst deprecatedClasses = metadata.deprecatedClasses;\n\nexport = {\n meta: {\n type: \"problem\", // The rule type\n docs: {\n category: \"Best Practices\",\n recommended: true,\n description: \"Replace classes that aren\u2019t available with SLDS 2 classes. See lightningdesignsystem.com for more info.\",\n url : \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2\"\n },\n schema: [], // No additional options needed\n },\n\n create(context) {\n\n function check(node) {\n if (isAttributesEmpty(node)) {\n return;\n }\n\n const classAttr = findAttr(node, \"class\");\n if (classAttr && classAttr.value) {\n const classNames = classAttr.value.value.split(/\\s+/);\n classNames.forEach((className) => {\n if (className && deprecatedClasses.includes(className)) {\n // Find the exact location of the problematic class name\n const classNameStart = classAttr.value.value.indexOf(className) +7; // 7 here is for `class= \"`\n const classNameEnd = classNameStart + className.length;\n\n // Use the loc property to get line and column from the class attribute\n const startLoc = {\n line: classAttr.loc.start.line,\n column: classAttr.loc.start.column + classNameStart,\n };\n const endLoc = {\n line: classAttr.loc.start.line,\n column: classAttr.loc.start.column + classNameEnd,\n };\n \n \n context.report({\n node,\n loc: { start: startLoc, end: endLoc },\n data: {\n className,\n },\n message: \"The class {{className}} isn't available in SLDS 2. Update it to a class supported in SLDS 2. See lightningdesignsystem.com for more information.\",\n });\n }\n });\n }\n }\n\n return {\n Tag: check,\n };\n },\n};"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["metadata"]
|
|
3
|
+
"sources": ["yaml-file:/Users/ritesh.kumar2/Documents/projects/stylelint-sds/packages/eslint-plugin-slds/src/config/rule-messages.yml", "../../src/utils/node.ts", "../../src/rules/no-deprecated-classes-slds2.ts"],
|
|
4
|
+
"sourcesContent": ["module.exports = {\n \"no-slds-class-overrides\": {\n \"description\": \"Create new custom CSS classes instead of overriding SLDS selectors\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides\",\n \"type\": \"problem\",\n \"messages\": {\n \"sldsClassOverride\": \"Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button.\"\n }\n },\n \"no-deprecated-slds-classes\": {\n \"description\": \"Please replace the deprecated classes with a modern equivalent\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedClass\": \"The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class.\"\n }\n },\n \"no-deprecated-tokens-slds1\": {\n \"description\": \"Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1\",\n \"type\": \"problem\",\n \"messages\": {\n \"deprecatedToken\": \"Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com.\",\n \"noReplacement\": \"Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com.\"\n }\n },\n \"enforce-sds-to-slds-hooks\": {\n \"description\": \"Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks\",\n \"type\": \"problem\",\n \"messages\": {\n \"replaceSdsWithSlds\": \"Replace {{oldValue}} with {{suggestedMatch}} styling hook.\"\n }\n },\n \"enforce-bem-usage\": {\n \"description\": \"Replace BEM double-dash syntax in class names with single underscore syntax\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage\",\n \"type\": \"problem\",\n \"messages\": {\n \"bemDoubleDash\": \"{{actual}} has been retired. Update it to the new name {{newValue}}.\",\n \"fixBemNaming\": \"Update to correct BEM naming convention\"\n }\n },\n \"modal-close-button-issue\": {\n \"description\": \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue\",\n \"type\": \"problem\",\n \"messages\": {\n \"modalCloseButtonIssue\": \"Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint.\",\n \"removeClass\": \"Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.\",\n \"changeVariant\": \"Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.\",\n \"removeVariant\": \"Remove the variant attribute from the <lightning-icon> component inside the <button> element.\",\n \"ensureButtonClasses\": \"Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.\",\n \"ensureSizeAttribute\": \"To size icons properly, set the size attribute \u200Cto large in the <lightning-icon> and <lightning-button-icon> components.\"\n }\n },\n \"no-deprecated-classes-slds2\": {\n \"description\": \"Replace classes that aren't available with SLDS 2 classes\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\",\n \"updateToModernClass\": \"Replace deprecated class with modern equivalent\",\n \"checkDocumentation\": \"See lightningdesignsystem.com for SLDS 2 class alternatives\"\n }\n },\n \"lwc-token-to-slds-hook\": {\n \"description\": \"Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook\",\n \"type\": \"problem\",\n \"messages\": {\n \"errorWithReplacement\": \"The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com.\",\n \"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.\",\n \"errorWithNoRecommendation\": \"The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com.\"\n }\n },\n \"no-sldshook-fallback-for-lwctoken\": {\n \"description\": \"Avoid using --slds styling hooks as fallback values for --lwc tokens.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken\",\n \"type\": \"problem\",\n \"messages\": {\n \"unsupportedFallback\": \"Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}.\"\n }\n },\n \"no-unsupported-hooks-slds2\": {\n \"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.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\"\n }\n },\n \"no-slds-var-without-fallback\": {\n \"description\": \"Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\"\n }\n },\n \"no-slds-namespace-for-custom-hooks\": {\n \"description\": \"To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks\",\n \"type\": \"problem\",\n \"messages\": {\n \"customHookNamespace\": \"Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}\"\n }\n },\n \"no-slds-private-var\": {\n \"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.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var\",\n \"type\": \"problem\",\n \"messages\": {\n \"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.\"\n }\n },\n \"enforce-component-hook-naming-convention\": {\n \"description\": \"Replace component styling hooks that use a deprecated naming convention.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention\",\n \"type\": \"problem\",\n \"messages\": {\n \"replace\": \"Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}.\"\n }\n },\n \"no-hardcoded-values-slds1\": {\n \"description\": \"Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value\",\n \"type\": \"suggestion\",\n \"messages\": {\n \"hardcodedValue\": \"Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}.\",\n \"noReplacement\": \"There's no replacement styling hook for the {{oldValue}} static value. Remove the static value.\"\n }\n },\n \"no-hardcoded-values-slds2\": {\n \"description\": \"Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value\",\n \"type\": \"suggestion\",\n \"messages\": {\n \"hardcodedValue\": \"Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.\",\n \"noReplacement\": \"There's no replacement styling hook for the {{oldValue}} static value. Remove the static value.\"\n }\n },\n \"reduce-annotations\": {\n \"description\": \"Remove your annotations and update your code.\",\n \"url\": \"https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations\",\n \"type\": \"problem\",\n \"messages\": {\n \"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/\"\n }\n }\n};", "// 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};", "import { Rule } from 'eslint';\nimport { findAttr, isAttributesEmpty } from \"../utils/node\";\nimport metadata from '@salesforce-ux/sds-metadata';\nimport ruleMessages from '../config/rule-messages.yml';\n\nconst deprecatedClasses = metadata.deprecatedClasses;\nconst ruleConfig = ruleMessages['no-deprecated-classes-slds2'];\n\nexport = {\n meta: {\n type: ruleConfig.type,\n docs: {\n category: \"Best Practices\",\n recommended: true,\n description: ruleConfig.description,\n url: ruleConfig.url\n },\n schema: [],\n messages: ruleConfig.messages,\n },\n\n create(context) {\n\n function check(node) {\n if (isAttributesEmpty(node)) {\n return;\n }\n\n const classAttr = findAttr(node, \"class\");\n if (classAttr && classAttr.value) {\n const classNames = classAttr.value.value.split(/\\s+/);\n classNames.forEach((className) => {\n if (className && deprecatedClasses.includes(className)) {\n // Find the exact location of the problematic class name\n const classNameStart = classAttr.value.value.indexOf(className) +7; // 7 here is for `class= \"`\n const classNameEnd = classNameStart + className.length;\n\n // Use the loc property to get line and column from the class attribute\n const startLoc = {\n line: classAttr.loc.start.line,\n column: classAttr.loc.start.column + classNameStart,\n };\n const endLoc = {\n line: classAttr.loc.start.line,\n column: classAttr.loc.start.column + classNameEnd,\n };\n \n \n context.report({\n node,\n loc: { start: startLoc, end: endLoc },\n messageId: 'deprecatedClass',\n data: {\n className,\n },\n });\n }\n });\n }\n }\n\n return {\n Tag: check,\n };\n },\n};"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,6HAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAO,UAAU;AAAA,MACf,2BAA2B;AAAA,QACzB,eAAe;AAAA,QACf,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,YAAY;AAAA,UACV,qBAAqB;AAAA,QACvB;AAAA,MACF;AAAA,MACA,8BAA8B;AAAA,QAC5B,eAAe;AAAA,QACf,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,YAAY;AAAA,UACV,mBAAmB;AAAA,QACrB;AAAA,MACF;AAAA,MACA,8BAA8B;AAAA,QAC5B,eAAe;AAAA,QACf,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,YAAY;AAAA,UACV,mBAAmB;AAAA,UACnB,iBAAiB;AAAA,QACnB;AA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