@dialpad/eslint-plugin-dialtone 1.8.2 → 1.9.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: node, messageId: 'recommendBackgroundSemanticColor' });
|
|
40
|
+
} else if (classes.match(/d-fc-\w+-\d{2,4}/)) {
|
|
41
|
+
context.report({ node: node, messageId: 'recommendForegroundSemanticColor' });
|
|
42
|
+
} else if (classes.match(/d-bc-\w+-\d{2,4}/)) {
|
|
43
|
+
context.report({ node: node, messageId: 'recommendBorderSemanticColor' });
|
|
44
|
+
} else if (classes.match(/d-divide-\w+-\d{2,4}/)) {
|
|
45
|
+
context.report({ node: node, messageId: 'recommendDivideSemanticColor' });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -34,7 +34,8 @@ module.exports = {
|
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode();
|
|
38
|
+
return sourceCode.parserServices.defineTemplateBodyVisitor({
|
|
38
39
|
VAttribute(node) {
|
|
39
40
|
deprecatedDirectives.forEach((item) => {
|
|
40
41
|
if (node.directive && node.key.name.name === item.directiveName) {
|
|
@@ -27,7 +27,8 @@ module.exports = {
|
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
create(context) {
|
|
30
|
-
|
|
30
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode();
|
|
31
|
+
return sourceCode.parserServices.defineTemplateBodyVisitor({
|
|
31
32
|
// Visitor functions for Vue templates
|
|
32
33
|
VAttribute(node) {
|
|
33
34
|
if (node.key.name === 'class') {
|