npm-groovy-lint 14.5.0 → 14.6.1-beta202408252114.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.
Files changed (83) hide show
  1. package/lib/codenarc-caller.js +54 -53
  2. package/lib/codenarc-factory.js +41 -50
  3. package/lib/config.js +22 -19
  4. package/lib/filter.js +8 -15
  5. package/lib/groovy-lint-fix.js +32 -34
  6. package/lib/groovy-lint-rules.js +12 -12
  7. package/lib/groovy-lint.js +40 -41
  8. package/lib/index.js +3 -3
  9. package/lib/java/CodeNarcServer.jar +0 -0
  10. package/lib/options.js +45 -54
  11. package/lib/output.js +23 -23
  12. package/lib/rules/AssignmentInConditional.js +7 -7
  13. package/lib/rules/BlankLineBeforePackage.js +11 -11
  14. package/lib/rules/BlockEndsWithBlankLine.js +6 -6
  15. package/lib/rules/BlockStartsWithBlankLine.js +6 -6
  16. package/lib/rules/BracesForClass.js +8 -8
  17. package/lib/rules/BracesForForLoop.js +9 -9
  18. package/lib/rules/BracesForIfElse.js +9 -9
  19. package/lib/rules/BracesForMethod.js +11 -11
  20. package/lib/rules/BracesForTryCatchFinally.js +7 -7
  21. package/lib/rules/CatchException.js +4 -4
  22. package/lib/rules/ClassEndsWithBlankLine.js +6 -6
  23. package/lib/rules/ClassStartsWithBlankLine.js +6 -6
  24. package/lib/rules/ClosingBraceNotAlone.js +8 -8
  25. package/lib/rules/ConsecutiveBlankLines.js +7 -7
  26. package/lib/rules/DuplicateImport.js +6 -6
  27. package/lib/rules/DuplicateNumberLiteral.js +6 -6
  28. package/lib/rules/DuplicateStringLiteral.js +6 -6
  29. package/lib/rules/ElseBlockBraces.js +10 -10
  30. package/lib/rules/ExplicitArrayListInstantiation.js +7 -7
  31. package/lib/rules/ExplicitLinkedListInstantiation.js +7 -7
  32. package/lib/rules/FileEndsWithoutNewline.js +7 -7
  33. package/lib/rules/GStringExpressionWithinString.js +7 -7
  34. package/lib/rules/IfStatementBraces.js +10 -10
  35. package/lib/rules/Indentation.js +14 -14
  36. package/lib/rules/IndentationClosingBraces.js +8 -8
  37. package/lib/rules/IndentationComments.js +6 -6
  38. package/lib/rules/InsecureRandom.js +14 -14
  39. package/lib/rules/JavaIoPackageAccess.js +6 -6
  40. package/lib/rules/MethodCount.js +6 -6
  41. package/lib/rules/MethodParameterTypeRequired.js +6 -6
  42. package/lib/rules/MethodReturnTypeRequired.js +6 -6
  43. package/lib/rules/MisorderedStaticImports.js +14 -14
  44. package/lib/rules/MissingBlankLineAfterImports.js +6 -6
  45. package/lib/rules/MissingBlankLineAfterPackage.js +6 -6
  46. package/lib/rules/NoDef.js +4 -4
  47. package/lib/rules/NoJavaUtilDate.js +4 -4
  48. package/lib/rules/NoTabCharacter.js +7 -7
  49. package/lib/rules/SimpleDateFormatMissingLocale.js +4 -4
  50. package/lib/rules/SpaceAfterCatch.js +7 -7
  51. package/lib/rules/SpaceAfterComma.js +9 -9
  52. package/lib/rules/SpaceAfterFor.js +8 -8
  53. package/lib/rules/SpaceAfterIf.js +10 -10
  54. package/lib/rules/SpaceAfterMethodCallName.js +7 -7
  55. package/lib/rules/SpaceAfterOpeningBrace.js +9 -9
  56. package/lib/rules/SpaceAfterSemicolon.js +8 -8
  57. package/lib/rules/SpaceAfterSwitch.js +8 -8
  58. package/lib/rules/SpaceAfterWhile.js +7 -7
  59. package/lib/rules/SpaceAroundOperator.js +14 -14
  60. package/lib/rules/SpaceBeforeClosingBrace.js +8 -8
  61. package/lib/rules/SpaceBeforeOpeningBrace.js +9 -9
  62. package/lib/rules/SpaceInsideParentheses.js +17 -17
  63. package/lib/rules/SystemExit.js +4 -4
  64. package/lib/rules/TrailingWhitespace.js +8 -8
  65. package/lib/rules/UnnecessaryDefInFieldDeclaration.js +8 -8
  66. package/lib/rules/UnnecessaryDefInMethodDeclaration.js +7 -7
  67. package/lib/rules/UnnecessaryDefInVariableDeclaration.js +9 -9
  68. package/lib/rules/UnnecessaryDotClass.js +7 -7
  69. package/lib/rules/UnnecessaryFinalOnPrivateMethod.js +7 -7
  70. package/lib/rules/UnnecessaryGString.js +14 -14
  71. package/lib/rules/UnnecessaryGroovyImport.js +6 -6
  72. package/lib/rules/UnnecessaryPackageReference.js +9 -9
  73. package/lib/rules/UnnecessaryParenthesesForMethodCallWithClosure.js +9 -9
  74. package/lib/rules/UnnecessaryPublicModifier.js +4 -4
  75. package/lib/rules/UnnecessarySemicolon.js +10 -13
  76. package/lib/rules/UnnecessaryToString.js +8 -8
  77. package/lib/rules/UnusedImport.js +10 -10
  78. package/lib/rules/UnusedMethodParameter.js +6 -6
  79. package/lib/rules/UnusedVariable.js +6 -6
  80. package/lib/rules/VariableName.js +11 -11
  81. package/lib/rules/VariableTypeRequired.js +11 -11
  82. package/lib/utils.js +62 -43
  83. package/package.json +23 -20
