@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/configs/vue-recommended.js +8 -0
  3. package/configs/vue-strict.js +8 -0
  4. package/index.js +8 -0
  5. package/package.json +1 -1
  6. package/rules/deprecation-bento-dropdown-size-prop/README.md +25 -0
  7. package/rules/deprecation-bento-dropdown-size-prop/__tests__/deprecation-bento-dropdown-size-prop.vue +9 -0
  8. package/rules/deprecation-bento-dropdown-size-prop/__tests__/eslint.config.js +26 -0
  9. package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.integration.test.ts +33 -0
  10. package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.js +78 -0
  11. package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.test.ts +101 -0
  12. package/rules/deprecation-bento-popover-modifiers-prop/README.md +23 -0
  13. package/rules/deprecation-bento-popover-modifiers-prop/__tests__/deprecation-bento-popover-modifiers-prop.vue +9 -0
  14. package/rules/deprecation-bento-popover-modifiers-prop/__tests__/eslint.config.js +26 -0
  15. package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.integration.test.ts +24 -0
  16. package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.js +78 -0
  17. package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.test.ts +109 -0
  18. package/rules/deprecation-bento-timeline-item-variant-prop/README.md +25 -0
  19. package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/deprecation-bento-timeline-item-variant-prop.vue +9 -0
  20. package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/eslint.config.js +26 -0
  21. package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.integration.test.ts +31 -0
  22. package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.js +78 -0
  23. package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.test.ts +66 -0
  24. package/rules/deprecation-components-aria-label-prop/README.md +62 -0
  25. package/rules/deprecation-components-aria-label-prop/__tests__/deprecation-components-aria-label-prop.vue +25 -0
  26. package/rules/deprecation-components-aria-label-prop/__tests__/eslint.config.js +26 -0
  27. package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.integration.test.ts +36 -0
  28. package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.js +79 -0
  29. package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.test.ts +194 -0
  30. package/rules/deprecation-components-error-prop/README.md +43 -0
  31. package/rules/deprecation-components-error-prop/__tests__/deprecation-components-error-prop.vue +17 -0
  32. package/rules/deprecation-components-error-prop/__tests__/eslint.config.js +26 -0
  33. package/rules/deprecation-components-error-prop/deprecation-components-error-prop.integration.test.ts +37 -0
  34. package/rules/deprecation-components-error-prop/deprecation-components-error-prop.js +79 -0
  35. package/rules/deprecation-components-error-prop/deprecation-components-error-prop.test.ts +120 -0
  36. package/rules/deprecation-components-has-error-prop/README.md +34 -0
  37. package/rules/deprecation-components-has-error-prop/__tests__/deprecation-components-has-error-prop.vue +13 -0
  38. package/rules/deprecation-components-has-error-prop/__tests__/eslint.config.js +26 -0
  39. package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.integration.test.ts +29 -0
  40. package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.js +77 -0
  41. package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.test.ts +133 -0
  42. package/rules/deprecation-components-input-emit/__tests__/eslint.config.js +1 -1
  43. package/rules/deprecation-components-input-emit/deprecation-components-input-emit.js +19 -4
  44. package/rules/deprecation-components-input-emit/deprecation-components-input-emit.test.ts +40 -0
  45. package/rules/deprecation-components-value-prop/__tests__/eslint.config.js +1 -1
  46. package/rules/deprecation-components-value-prop/deprecation-components-value-prop.js +24 -7
  47. package/rules/deprecation-components-value-prop/deprecation-components-value-prop.test.ts +56 -0
  48. package/rules/deprecation-filter-bar-deprecated-props/README.md +64 -0
  49. package/rules/deprecation-filter-bar-deprecated-props/__tests__/deprecation-filter-bar-deprecated-props.vue +48 -0
  50. package/rules/deprecation-filter-bar-deprecated-props/__tests__/eslint.config.js +25 -0
  51. package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.integration.test.ts +22 -0
  52. package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.js +187 -0
  53. package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.test.ts +421 -0
  54. package/rules/deprecation-input-filter-dropdown-options/README.md +44 -0
  55. package/rules/deprecation-input-filter-dropdown-options/__tests__/deprecation-input-filter-dropdown-options.vue +46 -0
  56. package/rules/deprecation-input-filter-dropdown-options/__tests__/eslint.config.js +26 -0
  57. package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.integration.test.ts +27 -0
  58. package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.js +135 -0
  59. package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.test.ts +392 -0
