@salesforce-ux/eslint-plugin-slds 0.0.12-alpha.0 → 0.0.12-alpha.6
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/.eslintrc.yml +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -2
- package/build/rules/bem-mapping.d.ts +1172 -0
- package/build/rules/bem-mapping.js +1175 -0
- package/build/rules/deprecatedClasses.d.ts +1 -1
- package/build/rules/deprecatedClasses.js +1 -1
- package/build/rules/enforce-bem-class.js +11 -3
- package/package.json +4 -1
- /package/build/rules/{no-deprecated-slds-classes.d.ts → no-deprecated-slds2-classes.d.ts} +0 -0
- /package/build/rules/{no-deprecated-slds-classes.js → no-deprecated-slds2-classes.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ideally we should be loading this from @salesforce-ux/metadata-slds package. But the
|
|
2
|
+
* Ideally we should be loading this from @salesforce-ux/metadata-slds package. But the eslint package in CJS and Metadata package is ESM.
|
|
3
3
|
* TODO: should avoid referencing this file.
|
|
4
4
|
*/
|
|
5
5
|
export declare const deprecatedClasses: string[];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deprecatedClasses = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Ideally we should be loading this from @salesforce-ux/metadata-slds package. But the
|
|
5
|
+
* Ideally we should be loading this from @salesforce-ux/metadata-slds package. But the eslint package in CJS and Metadata package is ESM.
|
|
6
6
|
* TODO: should avoid referencing this file.
|
|
7
7
|
*/
|
|
8
8
|
exports.deprecatedClasses = [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const node_1 = require("./utils/node");
|
|
3
|
+
const bem_mapping_1 = require("./bem-mapping");
|
|
3
4
|
module.exports = {
|
|
4
5
|
meta: {
|
|
5
6
|
type: "problem", // The rule type
|
|
@@ -25,9 +26,7 @@ module.exports = {
|
|
|
25
26
|
},
|
|
26
27
|
create(context) {
|
|
27
28
|
const pattern = /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)(__[a-z0-9]+(?:-[a-z0-9]+)*)?(--[a-z0-9]+(?:-[a-z0-9]+)*)?$/;
|
|
28
|
-
const checkNaming = (name) =>
|
|
29
|
-
return pattern.test(name);
|
|
30
|
-
};
|
|
29
|
+
const checkNaming = (name) => pattern.test(name);
|
|
31
30
|
function check(node) {
|
|
32
31
|
if ((0, node_1.isAttributesEmpty)(node)) {
|
|
33
32
|
return;
|
|
@@ -49,6 +48,8 @@ module.exports = {
|
|
|
49
48
|
line: classAttr.loc.start.line,
|
|
50
49
|
column: classAttr.loc.start.column + classNameEnd,
|
|
51
50
|
};
|
|
51
|
+
// Check whether a fixed class is available
|
|
52
|
+
const newValue = bem_mapping_1.bemMapping[className];
|
|
52
53
|
context.report({
|
|
53
54
|
node,
|
|
54
55
|
loc: { start: startLoc, end: endLoc },
|
|
@@ -56,6 +57,13 @@ module.exports = {
|
|
|
56
57
|
actual: className,
|
|
57
58
|
},
|
|
58
59
|
messageId: "wrongClassName",
|
|
60
|
+
fix(fixer) {
|
|
61
|
+
if (newValue) {
|
|
62
|
+
const newClassValue = classAttr.value.value.replace(className, newValue);
|
|
63
|
+
return fixer.replaceTextRange([classAttr.value.range[0], classAttr.value.range[1]], `${newClassValue}`);
|
|
64
|
+
}
|
|
65
|
+
return null; // Ensure a return value even if no fix is applied
|
|
66
|
+
},
|
|
59
67
|
});
|
|
60
68
|
}
|
|
61
69
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/eslint-plugin-slds",
|
|
3
|
-
"version": "0.0.12-alpha.
|
|
3
|
+
"version": "0.0.12-alpha.6",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"build/*",
|
|
@@ -16,5 +16,8 @@
|
|
|
16
16
|
"@html-eslint/eslint-plugin": "^0.34.0",
|
|
17
17
|
"@html-eslint/parser": "^0.34.0",
|
|
18
18
|
"eslint": "^8.0.0"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"registry": "https://registry.npmjs.org"
|
|
19
22
|
}
|
|
20
23
|
}
|
|
File without changes
|
|
File without changes
|