@@ -3,7 +3,7 @@
3
3
  // nvuillam: Fix not always working, especially when embedded missing If statements ...
4
4
  // let's let people correct that manually for now :)
5
5
 
6
- const { getOutOfBracesStrings, getStringRange, getVariable, isValidCodeLine } = require("../utils");
6
+ import { getOutOfBracesStrings, getStringRange, getVariable, isValidCodeLine } from "../utils.js";
7
7
 
8
8
  const rule = {
9
9
  scope: "file",
@@ -14,7 +14,7 @@ const rule = {
14
14
  type: "function",
15
15
  func: (errLine, errItem) => {
16
16
  return getStringRange(errLine, "if", errItem);
17
- }
17
+ },
18
18
  },
19
19
  fix: {
20
20
  label: "Add if statement braces",
@@ -62,7 +62,7 @@ const rule = {
62
62
  pos++;
63
63
  }
64
64
  return allLines;
65
- }
65
+ },
66
66
  },
67
67
  tests: [
68
68
  {
@@ -75,7 +75,7 @@ if (a == 1) {
75
75
  whatever()
76
76
  }
77
77
  `,
78
- codeNarcCallsNumber: 2
78
+ codeNarcCallsNumber: 2,
79
79
  },
80
80
  {
81
81
  sourceBefore: `
@@ -91,7 +91,7 @@ if (new File(sfdxWorkingDir + '/.sfdx').exists() && this.promptForReloadMetadata
91
91
  else
92
92
  doRetrieve = true
93
93
  `,
94
- codeNarcCallsNumber: 2
94
+ codeNarcCallsNumber: 2,
95
95
  },
96
96
  {
97
97
  sourceBefore: `
@@ -150,7 +150,7 @@ if (allowCreation==true) {
150
150
  }
151
151
  }
152
152
  `,
153
- codeNarcCallsNumber: 2
153
+ codeNarcCallsNumber: 2,
154
154
  },
155
155
  {
156
156
  sourceBefore: `
@@ -159,9 +159,9 @@ if (a == 1 && ( x === 2) && something()) whatever()
159
159
  sourceAfter: `
160
160
  if (a == 1 && ( x === 2) && something()) whatever()
161
161
  `,
162
- codeNarcCallsNumber: 1
163
- }
164
- ]
162
+ codeNarcCallsNumber: 1,
163
+ },
164
+ ],
165
165
  };
166
166
 
