@adyen/eslint-plugin-bento 2.6.4 → 2.7.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 +11 -0
- package/configs/vue-recommended.js +2 -0
- package/configs/vue-strict.js +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
- package/rules/deprecation-components-input-emit/README.md +160 -0
- package/rules/deprecation-components-input-emit/__tests__/deprecation-components-input-emit.vue +22 -0
- package/rules/deprecation-components-input-emit/__tests__/eslint.config.js +25 -0
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.integration.test.ts +35 -0
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.js +48 -0
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.test.ts +280 -0
- package/rules/deprecation-components-value-prop/README.md +160 -0
- package/rules/deprecation-components-value-prop/__tests__/deprecation-components-value-prop.vue +69 -0
- package/rules/deprecation-components-value-prop/__tests__/eslint.config.js +25 -0
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.integration.test.ts +37 -0
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.js +61 -0
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.test.ts +424 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# deprecation-components-value-prop
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The `value` prop in the following components is deprecated:
|
|
6
|
+
|
|
7
|
+
- `bento-date-picker`
|
|
8
|
+
- `bento-date-range-picker`
|
|
9
|
+
- `bento-dropdown`
|
|
10
|
+
- `bento-dropdown-avatar`
|
|
11
|
+
- `bento-dropdown-country`
|
|
12
|
+
- `bento-dropdown-currency`
|
|
13
|
+
- `bento-dropdown-payment-method`
|
|
14
|
+
- `bento-dropdown-tag`
|
|
15
|
+
- `bento-file-uploader`
|
|
16
|
+
- `bento-input-field`
|
|
17
|
+
- `bento-input-field-password`
|
|
18
|
+
- `bento-input-field-phone-number`
|
|
19
|
+
- `bento-checkbox-group`
|
|
20
|
+
- `bento-radio-group`
|
|
21
|
+
- `bento-selection-card-group`
|
|
22
|
+
- `bento-textarea`
|
|
23
|
+
|
|
24
|
+
Please use `model-value` instead.
|
|
25
|
+
|
|
26
|
+
## Rule Details
|
|
27
|
+
|
|
28
|
+
This rule reports usages of the deprecated item.
|
|
29
|
+
|
|
30
|
+
### ❌ Incorrect
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<bento-date-picker value="value" /> <bento-date-picker :value="value" />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<bento-date-range-picker value="value" /> <bento-date-range-picker :value="value" />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<bento-dropdown value="value" /> <bento-dropdown :value="value" />
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<bento-dropdown-avatar value="value" /> <bento-dropdown-avatar :value="value" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<bento-dropdown-country value="value" /> <bento-dropdown-country :value="value" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<bento-dropdown-currency value="value" /> <bento-dropdown-currency :value="value" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<bento-dropdown-payment-method value="value" /> <bento-dropdown-payment-method :value="value" />
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<bento-dropdown-tag value="value" /> <bento-dropdown-tag :value="value" />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<bento-file-uploader value="value" /> <bento-file-uploader :value="value" />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<bento-input-field value="value" /> <bento-input-field :value="value" />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<bento-input-field-password value="value" /> <bento-input-field-password :value="value" />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<bento-input-field-phone-number value="value" /> <bento-input-field-phone-number :value="value" />
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<bento-checkbox-group value="value" /> <bento-checkbox-group :value="value" />
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<bento-radio-group value="value" /> <bento-radio-group :value="value" />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<bento-selection-card-group value="value" /> <bento-selection-card-group :value="value" />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<bento-textarea value="value" /> <bento-textarea :value="value" />
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### ✅ Correct
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<bento-date-picker model-value="value" />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
<bento-date-range-picker model-value="value" />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<bento-dropdown model-value="value" />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<bento-dropdown-avatar model-value="value" />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<bento-dropdown-country model-value="value" />
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<bento-dropdown-currency model-value="value" />
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<bento-dropdown-payment-method model-value="value" />
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```html
|
|
127
|
+
<bento-dropdown-tag model-value="value" />
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<bento-file-uploader model-value="value" />
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<bento-input-field model-value="value" />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<bento-input-field-password model-value="value" />
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```html
|
|
143
|
+
<bento-input-field-phone-number model-value="value" />
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<bento-checkbox-group model-value="value" />
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<bento-radio-group model-value="value" />
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<bento-selection-card-group model-value="value" />
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<bento-textarea model-value="value" />
|
|
160
|
+
```
|
package/rules/deprecation-components-value-prop/__tests__/deprecation-components-value-prop.vue
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<bento-date-picker value="value" />
|
|
4
|
+
<bento-date-picker :value="value" />
|
|
5
|
+
<bento-date-picker :value="value" />
|
|
6
|
+
|
|
7
|
+
<bento-date-range-picker value="value" />
|
|
8
|
+
<bento-date-range-picker :value="value" />
|
|
9
|
+
<bento-date-range-picker :value="value" />
|
|
10
|
+
|
|
11
|
+
<bento-dropdown value="value" />
|
|
12
|
+
<bento-dropdown :value="value" />
|
|
13
|
+
<bento-dropdown :value="value" />
|
|
14
|
+
|
|
15
|
+
<bento-dropdown-avatar value="value" />
|
|
16
|
+
<bento-dropdown-avatar :value="value" />
|
|
17
|
+
<bento-dropdown-avatar :value="value" />
|
|
18
|
+
|
|
19
|
+
<bento-dropdown-country value="value" />
|
|
20
|
+
<bento-dropdown-country :value="value" />
|
|
21
|
+
<bento-dropdown-country :value="value" />
|
|
22
|
+
|
|
23
|
+
<bento-dropdown-currency value="value" />
|
|
24
|
+
<bento-dropdown-currency :value="value" />
|
|
25
|
+
<bento-dropdown-currency :value="value" />
|
|
26
|
+
|
|
27
|
+
<bento-dropdown-payment-method value="value" />
|
|
28
|
+
<bento-dropdown-payment-method :value="value" />
|
|
29
|
+
<bento-dropdown-payment-method :value="value" />
|
|
30
|
+
|
|
31
|
+
<bento-dropdown-tag value="value" />
|
|
32
|
+
<bento-dropdown-tag :value="value" />
|
|
33
|
+
<bento-dropdown-tag :value="value" />
|
|
34
|
+
|
|
35
|
+
<bento-file-uploader value="value" />
|
|
36
|
+
<bento-file-uploader :value="value" />
|
|
37
|
+
<bento-file-uploader :value="value" />
|
|
38
|
+
|
|
39
|
+
<bento-input-field value="value" />
|
|
40
|
+
<bento-input-field :value="value" />
|
|
41
|
+
<bento-input-field :value="value" />
|
|
42
|
+
|
|
43
|
+
<bento-input-field-password value="value" />
|
|
44
|
+
<bento-input-field-password :value="value" />
|
|
45
|
+
<bento-input-field-password :value="value" />
|
|
46
|
+
|
|
47
|
+
<bento-input-field-phone-number value="value" />
|
|
48
|
+
<bento-input-field-phone-number :value="value" />
|
|
49
|
+
<bento-input-field-phone-number :value="value" />
|
|
50
|
+
|
|
51
|
+
<bento-checkbox-group value="value" />
|
|
52
|
+
<bento-checkbox-group :value="value" />
|
|
53
|
+
<bento-checkbox-group :value="value" />
|
|
54
|
+
|
|
55
|
+
<bento-radio-group value="value" />
|
|
56
|
+
<bento-radio-group :value="value" />
|
|
57
|
+
<bento-radio-group :value="value" />
|
|
58
|
+
|
|
59
|
+
<bento-selection-card-group value="value" />
|
|
60
|
+
<bento-selection-card-group :value="value" />
|
|
61
|
+
<bento-selection-card-group :value="value" />
|
|
62
|
+
|
|
63
|
+
<bento-textarea value="value" />
|
|
64
|
+
<bento-textarea :value="value" />
|
|
65
|
+
<bento-textarea :value="value" />
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script setup></script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { defineConfig } = require('eslint/config');
|
|
2
|
+
const vueParser = require('vue-eslint-parser');
|
|
3
|
+
const tsParser = require('@typescript-eslint/parser');
|
|
4
|
+
const adyenBento = require('@adyen/eslint-plugin-bento');
|
|
5
|
+
|
|
6
|
+
module.exports = defineConfig([
|
|
7
|
+
{
|
|
8
|
+
languageOptions: {
|
|
9
|
+
ecmaVersion: 'latest',
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
parser: vueParser,
|
|
12
|
+
parserOptions: {
|
|
13
|
+
parser: tsParser,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
'@adyen/bento': adyenBento,
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
// Register the specific rule we are testing
|
|
21
|
+
'@adyen/bento/deprecation-components-value-prop': 'warn',
|
|
22
|
+
},
|
|
23
|
+
files: ['**/*.vue'],
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
+
|
|
4
|
+
describe('@adyen/bento/deprecation-components-value-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-value-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 = 16;
|
|
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-value-prop',
|
|
27
|
+
severity: 1,
|
|
28
|
+
|
|
29
|
+
messageId: 'deprecation',
|
|
30
|
+
message: `The "value" prop is deprecated. Please use "model-value" instead.`,
|
|
31
|
+
|
|
32
|
+
fix: expect.objectContaining({
|
|
33
|
+
text: expect.stringContaining('model-value'),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('eslint').Rule.RuleContext} RuleContext
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('eslint-plugin-vue/lib/utils').RuleModule} RuleModule
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const VueUtils = require('eslint-plugin-vue/lib/utils');
|
|
9
|
+
|
|
10
|
+
/** @type {RuleModule} */
|
|
11
|
+
module.exports = {
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'suggestion',
|
|
14
|
+
docs: {
|
|
15
|
+
description:
|
|
16
|
+
'Deprecates usage of value prop in bento-date-picker, bento-date-range-picker, bento-dropdown, bento-dropdown-avatar, bento-dropdown-country, bento-dropdown-currency, bento-dropdown-payment-method, bento-dropdown-tag, bento-file-uploader, bento-input-field, bento-input-field-password, bento-input-field-phone-number, bento-checkbox-group, bento-radio-group, bento-selection-card-group, bento-textarea',
|
|
17
|
+
category: 'Deprecations',
|
|
18
|
+
url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/deprecation-components-value-prop/README.md',
|
|
19
|
+
recommended: true,
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
deprecation: `The "value" prop is deprecated. Please use "model-value" instead.`,
|
|
23
|
+
},
|
|
24
|
+
fixable: 'code',
|
|
25
|
+
schema: [],
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/** @param {RuleContext} context */
|
|
29
|
+
create(context) {
|
|
30
|
+
/* ------------------------------------------------ */
|
|
31
|
+
/* CASE 2: PROP DEPRECATION (Multiple Components) */
|
|
32
|
+
/* ------------------------------------------------ */
|
|
33
|
+
return VueUtils.defineTemplateBodyVisitor(context, {
|
|
34
|
+
// 1. STATIC: value="foo"
|
|
35
|
+
[`VElement:matches([name="bento-date-picker"], [name="BentoDatePicker"], [name="bento-date-range-picker"], [name="BentoDateRangePicker"], [name="bento-dropdown"], [name="BentoDropdown"], [name="bento-dropdown-avatar"], [name="BentoDropdownAvatar"], [name="bento-dropdown-country"], [name="BentoDropdownCountry"], [name="bento-dropdown-currency"], [name="BentoDropdownCurrency"], [name="bento-dropdown-payment-method"], [name="BentoDropdownPaymentMethod"], [name="bento-dropdown-tag"], [name="BentoDropdownTag"], [name="bento-file-uploader"], [name="BentoFileUploader"], [name="bento-input-field"], [name="BentoInputField"], [name="bento-input-field-password"], [name="BentoInputFieldPassword"], [name="bento-input-field-phone-number"], [name="BentoInputFieldPhoneNumber"], [name="bento-checkbox-group"], [name="BentoCheckboxGroup"], [name="bento-radio-group"], [name="BentoRadioGroup"], [name="bento-selection-card-group"], [name="BentoSelectionCardGroup"], [name="bento-textarea"], [name="BentoTextarea"]) > VStartTag > VAttribute[directive=false][key.name="value"]`](
|
|
36
|
+
node
|
|
37
|
+
) {
|
|
38
|
+
context.report({
|
|
39
|
+
node,
|
|
40
|
+
messageId: 'deprecation',
|
|
41
|
+
fix(fixer) {
|
|
42
|
+
return fixer.replaceText(node.key, 'model-value');
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// 2. DYNAMIC: :value="foo" or v-bind:value="foo"
|
|
48
|
+
[`VElement:matches([name="bento-date-picker"], [name="BentoDatePicker"], [name="bento-date-range-picker"], [name="BentoDateRangePicker"], [name="bento-dropdown"], [name="BentoDropdown"], [name="bento-dropdown-avatar"], [name="BentoDropdownAvatar"], [name="bento-dropdown-country"], [name="BentoDropdownCountry"], [name="bento-dropdown-currency"], [name="BentoDropdownCurrency"], [name="bento-dropdown-payment-method"], [name="BentoDropdownPaymentMethod"], [name="bento-dropdown-tag"], [name="BentoDropdownTag"], [name="bento-file-uploader"], [name="BentoFileUploader"], [name="bento-input-field"], [name="BentoInputField"], [name="bento-input-field-password"], [name="BentoInputFieldPassword"], [name="bento-input-field-phone-number"], [name="BentoInputFieldPhoneNumber"], [name="bento-checkbox-group"], [name="BentoCheckboxGroup"], [name="bento-radio-group"], [name="BentoRadioGroup"], [name="bento-selection-card-group"], [name="BentoSelectionCardGroup"], [name="bento-textarea"], [name="BentoTextarea"]) > VStartTag > VAttribute[directive=true][key.name.name="bind"][key.argument.name="value"]`](
|
|
49
|
+
node
|
|
50
|
+
) {
|
|
51
|
+
context.report({
|
|
52
|
+
node,
|
|
53
|
+
messageId: 'deprecation',
|
|
54
|
+
fix(fixer) {
|
|
55
|
+
return fixer.replaceText(node.key.argument, 'model-value');
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
};
|