@adyen/eslint-plugin-bento 2.7.7 → 2.9.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 +26 -0
- package/README.md +48 -15
- package/configs/tailwind.js +17 -0
- package/configs/vue-recommended.js +3 -0
- package/configs/vue-strict.js +3 -0
- package/index.js +5 -0
- package/package.json +1 -1
- package/rules/deprecation-bento-dropdown-size-prop/README.md +25 -0
- package/rules/deprecation-bento-dropdown-size-prop/__tests__/deprecation-bento-dropdown-size-prop.vue +9 -0
- package/rules/deprecation-bento-dropdown-size-prop/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.integration.test.ts +33 -0
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.js +78 -0
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.test.ts +101 -0
- package/rules/deprecation-components-error-prop/README.md +43 -0
- package/rules/deprecation-components-error-prop/__tests__/deprecation-components-error-prop.vue +17 -0
- package/rules/deprecation-components-error-prop/__tests__/eslint.config.js +26 -0
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.integration.test.ts +37 -0
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.js +79 -0
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.test.ts +120 -0
- package/rules/deprecation-components-input-emit/__tests__/eslint.config.js +1 -1
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.js +19 -4
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.test.ts +40 -0
- package/rules/deprecation-components-value-prop/__tests__/eslint.config.js +1 -1
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.js +24 -7
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.test.ts +56 -0
- package/rules/deprecation-filter-bar-deprecated-props/README.md +64 -0
- package/rules/deprecation-filter-bar-deprecated-props/__tests__/deprecation-filter-bar-deprecated-props.vue +48 -0
- package/rules/deprecation-filter-bar-deprecated-props/__tests__/eslint.config.js +25 -0
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.integration.test.ts +22 -0
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.js +187 -0
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.test.ts +421 -0
- package/rules/tailwind-v3-to-bento/README.md +114 -0
- package/rules/tailwind-v3-to-bento/__tests__/eslint.config.js +24 -0
- package/rules/tailwind-v3-to-bento/__tests__/tailwind-v3-to-bento.vue +15 -0
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.integration.test.ts +29 -0
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.js +377 -0
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.test.ts +403 -0
|
@@ -0,0 +1,79 @@
|
|
|
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 error prop in bento-dropdown, bento-input-field, bento-input-field-phone-number',
|
|
17
|
+
category: 'Deprecations',
|
|
18
|
+
url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/deprecation-components-error-prop/README.md',
|
|
19
|
+
recommended: true,
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
deprecation: `The "error" prop is deprecated. Please use "error-message" instead.`,
|
|
23
|
+
},
|
|
24
|
+
fixable: 'code',
|
|
25
|
+
schema: [
|
|
26
|
+
{
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
autofix: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/** @param {RuleContext} context */
|
|
40
|
+
create(context) {
|
|
41
|
+
const options = context.options[0] || {};
|
|
42
|
+
const autofix = options.autofix === true;
|
|
43
|
+
|
|
44
|
+
/* ------------------------------------------------ */
|
|
45
|
+
/* CASE 2: PROP DEPRECATION (Multiple Components) */
|
|
46
|
+
/* ------------------------------------------------ */
|
|
47
|
+
return VueUtils.defineTemplateBodyVisitor(context, {
|
|
48
|
+
// 1. STATIC: value="foo"
|
|
49
|
+
[`VElement:matches([name="bento-dropdown"], [name="BentoDropdown"], [name="bento-input-field"], [name="BentoInputField"], [name="bento-input-field-phone-number"], [name="BentoInputFieldPhoneNumber"]) > VStartTag > VAttribute[directive=false][key.name="error"]`](
|
|
50
|
+
node
|
|
51
|
+
) {
|
|
52
|
+
context.report({
|
|
53
|
+
node,
|
|
54
|
+
messageId: 'deprecation',
|
|
55
|
+
...(autofix && {
|
|
56
|
+
fix(fixer) {
|
|
57
|
+
return fixer.replaceText(node.key, 'error-message');
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// 2. DYNAMIC: :value="foo" or v-bind:value="foo"
|
|
64
|
+
[`VElement:matches([name="bento-dropdown"], [name="BentoDropdown"], [name="bento-input-field"], [name="BentoInputField"], [name="bento-input-field-phone-number"], [name="BentoInputFieldPhoneNumber"]) > VStartTag > VAttribute[directive=true][key.name.name="bind"][key.argument.name="error"]`](
|
|
65
|
+
node
|
|
66
|
+
) {
|
|
67
|
+
context.report({
|
|
68
|
+
node,
|
|
69
|
+
messageId: 'deprecation',
|
|
70
|
+
...(autofix && {
|
|
71
|
+
fix(fixer) {
|
|
72
|
+
return fixer.replaceText(node.key.argument, 'error-message');
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
{
|
|
50
|
+
name: 'Invalid: autofix disabled (explicit false)',
|
|
51
|
+
filename: 'test.vue',
|
|
52
|
+
code: `<template><bento-dropdown error="val" /></template>`,
|
|
53
|
+
output: null,
|
|
54
|
+
options: [{ autofix: false }],
|
|
55
|
+
errors: [{ messageId: 'deprecation' }],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'Invalid: autofix disabled (no options)',
|
|
59
|
+
filename: 'test.vue',
|
|
60
|
+
code: `<template><bento-dropdown :error="val" /></template>`,
|
|
61
|
+
output: null,
|
|
62
|
+
errors: [{ messageId: 'deprecation' }],
|
|
63
|
+
},
|
|
64
|
+
// bento-dropdown: Static
|
|
65
|
+
{
|
|
66
|
+
name: 'Invalid: Static prop on bento-dropdown',
|
|
67
|
+
filename: 'test.vue',
|
|
68
|
+
code: `<template><bento-dropdown error="val" /></template>`,
|
|
69
|
+
output: `<template><bento-dropdown error-message="val" /></template>`,
|
|
70
|
+
options: [{ autofix: true }],
|
|
71
|
+
errors: [{ messageId: 'deprecation' }],
|
|
72
|
+
},
|
|
73
|
+
// bento-dropdown: Shorthand
|
|
74
|
+
{
|
|
75
|
+
name: 'Invalid: Dynamic prop on bento-dropdown',
|
|
76
|
+
filename: 'test.vue',
|
|
77
|
+
code: `<template><bento-dropdown :error="val" /></template>`,
|
|
78
|
+
output: `<template><bento-dropdown :error-message="val" /></template>`,
|
|
79
|
+
options: [{ autofix: true }],
|
|
80
|
+
errors: [{ messageId: 'deprecation' }],
|
|
81
|
+
},
|
|
82
|
+
// bento-input-field: Static
|
|
83
|
+
{
|
|
84
|
+
name: 'Invalid: Static prop on bento-input-field',
|
|
85
|
+
filename: 'test.vue',
|
|
86
|
+
code: `<template><bento-input-field error="val" /></template>`,
|
|
87
|
+
output: `<template><bento-input-field error-message="val" /></template>`,
|
|
88
|
+
options: [{ autofix: true }],
|
|
89
|
+
errors: [{ messageId: 'deprecation' }],
|
|
90
|
+
},
|
|
91
|
+
// bento-input-field: Shorthand
|
|
92
|
+
{
|
|
93
|
+
name: 'Invalid: Dynamic prop on bento-input-field',
|
|
94
|
+
filename: 'test.vue',
|
|
95
|
+
code: `<template><bento-input-field :error="val" /></template>`,
|
|
96
|
+
output: `<template><bento-input-field :error-message="val" /></template>`,
|
|
97
|
+
options: [{ autofix: true }],
|
|
98
|
+
errors: [{ messageId: 'deprecation' }],
|
|
99
|
+
},
|
|
100
|
+
// bento-input-field-phone-number: Static
|
|
101
|
+
{
|
|
102
|
+
name: 'Invalid: Static prop on bento-input-field-phone-number',
|
|
103
|
+
filename: 'test.vue',
|
|
104
|
+
code: `<template><bento-input-field-phone-number error="val" /></template>`,
|
|
105
|
+
output: `<template><bento-input-field-phone-number error-message="val" /></template>`,
|
|
106
|
+
options: [{ autofix: true }],
|
|
107
|
+
errors: [{ messageId: 'deprecation' }],
|
|
108
|
+
},
|
|
109
|
+
// bento-input-field-phone-number: Shorthand
|
|
110
|
+
{
|
|
111
|
+
name: 'Invalid: Dynamic prop on bento-input-field-phone-number',
|
|
112
|
+
filename: 'test.vue',
|
|
113
|
+
code: `<template><bento-input-field-phone-number :error="val" /></template>`,
|
|
114
|
+
output: `<template><bento-input-field-phone-number :error-message="val" /></template>`,
|
|
115
|
+
options: [{ autofix: true }],
|
|
116
|
+
errors: [{ messageId: 'deprecation' }],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -18,7 +18,7 @@ module.exports = defineConfig([
|
|
|
18
18
|
},
|
|
19
19
|
rules: {
|
|
20
20
|
// Register the specific rule we are testing
|
|
21
|
-
'@adyen/bento/deprecation-components-input-emit': 'warn',
|
|
21
|
+
'@adyen/bento/deprecation-components-input-emit': ['warn', { autofix: true }],
|
|
22
22
|
},
|
|
23
23
|
files: ['**/*.vue'],
|
|
24
24
|
},
|
|
@@ -22,11 +22,24 @@ module.exports = {
|
|
|
22
22
|
deprecation: `The "input" emit is deprecated. Please use "update:model-value" instead.`,
|
|
23
23
|
},
|
|
24
24
|
fixable: 'code',
|
|
25
|
-
schema: [
|
|
25
|
+
schema: [
|
|
26
|
+
{
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
autofix: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
26
37
|
},
|
|
27
38
|
|
|
28
39
|
/** @param {RuleContext} context */
|
|
29
40
|
create(context) {
|
|
41
|
+
const options = context.options[0] || {};
|
|
42
|
+
const autofix = options.autofix === true;
|
|
30
43
|
/* ------------------------------------------------ */
|
|
31
44
|
/* CASE 3: EMIT DEPRECATION (Multiple Components) */
|
|
32
45
|
/* ------------------------------------------------ */
|
|
@@ -38,9 +51,11 @@ module.exports = {
|
|
|
38
51
|
context.report({
|
|
39
52
|
node,
|
|
40
53
|
messageId: 'deprecation',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
...(autofix && {
|
|
55
|
+
fix(fixer) {
|
|
56
|
+
return fixer.replaceText(node.key.argument, 'update:model-value');
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
44
59
|
});
|
|
45
60
|
},
|
|
46
61
|
});
|
|
@@ -163,11 +163,36 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
163
163
|
},
|
|
164
164
|
],
|
|
165
165
|
invalid: [
|
|
166
|
+
/* autofix: false */
|
|
167
|
+
{
|
|
168
|
+
name: 'Invalid: Emit event with autofix disabled (explicit false)',
|
|
169
|
+
filename: 'test.vue',
|
|
170
|
+
code: `<template><bento-input-field @input="val" /></template>`,
|
|
171
|
+
output: null,
|
|
172
|
+
options: [{ autofix: false }],
|
|
173
|
+
errors: [{ messageId: 'deprecation' }],
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'Invalid: Emit event with autofix disabled (no options)',
|
|
177
|
+
filename: 'test.vue',
|
|
178
|
+
code: `<template><bento-dropdown @input="handleInput" /></template>`,
|
|
179
|
+
output: null,
|
|
180
|
+
errors: [{ messageId: 'deprecation' }],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'Invalid: Emit event with v-on directive and autofix disabled',
|
|
184
|
+
filename: 'test.vue',
|
|
185
|
+
code: `<template><bento-textarea v-on:input="val" /></template>`,
|
|
186
|
+
output: null,
|
|
187
|
+
errors: [{ messageId: 'deprecation' }],
|
|
188
|
+
},
|
|
189
|
+
/* autofix: true */
|
|
166
190
|
{
|
|
167
191
|
name: 'Invalid: Emit event on bento-date-picker',
|
|
168
192
|
filename: 'test.vue',
|
|
169
193
|
code: `<template><bento-date-picker @input="val" /></template>`,
|
|
170
194
|
output: `<template><bento-date-picker @update:model-value="val" /></template>`,
|
|
195
|
+
options: [{ autofix: true }],
|
|
171
196
|
errors: [{ messageId: 'deprecation' }],
|
|
172
197
|
},
|
|
173
198
|
{
|
|
@@ -175,6 +200,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
175
200
|
filename: 'test.vue',
|
|
176
201
|
code: `<template><bento-date-range-picker @input="val" /></template>`,
|
|
177
202
|
output: `<template><bento-date-range-picker @update:model-value="val" /></template>`,
|
|
203
|
+
options: [{ autofix: true }],
|
|
178
204
|
errors: [{ messageId: 'deprecation' }],
|
|
179
205
|
},
|
|
180
206
|
{
|
|
@@ -182,6 +208,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
182
208
|
filename: 'test.vue',
|
|
183
209
|
code: `<template><bento-dropdown @input="val" /></template>`,
|
|
184
210
|
output: `<template><bento-dropdown @update:model-value="val" /></template>`,
|
|
211
|
+
options: [{ autofix: true }],
|
|
185
212
|
errors: [{ messageId: 'deprecation' }],
|
|
186
213
|
},
|
|
187
214
|
{
|
|
@@ -189,6 +216,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
189
216
|
filename: 'test.vue',
|
|
190
217
|
code: `<template><bento-dropdown-avatar @input="val" /></template>`,
|
|
191
218
|
output: `<template><bento-dropdown-avatar @update:model-value="val" /></template>`,
|
|
219
|
+
options: [{ autofix: true }],
|
|
192
220
|
errors: [{ messageId: 'deprecation' }],
|
|
193
221
|
},
|
|
194
222
|
{
|
|
@@ -196,6 +224,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
196
224
|
filename: 'test.vue',
|
|
197
225
|
code: `<template><bento-dropdown-country @input="val" /></template>`,
|
|
198
226
|
output: `<template><bento-dropdown-country @update:model-value="val" /></template>`,
|
|
227
|
+
options: [{ autofix: true }],
|
|
199
228
|
errors: [{ messageId: 'deprecation' }],
|
|
200
229
|
},
|
|
201
230
|
{
|
|
@@ -203,6 +232,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
203
232
|
filename: 'test.vue',
|
|
204
233
|
code: `<template><bento-dropdown-currency @input="val" /></template>`,
|
|
205
234
|
output: `<template><bento-dropdown-currency @update:model-value="val" /></template>`,
|
|
235
|
+
options: [{ autofix: true }],
|
|
206
236
|
errors: [{ messageId: 'deprecation' }],
|
|
207
237
|
},
|
|
208
238
|
{
|
|
@@ -210,6 +240,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
210
240
|
filename: 'test.vue',
|
|
211
241
|
code: `<template><bento-dropdown-payment-method @input="val" /></template>`,
|
|
212
242
|
output: `<template><bento-dropdown-payment-method @update:model-value="val" /></template>`,
|
|
243
|
+
options: [{ autofix: true }],
|
|
213
244
|
errors: [{ messageId: 'deprecation' }],
|
|
214
245
|
},
|
|
215
246
|
{
|
|
@@ -217,6 +248,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
217
248
|
filename: 'test.vue',
|
|
218
249
|
code: `<template><bento-dropdown-tag @input="val" /></template>`,
|
|
219
250
|
output: `<template><bento-dropdown-tag @update:model-value="val" /></template>`,
|
|
251
|
+
options: [{ autofix: true }],
|
|
220
252
|
errors: [{ messageId: 'deprecation' }],
|
|
221
253
|
},
|
|
222
254
|
{
|
|
@@ -224,6 +256,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
224
256
|
filename: 'test.vue',
|
|
225
257
|
code: `<template><bento-file-uploader @input="val" /></template>`,
|
|
226
258
|
output: `<template><bento-file-uploader @update:model-value="val" /></template>`,
|
|
259
|
+
options: [{ autofix: true }],
|
|
227
260
|
errors: [{ messageId: 'deprecation' }],
|
|
228
261
|
},
|
|
229
262
|
{
|
|
@@ -231,6 +264,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
231
264
|
filename: 'test.vue',
|
|
232
265
|
code: `<template><bento-input-field @input="val" /></template>`,
|
|
233
266
|
output: `<template><bento-input-field @update:model-value="val" /></template>`,
|
|
267
|
+
options: [{ autofix: true }],
|
|
234
268
|
errors: [{ messageId: 'deprecation' }],
|
|
235
269
|
},
|
|
236
270
|
{
|
|
@@ -238,6 +272,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
238
272
|
filename: 'test.vue',
|
|
239
273
|
code: `<template><bento-input-field-password @input="val" /></template>`,
|
|
240
274
|
output: `<template><bento-input-field-password @update:model-value="val" /></template>`,
|
|
275
|
+
options: [{ autofix: true }],
|
|
241
276
|
errors: [{ messageId: 'deprecation' }],
|
|
242
277
|
},
|
|
243
278
|
{
|
|
@@ -245,6 +280,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
245
280
|
filename: 'test.vue',
|
|
246
281
|
code: `<template><bento-input-field-phone-number @input="val" /></template>`,
|
|
247
282
|
output: `<template><bento-input-field-phone-number @update:model-value="val" /></template>`,
|
|
283
|
+
options: [{ autofix: true }],
|
|
248
284
|
errors: [{ messageId: 'deprecation' }],
|
|
249
285
|
},
|
|
250
286
|
{
|
|
@@ -252,6 +288,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
252
288
|
filename: 'test.vue',
|
|
253
289
|
code: `<template><bento-checkbox-group @input="val" /></template>`,
|
|
254
290
|
output: `<template><bento-checkbox-group @update:model-value="val" /></template>`,
|
|
291
|
+
options: [{ autofix: true }],
|
|
255
292
|
errors: [{ messageId: 'deprecation' }],
|
|
256
293
|
},
|
|
257
294
|
{
|
|
@@ -259,6 +296,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
259
296
|
filename: 'test.vue',
|
|
260
297
|
code: `<template><bento-radio-group @input="val" /></template>`,
|
|
261
298
|
output: `<template><bento-radio-group @update:model-value="val" /></template>`,
|
|
299
|
+
options: [{ autofix: true }],
|
|
262
300
|
errors: [{ messageId: 'deprecation' }],
|
|
263
301
|
},
|
|
264
302
|
{
|
|
@@ -266,6 +304,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
266
304
|
filename: 'test.vue',
|
|
267
305
|
code: `<template><bento-selection-card-group @input="val" /></template>`,
|
|
268
306
|
output: `<template><bento-selection-card-group @update:model-value="val" /></template>`,
|
|
307
|
+
options: [{ autofix: true }],
|
|
269
308
|
errors: [{ messageId: 'deprecation' }],
|
|
270
309
|
},
|
|
271
310
|
{
|
|
@@ -273,6 +312,7 @@ describe('@adyen/bento/deprecation-components-input-emit', () => {
|
|
|
273
312
|
filename: 'test.vue',
|
|
274
313
|
code: `<template><bento-textarea @input="val" /></template>`,
|
|
275
314
|
output: `<template><bento-textarea @update:model-value="val" /></template>`,
|
|
315
|
+
options: [{ autofix: true }],
|
|
276
316
|
errors: [{ messageId: 'deprecation' }],
|
|
277
317
|
},
|
|
278
318
|
],
|
|
@@ -18,7 +18,7 @@ module.exports = defineConfig([
|
|
|
18
18
|
},
|
|
19
19
|
rules: {
|
|
20
20
|
// Register the specific rule we are testing
|
|
21
|
-
'@adyen/bento/deprecation-components-value-prop': 'warn',
|
|
21
|
+
'@adyen/bento/deprecation-components-value-prop': ['warn', { autofix: true }],
|
|
22
22
|
},
|
|
23
23
|
files: ['**/*.vue'],
|
|
24
24
|
},
|
|
@@ -22,11 +22,24 @@ module.exports = {
|
|
|
22
22
|
deprecation: `The "value" prop is deprecated. Please use "model-value" instead.`,
|
|
23
23
|
},
|
|
24
24
|
fixable: 'code',
|
|
25
|
-
schema: [
|
|
25
|
+
schema: [
|
|
26
|
+
{
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
autofix: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
26
37
|
},
|
|
27
38
|
|
|
28
39
|
/** @param {RuleContext} context */
|
|
29
40
|
create(context) {
|
|
41
|
+
const options = context.options[0] || {};
|
|
42
|
+
const autofix = options.autofix === true;
|
|
30
43
|
/* ------------------------------------------------ */
|
|
31
44
|
/* CASE 2: PROP DEPRECATION (Multiple Components) */
|
|
32
45
|
/* ------------------------------------------------ */
|
|
@@ -38,9 +51,11 @@ module.exports = {
|
|
|
38
51
|
context.report({
|
|
39
52
|
node,
|
|
40
53
|
messageId: 'deprecation',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
...(autofix && {
|
|
55
|
+
fix(fixer) {
|
|
56
|
+
return fixer.replaceText(node.key, 'model-value');
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
44
59
|
});
|
|
45
60
|
},
|
|
46
61
|
|
|
@@ -51,9 +66,11 @@ module.exports = {
|
|
|
51
66
|
context.report({
|
|
52
67
|
node,
|
|
53
68
|
messageId: 'deprecation',
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
...(autofix && {
|
|
70
|
+
fix(fixer) {
|
|
71
|
+
return fixer.replaceText(node.key.argument, 'model-value');
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
57
74
|
});
|
|
58
75
|
},
|
|
59
76
|
});
|