@dineroregnskab/eslint-plugin-custom-rules 3.0.1 → 3.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/.DS_Store CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dineroregnskab/eslint-plugin-custom-rules",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "ESLint plugin with custom rules for Dinero Regnskab",
5
5
  "main": "eslint-plugin-custom-rules.js",
6
6
  "scripts": {
@@ -12,38 +12,29 @@ module.exports = {
12
12
  },
13
13
  create(context) {
14
14
  return {
15
- VariableDeclarator(node) {
16
- // Check if it's an Enum declaration
17
- if (
18
- node.init &&
19
- node.init.type === "ObjectExpression" &&
20
- node.id.type === "Identifier"
21
- ) {
22
- node.init.properties.forEach((prop) => {
23
- if (
24
- prop.key &&
25
- prop.key.type === "Identifier" &&
26
- prop.value &&
27
- prop.value.type === "Literal" &&
28
- typeof prop.value.value === "string"
29
- ) {
30
- const enumKey = prop.key.name;
31
- const enumValue = prop.value.value;
15
+ TSEnumDeclaration(node) {
16
+ node.members.forEach((member) => {
17
+ if (
18
+ member.initializer &&
19
+ member.initializer.type === "Literal" &&
20
+ typeof member.initializer.value === "string"
21
+ ) {
22
+ const enumKey = member.id.name; // The enum key (e.g., "TaxTotal")
23
+ const enumValue = member.initializer.value; // The string value (e.g., "TaxTotal")
32
24
 
33
- // Check if the value is not fully lowercase
34
- if (!/^[a-z]+$/.test(enumValue)) {
35
- context.report({
36
- node: prop.value,
37
- messageId: "enumLowercase",
38
- data: {
39
- enumKey,
40
- suggestedValue: enumValue.toLowerCase(),
41
- },
42
- });
43
- }
25
+ // Check if the value is not fully lowercase
26
+ if (!/^[a-z]+$/.test(enumValue)) {
27
+ context.report({
28
+ node: member.initializer,
29
+ messageId: "enumLowercase",
30
+ data: {
31
+ enumKey,
32
+ suggestedValue: enumValue.toLowerCase(),
33
+ },
34
+ });
44
35
  }
45
- });
46
- }
36
+ }
37
+ });
47
38
  }
48
39
  };
49
40
  }