From 32795f34f0c74f03eeef4bc7a69065a3844eb096 Mon Sep 17 00:00:00 2001 From: LoneRifle Date: Mon, 26 Jun 2023 21:26:52 +0800 Subject: [PATCH] Enforce eslint `no-unused-vars` (#322) - Flag `no-unused-vars` violations as errors - Remove spurious import in HMAC tests - Remove spurious namespace arg to `renderAttrs()` --- .eslintrc.json | 2 +- lib/c14n-canonicalization.js | 4 ++-- lib/exclusive-canonicalization.js | 4 ++-- test/hmac-tests.js | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 37c46986..49cbbdaf 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,7 +9,7 @@ "extends": ["eslint:recommended", "prettier"], "rules": { "no-console": "error", - "no-unused-vars": "warn", + "no-unused-vars": "error", "no-prototype-builtins": "error", "one-var": ["error", "never"], "no-duplicate-imports": "error", diff --git a/lib/c14n-canonicalization.js b/lib/c14n-canonicalization.js index cf5ba632..04686724 100644 --- a/lib/c14n-canonicalization.js +++ b/lib/c14n-canonicalization.js @@ -37,7 +37,7 @@ class C14nCanonicalization { return attr1.localeCompare(attr2); } - renderAttrs(node, defaultNS) { + renderAttrs(node) { let i; let attr; const attrListToRender = []; @@ -171,7 +171,7 @@ class C14nCanonicalization { defaultNsForPrefix, ancestorNamespaces ); - const res = ["<", node.tagName, ns.rendered, this.renderAttrs(node, ns.newDefaultNs), ">"]; + const res = ["<", node.tagName, ns.rendered, this.renderAttrs(node), ">"]; for (i = 0; i < node.childNodes.length; ++i) { pfxCopy = prefixesInScope.slice(0); diff --git a/lib/exclusive-canonicalization.js b/lib/exclusive-canonicalization.js index b696e652..961da497 100644 --- a/lib/exclusive-canonicalization.js +++ b/lib/exclusive-canonicalization.js @@ -48,7 +48,7 @@ class ExclusiveCanonicalization { return attr1.localeCompare(attr2); } - renderAttrs(node, defaultNS) { + renderAttrs(node) { let i; let attr; const res = []; @@ -183,7 +183,7 @@ class ExclusiveCanonicalization { defaultNsForPrefix, inclusiveNamespacesPrefixList ); - const res = ["<", node.tagName, ns.rendered, this.renderAttrs(node, ns.newDefaultNs), ">"]; + const res = ["<", node.tagName, ns.rendered, this.renderAttrs(node), ">"]; for (i = 0; i < node.childNodes.length; ++i) { pfxCopy = prefixesInScope.slice(0); diff --git a/test/hmac-tests.js b/test/hmac-tests.js index e9e711e4..acf2859c 100644 --- a/test/hmac-tests.js +++ b/test/hmac-tests.js @@ -2,7 +2,6 @@ const crypto = require("../index"); const xpath = require("xpath"); const xmldom = require("@xmldom/xmldom"); const fs = require("fs"); -const { sign } = require("crypto"); const expect = require("chai").expect; describe("HMAC tests", function () {