@adyen/eslint-plugin-bento 2.9.0 → 2.11.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 +28 -0
- package/configs/vue-recommended.js +7 -0
- package/configs/vue-strict.js +7 -0
- package/index.js +7 -0
- package/package.json +2 -2
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/README.md +48 -0
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/deprecation-bento-data-grid-cell-action-menu-item-handler.vue +63 -0
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.integration.test.ts +24 -0
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.js +232 -0
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.test.ts +116 -0
- package/rules/deprecation-bento-popover-modifiers-prop/README.md +23 -0
- package/rules/deprecation-bento-popover-modifiers-prop/__tests__/deprecation-bento-popover-modifiers-prop.vue +9 -0
- package/rules/deprecation-bento-popover-modifiers-prop/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.integration.test.ts +24 -0
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.js +78 -0
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.test.ts +109 -0
- package/rules/deprecation-bento-timeline-item-variant-prop/README.md +25 -0
- package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/deprecation-bento-timeline-item-variant-prop.vue +9 -0
- package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.integration.test.ts +31 -0
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.js +78 -0
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.test.ts +66 -0
- package/rules/deprecation-components-aria-label-prop/README.md +62 -0
- package/rules/deprecation-components-aria-label-prop/__tests__/deprecation-components-aria-label-prop.vue +25 -0
- package/rules/deprecation-components-aria-label-prop/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.integration.test.ts +36 -0
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.js +79 -0
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.test.ts +194 -0
- package/rules/deprecation-components-has-error-prop/README.md +34 -0
- package/rules/deprecation-components-has-error-prop/__tests__/deprecation-components-has-error-prop.vue +13 -0
- package/rules/deprecation-components-has-error-prop/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.integration.test.ts +29 -0
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.js +77 -0
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.test.ts +133 -0
- package/rules/deprecation-country-custom-usage/README.md +151 -0
- package/rules/deprecation-country-custom-usage/__tests__/deprecation-country-custom-usage.vue +93 -0
- package/rules/deprecation-country-custom-usage/__tests__/eslint.config.js +25 -0
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.integration.test.ts +22 -0
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.js +569 -0
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.test.ts +380 -0
- package/rules/deprecation-input-filter-dropdown-options/README.md +44 -0
- package/rules/deprecation-input-filter-dropdown-options/__tests__/deprecation-input-filter-dropdown-options.vue +46 -0
- package/rules/deprecation-input-filter-dropdown-options/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.integration.test.ts +27 -0
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.js +135 -0
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.test.ts +392 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# deprecation-country-custom-usage
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
This rule deprecates the `variant="custom"` prop and custom `label` usage across country-related components.
|
|
6
|
+
These features are being removed because country components should use built-in variants (`name`, `iso`, `capital`, `phone_code`) rather than custom labels.
|
|
7
|
+
|
|
8
|
+
The rule covers three components:
|
|
9
|
+
|
|
10
|
+
1. **`bento-country`** — the `variant="custom"` prop and the `label` prop
|
|
11
|
+
2. **`bento-dropdown-country`** — the `variant="custom"` prop and `label` keys in the `:items` array
|
|
12
|
+
3. **`BentoFilterItemType.SELECT_COUNTRY`** — the `variant: 'custom'` option and `label` keys in `listboxItems`
|
|
13
|
+
|
|
14
|
+
## Rule Details
|
|
15
|
+
|
|
16
|
+
### `bento-country`
|
|
17
|
+
|
|
18
|
+
The `label` prop only takes effect when `variant="custom"` is set. Using either one alone is dead code.
|
|
19
|
+
|
|
20
|
+
#### ❌ Incorrect
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<!-- variant="custom" only — variant does nothing without a label -->
|
|
24
|
+
<bento-country code="NL" variant="custom" />
|
|
25
|
+
|
|
26
|
+
<!-- label only — label is ignored without variant="custom" -->
|
|
27
|
+
<bento-country code="NL" label="Custom label" />
|
|
28
|
+
|
|
29
|
+
<!-- both — deprecated, use bento-typography instead -->
|
|
30
|
+
<bento-country code="NL" variant="custom" label="Custom label" />
|
|
31
|
+
<bento-country code="NL" :variant="BentoCountryVariant.CUSTOM" :label="customLabel" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### ✅ Correct
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<!-- Use a built-in variant -->
|
|
38
|
+
<bento-country code="NL" variant="name" />
|
|
39
|
+
|
|
40
|
+
<!-- Use bento-typography for custom text -->
|
|
41
|
+
<bento-typography el="span">Custom label</bento-typography>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### `bento-dropdown-country`
|
|
45
|
+
|
|
46
|
+
The `label` key in items is only used when `variant="custom"` is set. Using either one alone is dead code.
|
|
47
|
+
|
|
48
|
+
#### ❌ Incorrect
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<!-- label in items only — labels are ignored without variant="custom" -->
|
|
52
|
+
<bento-dropdown-country :items="[{ value: 'NL', label: 'Custom label' }]" />
|
|
53
|
+
|
|
54
|
+
<!-- variant="custom" only — variant does nothing without labels in items -->
|
|
55
|
+
<bento-dropdown-country :items="[{ value: 'NL' }]" variant="custom" />
|
|
56
|
+
|
|
57
|
+
<!-- both — deprecated, use bento-dropdown instead -->
|
|
58
|
+
<bento-dropdown-country :items="[{ value: 'NL', label: 'Custom label' }]" variant="custom" />
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### ✅ Correct
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<!-- Use a built-in variant -->
|
|
65
|
+
<bento-dropdown-country :items="[{ value: 'NL' }]" variant="name" />
|
|
66
|
+
|
|
67
|
+
<!-- Use bento-dropdown for custom labels -->
|
|
68
|
+
<bento-dropdown :items="[{ value: 'NL', label: 'Custom label' }]" />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `SELECT_COUNTRY` filter config (`bento-filter-bar` / `bento-data-grid`)
|
|
72
|
+
|
|
73
|
+
The `label` key in `listboxItems` is only used when `variant: 'custom'` is set. Using either one alone is dead code.
|
|
74
|
+
|
|
75
|
+
#### ❌ Incorrect
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<!-- variant: 'custom' only -->
|
|
79
|
+
<bento-filter-bar
|
|
80
|
+
:config="[{
|
|
81
|
+
field: 'country', label: 'Country',
|
|
82
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
83
|
+
options: { listboxItems: [{ value: 'NL' }], variant: 'custom' }
|
|
84
|
+
}]"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<!-- label in listboxItems only -->
|
|
88
|
+
<bento-filter-bar
|
|
89
|
+
:config="[{
|
|
90
|
+
field: 'country', label: 'Country',
|
|
91
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
92
|
+
options: { listboxItems: [{ value: 'NL', label: 'Custom label' }] }
|
|
93
|
+
}]"
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<!-- both -->
|
|
97
|
+
<bento-filter-bar
|
|
98
|
+
:config="[{
|
|
99
|
+
field: 'country', label: 'Country',
|
|
100
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
101
|
+
options: {
|
|
102
|
+
listboxItems: [{ value: 'NL', label: 'Custom label' }],
|
|
103
|
+
variant: 'custom'
|
|
104
|
+
}
|
|
105
|
+
}]"
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### ✅ Correct
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<!-- Use a built-in variant -->
|
|
113
|
+
<bento-filter-bar
|
|
114
|
+
:config="[{
|
|
115
|
+
field: 'country', label: 'Country',
|
|
116
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
117
|
+
options: { listboxItems: [{ value: 'NL' }], variant: 'name' }
|
|
118
|
+
}]"
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<!-- Use SELECT type for custom labels -->
|
|
122
|
+
<bento-filter-bar
|
|
123
|
+
:config="[{
|
|
124
|
+
field: 'country', label: 'Country',
|
|
125
|
+
type: BentoFilterItemType.SELECT,
|
|
126
|
+
options: { listboxItems: [{ value: 'NL', label: 'Custom label' }] }
|
|
127
|
+
}]"
|
|
128
|
+
/>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Autofix
|
|
132
|
+
|
|
133
|
+
Enable opt-in autofix via ESLint config:
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
'@adyen/bento/deprecation-country-custom-usage': ['warn', { autofix: true }]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The autofix behavior depends on which deprecated props are present:
|
|
140
|
+
|
|
141
|
+
| Scenario | Autofix |
|
|
142
|
+
|---|---|
|
|
143
|
+
| `variant="custom"` only | Removes the `variant` prop/property |
|
|
144
|
+
| `label` only | Removes the `label` prop/property |
|
|
145
|
+
| Both `variant="custom"` + `label` | Full replacement (see below) |
|
|
146
|
+
|
|
147
|
+
### Full replacement (both present)
|
|
148
|
+
|
|
149
|
+
- **`bento-country`** — replaces the entire element with `<bento-typography el="span">{{ label }}</bento-typography>`
|
|
150
|
+
- **`bento-dropdown-country`** — renames the tag to `bento-dropdown` and removes the `variant` attribute
|
|
151
|
+
- **`SELECT_COUNTRY` filter** — changes `type` to `BentoFilterItemType.SELECT` and removes `variant` from options
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- bento-country: variant="custom" only (warn) -->
|
|
4
|
+
<bento-country code="NL" variant="custom" />
|
|
5
|
+
<!-- bento-country: label only (warn) -->
|
|
6
|
+
<bento-country code="NL" label="Custom label" />
|
|
7
|
+
<!-- bento-country: both (warn) -->
|
|
8
|
+
<bento-country code="NL" variant="custom" label="Custom label" />
|
|
9
|
+
|
|
10
|
+
<!-- bento-dropdown-country: label in items only (warn) -->
|
|
11
|
+
<bento-dropdown-country :items="[{ value: 'NL', label: 'Custom label' }]" />
|
|
12
|
+
<!-- bento-dropdown-country: variant="custom" only (warn) -->
|
|
13
|
+
<bento-dropdown-country :items="[{ value: 'NL' }]" variant="custom" />
|
|
14
|
+
<!-- bento-dropdown-country: both (warn) -->
|
|
15
|
+
<bento-dropdown-country :items="[{ value: 'NL', label: 'Custom label' }]" variant="custom" />
|
|
16
|
+
|
|
17
|
+
<!-- SELECT_COUNTRY filter-bar: label only (warn) -->
|
|
18
|
+
<bento-filter-bar
|
|
19
|
+
:config="[
|
|
20
|
+
{
|
|
21
|
+
field: 'c',
|
|
22
|
+
label: 'C',
|
|
23
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
24
|
+
options: { listboxItems: [{ value: 'NL', label: 'Custom label' }] },
|
|
25
|
+
},
|
|
26
|
+
]"
|
|
27
|
+
/>
|
|
28
|
+
<!-- SELECT_COUNTRY filter-bar: variant="custom" only (warn) -->
|
|
29
|
+
<bento-filter-bar
|
|
30
|
+
:config="[
|
|
31
|
+
{
|
|
32
|
+
field: 'c',
|
|
33
|
+
label: 'C',
|
|
34
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
35
|
+
options: { listboxItems: [{ value: 'NL' }], variant: 'custom' },
|
|
36
|
+
},
|
|
37
|
+
]"
|
|
38
|
+
/>
|
|
39
|
+
<!-- SELECT_COUNTRY filter-bar: both (warn x2) -->
|
|
40
|
+
<bento-filter-bar
|
|
41
|
+
:config="[
|
|
42
|
+
{
|
|
43
|
+
field: 'c',
|
|
44
|
+
label: 'C',
|
|
45
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
46
|
+
options: { listboxItems: [{ value: 'NL', label: 'Custom label' }], variant: 'custom' },
|
|
47
|
+
},
|
|
48
|
+
]"
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<!-- SELECT_COUNTRY data-grid: label only (warn) -->
|
|
52
|
+
<bento-data-grid
|
|
53
|
+
:filters="[
|
|
54
|
+
{
|
|
55
|
+
field: 'c',
|
|
56
|
+
label: 'C',
|
|
57
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
58
|
+
options: { listboxItems: [{ value: 'NL', label: 'Custom label' }] },
|
|
59
|
+
},
|
|
60
|
+
]"
|
|
61
|
+
/>
|
|
62
|
+
<!-- SELECT_COUNTRY data-grid: variant="custom" only (warn) -->
|
|
63
|
+
<bento-data-grid
|
|
64
|
+
:filters="[
|
|
65
|
+
{
|
|
66
|
+
field: 'c',
|
|
67
|
+
label: 'C',
|
|
68
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
69
|
+
options: { listboxItems: [{ value: 'NL' }], variant: 'custom' },
|
|
70
|
+
},
|
|
71
|
+
]"
|
|
72
|
+
/>
|
|
73
|
+
<!-- SELECT_COUNTRY data-grid: both (warn x2) -->
|
|
74
|
+
<bento-data-grid
|
|
75
|
+
:filters="[
|
|
76
|
+
{
|
|
77
|
+
field: 'c',
|
|
78
|
+
label: 'C',
|
|
79
|
+
type: BentoFilterItemType.SELECT_COUNTRY,
|
|
80
|
+
options: { listboxItems: [{ value: 'NL', label: 'Custom label' }], variant: 'custom' },
|
|
81
|
+
},
|
|
82
|
+
]"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<!-- Valid: non-custom usage -->
|
|
86
|
+
<bento-country code="NL" variant="name" />
|
|
87
|
+
<bento-dropdown-country :items="[{ value: 'NL' }]" />
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<script setup>
|
|
92
|
+
import { BentoFilterItemType } from '@adyen/bento-vue2';
|
|
93
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
'@adyen/bento/deprecation-country-custom-usage': ['warn', { autofix: true }],
|
|
22
|
+
},
|
|
23
|
+
files: ['**/*.vue'],
|
|
24
|
+
},
|
|
25
|
+
]);
|
package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.integration.test.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
+
|
|
4
|
+
describe('@adyen/bento/deprecation-country-custom-usage', () => {
|
|
5
|
+
it('should lint with warning', () => {
|
|
6
|
+
const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
|
|
7
|
+
const vueFile = path.resolve(__dirname, '__tests__', 'deprecation-country-custom-usage.vue');
|
|
8
|
+
|
|
9
|
+
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
10
|
+
|
|
11
|
+
// bento-country: variant only (1) + label only (1) + both (1) = 3
|
|
12
|
+
// bento-dropdown-country: label only (1) + variant only (1) + both (1) = 3
|
|
13
|
+
// filter-bar: label only (1) + variant only (1) + both (2) = 4
|
|
14
|
+
// data-grid: label only (1) + variant only (1) + both (2) = 4
|
|
15
|
+
expect(result[0].warningCount).toBe(14);
|
|
16
|
+
|
|
17
|
+
expect(result[0].messages[0]).toMatchObject({
|
|
18
|
+
ruleId: '@adyen/bento/deprecation-country-custom-usage',
|
|
19
|
+
severity: 1,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|