Skip to content

Commit

Permalink
Update dependency glob to v11 (#399)
Browse files Browse the repository at this point in the history
* Update dependency glob to v11

* build

* Upgrade eslint

* remove old eslint config

* eslint fix

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Nicolas Vuillamy <nicolas.vuillamy@gmail.com>
  • Loading branch information
renovate[bot] and nvuillam authored Aug 23, 2024
1 parent 2fd6c61 commit 6c5288b
Show file tree
Hide file tree
Showing 86 changed files with 917 additions and 842 deletions.
32 changes: 0 additions & 32 deletions .eslintrc.js

This file was deleted.

46 changes: 46 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import globals from "globals";
import babelParser from "@babel/eslint-parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.browser,
Atomics: "readonly",
SharedArrayBuffer: "readonly",
module: true,
require: true,
process: true,
__dirname: true,
describe: true,
it: true,
globalThis: true,
beforeEach: true,
app: true,
Tablesort: true,
},

parser: babelParser,
ecmaVersion: 2018,
sourceType: "module",

parserOptions: {
requireConfigFile: false,
},
},

rules: {
indent: "off",
},
}];
69 changes: 36 additions & 33 deletions lib/codenarc-caller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class CodeNarcCaller {
minimumJavaVersion: 17,
maximumJavaVersion: 17,
rootPath: __dirname,
jar: "java/CodeNarcServer.jar"
jar: "java/CodeNarcServer.jar",
},
codeNarcJava: {
minimumJavaVersion: 17,
maximumJavaVersion: 17,
rootPath: __dirname,
jar: "java/CodeNarcServer.jar"
}
jar: "java/CodeNarcServer.jar",
},
};

constructor(codenarcArgs1, serverStatus1, args1, options1, execOpts1) {
Expand Down Expand Up @@ -69,9 +69,9 @@ class CodeNarcCaller {
codeNarcExcludes: this.execOpts.codeNarcExcludes,
parse: this.options.parse !== false && this.execOpts.onlyCodeNarc === false,
fileList: this.execOpts.groovyFileName ? [this.execOpts.groovyFileName] : this.execOpts.inputFileList,
requestKey: this.execOpts.requestKey || null
requestKey: this.execOpts.requestKey || null,
},
timeout: 600000
timeout: 600000,
};
trace(`CALL CodeNarcServer with ${JSON.stringify(axiosConfig, null, 2)}`);
let response;
Expand All @@ -98,8 +98,8 @@ class CodeNarcCaller {
error: {
msg: `exception: ${e.response.data.exceptionType} message: ${e.response.data.errorMessage}`,
stack: e.stack,
responseData: e.response.data.errorDtl
}
responseData: e.response.data.errorDtl,
},
};
} else if (e.code === "ECONNRESET") {
// The server was shutdown just retry.
Expand All @@ -111,13 +111,16 @@ class CodeNarcCaller {
// respObj.status = 'cancelledByDuplicateRequest'
// respObj.statusCode = 444
return {
status: 9
status: 9,
};
} else {
console.error(
c.red(
"CodeNarcServer unexpected error:\n" + JSON.stringify(e, null, 2) + "\n" + JSON.stringify(e.response?.data?.errorDtl, null, 2)
)
"CodeNarcServer unexpected error:\n" +
JSON.stringify(e, null, 2) +
"\n" +
JSON.stringify(e.response?.data?.errorDtl, null, 2),
),
);
}
this.serverStatus = "error";
Expand All @@ -126,8 +129,8 @@ class CodeNarcCaller {
error: {
msg: e.message,
stack: e.stack,
responseData: e.response?.data?.errorDtl
}
responseData: e.response?.data?.errorDtl,
},
};
}

Expand All @@ -139,7 +142,7 @@ class CodeNarcCaller {
parseErrors: response.data.parseErrors,
codeNarcStdOut: response.data.stdout,
codeNarcStdErr: undefined,
status: 0
status: 0,
};
}

Expand All @@ -148,7 +151,7 @@ class CodeNarcCaller {
return {
codeNarcStdOut: undefined,
codeNarcStdErr: undefined,
status: 9
status: 9,
};
}

Expand All @@ -165,9 +168,9 @@ class CodeNarcCaller {
msgDtl: {
parseErrors: response.data.parseErrors,
stdout: response.data.stdout,
stderr: response.data.errorDtl
}
}
stderr: response.data.errorDtl,
},
},
};
}

