eslint-plugin-vuetify 2.7.0 → 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.
@@ -32,9 +32,9 @@ module.exports = {
32
32
  }
33
33
  }],
34
34
  messages: {
35
- deprecated: `'{{ name }}' is deprecated`,
36
- deprecatedWithMessage: `'{{ name }}' is deprecated: {{ message }}`,
37
- deprecatedWithReplacement: `'{{ name }}' is deprecated, use '<{{ tag }}{{ classAttr }}>' instead`
35
+ deprecated: `do not use '{{ name }}' (custom policy)`,
36
+ deprecatedWithMessage: `'{{ name }}' {{ message }}`,
37
+ deprecatedWithReplacement: `do not use '{{ name }}', use '<{{ tag }}{{ classAttr }}>' instead`
38
38
  }
39
39
  },
40
40
  create(context) {
@@ -35,9 +35,9 @@ module.exports = {
35
35
  }
36
36
  }],
37
37
  messages: {
38
- replacedWith: `{{ tag }}: @{{ a }} has been replaced with @{{ b }}`,
39
- removed: `{{ tag }}: @{{ name }} has been removed`,
40
- removedWithMessage: `{{ tag }}: @{{ name }} has been removed: {{ message }}`
38
+ removed: `{{ tag }}: do not use @{{ name }} (custom policy)`,
39
+ replacedWith: `{{ tag }}: do not use @{{ a }}, use @{{ b }} instead`,
40
+ removedWithMessage: `{{ tag }}: @{{ name }} {{ message }}`
41
41
  }
42
42
  },
43
43
  create(context) {
@@ -35,9 +35,9 @@ module.exports = {
35
35
  }
36
36
  }],
37
37
  messages: {
38
- replacedWith: `'{{ a }}' has been replaced with '{{ b }}'`,
39
- removed: `'{{ name }}' has been removed`,
40
- removedWithMessage: `'{{ name }}' has been removed: {{ message }}`
38
+ removed: `do not use '{{ name }}' (custom policy)`,
39
+ replacedWith: `do not use '{{ a }}', use '{{ b }}' instead`,
40
+ removedWithMessage: `'{{ name }}' {{ message }}`
41
41
  }
42
42
  },
43
43
  create(context) {
@@ -34,9 +34,9 @@ module.exports = {
34
34
  }
35
35
  }],
36
36
  messages: {
37
- replacedWith: `{{ component }}'s '{{ slot }}' slot has been replaced with '{{ newSlot }}'`,
38
- removed: `{{ component }}'s '{{ slot }}' slot has been removed`,
39
- removedWithMessage: `{{ component }}'s '{{ slot }}' slot has been removed: {{ message }}`
37
+ removed: `do not use {{ component }}'s '{{ slot }}' slot (custom policy)`,
38
+ replacedWith: `do not use {{ component }}'s '{{ slot }}' slot, use '{{ newSlot }}' instead`,
39
+ removedWithMessage: `{{ component }}'s '{{ slot }}' slot {{ message }}`
40
40
  }
41
41
  },
42
42
  create(context) {
@@ -796,7 +796,6 @@ const replacements = {
796
796
  value: 'right'
797
797
  },
798
798
  shaped: false,
799
- text: false,
800
799
  top: {
801
800
  name: 'location',
802
801
  value: 'top'
@@ -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
- // Remove entries the user set to false
73
- for (const key of Object.keys(replacements)) {
74
- if (replacements[key] === false) delete replacements[key];
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 = replacements[className];
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];
@@ -85,8 +85,13 @@ module.exports = {
85
85
  if (!node.value || !node.value.value) return;
86
86
  const classes = node.value.value.split(/\s+/).filter(Boolean);
87
87
  classes.forEach(className => {
88
- const replace = replacements[className];
88
+ // Support variant prefixes like md:pa-6, dark:flex-grow-1
89
+ const parts = className.split(':');
90
+ const baseClass = parts.pop();
91
+ const prefix = parts.length ? parts.join(':') + ':' : '';
92
+ const replace = replacements[baseClass];
89
93
  if (replace == null) return;
94
+ const fullReplace = prefix + replace;
90
95
  const idx = node.value.value.indexOf(className) + 1;
91
96
  const range = [node.value.range[0] + idx, node.value.range[0] + idx + className.length];
92
97
  const loc = {
@@ -98,10 +103,10 @@ module.exports = {
98
103
  messageId: 'replacedWith',
99
104
  data: {
100
105
  a: className,
101
- b: replace
106
+ b: fullReplace
102
107
  },
103
108
  fix(fixer) {
104
- return fixer.replaceTextRange(range, replace);
109
+ return fixer.replaceTextRange(range, fullReplace);
105
110
  }
106
111
  });
107
112
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-vuetify",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "An eslint plugin for Vuetify",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",