@adyen/eslint-plugin-bento 1.0.0 → 1.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adyen/eslint-plugin-bento",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Adyen Bento ESLint rules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"lint": "eslint -c ./.eslintrc.js ./ --exit-on-fatal-error",
|
|
17
|
-
"test": "vitest run",
|
|
17
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
18
18
|
"test:coverage": "npm run test -- --coverage",
|
|
19
19
|
"test:watch": "vitest watch"
|
|
20
20
|
},
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"eslint": "^8.57.0",
|
|
28
|
-
"vue-eslint-parser": "^
|
|
28
|
+
"vue-eslint-parser": "^9.3.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"eslint": "^8.0",
|
|
32
|
-
"vue-eslint-parser": "^
|
|
32
|
+
"vue-eslint-parser": "^9.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -34,28 +34,35 @@ module.exports = {
|
|
|
34
34
|
return VueUtils.defineTemplateBodyVisitor(context, {
|
|
35
35
|
VLiteral: node => {
|
|
36
36
|
if (typeof node.value === 'string') {
|
|
37
|
-
let fixed = node.value;
|
|
38
37
|
let hasReplacements = false;
|
|
38
|
+
const classList = node.value;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const fixed = classList
|
|
41
|
+
.split(' ')
|
|
42
|
+
.map(cssClass => {
|
|
43
|
+
// Check if the class list has "padding" or "margin" utilities
|
|
44
|
+
const regexPaddingMargin = /\bu-(padding|margin)\b/g;
|
|
45
|
+
if (regexPaddingMargin.test(cssClass)) {
|
|
46
|
+
// Loop through the list of classes and replace them
|
|
47
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
48
|
+
for (const [oldClass, newClass] of Object.entries(CLASS_MAP)) {
|
|
49
|
+
// Check if the utility can be fixed/re-mapped
|
|
50
|
+
// by checking if the digit has a Bento counterpart
|
|
51
|
+
const regexOldNewMapping = new RegExp(`\\b${oldClass}\\b`, 'g');
|
|
52
|
+
if (regexOldNewMapping.test(cssClass)) {
|
|
53
|
+
hasReplacements = true;
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
// Replace values to Bento
|
|
56
|
+
return cssClass
|
|
57
|
+
.replace(regexOldNewMapping, newClass) // Replace numbers
|
|
58
|
+
.replace(/u-/g, 'b-'); // Replace class to Bento
|
|
59
|
+
}
|
|
60
|
+
}
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
|
|
63
|
+
return cssClass;
|
|
64
|
+
})
|
|
65
|
+
.join(' ');
|
|
59
66
|
|
|
60
67
|
// If replacements were made, report and provide a fix
|
|
61
68
|
if (hasReplacements) {
|