@adyen/eslint-plugin-bento 2.22.0 → 2.24.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/CHANGELOG.md +33 -0
- package/README.md +31 -15
- package/configs/vue-recommended.js +16 -0
- package/configs/vue-strict.js +17 -1
- package/index.js +3 -0
- package/package.json +3 -3
- package/rules/deprecation-bento-tag-variant-enum/README.md +69 -0
- package/rules/deprecation-bento-tag-variant-enum/deprecation-bento-tag-variant-enum.js +167 -0
- package/rules/deprecation-filter-bar-deprecated-props/README.md +7 -0
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.js +14 -3
- package/rules/vue-no-redundant-dialog-v-if/README.md +55 -0
- package/rules/vue-no-redundant-dialog-v-if/vue-no-redundant-dialog-v-if.js +150 -0
- package/rules/vue-no-use-bento-translation-overrides/README.md +14 -0
- package/rules/vue-no-use-bento-translation-overrides/vue-no-use-bento-translation-overrides.js +93 -0
- package/utils/component-slot-migration.js +22 -4
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/deprecation-bento-data-grid-cell-action-menu-item-handler.vue +0 -63
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.integration.test.ts +0 -24
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.test.ts +0 -116
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/deprecation-bento-date-range-picker-has-actions-prop.vue +0 -10
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/eslint.config.js +0 -29
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/remove/deprecation-bento-date-range-picker-has-actions-prop.vue +0 -11
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/remove/eslint.config.js +0 -29
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/deprecation-bento-date-range-picker-has-actions-prop.integration.test.ts +0 -47
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/deprecation-bento-date-range-picker-has-actions-prop.test.ts +0 -176
- package/rules/deprecation-bento-dropdown-size-prop/__tests__/deprecation-bento-dropdown-size-prop.vue +0 -9
- package/rules/deprecation-bento-dropdown-size-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.integration.test.ts +0 -33
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.test.ts +0 -101
- package/rules/deprecation-bento-popover-modifiers-prop/__tests__/deprecation-bento-popover-modifiers-prop.vue +0 -9
- package/rules/deprecation-bento-popover-modifiers-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.integration.test.ts +0 -24
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.test.ts +0 -109
- package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/deprecation-bento-timeline-item-variant-prop.vue +0 -9
- package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.integration.test.ts +0 -35
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.test.ts +0 -141
- package/rules/deprecation-components-aria-label-prop/__tests__/deprecation-components-aria-label-prop.vue +0 -25
- package/rules/deprecation-components-aria-label-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.integration.test.ts +0 -36
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.test.ts +0 -194
- package/rules/deprecation-components-error-prop/__tests__/deprecation-components-error-prop.vue +0 -17
- package/rules/deprecation-components-error-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.integration.test.ts +0 -41
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.test.ts +0 -153
- package/rules/deprecation-components-has-error-prop/__tests__/deprecation-components-has-error-prop.vue +0 -13
- package/rules/deprecation-components-has-error-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.integration.test.ts +0 -37
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.test.ts +0 -122
- package/rules/deprecation-components-input-emit/__tests__/deprecation-components-input-emit.vue +0 -22
- package/rules/deprecation-components-input-emit/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.integration.test.ts +0 -43
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.test.ts +0 -320
- package/rules/deprecation-components-value-prop/__tests__/deprecation-components-value-prop.vue +0 -69
- package/rules/deprecation-components-value-prop/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.integration.test.ts +0 -37
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.test.ts +0 -480
- package/rules/deprecation-country-custom-usage/__tests__/deprecation-country-custom-usage.vue +0 -93
- package/rules/deprecation-country-custom-usage/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.integration.test.ts +0 -22
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.test.ts +0 -380
- package/rules/deprecation-currency-default-slot/__tests__/deprecation-currency-default-slot.vue +0 -7
- package/rules/deprecation-currency-default-slot/__tests__/eslint.config.js +0 -24
- package/rules/deprecation-currency-default-slot/deprecation-currency-default-slot.integration.test.ts +0 -29
- package/rules/deprecation-currency-default-slot/deprecation-currency-default-slot.test.ts +0 -136
- package/rules/deprecation-filter-bar-deprecated-props/__tests__/deprecation-filter-bar-deprecated-props.vue +0 -62
- package/rules/deprecation-filter-bar-deprecated-props/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.integration.test.ts +0 -22
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.test.ts +0 -467
- package/rules/deprecation-input-filter-dropdown-options/__tests__/deprecation-input-filter-dropdown-options.vue +0 -46
- package/rules/deprecation-input-filter-dropdown-options/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.integration.test.ts +0 -27
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.test.ts +0 -392
- package/rules/deprecation-tag-default-slot/__tests__/deprecation-tag-default-slot.vue +0 -5
- package/rules/deprecation-tag-default-slot/__tests__/eslint.config.js +0 -24
- package/rules/deprecation-tag-default-slot/deprecation-tag-default-slot.integration.test.ts +0 -29
- package/rules/deprecation-tag-default-slot/deprecation-tag-default-slot.test.ts +0 -145
- package/rules/tailwind-v3-to-bento/__tests__/eslint.config.js +0 -24
- package/rules/tailwind-v3-to-bento/__tests__/tailwind-v3-to-bento.vue +0 -15
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.integration.test.ts +0 -29
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.test.ts +0 -403
- package/rules/vue-old-spacer-tokens/__tests__/eslint.config.js +0 -24
- package/rules/vue-old-spacer-tokens/__tests__/vue-old-spacer-tokens.vue +0 -5
- package/rules/vue-old-spacer-tokens/vue-old-spacer-tokens.integration.test.ts +0 -29
- package/rules/vue-old-spacer-tokens/vue-old-spacer-tokens.test.ts +0 -77
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from 'eslint';
|
|
2
|
-
import vueParser from 'vue-eslint-parser';
|
|
3
|
-
import tsParser from '@typescript-eslint/parser';
|
|
4
|
-
import deprecationBentoTimelineItemVariantProp from './deprecation-bento-timeline-item-variant-prop';
|
|
5
|
-
|
|
6
|
-
const ruleTester = new RuleTester({
|
|
7
|
-
languageOptions: {
|
|
8
|
-
ecmaVersion: 'latest',
|
|
9
|
-
sourceType: 'module',
|
|
10
|
-
parser: vueParser,
|
|
11
|
-
parserOptions: {
|
|
12
|
-
parser: tsParser,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('@adyen/bento/deprecation-bento-timeline-item-variant-prop', () => {
|
|
18
|
-
ruleTester.run('deprecation-bento-timeline-item-variant-prop', deprecationBentoTimelineItemVariantProp, {
|
|
19
|
-
valid: [
|
|
20
|
-
{
|
|
21
|
-
name: 'Valid usage with status prop',
|
|
22
|
-
filename: 'test.vue',
|
|
23
|
-
code: `
|
|
24
|
-
<template>
|
|
25
|
-
<bento-timeline-item status="green" />
|
|
26
|
-
</template>
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
invalid: [
|
|
31
|
-
// No autofix when disabled
|
|
32
|
-
{
|
|
33
|
-
name: 'Invalid: autofix disabled (explicit false)',
|
|
34
|
-
filename: 'test.vue',
|
|
35
|
-
code: `<template><bento-timeline-item variant="CheckedCircleIcon" /></template>`,
|
|
36
|
-
output: null,
|
|
37
|
-
options: [{ autofix: false }],
|
|
38
|
-
errors: [{ messageId: 'deprecation' }],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'Invalid: autofix disabled (no options)',
|
|
42
|
-
filename: 'test.vue',
|
|
43
|
-
code: `<template><bento-timeline-item :variant="BentoTimelineItemVariant.SUCCESS" /></template>`,
|
|
44
|
-
output: null,
|
|
45
|
-
errors: [{ messageId: 'deprecation' }],
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
// Static values — remaps enum value strings to colors
|
|
49
|
-
{
|
|
50
|
-
name: 'Invalid: Static variant="SquareSmallIcon" → status="black"',
|
|
51
|
-
filename: 'test.vue',
|
|
52
|
-
code: `<template><bento-timeline-item variant="SquareSmallIcon" /></template>`,
|
|
53
|
-
output: `<template><bento-timeline-item status="black" /></template>`,
|
|
54
|
-
options: [{ autofix: true }],
|
|
55
|
-
errors: [{ messageId: 'deprecation' }],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'Invalid: Static variant="CheckedCircleIcon" → status="green"',
|
|
59
|
-
filename: 'test.vue',
|
|
60
|
-
code: `<template><bento-timeline-item variant="CheckedCircleIcon" /></template>`,
|
|
61
|
-
output: `<template><bento-timeline-item status="green" /></template>`,
|
|
62
|
-
options: [{ autofix: true }],
|
|
63
|
-
errors: [{ messageId: 'deprecation' }],
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'Invalid: Static variant="CrossCircleIcon" → status="red"',
|
|
67
|
-
filename: 'test.vue',
|
|
68
|
-
code: `<template><bento-timeline-item variant="CrossCircleIcon" /></template>`,
|
|
69
|
-
output: `<template><bento-timeline-item status="red" /></template>`,
|
|
70
|
-
options: [{ autofix: true }],
|
|
71
|
-
errors: [{ messageId: 'deprecation' }],
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// Static with unknown value — no fix applied
|
|
75
|
-
{
|
|
76
|
-
name: 'Invalid: Static variant with unknown value does not autofix',
|
|
77
|
-
filename: 'test.vue',
|
|
78
|
-
code: `<template><bento-timeline-item variant="unknownValue" /></template>`,
|
|
79
|
-
output: null,
|
|
80
|
-
options: [{ autofix: true }],
|
|
81
|
-
errors: [{ messageId: 'deprecation' }],
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
// Dynamic with enum member expression — remaps enum key to color
|
|
85
|
-
{
|
|
86
|
-
name: 'Invalid: Dynamic :variant="BentoTimelineItemVariant.DEFAULT" → status="black"',
|
|
87
|
-
filename: 'test.vue',
|
|
88
|
-
code: `<template><bento-timeline-item :variant="BentoTimelineItemVariant.DEFAULT" /></template>`,
|
|
89
|
-
output: `<template><bento-timeline-item status="black" /></template>`,
|
|
90
|
-
options: [{ autofix: true }],
|
|
91
|
-
errors: [{ messageId: 'deprecation' }],
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
name: 'Invalid: Dynamic :variant="BentoTimelineItemVariant.SUCCESS" → status="green"',
|
|
95
|
-
filename: 'test.vue',
|
|
96
|
-
code: `<template><bento-timeline-item :variant="BentoTimelineItemVariant.SUCCESS" /></template>`,
|
|
97
|
-
output: `<template><bento-timeline-item status="green" /></template>`,
|
|
98
|
-
options: [{ autofix: true }],
|
|
99
|
-
errors: [{ messageId: 'deprecation' }],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: 'Invalid: Dynamic :variant="BentoTimelineItemVariant.CRITICAL" → status="red"',
|
|
103
|
-
filename: 'test.vue',
|
|
104
|
-
code: `<template><bento-timeline-item :variant="BentoTimelineItemVariant.CRITICAL" /></template>`,
|
|
105
|
-
output: `<template><bento-timeline-item status="red" /></template>`,
|
|
106
|
-
options: [{ autofix: true }],
|
|
107
|
-
errors: [{ messageId: 'deprecation' }],
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
// Dynamic with string literal — remaps value to color
|
|
111
|
-
{
|
|
112
|
-
name: 'Invalid: Dynamic :variant="\'CheckedCircleIcon\'" → status="green"',
|
|
113
|
-
filename: 'test.vue',
|
|
114
|
-
code: `<template><bento-timeline-item :variant="'CheckedCircleIcon'" /></template>`,
|
|
115
|
-
output: `<template><bento-timeline-item status="green" /></template>`,
|
|
116
|
-
options: [{ autofix: true }],
|
|
117
|
-
errors: [{ messageId: 'deprecation' }],
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
// Dynamic with unknown expression — no fix applied
|
|
121
|
-
{
|
|
122
|
-
name: 'Invalid: Dynamic :variant with unknown expression does not autofix',
|
|
123
|
-
filename: 'test.vue',
|
|
124
|
-
code: `<template><bento-timeline-item :variant="computedVariant" /></template>`,
|
|
125
|
-
output: null,
|
|
126
|
-
options: [{ autofix: true }],
|
|
127
|
-
errors: [{ messageId: 'deprecation' }],
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
// Dynamic with non-BentoTimelineItemVariant enum — no fix applied
|
|
131
|
-
{
|
|
132
|
-
name: 'Invalid: Dynamic :variant with unrelated enum does not autofix',
|
|
133
|
-
filename: 'test.vue',
|
|
134
|
-
code: `<template><bento-timeline-item :variant="customStatus.SUCCESS" /></template>`,
|
|
135
|
-
output: null,
|
|
136
|
-
options: [{ autofix: true }],
|
|
137
|
-
errors: [{ messageId: 'deprecation' }],
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
});
|
|
141
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<bento-dropdown ariaLabel="value" />
|
|
4
|
-
<bento-dropdown :ariaLabel="value" />
|
|
5
|
-
<bento-dropdown v-bind:ariaLabel="value" />
|
|
6
|
-
|
|
7
|
-
<bento-input-field ariaLabel="value" />
|
|
8
|
-
<bento-input-field :ariaLabel="value" />
|
|
9
|
-
<bento-input-field v-bind:ariaLabel="value" />
|
|
10
|
-
|
|
11
|
-
<bento-pagination ariaLabel="value" />
|
|
12
|
-
<bento-pagination :ariaLabel="value" />
|
|
13
|
-
<bento-pagination v-bind:ariaLabel="value" />
|
|
14
|
-
|
|
15
|
-
<bento-popover ariaLabel="value" />
|
|
16
|
-
<bento-popover :ariaLabel="value" />
|
|
17
|
-
<bento-popover v-bind:ariaLabel="value" />
|
|
18
|
-
|
|
19
|
-
<bento-segmented-control ariaLabel="value" />
|
|
20
|
-
<bento-segmented-control :ariaLabel="value" />
|
|
21
|
-
<bento-segmented-control v-bind:ariaLabel="value" />
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script setup></script>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// eslint.config.js
|
|
2
|
-
const { defineConfig } = require('eslint/config');
|
|
3
|
-
const vueParser = require('vue-eslint-parser');
|
|
4
|
-
const tsParser = require('@typescript-eslint/parser');
|
|
5
|
-
const adyenBento = require('@adyen/eslint-plugin-bento');
|
|
6
|
-
|
|
7
|
-
module.exports = defineConfig([
|
|
8
|
-
{
|
|
9
|
-
languageOptions: {
|
|
10
|
-
ecmaVersion: 'latest',
|
|
11
|
-
sourceType: 'module',
|
|
12
|
-
parser: vueParser,
|
|
13
|
-
parserOptions: {
|
|
14
|
-
parser: tsParser,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
plugins: {
|
|
18
|
-
'@adyen/bento': adyenBento,
|
|
19
|
-
},
|
|
20
|
-
rules: {
|
|
21
|
-
// Register the specific rule we are testing
|
|
22
|
-
'@adyen/bento/deprecation-components-aria-label-prop': 'warn',
|
|
23
|
-
},
|
|
24
|
-
files: ['**/*.vue'],
|
|
25
|
-
},
|
|
26
|
-
]);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
-
|
|
4
|
-
describe('@adyen/bento/deprecation-components-aria-label-prop', () => {
|
|
5
|
-
it('should lint with warning', () => {
|
|
6
|
-
// Load .eslintrc
|
|
7
|
-
const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
|
|
8
|
-
// Load the test file generated alongside this one
|
|
9
|
-
const vueFile = path.resolve(__dirname, '__tests__', 'deprecation-components-aria-label-prop.vue');
|
|
10
|
-
|
|
11
|
-
// Execute the linter
|
|
12
|
-
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
13
|
-
|
|
14
|
-
/* ------------------------------------------------ */
|
|
15
|
-
/* CASE 2: SINGLE REPLACEMENT */
|
|
16
|
-
/* ------------------------------------------------ */
|
|
17
|
-
|
|
18
|
-
// For props, we generate 3 examples (static, shorthand, longhand) FOR EACH component.
|
|
19
|
-
// Total = (Number of Components) * 3
|
|
20
|
-
const numberOfComponents = 5;
|
|
21
|
-
expect(result[0].warningCount).toBe(numberOfComponents * 3);
|
|
22
|
-
|
|
23
|
-
// Verify the message structure on the first error found.
|
|
24
|
-
// Since the rule is the same for all components, checking the first one confirms the message is correct.
|
|
25
|
-
expect(result[0].messages[0]).toMatchObject({
|
|
26
|
-
ruleId: '@adyen/bento/deprecation-components-aria-label-prop',
|
|
27
|
-
severity: 1,
|
|
28
|
-
|
|
29
|
-
messageId: 'deprecation',
|
|
30
|
-
message: `The "ariaLabel" prop is deprecated. Please use "aria-label" instead.`,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Without autofix option, no fix should be present
|
|
34
|
-
expect(result[0].messages[0].fix).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
});
|
package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.test.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from 'eslint';
|
|
2
|
-
import vueParser from 'vue-eslint-parser';
|
|
3
|
-
import tsParser from '@typescript-eslint/parser';
|
|
4
|
-
import deprecationComponentsAriaLabelProp from './deprecation-components-aria-label-prop';
|
|
5
|
-
|
|
6
|
-
const ruleTester = new RuleTester({
|
|
7
|
-
languageOptions: {
|
|
8
|
-
ecmaVersion: 'latest',
|
|
9
|
-
sourceType: 'module',
|
|
10
|
-
parser: vueParser,
|
|
11
|
-
parserOptions: {
|
|
12
|
-
parser: tsParser,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('@adyen/bento/deprecation-components-aria-label-prop', () => {
|
|
18
|
-
ruleTester.run('deprecation-components-aria-label-prop', deprecationComponentsAriaLabelProp, {
|
|
19
|
-
valid: [
|
|
20
|
-
{
|
|
21
|
-
name: 'Valid usage for bento-dropdown',
|
|
22
|
-
filename: 'test.vue',
|
|
23
|
-
code: `
|
|
24
|
-
<template>
|
|
25
|
-
<bento-dropdown aria-label="val" />
|
|
26
|
-
</template>
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'Valid usage for bento-input-field',
|
|
31
|
-
filename: 'test.vue',
|
|
32
|
-
code: `
|
|
33
|
-
<template>
|
|
34
|
-
<bento-input-field aria-label="val" />
|
|
35
|
-
</template>
|
|
36
|
-
`,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'Valid usage for bento-pagination',
|
|
40
|
-
filename: 'test.vue',
|
|
41
|
-
code: `
|
|
42
|
-
<template>
|
|
43
|
-
<bento-pagination aria-label="val" />
|
|
44
|
-
</template>
|
|
45
|
-
`,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'Valid usage for bento-popover',
|
|
49
|
-
filename: 'test.vue',
|
|
50
|
-
code: `
|
|
51
|
-
<template>
|
|
52
|
-
<bento-popover aria-label="val" />
|
|
53
|
-
</template>
|
|
54
|
-
`,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'Valid usage for bento-segmented-control',
|
|
58
|
-
filename: 'test.vue',
|
|
59
|
-
code: `
|
|
60
|
-
<template>
|
|
61
|
-
<bento-segmented-control aria-label="val" />
|
|
62
|
-
</template>
|
|
63
|
-
`,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
invalid: [
|
|
67
|
-
// bento-dropdown: Static
|
|
68
|
-
{
|
|
69
|
-
name: 'Invalid: Static prop on bento-dropdown',
|
|
70
|
-
filename: 'test.vue',
|
|
71
|
-
code: `<template><bento-dropdown ariaLabel="val" /></template>`,
|
|
72
|
-
errors: [{ messageId: 'deprecation' }],
|
|
73
|
-
},
|
|
74
|
-
// bento-dropdown: Shorthand
|
|
75
|
-
{
|
|
76
|
-
name: 'Invalid: Dynamic prop on bento-dropdown',
|
|
77
|
-
filename: 'test.vue',
|
|
78
|
-
code: `<template><bento-dropdown :ariaLabel="val" /></template>`,
|
|
79
|
-
errors: [{ messageId: 'deprecation' }],
|
|
80
|
-
},
|
|
81
|
-
// bento-input-field: Static
|
|
82
|
-
{
|
|
83
|
-
name: 'Invalid: Static prop on bento-input-field',
|
|
84
|
-
filename: 'test.vue',
|
|
85
|
-
code: `<template><bento-input-field ariaLabel="val" /></template>`,
|
|
86
|
-
errors: [{ messageId: 'deprecation' }],
|
|
87
|
-
},
|
|
88
|
-
// bento-input-field: Shorthand
|
|
89
|
-
{
|
|
90
|
-
name: 'Invalid: Dynamic prop on bento-input-field',
|
|
91
|
-
filename: 'test.vue',
|
|
92
|
-
code: `<template><bento-input-field :ariaLabel="val" /></template>`,
|
|
93
|
-
errors: [{ messageId: 'deprecation' }],
|
|
94
|
-
},
|
|
95
|
-
// bento-pagination: Static
|
|
96
|
-
{
|
|
97
|
-
name: 'Invalid: Static prop on bento-pagination',
|
|
98
|
-
filename: 'test.vue',
|
|
99
|
-
code: `<template><bento-pagination ariaLabel="val" /></template>`,
|
|
100
|
-
errors: [{ messageId: 'deprecation' }],
|
|
101
|
-
},
|
|
102
|
-
// bento-pagination: Shorthand
|
|
103
|
-
{
|
|
104
|
-
name: 'Invalid: Dynamic prop on bento-pagination',
|
|
105
|
-
filename: 'test.vue',
|
|
106
|
-
code: `<template><bento-pagination :ariaLabel="val" /></template>`,
|
|
107
|
-
errors: [{ messageId: 'deprecation' }],
|
|
108
|
-
},
|
|
109
|
-
// bento-popover: Static
|
|
110
|
-
{
|
|
111
|
-
name: 'Invalid: Static prop on bento-popover',
|
|
112
|
-
filename: 'test.vue',
|
|
113
|
-
code: `<template><bento-popover ariaLabel="val" /></template>`,
|
|
114
|
-
errors: [{ messageId: 'deprecation' }],
|
|
115
|
-
},
|
|
116
|
-
// bento-popover: Shorthand
|
|
117
|
-
{
|
|
118
|
-
name: 'Invalid: Dynamic prop on bento-popover',
|
|
119
|
-
filename: 'test.vue',
|
|
120
|
-
code: `<template><bento-popover :ariaLabel="val" /></template>`,
|
|
121
|
-
errors: [{ messageId: 'deprecation' }],
|
|
122
|
-
},
|
|
123
|
-
// bento-segmented-control: Static
|
|
124
|
-
{
|
|
125
|
-
name: 'Invalid: Static prop on bento-segmented-control',
|
|
126
|
-
filename: 'test.vue',
|
|
127
|
-
code: `<template><bento-segmented-control ariaLabel="val" /></template>`,
|
|
128
|
-
errors: [{ messageId: 'deprecation' }],
|
|
129
|
-
},
|
|
130
|
-
// bento-segmented-control: Shorthand
|
|
131
|
-
{
|
|
132
|
-
name: 'Invalid: Dynamic prop on bento-segmented-control',
|
|
133
|
-
filename: 'test.vue',
|
|
134
|
-
code: `<template><bento-segmented-control :ariaLabel="val" /></template>`,
|
|
135
|
-
errors: [{ messageId: 'deprecation' }],
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
/* ------------------------------------------------ */
|
|
141
|
-
/* AUTOFIX TESTS */
|
|
142
|
-
/* ------------------------------------------------ */
|
|
143
|
-
ruleTester.run('deprecation-components-aria-label-prop (autofix enabled)', deprecationComponentsAriaLabelProp, {
|
|
144
|
-
valid: [
|
|
145
|
-
{
|
|
146
|
-
name: 'Valid: aria-label (kebab-case) on bento-dropdown (autofix enabled)',
|
|
147
|
-
filename: 'test.vue',
|
|
148
|
-
options: [{ autofix: true }],
|
|
149
|
-
code: `<template><bento-dropdown aria-label="val" /></template>`,
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
invalid: [
|
|
153
|
-
{
|
|
154
|
-
name: 'Autofix: static prop on bento-dropdown',
|
|
155
|
-
filename: 'test.vue',
|
|
156
|
-
options: [{ autofix: true }],
|
|
157
|
-
code: `<template><bento-dropdown ariaLabel="val" /></template>`,
|
|
158
|
-
output: `<template><bento-dropdown aria-label="val" /></template>`,
|
|
159
|
-
errors: [{ messageId: 'deprecation' }],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: 'Autofix: dynamic prop on bento-dropdown',
|
|
163
|
-
filename: 'test.vue',
|
|
164
|
-
options: [{ autofix: true }],
|
|
165
|
-
code: `<template><bento-dropdown :ariaLabel="val" /></template>`,
|
|
166
|
-
output: `<template><bento-dropdown :aria-label="val" /></template>`,
|
|
167
|
-
errors: [{ messageId: 'deprecation' }],
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
name: 'Autofix: static prop on bento-segmented-control',
|
|
171
|
-
filename: 'test.vue',
|
|
172
|
-
options: [{ autofix: true }],
|
|
173
|
-
code: `<template><bento-segmented-control ariaLabel="val" /></template>`,
|
|
174
|
-
output: `<template><bento-segmented-control aria-label="val" /></template>`,
|
|
175
|
-
errors: [{ messageId: 'deprecation' }],
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: 'Autofix: v-bind longhand on bento-popover',
|
|
179
|
-
filename: 'test.vue',
|
|
180
|
-
options: [{ autofix: true }],
|
|
181
|
-
code: `<template><bento-popover v-bind:ariaLabel="val" /></template>`,
|
|
182
|
-
output: `<template><bento-popover v-bind:aria-label="val" /></template>`,
|
|
183
|
-
errors: [{ messageId: 'deprecation' }],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: 'Autofix: does not fix when autofix is false',
|
|
187
|
-
filename: 'test.vue',
|
|
188
|
-
options: [{ autofix: false }],
|
|
189
|
-
code: `<template><bento-dropdown ariaLabel="val" /></template>`,
|
|
190
|
-
errors: [{ messageId: 'deprecation' }],
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
});
|
|
194
|
-
});
|
package/rules/deprecation-components-error-prop/__tests__/deprecation-components-error-prop.vue
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<bento-dropdown error="value" />
|
|
4
|
-
<bento-dropdown :error="value" />
|
|
5
|
-
<bento-dropdown :error="value" />
|
|
6
|
-
|
|
7
|
-
<bento-input-field error="value" />
|
|
8
|
-
<bento-input-field :error="value" />
|
|
9
|
-
<bento-input-field :error="value" />
|
|
10
|
-
|
|
11
|
-
<bento-input-field-phone-number error="value" />
|
|
12
|
-
<bento-input-field-phone-number :error="value" />
|
|
13
|
-
<bento-input-field-phone-number :error="value" />
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script setup></script>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// eslint.config.js
|
|
2
|
-
const { defineConfig } = require('eslint/config');
|
|
3
|
-
const vueParser = require('vue-eslint-parser');
|
|
4
|
-
const tsParser = require('@typescript-eslint/parser');
|
|
5
|
-
const adyenBento = require('@adyen/eslint-plugin-bento');
|
|
6
|
-
|
|
7
|
-
module.exports = defineConfig([
|
|
8
|
-
{
|
|
9
|
-
languageOptions: {
|
|
10
|
-
ecmaVersion: 'latest',
|
|
11
|
-
sourceType: 'module',
|
|
12
|
-
parser: vueParser,
|
|
13
|
-
parserOptions: {
|
|
14
|
-
parser: tsParser,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
plugins: {
|
|
18
|
-
'@adyen/bento': adyenBento,
|
|
19
|
-
},
|
|
20
|
-
rules: {
|
|
21
|
-
// Register the specific rule we are testing
|
|
22
|
-
'@adyen/bento/deprecation-components-error-prop': 'warn',
|
|
23
|
-
},
|
|
24
|
-
files: ['**/*.vue'],
|
|
25
|
-
},
|
|
26
|
-
]);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
-
|
|
4
|
-
describe('@adyen/bento/deprecation-components-error-prop', () => {
|
|
5
|
-
it('should lint with warning', () => {
|
|
6
|
-
// Load .eslintrc
|
|
7
|
-
const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
|
|
8
|
-
// Load the test file generated alongside this one
|
|
9
|
-
const vueFile = path.resolve(__dirname, '__tests__', 'deprecation-components-error-prop.vue');
|
|
10
|
-
|
|
11
|
-
// Execute the linter — strip any non-JSON preamble (e.g. pnpm warnings)
|
|
12
|
-
const rawOutput = execFileSyncEslintVueFiles(eslintrc, vueFile);
|
|
13
|
-
const jsonStart = rawOutput.indexOf('[{"');
|
|
14
|
-
const result = JSON.parse(jsonStart >= 0 ? rawOutput.slice(jsonStart) : rawOutput);
|
|
15
|
-
|
|
16
|
-
/* ------------------------------------------------ */
|
|
17
|
-
/* CASE 2: SINGLE REPLACEMENT */
|
|
18
|
-
/* ------------------------------------------------ */
|
|
19
|
-
|
|
20
|
-
// For props, we generate 3 examples (static, shorthand, longhand) FOR EACH component.
|
|
21
|
-
// Total = (Number of Components) * 3
|
|
22
|
-
const numberOfComponents = 3;
|
|
23
|
-
expect(result[0].warningCount).toBe(numberOfComponents * 3);
|
|
24
|
-
|
|
25
|
-
// Verify the message structure on the first warning found.
|
|
26
|
-
expect(result[0].messages[0]).toMatchObject({
|
|
27
|
-
ruleId: '@adyen/bento/deprecation-components-error-prop',
|
|
28
|
-
severity: 1,
|
|
29
|
-
messageId: 'deprecation',
|
|
30
|
-
message: `The "error" prop is deprecated. Use "error-message" instead. Note that "error" accepted a boolean, but "error-message" expects a string, so update the value to an error message.`,
|
|
31
|
-
suggestions: expect.arrayContaining([
|
|
32
|
-
expect.objectContaining({
|
|
33
|
-
messageId: 'suggestReplace',
|
|
34
|
-
fix: expect.objectContaining({
|
|
35
|
-
text: expect.stringContaining('error-message'),
|
|
36
|
-
}),
|
|
37
|
-
}),
|
|
38
|
-
]),
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from 'eslint';
|
|
2
|
-
import vueParser from 'vue-eslint-parser';
|
|
3
|
-
import tsParser from '@typescript-eslint/parser';
|
|
4
|
-
import deprecationComponentsErrorProp from './deprecation-components-error-prop';
|
|
5
|
-
|
|
6
|
-
const ruleTester = new RuleTester({
|
|
7
|
-
languageOptions: {
|
|
8
|
-
ecmaVersion: 'latest',
|
|
9
|
-
sourceType: 'module',
|
|
10
|
-
parser: vueParser,
|
|
11
|
-
parserOptions: {
|
|
12
|
-
parser: tsParser,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('@adyen/bento/deprecation-components-error-prop', () => {
|
|
18
|
-
ruleTester.run('deprecation-components-error-prop', deprecationComponentsErrorProp, {
|
|
19
|
-
valid: [
|
|
20
|
-
{
|
|
21
|
-
name: 'Valid usage for bento-dropdown',
|
|
22
|
-
filename: 'test.vue',
|
|
23
|
-
code: `
|
|
24
|
-
<template>
|
|
25
|
-
<bento-dropdown error-message="val" />
|
|
26
|
-
</template>
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'Valid usage for bento-input-field',
|
|
31
|
-
filename: 'test.vue',
|
|
32
|
-
code: `
|
|
33
|
-
<template>
|
|
34
|
-
<bento-input-field error-message="val" />
|
|
35
|
-
</template>
|
|
36
|
-
`,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'Valid usage for bento-input-field-phone-number',
|
|
40
|
-
filename: 'test.vue',
|
|
41
|
-
code: `
|
|
42
|
-
<template>
|
|
43
|
-
<bento-input-field-phone-number error-message="val" />
|
|
44
|
-
</template>
|
|
45
|
-
`,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
invalid: [
|
|
49
|
-
// bento-dropdown: Static
|
|
50
|
-
{
|
|
51
|
-
name: 'Invalid: Static prop on bento-dropdown',
|
|
52
|
-
filename: 'test.vue',
|
|
53
|
-
code: `<template><bento-dropdown error="val" /></template>`,
|
|
54
|
-
errors: [
|
|
55
|
-
{
|
|
56
|
-
messageId: 'deprecation',
|
|
57
|
-
suggestions: [
|
|
58
|
-
{
|
|
59
|
-
messageId: 'suggestReplace',
|
|
60
|
-
output: `<template><bento-dropdown error-message="val" /></template>`,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
// bento-dropdown: Dynamic
|
|
67
|
-
{
|
|
68
|
-
name: 'Invalid: Dynamic prop on bento-dropdown',
|
|
69
|
-
filename: 'test.vue',
|
|
70
|
-
code: `<template><bento-dropdown :error="val" /></template>`,
|
|
71
|
-
errors: [
|
|
72
|
-
{
|
|
73
|
-
messageId: 'deprecation',
|
|
74
|
-
suggestions: [
|
|
75
|
-
{
|
|
76
|
-
messageId: 'suggestReplace',
|
|
77
|
-
output: `<template><bento-dropdown :error-message="val" /></template>`,
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
// bento-input-field: Static
|
|
84
|
-
{
|
|
85
|
-
name: 'Invalid: Static prop on bento-input-field',
|
|
86
|
-
filename: 'test.vue',
|
|
87
|
-
code: `<template><bento-input-field error="val" /></template>`,
|
|
88
|
-
errors: [
|
|
89
|
-
{
|
|
90
|
-
messageId: 'deprecation',
|
|
91
|
-
suggestions: [
|
|
92
|
-
{
|
|
93
|
-
messageId: 'suggestReplace',
|
|
94
|
-
output: `<template><bento-input-field error-message="val" /></template>`,
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
// bento-input-field: Dynamic
|
|
101
|
-
{
|
|
102
|
-
name: 'Invalid: Dynamic prop on bento-input-field',
|
|
103
|
-
filename: 'test.vue',
|
|
104
|
-
code: `<template><bento-input-field :error="val" /></template>`,
|
|
105
|
-
errors: [
|
|
106
|
-
{
|
|
107
|
-
messageId: 'deprecation',
|
|
108
|
-
suggestions: [
|
|
109
|
-
{
|
|
110
|
-
messageId: 'suggestReplace',
|
|
111
|
-
output: `<template><bento-input-field :error-message="val" /></template>`,
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
},
|
|
117
|
-
// bento-input-field-phone-number: Static
|
|
118
|
-
{
|
|
119
|
-
name: 'Invalid: Static prop on bento-input-field-phone-number',
|
|
120
|
-
filename: 'test.vue',
|
|
121
|
-
code: `<template><bento-input-field-phone-number error="val" /></template>`,
|
|
122
|
-
errors: [
|
|
123
|
-
{
|
|
124
|
-
messageId: 'deprecation',
|
|
125
|
-
suggestions: [
|
|
126
|
-
{
|
|
127
|
-
messageId: 'suggestReplace',
|
|
128
|
-
output: `<template><bento-input-field-phone-number error-message="val" /></template>`,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
},
|
|
134
|
-
// bento-input-field-phone-number: Dynamic
|
|
135
|
-
{
|
|
136
|
-
name: 'Invalid: Dynamic prop on bento-input-field-phone-number',
|
|
137
|
-
filename: 'test.vue',
|
|
138
|
-
code: `<template><bento-input-field-phone-number :error="val" /></template>`,
|
|
139
|
-
errors: [
|
|
140
|
-
{
|
|
141
|
-
messageId: 'deprecation',
|
|
142
|
-
suggestions: [
|
|
143
|
-
{
|
|
144
|
-
messageId: 'suggestReplace',
|
|
145
|
-
output: `<template><bento-input-field-phone-number :error-message="val" /></template>`,
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
});
|
|
153
|
-
});
|