@maltjoy/eslint-rules 0.4.0 → 0.6.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.
- package/README.md +100 -1
- package/index.js +97 -4
- package/package.json +1 -1
- package/rules/accessibility/require-vjoyiconbutton-label.js +92 -0
- package/rules/accessibility/require-vjoytemplate-template-title-heading.js +61 -0
- package/rules/components/no-vjoyavatar-fullname-totalnumber.js +14 -0
- package/rules/components/no-vjoyavatar-photourl-totalnumber.js +14 -0
- package/rules/components/no-vjoybutton-circle.js +17 -0
- package/rules/components/no-vjoybutton-icon-only.js +87 -0
- package/rules/components/no-vjoybutton-white-variant.js +94 -0
- package/rules/components/no-vjoycollapse-single-item.js +55 -0
- package/rules/components/no-vjoycollapseitem-outside-collapse.js +15 -0
- package/rules/components/no-vjoycompanyavatar.js +16 -0
- package/rules/components/no-vjoyformerror-no-html-error-text.js +66 -0
- package/rules/components/no-vjoyformerror-visible-prop.js +18 -0
- package/rules/components/no-vjoyformgroup-vjoyradio.js +54 -0
- package/rules/components/no-vjoyfunnelfooter-slot.js +89 -0
- package/rules/{no-vjoyinput-type-password.js → components/no-vjoyinput-type-password.js} +18 -36
- package/rules/components/no-vjoyinput-unit.js +17 -0
- package/rules/components/no-vjoymenu-items-prop.js +19 -0
- package/rules/components/no-vjoymenu-vjoypanel.js +49 -0
- package/rules/components/no-vjoymenuitem-outside-menu.js +15 -0
- package/rules/components/no-vjoyradio-outside-group.js +16 -0
- package/rules/components/no-vjoyselectableitem-group.js +17 -0
- package/rules/components/no-vjoyselectableitem.js +55 -0
- package/rules/components/no-vjoysnackbar-direct.js +18 -0
- package/rules/components/no-vjoystep-outside-stepper.js +15 -0
- package/rules/components/no-vjoytab-outside-tabs.js +15 -0
- package/rules/components/no-vjoytooltip-enable-click-in-content.js +18 -0
- package/rules/components/no-vjoyusercard-rating-stars-slot.js +79 -0
- package/rules/components/require-vjoymenu-template-sidebar.js +62 -0
- package/rules/components/require-vjoytemplate-template-title.js +52 -0
- package/rules/tokens/no-arbitrary-font-size.js +24 -0
- package/rules/tokens/no-hardcoded-color-names.js +22 -0
- package/rules/tokens/no-hardcoded-hex-colors-in-vue.js +22 -0
- package/rules/tokens/no-hardcoded-rgb-colors-in-vue.js +22 -0
- package/rules/tokens/no-inline-style-colors.js +23 -0
- package/rules/tokens/prefer-joy-color-classes.js +128 -0
- package/rules/tokens/vue-style-visitors.js +168 -0
- package/rules/utils/forbidden-attribute.js +58 -0
- package/rules/utils/forbidden-element.js +36 -0
- package/rules/utils/require-ancestor.js +47 -0
- package/rules/utils/style-inspection.js +439 -0
- package/rules/utils/vjoyavatar.js +69 -0
- package/rules/utils/vue-ast.js +81 -0
- package/rules/no-vjoybutton-circle.js +0 -74
- package/rules/no-vjoyinput-unit.js +0 -75
- package/rules/no-vjoyusercard-rating-stars-slot.js +0 -110
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createTemplateBodyVisitor, isElementNamed } from '../utils/vue-ast.js';
|
|
2
|
+
|
|
3
|
+
const WARNING_MESSAGE =
|
|
4
|
+
'VJoyCollapse is intended for multiple items. A single VJoyCollapseItem is usually an antipattern.';
|
|
5
|
+
|
|
6
|
+
function isVJoyCollapseElement(node) {
|
|
7
|
+
return isElementNamed(node, ['vjoycollapse', 'v-joy-collapse']);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isVJoyCollapseItemElement(node) {
|
|
11
|
+
return isElementNamed(node, ['vjoycollapseitem', 'v-joy-collapse-item']);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function countDirectCollapseItems(node) {
|
|
15
|
+
if (!Array.isArray(node.children)) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return node.children.filter(
|
|
20
|
+
(child) => child.type === 'VElement' && isVJoyCollapseItemElement(child),
|
|
21
|
+
).length;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
meta: {
|
|
26
|
+
type: 'suggestion',
|
|
27
|
+
docs: {
|
|
28
|
+
description: 'discourage a single VJoyCollapseItem inside VJoyCollapse',
|
|
29
|
+
details:
|
|
30
|
+
'VJoyCollapse is designed to group multiple collapsible sections. Using only one VJoyCollapseItem is usually a sign that another component would be a better fit.',
|
|
31
|
+
examples: {
|
|
32
|
+
incorrect:
|
|
33
|
+
'<VJoyCollapse>\n <VJoyCollapseItem header="Only section">Content</VJoyCollapseItem>\n</VJoyCollapse>',
|
|
34
|
+
correct:
|
|
35
|
+
'<VJoyCollapse>\n <VJoyCollapseItem header="First">Content</VJoyCollapseItem>\n <VJoyCollapseItem header="Second">More content</VJoyCollapseItem>\n</VJoyCollapse>',
|
|
36
|
+
},
|
|
37
|
+
recommended: true,
|
|
38
|
+
category: 'components',
|
|
39
|
+
},
|
|
40
|
+
schema: [],
|
|
41
|
+
messages: {
|
|
42
|
+
singleCollapseItem: WARNING_MESSAGE,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
create(context) {
|
|
46
|
+
return createTemplateBodyVisitor((node) => {
|
|
47
|
+
if (isVJoyCollapseElement(node) && countDirectCollapseItems(node) === 1) {
|
|
48
|
+
context.report({
|
|
49
|
+
node,
|
|
50
|
+
messageId: 'singleCollapseItem',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequireAncestorRule } from '../utils/require-ancestor.js';
|
|
2
|
+
|
|
3
|
+
export default createRequireAncestorRule({
|
|
4
|
+
childElementNames: ['vjoycollapseitem', 'v-joy-collapse-item'],
|
|
5
|
+
parentElementNames: ['vjoycollapse', 'v-joy-collapse'],
|
|
6
|
+
description: 'disallow VJoyCollapseItem outside VJoyCollapse',
|
|
7
|
+
details: 'VJoyCollapseItem must be used inside VJoyCollapse.',
|
|
8
|
+
examples: {
|
|
9
|
+
incorrect: '<VJoyCollapseItem header="Section">Content</VJoyCollapseItem>',
|
|
10
|
+
correct:
|
|
11
|
+
'<VJoyCollapse>\n <VJoyCollapseItem header="Section">Content</VJoyCollapseItem>\n</VJoyCollapse>',
|
|
12
|
+
},
|
|
13
|
+
message: 'VJoyCollapseItem must be used inside VJoyCollapse.',
|
|
14
|
+
messageId: 'requireCollapse',
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createForbiddenElementRule } from '../utils/forbidden-element.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE = 'VJoyCompanyAvatar is deprecated, use VJoyAvatar instead.';
|
|
4
|
+
|
|
5
|
+
export default createForbiddenElementRule({
|
|
6
|
+
elementNames: ['vjoycompanyavatar', 'v-joy-company-avatar'],
|
|
7
|
+
description: 'disallow deprecated VJoyCompanyAvatar usage',
|
|
8
|
+
details:
|
|
9
|
+
'VJoyCompanyAvatar is deprecated. Use VJoyAvatar for company and user avatars.',
|
|
10
|
+
examples: {
|
|
11
|
+
incorrect: '<VJoyCompanyAvatar />',
|
|
12
|
+
correct: '<VJoyAvatar />',
|
|
13
|
+
},
|
|
14
|
+
message: ERROR_MESSAGE,
|
|
15
|
+
messageId: 'deprecatedCompanyAvatar',
|
|
16
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createTemplateBodyVisitor, getStaticName, isElementNamed } from '../utils/vue-ast.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'VJoyFormError no-html-error-text was removed, use the errors prop or default slot instead.';
|
|
5
|
+
|
|
6
|
+
const ATTRIBUTE_NAMES = new Set(['no-html-error-text', 'nohtmlerrortext']);
|
|
7
|
+
|
|
8
|
+
function isRemovedNoHtmlErrorTextAttribute(node) {
|
|
9
|
+
if (node?.type !== 'VAttribute' || !node.key) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!node.directive) {
|
|
14
|
+
return ATTRIBUTE_NAMES.has(node.key.name?.toLowerCase().replaceAll('-', ''));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (node.key.name?.name !== 'bind') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const argumentName = getStaticName(node.key.argument);
|
|
22
|
+
return (
|
|
23
|
+
typeof argumentName === 'string' &&
|
|
24
|
+
ATTRIBUTE_NAMES.has(argumentName.toLowerCase().replaceAll('-', ''))
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isVJoyFormErrorElement(node) {
|
|
29
|
+
return isElementNamed(node, ['vjoyformerror', 'v-joy-form-error']);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
meta: {
|
|
34
|
+
type: 'suggestion',
|
|
35
|
+
docs: {
|
|
36
|
+
description: 'disallow removed no-html-error-text prop on VJoyFormError',
|
|
37
|
+
details:
|
|
38
|
+
'The no-html-error-text prop was removed from VJoyFormError. Pass messages through the errors prop or use the default slot.',
|
|
39
|
+
examples: {
|
|
40
|
+
incorrect: '<VJoyFormError no-html-error-text="Required" />',
|
|
41
|
+
correct: '<VJoyFormError :errors="[\'Required\']" />',
|
|
42
|
+
},
|
|
43
|
+
recommended: true,
|
|
44
|
+
},
|
|
45
|
+
schema: [],
|
|
46
|
+
messages: {
|
|
47
|
+
removedFormErrorNoHtmlErrorText: ERROR_MESSAGE,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
create(context) {
|
|
51
|
+
return createTemplateBodyVisitor((node) => {
|
|
52
|
+
if (!isVJoyFormErrorElement(node) || !Array.isArray(node.startTag?.attributes)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
node.startTag.attributes.forEach((attribute) => {
|
|
57
|
+
if (isRemovedNoHtmlErrorTextAttribute(attribute)) {
|
|
58
|
+
context.report({
|
|
59
|
+
node: attribute,
|
|
60
|
+
messageId: 'removedFormErrorNoHtmlErrorText',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createForbiddenAttributeRule } from '../utils/forbidden-attribute.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'VJoyFormError visible property is deprecated and ignored. Remove it.';
|
|
5
|
+
|
|
6
|
+
export default createForbiddenAttributeRule({
|
|
7
|
+
attributeName: 'visible',
|
|
8
|
+
elementNames: ['vjoyformerror', 'v-joy-form-error'],
|
|
9
|
+
description: 'disallow deprecated visible prop on VJoyFormError',
|
|
10
|
+
details:
|
|
11
|
+
'The visible prop on VJoyFormError is deprecated and no longer affects rendering. Remove it from templates.',
|
|
12
|
+
examples: {
|
|
13
|
+
incorrect: '<VJoyFormError visible :errors="errors" />',
|
|
14
|
+
correct: '<VJoyFormError :errors="errors" />',
|
|
15
|
+
},
|
|
16
|
+
message: ERROR_MESSAGE,
|
|
17
|
+
messageId: 'deprecatedFormErrorVisibleProp',
|
|
18
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
containsElement,
|
|
3
|
+
createTemplateBodyVisitor,
|
|
4
|
+
isElementNamed,
|
|
5
|
+
} from '../utils/vue-ast.js';
|
|
6
|
+
|
|
7
|
+
const ERROR_MESSAGE =
|
|
8
|
+
"VJoyFormGroup shouldn't be used around a VJoyRadio. Use VJoyRadioGroup instead.";
|
|
9
|
+
|
|
10
|
+
function isVJoyFormGroupElement(node) {
|
|
11
|
+
return isElementNamed(node, ['vjoyformgroup', 'v-joy-form-group']);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isVJoyRadioElement(node) {
|
|
15
|
+
return isElementNamed(node, ['vjoyradio', 'v-joy-radio']);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isVJoyRadioGroupElement(node) {
|
|
19
|
+
return isElementNamed(node, ['vjoyradiogroup', 'v-joy-radio-group']);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function containsRadioOutsideRadioGroup(node) {
|
|
23
|
+
return containsElement(node, isVJoyRadioElement, isVJoyRadioGroupElement);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
meta: {
|
|
28
|
+
type: 'suggestion',
|
|
29
|
+
docs: {
|
|
30
|
+
description: 'disallow VJoyFormGroup around VJoyRadio; use VJoyRadioGroup instead',
|
|
31
|
+
details:
|
|
32
|
+
'VJoyFormGroup must not wrap VJoyRadio. Use VJoyRadioGroup to provide the expected radio-group semantics and behavior.',
|
|
33
|
+
examples: {
|
|
34
|
+
incorrect: '<VJoyFormGroup>\n <VJoyRadio value="daily" />\n</VJoyFormGroup>',
|
|
35
|
+
correct: '<VJoyRadioGroup>\n <VJoyRadio value="daily" />\n</VJoyRadioGroup>',
|
|
36
|
+
},
|
|
37
|
+
recommended: true,
|
|
38
|
+
},
|
|
39
|
+
schema: [],
|
|
40
|
+
messages: {
|
|
41
|
+
useVJoyRadioGroup: ERROR_MESSAGE,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
create(context) {
|
|
45
|
+
return createTemplateBodyVisitor((node) => {
|
|
46
|
+
if (isVJoyFormGroupElement(node) && containsRadioOutsideRadioGroup(node)) {
|
|
47
|
+
context.report({
|
|
48
|
+
node,
|
|
49
|
+
messageId: 'useVJoyRadioGroup',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTemplateBodyVisitor,
|
|
3
|
+
getStaticName,
|
|
4
|
+
isElementNamed,
|
|
5
|
+
isNamedSlotTemplate,
|
|
6
|
+
} from '../utils/vue-ast.js';
|
|
7
|
+
|
|
8
|
+
const SLOT_NAME = 'funnel-footer';
|
|
9
|
+
const ERROR_MESSAGE =
|
|
10
|
+
'VJoyFunnel funnel-footer slot is deprecated, use VJoyFunnelFooter in the default slot instead.';
|
|
11
|
+
|
|
12
|
+
function isVJoyFunnelElement(node) {
|
|
13
|
+
return isElementNamed(node, ['vjoyfunnel', 'v-joy-funnel']);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isDeprecatedFunnelFooterSlot(node) {
|
|
17
|
+
return isNamedSlotTemplate(node, SLOT_NAME);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isDeprecatedFunnelFooterSlotAttribute(node) {
|
|
21
|
+
if (node?.type !== 'VAttribute') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!node.directive) {
|
|
26
|
+
return (
|
|
27
|
+
node.key?.name === 'slot' &&
|
|
28
|
+
node.value?.type === 'VLiteral' &&
|
|
29
|
+
node.value.value === SLOT_NAME
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const directiveName = node.key?.name?.name;
|
|
34
|
+
const argumentName = getStaticName(node.key?.argument);
|
|
35
|
+
|
|
36
|
+
return directiveName === 'slot' && argumentName === SLOT_NAME;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function reportDeprecatedFunnelFooterSlot(context, node) {
|
|
40
|
+
if (!Array.isArray(node?.startTag?.attributes)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
node.startTag.attributes.forEach((attribute) => {
|
|
45
|
+
if (isDeprecatedFunnelFooterSlotAttribute(attribute)) {
|
|
46
|
+
context.report({
|
|
47
|
+
node: attribute,
|
|
48
|
+
messageId: 'deprecatedFunnelFooterSlot',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
meta: {
|
|
56
|
+
type: 'suggestion',
|
|
57
|
+
docs: {
|
|
58
|
+
description: 'disallow deprecated funnel-footer slot on VJoyFunnel',
|
|
59
|
+
details:
|
|
60
|
+
'The funnel-footer slot on VJoyFunnel is deprecated. Place VJoyFunnelFooter in the default slot instead.',
|
|
61
|
+
examples: {
|
|
62
|
+
incorrect:
|
|
63
|
+
'<VJoyFunnel>\n <template #funnel-footer>Footer</template>\n</VJoyFunnel>',
|
|
64
|
+
correct:
|
|
65
|
+
'<VJoyFunnel>\n <VJoyFunnelFooter>Footer</VJoyFunnelFooter>\n</VJoyFunnel>',
|
|
66
|
+
},
|
|
67
|
+
recommended: true,
|
|
68
|
+
},
|
|
69
|
+
schema: [],
|
|
70
|
+
messages: {
|
|
71
|
+
deprecatedFunnelFooterSlot: ERROR_MESSAGE,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
create(context) {
|
|
75
|
+
return createTemplateBodyVisitor((node, parentElement) => {
|
|
76
|
+
if (parentElement && isVJoyFunnelElement(parentElement) && node.name === 'template') {
|
|
77
|
+
if (isDeprecatedFunnelFooterSlot(node)) {
|
|
78
|
+
context.report({
|
|
79
|
+
node,
|
|
80
|
+
messageId: 'deprecatedFunnelFooterSlot',
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
reportDeprecatedFunnelFooterSlot(context, node);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createTemplateBodyVisitor, isElementNamed } from '../utils/vue-ast.js';
|
|
2
|
+
|
|
1
3
|
const ERROR_MESSAGE =
|
|
2
4
|
'Do not use VJoyInput with type="password", use VJoyInputPassword instead.';
|
|
3
5
|
|
|
@@ -27,25 +29,25 @@ function isLiteralPasswordExpression(expr) {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
function isTypePasswordAttribute(node) {
|
|
30
|
-
if (
|
|
32
|
+
if (node?.type !== 'VAttribute') {
|
|
31
33
|
return false;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
if (!node.directive) {
|
|
35
|
-
if (node.key
|
|
37
|
+
if (node.key?.name === 'type' && node.value?.type === 'VLiteral') {
|
|
36
38
|
return isPasswordString(node.value.value);
|
|
37
39
|
}
|
|
38
40
|
return false;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
const directiveName = node.key
|
|
42
|
-
const argumentName = node.key
|
|
43
|
+
const directiveName = node.key?.name?.name;
|
|
44
|
+
const argumentName = node.key?.argument?.name;
|
|
43
45
|
|
|
44
46
|
if (directiveName !== 'bind' || argumentName !== 'type') {
|
|
45
47
|
return false;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
if (
|
|
50
|
+
if (node.value?.type !== 'VExpressionContainer') {
|
|
49
51
|
return false;
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -53,11 +55,7 @@ function isTypePasswordAttribute(node) {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
function isVJoyInputElement(node) {
|
|
56
|
-
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return node.name.toLowerCase() === 'vjoyinput';
|
|
58
|
+
return isElementNamed(node, ['vjoyinput']);
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
export default {
|
|
@@ -65,7 +63,13 @@ export default {
|
|
|
65
63
|
type: 'suggestion',
|
|
66
64
|
docs: {
|
|
67
65
|
description: 'disallow VJoyInput with type password; use VJoyInputPassword',
|
|
68
|
-
|
|
66
|
+
details:
|
|
67
|
+
'Do not turn VJoyInput into a password field with type="password" or a literal bound value. VJoyInputPassword provides the supported password experience.',
|
|
68
|
+
examples: {
|
|
69
|
+
incorrect: '<VJoyInput type="password" />',
|
|
70
|
+
correct: '<VJoyInputPassword />',
|
|
71
|
+
},
|
|
72
|
+
recommended: true,
|
|
69
73
|
},
|
|
70
74
|
schema: [],
|
|
71
75
|
messages: {
|
|
@@ -73,12 +77,8 @@ export default {
|
|
|
73
77
|
},
|
|
74
78
|
},
|
|
75
79
|
create(context) {
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (isVJoyInputElement(node) && node.startTag && Array.isArray(node.startTag.attributes)) {
|
|
80
|
+
return createTemplateBodyVisitor((node) => {
|
|
81
|
+
if (isVJoyInputElement(node) && Array.isArray(node.startTag?.attributes)) {
|
|
82
82
|
node.startTag.attributes.forEach((attribute) => {
|
|
83
83
|
if (isTypePasswordAttribute(attribute)) {
|
|
84
84
|
context.report({
|
|
@@ -88,24 +88,6 @@ export default {
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!Array.isArray(node.children)) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
node.children.forEach((child) => {
|
|
97
|
-
visitElement(child);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
Program(programNode) {
|
|
103
|
-
if (!programNode || !programNode.templateBody) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
visitElement(programNode.templateBody);
|
|
108
|
-
},
|
|
109
|
-
};
|
|
91
|
+
});
|
|
110
92
|
},
|
|
111
93
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createForbiddenAttributeRule } from '../utils/forbidden-attribute.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'Do not use VJoyInput with unit property, use VJoyInputNumber instead.';
|
|
5
|
+
|
|
6
|
+
export default createForbiddenAttributeRule({
|
|
7
|
+
attributeName: 'unit',
|
|
8
|
+
description: 'disallow VJoyInput with unit prop; use VJoyInputNumber',
|
|
9
|
+
details: 'The unit prop belongs to VJoyInputNumber, not VJoyInput.',
|
|
10
|
+
elementNames: ['vjoyinput'],
|
|
11
|
+
examples: {
|
|
12
|
+
incorrect: '<VJoyInput unit="€" />',
|
|
13
|
+
correct: '<VJoyInputNumber unit="€" />',
|
|
14
|
+
},
|
|
15
|
+
message: ERROR_MESSAGE,
|
|
16
|
+
messageId: 'useVJoyInputNumber',
|
|
17
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createForbiddenAttributeRule } from '../utils/forbidden-attribute.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'VJoyMenu items property is deprecated, use VJoyMenuItem in the default slot instead.';
|
|
5
|
+
|
|
6
|
+
export default createForbiddenAttributeRule({
|
|
7
|
+
attributeName: 'items',
|
|
8
|
+
elementNames: ['vjoymenu', 'v-joy-menu'],
|
|
9
|
+
description: 'disallow deprecated items prop on VJoyMenu',
|
|
10
|
+
details:
|
|
11
|
+
'The items prop on VJoyMenu is deprecated. Render menu entries with VJoyMenuItem components in the default slot.',
|
|
12
|
+
examples: {
|
|
13
|
+
incorrect: '<VJoyMenu :items="menuItems" />',
|
|
14
|
+
correct:
|
|
15
|
+
'<VJoyMenu>\n <VJoyMenuItem label="Settings" />\n</VJoyMenu>',
|
|
16
|
+
},
|
|
17
|
+
message: ERROR_MESSAGE,
|
|
18
|
+
messageId: 'deprecatedMenuItemsProp',
|
|
19
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
containsElement,
|
|
3
|
+
createTemplateBodyVisitor,
|
|
4
|
+
isElementNamed,
|
|
5
|
+
} from '../utils/vue-ast.js';
|
|
6
|
+
|
|
7
|
+
const ERROR_MESSAGE = 'Never use a VJoyMenu inside a VJoyPanel.';
|
|
8
|
+
|
|
9
|
+
function isVJoyMenuElement(node) {
|
|
10
|
+
return isElementNamed(node, ['vjoymenu', 'v-joy-menu']);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isVJoyPanelElement(node) {
|
|
14
|
+
return isElementNamed(node, ['vjoypanel', 'v-joy-panel']);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function containsVJoyMenu(node) {
|
|
18
|
+
return containsElement(node, isVJoyMenuElement);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
meta: {
|
|
23
|
+
type: 'suggestion',
|
|
24
|
+
docs: {
|
|
25
|
+
description: 'disallow VJoyMenu inside VJoyPanel',
|
|
26
|
+
details:
|
|
27
|
+
'VJoyMenu and VJoyPanel represent different navigation and content patterns and must not be nested.',
|
|
28
|
+
examples: {
|
|
29
|
+
incorrect: '<VJoyPanel>\n <VJoyMenu />\n</VJoyPanel>',
|
|
30
|
+
correct: '<VJoyMenu />\n<VJoyPanel />',
|
|
31
|
+
},
|
|
32
|
+
recommended: true,
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
messages: {
|
|
36
|
+
noVJoyMenuInsideVJoyPanel: ERROR_MESSAGE,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
create(context) {
|
|
40
|
+
return createTemplateBodyVisitor((node) => {
|
|
41
|
+
if (isVJoyPanelElement(node) && containsVJoyMenu(node)) {
|
|
42
|
+
context.report({
|
|
43
|
+
node,
|
|
44
|
+
messageId: 'noVJoyMenuInsideVJoyPanel',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequireAncestorRule } from '../utils/require-ancestor.js';
|
|
2
|
+
|
|
3
|
+
export default createRequireAncestorRule({
|
|
4
|
+
childElementNames: ['vjoymenuitem', 'v-joy-menu-item'],
|
|
5
|
+
parentElementNames: ['vjoymenu', 'v-joy-menu'],
|
|
6
|
+
description: 'disallow VJoyMenuItem outside VJoyMenu',
|
|
7
|
+
details: 'VJoyMenuItem must be used inside VJoyMenu.',
|
|
8
|
+
examples: {
|
|
9
|
+
incorrect: '<VJoyMenuItem label="Settings" />',
|
|
10
|
+
correct:
|
|
11
|
+
'<VJoyMenu>\n <VJoyMenuItem label="Settings" />\n</VJoyMenu>',
|
|
12
|
+
},
|
|
13
|
+
message: 'VJoyMenuItem must be used inside VJoyMenu.',
|
|
14
|
+
messageId: 'requireMenu',
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequireAncestorRule } from '../utils/require-ancestor.js';
|
|
2
|
+
|
|
3
|
+
export default createRequireAncestorRule({
|
|
4
|
+
childElementNames: ['vjoyradio', 'v-joy-radio'],
|
|
5
|
+
parentElementNames: ['vjoyradiogroup', 'v-joy-radio-group'],
|
|
6
|
+
description: 'disallow VJoyRadio outside VJoyRadioGroup',
|
|
7
|
+
details:
|
|
8
|
+
'VJoyRadio must be used inside VJoyRadioGroup to provide the expected fieldset semantics, grouping, and accessibility behavior.',
|
|
9
|
+
examples: {
|
|
10
|
+
incorrect: '<VJoyRadio value="daily" />',
|
|
11
|
+
correct:
|
|
12
|
+
'<VJoyRadioGroup v-model="frequency">\n <VJoyRadio value="daily" />\n</VJoyRadioGroup>',
|
|
13
|
+
},
|
|
14
|
+
message: 'VJoyRadio must be used inside VJoyRadioGroup.',
|
|
15
|
+
messageId: 'requireRadioGroup',
|
|
16
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createForbiddenElementRule } from '../utils/forbidden-element.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'VJoySelectableItemGroup is deprecated, use VJoyCheckboxGroup, VJoyRadioGroup, VJoyButtonCard, or VJoyCheckboxCard instead.';
|
|
5
|
+
|
|
6
|
+
export default createForbiddenElementRule({
|
|
7
|
+
elementNames: ['vjoyselectableitemgroup', 'v-joy-selectable-item-group'],
|
|
8
|
+
description: 'disallow deprecated VJoySelectableItemGroup usage',
|
|
9
|
+
details:
|
|
10
|
+
'VJoySelectableItemGroup is deprecated. Choose VJoyCheckboxGroup, VJoyRadioGroup, VJoyButtonCard, or VJoyCheckboxCard depending on the interaction.',
|
|
11
|
+
examples: {
|
|
12
|
+
incorrect: '<VJoySelectableItemGroup v-model:value="value" :options="options" />',
|
|
13
|
+
correct: '<VJoyCheckboxGroup v-model:value="value" :options="options" />',
|
|
14
|
+
},
|
|
15
|
+
message: ERROR_MESSAGE,
|
|
16
|
+
messageId: 'deprecatedSelectableItemGroup',
|
|
17
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createTemplateBodyVisitor, isElementNamed } from '../utils/vue-ast.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'VJoySelectableItem is deprecated, use VJoyCheckboxGroup, VJoyRadioGroup, VJoyButtonCard, or VJoyCheckboxCard instead.';
|
|
5
|
+
|
|
6
|
+
const SELECTABLE_ITEM_NAMES = ['vjoyselectableitem', 'v-joy-selectable-item'];
|
|
7
|
+
const SELECTABLE_ITEM_GROUP_NAMES = [
|
|
8
|
+
'vjoyselectableitemgroup',
|
|
9
|
+
'v-joy-selectable-item-group',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
function isVJoySelectableItemElement(node) {
|
|
13
|
+
return isElementNamed(node, SELECTABLE_ITEM_NAMES);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function hasSelectableItemGroupAncestor(ancestors) {
|
|
17
|
+
return ancestors.some((ancestor) => isElementNamed(ancestor, SELECTABLE_ITEM_GROUP_NAMES));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
meta: {
|
|
22
|
+
type: 'suggestion',
|
|
23
|
+
docs: {
|
|
24
|
+
description: 'disallow deprecated VJoySelectableItem usage outside its group component',
|
|
25
|
+
details:
|
|
26
|
+
'VJoySelectableItem is deprecated. Use VJoyCheckboxGroup, VJoyRadioGroup, VJoyButtonCard, or VJoyCheckboxCard instead of composing selectable items manually.',
|
|
27
|
+
examples: {
|
|
28
|
+
incorrect: '<VJoySelectableItem value="option-a" name="choice" />',
|
|
29
|
+
correct:
|
|
30
|
+
'<VJoyRadioGroup v-model="choice">\n <VJoyRadio value="option-a" name="choice" />\n</VJoyRadioGroup>',
|
|
31
|
+
},
|
|
32
|
+
recommended: true,
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
messages: {
|
|
36
|
+
deprecatedSelectableItem: ERROR_MESSAGE,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
create(context) {
|
|
40
|
+
return createTemplateBodyVisitor((node, _parentElement, ancestors) => {
|
|
41
|
+
if (!isVJoySelectableItemElement(node)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (hasSelectableItemGroupAncestor(ancestors)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
context.report({
|
|
50
|
+
node,
|
|
51
|
+
messageId: 'deprecatedSelectableItem',
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createForbiddenElementRule } from '../utils/forbidden-element.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'Do not use VJoySnackbar directly, use pushVJoySnackbar from @maltjoy/core-vue instead.';
|
|
5
|
+
|
|
6
|
+
export default createForbiddenElementRule({
|
|
7
|
+
elementNames: ['vjoysnackbar', 'v-joy-snackbar'],
|
|
8
|
+
description: 'disallow direct VJoySnackbar usage in templates',
|
|
9
|
+
details:
|
|
10
|
+
'VJoySnackbar should not be rendered directly. Use the pushVJoySnackbar service from @maltjoy/core-vue.',
|
|
11
|
+
examples: {
|
|
12
|
+
incorrect: '<VJoySnackbar message="Saved" />',
|
|
13
|
+
correct:
|
|
14
|
+
"import { pushVJoySnackbar } from '@maltjoy/core-vue';\n\npushVJoySnackbar({ props: { message: 'Saved' } });",
|
|
15
|
+
},
|
|
16
|
+
message: ERROR_MESSAGE,
|
|
17
|
+
messageId: 'usePushVJoySnackbar',
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequireAncestorRule } from '../utils/require-ancestor.js';
|
|
2
|
+
|
|
3
|
+
export default createRequireAncestorRule({
|
|
4
|
+
childElementNames: ['vjoystep', 'v-joy-step'],
|
|
5
|
+
parentElementNames: ['vjoystepper', 'v-joy-stepper'],
|
|
6
|
+
description: 'disallow VJoyStep outside VJoyStepper',
|
|
7
|
+
details: 'VJoyStep must be used inside VJoyStepper.',
|
|
8
|
+
examples: {
|
|
9
|
+
incorrect: '<VJoyStep label="Profile" />',
|
|
10
|
+
correct:
|
|
11
|
+
'<VJoyStepper>\n <VJoyStep label="Profile" />\n</VJoyStepper>',
|
|
12
|
+
},
|
|
13
|
+
message: 'VJoyStep must be used inside VJoyStepper.',
|
|
14
|
+
messageId: 'requireStepper',
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequireAncestorRule } from '../utils/require-ancestor.js';
|
|
2
|
+
|
|
3
|
+
export default createRequireAncestorRule({
|
|
4
|
+
childElementNames: ['vjoytab', 'v-joy-tab'],
|
|
5
|
+
parentElementNames: ['vjoytabs', 'v-joy-tabs'],
|
|
6
|
+
description: 'disallow VJoyTab outside VJoyTabs',
|
|
7
|
+
details: 'VJoyTab must be used inside VJoyTabs.',
|
|
8
|
+
examples: {
|
|
9
|
+
incorrect: '<VJoyTab label="Overview" />',
|
|
10
|
+
correct:
|
|
11
|
+
'<VJoyTabs>\n <VJoyTab label="Overview" />\n</VJoyTabs>',
|
|
12
|
+
},
|
|
13
|
+
message: 'VJoyTab must be used inside VJoyTabs.',
|
|
14
|
+
messageId: 'requireTabs',
|
|
15
|
+
});
|