@adyen/eslint-plugin-bento 1.0.2 → 1.0.3-rc.2
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/LICENSE +21 -0
- package/README.md +1 -1
- package/package.json +35 -33
- package/rules/vue-old-spacer-tokens/__tests__/.eslintrc.js +8 -0
- package/rules/vue-old-spacer-tokens/__tests__/vue-old-spacer-tokens.vue +5 -0
- package/rules/vue-old-spacer-tokens/vue-old-spacer-tokens.integration.test.ts +36 -0
- package/rules/vue-old-spacer-tokens/vue-old-spacer-tokens.test.ts +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Adyen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install --save-dev eslint@8 vue-eslint-parser@7 @adyen/eslint-plugin-bento
|
|
|
11
11
|
<!-- prettier-ignore -->
|
|
12
12
|
> Requirements
|
|
13
13
|
>
|
|
14
|
-
> ESLint v6.0.0 up to v8.0.0
|
|
14
|
+
> ESLint v6.0.0 up to v8.0.0
|
|
15
15
|
> Node.js v12.22.x, v14.17.x, v16.x and above
|
|
16
16
|
> `vue-eslint-parser` v7.0.0
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
2
|
+
"name": "@adyen/eslint-plugin-bento",
|
|
3
|
+
"version": "1.0.3-rc.2",
|
|
4
|
+
"description": "Adyen Bento ESLint rules",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"rules/*",
|
|
9
|
+
"!**/__tests__",
|
|
10
|
+
"!**/*.test.ts"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./index.js"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git@github.com:Adyen/bento.git"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@vitest/coverage-v8": "2.1.4",
|
|
22
|
+
"eslint": "8.57.1",
|
|
23
|
+
"vitest": "2.1.4",
|
|
24
|
+
"vue-eslint-parser": "9.3.2"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"eslint": "^8.0",
|
|
28
|
+
"vue-eslint-parser": "^9.0"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"lint": "eslint -c ./.eslintrc.js ./ --exit-on-fatal-error",
|
|
32
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
33
|
+
"test:coverage": "pnpm run test -- --coverage",
|
|
34
|
+
"test:watch": "vitest watch"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
// ESLint command
|
|
5
|
+
const ESLINT = 'pnpm eslint';
|
|
6
|
+
|
|
7
|
+
describe('@adyen/bento/vue-old-spacer-tokens', () => {
|
|
8
|
+
it('should lint with warning', () => {
|
|
9
|
+
// Load .eslintrc
|
|
10
|
+
const eslintrc = path.resolve(__dirname, '__tests__', '.eslintrc.js');
|
|
11
|
+
// Load the test file
|
|
12
|
+
const vueFile = path.resolve(__dirname, '__tests__', 'vue-old-spacer-tokens.vue');
|
|
13
|
+
|
|
14
|
+
// Execute the linter
|
|
15
|
+
const result = JSON.parse(
|
|
16
|
+
execSync(`${ESLINT} --format=json -c ${eslintrc} ${vueFile}`, {
|
|
17
|
+
encoding: 'utf8',
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Expects a warning with a suggestion/fix and an error message
|
|
22
|
+
expect(result[0].warningCount).toBe(1);
|
|
23
|
+
expect(result[0].messages[0]).toStrictEqual({
|
|
24
|
+
ruleId: '@adyen/bento/vue-old-spacer-tokens',
|
|
25
|
+
severity: 1,
|
|
26
|
+
message: 'Found outdated class names that need replacing',
|
|
27
|
+
messageId: 'updateUtilityClass',
|
|
28
|
+
line: 2,
|
|
29
|
+
column: 16,
|
|
30
|
+
nodeType: 'VLiteral',
|
|
31
|
+
endLine: 2,
|
|
32
|
+
endColumn: 56,
|
|
33
|
+
fix: { range: [26, 66], text: '"b-padding-020 u-display-flex u-row-gap-8"' },
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import spacerTokens from './vue-old-spacer-tokens';
|
|
3
|
+
|
|
4
|
+
const ruleTester = new RuleTester({
|
|
5
|
+
parser: require.resolve('vue-eslint-parser'),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
describe('@adyen/bento/vue-old-spacer-tokens should suggest a Bento alternative to ADL classes', () => {
|
|
9
|
+
ruleTester.run('vue-old-spacer-tokens', spacerTokens, {
|
|
10
|
+
valid: [
|
|
11
|
+
{
|
|
12
|
+
name: 'Valid Bento classes',
|
|
13
|
+
filename: 'test.vue',
|
|
14
|
+
code: `
|
|
15
|
+
<template>
|
|
16
|
+
<div class="b-padding-020 b-padding-040"></div>
|
|
17
|
+
</template>
|
|
18
|
+
`,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'Unmapped ADL classes with Bento classes',
|
|
22
|
+
filename: 'test.vue',
|
|
23
|
+
code: `
|
|
24
|
+
<template>
|
|
25
|
+
<div class="b-padding-100 u-padding-88"></div>
|
|
26
|
+
</template>
|
|
27
|
+
`,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Varied utilities mix without Bento classes',
|
|
31
|
+
filename: 'test.vue',
|
|
32
|
+
code: `
|
|
33
|
+
<template>
|
|
34
|
+
<div class="u-display-flex u-flex-direction-column u-row-gap-j"></div>
|
|
35
|
+
</template>
|
|
36
|
+
`,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
invalid: [
|
|
40
|
+
{
|
|
41
|
+
code: `
|
|
42
|
+
<template>
|
|
43
|
+
<div class="u-padding-4 u-padding-8"></div>
|
|
44
|
+
</template>
|
|
45
|
+
`,
|
|
46
|
+
output: `
|
|
47
|
+
<template>
|
|
48
|
+
<div class="b-padding-020 b-padding-040"></div>
|
|
49
|
+
</template>
|
|
50
|
+
`,
|
|
51
|
+
errors: [{ message: 'Found outdated class names that need replacing' }],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
code: `
|
|
55
|
+
<template>
|
|
56
|
+
<div class="u-display-flex u-flex-direction-column u-row-gap-8 u-margin-top-16"></div>
|
|
57
|
+
</template>
|
|
58
|
+
`,
|
|
59
|
+
output: `
|
|
60
|
+
<template>
|
|
61
|
+
<div class="u-display-flex u-flex-direction-column u-row-gap-8 b-margin-top-070"></div>
|
|
62
|
+
</template>
|
|
63
|
+
`,
|
|
64
|
+
errors: [{ message: 'Found outdated class names that need replacing' }],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
});
|