@salesforce-ux/eslint-plugin-slds 0.1.0 → 0.1.2-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.
@@ -2,7 +2,6 @@ declare const _default: {
2
2
  meta: {
3
3
  type: string;
4
4
  docs: {
5
- description: string;
6
5
  category: string;
7
6
  recommended: boolean;
8
7
  };
@@ -20,7 +19,7 @@ declare const _default: {
20
19
  additionalProperties: boolean;
21
20
  }[];
22
21
  messages: {
23
- wrongClassName: string;
22
+ suggestedMsg: string;
24
23
  };
25
24
  };
26
25
  create(context: any): {
@@ -5,7 +5,6 @@ module.exports = {
5
5
  meta: {
6
6
  type: "problem", // The rule type
7
7
  docs: {
8
- description: "Enforce consistent class naming using BEM convention",
9
8
  category: "Stylistic Issues",
10
9
  recommended: true,
11
10
  },
@@ -21,12 +20,10 @@ module.exports = {
21
20
  },
22
21
  ],
23
22
  messages: {
24
- wrongClassName: "The class '{{actual}}' does not follow BEM naming convention.",
23
+ suggestedMsg: "{{actual}} has been retired. Update it to the new name {{newValue}}.",
25
24
  },
26
25
  },
27
26
  create(context) {
28
- const pattern = /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)(__[a-z0-9]+(?:-[a-z0-9]+)*)?(--[a-z0-9]+(?:-[a-z0-9]+)*)?$/;
29
- const checkNaming = (name) => pattern.test(name);
30
27
  function check(node) {
31
28
  if ((0, node_1.isAttributesEmpty)(node)) {
32
29
  return;
@@ -35,7 +32,7 @@ module.exports = {
35
32
  if (classAttr && classAttr.value) {
36
33
  const classNames = classAttr.value.value.split(/\s+/);
37
34
  classNames.forEach((className) => {
38
- if (className && !checkNaming(className)) {
35
+ if (className && className in bem_mapping_1.bemMapping) {
39
36
  // Find the exact location of the problematic class name
40
37
  const classNameStart = classAttr.value.value.indexOf(className) + 7; // 7 here is for `class= "`
41
38
  const classNameEnd = classNameStart + className.length;
@@ -55,8 +52,9 @@ module.exports = {
55
52
  loc: { start: startLoc, end: endLoc },
56
53
  data: {
57
54
  actual: className,
55
+ newValue
58
56
  },
59
- messageId: "wrongClassName",
57
+ messageId: "suggestedMsg",
60
58
  fix(fixer) {
61
59
  if (newValue) {
62
60
  const newClassValue = classAttr.value.value.replace(className, newValue);
@@ -2,7 +2,6 @@ declare const _default: {
2
2
  meta: {
3
3
  type: string;
4
4
  docs: {
5
- description: string;
6
5
  category: string;
7
6
  recommended: boolean;
8
7
  };
@@ -4,18 +4,17 @@ module.exports = {
4
4
  meta: {
5
5
  type: "problem",
6
6
  docs: {
7
- description: "Ensure SLDS modal compliance by enforcing correct button and icon attributes.",
8
7
  category: "Best Practices",
9
8
  recommended: true,
10
9
  },
11
10
  fixable: "code",
12
11
  schema: [],
13
12
  messages: {
14
- removeClass: "Remove the class 'slds-button_icon-inverse' from SLDS Modal blueprints.",
15
- changeVariant: "Change 'variant' attribute from 'bare-inverse' to 'bare' in <lightning-button-icon> or <lightning-icon>.",
16
- removeVariant: "Remove 'variant' attribute completely in <lightning-icon> inside <button>.",
17
- ensureButtonClasses: "Ensure 'slds-button' and 'slds-button_icon' are in the class attribute of <button> or <lightning-button-icon>.",
18
- ensureSizeAttribute: "Ensure 'size' attribute is set to 'large' in <lightning-icon> or <lightning-button-icon> for correct icon sizing.",
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.",
19
18
  },
20
19
  },
21
20
  create(context) {
@@ -2,13 +2,12 @@ declare const _default: {
2
2
  meta: {
3
3
  type: string;
4
4
  docs: {
5
- description: string;
6
5
  category: string;
7
6
  recommended: boolean;
8
7
  };
9
8
  schema: any[];
10
9
  messages: {
11
- deprecatedClass: string;
10
+ errorMsg: string;
12
11
  };
13
12
  };
14
13
  create(context: any): {
@@ -6,13 +6,12 @@ module.exports = {
6
6
  meta: {
7
7
  type: "problem", // The rule type
8
8
  docs: {
9
- description: "Disallow usage of deprecated CSS classes",
10
9
  category: "Best Practices",
11
10
  recommended: true,
12
11
  },
13
12
  schema: [], // No additional options needed
14
13
  messages: {
15
- deprecatedClass: "The class '{{className}}' is deprecated and should not be used.",
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.",
16
15
  },
17
16
  },
18
17
  create(context) {
@@ -43,7 +42,7 @@ module.exports = {
43
42
  data: {
44
43
  className,
45
44
  },
46
- messageId: "deprecatedClass",
45
+ messageId: "errorMsg",
47
46
  });
48
47
  }
49
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/eslint-plugin-slds",
3
- "version": "0.1.0",
3
+ "version": "0.1.2-alpha.0",
4
4
  "main": "build/index.js",
5
5
  "files": [
6
6
  "build/*",