Skip to content

Commit 1cbcf5e

Browse files
committed
fix(server): linting errors
1 parent 5eb151c commit 1cbcf5e

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

server/app.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import staticRouter from "./src/static/staticRouter.js";
55
import * as ejs from "ejs";
66
import * as fastifyView from "@fastify/view";
77
import minifier from "html-minifier";
8-
import { Stream } from "stream";
8+
import { Stream } from "node:stream";
99
import toArray from "stream-to-array";
1010
import zlib from "node:zlib";
1111
import { getSizeRouter } from "./src/responseSize/responseSizeRouter.js";
@@ -56,11 +56,11 @@ function buildServer(options = {}) {
5656
fastify.addHook("onSend", async (request, reply, payload) => {
5757
// const MISSING_HEADERS_AND_HTTP = 99;
5858
let getSizeInfo = (original, compressed) => {
59-
if (!compressed) {
60-
compressed = original;
61-
} else {
59+
if (compressed) {
6260
reply.header("Content-Length", compressed.length);
6361
reply.header("Content-Encoding", "br");
62+
} else {
63+
compressed = original;
6464
}
6565
// let headers = Object.entries(reply.getHeaders()).reduce((p, [e, v]) => p + `${e}: ${v} \n`, "");
6666
// console.log(request.url, reply.statusCode, "\n", headers);
@@ -100,8 +100,8 @@ function buildServer(options = {}) {
100100
return buffer;
101101
}
102102
})
103-
.catch((err) => {
104-
console.log("onSend: Error", err);
103+
.catch((error) => {
104+
console.log("onSend: Error", error);
105105
});
106106
} else {
107107
console.log("onSend: Unknown payload type", typeof payload, payload);

server/src/config/directories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from "path";
2-
import process from "process";
1+
import path from "node:path";
2+
import process from "node:process";
33

44
// Checks if the directory is explicitly specified.
55
// It can be specified by writing for example `npm start other-frameworks-directory`.

server/src/csp/cspControllers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export function getCSP(_request, reply) {
2222
export function addCSP(request, reply) {
2323
const { body } = request;
2424

25-
console.log("/CSP ", body);
25+
console.log("/CSP", body);
2626

2727
const uri = body["csp-report"]["document-uri"];
2828
const frameworkRegEx = /((non-)?keyed\/.*?\/)/;
2929
let framework = uri.match(frameworkRegEx)[0];
30-
framework = framework.substring(0, framework.length - 1);
30+
framework = framework.slice(0, Math.max(0, framework.length - 1));
3131

3232
if (!violations.includes(framework)) {
3333
violations.push(framework);

server/src/frameworks/frameworksServices.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PackageJSONProvider {
2828
framework,
2929
"package.json",
3030
);
31-
const packageJSON = await fs.promises.readFile(packageJSONPath, "utf-8");
31+
const packageJSON = await fs.promises.readFile(packageJSONPath, "utf8");
3232
return JSON.parse(packageJSON);
3333
} catch (error) {
3434
if (error.code === "ENOENT") {
@@ -54,7 +54,7 @@ class PackageJSONProvider {
5454
);
5555
const packageLockJSON = await fs.promises.readFile(
5656
packageLockJSONPath,
57-
"utf-8",
57+
"utf8",
5858
);
5959
return JSON.parse(packageLockJSON);
6060
} catch (error) {

0 commit comments

Comments
 (0)