167
- module.exports = { rule };
167
+ export { rule };
@@ -1,7 +1,7 @@
1
1
  // Indentation
2
2
  // Warning CodeNarc does not like tabs, better replace them by spaces ...
3
3
 
4
- const { getVariable } = require("../utils");
4
+ import { getVariable } from "../utils.js";
5
5
 
6
6
  const rule = {
7
7
  triggers: ["IndentationClosingBraces", "IndentationComments"],
@@ -11,35 +11,35 @@ const rule = {
11
11
  name: "EXPECTED",
12
12
  regex: /The (.*) is at the incorrect indent level: Expected column (.*) but was (.*)/,
13
13
  regexPos: 2,
14
- type: "number"
14
+ type: "number",
15
15
  },
16
16
  {
17
17
  name: "EXPECTED_LIST",
18
18
  regex: /The (.*) is at the incorrect indent level: Expected one of columns (.*) but was (.*)/,
19
19
  regexPos: 2,
20
- type: "array"
20
+ type: "array",
21
21
  },
22
22
  {
23
23
  name: "EXPECTED_LIST_CHAINING",
24
24
  regex: /The (.*) is at the incorrect indent level: Depending on your chaining style, expected one of (.*) or one of (.*) columns, but was (.*)/,
25
25
  regexPos: 2,
26
- type: "array"
26
+ type: "array",
27
27
  },
28
28
  {
29
29
  name: "FOUND",
30
30
  regex: /The (.*) is at the incorrect indent level: Expected column (.*) but was (.*)/,
31
31
  regexPos: 3,
32
- type: "number"
33
- }
32
+ type: "number",
33
+ },
34
34
  ],
35
35
  range: {
36
36
  type: "function",
37
37
  func: (errLine, errItem, evaluatedVars) => {
38
38
  return {
39
39
  start: { line: errItem.line, character: 0 },
40
- end: { line: errItem.line, character: getVariable(evaluatedVars, "FOUND") - 1 }
40
+ end: { line: errItem.line, character: getVariable(evaluatedVars, "FOUND") - 1 },
41
41
  };
42
- }
42
+ },
43
43
  },
44
44
  fix: {
45
45
  label: "Correct Indentation",
@@ -55,7 +55,7 @@ const rule = {
55
55
  const startSpaces = expected === 0 ? 0 : expected - 1;
56
56
  line = " ".repeat(startSpaces) + line.trimStart();
57
57
  return line;
58
- }
58
+ },
59
59
  },
60
60
  tests: [
61
61
  {
@@ -66,7 +66,7 @@ x = 1
66
66
  sourceAfter: `
67
67
  if (a == 2){
68
68
  x = 1
69
- }`
69
+ }`,
70
70
  },
71
71
  {
72
72
  sourceBefore: `
@@ -104,9 +104,9 @@ docker.withRegistry("https://"+ envVars.GetDockerRegistry(), envVars.GetDockerRe
104
104
  }
105
105
  }
106
106
  }
107
- `
108
- }
109
- ]
107
+ `,
108
+ },
109
+ ],
110
110
  };
111
111
 
112
- module.exports = { rule };
112
+ export { rule };
@@ -1,4 +1,4 @@
1
- const { containsExceptInsideString } = require("../utils");
1
+ import { containsExceptInsideString } from "../utils.js";
2
2
 
3
3
  // Indentation closing braces
