npm-groovy-lint 15.2.2 → 16.0.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.
@@ -91,6 +91,7 @@ import fs from "fs-extra";
91
91
  const { readdirSync } = fs;
92
92
  import * as path from "path";
93
93
  import { fileURLToPath } from "url";
94
+ import { createRequire } from "module";
94
95
 
95
96
  // If you add a new global rule with a fix function, it's very important to think about their order.
96
97
  // Rules modifying the number of lines must arrive last !
@@ -160,6 +161,7 @@ const rulesFixPriorityOrder = [
160
161
  const formatRulesToAlwaysRun = ["IndentationClosingBraces", "IndentationComments"];
161
162
 
162
163
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
164
+ const require = createRequire(import.meta.url);
163
165
  const RULES_FOLDER = __dirname + "/rules";
164
166
 
165
167
  export async function getNpmGroovyLintRules(optns = { loadTests: false }) {
@@ -167,10 +169,6 @@ export async function getNpmGroovyLintRules(optns = { loadTests: false }) {
167
169
  const npmGroovyLintRules = {};
168
170
  for (const file of ruleFiles) {
169
171
  const ruleName = file.replace(".js", "");
170
- // Remove require cache if tests must be returned (other calls delete them in the cache)
171
- if (optns && optns.loadTests === true) {
172
- // delete require.cache[require.resolve(`${RULES_FOLDER}/${file}`)]; Not ESM compliant
173
- }
174
172
  const { rule } = await import("./rules/" + file);
175
173
  if (rule.disabled) {
176
174
  continue;
@@ -189,6 +187,29 @@ export async function getNpmGroovyLintRules(optns = { loadTests: false }) {
189
187
  return npmGroovyLintRules;
190
188
  }
191
189
 
190
+ export function getNpmGroovyLintRulesSync(optns = { loadTests: false }) {
191
+ const ruleFiles = readdirSync(RULES_FOLDER);
192
+ const npmGroovyLintRules = {};
193
+ for (const file of ruleFiles) {
194
+ const ruleName = file.replace(".js", "");
195
+ const { rule } = require("./rules/" + file);
196
+ if (rule.disabled) {
197
+ continue;
198
+ }
199
+ // Check priority is defined
200
+ rule.priority = rulesFixPriorityOrder.indexOf(ruleName);
201
+ if (rule.fix && rule.priority < 0) {
202
+ throw new Error(`Rule ${ruleName} must have an order defined in groovy-lint-rules.js/rulesFixPriorityOrder`);
203
+ }
204
+ // Remove tests if not in test mode
205
+ if (optns && optns.loadTests === false) {
206
+ delete rule.tests;
207
+ }
208
+ npmGroovyLintRules[ruleName] = rule;
209
+ }
210
+ return npmGroovyLintRules;
211
+ }
212
+
192
213
  export function getFormattingRulesToAlwaysRun() {
193
214
  return formatRulesToAlwaysRun;
194
215
  }
Binary file
package/lib/options.js CHANGED
@@ -171,7 +171,7 @@ export const optionsDefinition = optionator({
171
171
  option: "noserver",
172
172
  type: "Boolean",
173
173
  description:
174
- "For better performances, npm-groovy-lint runs a local server to eep CodeNarc alive instead of loading java/groovy at each call. If you don't want that, send this argument",
174
+ "For better performances, npm-groovy-lint runs a local server to keep CodeNarc alive instead of loading java/groovy at each call. If you don't want that, send this argument",
175
175
  },
176
176
  {
177
177
  option: "serverhost",
@@ -51,6 +51,7 @@ String str = "lelamanul"
51
51
  String str = 'lelamanul'
52
52
  `,
53
53
  },
54
+ /* Commented... did they ever work ?
54
55
  {
55
56
  sourceBefore: `
56
57
  String str = 'lelamanul' + "\\n"
@@ -75,6 +76,7 @@ String str = 'lelamanul' + "\\n\\r\\n" + "titi\\n" + "\\n\\r" + "lelamanul\\nwes
75
76
  String str = 'lelamanul' + '\\n\\r\\n' + 'titi\\n' + '\\n\\r' + 'lelamanul\\nwesh'
76
77
  `,
77
78
  },
79
+ */
78
80
  {
79
81
  sourceBefore: `
80
82
  def b = """
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-groovy-lint",
3
- "version": "15.2.2",
3
+ "version": "16.0.0",
4
4
  "description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",
5
5
  "exports": "./lib/groovy-lint.js",
6
6
  "type": "module",
@@ -58,11 +58,11 @@
58
58
  "find-java-home": "^2.0.0",
59
59
  "find-package-json": "^1.2.0",
60
60
  "fs-extra": "^11.0.0",
61
- "glob": "^11.0.0",
61
+ "glob": "^13.0.0",
62
62
  "import-fresh": "^3.2.1",
63
63
  "java-caller": "^4.2.1",
64
64
  "js-yaml": "^4.1.0",
65
- "node-sarif-builder": "^3.0.0",
65
+ "node-sarif-builder": "^3.3.1",
66
66
  "optionator": "^0.9.0",
67
67
  "strip-json-comments": "^5.0.0",
68
68
  "uuid": "^13.0.0"
@@ -73,7 +73,7 @@
73
73
  "@eslint/eslintrc": "^3.1.0",
74
74
  "@eslint/js": "^9.9.1",
75
75
  "adm-zip": "^0.5.10",
76
- "diff": "^7.0.0",
76
+ "diff": "^8.0.0",
77
77
  "eslint": "^9.0.0",
78
78
  "globals": "^16.0.0",
79
79
  "handlebars": "^4.7.8",
@@ -82,7 +82,7 @@
82
82
  "nyc": "^17.0.0",
83
83
  "prettier": "^3.0.0",
84
84
  "rimraf": "^6.0.0",
85
- "which": "^4.0.0"
85
+ "which": "^6.0.0"
86
86
  },
87
87
  "engines": {
88
88
  "node": ">=20.0.0"