@salesforce-ux/eslint-plugin-slds 0.1.4-alpha.2 → 0.1.4-alpha.3

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.
@@ -59,10 +59,15 @@ module.exports = {
59
59
  function validateClassAttr(attribute, attrName) {
60
60
  if (attribute && attribute.value) {
61
61
  const classList = attribute.value.value.split(/\s+/);
62
+ // Irrespective of whether we are checking for class or icon-class we need to check whether the attribute is present or not.
62
63
  // ✅ Ensure "slds-modal__close" exists before proceeding
63
- if (!classList.includes("slds-modal__close")) {
64
- return; // Stop execution if the class is missing
64
+ if (!classAttr?.value?.value?.includes("slds-modal__close")) {
65
+ return;
65
66
  }
67
+ // ✅ Ensure "slds-modal__close" exists before proceeding
68
+ // if (!classList.includes("slds-modal__close")) {
69
+ // return; // Stop execution if the class is missing
70
+ // }
66
71
  // Remove inverse classes
67
72
  if (classList.includes("slds-button_icon-inverse") || classList.includes("slds-button--icon-inverse")) {
68
73
  context.report({
@@ -84,12 +89,25 @@ module.exports = {
84
89
  node: attribute,
85
90
  messageId: "ensureButtonClasses",
86
91
  fix(fixer) {
87
- const newClassList = [
88
- "slds-button",
89
- "slds-button_icon",
90
- ...classList.filter((cls) => cls !== "slds-button_icon-inverse"),
91
- ].join(" ");
92
- return fixer.replaceText(attribute.value, `"${newClassList}"`);
92
+ let newClassList;
93
+ if (attrName === 'icon-class') {
94
+ newClassList = [
95
+ ...classList.filter((cls) => cls !== "slds-button_icon-inverse"),
96
+ ].join(" ");
97
+ }
98
+ else {
99
+ newClassList = [
100
+ "slds-button",
101
+ "slds-button_icon",
102
+ ...classList.filter((cls) => cls !== "slds-button_icon-inverse"),
103
+ ].join(" ");
104
+ }
105
+ // const newClassList = [
106
+ // "slds-button",
107
+ // "slds-button_icon",
108
+ // ...classList.filter((cls) => cls !== "slds-button_icon-inverse"),
109
+ // ].join(" ");
110
+ return fixer.replaceText(attribute.value, `${newClassList}`);
93
111
  },
94
112
  });
95
113
  }
@@ -138,20 +156,20 @@ module.exports = {
138
156
  node: variantAttr,
139
157
  messageId: "changeVariant",
140
158
  fix(fixer) {
141
- return fixer.replaceText(variantAttr.value, `"bare"`);
142
- },
143
- });
144
- }
145
- // Remove variant attribute completely
146
- if (variantAttr) {
147
- context.report({
148
- node: variantAttr,
149
- messageId: "removeVariant",
150
- fix(fixer) {
151
- return fixer.remove(variantAttr);
159
+ return fixer.replaceText(variantAttr.value, "bare");
152
160
  },
153
161
  });
154
162
  }
163
+ // // Remove variant attribute completely
164
+ // if (variantAttr) {
165
+ // context.report({
166
+ // node: variantAttr,
167
+ // messageId: "removeVariant",
168
+ // fix(fixer) {
169
+ // return fixer.remove(variantAttr);
170
+ // },
171
+ // });
172
+ // }
155
173
  //Ensure size="large" is set
156
174
  if (!sizeAttr) {
157
175
  context.report({
@@ -160,7 +178,7 @@ module.exports = {
160
178
  fix(fixer) {
161
179
  //return fixer.insertTextAfter(node, ' size="large"');
162
180
  if (variantAttr) {
163
- return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], 'size="large"');
181
+ return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"');
164
182
  }
165
183
  },
166
184
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/eslint-plugin-slds",
3
- "version": "0.1.4-alpha.2",
3
+ "version": "0.1.4-alpha.3",
4
4
  "main": "build/index.js",
5
5
  "files": [
6
6
  "build/*",