Expand All @@ -183,7 +186,7 @@ class CodeNarcCaller {
if (this.execOpts.groovyFileName) {
scriptArgs.unshift("--file", this.execOpts.groovyFileName);
} else if (this.execOpts.inputFileList) {
this.execOpts.inputFileList.forEach(file => {
this.execOpts.inputFileList.forEach((file) => {
scriptArgs.unshift("--file", file);
});
}
Expand All @@ -194,9 +197,9 @@ class CodeNarcCaller {
{
format: "[{bar}] Running CodeNarc for {duration_formatted}",
hideCursor: true,
clearOnComplete: true
clearOnComplete: true,
},
cliProgress.Presets.shades_classic
cliProgress.Presets.shades_classic,
);
this.bar.start(10, 1);
this.barTimer = setInterval(() => {
Expand Down Expand Up @@ -232,8 +235,8 @@ class CodeNarcCaller {
reason =
"It seems node.js has not been found on your computer. Please install a recent node.js: https://nodejs.org/en/download/\nIf node is already installed, make sure your PATH contains node installation folder: https://love2dev.com/blog/node-is-not-recognized-as-an-internal-or-external-command/";
} else {
await new Promise(resolve => {
require("find-java-home")(err => {
await new Promise((resolve) => {
require("find-java-home")((err) => {
if (err) {
reason =
"Java is required to run npm-groovy-lint, as CodeNarc is written in Java/Groovy. Please install Java (version 8 minimum) https://www.java.com/download";
Expand All @@ -246,8 +249,8 @@ class CodeNarcCaller {
codeNarcStdErr: javaResult.stderr,
status: 2,
error: {
msg: `Fatal error while calling CodeNarc\n${reason}\n${javaResult.stderr}`
}
msg: `Fatal error while calling CodeNarc\n${reason}\n${javaResult.stderr}`,
},
};
}
}
Expand All @@ -259,7 +262,7 @@ class CodeNarcCaller {
parseErrors: response.parseErrors,
codeNarcStdOut: javaResult.stdout,
codeNarcStdErr: javaResult.stderr,
status: 0
status: 0,
};
}

Expand Down Expand Up @@ -295,16 +298,16 @@ class CodeNarcCaller {
const start = performance.now();
let notified = false;
let interval;
await new Promise(resolve => {
await new Promise((resolve) => {
interval = setInterval(() => {
debug(
`pinging CodeNarcServer at ${serverPingUri} notified: ${notified}, serverStatus: ${
this.serverStatus
}, since: ${performance.now() - start}, maxAttemptTimeMs: ${maxAttemptTimeMs}`
}, since: ${performance.now() - start}, maxAttemptTimeMs: ${maxAttemptTimeMs}`,
);
axios
.get(serverPingUri)
.then(response => {
.then((response) => {
if (response.status === 200) {
// Server is correctly started, as he replied to the ping request
this.serverStatus = "running";
Expand All @@ -322,7 +325,7 @@ class CodeNarcCaller {
resolve();
}
})
.catch(e => {
.catch((e) => {
debug(`Ping code: ${e.code} message: ${e.message}`);
let since = performance.now() - start;
if (notified === false && this.serverStatus === "unknown" && since > maxAttemptTimeMs) {
Expand Down Expand Up @@ -399,15 +402,15 @@ class CodeNarcCaller {
const serverPingUri = this.getCodeNarcServerUri() + "/ping";

let interval;
await new Promise(resolve => {
await new Promise((resolve) => {
interval = setInterval(() => {
debug(`pinging CodeNarcServer at ${serverPingUri} serverStatus: ${this.serverStatus}`);
axios
.get(serverPingUri)
.then(response => {
.then((response) => {
debug(`ping response: ${response.status}`);
})
.catch(e => {
.catch((e) => {
debug(`Ping code: ${e.code} message: ${e.message}`);
clearInterval(interval);
resolve();
Expand Down Expand Up @@ -438,7 +441,7 @@ class CodeNarcCaller {
try {
return JSON.parse(response);
} catch (e) {
return { err: `Unable to parse ${response}` };
return { err: `Unable to parse ${response}: ${e.message}` };
}
}
}
Expand Down
Loading

0 comments on commit 6c5288b

Please sign in to comment.