@adyen/eslint-plugin-bento 2.8.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 +30 -0
- package/configs/vue-recommended.js +8 -0
- package/configs/vue-strict.js +8 -0
- package/index.js +8 -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-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-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-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-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/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,35 @@
|
|
|
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
|
+
|
|
18
|
+
## 2.9.0 (2026-04-22)
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- added deprecation rule for `bento-filter-bar` props ([7044b0346](https://github.com/Adyen/bento/commit/7044b0346))
|
|
23
|
+
- added deprecation rule for `size` for `bento-dropdown` ([11effcdff](https://github.com/Adyen/bento/commit/11effcdff))
|
|
24
|
+
- added deprecation rule for `error` property ([97327a416](https://github.com/Adyen/bento/commit/97327a416))
|
|
25
|
+
- added `autofix` option to ESLint deprecation rules and generator ([70f4b9890](https://github.com/Adyen/bento/commit/70f4b9890))
|
|
26
|
+
|
|
27
|
+
### ❤️ Thank You
|
|
28
|
+
|
|
29
|
+
- daver
|
|
30
|
+
- gerald
|
|
31
|
+
|
|
32
|
+
|
|
3
33
|
## 2.8.0 (2026-04-15)
|
|
4
34
|
|
|
5
35
|
### Features
|
|
@@ -11,6 +11,14 @@ module.exports = [
|
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
rules: {
|
|
14
|
+
'@adyen/bento/deprecation-input-filter-dropdown-options': 'warn',
|
|
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',
|
|
18
|
+
'@adyen/bento/deprecation-components-error-prop': 'warn',
|
|
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',
|
|
14
22
|
'@adyen/bento/deprecation-components-input-emit': 'warn',
|
|
15
23
|
'@adyen/bento/deprecation-components-value-prop': 'warn',
|
|
16
24
|
'@adyen/bento/deprecation-currency-default-slot': 'warn',
|
package/configs/vue-strict.js
CHANGED
|
@@ -11,6 +11,14 @@ module.exports = [
|
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
rules: {
|
|
14
|
+
'@adyen/bento/deprecation-input-filter-dropdown-options': 'error',
|
|
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',
|
|
18
|
+
'@adyen/bento/deprecation-components-error-prop': 'error',
|
|
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',
|
|
14
22
|
'@adyen/bento/deprecation-components-input-emit': 'error',
|
|
15
23
|
'@adyen/bento/deprecation-components-value-prop': 'error',
|
|
16
24
|
'@adyen/bento/deprecation-currency-default-slot': 'error',
|
package/index.js
CHANGED
|
@@ -12,6 +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'),
|
|
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'),
|
|
19
|
+
'deprecation-components-error-prop': require('./rules/deprecation-components-error-prop/deprecation-components-error-prop'),
|
|
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'),
|
|
15
23
|
'deprecation-components-input-emit': require('./rules/deprecation-components-input-emit/deprecation-components-input-emit'),
|
|
16
24
|
'deprecation-components-value-prop': require('./rules/deprecation-components-value-prop/deprecation-components-value-prop'),
|
|
17
25
|
'deprecation-currency-default-slot': require('./rules/deprecation-currency-default-slot/deprecation-currency-default-slot'),
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# deprecation-bento-dropdown-size-prop
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The `size` prop in the following components is deprecated:
|
|
6
|
+
|
|
7
|
+
- `bento-dropdown`
|
|
8
|
+
|
|
9
|
+
Only the `default` size is supported. Remove the `size` prop entirely.
|
|
10
|
+
|
|
11
|
+
## Rule Details
|
|
12
|
+
|
|
13
|
+
This rule reports usages of the deprecated `size` prop.
|
|
14
|
+
|
|
15
|
+
### ❌ Incorrect
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<bento-dropdown size="small" /> <bento-dropdown :size="BentoDropdownSize.SMALL" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### ✅ Correct
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<bento-dropdown />
|
|
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-dropdown-size-prop': ['warn', { autofix: true }],
|
|
23
|
+
},
|
|
24
|
+
files: ['**/*.vue'],
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
+
|
|
4
|
+
describe('@adyen/bento/deprecation-bento-dropdown-size-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-dropdown-size-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 = 1;
|
|
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-bento-dropdown-size-prop',
|
|
27
|
+
severity: 1,
|
|
28
|
+
|
|
29
|
+
messageId: 'deprecation',
|
|
30
|
+
message: `The "size" prop is deprecated.`,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -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 size prop in bento-dropdown',
|
|
16
|
+
category: 'Deprecations',
|
|
17
|
+
url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/deprecation-bento-dropdown-size-prop/README.md',
|
|
18
|
+
recommended: true,
|
|
19
|
+
},
|
|
20
|
+
messages: {
|
|
21
|
+
deprecation: `The "size" 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
|
+
/* CASE 2: PROP DEPRECATION (Multiple Components) */
|
|
45
|
+
/* ------------------------------------------------ */
|
|
46
|
+
return VueUtils.defineTemplateBodyVisitor(context, {
|
|
47
|
+
// 1. STATIC: size="foo"
|
|
48
|
+
[`VElement:matches([name="bento-dropdown"], [name="BentoDropdown"]) > VStartTag > VAttribute[directive=false][key.name="size"]`](
|
|
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: :size="foo" or v-bind:size="foo"
|
|
63
|
+
[`VElement:matches([name="bento-dropdown"], [name="BentoDropdown"]) > VStartTag > VAttribute[directive=true][key.name.name="bind"][key.argument.name="size"]`](
|
|
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
|
+
};
|
package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.test.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import vueParser from 'vue-eslint-parser';
|
|
3
|
+
import tsParser from '@typescript-eslint/parser';
|
|
4
|
+
import deprecationBentoDropdownSizeProp from './deprecation-bento-dropdown-size-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-dropdown-size-prop', () => {
|
|
18
|
+
ruleTester.run('deprecation-bento-dropdown-size-prop', deprecationBentoDropdownSizeProp, {
|
|
19
|
+
valid: [
|
|
20
|
+
{
|
|
21
|
+
name: 'Valid usage for bento-dropdown',
|
|
22
|
+
filename: 'test.vue',
|
|
23
|
+
code: `
|
|
24
|
+
<template>
|
|
25
|
+
<bento-dropdown other-prop="val" />
|
|
26
|
+
</template>
|
|
27
|
+
`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
invalid: [
|
|
31
|
+
// bento-dropdown: Static
|
|
32
|
+
{
|
|
33
|
+
name: 'Invalid: Static prop on bento-dropdown',
|
|
34
|
+
filename: 'test.vue',
|
|
35
|
+
code: `<template><bento-dropdown size="small" /></template>`,
|
|
36
|
+
errors: [{ messageId: 'deprecation' }],
|
|
37
|
+
},
|
|
38
|
+
// bento-dropdown: Shorthand
|
|
39
|
+
{
|
|
40
|
+
name: 'Invalid: Dynamic prop on bento-dropdown',
|
|
41
|
+
filename: 'test.vue',
|
|
42
|
+
code: `<template><bento-dropdown :size="dropdownSize" /></template>`,
|
|
43
|
+
errors: [{ messageId: 'deprecation' }],
|
|
44
|
+
},
|
|
45
|
+
// bento-dropdown: v-bind longhand
|
|
46
|
+
{
|
|
47
|
+
name: 'Invalid: v-bind longhand prop on bento-dropdown',
|
|
48
|
+
filename: 'test.vue',
|
|
49
|
+
code: `<template><bento-dropdown v-bind:size="dropdownSize" /></template>`,
|
|
50
|
+
errors: [{ messageId: 'deprecation' }],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/* ------------------------------------------------ */
|
|
56
|
+
/* AUTOFIX TESTS */
|
|
57
|
+
/* ------------------------------------------------ */
|
|
58
|
+
ruleTester.run('deprecation-bento-dropdown-size-prop (autofix enabled)', deprecationBentoDropdownSizeProp, {
|
|
59
|
+
valid: [
|
|
60
|
+
{
|
|
61
|
+
name: 'Valid: no size prop (autofix enabled)',
|
|
62
|
+
filename: 'test.vue',
|
|
63
|
+
options: [{ autofix: true }],
|
|
64
|
+
code: `<template><bento-dropdown :items="items" /></template>`,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
invalid: [
|
|
68
|
+
{
|
|
69
|
+
name: 'Autofix: removes static size prop',
|
|
70
|
+
filename: 'test.vue',
|
|
71
|
+
options: [{ autofix: true }],
|
|
72
|
+
code: `<template><bento-dropdown size="small" /></template>`,
|
|
73
|
+
output: `<template><bento-dropdown /></template>`,
|
|
74
|
+
errors: [{ messageId: 'deprecation' }],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Autofix: removes dynamic size prop',
|
|
78
|
+
filename: 'test.vue',
|
|
79
|
+
options: [{ autofix: true }],
|
|
80
|
+
code: `<template><bento-dropdown :size="dropdownSize" /></template>`,
|
|
81
|
+
output: `<template><bento-dropdown /></template>`,
|
|
82
|
+
errors: [{ messageId: 'deprecation' }],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Autofix: removes v-bind longhand size prop',
|
|
86
|
+
filename: 'test.vue',
|
|
87
|
+
options: [{ autofix: true }],
|
|
88
|
+
code: `<template><bento-dropdown v-bind:size="dropdownSize" /></template>`,
|
|
89
|
+
output: `<template><bento-dropdown /></template>`,
|
|
90
|
+
errors: [{ messageId: 'deprecation' }],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Autofix: does not fix when autofix is false',
|
|
94
|
+
filename: 'test.vue',
|
|
95
|
+
options: [{ autofix: false }],
|
|
96
|
+
code: `<template><bento-dropdown size="small" other="x" /></template>`,
|
|
97
|
+
errors: [{ messageId: 'deprecation' }],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -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
|
+
});
|