4
4
  const rule = {
@@ -7,7 +7,7 @@ const rule = {
7
7
  fix: {
8
8
  label: "Fix indentation closing braces",
9
9
  type: "function",
10
- func: allLines => {
10
+ func: (allLines) => {
11
11
  const newFileLines = [];
12
12
  for (let i = 0; i < allLines.length; i++) {
13
13
  let line = allLines[i] + "";
@@ -41,7 +41,7 @@ const rule = {
41
41
  newFileLines.push(line);
42
42
  }
43
43
  return newFileLines;
44
- }
44
+ },
45
45
  },
46
46
  tests: [
47
47
  {
@@ -58,7 +58,7 @@ try {
58
58
  } catch {
59
59
  whateverelse()
60
60
  }
61
- `
61
+ `,
62
62
  },
63
63
  {
64
64
  sourceBefore: `
@@ -97,9 +97,9 @@ docker.withRegistry("https://"+ envVars.GetDockerRegistry(), envVars.GetDockerRe
97
97
  }
98
98
  }
99
99
  }
100
- `
101
- }
102
- ]
100
+ `,
101
+ },
102
+ ],
103
103
  };
104
104
 
105
- module.exports = { rule };
105
+ export { rule };
@@ -6,7 +6,7 @@ const rule = {
6
6
  fix: {
7
7
  label: "Fix indentation",
8
8
  type: "function",
9
- func: allLines => {
9
+ func: (allLines) => {
10
10
  const newFileLines = [];
11
11
  for (let i = 0; i < allLines.length; i++) {
12
12
  let line = allLines[i];
@@ -29,7 +29,7 @@ const rule = {
29
29
  newFileLines.push(line);
30
30
  }
31
31
  return newFileLines;
32
- }
32
+ },
33
33
  },
34
34
  tests: [
35
35
  {
@@ -40,9 +40,9 @@ const rule = {
40
40
  sourceAfter: `
41
41
  // comments should be aligned with line after
42
42
  whateverelse()
43
- `
44
- }
45
- ]
43
+ `,
44
+ },
45
+ ],
46
46
  };
47
47
 
48
- module.exports = { rule };
48
+ export { rule };
@@ -1,5 +1,5 @@
1
1
  // Insecure use of Random
2
- const { addImport, getVariable, getVariableRange } = require("../utils");
2
+ import { addImport, getVariable, getVariableRange } from "../utils.js";
3
3
 
4
4
  const rule = {
5
5
  scope: "file",
@@ -7,14 +7,14 @@ const rule = {
7
7
  variables: [
8
8
  {
9
9
  name: "RANDOM_REFERENCE",
10
- regex: /Using (.*) is insecure. Use SecureRandom instead/
11
- }
10
+ regex: /Using (.*) is insecure. Use SecureRandom instead/,
11
+ },
12
12
  ],
13
13
  range: {
14
14
  type: "function",
15
15
  func: (errLine, errItem, evaluatedVars) => {
16
16
  return getVariableRange(errLine, evaluatedVars, "RANDOM_REFERENCE", errItem);
17
- }
17
+ },
18
18
  },
19
19
  fix: {
20
20
  label: "Replace by SecureRandom use",
@@ -36,7 +36,7 @@ const rule = {
36
36
  allLines[lineNumber] = line;
37
37
  allLines = addImport(allLines, "java.security.SecureRandom");
38
38
  return allLines;
39
- }
39
+ },
40
40
  },
