@adyen/eslint-plugin-bento 2.23.0 → 2.24.1
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 +23 -0
- package/README.md +31 -15
- package/configs/vue-recommended.js +15 -0
- package/configs/vue-strict.js +15 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/rules/deprecation-bento-tag-variant-enum/README.md +69 -0
- package/rules/deprecation-bento-tag-variant-enum/deprecation-bento-tag-variant-enum.js +167 -0
- package/rules/vue-no-redundant-dialog-v-if/README.md +55 -0
- package/rules/vue-no-redundant-dialog-v-if/vue-no-redundant-dialog-v-if.js +150 -0
- package/rules/vue-no-use-bento-translation-overrides/README.md +14 -0
- package/rules/vue-no-use-bento-translation-overrides/vue-no-use-bento-translation-overrides.js +93 -0
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/deprecation-bento-data-grid-cell-action-menu-item-handler.vue +0 -63
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.integration.test.ts +0 -24
- package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/deprecation-bento-data-grid-cell-action-menu-item-handler.test.ts +0 -116
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/deprecation-bento-date-range-picker-has-actions-prop.vue +0 -10
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/eslint.config.js +0 -29
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/remove/deprecation-bento-date-range-picker-has-actions-prop.vue +0 -11
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/remove/eslint.config.js +0 -29
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/deprecation-bento-date-range-picker-has-actions-prop.integration.test.ts +0 -47
- package/rules/deprecation-bento-date-range-picker-has-actions-prop/deprecation-bento-date-range-picker-has-actions-prop.test.ts +0 -176
- package/rules/deprecation-bento-dropdown-size-prop/__tests__/deprecation-bento-dropdown-size-prop.vue +0 -9
- package/rules/deprecation-bento-dropdown-size-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.integration.test.ts +0 -33
- package/rules/deprecation-bento-dropdown-size-prop/deprecation-bento-dropdown-size-prop.test.ts +0 -101
- package/rules/deprecation-bento-popover-modifiers-prop/__tests__/deprecation-bento-popover-modifiers-prop.vue +0 -9
- package/rules/deprecation-bento-popover-modifiers-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.integration.test.ts +0 -24
- package/rules/deprecation-bento-popover-modifiers-prop/deprecation-bento-popover-modifiers-prop.test.ts +0 -109
- package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/deprecation-bento-timeline-item-variant-prop.vue +0 -9
- package/rules/deprecation-bento-timeline-item-variant-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.integration.test.ts +0 -35
- package/rules/deprecation-bento-timeline-item-variant-prop/deprecation-bento-timeline-item-variant-prop.test.ts +0 -141
- package/rules/deprecation-components-aria-label-prop/__tests__/deprecation-components-aria-label-prop.vue +0 -25
- package/rules/deprecation-components-aria-label-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.integration.test.ts +0 -36
- package/rules/deprecation-components-aria-label-prop/deprecation-components-aria-label-prop.test.ts +0 -194
- package/rules/deprecation-components-error-prop/__tests__/deprecation-components-error-prop.vue +0 -17
- package/rules/deprecation-components-error-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.integration.test.ts +0 -41
- package/rules/deprecation-components-error-prop/deprecation-components-error-prop.test.ts +0 -153
- package/rules/deprecation-components-has-error-prop/__tests__/deprecation-components-has-error-prop.vue +0 -13
- package/rules/deprecation-components-has-error-prop/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.integration.test.ts +0 -37
- package/rules/deprecation-components-has-error-prop/deprecation-components-has-error-prop.test.ts +0 -122
- package/rules/deprecation-components-input-emit/__tests__/deprecation-components-input-emit.vue +0 -22
- package/rules/deprecation-components-input-emit/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.integration.test.ts +0 -43
- package/rules/deprecation-components-input-emit/deprecation-components-input-emit.test.ts +0 -320
- package/rules/deprecation-components-value-prop/__tests__/deprecation-components-value-prop.vue +0 -69
- package/rules/deprecation-components-value-prop/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.integration.test.ts +0 -37
- package/rules/deprecation-components-value-prop/deprecation-components-value-prop.test.ts +0 -480
- package/rules/deprecation-country-custom-usage/__tests__/deprecation-country-custom-usage.vue +0 -93
- package/rules/deprecation-country-custom-usage/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.integration.test.ts +0 -22
- package/rules/deprecation-country-custom-usage/deprecation-country-custom-usage.test.ts +0 -380
- package/rules/deprecation-currency-default-slot/__tests__/deprecation-currency-default-slot.vue +0 -7
- package/rules/deprecation-currency-default-slot/__tests__/eslint.config.js +0 -24
- package/rules/deprecation-currency-default-slot/deprecation-currency-default-slot.integration.test.ts +0 -29
- package/rules/deprecation-currency-default-slot/deprecation-currency-default-slot.test.ts +0 -136
- package/rules/deprecation-filter-bar-deprecated-props/__tests__/deprecation-filter-bar-deprecated-props.vue +0 -62
- package/rules/deprecation-filter-bar-deprecated-props/__tests__/eslint.config.js +0 -25
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.integration.test.ts +0 -22
- package/rules/deprecation-filter-bar-deprecated-props/deprecation-filter-bar-deprecated-props.test.ts +0 -492
- package/rules/deprecation-input-filter-dropdown-options/__tests__/deprecation-input-filter-dropdown-options.vue +0 -46
- package/rules/deprecation-input-filter-dropdown-options/__tests__/eslint.config.js +0 -26
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.integration.test.ts +0 -27
- package/rules/deprecation-input-filter-dropdown-options/deprecation-input-filter-dropdown-options.test.ts +0 -392
- package/rules/deprecation-tag-default-slot/__tests__/deprecation-tag-default-slot.vue +0 -5
- package/rules/deprecation-tag-default-slot/__tests__/eslint.config.js +0 -24
- package/rules/deprecation-tag-default-slot/deprecation-tag-default-slot.integration.test.ts +0 -29
- package/rules/deprecation-tag-default-slot/deprecation-tag-default-slot.test.ts +0 -163
- package/rules/tailwind-v3-to-bento/__tests__/eslint.config.js +0 -24
- package/rules/tailwind-v3-to-bento/__tests__/tailwind-v3-to-bento.vue +0 -15
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.integration.test.ts +0 -29
- package/rules/tailwind-v3-to-bento/tailwind-v3-to-bento.test.ts +0 -403
- package/rules/vue-old-spacer-tokens/__tests__/eslint.config.js +0 -24
- package/rules/vue-old-spacer-tokens/__tests__/vue-old-spacer-tokens.vue +0 -5
- package/rules/vue-old-spacer-tokens/vue-old-spacer-tokens.integration.test.ts +0 -29
- package/rules/vue-old-spacer-tokens/vue-old-spacer-tokens.test.ts +0 -77
package/rules/vue-no-use-bento-translation-overrides/vue-no-use-bento-translation-overrides.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('eslint').Rule.RuleContext} RuleContext
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('eslint').Rule.RuleModule} RuleModule
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const BENTO_VUE3_PACKAGE = '@adyen/bento-vue3';
|
|
9
|
+
const RESTRICTED_COMPOSABLE = 'useBentoTranslationOverrides';
|
|
10
|
+
|
|
11
|
+
/** @type {RuleModule} */
|
|
12
|
+
module.exports = {
|
|
13
|
+
meta: {
|
|
14
|
+
type: 'problem',
|
|
15
|
+
docs: {
|
|
16
|
+
description: `Restricts use of ${RESTRICTED_COMPOSABLE} to approved customer-facing SDKs and component libraries.`,
|
|
17
|
+
category: 'Restrictions',
|
|
18
|
+
url: 'https://github.com/Adyen/bento/blob/main/packages/eslint/rules/vue-no-use-bento-translation-overrides/README.md',
|
|
19
|
+
recommended: true,
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
restricted:
|
|
23
|
+
'`useBentoTranslationOverrides` is restricted to teams building SDKs or component libraries for external customers and must not be used in Adyen products. Request approval from the Bento team before using this composable.',
|
|
24
|
+
},
|
|
25
|
+
schema: [],
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/** @param {RuleContext} context */
|
|
29
|
+
create(context) {
|
|
30
|
+
const namespaceImports = new Set();
|
|
31
|
+
|
|
32
|
+
const getImportedName = specifier => {
|
|
33
|
+
if (specifier.type !== 'ImportSpecifier' && specifier.type !== 'ExportSpecifier') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const imported = specifier.type === 'ImportSpecifier' ? specifier.imported : specifier.local;
|
|
38
|
+
return imported.type === 'Identifier' ? imported.name : imported.value;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const reportRestrictedSpecifier = specifier => {
|
|
42
|
+
if (getImportedName(specifier) === RESTRICTED_COMPOSABLE) {
|
|
43
|
+
context.report({
|
|
44
|
+
node: specifier,
|
|
45
|
+
messageId: 'restricted',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
ImportDeclaration(node) {
|
|
52
|
+
if (node.source.value !== BENTO_VUE3_PACKAGE) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const specifier of node.specifiers) {
|
|
57
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
58
|
+
namespaceImports.add(specifier.local.name);
|
|
59
|
+
} else {
|
|
60
|
+
reportRestrictedSpecifier(specifier);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
ExportNamedDeclaration(node) {
|
|
65
|
+
if (node.source?.value !== BENTO_VUE3_PACKAGE) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
node.specifiers.forEach(reportRestrictedSpecifier);
|
|
70
|
+
},
|
|
71
|
+
MemberExpression(node) {
|
|
72
|
+
if (node.object.type !== 'Identifier' || !namespaceImports.has(node.object.name)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const propertyName = node.computed
|
|
77
|
+
? node.property.type === 'Literal'
|
|
78
|
+
? node.property.value
|
|
79
|
+
: null
|
|
80
|
+
: node.property.type === 'Identifier'
|
|
81
|
+
? node.property.name
|
|
82
|
+
: null;
|
|
83
|
+
|
|
84
|
+
if (propertyName === RESTRICTED_COMPOSABLE) {
|
|
85
|
+
context.report({
|
|
86
|
+
node,
|
|
87
|
+
messageId: 'restricted',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<!-- Inline expression: should warn (2 handlers) -->
|
|
4
|
-
<bento-data-grid
|
|
5
|
-
:cell-actions="[
|
|
6
|
-
{
|
|
7
|
-
variant: 'more',
|
|
8
|
-
menuData: [
|
|
9
|
-
{
|
|
10
|
-
text: 'Cancel payment',
|
|
11
|
-
handler: () => {
|
|
12
|
-
return;
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
text: 'Transfer payment',
|
|
17
|
-
handler: () => {
|
|
18
|
-
return;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
]"
|
|
24
|
-
:data="[]"
|
|
25
|
-
:columns="[]"
|
|
26
|
-
/>
|
|
27
|
-
|
|
28
|
-
<!-- Identifier reference: should warn (1 handler) -->
|
|
29
|
-
<bento-data-grid :cell-actions="rowActions" :data="[]" :columns="[]" />
|
|
30
|
-
|
|
31
|
-
<!-- Non-data-grid component: should NOT warn -->
|
|
32
|
-
<test-component
|
|
33
|
-
:cell-actions="[
|
|
34
|
-
{
|
|
35
|
-
menuData: [
|
|
36
|
-
{
|
|
37
|
-
text: 'Action',
|
|
38
|
-
handler: () => {
|
|
39
|
-
return;
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
]"
|
|
45
|
-
/>
|
|
46
|
-
</div>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script setup>
|
|
50
|
-
const rowActions = [
|
|
51
|
-
{
|
|
52
|
-
variant: 'more',
|
|
53
|
-
menuData: [
|
|
54
|
-
{
|
|
55
|
-
text: 'Refund',
|
|
56
|
-
handler: () => {
|
|
57
|
-
return;
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
</script>
|
package/rules/deprecation-bento-data-grid-cell-action-menu-item-handler/__tests__/eslint.config.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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-data-grid-cell-action-menu-item-handler': ['warn', { autofix: true }],
|
|
23
|
-
},
|
|
24
|
-
files: ['**/*.vue'],
|
|
25
|
-
},
|
|
26
|
-
]);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
-
|
|
4
|
-
describe('@adyen/bento/deprecation-bento-data-grid-cell-action-menu-item-handler', () => {
|
|
5
|
-
it('should lint with warning when handler is used in menuData', () => {
|
|
6
|
-
const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
|
|
7
|
-
const vueFile = path.resolve(
|
|
8
|
-
__dirname,
|
|
9
|
-
'__tests__',
|
|
10
|
-
'deprecation-bento-data-grid-cell-action-menu-item-handler.vue'
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
14
|
-
|
|
15
|
-
expect(result[0].warningCount).toBe(3);
|
|
16
|
-
|
|
17
|
-
expect(result[0].messages[0]).toMatchObject({
|
|
18
|
-
ruleId: '@adyen/bento/deprecation-bento-data-grid-cell-action-menu-item-handler',
|
|
19
|
-
severity: 1,
|
|
20
|
-
messageId: 'deprecation',
|
|
21
|
-
message: `The "handler" property is deprecated in bento-data-grid cell action menu items. Use "event" instead.`,
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from 'eslint';
|
|
2
|
-
import vueParser from 'vue-eslint-parser';
|
|
3
|
-
import tsParser from '@typescript-eslint/parser';
|
|
4
|
-
import deprecationRule from './deprecation-bento-data-grid-cell-action-menu-item-handler';
|
|
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-data-grid-cell-action-menu-item-handler', () => {
|
|
18
|
-
ruleTester.run('deprecation-bento-data-grid-cell-action-menu-item-handler', deprecationRule, {
|
|
19
|
-
valid: [
|
|
20
|
-
{
|
|
21
|
-
name: 'Valid: menuData with event instead of handler',
|
|
22
|
-
filename: 'test.vue',
|
|
23
|
-
code: `<template>
|
|
24
|
-
<bento-data-grid :cell-actions="[{ menuData: [{ text: 'Edit', event: fn }] }]" />
|
|
25
|
-
</template>`,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'Valid: handler in menuData on a non-data-grid component (template)',
|
|
29
|
-
filename: 'test.vue',
|
|
30
|
-
code: `<template>
|
|
31
|
-
<test-component :cell-actions="[{ menuData: [{ text: 'Edit', handler: fn }] }]" />
|
|
32
|
-
</template>`,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'Valid: handler outside of menuData context',
|
|
36
|
-
filename: 'test.vue',
|
|
37
|
-
code: `<script>const obj = { handler: () => {} };</script>`,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'Valid: handler in unrelated array',
|
|
41
|
-
filename: 'test.vue',
|
|
42
|
-
code: `<script>const arr = [{ handler: () => {} }];</script>`,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: 'Valid: menuData with event in script',
|
|
46
|
-
filename: 'test.vue',
|
|
47
|
-
code: `<script>
|
|
48
|
-
const actions = [{ menuData: [{ text: 'Edit', event: () => {} }] }];
|
|
49
|
-
</script>`,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'Valid: handler in menuData in script not passed to bento-data-grid',
|
|
53
|
-
filename: 'test.vue',
|
|
54
|
-
code: `<template>
|
|
55
|
-
<test-component :cell-actions="actions" />
|
|
56
|
-
</template>
|
|
57
|
-
<script>
|
|
58
|
-
const actions = [{ menuData: [{ text: 'Cancel', handler: () => {} }] }];
|
|
59
|
-
</script>`,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
invalid: [
|
|
63
|
-
{
|
|
64
|
-
name: 'Invalid: handler in menuData (template, no autofix)',
|
|
65
|
-
filename: 'test.vue',
|
|
66
|
-
code: `<template>
|
|
67
|
-
<bento-data-grid :cell-actions="[{ menuData: [{ text: 'Cancel', handler: fn }] }]" />
|
|
68
|
-
</template>`,
|
|
69
|
-
output: null,
|
|
70
|
-
errors: [{ messageId: 'deprecation' }],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'Invalid: handler in menuData (template, autofix renames to event)',
|
|
74
|
-
filename: 'test.vue',
|
|
75
|
-
code: `<template>
|
|
76
|
-
<bento-data-grid :cell-actions="[{ menuData: [{ text: 'Cancel', handler: fn }] }]" />
|
|
77
|
-
</template>`,
|
|
78
|
-
output: `<template>
|
|
79
|
-
<bento-data-grid :cell-actions="[{ menuData: [{ text: 'Cancel', event: fn }] }]" />
|
|
80
|
-
</template>`,
|
|
81
|
-
options: [{ autofix: true }],
|
|
82
|
-
errors: [{ messageId: 'deprecation' }],
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: 'Invalid: handler resolved from script variable via identifier',
|
|
86
|
-
filename: 'test.vue',
|
|
87
|
-
code: `<template>
|
|
88
|
-
<bento-data-grid :cell-actions="actions" />
|
|
89
|
-
</template>
|
|
90
|
-
<script>
|
|
91
|
-
const actions = [{ menuData: [{ text: 'Cancel', handler: () => {} }] }];
|
|
92
|
-
</script>`,
|
|
93
|
-
output: `<template>
|
|
94
|
-
<bento-data-grid :cell-actions="actions" />
|
|
95
|
-
</template>
|
|
96
|
-
<script>
|
|
97
|
-
const actions = [{ menuData: [{ text: 'Cancel', event: () => {} }] }];
|
|
98
|
-
</script>`,
|
|
99
|
-
options: [{ autofix: true }],
|
|
100
|
-
errors: [{ messageId: 'deprecation' }],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'Invalid: multiple handlers in menuData (template, autofix)',
|
|
104
|
-
filename: 'test.vue',
|
|
105
|
-
code: `<template>
|
|
106
|
-
<bento-data-grid :cell-actions="[{ menuData: [{ text: 'Cancel', handler: a }, { text: 'Delete', handler: b }] }]" />
|
|
107
|
-
</template>`,
|
|
108
|
-
output: `<template>
|
|
109
|
-
<bento-data-grid :cell-actions="[{ menuData: [{ text: 'Cancel', event: a }, { text: 'Delete', event: b }] }]" />
|
|
110
|
-
</template>`,
|
|
111
|
-
options: [{ autofix: true }],
|
|
112
|
-
errors: [{ messageId: 'deprecation' }, { messageId: 'deprecation' }],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
});
|
|
116
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<!-- These should trigger the "add" action (missing has-actions) -->
|
|
4
|
-
<bento-date-range-picker label="Pick a date" />
|
|
5
|
-
<bento-date-range-picker label="Another picker" :min="minDate" />
|
|
6
|
-
<bento-date-range-picker v-model="value" />
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script setup></script>
|
package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/eslint.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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-date-range-picker-has-actions-prop': [
|
|
23
|
-
'warn',
|
|
24
|
-
{ action: 'add', autofix: true },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
files: ['**/*.vue'],
|
|
28
|
-
},
|
|
29
|
-
]);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<!-- These should trigger the "remove" action (has-actions present) -->
|
|
4
|
-
<bento-date-range-picker has-actions />
|
|
5
|
-
<bento-date-range-picker has-actions label="Pick a date" />
|
|
6
|
-
<bento-date-range-picker :has-actions="true" />
|
|
7
|
-
<bento-date-range-picker :has-actions="false" />
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup></script>
|
package/rules/deprecation-bento-date-range-picker-has-actions-prop/__tests__/remove/eslint.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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-date-range-picker-has-actions-prop': [
|
|
23
|
-
'warn',
|
|
24
|
-
{ action: 'remove', autofix: true },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
files: ['**/*.vue'],
|
|
28
|
-
},
|
|
29
|
-
]);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { execFileSyncEslintVueFiles } from '../../utils/exec-file-sync-eslint-vue-files';
|
|
3
|
-
|
|
4
|
-
describe('@adyen/bento/deprecation-bento-date-range-picker-has-actions-prop', () => {
|
|
5
|
-
it('should lint with warning when has-actions is missing (add action)', () => {
|
|
6
|
-
const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
|
|
7
|
-
const vueFile = path.resolve(
|
|
8
|
-
__dirname,
|
|
9
|
-
'__tests__',
|
|
10
|
-
'deprecation-bento-date-range-picker-has-actions-prop.vue'
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
14
|
-
|
|
15
|
-
// The test .vue file has 3 bento-date-range-picker instances without has-actions
|
|
16
|
-
expect(result[0].warningCount).toBe(3);
|
|
17
|
-
|
|
18
|
-
expect(result[0].messages[0]).toMatchObject({
|
|
19
|
-
ruleId: '@adyen/bento/deprecation-bento-date-range-picker-has-actions-prop',
|
|
20
|
-
severity: 1,
|
|
21
|
-
messageId: 'missingProp',
|
|
22
|
-
message: `The temporary "has-actions" prop is missing on bento-date-range-picker. Add it to opt in to the new actions behavior.`,
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should lint with warning when has-actions is present (remove action)', () => {
|
|
27
|
-
const eslintrc = path.resolve(__dirname, '__tests__', 'remove', 'eslint.config.js');
|
|
28
|
-
const vueFile = path.resolve(
|
|
29
|
-
__dirname,
|
|
30
|
-
'__tests__',
|
|
31
|
-
'remove',
|
|
32
|
-
'deprecation-bento-date-range-picker-has-actions-prop.vue'
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const result = JSON.parse(execFileSyncEslintVueFiles(eslintrc, vueFile));
|
|
36
|
-
|
|
37
|
-
// The test .vue file has 4 bento-date-range-picker instances with has-actions
|
|
38
|
-
expect(result[0].warningCount).toBe(4);
|
|
39
|
-
|
|
40
|
-
expect(result[0].messages[0]).toMatchObject({
|
|
41
|
-
ruleId: '@adyen/bento/deprecation-bento-date-range-picker-has-actions-prop',
|
|
42
|
-
severity: 1,
|
|
43
|
-
messageId: 'removeProp',
|
|
44
|
-
message: `The temporary "has-actions" prop should be removed from bento-date-range-picker.`,
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from 'eslint';
|
|
2
|
-
import vueParser from 'vue-eslint-parser';
|
|
3
|
-
import tsParser from '@typescript-eslint/parser';
|
|
4
|
-
import deprecationBentoDateRangePickerHasActionsProp from './deprecation-bento-date-range-picker-has-actions-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-date-range-picker-has-actions-prop', () => {
|
|
18
|
-
describe('action: add (default)', () => {
|
|
19
|
-
ruleTester.run(
|
|
20
|
-
'deprecation-bento-date-range-picker-has-actions-prop (add)',
|
|
21
|
-
deprecationBentoDateRangePickerHasActionsProp,
|
|
22
|
-
{
|
|
23
|
-
valid: [
|
|
24
|
-
{
|
|
25
|
-
name: 'Valid: component already has has-actions (static boolean)',
|
|
26
|
-
filename: 'test.vue',
|
|
27
|
-
code: `<template><bento-date-range-picker has-actions /></template>`,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'Valid: component already has has-actions (dynamic)',
|
|
31
|
-
filename: 'test.vue',
|
|
32
|
-
code: `<template><bento-date-range-picker :has-actions="true" /></template>`,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'Valid: unrelated component without has-actions',
|
|
36
|
-
filename: 'test.vue',
|
|
37
|
-
code: `<template><bento-button label="click" /></template>`,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
invalid: [
|
|
41
|
-
{
|
|
42
|
-
name: 'Invalid: missing has-actions (no autofix)',
|
|
43
|
-
filename: 'test.vue',
|
|
44
|
-
code: `<template><bento-date-range-picker label="Pick" /></template>`,
|
|
45
|
-
output: null,
|
|
46
|
-
errors: [{ messageId: 'missingProp' }],
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'Invalid: missing has-actions (autofix adds prop)',
|
|
50
|
-
filename: 'test.vue',
|
|
51
|
-
code: `<template><bento-date-range-picker label="Pick" /></template>`,
|
|
52
|
-
output: `<template><bento-date-range-picker has-actions label="Pick" /></template>`,
|
|
53
|
-
options: [{ action: 'add', autofix: true }],
|
|
54
|
-
errors: [{ messageId: 'missingProp' }],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'Invalid: missing has-actions on self-closing tag without attrs (autofix)',
|
|
58
|
-
filename: 'test.vue',
|
|
59
|
-
code: `<template><bento-date-range-picker /></template>`,
|
|
60
|
-
output: `<template><bento-date-range-picker has-actions /></template>`,
|
|
61
|
-
options: [{ autofix: true }],
|
|
62
|
-
errors: [{ messageId: 'missingProp' }],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'Invalid: missing has-actions on self-closing tag without space before /> (autofix)',
|
|
66
|
-
filename: 'test.vue',
|
|
67
|
-
code: `<template><bento-date-range-picker/></template>`,
|
|
68
|
-
output: `<template><bento-date-range-picker has-actions /></template>`,
|
|
69
|
-
options: [{ autofix: true }],
|
|
70
|
-
errors: [{ messageId: 'missingProp' }],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'Invalid: has-actions="false" (static string false, no autofix)',
|
|
74
|
-
filename: 'test.vue',
|
|
75
|
-
code: `<template><bento-date-range-picker has-actions="false" /></template>`,
|
|
76
|
-
output: null,
|
|
77
|
-
errors: [{ messageId: 'missingProp' }],
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'Invalid: has-actions="false" (static string false, autofix replaces)',
|
|
81
|
-
filename: 'test.vue',
|
|
82
|
-
code: `<template><bento-date-range-picker has-actions="false" label="Pick" /></template>`,
|
|
83
|
-
output: `<template><bento-date-range-picker has-actions label="Pick" /></template>`,
|
|
84
|
-
options: [{ autofix: true }],
|
|
85
|
-
errors: [{ messageId: 'missingProp' }],
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: 'Invalid: :has-actions="false" (dynamic false, autofix replaces)',
|
|
89
|
-
filename: 'test.vue',
|
|
90
|
-
code: `<template><bento-date-range-picker :has-actions="false" label="Pick" /></template>`,
|
|
91
|
-
output: `<template><bento-date-range-picker has-actions label="Pick" /></template>`,
|
|
92
|
-
options: [{ autofix: true }],
|
|
93
|
-
errors: [{ messageId: 'missingProp' }],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: 'Invalid: multi-line component missing has-actions (autofix preserves indentation)',
|
|
97
|
-
filename: 'test.vue',
|
|
98
|
-
code: `<template>
|
|
99
|
-
<bento-date-range-picker
|
|
100
|
-
label="Pick"
|
|
101
|
-
/>
|
|
102
|
-
</template>`,
|
|
103
|
-
output: `<template>
|
|
104
|
-
<bento-date-range-picker
|
|
105
|
-
has-actions
|
|
106
|
-
label="Pick"
|
|
107
|
-
/>
|
|
108
|
-
</template>`,
|
|
109
|
-
options: [{ autofix: true }],
|
|
110
|
-
errors: [{ messageId: 'missingProp' }],
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe('action: remove', () => {
|
|
118
|
-
ruleTester.run(
|
|
119
|
-
'deprecation-bento-date-range-picker-has-actions-prop (remove)',
|
|
120
|
-
deprecationBentoDateRangePickerHasActionsProp,
|
|
121
|
-
{
|
|
122
|
-
valid: [
|
|
123
|
-
{
|
|
124
|
-
name: 'Valid: component without has-actions',
|
|
125
|
-
filename: 'test.vue',
|
|
126
|
-
code: `<template><bento-date-range-picker label="Pick" /></template>`,
|
|
127
|
-
options: [{ action: 'remove' }],
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
invalid: [
|
|
131
|
-
{
|
|
132
|
-
name: 'Invalid: has-actions present (static boolean, no autofix)',
|
|
133
|
-
filename: 'test.vue',
|
|
134
|
-
code: `<template><bento-date-range-picker has-actions /></template>`,
|
|
135
|
-
output: null,
|
|
136
|
-
options: [{ action: 'remove' }],
|
|
137
|
-
errors: [{ messageId: 'removeProp' }],
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'Invalid: has-actions present (static boolean, autofix removes)',
|
|
141
|
-
filename: 'test.vue',
|
|
142
|
-
code: `<template><bento-date-range-picker has-actions label="Pick" /></template>`,
|
|
143
|
-
output: `<template><bento-date-range-picker label="Pick" /></template>`,
|
|
144
|
-
options: [{ action: 'remove', autofix: true }],
|
|
145
|
-
errors: [{ messageId: 'removeProp' }],
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'Invalid: has-actions present (dynamic, autofix removes)',
|
|
149
|
-
filename: 'test.vue',
|
|
150
|
-
code: `<template><bento-date-range-picker :has-actions="true" /></template>`,
|
|
151
|
-
output: `<template><bento-date-range-picker /></template>`,
|
|
152
|
-
options: [{ action: 'remove', autofix: true }],
|
|
153
|
-
errors: [{ messageId: 'removeProp' }],
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'Invalid: multi-line has-actions on its own line (autofix removes entire line)',
|
|
157
|
-
filename: 'test.vue',
|
|
158
|
-
code: `<template>
|
|
159
|
-
<bento-date-range-picker
|
|
160
|
-
has-actions
|
|
161
|
-
label="Pick"
|
|
162
|
-
/>
|
|
163
|
-
</template>`,
|
|
164
|
-
output: `<template>
|
|
165
|
-
<bento-date-range-picker
|
|
166
|
-
label="Pick"
|
|
167
|
-
/>
|
|
168
|
-
</template>`,
|
|
169
|
-
options: [{ action: 'remove', autofix: true }],
|
|
170
|
-
errors: [{ messageId: 'removeProp' }],
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
]);
|