@dialpad/eslint-plugin-dialtone 1.8.2 → 1.10.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.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @fileoverview Detects usage of deprecated base color utility classes.
3
+ * @author Tico Ortega
4
+ */
5
+ 'use strict';
6
+
7
+ // ------------------------------------------------------------------------------
8
+ // Rule Definition
9
+ // ------------------------------------------------------------------------------
10
+
11
+ const description = 'Usage of base color utility classes are deprecated and will be removed in the future.';
12
+
13
+ module.exports = {
14
+ meta: {
15
+ type: 'suggestion', // `problem`, `suggestion`, or `layout`
16
+ docs: {
17
+ description,
18
+ recommended: false,
19
+ url: 'https://github.com/dialpad/dialtone/blob/staging/packages/eslint-plugin-dialtone/docs/rules/deprecated-base-color-classes.md', // URL to the documentation page for this rule
20
+ },
21
+ fixable: null, // Or `code` or `whitespace`
22
+ schema: [], // Add a schema if the rule has options
23
+ messages: {
24
+ recommendBackgroundSemanticColor: `${description} Checkout the available replacements here: https://dialtone.dialpad.com/utilities/backgrounds/color.html`,
25
+ recommendForegroundSemanticColor: `${description} Checkout the available replacements here: https://dialtone.dialpad.com/utilities/typography/font-color.html`,
26
+ recommendBorderSemanticColor: `${description} Checkout the available replacements here: https://dialtone.dialpad.com/utilities/borders/color.html`,
27
+ recommendDivideSemanticColor: `${description} Checkout the available replacements here: https://dialtone.dialpad.com/utilities/borders/divide-color.html`,
28
+ }, // Add messageId and message
29
+ },
30
+
31
+ create (context) {
32
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
33
+ return sourceCode.parserServices.defineTemplateBodyVisitor({
34
+ // Visitor functions for Vue templates
35
+ VAttribute (node) {
36
+ if (node.key.name === 'class') {
37
+ const classes = node.value.value;
38
+ if (classes.match(/d-bgc-\w+-\d{2,4}/)) {
39
+ context.report({ node, messageId: 'recommendBackgroundSemanticColor' });
40
+ } else if (classes.match(/d-fc-\w+-\d{2,4}/)) {
41
+ context.report({ node, messageId: 'recommendForegroundSemanticColor' });
42
+ } else if (classes.match(/d-bc-\w+-\d{2,4}/)) {
43
+ context.report({ node, messageId: 'recommendBorderSemanticColor' });
44
+ } else if (classes.match(/d-divide-\w+-\d{2,4}/)) {
45
+ context.report({ node, messageId: 'recommendDivideSemanticColor' });
46
+ }
47
+ }
48
+ },
49
+ });
50
+ },
51
+ };
@@ -4,9 +4,9 @@
4
4
  */
5
5
  'use strict';
6
6
 
7
- //------------------------------------------------------------------------------
7
+ // ------------------------------------------------------------------------------
8
8
  // Rule Definition
9
- //------------------------------------------------------------------------------
9
+ // ------------------------------------------------------------------------------
10
10
 
11
11
  module.exports = {
12
12
  meta: {
@@ -25,7 +25,7 @@ module.exports = {
25
25
  },
26
26
  },
27
27
 
28
- create(context) {
28
+ create (context) {
29
29
  const deprecatedDirectives = [
30
30
  {
31
31
  directiveName: 'tooltip',
@@ -34,12 +34,13 @@ module.exports = {
34
34
  },
35
35
  ];
36
36
 
37
- return context.parserServices.defineTemplateBodyVisitor({
38
- VAttribute(node) {
37
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
38
+ return sourceCode.parserServices.defineTemplateBodyVisitor({
39
+ VAttribute (node) {
39
40
  deprecatedDirectives.forEach((item) => {
40
41
  if (node.directive && node.key.name.name === item.directiveName) {
41
42
  context.report({
42
- node: node,
43
+ node,
43
44
  messageId: 'deprecatedDirective',
44
45
  data: {
45
46
  directiveName: item.directiveName,
@@ -2,17 +2,17 @@
2
2
  * @fileoverview Utilities to set Font family, Font weight, Font size, and Line height separately are discouraged in favor of composed typography utilities
3
3
  * @author Nina Repetto
4
4
  */
5
- "use strict";
5
+ 'use strict';
6
6
 
7
- //------------------------------------------------------------------------------
7
+ // ------------------------------------------------------------------------------
8
8
  // Rule Definition
9
- //------------------------------------------------------------------------------
9
+ // ------------------------------------------------------------------------------
10
10
 
11
11
  module.exports = {
12
12
  meta: {
13
13
  type: 'suggestion', // `problem`, `suggestion`, or `layout`
14
14
  docs: {
15
- description: "Utilities to set Font family, Font weight, Font size, and Line height separately are discouraged in favor of composed typography utilities",
15
+ description: 'Utilities to set Font family, Font weight, Font size, and Line height separately are discouraged in favor of composed typography utilities',
16
16
  recommended: false,
17
17
  url: 'https://github.com/dialpad/dialtone/blob/staging/packages/eslint-plugin-dialtone/docs/rules/recommend-typography-style.md', // URL to the documentation page for this rule
18
18
  },
@@ -26,10 +26,11 @@ module.exports = {
26
26
  }, // Add messageId and message
27
27
  },
28
28
 
29
- create(context) {
30
- return context.parserServices.defineTemplateBodyVisitor({
29
+ create (context) {
30
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
31
+ return sourceCode.parserServices.defineTemplateBodyVisitor({
31
32
  // Visitor functions for Vue templates
32
- VAttribute(node) {
33
+ VAttribute (node) {
33
34
  if (node.key.name === 'class') {
34
35
  const classes = node.value.value.split(' ');
35
36
  const typographyClasses = [
@@ -46,16 +47,16 @@ module.exports = {
46
47
  'd-ff-unset',
47
48
  ];
48
49
  const typographyClassesFound = classes.filter((className) =>
49
- typographyClasses.some((typographyClass) => className.includes(typographyClass))
50
+ typographyClasses.some((typographyClass) => className.includes(typographyClass)),
50
51
  );
51
52
  if (typographyClassesFound.length > 0) {
52
53
  context.report({
53
- node: node,
54
+ node,
54
55
  messageId: 'recommendTypographyStyle',
55
56
  });
56
57
  }
57
58
  }
58
- }
59
+ },
59
60
  });
60
- }
61
+ },
61
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialpad/eslint-plugin-dialtone",
3
- "version": "1.8.2",
3
+ "version": "1.10.0",
4
4
  "description": "dialtone eslint plugin",
5
5
  "keywords": [
6
6
  "Dialpad",