@dineroregnskab/eslint-plugin-custom-rules 2.0.1 → 2.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/README.md +2 -0
- package/package.json +5 -2
- package/rules/camel-case-attributes.js +19 -25
package/README.md
CHANGED
|
@@ -57,6 +57,8 @@ npm i
|
|
|
57
57
|
#
|
|
58
58
|
See [ESLint custom rule tutorial](https://eslint.org/docs/latest/extend/custom-rule-tutorial) for more.
|
|
59
59
|
|
|
60
|
+
Useful tool for working with AST tree: [AST Explorer](https://astexplorer.net/)
|
|
61
|
+
|
|
60
62
|
## License
|
|
61
63
|
|
|
62
64
|
[MIT](https://choosealicense.com/licenses/mit/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dineroregnskab/eslint-plugin-custom-rules",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "ESLint plugin with custom rules for Dineroregnskab",
|
|
5
5
|
"main": "eslint-plugin-custom-rules.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,5 +18,8 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"**/*",
|
|
20
20
|
"!example/**/*"
|
|
21
|
-
]
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@angular-eslint/template-parser": "^17.1.0"
|
|
24
|
+
}
|
|
22
25
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
meta: {
|
|
3
|
-
type: '
|
|
3
|
+
type: 'suggestion',
|
|
4
4
|
docs: {
|
|
5
5
|
description: 'Enforce camel case for data-cy and id attributes',
|
|
6
6
|
},
|
|
@@ -10,30 +10,24 @@ module.exports = {
|
|
|
10
10
|
|
|
11
11
|
create(context) {
|
|
12
12
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return g[1].toUpperCase();
|
|
20
|
-
},
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (value !== camelCasedValue) {
|
|
24
|
-
context.report({
|
|
25
|
-
node,
|
|
26
|
-
message:
|
|
27
|
-
'The value of data-cy and id attributes must be in camelCase.',
|
|
28
|
-
fix(fixer) {
|
|
29
|
-
return fixer.replaceText(
|
|
30
|
-
node.value,
|
|
31
|
-
`"${camelCasedValue}"`,
|
|
32
|
-
);
|
|
13
|
+
TextAttribute(node) {
|
|
14
|
+
if ((node.name === 'data-cy' || node.name === 'id') && node.value) {
|
|
15
|
+
const camelCasedValue = node.value.replace(
|
|
16
|
+
/-([a-z])/g,
|
|
17
|
+
function (g) {
|
|
18
|
+
return g[1].toUpperCase();
|
|
33
19
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (node.value !== camelCasedValue) {
|
|
23
|
+
context.report({
|
|
24
|
+
node,
|
|
25
|
+
message:
|
|
26
|
+
'The value of data-cy and id attributes should be in camelCase.',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
38
32
|
},
|
|
39
33
|
};
|