@salesforce-ux/eslint-plugin-slds 0.5.2 → 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.
Files changed (117) hide show
  1. package/build/index.js +2365 -50
  2. package/build/index.js.map +4 -4
  3. package/build/rules/enforce-bem-usage.js +325 -85
  4. package/build/rules/enforce-bem-usage.js.map +4 -4
  5. package/build/rules/modal-close-button-issue.js +324 -179
  6. package/build/rules/modal-close-button-issue.js.map +4 -4
  7. package/build/rules/no-deprecated-classes-slds2.js +247 -53
  8. package/build/rules/no-deprecated-classes-slds2.js.map +4 -4
  9. package/build/rules/v9/enforce-bem-usage.js +236 -0
  10. package/build/rules/v9/enforce-bem-usage.js.map +7 -0
  11. package/build/rules/v9/enforce-component-hook-naming-convention.js +262 -0
  12. package/build/rules/v9/enforce-component-hook-naming-convention.js.map +7 -0
  13. package/build/rules/v9/enforce-sds-to-slds-hooks.js +260 -0
  14. package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +7 -0
  15. package/build/rules/v9/lwc-token-to-slds-hook.js +369 -0
  16. package/build/rules/v9/lwc-token-to-slds-hook.js.map +7 -0
  17. package/build/rules/v9/no-deprecated-slds-classes.js +227 -0
  18. package/build/rules/v9/no-deprecated-slds-classes.js.map +7 -0
  19. package/build/rules/v9/no-deprecated-tokens-slds1.js +270 -0
  20. package/build/rules/v9/no-deprecated-tokens-slds1.js.map +7 -0
  21. package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +334 -0
  22. package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +7 -0
  23. package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +355 -0
  24. package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +7 -0
  25. package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +355 -0
  26. package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +7 -0
  27. package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +399 -0
  28. package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +7 -0
  29. package/build/rules/v9/no-hardcoded-values/handlers/index.js +830 -0
  30. package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +7 -0
  31. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +1132 -0
  32. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +7 -0
  33. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +1132 -0
  34. package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +7 -0
  35. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +963 -0
  36. package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +7 -0
  37. package/build/rules/v9/no-slds-class-overrides.js +233 -0
  38. package/build/rules/v9/no-slds-class-overrides.js.map +7 -0
  39. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +250 -0
  40. package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +7 -0
  41. package/build/rules/v9/no-slds-private-var.js +230 -0
  42. package/build/rules/v9/no-slds-private-var.js.map +7 -0
  43. package/build/rules/v9/no-slds-var-without-fallback.js +339 -0
  44. package/build/rules/v9/no-slds-var-without-fallback.js.map +7 -0
  45. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +253 -0
  46. package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +7 -0
  47. package/build/rules/v9/no-unsupported-hooks-slds2.js +243 -0
  48. package/build/rules/v9/no-unsupported-hooks-slds2.js.map +7 -0
  49. package/build/rules/v9/reduce-annotations.js +234 -0
  50. package/build/rules/v9/reduce-annotations.js.map +7 -0
  51. package/build/src/rules/enforce-bem-usage.d.ts +17 -0
  52. package/build/{rules → src/rules}/modal-close-button-issue.d.ts +2 -1
  53. package/build/{rules → src/rules}/no-deprecated-classes-slds2.d.ts +2 -1
  54. package/build/src/rules/v9/enforce-bem-usage.d.ts +3 -0
  55. package/build/src/rules/v9/enforce-component-hook-naming-convention.d.ts +3 -0
  56. package/build/src/rules/v9/enforce-sds-to-slds-hooks.d.ts +3 -0
  57. package/build/src/rules/v9/lwc-token-to-slds-hook.d.ts +3 -0
  58. package/build/src/rules/v9/no-deprecated-slds-classes.d.ts +3 -0
  59. package/build/src/rules/v9/no-deprecated-tokens-slds1.d.ts +3 -0
  60. package/build/src/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.d.ts +5 -0
  61. package/build/src/rules/v9/no-hardcoded-values/handlers/colorHandler.d.ts +7 -0
  62. package/build/src/rules/v9/no-hardcoded-values/handlers/densityHandler.d.ts +7 -0
  63. package/build/src/rules/v9/no-hardcoded-values/handlers/fontHandler.d.ts +6 -0
  64. package/build/src/rules/v9/no-hardcoded-values/handlers/index.d.ts +8 -0
  65. package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.d.ts +3 -0
  66. package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.d.ts +3 -0
  67. package/build/src/rules/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +11 -0
  68. package/build/src/rules/v9/no-slds-class-overrides.d.ts +8 -0
  69. package/build/src/rules/v9/no-slds-namespace-for-custom-hooks.d.ts +3 -0
  70. package/build/src/rules/v9/no-slds-private-var.d.ts +3 -0
  71. package/build/src/rules/v9/no-slds-var-without-fallback.d.ts +7 -0
  72. package/build/src/rules/v9/no-sldshook-fallback-for-lwctoken.d.ts +3 -0
  73. package/build/src/rules/v9/no-unsupported-hooks-slds2.d.ts +3 -0
  74. package/build/src/rules/v9/reduce-annotations.d.ts +3 -0
  75. package/build/src/types/index.d.ts +26 -0
  76. package/build/src/utils/boxShadowValueParser.d.ts +17 -0
  77. package/build/src/utils/color-lib-utils.d.ts +18 -0
  78. package/build/src/utils/css-functions.d.ts +7 -0
  79. package/build/src/utils/css-utils.d.ts +26 -0
  80. package/build/src/utils/hardcoded-shared-utils.d.ts +60 -0
  81. package/build/src/utils/property-matcher.d.ts +23 -0
  82. package/build/src/utils/rule-utils.d.ts +8 -0
  83. package/build/src/utils/styling-hook-utils.d.ts +7 -0
  84. package/build/src/utils/value-utils.d.ts +41 -0
  85. package/build/types/index.js +18 -0
  86. package/build/types/index.js.map +7 -0
  87. package/build/types/yaml.d.js +1 -0
  88. package/build/types/yaml.d.js.map +7 -0
  89. package/build/utils/boxShadowValueParser.js +200 -0
  90. package/build/utils/boxShadowValueParser.js.map +7 -0
  91. package/build/utils/color-lib-utils.js +160 -0
  92. package/build/utils/color-lib-utils.js.map +7 -0
  93. package/build/utils/css-functions.js +68 -0
  94. package/build/utils/css-functions.js.map +7 -0
  95. package/build/utils/css-utils.js +141 -0
  96. package/build/utils/css-utils.js.map +7 -0
  97. package/build/utils/hardcoded-shared-utils.js +303 -0
  98. package/build/utils/hardcoded-shared-utils.js.map +7 -0
  99. package/build/utils/node.js +158 -0
  100. package/build/{rules/utils → utils}/node.js.map +2 -2
  101. package/build/utils/property-matcher.js +159 -0
  102. package/build/utils/property-matcher.js.map +7 -0
  103. package/build/utils/rule-utils.js +46 -0
  104. package/build/utils/rule-utils.js.map +7 -0
  105. package/build/utils/styling-hook-utils.js +83 -0
  106. package/build/utils/styling-hook-utils.js.map +7 -0
  107. package/build/utils/value-utils.js +70 -0
  108. package/build/utils/value-utils.js.map +7 -0
  109. package/package.json +9 -4
  110. package/src/config/rule-messages.yml +143 -0
  111. package/build/rules/enforce-bem-usage.d.ts +0 -28
  112. package/build/rules/utils/node.js +0 -197
  113. package/build/rules/utils/rule.d.ts +0 -7
  114. package/build/rules/utils/rule.js +0 -10
  115. package/build/rules/utils/rule.js.map +0 -7
  116. /package/build/{index.d.ts → src/index.d.ts} +0 -0
  117. /package/build/{rules → src}/utils/node.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/eslint-plugin-slds",
