eslint-plugin-vuetify 2.7.1 → 2.7.2
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.
|
@@ -33,6 +33,8 @@ const md3 = {
|
|
|
33
33
|
'text-button': 'text-label-large',
|
|
34
34
|
'text-overline': 'text-label-small'
|
|
35
35
|
};
|
|
36
|
+
const breakpoints = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
37
|
+
const responsiveClassPattern = new RegExp(`^text-(${breakpoints.join('|')})-(.+)$`);
|
|
36
38
|
|
|
37
39
|
// ------------------------------------------------------------------------------
|
|
38
40
|
// Rule Definition
|
|
@@ -68,17 +70,25 @@ module.exports = {
|
|
|
68
70
|
const replacements = {
|
|
69
71
|
...(context.options[0] || md3)
|
|
70
72
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
73
|
+
function getReplace(className) {
|
|
74
|
+
const direct = replacements[className];
|
|
75
|
+
if (direct === false) return null;
|
|
76
|
+
if (direct != null) return direct;
|
|
77
|
+
const match = responsiveClassPattern.exec(className);
|
|
78
|
+
if (!match) return null;
|
|
79
|
+
const [, breakpoint, variant] = match;
|
|
80
|
+
const base = `text-${variant}`;
|
|
81
|
+
const baseReplace = replacements[base];
|
|
82
|
+
if (baseReplace == null || baseReplace === false) return null;
|
|
83
|
+
const newVariant = baseReplace.startsWith('text-') ? baseReplace.slice(5) : baseReplace;
|
|
84
|
+
return `text-${breakpoint}-${newVariant}`;
|
|
75
85
|
}
|
|
76
86
|
return context.sourceCode.parserServices.defineTemplateBodyVisitor({
|
|
77
87
|
'VAttribute[key.name="class"]'(node) {
|
|
78
88
|
if (!node.value || !node.value.value) return;
|
|
79
89
|
const classes = node.value.value.split(/\s+/).filter(Boolean);
|
|
80
90
|
classes.forEach(className => {
|
|
81
|
-
const replace =
|
|
91
|
+
const replace = getReplace(className);
|
|
82
92
|
if (replace == null) return;
|
|
83
93
|
const idx = node.value.value.indexOf(className) + 1;
|
|
84
94
|
const range = [node.value.range[0] + idx, node.value.range[0] + idx + className.length];
|