@maltjoy/eslint-rules 0.5.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 +59 -2
- package/index.js +83 -11
- package/package.json +1 -1
- package/rules/accessibility/require-vjoyiconbutton-label.js +92 -0
- package/rules/{require-vjoytemplate-template-title-heading.js → accessibility/require-vjoytemplate-template-title-heading.js} +2 -1
- package/rules/{no-vjoyavatar-fullname-totalnumber.js → components/no-vjoyavatar-fullname-totalnumber.js} +1 -1
- package/rules/{no-vjoyavatar-photourl-totalnumber.js → components/no-vjoyavatar-photourl-totalnumber.js} +1 -1
- package/rules/{no-vjoybutton-circle.js → components/no-vjoybutton-circle.js} +1 -1
- 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/{no-vjoyformgroup-vjoyradio.js → components/no-vjoyformgroup-vjoyradio.js} +1 -1
- package/rules/components/no-vjoyfunnelfooter-slot.js +89 -0
- package/rules/{no-vjoyinput-type-password.js → components/no-vjoyinput-type-password.js} +1 -1
- package/rules/{no-vjoyinput-unit.js → components/no-vjoyinput-unit.js} +1 -1
- package/rules/components/no-vjoymenu-items-prop.js +19 -0
- package/rules/{no-vjoymenu-vjoypanel.js → components/no-vjoymenu-vjoypanel.js} +1 -1
- 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/{no-vjoyusercard-rating-stars-slot.js → components/no-vjoyusercard-rating-stars-slot.js} +1 -1
- package/rules/{require-vjoymenu-template-sidebar.js → components/require-vjoymenu-template-sidebar.js} +1 -1
- package/rules/{require-vjoytemplate-template-title.js → components/require-vjoytemplate-template-title.js} +1 -1
- 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 +1 -1
- package/rules/utils/forbidden-element.js +36 -0
- package/rules/utils/require-ancestor.js +47 -0
- package/rules/utils/style-inspection.js +439 -0
|
@@ -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,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
|
+
};
|
|
@@ -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,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
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createForbiddenAttributeRule } from '../utils/forbidden-attribute.js';
|
|
2
|
+
|
|
3
|
+
const ERROR_MESSAGE =
|
|
4
|
+
'VJoyTooltip enable-click-in-content property is deprecated and enabled by default. Remove it.';
|
|
5
|
+
|
|
6
|
+
export default createForbiddenAttributeRule({
|
|
7
|
+
attributeName: 'enable-click-in-content',
|
|
8
|
+
elementNames: ['vjoytooltip', 'v-joy-tooltip'],
|
|
9
|
+
description: 'disallow deprecated enable-click-in-content prop on VJoyTooltip',
|
|
10
|
+
details:
|
|
11
|
+
'The enable-click-in-content prop on VJoyTooltip is deprecated because the behavior is now enabled by default.',
|
|
12
|
+
examples: {
|
|
13
|
+
incorrect: '<VJoyTooltip enable-click-in-content text="Help" />',
|
|
14
|
+
correct: '<VJoyTooltip text="Help" />',
|
|
15
|
+
},
|
|
16
|
+
message: ERROR_MESSAGE,
|
|
17
|
+
messageId: 'deprecatedEnableClickInContent',
|
|
18
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createVueStyleInspectionRule,
|
|
3
|
+
inspectStyleExpressionForFontSize,
|
|
4
|
+
inspectStyleTextForArbitraryFontSize,
|
|
5
|
+
} from './vue-style-visitors.js';
|
|
6
|
+
|
|
7
|
+
const ERROR_MESSAGE =
|
|
8
|
+
'Avoid arbitrary font-size values in Vue files. Use @maltjoy/themes tokens such as var(--joy-font-size-primary-400) or typography classes like joy-font-primary-400.';
|
|
9
|
+
|
|
10
|
+
export default createVueStyleInspectionRule({
|
|
11
|
+
description: 'disallow arbitrary font-size values in Vue templates and style blocks',
|
|
12
|
+
details:
|
|
13
|
+
'Font sizes should come from the Joy typography scale. Prefer VJoyText with classes such as joy-font-primary-400, utility classes such as joy-font-size-primary-400, or CSS variables such as var(--joy-font-size-primary-400) instead of px, rem, or em literals.',
|
|
14
|
+
examples: {
|
|
15
|
+
incorrect:
|
|
16
|
+
'<div style="font-size: 14px" />\n\n<style scoped>\n.title {\n font-size: 16px;\n}\n</style>',
|
|
17
|
+
correct:
|
|
18
|
+
'<VJoyText class="joy-font-primary-400" />\n\n<style scoped>\n.title {\n font-size: var(--joy-font-size-primary-400);\n}\n</style>',
|
|
19
|
+
},
|
|
20
|
+
messageId: 'arbitraryFontSize',
|
|
21
|
+
message: ERROR_MESSAGE,
|
|
22
|
+
inspectStyleText: inspectStyleTextForArbitraryFontSize,
|
|
23
|
+
inspectStyleExpression: inspectStyleExpressionForFontSize,
|
|
24
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createVueStyleInspectionRule,
|
|
3
|
+
inspectStyleTextForNamedColors,
|
|
4
|
+
} from './vue-style-visitors.js';
|
|
5
|
+
|
|
6
|
+
const ERROR_MESSAGE =
|
|
7
|
+
'Avoid hardcoded CSS color names in Vue files. Use @maltjoy/themes design tokens such as var(--joy-color-*) or joy-color-* classes.';
|
|
8
|
+
|
|
9
|
+
export default createVueStyleInspectionRule({
|
|
10
|
+
description: 'disallow hardcoded CSS color names in Vue templates and style blocks',
|
|
11
|
+
details:
|
|
12
|
+
'Named CSS colors such as red or white bypass the Joy design token system. Prefer CSS variables from @maltjoy/themes or Joy utility classes.',
|
|
13
|
+
examples: {
|
|
14
|
+
incorrect:
|
|
15
|
+
'<div style="color: red" />\n\n<style scoped>\n.title {\n background-color: white;\n}\n</style>',
|
|
16
|
+
correct:
|
|
17
|
+
'<div class="joy-color-error-50" />\n\n<style scoped>\n.title {\n background-color: var(--joy-color-neutral-0);\n}\n</style>',
|
|
18
|
+
},
|
|
19
|
+
messageId: 'hardcodedColorName',
|
|
20
|
+
message: ERROR_MESSAGE,
|
|
21
|
+
inspectStyleText: inspectStyleTextForNamedColors,
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createVueStyleInspectionRule,
|
|
3
|
+
inspectStyleTextForHexColors,
|
|
4
|
+
} from './vue-style-visitors.js';
|
|
5
|
+
|
|
6
|
+
const ERROR_MESSAGE =
|
|
7
|
+
'Avoid hardcoded hex colors in Vue files. Use @maltjoy/themes design tokens such as var(--joy-color-*).';
|
|
8
|
+
|
|
9
|
+
export default createVueStyleInspectionRule({
|
|
10
|
+
description: 'disallow hardcoded hex colors in Vue templates and style blocks',
|
|
11
|
+
details:
|
|
12
|
+
'Hardcoded hex colors bypass the Joy design token system. Prefer CSS variables from @maltjoy/themes, for example var(--joy-color-primary-30).',
|
|
13
|
+
examples: {
|
|
14
|
+
incorrect:
|
|
15
|
+
'<div style="color: #0F6378" />\n\n<style scoped>\n.title {\n color: #fff;\n}\n</style>',
|
|
16
|
+
correct:
|
|
17
|
+
'<div class="joy-color-primary-30" />\n\n<style scoped>\n.title {\n color: var(--joy-color-neutral-0);\n}\n</style>',
|
|
18
|
+
},
|
|
19
|
+
messageId: 'hardcodedHex',
|
|
20
|
+
message: ERROR_MESSAGE,
|
|
21
|
+
inspectStyleText: inspectStyleTextForHexColors,
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createVueStyleInspectionRule,
|
|
3
|
+
inspectStyleTextForRgbColors,
|
|
4
|
+
} from './vue-style-visitors.js';
|
|
5
|
+
|
|
6
|
+
const ERROR_MESSAGE =
|
|
7
|
+
'Avoid hardcoded rgb/rgba colors in Vue files. Use @maltjoy/themes design tokens such as var(--joy-color-*).';
|
|
8
|
+
|
|
9
|
+
export default createVueStyleInspectionRule({
|
|
10
|
+
description: 'disallow hardcoded rgb/rgba colors in Vue templates and style blocks',
|
|
11
|
+
details:
|
|
12
|
+
'Hardcoded rgb/rgba colors bypass the Joy design token system. Prefer CSS variables from @maltjoy/themes, for example var(--joy-color-primary-30).',
|
|
13
|
+
examples: {
|
|
14
|
+
incorrect:
|
|
15
|
+
'<div style="color: rgb(15, 99, 120)" />\n\n<style scoped>\n.title {\n background-color: rgba(0, 0, 0, 0.5);\n}\n</style>',
|
|
16
|
+
correct:
|
|
17
|
+
'<div class="joy-color-primary-30" />\n\n<style scoped>\n.title {\n background-color: var(--joy-color-neutral-60);\n}\n</style>',
|
|
18
|
+
},
|
|
19
|
+
messageId: 'hardcodedRgb',
|
|
20
|
+
message: ERROR_MESSAGE,
|
|
21
|
+
inspectStyleText: inspectStyleTextForRgbColors,
|
|
22
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createVueStyleInspectionRule,
|
|
3
|
+
inspectStyleExpressionForInlineColors,
|
|
4
|
+
inspectStyleTextForInlineColors,
|
|
5
|
+
} from './vue-style-visitors.js';
|
|
6
|
+
|
|
7
|
+
const ERROR_MESSAGE =
|
|
8
|
+
'Avoid inline color styles in Vue templates. Use Joy utility classes or component styles with design tokens instead.';
|
|
9
|
+
|
|
10
|
+
export default createVueStyleInspectionRule({
|
|
11
|
+
description: 'disallow inline color styles in Vue templates',
|
|
12
|
+
details:
|
|
13
|
+
'Inline color styles make theming and consistency harder to maintain. Use Joy CSS classes, SCSS with var(--joy-*), or component styles instead of style or :style color declarations.',
|
|
14
|
+
examples: {
|
|
15
|
+
incorrect: '<div style="color: var(--joy-color-neutral-90)" />',
|
|
16
|
+
correct: '<div class="joy-color-neutral-90" />',
|
|
17
|
+
},
|
|
18
|
+
messageId: 'inlineStyleColor',
|
|
19
|
+
message: ERROR_MESSAGE,
|
|
20
|
+
includeStyleBlocks: false,
|
|
21
|
+
inspectStyleText: inspectStyleTextForInlineColors,
|
|
22
|
+
inspectStyleExpression: inspectStyleExpressionForInlineColors,
|
|
23
|
+
});
|