@adyen/eslint-plugin-bento 2.9.0 → 2.10.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 +15 -0
- package/configs/vue-recommended.js +5 -0
- package/configs/vue-strict.js +5 -0
- package/index.js +5 -0
- package/package.json +1 -1
- 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-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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.10.0 (2026-04-29)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- added deprecation rule for `modifers` prop in `bento-popover` ([9fb597154](https://github.com/Adyen/bento/commit/9fb597154))
|
|
8
|
+
- added deprecation rule for `ariaLabel` property ([155145eae](https://github.com/Adyen/bento/commit/155145eae))
|
|
9
|
+
- added deprecation rule for `hasError` prop for `bento-checkbox-group` & `bento-radio-group` ([94b181c62](https://github.com/Adyen/bento/commit/94b181c62))
|
|
10
|
+
- added deprecation rule for filter of type `BentoFilterItemType.INPUT` using dropdown props ([0b2d242ce](https://github.com/Adyen/bento/commit/0b2d242ce))
|
|
11
|
+
- added deprecation rule for `variant` for `bento-timeline-item` ([245c7f7f8](https://github.com/Adyen/bento/commit/245c7f7f8))
|
|
12
|
+
|
|
13
|
+
### ❤️ Thank You
|
|
14
|
+
|
|
15
|
+
- gerald
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## 2.9.0 (2026-04-22)
|
|
4
19
|
|
|
5
20
|
### Features
|
|
@@ -11,9 +11,14 @@ module.exports = [
|
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
rules: {
|
|
14
|
+
'@adyen/bento/deprecation-input-filter-dropdown-options': 'warn',
|
|
14
15
|
'@adyen/bento/deprecation-bento-dropdown-size-prop': 'warn',
|
|
16
|
+
'@adyen/bento/deprecation-bento-timeline-item-variant-prop': 'warn',
|
|
17
|
+
'@adyen/bento/deprecation-bento-popover-modifiers-prop': 'warn',
|
|
15
18
|
'@adyen/bento/deprecation-components-error-prop': 'warn',
|
|
16
19
|
'@adyen/bento/deprecation-filter-bar-deprecated-props': 'warn',
|
|
20
|
+
'@adyen/bento/deprecation-components-has-error-prop': 'warn',
|
|
21
|
+
'@adyen/bento/deprecation-components-aria-label-prop': 'warn',
|
|
17
22
|
'@adyen/bento/deprecation-components-input-emit': 'warn',
|
|
18
23
|
'@adyen/bento/deprecation-components-value-prop': 'warn',
|
|
19
24
|
'@adyen/bento/deprecation-currency-default-slot': 'warn',
|
package/configs/vue-strict.js
CHANGED
|
@@ -11,9 +11,14 @@ module.exports = [
|
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
rules: {
|
|
14
|
+
'@adyen/bento/deprecation-input-filter-dropdown-options': 'error',
|
|
14
15
|
'@adyen/bento/deprecation-bento-dropdown-size-prop': 'error',
|
|
16
|
+
'@adyen/bento/deprecation-bento-timeline-item-variant-prop': 'error',
|
|
17
|
+
'@adyen/bento/deprecation-bento-popover-modifiers-prop': 'error',
|
|
15
18
|
'@adyen/bento/deprecation-components-error-prop': 'error',
|
|
16
19
|
'@adyen/bento/deprecation-filter-bar-deprecated-props': 'error',
|
|
20
|
+
'@adyen/bento/deprecation-components-has-error-prop': 'error',
|
|
21
|
+
'@adyen/bento/deprecation-components-aria-label-prop': 'error',
|
|
17
22
|
'@adyen/bento/deprecation-components-input-emit': 'error',
|
|
18
23
|
'@adyen/bento/deprecation-components-value-prop': 'error',
|
|
19
24
|
'@adyen/bento/deprecation-currency-default-slot': 'error',
|
package/index.js
CHANGED
|
@@ -12,9 +12,14 @@ const plugin = {
|
|
|
12
12
|
tailwind: require('./configs/tailwind'),
|
|
13
13
|
},
|
|
14
14
|
rules: {
|
|
15
|
+
'deprecation-input-filter-dropdown-options': require('./rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options'),
|
|
15
16
|
'deprecation-bento-dropdown-size-prop': require('./rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop'),
|
|
17
|
+
'deprecation-bento-timeline-item-variant-prop': require('./rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop'),
|
|
18
|
+
'deprecation-bento-popover-modifiers-prop': require('./rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop'),
|
|
16
19
|
'deprecation-components-error-prop': require('./rules/deprecation-components-error-prop/deprecation-components-error-prop'),
|
|
17
20
|
'deprecation-filter-bar-deprecated-props': require('./rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props'),
|
|
21
|
+
'deprecation-components-has-error-prop': require('./rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop'),
|
|
22
|
+
'deprecation-components-aria-label-prop': require('./rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop'),
|
|
18
23
|
'deprecation-components-input-emit': require('./rules/deprecation-components-input-emit/deprecation-components-input-emit'),
|
|
19
24
|
'deprecation-components-value-prop': require('./rules/deprecation-components-value-prop/deprecation-components-value-prop'),
|
|
20
25
|
'deprecation-currency-default-slot': require('./rules/deprecation-currency-default-slot/deprecation-currency-default-slot'),
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# deprecation-bento-popover-modifiers-prop
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The `modifiers` prop in the following components is deprecated:
|
|
6
|
+
|
|
7
|
+
- `bento-popover`
|
|
8
|
+
|
|
9
|
+
## Rule Details
|
|
10
|
+
|
|
11
|
+
This rule reports usages of the deprecated item.
|
|
12
|
+
|
|
13
|
+
### ❌ Incorrect
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<bento-popover modifiers="value" /> <bento-popover :modifiers="value" />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### ✅ Correct
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<bento-popover />
|
|
23
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
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-bento-popover-modifiers-prop': ['warn', { autofix: true }],
|
|
23
|
+
},
|
|
24
|
+
files: ['**/*.vue'],
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
+
|
|
4
|
+
describe('@adyen/bento/deprecation-bento-popover-modifiers-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-bento-popover-modifiers-prop.vue');
|
|
10
|
+
|
|
11
|
+
// Execute the linter
|
|
12
|
+
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
13
|
+
|
|
14
|
+
// 3 examples: static, shorthand, longhand
|
|
15
|
+
expect(result[0].warningCount).toBe(3);
|
|
16
|
+
expect(result[0].messages[0]).toMatchObject({
|
|
17
|
+
ruleId: '@adyen/bento/deprecation-bento-popover-modifiers-prop',
|
|
18
|
+
severity: 1,
|
|
19
|
+
|
|
20
|
+
messageId: 'deprecation',
|
|
21
|
+
message: `The "modifiers" prop is deprecated.`,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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: 'Deprecates usage of modifiers prop in bento-popover',
|
|
16
|
+
category: 'Deprecations',
|
|
17
|
+
url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/deprecation-bento-popover-modifiers-prop/README.md',
|
|
18
|
+
recommended: true,
|
|
19
|
+
},
|
|
20
|
+
messages: {
|
|
21
|
+
deprecation: `The "modifiers" prop is deprecated.`,
|
|
22
|
+
},
|
|
23
|
+
fixable: 'code',
|
|
24
|
+
schema: [
|
|
25
|
+
{
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
autofix: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/** @param {RuleContext} context */
|
|
39
|
+
create(context) {
|
|
40
|
+
const options = context.options[0] || {};
|
|
41
|
+
const autofix = options.autofix === true;
|
|
42
|
+
|
|
43
|
+
/* ------------------------------------------------ */
|
|
44
|
+
/* PROP DEPRECATION */
|
|
45
|
+
/* ------------------------------------------------ */
|
|
46
|
+
return VueUtils.defineTemplateBodyVisitor(context, {
|
|
47
|
+
// 1. STATIC: modifiers="foo"
|
|
48
|
+
[`VElement:matches([name="bento-popover"], [name="BentoPopover"]) > VStartTag > VAttribute[directive=false][key.name="modifiers"]`](
|
|
49
|
+
node
|
|
50
|
+
) {
|
|
51
|
+
context.report({
|
|
52
|
+
node,
|
|
53
|
+
messageId: 'deprecation',
|
|
54
|
+
...(autofix && {
|
|
55
|
+
fix(fixer) {
|
|
56
|
+
return fixer.remove(node);
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// 2. DYNAMIC: :modifiers="foo" or v-bind:modifiers="foo"
|
|
63
|
+
[`VElement:matches([name="bento-popover"], [name="BentoPopover"]) > VStartTag > VAttribute[directive=true][key.name.name="bind"][key.argument.name="modifiers"]`](
|
|
64
|
+
node
|
|
65
|
+
) {
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
messageId: 'deprecation',
|
|
69
|
+
...(autofix && {
|
|
70
|
+
fix(fixer) {
|
|
71
|
+
return fixer.remove(node);
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import vueParser from 'vue-eslint-parser';
|
|
3
|
+
import tsParser from '@typescript-eslint/parser';
|
|
4
|
+
import deprecationBentoPopoverModifiersProp from './deprecation-bento-popover-modifiers-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-popover-modifiers-prop', () => {
|
|
18
|
+
ruleTester.run('deprecation-bento-popover-modifiers-prop', deprecationBentoPopoverModifiersProp, {
|
|
19
|
+
valid: [
|
|
20
|
+
{
|
|
21
|
+
name: 'Valid usage for bento-popover',
|
|
22
|
+
filename: 'test.vue',
|
|
23
|
+
code: `
|
|
24
|
+
<template>
|
|
25
|
+
<bento-popover other-prop="val" />
|
|
26
|
+
</template>
|
|
27
|
+
`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
invalid: [
|
|
31
|
+
{
|
|
32
|
+
name: 'Invalid: autofix disabled (explicit false)',
|
|
33
|
+
filename: 'test.vue',
|
|
34
|
+
code: `<template><bento-popover modifiers="val" /></template>`,
|
|
35
|
+
output: null,
|
|
36
|
+
options: [{ autofix: false }],
|
|
37
|
+
errors: [{ messageId: 'deprecation' }],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Invalid: autofix disabled (no options)',
|
|
41
|
+
filename: 'test.vue',
|
|
42
|
+
code: `<template><bento-popover :modifiers="val" /></template>`,
|
|
43
|
+
output: null,
|
|
44
|
+
errors: [{ messageId: 'deprecation' }],
|
|
45
|
+
},
|
|
46
|
+
// bento-popover: Static
|
|
47
|
+
{
|
|
48
|
+
name: 'Invalid: Static prop on bento-popover',
|
|
49
|
+
filename: 'test.vue',
|
|
50
|
+
code: `<template><bento-popover modifiers="val" /></template>`,
|
|
51
|
+
errors: [{ messageId: 'deprecation' }],
|
|
52
|
+
},
|
|
53
|
+
// bento-popover: v-bind longhand
|
|
54
|
+
{
|
|
55
|
+
name: 'Invalid: v-bind longhand prop on bento-popover',
|
|
56
|
+
filename: 'test.vue',
|
|
57
|
+
code: `<template><bento-popover v-bind:modifiers="val" /></template>`,
|
|
58
|
+
errors: [{ messageId: 'deprecation' }],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/* ------------------------------------------------ */
|
|
64
|
+
/* AUTOFIX TESTS */
|
|
65
|
+
/* ------------------------------------------------ */
|
|
66
|
+
ruleTester.run('deprecation-bento-popover-modifiers-prop (autofix enabled)', deprecationBentoPopoverModifiersProp, {
|
|
67
|
+
valid: [
|
|
68
|
+
{
|
|
69
|
+
name: 'Valid: no modifiers prop (autofix enabled)',
|
|
70
|
+
filename: 'test.vue',
|
|
71
|
+
options: [{ autofix: true }],
|
|
72
|
+
code: `<template><bento-popover position="top" /></template>`,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
invalid: [
|
|
76
|
+
{
|
|
77
|
+
name: 'Autofix: removes static modifiers prop',
|
|
78
|
+
filename: 'test.vue',
|
|
79
|
+
options: [{ autofix: true }],
|
|
80
|
+
code: `<template><bento-popover modifiers="val" /></template>`,
|
|
81
|
+
output: `<template><bento-popover /></template>`,
|
|
82
|
+
errors: [{ messageId: 'deprecation' }],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Autofix: removes dynamic modifiers prop',
|
|
86
|
+
filename: 'test.vue',
|
|
87
|
+
options: [{ autofix: true }],
|
|
88
|
+
code: `<template><bento-popover :modifiers="val" /></template>`,
|
|
89
|
+
output: `<template><bento-popover /></template>`,
|
|
90
|
+
errors: [{ messageId: 'deprecation' }],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Autofix: removes v-bind longhand modifiers prop',
|
|
94
|
+
filename: 'test.vue',
|
|
95
|
+
options: [{ autofix: true }],
|
|
96
|
+
code: `<template><bento-popover v-bind:modifiers="val" /></template>`,
|
|
97
|
+
output: `<template><bento-popover /></template>`,
|
|
98
|
+
errors: [{ messageId: 'deprecation' }],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Autofix: does not fix when autofix is false',
|
|
102
|
+
filename: 'test.vue',
|
|
103
|
+
options: [{ autofix: false }],
|
|
104
|
+
code: `<template><bento-popover modifiers="val" other="x" /></template>`,
|
|
105
|
+
errors: [{ messageId: 'deprecation' }],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# deprecation-bento-timeline-item-variant-prop
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The `variant` prop in the following components is deprecated:
|
|
6
|
+
|
|
7
|
+
- `bento-timeline-item`
|
|
8
|
+
|
|
9
|
+
Please use `status` instead.
|
|
10
|
+
|
|
11
|
+
## Rule Details
|
|
12
|
+
|
|
13
|
+
This rule reports usages of the deprecated item.
|
|
14
|
+
|
|
15
|
+
### ❌ Incorrect
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<bento-timeline-item variant="SUCCESS" /> <bento-timeline-item :variant="BentoTimelineItemVariant.CRITICAL" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### ✅ Correct
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<bento-timeline-item status="green" /> <bento-timeline-item status="red" />
|
|
25
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
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-bento-timeline-item-variant-prop': ['warn', { autofix: true }],
|
|
23
|
+
},
|
|
24
|
+
files: ['**/*.vue'],
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
+
|
|
4
|
+
describe('@adyen/bento/deprecation-bento-timeline-item-variant-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-bento-timeline-item-variant-prop.vue');
|
|
10
|
+
|
|
11
|
+
// Execute the linter
|
|
12
|
+
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
13
|
+
|
|
14
|
+
// 3 examples: static, shorthand, longhand
|
|
15
|
+
expect(result[0].warningCount).toBe(3);
|
|
16
|
+
|
|
17
|
+
// Verify the message structure on the first error found.
|
|
18
|
+
// Since the rule is the same for all components, checking the first one confirms the message is correct.
|
|
19
|
+
expect(result[0].messages[0]).toMatchObject({
|
|
20
|
+
ruleId: '@adyen/bento/deprecation-bento-timeline-item-variant-prop',
|
|
21
|
+
severity: 1,
|
|
22
|
+
|
|
23
|
+
messageId: 'deprecation',
|
|
24
|
+
message: `The "variant" prop is deprecated. Please use "status" instead.`,
|
|
25
|
+
|
|
26
|
+
fix: expect.objectContaining({
|
|
27
|
+
text: expect.stringContaining('status'),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
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: 'Deprecates usage of variant prop in bento-timeline-item',
|
|
16
|
+
category: 'Deprecations',
|
|
17
|
+
url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/deprecation-bento-timeline-item-variant-prop/README.md',
|
|
18
|
+
recommended: true,
|
|
19
|
+
},
|
|
20
|
+
messages: {
|
|
21
|
+
deprecation: `The "variant" prop is deprecated. Please use "status" instead.`,
|
|
22
|
+
},
|
|
23
|
+
fixable: 'code',
|
|
24
|
+
schema: [
|
|
25
|
+
{
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
autofix: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/** @param {RuleContext} context */
|
|
39
|
+
create(context) {
|
|
40
|
+
const options = context.options[0] || {};
|
|
41
|
+
const autofix = options.autofix === true;
|
|
42
|
+
|
|
43
|
+
/* ------------------------------------------------ */
|
|
44
|
+
/* PROP DEPRECATION */
|
|
45
|
+
/* ------------------------------------------------ */
|
|
46
|
+
return VueUtils.defineTemplateBodyVisitor(context, {
|
|
47
|
+
// 1. STATIC: value="foo"
|
|
48
|
+
[`VElement:matches([name="bento-timeline-item"], [name="BentoTimelineItem"]) > VStartTag > VAttribute[directive=false][key.name="variant"]`](
|
|
49
|
+
node
|
|
50
|
+
) {
|
|
51
|
+
context.report({
|
|
52
|
+
node,
|
|
53
|
+
messageId: 'deprecation',
|
|
54
|
+
...(autofix && {
|
|
55
|
+
fix(fixer) {
|
|
56
|
+
return fixer.replaceText(node.key, 'status');
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// 2. DYNAMIC: :value="foo" or v-bind:value="foo"
|
|
63
|
+
[`VElement:matches([name="bento-timeline-item"], [name="BentoTimelineItem"]) > VStartTag > VAttribute[directive=true][key.name.name="bind"][key.argument.name="variant"]`](
|
|
64
|
+
node
|
|
65
|
+
) {
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
messageId: 'deprecation',
|
|
69
|
+
...(autofix && {
|
|
70
|
+
fix(fixer) {
|
|
71
|
+
return fixer.replaceText(node.key.argument, 'status');
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
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 for bento-timeline-item',
|
|
22
|
+
filename: 'test.vue',
|
|
23
|
+
code: `
|
|
24
|
+
<template>
|
|
25
|
+
<bento-timeline-item status="val" />
|
|
26
|
+
</template>
|
|
27
|
+
`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
invalid: [
|
|
31
|
+
{
|
|
32
|
+
name: 'Invalid: autofix disabled (explicit false)',
|
|
33
|
+
filename: 'test.vue',
|
|
34
|
+
code: `<template><bento-timeline-item variant="val" /></template>`,
|
|
35
|
+
output: null,
|
|
36
|
+
options: [{ autofix: false }],
|
|
37
|
+
errors: [{ messageId: 'deprecation' }],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Invalid: autofix disabled (no options)',
|
|
41
|
+
filename: 'test.vue',
|
|
42
|
+
code: `<template><bento-timeline-item :variant="val" /></template>`,
|
|
43
|
+
output: null,
|
|
44
|
+
errors: [{ messageId: 'deprecation' }],
|
|
45
|
+
},
|
|
46
|
+
// bento-timeline-item: Static
|
|
47
|
+
{
|
|
48
|
+
name: 'Invalid: Static prop on bento-timeline-item',
|
|
49
|
+
filename: 'test.vue',
|
|
50
|
+
code: `<template><bento-timeline-item variant="val" /></template>`,
|
|
51
|
+
output: `<template><bento-timeline-item status="val" /></template>`,
|
|
52
|
+
options: [{ autofix: true }],
|
|
53
|
+
errors: [{ messageId: 'deprecation' }],
|
|
54
|
+
},
|
|
55
|
+
// bento-timeline-item: Shorthand
|
|
56
|
+
{
|
|
57
|
+
name: 'Invalid: Dynamic prop on bento-timeline-item',
|
|
58
|
+
filename: 'test.vue',
|
|
59
|
+
code: `<template><bento-timeline-item :variant="val" /></template>`,
|
|
60
|
+
output: `<template><bento-timeline-item :status="val" /></template>`,
|
|
61
|
+
options: [{ autofix: true }],
|
|
62
|
+
errors: [{ messageId: 'deprecation' }],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# deprecation-components-aria-label-prop
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The `ariaLabel` prop in the following components is deprecated:
|
|
6
|
+
|
|
7
|
+
- `bento-dropdown`
|
|
8
|
+
- `bento-input-field`
|
|
9
|
+
- `bento-pagination`
|
|
10
|
+
- `bento-popover`
|
|
11
|
+
- `bento-segmented-control`
|
|
12
|
+
|
|
13
|
+
Please use `aria-label` instead.
|
|
14
|
+
|
|
15
|
+
## Rule Details
|
|
16
|
+
|
|
17
|
+
This rule reports usages of the deprecated `ariaLabel` prop (camelCase). The replacement `aria-label` is the native HTML
|
|
18
|
+
attribute, which the components already pick up via `attrs['aria-label']`.
|
|
19
|
+
|
|
20
|
+
### ❌ Incorrect
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<bento-dropdown ariaLabel="value" /> <bento-dropdown :ariaLabel="value" />
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<bento-input-field ariaLabel="value" /> <bento-input-field :ariaLabel="value" />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<bento-pagination ariaLabel="value" /> <bento-pagination :ariaLabel="value" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<bento-popover ariaLabel="value" /> <bento-popover :ariaLabel="value" />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<bento-segmented-control ariaLabel="value" /> <bento-segmented-control :ariaLabel="value" />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### ✅ Correct
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<bento-dropdown aria-label="value" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<bento-input-field aria-label="value" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<bento-pagination aria-label="value" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<bento-popover aria-label="value" />
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<bento-segmented-control aria-label="value" />
|
|
62
|
+
```
|