41
41
  tests: [
42
42
  {
@@ -53,7 +53,7 @@ def r2 = new SecureRandom()
53
53
  def r3 = new SecureRandom().nextDouble()
54
54
  def r4 = new SecureRandom().nextDouble()
55
55
  def r5 = "lelamanul"+new SecureRandom().nextDouble()+"_yeah_"+new SecureRandom().nextDouble()
56
- `
56
+ `,
57
57
  },
58
58
  {
59
59
  sourceBefore: `
@@ -80,7 +80,7 @@ def r2 = new SecureRandom()
80
80
  def r3 = new SecureRandom().nextDouble()
81
81
  def r4 = new SecureRandom().nextDouble()
82
82
  def r5 = "lelamanul"+new SecureRandom().nextDouble()+"_yeah_"+new SecureRandom().nextDouble()
83
- `
83
+ `,
84
84
  },
85
85
  {
86
86
  sourceBefore: `
@@ -103,7 +103,7 @@ def r2 = new SecureRandom()
103
103
  def r3 = new SecureRandom().nextDouble()
104
104
  def r4 = new SecureRandom().nextDouble()
105
105
  def r5 = "lelamanul"+new SecureRandom().nextDouble()+"_yeah_"+new SecureRandom().nextDouble()
106
- `
106
+ `,
107
107
  },
108
108
  {
109
109
  sourceBefore: `def r1 = new Random()
@@ -119,7 +119,7 @@ def r2 = new SecureRandom()
119
119
  def r3 = new SecureRandom().nextDouble()
120
120
  def r4 = new SecureRandom().nextDouble()
121
121
  def r5 = "lelamanul"+new SecureRandom().nextDouble()+"_yeah_"+new SecureRandom().nextDouble()
122
- `
122
+ `,
123
123
  },
124
124
  {
125
125
  sourceBefore: `/* blablabla */
@@ -138,7 +138,7 @@ def r2 = new SecureRandom()
138
138
  def r3 = new SecureRandom().nextDouble()
139
139
  def r4 = new SecureRandom().nextDouble()
140
140
  def r5 = "lelamanul"+new SecureRandom().nextDouble()+"_yeah_"+new SecureRandom().nextDouble()
141
- `
141
+ `,
142
142
  },
143
143
  {
144
144
  sourceBefore: `/* blablabla */
@@ -162,9 +162,9 @@ def r2 = new SecureRandom()
162
162
  def r3 = new SecureRandom().nextDouble()
163
163
  def r4 = new SecureRandom().nextDouble()
164
164
  def r5 = "lelamanul"+new SecureRandom().nextDouble()+"_yeah_"+new SecureRandom().nextDouble()
165
- `
166
- }
167
- ]
165
+ `,
166
+ },
167
+ ],
168
168
  };
169
169
 
170
- module.exports = { rule };
170
+ export { rule };
@@ -1,6 +1,6 @@
1
1
  // No use of Java.io classes
2
2
 
3
- const { getLastVariableRange } = require("../utils");
3
+ import { getLastVariableRange } from "../utils.js";
4
4
 
5
5
  //NV: TODO: finalise for when there is several occurrences of the string in the same line
6
6
  const rule = {
@@ -9,15 +9,15 @@ const rule = {
9
9
  {
10
10
  name: "CLASSNAME",
11
11
  regex: /The use of java.io.(.*) violates the Enterprise Java Bean specification/,
12
- regexPos: 1
13
- }
12
+ regexPos: 1,
13
+ },
14
14
  ],
15
15
  range: {
16
16
  type: "function",
17
17
  func: (errLine, errItem, evaluatedVars) => {
18
18
  return getLastVariableRange(errLine, evaluatedVars, "CLASSNAME", errItem);
19
- }
20
- }
19
+ },
20
+ },
21
21
  };
22
22
 
23
- module.exports = { rule };
23
+ export { rule };
@@ -1,21 +1,21 @@
1
1
  // Too many methods in a class
2
2
 
3
- const { getVariableRange } = require("../utils");
3
+ import { getVariableRange } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  variables: [
7
7
  {
8
8
  name: "CLASSNAME",
9
9
  regex: /Class (.*) has 52 methods/,
10
- regexPos: 1
11
- }
10
+ regexPos: 1,
11
+ },
12
12
  ],
13
13
  range: {
14
14
  type: "function",
15
15
  func: (errLine, errItem, evaluatedVars) => {
16
16
  return getVariableRange(errLine, evaluatedVars, "CLASSNAME", errItem);
17
- }
18
- }
17
+ },
18
+ },
19
19
  };
20
20
 
21
- module.exports = { rule };
21
+ export { rule };
@@ -1,21 +1,21 @@
1
1
  // Too many methods in a class
2
2
 
3
- const { getVariableRange } = require("../utils");
3
+ import { getVariableRange } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  variables: [
7
7
  {
8
8
  name: "METHODNAME",
9
9
  regex: /"(.*)" parameter of "(.*)" method is dynamically typed/,
10
- regexPos: 1
11
- }
10
+ regexPos: 1,
11
+ },
12
12
  ],
13
13
  range: {
14
14
  type: "function",
15
15
  func: (errLine, errItem, evaluatedVars) => {
16
16
  return getVariableRange(errLine, evaluatedVars, "METHODNAME", errItem);
17
- }
18
- }
17
+ },
18
+ },
19
19
  };
20
20
 
21
- module.exports = { rule };
21
+ export { rule };
@@ -1,21 +1,21 @@
1
1
  // Too many methods in a class
2
2
 
3
- const { getVariableRange } = require("../utils");
3
+ import { getVariableRange } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  variables: [
7
7
  {
8
8
  name: "METHODNAME",
9
9
  regex: /Method "(.*)" has a dynamic return type/,
10
- regexPos: 1
11
- }
10
+ regexPos: 1,
11
+ },
12
12
  ],
13
13
  range: {
14
14
  type: "function",
15
15
  func: (errLine, errItem, evaluatedVars) => {
16
16
  return getVariableRange(errLine, evaluatedVars, "METHODNAME", errItem);
17
- }
18
- }
17
+ },
18
+ },
19
19
  };
20
20
 
21
- module.exports = { rule };
21
+ export { rule };
@@ -8,12 +8,12 @@ Update list following format
8
8
  }
9
9
  */
10
10
  function addInImportsList(importsLs, commentLine, importLine) {
11
- const commentImportObjs = importsLs.filter(importObj => importObj.commentLine === commentLine);
11
+ const commentImportObjs = importsLs.filter((importObj) => importObj.commentLine === commentLine);
12
12
  const commentImportObj = commentImportObjs && commentImportObjs[0] ? commentImportObjs[0] : { commentLine: commentLine, importLines: [] };
13
13
  commentImportObj.importLines.push(importLine);
14
14
  commentImportObj.importLines.sort();
15
15
  if (commentImportObjs && commentImportObjs.length > 0) {
16
- importsLs = importsLs.map(importObj => (importObj.commentLine === commentLine ? commentImportObj : importObj));
16
+ importsLs = importsLs.map((importObj) => (importObj.commentLine === commentLine ? commentImportObj : importObj));
17
17
  } else {
18
18
  importsLs.push(commentImportObj);
19
19
  }
@@ -40,7 +40,7 @@ const rule = {
40
40
  fix: {
41
41
  label: "Reorder imports",
42
42
  type: "function",
43
- func: allLines => {
43
+ func: (allLines) => {
44
44
  let lastCommentFound = "";
45
45
  let lastCommentFoundPos = null;
46
46
  let firstCommentFoundPos = null;
@@ -48,7 +48,7 @@ const rule = {
48
48
  let lastImportFoundPos = null;
49
49
  const imports = {
50
50
  static: [],
51
- normal: []
51
+ normal: [],
52
52
  };
53
53
  let pos = 0;
54
54
  // Parse all lines and store what we need in imports object
@@ -61,13 +61,13 @@ const rule = {
61
61
  // Import static line
62
62
  if (line.trimStart().startsWith("import static")) {
63
63
  const commentKey =
64
- imports.normal.filter(importObj => importObj.commentLine === lastCommentFound).length === 0 ? lastCommentFound : "";
64
+ imports.normal.filter((importObj) => importObj.commentLine === lastCommentFound).length === 0 ? lastCommentFound : "";
65
65
  imports.static = addInImportsList(imports.static, commentKey, line);
66
66
  }
67
67
  // Import line
68
68
  else {
69
69
  const commentKey =
70
- imports.static.filter(importObj => importObj.commentLine === lastCommentFound).length === 0 ? lastCommentFound : "";
70
+ imports.static.filter((importObj) => importObj.commentLine === lastCommentFound).length === 0 ? lastCommentFound : "";
71
71
  imports.normal = addInImportsList(imports.normal, commentKey, line);
72
72
  }
73
73
  // Update positions for later build of ordered imports with comments
@@ -77,8 +77,8 @@ const rule = {
77
77
  firstCommentFoundPos || firstCommentFoundPos === 0
78
78
  ? firstCommentFoundPos
79
79
  : lastCommentFound === ""
80
- ? null
81
- : lastCommentFoundPos;
80
+ ? null
81
+ : lastCommentFoundPos;
82
82
  }
83
83
  pos++;
84
84
  }
@@ -89,7 +89,7 @@ const rule = {
89
89
  const startPos = firstCommentFoundPos ? Math.min(firstCommentFoundPos, firstImportFoundPos) : firstImportFoundPos;
90
90
  allLines.splice(startPos, lastImportFoundPos - startPos + 1, ...allImportLines);
91
91
  return allLines;
92
- }
92
+ },
93
93
  },
94
94
 
95
95
  tests: [
@@ -137,7 +137,7 @@ import java.io.File
137
137
  import after.all.does.it.work
138
138
 
139
139
  // The rest of the file below ...
140
- `
140
+ `,
141
141
  },
142
142
  {
143
143
  sourceBefore: `
