@salesforce-ux/eslint-plugin-slds 0.1.4-alpha.3 → 0.1.4
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/rules/enforce-bem-class.d.ts +0 -3
- package/build/rules/enforce-bem-class.js +1 -4
- package/build/rules/modal-close-button-issue.d.ts +0 -7
- package/build/rules/modal-close-button-issue.js +55 -60
- package/build/rules/no-deprecated-classes-slds2.d.ts +0 -3
- package/build/rules/no-deprecated-classes-slds2.js +1 -4
- package/build/rules/utils/rule.d.ts +7 -0
- package/build/rules/utils/rule.js +10 -0
- package/package.json +1 -1
|
@@ -19,9 +19,6 @@ module.exports = {
|
|
|
19
19
|
additionalProperties: false,
|
|
20
20
|
},
|
|
21
21
|
],
|
|
22
|
-
messages: {
|
|
23
|
-
suggestedMsg: "{{actual}} has been retired. Update it to the new name {{newValue}}.",
|
|
24
|
-
},
|
|
25
22
|
},
|
|
26
23
|
create(context) {
|
|
27
24
|
function check(node) {
|
|
@@ -54,7 +51,7 @@ module.exports = {
|
|
|
54
51
|
actual: className,
|
|
55
52
|
newValue
|
|
56
53
|
},
|
|
57
|
-
|
|
54
|
+
message: JSON.stringify({ message: "{{actual}} has been retired. Update it to the new name {{newValue}}.", suggestions: [newValue] }),
|
|
58
55
|
fix(fixer) {
|
|
59
56
|
if (newValue) {
|
|
60
57
|
const newClassValue = classAttr.value.value.replace(className, newValue);
|
|
@@ -7,13 +7,6 @@ declare const _default: {
|
|
|
7
7
|
};
|
|
8
8
|
fixable: string;
|
|
9
9
|
schema: any[];
|
|
10
|
-
messages: {
|
|
11
|
-
removeClass: string;
|
|
12
|
-
changeVariant: string;
|
|
13
|
-
removeVariant: string;
|
|
14
|
-
ensureButtonClasses: string;
|
|
15
|
-
ensureSizeAttribute: string;
|
|
16
|
-
};
|
|
17
10
|
};
|
|
18
11
|
create(context: any): {
|
|
19
12
|
Tag: (node: any) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const node_1 = require("./utils/node");
|
|
3
|
+
const rule_1 = require("./utils/rule");
|
|
3
4
|
module.exports = {
|
|
4
5
|
meta: {
|
|
5
6
|
type: "problem",
|
|
@@ -9,13 +10,6 @@ module.exports = {
|
|
|
9
10
|
},
|
|
10
11
|
fixable: "code",
|
|
11
12
|
schema: [],
|
|
12
|
-
messages: {
|
|
13
|
-
removeClass: "Remove the slds-button_icon-inverse class from the modal close button in components that use the SLDS modal blueprint.",
|
|
14
|
-
changeVariant: "Change the variant attribute value from bare-inverse to bare in <lightning-button-icon> or <lightning-icon>.",
|
|
15
|
-
removeVariant: "Remove the variant attribute from the <lightning-icon> component inside the <button> element.",
|
|
16
|
-
ensureButtonClasses: "Add or move slds-button and slds-button_icon to the class attribute of the <button> element or <lightning-button-icon> component.",
|
|
17
|
-
ensureSizeAttribute: "To size icons properly, set the size attribute to large in the <lightning-icon> and <lightning-button-icon> components.",
|
|
18
|
-
},
|
|
19
13
|
},
|
|
20
14
|
create(context) {
|
|
21
15
|
function check(node) {
|
|
@@ -35,13 +29,14 @@ module.exports = {
|
|
|
35
29
|
return; // Stop execution if the class is missing
|
|
36
30
|
}
|
|
37
31
|
if (classList.includes("slds-button_icon-inverse") || classList.includes("slds-button--icon-inverse")) {
|
|
32
|
+
const newClassList = classList
|
|
33
|
+
.filter((cls) => (cls !== "slds-button_icon-inverse" && cls !== "slds-button--icon-inverse"))
|
|
34
|
+
.join(" ");
|
|
38
35
|
context.report({
|
|
39
36
|
node,
|
|
40
|
-
|
|
37
|
+
loc: classAttr.loc,
|
|
38
|
+
message: JSON.stringify({ message: rule_1.messages["removeClass"], suggestions: [`class="${newClassList}"`] }),
|
|
41
39
|
fix(fixer) {
|
|
42
|
-
const newClassList = classList
|
|
43
|
-
.filter((cls) => (cls !== "slds-button_icon-inverse" && cls !== "slds-button--icon-inverse"))
|
|
44
|
-
.join(" ");
|
|
45
40
|
return fixer.replaceText(classAttr, // Replace the full attribute
|
|
46
41
|
`class="${newClassList}"` // Updated class list
|
|
47
42
|
);
|
|
@@ -70,13 +65,14 @@ module.exports = {
|
|
|
70
65
|
// }
|
|
71
66
|
// Remove inverse classes
|
|
72
67
|
if (classList.includes("slds-button_icon-inverse") || classList.includes("slds-button--icon-inverse")) {
|
|
68
|
+
const newClassList = classList
|
|
69
|
+
.filter((cls) => cls !== "slds-button_icon-inverse" && cls !== "slds-button--icon-inverse")
|
|
70
|
+
.join(" ");
|
|
73
71
|
context.report({
|
|
74
72
|
node,
|
|
75
|
-
|
|
73
|
+
loc: attribute.loc,
|
|
74
|
+
message: JSON.stringify({ message: rule_1.messages["removeClass"], suggestions: [`${attrName}="${newClassList}"`] }),
|
|
76
75
|
fix(fixer) {
|
|
77
|
-
const newClassList = classList
|
|
78
|
-
.filter((cls) => cls !== "slds-button_icon-inverse" && cls !== "slds-button--icon-inverse")
|
|
79
|
-
.join(" ");
|
|
80
76
|
return fixer.replaceText(attribute, // Replace the full attribute
|
|
81
77
|
`${attrName}="${newClassList}"` // Correctly modifies the respective attribute
|
|
82
78
|
);
|
|
@@ -85,28 +81,24 @@ module.exports = {
|
|
|
85
81
|
}
|
|
86
82
|
// Ensure 'slds-button' and 'slds-button_icon' exist
|
|
87
83
|
if (!classList.includes("slds-button") || !classList.includes("slds-button_icon")) {
|
|
84
|
+
let newClassList;
|
|
85
|
+
if (attrName === 'icon-class') {
|
|
86
|
+
newClassList = [
|
|
87
|
+
...classList.filter((cls) => cls !== "slds-button_icon-inverse"),
|
|
88
|
+
].join(" ");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
newClassList = [
|
|
92
|
+
"slds-button",
|
|
93
|
+
"slds-button_icon",
|
|
94
|
+
...classList.filter((cls) => cls !== "slds-button_icon-inverse"),
|
|
95
|
+
].join(" ");
|
|
96
|
+
}
|
|
88
97
|
context.report({
|
|
89
98
|
node: attribute,
|
|
90
|
-
|
|
99
|
+
loc: attribute.value.loc,
|
|
100
|
+
message: JSON.stringify({ message: rule_1.messages["ensureButtonClasses"], suggestions: [newClassList] }),
|
|
91
101
|
fix(fixer) {
|
|
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
102
|
return fixer.replaceText(attribute.value, `${newClassList}`);
|
|
111
103
|
},
|
|
112
104
|
});
|
|
@@ -115,24 +107,25 @@ module.exports = {
|
|
|
115
107
|
if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
|
|
116
108
|
context.report({
|
|
117
109
|
node: variantAttr,
|
|
118
|
-
|
|
110
|
+
message: JSON.stringify({ message: rule_1.messages["changeVariant"], suggestions: ["bare"] }),
|
|
111
|
+
loc: variantAttr.value.loc,
|
|
119
112
|
fix(fixer) {
|
|
120
113
|
return fixer.replaceText(variantAttr.value, `bare`);
|
|
121
114
|
},
|
|
122
115
|
});
|
|
123
116
|
}
|
|
124
117
|
// Ensure size="large" exists
|
|
125
|
-
if (!sizeAttr) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
118
|
+
// if (!sizeAttr) {
|
|
119
|
+
// context.report({
|
|
120
|
+
// node,
|
|
121
|
+
// message: messages["ensureSizeAttribute"],
|
|
122
|
+
// fix(fixer) {
|
|
123
|
+
// if (variantAttr) {
|
|
124
|
+
// return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"');
|
|
125
|
+
// }
|
|
126
|
+
// },
|
|
127
|
+
// });
|
|
128
|
+
// }
|
|
136
129
|
}
|
|
137
130
|
}
|
|
138
131
|
// ✅ Validate `class` and `icon-class` separately, maintaining their own attribute names
|
|
@@ -154,9 +147,10 @@ module.exports = {
|
|
|
154
147
|
if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
|
|
155
148
|
context.report({
|
|
156
149
|
node: variantAttr,
|
|
157
|
-
|
|
150
|
+
message: JSON.stringify({ message: rule_1.messages["changeVariant"], suggestions: ["bare"] }),
|
|
151
|
+
loc: variantAttr.value.loc,
|
|
158
152
|
fix(fixer) {
|
|
159
|
-
return fixer.replaceText(variantAttr.value,
|
|
153
|
+
return fixer.replaceText(variantAttr.value, `bare`);
|
|
160
154
|
},
|
|
161
155
|
});
|
|
162
156
|
}
|
|
@@ -171,18 +165,19 @@ module.exports = {
|
|
|
171
165
|
// });
|
|
172
166
|
// }
|
|
173
167
|
//Ensure size="large" is set
|
|
174
|
-
if (!sizeAttr) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
168
|
+
// if (!sizeAttr) {
|
|
169
|
+
// context.report({
|
|
170
|
+
// node,
|
|
171
|
+
// message: messages["ensureSizeAttribute"],
|
|
172
|
+
// fix(fixer) {
|
|
173
|
+
// //return fixer.insertTextAfter(node, ' size="large"');
|
|
174
|
+
// if(variantAttr)
|
|
175
|
+
// {
|
|
176
|
+
// return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"')
|
|
177
|
+
// }
|
|
178
|
+
// },
|
|
179
|
+
// });
|
|
180
|
+
// }
|
|
186
181
|
}
|
|
187
182
|
}
|
|
188
183
|
}
|
|
@@ -10,9 +10,6 @@ module.exports = {
|
|
|
10
10
|
recommended: true,
|
|
11
11
|
},
|
|
12
12
|
schema: [], // No additional options needed
|
|
13
|
-
messages: {
|
|
14
|
-
errorMsg: "The class {{className}} isn't available in SLDS 2. Update it to a class supported in SLDS 2. See lightningdesignsystem.com for more information.",
|
|
15
|
-
},
|
|
16
13
|
},
|
|
17
14
|
create(context) {
|
|
18
15
|
function check(node) {
|
|
@@ -42,7 +39,7 @@ module.exports = {
|
|
|
42
39
|
data: {
|
|
43
40
|
className,
|
|
44
41
|
},
|
|
45
|
-
|
|
42
|
+
message: JSON.stringify({ 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.", suggestions: [] }),
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
45
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
};
|