@@ -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,9 @@
1
+ <template>
2
+ <div>
3
+ <bento-timeline-item variant="SUCCESS" />
4
+ <bento-timeline-item :variant="BentoTimelineItemVariant.CRITICAL" />
5
+ <bento-timeline-item :variant="BentoTimelineItemVariant.SUCCESS" />
6
+ </div>
7
+ </template>
8
+
9
+ <script setup></script>
@@ -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
+ ```
@@ -0,0 +1,25 @@
1
+ <template>
2
+ <div>
3
+ <bento-dropdown ariaLabel="value" />
4
+ <bento-dropdown :ariaLabel="value" />
5
+ <bento-dropdown v-bind:ariaLabel="value" />
6
+
7
+ <bento-input-field ariaLabel="value" />
8
+ <bento-input-field :ariaLabel="value" />
9
+ <bento-input-field v-bind:ariaLabel="value" />
10
+
11
+ <bento-pagination ariaLabel="value" />
12
+ <bento-pagination :ariaLabel="value" />
13
+ <bento-pagination v-bind:ariaLabel="value" />
14
+
15
+ <bento-popover ariaLabel="value" />
16
+ <bento-popover :ariaLabel="value" />
17
+ <bento-popover v-bind:ariaLabel="value" />
18
+
19
+ <bento-segmented-control ariaLabel="value" />
20
+ <bento-segmented-control :ariaLabel="value" />
21
+ <bento-segmented-control v-bind:ariaLabel="value" />
22
+ </div>
23
+ </template>
24
+
25
+ <script setup></script>
@@ -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-components-aria-label-prop': 'warn',
23
+ },
24
+ files: ['**/*.vue'],
25
+ },
26
+ ]);
@@ -0,0 +1,36 @@
1
+ import path from 'node:path';
2
+ import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
3
+
4
+ describe('@adyen/bento/deprecation-components-aria-label-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-aria-label-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 = 5;
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-aria-label-prop',
27
+ severity: 1,
28
+
29
+ messageId: 'deprecation',
30
+ message: `The "ariaLabel" prop is deprecated. Please use "aria-label" instead.`,
31
+ });
32
+
33
+ // Without autofix option, no fix should be present
34
+ expect(result[0].messages[0].fix).toBeUndefined();
35
+ });
36
+ });
@@ -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 ariaLabel prop in bento-dropdown, bento-input-field, bento-pagination, bento-popover, bento-segmented-control',
17
+ category: 'Deprecations',
18
+ url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/deprecation-components-aria-label-prop/README.md',
19
+ recommended: true,
20
+ },
21
+ messages: {
22
+ deprecation: `The "ariaLabel" prop is deprecated. Please use "aria-label" 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: ariaLabel="foo" (parser lowercases to "arialabel")
49
+ [`VElement:matches([name="bento-dropdown"], [name="BentoDropdown"], [name="bento-input-field"], [name="BentoInputField"], [name="bento-pagination"], [name="BentoPagination"], [name="bento-popover"], [name="BentoPopover"], [name="bento-segmented-control"], [name="BentoSegmentedControl"]) > VStartTag > VAttribute[directive=false][key.name="arialabel"]`](
50
+ node
51
+ ) {
52
+ context.report({
53
+ node,
54
+ messageId: 'deprecation',
55
+ ...(autofix && {
56
+ fix(fixer) {
57
+ return fixer.replaceText(node.key, 'aria-label');
58
+ },
59
+ }),
60
+ });
61
+ },
62
+
63
+ // 2. DYNAMIC: :ariaLabel="foo" or v-bind:ariaLabel="foo" (parser lowercases to "arialabel")
64
+ [`VElement:matches([name="bento-dropdown"], [name="BentoDropdown"], [name="bento-input-field"], [name="BentoInputField"], [name="bento-pagination"], [name="BentoPagination"], [name="bento-popover"], [name="BentoPopover"], [name="bento-segmented-control"], [name="BentoSegmentedControl"]) > VStartTag > VAttribute[directive=true][key.name.name="bind"][key.argument.name="arialabel"]`](
65
+ node
66
+ ) {
67
+ context.report({
68
+ node,
69
+ messageId: 'deprecation',
70
+ ...(autofix && {
71
+ fix(fixer) {
72
+ return fixer.replaceText(node.key.argument, 'aria-label');
73
+ },
74
+ }),
75
+ });
76
+ },
77
+ });
78
+ },
79
+ };
@@ -0,0 +1,194 @@
1
+ import { RuleTester } from 'eslint';
2
+ import vueParser from 'vue-eslint-parser';
3
+ import tsParser from '@typescript-eslint/parser';
4
+ import deprecationComponentsAriaLabelProp from './deprecation-components-aria-label-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-aria-label-prop', () => {
18
+ ruleTester.run('deprecation-components-aria-label-prop', deprecationComponentsAriaLabelProp, {
19
+ valid: [
20
+ {
21
+ name: 'Valid usage for bento-dropdown',
22
+ filename: 'test.vue',
23
+ code: `
24
+ <template>
25
+ <bento-dropdown aria-label="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 aria-label="val" />
35
+ </template>
36
+ `,
37
+ },
38
+ {
39
+ name: 'Valid usage for bento-pagination',
40
+ filename: 'test.vue',
41
+ code: `
42
+ <template>
43
+ <bento-pagination aria-label="val" />
44
+ </template>
45
+ `,
46
+ },
47
+ {
48
+ name: 'Valid usage for bento-popover',
49
+ filename: 'test.vue',
50
+ code: `
51
+ <template>
52
+ <bento-popover aria-label="val" />
53
+ </template>
54
+ `,
55
+ },
56
+ {
57
+ name: 'Valid usage for bento-segmented-control',
58
+ filename: 'test.vue',
59
+ code: `
60
+ <template>
61
+ <bento-segmented-control aria-label="val" />
62
+ </template>
63
+ `,
64
+ },
65
+ ],
66
+ invalid: [
67
+ // bento-dropdown: Static
68
+ {
69
+ name: 'Invalid: Static prop on bento-dropdown',
70
+ filename: 'test.vue',
71
+ code: `<template><bento-dropdown ariaLabel="val" /></template>`,
72
+ errors: [{ messageId: 'deprecation' }],
73
+ },
74
+ // bento-dropdown: Shorthand
75
+ {
76
+ name: 'Invalid: Dynamic prop on bento-dropdown',
77
+ filename: 'test.vue',
78
+ code: `<template><bento-dropdown :ariaLabel="val" /></template>`,
79
+ errors: [{ messageId: 'deprecation' }],
80
+ },
81
+ // bento-input-field: Static
82
+ {
83
+ name: 'Invalid: Static prop on bento-input-field',
84
+ filename: 'test.vue',
85
+ code: `<template><bento-input-field ariaLabel="val" /></template>`,
86
+ errors: [{ messageId: 'deprecation' }],
87
+ },
88
+ // bento-input-field: Shorthand
89
+ {
90
+ name: 'Invalid: Dynamic prop on bento-input-field',
91
+ filename: 'test.vue',
92
+ code: `<template><bento-input-field :ariaLabel="val" /></template>`,
93
+ errors: [{ messageId: 'deprecation' }],
94
+ },
95
+ // bento-pagination: Static
96
+ {
97
+ name: 'Invalid: Static prop on bento-pagination',
98
+ filename: 'test.vue',
99
+ code: `<template><bento-pagination ariaLabel="val" /></template>`,
100
+ errors: [{ messageId: 'deprecation' }],
101
+ },
102
+ // bento-pagination: Shorthand
103
+ {
104
+ name: 'Invalid: Dynamic prop on bento-pagination',
105
+ filename: 'test.vue',
106
+ code: `<template><bento-pagination :ariaLabel="val" /></template>`,
107
+ errors: [{ messageId: 'deprecation' }],
108
+ },
109
+ // bento-popover: Static
110
+ {
111
+ name: 'Invalid: Static prop on bento-popover',
112
+ filename: 'test.vue',
113
+ code: `<template><bento-popover ariaLabel="val" /></template>`,
114
+ errors: [{ messageId: 'deprecation' }],
115
+ },
116
+ // bento-popover: Shorthand
117
+ {
118
+ name: 'Invalid: Dynamic prop on bento-popover',
119
+ filename: 'test.vue',
120
+ code: `<template><bento-popover :ariaLabel="val" /></template>`,
121
+ errors: [{ messageId: 'deprecation' }],
122
+ },
123
+ // bento-segmented-control: Static
124
+ {
125
+ name: 'Invalid: Static prop on bento-segmented-control',
126
+ filename: 'test.vue',
127
+ code: `<template><bento-segmented-control ariaLabel="val" /></template>`,
128
+ errors: [{ messageId: 'deprecation' }],
129
+ },
130
+ // bento-segmented-control: Shorthand
131
+ {
132
+ name: 'Invalid: Dynamic prop on bento-segmented-control',
133
+ filename: 'test.vue',
134
+ code: `<template><bento-segmented-control :ariaLabel="val" /></template>`,
135
+ errors: [{ messageId: 'deprecation' }],
136
+ },
137
+ ],
138
+ });
139
+
140
+ /* ------------------------------------------------ */
141
+ /* AUTOFIX TESTS */
142
+ /* ------------------------------------------------ */
143
+ ruleTester.run('deprecation-components-aria-label-prop (autofix enabled)', deprecationComponentsAriaLabelProp, {
144
+ valid: [
145
+ {
146
+ name: 'Valid: aria-label (kebab-case) on bento-dropdown (autofix enabled)',
147
+ filename: 'test.vue',
148
+ options: [{ autofix: true }],
149
+ code: `<template><bento-dropdown aria-label="val" /></template>`,
150
+ },
151
+ ],
152
+ invalid: [
153
+ {
154
+ name: 'Autofix: static prop on bento-dropdown',
155
+ filename: 'test.vue',
156
+ options: [{ autofix: true }],
157
+ code: `<template><bento-dropdown ariaLabel="val" /></template>`,
158
+ output: `<template><bento-dropdown aria-label="val" /></template>`,
159
+ errors: [{ messageId: 'deprecation' }],
160
+ },
161
+ {
162
+ name: 'Autofix: dynamic prop on bento-dropdown',
163
+ filename: 'test.vue',
164
+ options: [{ autofix: true }],
165
+ code: `<template><bento-dropdown :ariaLabel="val" /></template>`,
166
+ output: `<template><bento-dropdown :aria-label="val" /></template>`,
167
+ errors: [{ messageId: 'deprecation' }],
168
+ },
169
+ {
170
+ name: 'Autofix: static prop on bento-segmented-control',
171
+ filename: 'test.vue',
172
+ options: [{ autofix: true }],
173
+ code: `<template><bento-segmented-control ariaLabel="val" /></template>`,
174
+ output: `<template><bento-segmented-control aria-label="val" /></template>`,
175
+ errors: [{ messageId: 'deprecation' }],
176
+ },
177
+ {
178
+ name: 'Autofix: v-bind longhand on bento-popover',
179
+ filename: 'test.vue',
180
+ options: [{ autofix: true }],
181
+ code: `<template><bento-popover v-bind:ariaLabel="val" /></template>`,
182
+ output: `<template><bento-popover v-bind:aria-label="val" /></template>`,
183
+ errors: [{ messageId: 'deprecation' }],
184
+ },
185
+ {
186
+ name: 'Autofix: does not fix when autofix is false',
187
+ filename: 'test.vue',
188
+ options: [{ autofix: false }],
189
+ code: `<template><bento-dropdown ariaLabel="val" /></template>`,
190
+ errors: [{ messageId: 'deprecation' }],
191
+ },
192
+ ],
193
+ });
194
+ });