@@ -176,7 +176,7 @@ import java.io.File
176
176
  import after.all.does.it.work
177
177
 
178
178
  // The rest of the file below ...
179
- `
179
+ `,
180
180
  } /*,
181
181
  {
182
182
  sourceBefore: `
@@ -230,8 +230,8 @@ import after.all.does.it.work
230
230
 
231
231
  // The rest of the file below ...
232
232
  `
233
- } */
234
- ]
233
+ } */,
234
+ ],
235
235
  };
236
236
 
237
- module.exports = { rule };
237
+ export { rule };
@@ -1,6 +1,6 @@
1
1
  // Missing blank lines after import
2
2
 
3
- const { getVariable } = require("../utils");
3
+ import { getVariable } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  scope: "file",
@@ -12,7 +12,7 @@ const rule = {
12
12
  const lineNumber = getVariable(variables, "lineNb", { mandatory: true });
13
13
  allLines.splice(lineNumber, 0, "");
14
14
  return allLines;
15
- }
15
+ },
16
16
  },
17
17
  tests: [
18
18
  {
@@ -28,9 +28,9 @@ import g.eeee.f.g.Hhhhh
28
28
  import g.eeee.f.g.Iiii
29
29
 
30
30
  def a = 1
31
- `
32
- }
33
- ]
31
+ `,
32
+ },
33
+ ],
34
34
  };