3
- "version": "0.5.2",
3
+ "version": "1.0.0-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"
@@ -0,0 +1,143 @@
1
+ # ESLint Rule Messages - Complete Configuration
2
+ # This file contains all rule metadata: descriptions, documentation URLs, user-facing messages etc.
3
+
4
+ # =============================================================================
5
+ # CSS Rules (ESLint v9 with @eslint/css)
6
+ # =============================================================================
7
+
8
+ no-slds-class-overrides:
9
+ description: "Create new custom CSS classes instead of overriding SLDS selectors"
10
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-class-overrides"
11
+ type: "problem"
12
+ messages:
13
+ sldsClassOverride: "Overriding .{{className}} isn't supported. To differentiate SLDS and custom classes, create a CSS class in your namespace. Examples: myapp-input, myapp-button."
14
+
15
+ no-deprecated-slds-classes:
16
+ description: "Please replace the deprecated classes with a modern equivalent"
17
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-slds-classes"
18
+ type: "problem"
19
+ messages:
20
+ deprecatedClass: "The class {{className}} is deprecated and not available in SLDS2. Please update to a supported class."
21
+
22
+ no-deprecated-tokens-slds1:
23
+ description: "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com."
24
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-tokens-slds1"
25
+ type: "problem"
26
+ messages:
27
+ deprecatedToken: "Consider removing {{oldValue}} or replacing it with {{newValue}}. Set the fallback to {{oldValue}}. For more info, see Styling Hooks on lightningdesignsystem.com."
28
+ noReplacement: "Update outdated design tokens to SLDS 2 styling hooks with similar values. For more information, see Styling Hooks on lightningdesignsystem.com."
29
+
30
+ enforce-sds-to-slds-hooks:
31
+ description: "Convert your existing --sds styling hooks to --slds styling hooks. See lightningdesignsystem.com for more info."
32
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-sds-to-slds-hooks"
33
+ type: "problem"
34
+ messages:
35
+ replaceSdsWithSlds: "Replace {{oldValue}} with {{suggestedMatch}} styling hook."
36
+
37
+ # =============================================================================
38
+ # HTML/Component Rules (ESLint v8 & v9)
39
+ # =============================================================================
40
+
41
+ enforce-bem-usage:
42
+ description: "Replace BEM double-dash syntax in class names with single underscore syntax"
43
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-bem-usage"
44
+ type: "problem"
45
+ messages:
46
+ bemDoubleDash: "{{actual}} has been retired. Update it to the new name {{newValue}}."
47
+ fixBemNaming: "Update to correct BEM naming convention"
48
+
49
+ modal-close-button-issue:
50
+ description: "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint"
51
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#modal-close-button-issue"
52
+ type: "problem"
53
+ messages:
54
+ modalCloseButtonIssue: "Update component attributes or CSS classes for the modal close button to comply with the modal component blueprint."
55
+ removeClass: "Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint."
56
+ changeVariant: "Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>."
57
+ removeVariant: "Remove the variant attribute from the <lightning-icon> component inside the <button> element."
58
+ ensureButtonClasses: "Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component."
59
+ ensureSizeAttribute: "To size icons properly, set the size attribute ‌to large in the <lightning-icon> and <lightning-button-icon> components."
60
+
61
+ no-deprecated-classes-slds2:
62
+ description: "Replace classes that aren't available with SLDS 2 classes"
63
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-deprecated-classes-slds2"
64
+ type: "problem"
65
+ messages:
66
+ 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."
67
+ updateToModernClass: "Replace deprecated class with modern equivalent"
68
+ checkDocumentation: "See lightningdesignsystem.com for SLDS 2 class alternatives"
69
+
70
+ lwc-token-to-slds-hook:
71
+ description: "Replace the deprecated --lwc tokens with the latest --slds tokens. See lightningdesignsystem.com for more info."
72
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#lwc-token-to-slds-hook"
73
+ type: "problem"
74
+ messages:
75
+ errorWithReplacement: "The '{{oldValue}}' design token is deprecated. Replace it with '{{newValue}}'. For more info, see Global Styling Hooks on lightningdesignsystem.com."
76
+ 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."
77
+ errorWithNoRecommendation: "The '{{oldValue}}' design token is deprecated. For more info, see the New Global Styling Hook Guidance on lightningdesignsystem.com."
78
+
79
+ no-sldshook-fallback-for-lwctoken:
80
+ description: "Avoid using --slds styling hooks as fallback values for --lwc tokens."
81
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-sldshook-fallback-for-lwctoken"
82
+ type: "problem"
83
+ messages:
84
+ unsupportedFallback: "Remove the {{sldsToken}} styling hook that is used as a fallback value for {{lwcToken}}."
85
+
86
+ no-unsupported-hooks-slds2:
87
+ 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."
88
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-unsupported-hooks-slds2"
89
+ type: "problem"
90
+ messages:
91
+ 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."
92
+
93
+ no-slds-var-without-fallback:
94
+ description: "Add fallback values to SLDS styling hooks. The fallback values are used in Salesforce environments where styling hooks are unavailable."
95
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-var-without-fallback"
96
+ type: "problem"
97
+ messages:
98
+ 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."
99
+
100
+ no-slds-namespace-for-custom-hooks:
101
+ description: "To differentiate custom styling hooks from SLDS styling hooks, create custom styling hooks in your namespace."
102
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-namespace-for-custom-hooks"
103
+ type: "problem"
104
+ messages:
105
+ customHookNamespace: "Using the --slds namespace for {{token}} isn't supported. Create the custom styling hook in your namespace. Example: --myapp-{{tokenWithoutNamespace}}"
106
+
107
+ no-slds-private-var:
108
+ 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."
109
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-slds-private-var"
110
+ type: "problem"
111
+ messages:
112
+ privateVar: "This styling hook is reserved for internal Salesforce use. Remove the --_slds- or –slds-s private variable within selector {{prop}}. For more information, look up private CSS in lightningdesignsystem.com."
113
+
114
+ enforce-component-hook-naming-convention:
115
+ description: "Replace component styling hooks that use a deprecated naming convention."
116
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#enforce-component-hook-naming-convention"
117
+ type: "problem"
118
+ messages:
119
+ replace: "Replace the deprecated {{oldValue}} component styling hook with {{suggestedMatch}}."
120
+
121
+ no-hardcoded-values-slds1:
122
+ description: "Replace static values with SLDS 1 design tokens. For more information, look up design tokens on lightningdesignsystem.com."
123
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value"
124
+ type: "suggestion"
125
+ messages:
126
+ hardcodedValue: "Replace the {{oldValue}} static value with an SLDS 1 styling hook: {{newValue}}."
127
+ noReplacement: "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
128
+
129
+ no-hardcoded-values-slds2:
130
+ description: "Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com."
131
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value"
132
+ type: "suggestion"
133
+ messages:
134
+ hardcodedValue: "Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}."
135
+ noReplacement: "There's no replacement styling hook for the {{oldValue}} static value. Remove the static value."
136
+
137
+ reduce-annotations:
138
+ description: "Remove your annotations and update your code."
139
+ url: "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#reduce-annotations"
140
+ type: "problem"
141
+ messages:
142
+ 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/"
143
+
@@ -1,28 +0,0 @@
1
- declare const _default: {
2
- meta: {
3
- type: string;
4
- docs: {
5
- category: string;
6
- recommended: boolean;
7
- description: string;
8
- url: string;
9
- };
10
- fixable: string;
11
- schema: {
12
- type: string;
13
- properties: {
14
- pattern: {
15
- type: string;
16
- };
17
- flags: {
18
- type: string;
19
- };
20
- };
21
- additionalProperties: boolean;
22
- }[];
23
- };
24
- create(context: any): {
25
- Tag: (node: any) => void;
26
- };
27
- };
28
- export = _default;
@@ -1,197 +0,0 @@
1
- "use strict";
2
- // THIS IS TAKEN FROM html-eslint
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.findAttr = findAttr;
5
- exports.isAttributesEmpty = isAttributesEmpty;
6
- exports.isNodeTokensOnSameLine = isNodeTokensOnSameLine;
7
- exports.splitToLineNodes = splitToLineNodes;
8
- exports.getLocBetween = getLocBetween;
9
- exports.isExpressionInTemplate = isExpressionInTemplate;
10
- exports.isTag = isTag;
11
- exports.isComment = isComment;
12
- exports.isText = isText;
13
- exports.isOverlapWithTemplates = isOverlapWithTemplates;
14
- exports.codeToLines = codeToLines;
15
- exports.isRangesOverlap = isRangesOverlap;
16
- exports.getTemplateTokens = getTemplateTokens;
17
- const parser_1 = require("@html-eslint/parser");
18
- /**
19
- * @param {TagNode | ScriptTagNode | StyleTagNode} node
20
- * @param {string} key
21
- * @returns {AttributeNode | undefined}
22
- */
23
- function findAttr(node, key) {
24
- return node.attributes.find((attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase());
25
- }
26
- /**
27
- * Checks whether a node's attributes is empty or not.
28
- * @param {TagNode | ScriptTagNode | StyleTagNode} node
29
- * @returns {boolean}
30
- */
31
- function isAttributesEmpty(node) {
32
- return !node.attributes || node.attributes.length <= 0;
33
- }
34
- /**
35
- * Checks whether a node's all tokens are on the same line or not.
36
- * @param {AnyNode} node A node to check
37
- * @returns {boolean} `true` if a node's tokens are on the same line, otherwise `false`.
38
- */
39
- function isNodeTokensOnSameLine(node) {
40
- return node.loc.start.line === node.loc.end.line;
41
- }
42
- /**
43
- *
44
- * @param {Range} rangeA
45
- * @param {Range} rangeB
46
- * @returns {boolean}
47
- */
48
- function isRangesOverlap(rangeA, rangeB) {
49
- return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];
50
- }
51
- /**
52
- * @param {(TextNode | CommentContentNode)['templates']} templates
53
- * @param {Range} range
54
- * @returns {boolean}
55
- */
56
- function isOverlapWithTemplates(templates, range) {
57
- return templates
58
- .filter((template) => template.isTemplate)
59
- .some((template) => isRangesOverlap(template.range, range));
60
- }
61
- /**
62
- *
63
- * @param {TextNode | CommentContentNode} node
64
- * @returns {LineNode[]}
65
- */
66
- function splitToLineNodes(node) {
67
- let start = node.range[0];
68
- let line = node.loc.start.line;
69
- const startCol = node.loc.start.column;
70
- /**
71
- * @type {LineNode[]}
72
- */
73
- const lineNodes = [];
74
- const templates = node.templates || [];
75
- /**
76
- *
77
- * @param {import("../../types").Range} range
78
- */
79
- function shouldSkipIndentCheck(range) {
80
- const overlappedTemplates = templates.filter((template) => template.isTemplate && isRangesOverlap(template.range, range));
81
- const isLineInTemplate = overlappedTemplates.some((template) => {
82
- return template.range[0] <= range[0] && template.range[1] >= range[1];
83
- });
84
- if (isLineInTemplate) {
85
- return true;
86
- }
87
- const isLineBeforeTemplate = overlappedTemplates.some((template) => {
88
- return template.range[0] <= range[0] && template.range[1] <= range[1];
89
- });
90
- if (isLineBeforeTemplate) {
91
- return true;
92
- }
93
- const isLineAfterTemplate = overlappedTemplates.some((template) => {
94
- return template.range[1] <= range[0];
95
- });
96
- if (isLineAfterTemplate) {
97
- return true;
98
- }
99
- return false;
100
- }
101
- node.value.split("\n").forEach((value, index) => {
102
- const columnStart = index === 0 ? startCol : 0;
103
- /**
104
- * @type {import("../../types").Range}
105
- */
106
- const range = [start, start + value.length];
107
- const loc = {
108
- start: {
109
- line,
110
- column: columnStart,
111
- },
112
- end: {
113
- line,
114
- column: columnStart + value.length,
115
- },
116
- };
117
- /**
118
- * @type {LineNode}
119
- */
120
- const lineNode = {
121
- type: "Line",
122
- value,
123
- range,
124
- loc,
125
- skipIndentCheck: shouldSkipIndentCheck(range),
126
- };
127
- start += value.length + 1;
128
- line += 1;
129
- lineNodes.push(lineNode);
130
- });
131
- return lineNodes;
132
- }
133
- /**
134
- * Get location between two nodes.
135
- * @param {BaseNode} before A node placed in before
136
- * @param {BaseNode} after A node placed in after
137
- * @returns {Location} location between two nodes.
138
- */
139
- function getLocBetween(before, after) {
140
- return {
141
- start: before.loc.end,
142
- end: after.loc.start,
143
- };
144
- }
145
- /**
146
- * @param {AttributeValueNode} node
147
- * @return {boolean}
148
- */
149
- function isExpressionInTemplate(node) {
150
- if (node.type === parser_1.NODE_TYPES.AttributeValue) {
151
- return node.value.indexOf("${") === 0;
152
- }
153
- return false;
154
- }
155
- /**
156
- * @param {AnyNode} node
157
- * @returns {node is TagNode}
158
- */
159
- function isTag(node) {
160
- return node.type === parser_1.NODE_TYPES.Tag;
161
- }
162
- /**
163
- * @param {AnyNode} node
164
- * @returns {node is CommentNode}
165
- */
166
- function isComment(node) {
167
- return node.type === parser_1.NODE_TYPES.Comment;
168
- }
169
- /**
170
- * @param {AnyNode} node
171
- * @returns {node is TextNode}
172
- */
173
- function isText(node) {
174
- return node.type === parser_1.NODE_TYPES.Text;
175
- }
176
- const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
177
- const lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
178
- /**
179
- * @param {string} source
180
- * @returns {string[]}
181
- */
182
- function codeToLines(source) {
183
- return source.split(lineEndingPattern);
184
- }
185
- /**
186
- *
187
- * @param {AnyToken[]} tokens
188
- * @returns {((CommentContentNode | TextNode)['templates'][number])[]}
189
- */
190
- function getTemplateTokens(tokens) {
191
- return ([]
192
- .concat(...tokens
193
- // @ts-ignore
194
- .map((token) => token["templates"] || []))
195
- // @ts-ignore
196
- .filter((token) => token.isTemplate));
197
- }
@@ -1,7 +0,0 @@
1
- export declare const messages: {
2
- removeClass: string;
3
- changeVariant: string;
4
- removeVariant: string;
5
- ensureButtonClasses: string;
6
- ensureSizeAttribute: string;
7
- };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.messages = void 0;
4
- exports.messages = {
5
- removeClass: "Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.",
6
- changeVariant: "Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.",
7
- removeVariant: "Remove the variant attribute from the <lightning-icon> component inside the <button> element.",
8
- ensureButtonClasses: "Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.",
9
- ensureSizeAttribute: "To size icons properly, set the size attribute ‌to large in the <lightning-icon> and <lightning-button-icon> components.",
10
- };
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/rules/utils/rule.ts"],
4
- "sourcesContent": ["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 }"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,WAAU;AAAA,EACf,aACE;AAAA,EACF,eACE;AAAA,EACF,eACE;AAAA,EACF,qBACE;AAAA,EACF,qBACE;AACJ;",
6
- "names": []
7
- }
File without changes
File without changes