From 5f2f2b48893a05fff9b4185c9e5f15f315272fb3 Mon Sep 17 00:00:00 2001 From: PierreDemailly <39910767+PierreDemailly@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:04:22 +0100 Subject: [PATCH] chore: update @openally/config.eslint (#443) --- package.json | 2 +- src/commands/scorecard.js | 16 ++++++---------- src/http-server/endpoints/config.js | 2 +- src/http-server/endpoints/data.js | 2 +- src/http-server/endpoints/flags.js | 2 +- src/http-server/endpoints/i18n.js | 2 +- src/http-server/endpoints/root.js | 2 +- src/http-server/middleware.js | 2 +- test/httpServer.test.js | 4 ++-- test/process/verify.js | 2 +- workspaces/documentation-ui/example/master.js | 8 +------- workspaces/documentation-ui/index.js | 4 ++-- 12 files changed, 19 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index d3a12dbf..697904f7 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@myunisoft/httpie": "^5.0.0", "@nodesecure/size-satisfies": "^1.1.0", "@nodesecure/vis-network": "^1.4.0", - "@openally/config.eslint": "^1.1.0", + "@openally/config.eslint": "^1.3.0", "@types/node": "^22.2.0", "c8": "^10.1.2", "cross-env": "^7.0.3", diff --git a/src/commands/scorecard.js b/src/commands/scorecard.js index 47b4d348..416c1ba1 100644 --- a/src/commands/scorecard.js +++ b/src/commands/scorecard.js @@ -36,19 +36,15 @@ export async function main(repo, opts) { const vcs = opts.vcs.toLowerCase(); const result = typeof repo === "string" ? Ok([repo, vcs]) : getCurrentRepository(vcs); - let repository; - let platform; - try { - const [repo, vcs] = result.unwrap(); - repository = repo; - platform = vcs.slice(-4) === ".com" ? vcs : `${vcs}.com`; - } - catch (error) { - console.log(white().bold(result.err)); + if (result.err) { + console.log(white().bold(result.val)); process.exit(); } + const [repository, repoVcs] = result.unwrap(); + const platform = repoVcs.slice(-4) === ".com" ? vcs : `${vcs}.com`; + let data; try { data = await scorecard.result(repository, { @@ -56,7 +52,7 @@ export async function main(repo, opts) { platform }); } - catch (error) { + catch { console.log( kleur .white() diff --git a/src/http-server/endpoints/config.js b/src/http-server/endpoints/config.js index dfe5eb4e..fc79e35c 100644 --- a/src/http-server/endpoints/config.js +++ b/src/http-server/endpoints/config.js @@ -5,7 +5,7 @@ import send from "@polka/send-type"; import * as config from "../config.js"; import { bodyParser } from "../bodyParser.js"; -export async function get(req, res) { +export async function get(_req, res) { const result = await config.get(); send(res, 200, result); diff --git a/src/http-server/endpoints/data.js b/src/http-server/endpoints/data.js index 02194a86..21914efb 100644 --- a/src/http-server/endpoints/data.js +++ b/src/http-server/endpoints/data.js @@ -12,7 +12,7 @@ import { logger } from "../logger.js"; // CONSTANTS const kDefaultPayloadPath = path.join(process.cwd(), "nsecure-result.json"); -export async function get(req, res) { +export async function get(_req, res) { try { const { current, lru } = await appCache.payloadsList(); logger.info(`[data|get](current: ${current})`); diff --git a/src/http-server/endpoints/flags.js b/src/http-server/endpoints/flags.js index 791a2110..165d5031 100644 --- a/src/http-server/endpoints/flags.js +++ b/src/http-server/endpoints/flags.js @@ -8,7 +8,7 @@ import { getManifest, lazyFetchFlagFile, getFlags } from "@nodesecure/flags"; // CONSTANTS const kNodeSecureFlags = getFlags(); -export function getAll(req, res) { +export function getAll(_req, res) { send(res, 200, getManifest()); } diff --git a/src/http-server/endpoints/i18n.js b/src/http-server/endpoints/i18n.js index 660181fb..d4838456 100644 --- a/src/http-server/endpoints/i18n.js +++ b/src/http-server/endpoints/i18n.js @@ -5,6 +5,6 @@ import send from "@polka/send-type"; import english from "../../../i18n/english.js"; import french from "../../../i18n/french.js"; -export async function get(req, res) { +export async function get(_req, res) { send(res, 200, { english: english.ui, french: french.ui }); } diff --git a/src/http-server/endpoints/root.js b/src/http-server/endpoints/root.js index 795f2ad2..a720bc68 100644 --- a/src/http-server/endpoints/root.js +++ b/src/http-server/endpoints/root.js @@ -24,7 +24,7 @@ export async function buildHtml() { return templateStr; } -export async function get(req, res) { +export async function get(_req, res) { try { res.writeHead(200, { "Content-Type": "text/html" diff --git a/src/http-server/middleware.js b/src/http-server/middleware.js index c44308ea..0de0bc5d 100644 --- a/src/http-server/middleware.js +++ b/src/http-server/middleware.js @@ -9,7 +9,7 @@ import sirv from "sirv"; import { context } from "./context.js"; export function buildContextMiddleware(dataFilePath) { - return function addContext(req, res, next) { + return function addContext(_req, _res, next) { const store = { dataFilePath }; context.run(store, next); }; diff --git a/test/httpServer.test.js b/test/httpServer.test.js index f59500d4..08ecc0a6 100644 --- a/test/httpServer.test.js +++ b/test/httpServer.test.js @@ -83,7 +83,7 @@ describe("httpServer", { concurrency: 1 }, () => { const errors = []; const module = await esmock("../src/http-server/endpoints/root.js", { "@polka/send-type": { - default: (res, status, { error }) => errors.push(error) + default: (_res, _status, { error }) => errors.push(error) } }); @@ -124,7 +124,7 @@ describe("httpServer", { concurrency: 1 }, () => { test("'/flags/description/:title' should fail", async() => { const module = await esmock("../src/http-server/endpoints/flags.js", { stream: { - pipeline: (stream, res, err) => err("fake error") + pipeline: (_stream, _res, err) => err("fake error") }, fs: { createReadStream: () => "foo" diff --git a/test/process/verify.js b/test/process/verify.js index e3ca2f96..9b62d622 100644 --- a/test/process/verify.js +++ b/test/process/verify.js @@ -2,7 +2,7 @@ import * as verify from "../../src/commands/verify.js"; import { prepareProcess } from "../helpers/cliCommandRunner.js"; -function mockVerify(packageName) { +function mockVerify() { return ({ files: { list: ["index.js", "package.json"], diff --git a/workspaces/documentation-ui/example/master.js b/workspaces/documentation-ui/example/master.js index 4ddc2fbe..c556e5f5 100644 --- a/workspaces/documentation-ui/example/master.js +++ b/workspaces/documentation-ui/example/master.js @@ -1,13 +1,7 @@ import * as documentationUI from "../index.js"; document.addEventListener("DOMContentLoaded", async() => { - const result = documentationUI.render(document.getElementById("main"), { + documentationUI.render(document.getElementById("main"), { prefetch: true }); - - // setTimeout(() => { - // result.header.setNewActiveView("warnings"); - - // result.navigation.warnings.setNewActiveMenu("unsafe-stmt"); - // }, 3_000); }); diff --git a/workspaces/documentation-ui/index.js b/workspaces/documentation-ui/index.js index 0b9d005e..c48f7406 100644 --- a/workspaces/documentation-ui/index.js +++ b/workspaces/documentation-ui/index.js @@ -29,14 +29,14 @@ const kWikiMenus = { flags: { name: "Flags", data: Object.entries(getManifest()).map(([name, { title, emoji }]) => ({ name, title, icon: emoji })), - callback(name, menuElement) { + callback(_name, menuElement) { fetchAndRenderByMenu(menuElement, "flags").catch(console.error); } }, warnings: { name: "SAST Warnings", data: kSASTWarnings, - callback(name, menuElement) { + callback(_name, menuElement) { fetchAndRenderByMenu(menuElement, "warnings").catch(console.error); } }