35
35
 
36
- module.exports = { rule };
36
+ export { rule };
@@ -1,6 +1,6 @@
1
1
  // Missing blank lines after package
2
2
 
3
- const { getVariable } = require("../utils");
3
+ import { getVariable } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  scope: "file",
@@ -12,7 +12,7 @@ const rule = {
12
12
  const lineNumber = getVariable(variables, "lineNb", { mandatory: true });
13
13
  allLines.splice(lineNumber + 1, 0, "");
14
14
  return allLines;
15
- }
15
+ },
16
16
  },
17
17
  tests: [
18
18
  {
@@ -28,9 +28,9 @@ package com.lelama.nul
28
28
  import a.b.c.D
29
29
  import g.eeee.f.g.Hhhhh
30
30
  import g.eeee.f.g.Iiii
31
- `
32
- }
33
- ]
31
+ `,
32
+ },
33
+ ],
34
34
  };
35
35
 
36
- module.exports = { rule };
36
+ export { rule };
@@ -1,14 +1,14 @@
1
1
  // No use of def
2
2
 
3
- const { getStringRange } = require("../utils");
3
+ import { getStringRange } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  range: {
7
7
  type: "function",
8
8
  func: (errLine, errItem) => {
9
9
  return getStringRange(errLine, "def", errItem);
10
- }
11
- }
10
+ },
11
+ },
12
12
  };
13
13
 
14
- module.exports = { rule };
14
+ export { rule };
@@ -1,14 +1,14 @@
1
1
  // No use of Java.util.date
2
2
 
3
- const { getStringRange } = require("../utils");
3
+ import { getStringRange } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  range: {
7
7
  type: "function",
8
8
  func: (errLine, errItem) => {
9
9
  return getStringRange(errLine, "Date", errItem);
10
- }
11
- }
10
+ },
11
+ },
12
12
  };
13
13
 
14
- module.exports = { rule };
14
+ export { rule };
@@ -1,20 +1,20 @@
1
1
  // No tab character
2
2
 
3
- const { getIndentLength } = require("../utils");
3
+ import { getIndentLength } from "../utils.js";
4
4
 
5
5
  const rule = {
6
6
  scope: "file",
7
7
  fix: {
8
8
  label: "Replace tabs by spaces in all file",
9
9
  type: "function",
10
- func: allLines => {
10
+ func: (allLines) => {
11
11
  const newFileLines = [];
12
12
  const replaceChars = " ".repeat(getIndentLength());
13
13
  for (const line of allLines) {
14
14
  newFileLines.push(line.replace(/\t/g, replaceChars));
15
15
  }
16
16
  return newFileLines;
17
- }
17
+ },
18
18
  },
19
19
  tests: [
20
20
  {
@@ -31,9 +31,9 @@ try {
31
31
  } catch(Exception){
32
32
  whateverelse( )
33
33
  }
34
- `
35
- }
36
- ]
34
+ `,
35
+ },
36
+ ],
37
37
  };
38
38
 
39
- module.exports = { rule };
39
+ export { rule };