@adyen/eslint-plugin-bento 1.2.0 → 2.0.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 ADDED
@@ -0,0 +1,79 @@
1
+ # Changelog
2
+
3
+ ## [2.0.0](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.3.0...eslint-plugin-bento-v2.0.0) (2025-05-14)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **eslint:** migrated `@adyen/bento-eslint` to `eslint@9`
9
+
10
+ ### Miscellaneous Chores
11
+
12
+ * **eslint:** migrated `@adyen/bento-eslint` to `eslint@9` ([d8d390e](https://github.com/Adyen/bento/commit/d8d390eed5272a7f1c4e6ed6d9bbb71dc8f4b9a6))
13
+
14
+ ## [1.3.0](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.2.0...eslint-plugin-bento-v1.3.0) (2025-04-16)
15
+
16
+
17
+ ### Features
18
+
19
+ * **eslint:** added javascript type support to ESLint rules package ([0420b72](https://github.com/Adyen/bento/commit/0420b727b491a2ba8179149d5585f8c58a701fc5))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **eslint:** moved `jscodeshift` as dependency to fix issue with dependencies ([fe41f4b](https://github.com/Adyen/bento/commit/fe41f4bc5d91f119ca37a47e29c6651ba35229de))
25
+
26
+
27
+ ### Miscellaneous Chores
28
+
29
+ * added `vue-eslint-parser` as dev dep to Vue2 package to re-enable ESlint on VSCodium ([f6a5aea](https://github.com/Adyen/bento/commit/f6a5aeaf03292ff78f805a8f64653a6db6102f05))
30
+
31
+ ## [1.2.0](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.1.0...eslint-plugin-bento-v1.2.0) (2025-04-09)
32
+
33
+
34
+ ### Features
35
+
36
+ * **eslint:** added new cases to be covered by `currency` & `tag` slot deprecation rules ([b4e86a6](https://github.com/Adyen/bento/commit/b4e86a68cb34c9295248e95eb2002abfaf5d7805))
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **eslint:** corrected export module from `componentSlotMigration` util ([3321662](https://github.com/Adyen/bento/commit/33216626557496d6cad80aeaecdcefb7a0cde122))
42
+
43
+ ## [1.1.0](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.0.3...eslint-plugin-bento-v1.1.0) (2025-04-02)
44
+
45
+
46
+ ### Features
47
+
48
+ * **eslint:** added rule to disable the usage of `default` slot in `bento-currency` ([1914017](https://github.com/Adyen/bento/commit/19140179c47de9eeba6a17b94962646c93815004))
49
+ * **eslint:** added rule to disable the usage of `default` slot in `bento-tag` ([1914017](https://github.com/Adyen/bento/commit/19140179c47de9eeba6a17b94962646c93815004))
50
+
51
+ ## [1.0.3](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.0.2...eslint-plugin-bento-v1.0.3) (2025-03-26)
52
+
53
+
54
+ ### Miscellaneous Chores
55
+
56
+ * fixed all PNPM script parameters ([123269d](https://github.com/Adyen/bento/commit/123269d9cbaa791e0984074845c227c21125e864))
57
+
58
+ ## [1.0.2](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.0.1...eslint-plugin-bento-v1.0.2) (2024-12-04)
59
+
60
+
61
+ ### Miscellaneous Chores
62
+
63
+ * replaced `airbnb-base` with `eslint:recommended` `eslint` rules ([762ebf5](https://github.com/Adyen/bento/commit/762ebf549ca6f0baadb7a6c7b96bebe1084a57ee))
64
+ * updated `vitest` to `2.1.4` ([b615334](https://github.com/Adyen/bento/commit/b6153346e284cc2230119c4b5ca25a2f6786d844))
65
+
66
+ ## [1.0.1](https://github.com/Adyen/bento/compare/eslint-plugin-bento-v1.0.0...eslint-plugin-bento-v1.0.1) (2024-11-13)
67
+
68
+
69
+ ### Bug Fixes
70
+
71
+ * **eslint:** aligned `@adyen/eslint-plugin-bento` deps with main repo ([bf0c98e](https://github.com/Adyen/bento/commit/bf0c98e7144740b6f937cfd296114b09f1039f20))
72
+ * **eslint:** prevented `vue-old-spacer-tokens` from overwriting all classes with `b-` ([74ff227](https://github.com/Adyen/bento/commit/74ff2272371ce85d0a486b88830ed280dfc099bd))
73
+
74
+ ## 1.0.0 (2024-11-06)
75
+
76
+
77
+ ### Features
78
+
79
+ * **eslint:** added ESLint Bento rule set package ([0339bc3](https://github.com/Adyen/bento/commit/0339bc3db17a220d9b252bfe3d8a51e6561bfba8))
package/README.md CHANGED
@@ -5,42 +5,77 @@ The Bento ESLint package helps improving the usage of Bento components and utili
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install --save-dev eslint@8 vue-eslint-parser@7 @adyen/eslint-plugin-bento
8
+ npm install --save-dev eslint@9 vue-eslint-parser@10 @adyen/eslint-plugin-bento@2
9
9
  ```
10
10
 
11
11
  <!-- prettier-ignore -->
12
12
  > Requirements
13
13
  >
14
- > ESLint v6.0.0 up to v8.0.0
15
- > Node.js v12.22.x, v14.17.x, v16.x and above
16
- > `vue-eslint-parser` v7.0.0
14
+ > ESLint v9.0.0
15
+ > Node.js v20.x and above
16
+ > `vue-eslint-parser` v10.0.0
17
17
 
18
18
  ## Usage
19
19
 
20
- The `@adyen/bento` plugin hasn't been tested in ESLint9 nor with the flat config (i.e. `eslint.config.js`).
20
+ ### Flat config recommended (`eslint.config.js`)
21
21
 
22
- ### Legacy Config (`.eslintrc`)
22
+ All rules are set to `warn`
23
23
 
24
24
  ```javascript
25
- module.exports = {
26
- extends: ['plugin:@adyen/bento/recommended'],
27
- rules: {
28
- // override/add rules settings here, such as:
29
- // '@adyen/bento/spacer-tokens': 'error',
25
+ const { defineConfig } = require('eslint/config');
26
+ const parser = require('vue-eslint-parser');
27
+ const bento = require('@adyen/eslint-plugin-bento');
28
+
29
+ module.exports = defineConfig([
30
+ {
31
+ // Other configs
30
32
  },
31
- };
33
+ ...bento.configs['vue-recommended'],
34
+ ]);
32
35
  ```
33
36
 
34
- or without the recommended config:
37
+ ### Flat config strict
38
+
39
+ All rules are set to `err`
40
+
41
+ ```javascript
42
+ const { defineConfig } = require('eslint/config');
43
+ const parser = require('vue-eslint-parser');
44
+ const bento = require('@adyen/eslint-plugin-bento');
45
+
46
+ module.exports = defineConfig([
47
+ {
48
+ // Other configs
49
+ },
50
+ ...bento.configs['vue-strict'],
51
+ ]);
52
+ ```
53
+
54
+ ### Custom
55
+
56
+ Without the recommended configs:
35
57
 
36
58
  ```javascript
37
- module.exports = {
38
- parser: 'vue-eslint-parser',
39
- plugins: ['@adyen/bento'],
40
- rules: {
41
- '@adyen/bento/vue-old-spacer-tokens': 'warn',
59
+ const { defineConfig } = require('eslint/config');
60
+ const vueParser = require('vue-eslint-parser');
61
+ const bento = require('@adyen/eslint-plugin-bento');
62
+
63
+ module.exports = defineConfig([
64
+ {
65
+ languageOptions: {
66
+ parser: vueParser,
67
+ },
68
+ plugins: {
69
+ '@adyen/bento': bento,
70
+ },
71
+ rules: {
72
+ '@adyen/bento/vue-old-spacer-tokens': 'warn',
73
+ '@adyen/bento/deprecation-currency-default-slot': 'warn'
74
+ '@adyen/bento/deprecation-tag-default-slot': 'warn'
75
+ },
76
+ files: ['**/*.vue'],
42
77
  },
43
- };
78
+ ]);
44
79
  ```
45
80
 
46
81
  ## Rules
@@ -53,7 +88,7 @@ Disallow the use of ADL space utility classes in favor of Bento _spacer_ utility
53
88
 
54
89
  The recommended configuration contains pre-configured rules and their severity
55
90
 
56
- - `@adyen/bento/vue-old-spacer-tokens`: `warn`
91
+ - `@adyen/bento/vue-old-spacer-tokens`: `warn`
57
92
 
58
93
  ### `@adyen/bento/deprecation-currency-default-slot`
59
94
 
@@ -63,7 +98,7 @@ Disallow the use of the `default` slot in `bento-currency` instances
63
98
 
64
99
  The recommended configuration contains pre-configured rules and their severity
65
100
 
66
- - `@adyen/bento/deprecation-currency-default-slot`: `warn`
101
+ - `@adyen/bento/deprecation-currency-default-slot`: `warn`
67
102
 
68
103
  ### `@adyen/bento/deprecation-tag-default-slot`
69
104
 
@@ -73,4 +108,4 @@ Disallow the use of the `default` slot in `bento-tag` instances
73
108
 
74
109
  The recommended configuration contains pre-configured rules and their severity
75
110
 
76
- - `@adyen/bento/deprecation-tag-default-slot`: `warn`
111
+ - `@adyen/bento/deprecation-tag-default-slot`: `warn`
@@ -0,0 +1,19 @@
1
+ module.exports = [
2
+ {
3
+ name: '@bento/adyen/recommended',
4
+ files: ['*.vue', '**/*.vue'],
5
+ languageOptions: {
6
+ parser: require('vue-eslint-parser'),
7
+ },
8
+ plugins: {
9
+ get '@adyen/bento'() {
10
+ return require('../index');
11
+ },
12
+ },
13
+ rules: {
14
+ '@adyen/bento/deprecation-currency-default-slot': 'warn',
15
+ '@adyen/bento/deprecation-tag-default-slot': 'warn',
16
+ '@adyen/bento/vue-old-spacer-tokens': 'warn',
17
+ },
18
+ },
19
+ ];
@@ -0,0 +1,19 @@
1
+ module.exports = [
2
+ {
3
+ name: '@bento/adyen/strict',
4
+ files: ['*.vue', '**/*.vue'],
5
+ languageOptions: {
6
+ parser: require('vue-eslint-parser'),
7
+ },
8
+ plugins: {
9
+ get '@adyen/bento'() {
10
+ return require('../index');
11
+ },
12
+ },
13
+ rules: {
14
+ '@adyen/bento/deprecation-currency-default-slot': 'error',
15
+ '@adyen/bento/deprecation-tag-default-slot': 'error',
16
+ '@adyen/bento/vue-old-spacer-tokens': 'error',
17
+ },
18
+ },
19
+ ];
package/index.js CHANGED
@@ -1,30 +1,20 @@
1
- const fs = require('fs');
2
- const deprecationCurrencyDefaultSlot = require('./rules/deprecation-currency-default-slot/deprecation-currency-default-slot');
3
- const deprecationTagDefaultSlot = require('./rules/deprecation-tag-default-slot/deprecation-tag-default-slot');
4
- const spacerTokens = require('./rules/vue-old-spacer-tokens/vue-old-spacer-tokens');
5
-
6
1
  // The package name and version must be in sync with 'package.json'
7
- const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
2
+ const pkg = require('./package.json');
8
3
 
9
- module.exports = {
4
+ const plugin = {
10
5
  meta: {
11
6
  name: pkg.name,
12
7
  version: pkg.version,
13
8
  },
14
9
  configs: {
15
- recommended: {
16
- parser: 'vue-eslint-parser',
17
- plugins: ['@adyen/bento'],
18
- rules: {
19
- '@adyen/bento/deprecation-currency-default-slot': 'warn',
20
- '@adyen/bento/deprecation-tag-default-slot': 'warn',
21
- '@adyen/bento/vue-old-spacer-tokens': 'warn',
22
- },
23
- },
10
+ 'vue-recommended': require('./configs/vue-recommended'),
11
+ 'vue-strict': require('./configs/vue-strict'),
24
12
  },
25
13
  rules: {
26
- 'deprecation-currency-default-slot': deprecationCurrencyDefaultSlot,
27
- 'deprecation-tag-default-slot': deprecationTagDefaultSlot,
28
- 'vue-old-spacer-tokens': spacerTokens,
14
+ 'deprecation-currency-default-slot': require('./rules/deprecation-currency-default-slot/deprecation-currency-default-slot'),
15
+ 'deprecation-tag-default-slot': require('./rules/deprecation-tag-default-slot/deprecation-tag-default-slot'),
16
+ 'vue-old-spacer-tokens': require('./rules/vue-old-spacer-tokens/vue-old-spacer-tokens'),
29
17
  },
30
18
  };
19
+
20
+ module.exports = plugin;
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@adyen/eslint-plugin-bento",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "Adyen Bento ESLint rules",
5
5
  "main": "index.js",
6
6
  "files": [
7
+ "README.md",
8
+ "CHANGELOG.md",
9
+ "configs",
7
10
  "index.js",
8
11
  "rules/*",
9
12
  "utils/*",
@@ -18,19 +21,30 @@
18
21
  "url": "git@github.com:Adyen/bento.git"
19
22
  },
20
23
  "license": "MIT",
24
+ "dependencies": {
25
+ "jscodeshift": "17.1.2"
26
+ },
21
27
  "devDependencies": {
28
+ "@eslint/js": "9.24.0",
29
+ "@types/eslint": "9.6.1",
30
+ "@types/estree": "1.0.6",
31
+ "@types/node": "20.17.24",
32
+ "@typescript-eslint/eslint-plugin": "8.26.0",
33
+ "@typescript-eslint/parser": "8.26.0",
34
+ "@vitest/eslint-plugin": "1.1.25",
22
35
  "@vitest/coverage-v8": "2.1.9",
23
- "eslint": "8.57.1",
24
- "jscodeshift": "17.1.2",
36
+ "eslint": "9.24.0",
37
+ "eslint-plugin-vue": "10.0.0",
38
+ "globals": "16.0.0",
25
39
  "vitest": "2.1.9",
26
- "vue-eslint-parser": "9.3.2"
40
+ "vue-eslint-parser": "10.1.3"
27
41
  },
28
42
  "peerDependencies": {
29
- "eslint": "^8.0",
43
+ "eslint": "^9.0",
30
44
  "vue-eslint-parser": "^9.0"
31
45
  },
32
46
  "scripts": {
33
- "lint": "eslint -c ./.eslintrc.js ./ --exit-on-fatal-error",
47
+ "lint": "eslint -c ./eslint.config.js ./ --exit-on-fatal-error",
34
48
  "test": "vitest run --config ./vitest.config.ts",
35
49
  "test:coverage": "pnpm run test --coverage",
36
50
  "test:watch": "vitest watch"
@@ -0,0 +1,18 @@
1
+ const { defineConfig } = require('eslint/config');
2
+ const parser = require('vue-eslint-parser');
3
+ const adyenBento = require('@adyen/eslint-plugin-bento');
4
+
5
+ module.exports = defineConfig([
6
+ {
7
+ languageOptions: {
8
+ parser: parser,
9
+ },
10
+ plugins: {
11
+ '@adyen/bento': adyenBento,
12
+ },
13
+ rules: {
14
+ '@adyen/bento/deprecation-currency-default-slot': 'warn',
15
+ },
16
+ files: ['**/*.vue'],
17
+ },
18
+ ]);
@@ -7,7 +7,7 @@ const ESLINT = 'pnpm eslint';
7
7
  describe('@adyen/bento/deprecation-currency-default-slot', () => {
8
8
  it('should lint with warning', () => {
9
9
  // Load .eslintrc
10
- const eslintrc = path.resolve(__dirname, '__tests__', '.eslintrc.js');
10
+ const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
11
11
  // Load the test file
12
12
  const vueFile = path.resolve(__dirname, '__tests__', 'deprecation-currency-default-slot.vue');
13
13
 
@@ -1,6 +1,15 @@
1
+ /**
2
+ * @typedef {import('eslint').Rule.RuleContext} RuleContext
3
+ */
4
+
5
+ /**
6
+ * @typedef {import('eslint-plugin-vue/lib/utils').RuleModule} RuleModule
7
+ */
8
+
1
9
  const VueUtils = require('eslint-plugin-vue/lib/utils');
2
10
  const { componentSlotMigration } = require('../../utils/component-slot-migration');
3
11
 
12
+ /** @type {RuleModule} */
4
13
  module.exports = {
5
14
  meta: {
6
15
  type: 'suggestion',
@@ -16,8 +25,11 @@ module.exports = {
16
25
  fixable: 'code',
17
26
  schema: [], // No options are needed for this rule
18
27
  },
28
+
29
+ /** @param {RuleContext} context */
19
30
  create(context) {
20
- const sourceCode = context.getSourceCode();
31
+ const sourceCode = context.sourceCode;
32
+
21
33
  const template =
22
34
  sourceCode.parserServices.getTemplateBodyTokenStore &&
23
35
  sourceCode.parserServices.getTemplateBodyTokenStore();
@@ -1,8 +1,11 @@
1
1
  import { RuleTester } from 'eslint';
2
+ import vueParser from 'vue-eslint-parser';
2
3
  import deprecationCurrencyDefaultSlot from './deprecation-currency-default-slot';
3
4
 
4
5
  const ruleTester = new RuleTester({
5
- parser: require.resolve('vue-eslint-parser'),
6
+ languageOptions: {
7
+ parser: vueParser,
8
+ },
6
9
  });
7
10
 
8
11
  describe('@adyen/bento/deprecation-currency-default-slot should suggest the usage of "label" property instead of "default" slot', () => {
@@ -0,0 +1,18 @@
1
+ const { defineConfig } = require('eslint/config');
2
+ const parser = require('vue-eslint-parser');
3
+ const adyenBento = require('@adyen/eslint-plugin-bento');
4
+
5
+ module.exports = defineConfig([
6
+ {
7
+ languageOptions: {
8
+ parser: parser,
9
+ },
10
+ plugins: {
11
+ '@adyen/bento': adyenBento,
12
+ },
13
+ rules: {
14
+ '@adyen/bento/deprecation-tag-default-slot': 'warn',
15
+ },
16
+ files: ['**/*.vue'],
17
+ },
18
+ ]);
@@ -7,7 +7,7 @@ const ESLINT = 'pnpm eslint';
7
7
  describe('@adyen/bento/deprecation-tag-default-slot', () => {
8
8
  it('should lint with warning', () => {
9
9
  // Load .eslintrc
10
- const eslintrc = path.resolve(__dirname, '__tests__', '.eslintrc.js');
10
+ const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
11
11
  // Load the test file
12
12
  const vueFile = path.resolve(__dirname, '__tests__', 'deprecation-tag-default-slot.vue');
13
13
 
@@ -1,6 +1,15 @@
1
+ /**
2
+ * @typedef {import('eslint').Rule.RuleContext} RuleContext
3
+ */
4
+
5
+ /**
6
+ * @typedef {import('eslint-plugin-vue/lib/utils').RuleModule} RuleModule
7
+ */
8
+
1
9
  const VueUtils = require('eslint-plugin-vue/lib/utils');
2
10
  const { componentSlotMigration } = require('../../utils/component-slot-migration');
3
11
 
12
+ /** @type {RuleModule} */
4
13
  module.exports = {
5
14
  meta: {
6
15
  type: 'suggestion',
@@ -16,8 +25,10 @@ module.exports = {
16
25
  fixable: 'code',
17
26
  schema: [], // No options are needed for this rule
18
27
  },
28
+
29
+ /** @param {RuleContext} context */
19
30
  create(context) {
20
- const sourceCode = context.getSourceCode();
31
+ const sourceCode = context.sourceCode;
21
32
  const template =
22
33
  sourceCode.parserServices.getTemplateBodyTokenStore &&
23
34
  sourceCode.parserServices.getTemplateBodyTokenStore();
@@ -1,8 +1,11 @@
1
1
  import { RuleTester } from 'eslint';
2
+ import vueParser from 'vue-eslint-parser';
2
3
  import deprecationTagDefaultSlot from './deprecation-tag-default-slot';
3
4
 
4
5
  const ruleTester = new RuleTester({
5
- parser: require.resolve('vue-eslint-parser'),
6
+ languageOptions: {
7
+ parser: vueParser,
8
+ },
6
9
  });
7
10
 
8
11
  describe('@adyen/bento/deprecation-tag-default-slot should suggest the usage of "label" property instead of "default" slot', () => {
@@ -0,0 +1,18 @@
1
+ const { defineConfig } = require('eslint/config');
2
+ const parser = require('vue-eslint-parser');
3
+ const adyenBento = require('@adyen/eslint-plugin-bento');
4
+
5
+ module.exports = defineConfig([
6
+ {
7
+ languageOptions: {
8
+ parser: parser,
9
+ },
10
+ plugins: {
11
+ '@adyen/bento': adyenBento,
12
+ },
13
+ rules: {
14
+ '@adyen/bento/vue-old-spacer-tokens': 'warn',
15
+ },
16
+ files: ['**/*.vue'],
17
+ },
18
+ ]);
@@ -6,8 +6,8 @@ const ESLINT = 'pnpm eslint';
6
6
 
7
7
  describe('@adyen/bento/vue-old-spacer-tokens', () => {
8
8
  it('should lint with warning', () => {
9
- // Load .eslintrc
10
- const eslintrc = path.resolve(__dirname, '__tests__', '.eslintrc.js');
9
+ // Load eslint.config
10
+ const eslintrc = path.resolve(__dirname, '__tests__', 'eslint.config.js');
11
11
  // Load the test file
12
12
  const vueFile = path.resolve(__dirname, '__tests__', 'vue-old-spacer-tokens.vue');
13
13
 
@@ -1,3 +1,16 @@
1
+ /**
2
+ * @typedef {import('eslint').Rule.RuleContext} RuleContext
3
+ */
4
+ /**
5
+ * @typedef {import('estree').Node} Node
6
+ */
7
+ /**
8
+ * @typedef {import('vue-eslint-parser').AST.VLiteral} VLiteral
9
+ */
10
+ /**
11
+ * @typedef {import('eslint-plugin-vue/lib/utils').RuleModule} RuleModule
12
+ */
13
+
1
14
  const VueUtils = require('eslint-plugin-vue/lib/utils');
2
15
 
3
16
  // Mappings for the classes that can to be replaced
@@ -15,6 +28,7 @@ const CLASS_MAP = {
15
28
  '64': '140',
16
29
  };
17
30
 
31
+ /** @type {RuleModule} */
18
32
  module.exports = {
19
33
  meta: {
20
34
  type: 'suggestion', // The type can be "problem", "suggestion", or "layout"
@@ -30,21 +44,21 @@ module.exports = {
30
44
  fixable: 'code',
31
45
  schema: [], // No options are needed for this rule
32
46
  },
47
+ /** @param {RuleContext} context */
33
48
  create(context) {
34
49
  return VueUtils.defineTemplateBodyVisitor(context, {
35
- VLiteral: node => {
50
+ VLiteral: (/** @type {any} */ node) => {
36
51
  if (typeof node.value === 'string') {
37
52
  let hasReplacements = false;
38
- const classList = node.value;
53
+ const classList = /** @type {VLiteral['value']} */ node.value;
39
54
 
40
55
  const fixed = classList
41
56
  .split(' ')
42
- .map(cssClass => {
57
+ .map((/** @type {VLiteral['value']} */ cssClass) => {
43
58
  // Check if the class list has "padding" or "margin" utilities
44
59
  const regexPaddingMargin = /\bu-(padding|margin)\b/g;
45
60
  if (regexPaddingMargin.test(cssClass)) {
46
61
  // Loop through the list of classes and replace them
47
- // eslint-disable-next-line no-restricted-syntax
48
62
  for (const [oldClass, newClass] of Object.entries(CLASS_MAP)) {
49
63
  // Check if the utility can be fixed/re-mapped
50
64
  // by checking if the digit has a Bento counterpart
@@ -1,8 +1,11 @@
1
1
  import { RuleTester } from 'eslint';
2
+ import vueParser from 'vue-eslint-parser';
2
3
  import spacerTokens from './vue-old-spacer-tokens';
3
4
 
4
5
  const ruleTester = new RuleTester({
5
- parser: require.resolve('vue-eslint-parser'),
6
+ languageOptions: {
7
+ parser: vueParser,
8
+ },
6
9
  });
7
10
 
8
11
  describe('@adyen/bento/vue-old-spacer-tokens should suggest a Bento alternative to ADL classes', () => {
@@ -1,12 +1,28 @@
1
1
  const j = require('jscodeshift');
2
2
 
3
+ /**
4
+ * @typedef {import('eslint').Rule.RuleContext} RuleContext
5
+ * @typedef {import('eslint').AST.Token} Token
6
+ */
7
+
8
+ /**
9
+ * @typedef {import('vue-eslint-parser').AST.VText} VText
10
+ * @typedef {import('vue-eslint-parser').AST.VExpressionContainer} VExpressionContainer
11
+ */
12
+
13
+ /**
14
+ * @typedef { { propertyName: string, context: RuleContext, template: any, alwaysExpression?: boolean } } ComponentSlotMigrationProps
15
+ * @typedef { (node: any) => void } ComponentSlotMigrationReturn
16
+ */
17
+
3
18
  module.exports = {
4
19
  /**
5
20
  * Generates a report with a fix to those VElements containing a deprecated default slot.
6
21
  *
7
22
  * It moves the content of the "default" slot into a prop with the "propertyName" value.
8
23
  *
9
- * @param props Contains the name of the property by which it will be replace and the context
24
+ * @param {ComponentSlotMigrationProps} props Contains the name of the property by which it will be replace and the context
25
+ * @returns {ComponentSlotMigrationReturn}
10
26
  */
11
27
  componentSlotMigration({ propertyName, context, template, alwaysExpression = false }) {
12
28
  return node => {
@@ -17,6 +33,11 @@ module.exports = {
17
33
  // Turned true if one of the children is an expression
18
34
  let hasExpression = false;
19
35
 
36
+ /**
37
+ * @param {VText | VExpressionContainer } node
38
+ * @param {boolean} wrapStringLiteral
39
+ * @returns {string | undefined}
40
+ */
20
41
  function transformNodeToText(node, wrapStringLiteral = false) {
21
42
  if (node.type === 'VText') {
22
43
  return node.value;
@@ -31,6 +52,10 @@ module.exports = {
31
52
  }
32
53
  }
33
54
 
55
+ /**
56
+ * @param { VText | VExpressionContainer } node
57
+ * @returns {boolean}
58
+ */
34
59
  function removeEmptyVTextNodes(node) {
35
60
  if (node.type === 'VText') {
36
61
  return !!node.value.trim().length;
@@ -40,9 +65,11 @@ module.exports = {
40
65
  }
41
66
 
42
67
  // Opening tag closing brace ">"
68
+ /** @type {Token} */
43
69
  const closingBrace = template.getLastToken(node.startTag);
44
70
 
45
71
  // Remove empty nodes
72
+ /** @type { Array<VText | VExpressionContainer> } */
46
73
  const filteredNodes = node.children.filter(removeEmptyVTextNodes);
47
74
 
48
75
  // Get all content and concat
@@ -52,7 +79,7 @@ module.exports = {
52
79
  }
53
80
 
54
81
  const content = node.children
55
- .map(node => transformNodeToText(node, true))
82
+ .map((/** @type {VText | VExpressionContainer} */ node) => transformNodeToText(node, true))
56
83
  .join('')
57
84
  .trim();
58
85
 
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- env: { es2021: true },
3
- parser: 'vue-eslint-parser',
4
- plugins: ['@adyen/bento'],
5
- rules: {
6
- '@adyen/bento/deprecation-currency-default-slot': 'warn',
7
- },
8
- };
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- env: { es2021: true },
3
- parser: 'vue-eslint-parser',
4
- plugins: ['@adyen/bento'],
5
- rules: {
6
- '@adyen/bento/deprecation-tag-default-slot': 'warn',
7
- },
8
- };
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- env: { es2021: true },
3
- parser: 'vue-eslint-parser',
4
- plugins: ['@adyen/bento'],
5
- rules: {
6
- '@adyen/bento/vue-old-spacer-tokens': 'warn',
7
- },
8
- };