diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 73fd99363..ce6a16c14 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -17,6 +17,7 @@ ignorePatterns: rules: # Code quality rules + eqeqeq: error no-unused-vars: error no-use-before-define: ["error", { "functions": false, "classes": false }] prefer-const: ["error", {"destructuring": "all"}] diff --git a/src/authz/index.js b/src/authz/index.js index b0e6b52b2..7d168fb96 100644 --- a/src/authz/index.js +++ b/src/authz/index.js @@ -18,9 +18,9 @@ import tags from './tags.js'; */ function authorized(user, action, object) { // user may be null - assert(!user || user.authzRoles != null, "user.authzRoles is not null if user is not null"); + assert(!user || user.authzRoles !== null, "user.authzRoles is not null if user is not null"); assert(actions.has(action), "action is known"); - assert(object != null, "object is not null"); + assert(object !== null, "object is not null"); /* As a safe guard, anonymous users can only ever read, regardless of * policies right now. We don't have any use cases right now where letting diff --git a/src/sources/groups.js b/src/sources/groups.js index 642bcd0f8..bc563ca08 100644 --- a/src/sources/groups.js +++ b/src/sources/groups.js @@ -112,7 +112,7 @@ class GroupSource extends Source { let {title, byline, website, showDatasets, showNarratives} = frontMatter; // Must be an allowed protocol - if (website != null) { + if (website !== null) { const {protocol} = parseUrl(website) ?? {}; const allowedProtocols = new Set(["https:", "http:", "ftp:", "ftps:", "mailto:"]); if (!allowedProtocols.has(protocol)) { diff --git a/src/upstream.js b/src/upstream.js index c98e999d2..d53f4ed52 100644 --- a/src/upstream.js +++ b/src/upstream.js @@ -346,7 +346,7 @@ function copyHeaders(headerSource, headerNames) { return Object.fromEntries( headerNames .map(name => [name, headerSource.get(name)]) - .filter(([name, value]) => value != null && value !== "") // eslint-disable-line no-unused-vars + .filter(([name, value]) => value !== null && value !== "") // eslint-disable-line no-unused-vars ); } diff --git a/src/utils/index.js b/src/utils/index.js index 5bddf580e..cac6556f1 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -109,7 +109,7 @@ const parseNarrativeLanguage = (narrative) => { const normalizeHeaders = (headers) => { const withValues = Object.entries(headers) - .filter(([, value]) => value != null && value !== ""); + .filter(([, value]) => value !== null && value !== ""); /* Use the WHATWG Headers object to do most of the normalization, including * lowercasing and combining duplicate headers as appropriate. diff --git a/src/utils/scripts.js b/src/utils/scripts.js index a87685991..be22c320c 100644 --- a/src/utils/scripts.js +++ b/src/utils/scripts.js @@ -91,7 +91,7 @@ async function run(argv) { proc.stderr.on("data", data => console.error(data.toString().replace(/\n$/, ""))); proc.on("close", (code, signal) => { - const result = code !== 0 || signal != null + const result = code !== 0 || signal !== null ? reject : resolve; return result({code, signal, argv}); diff --git a/static-site/src/components/ExpandableTiles/index.tsx b/static-site/src/components/ExpandableTiles/index.tsx index d5e56e186..8ea6d9085 100644 --- a/static-site/src/components/ExpandableTiles/index.tsx +++ b/static-site/src/components/ExpandableTiles/index.tsx @@ -31,7 +31,7 @@ export const ExpandableTiles = ({tiles, tileWidth, tileHei function tilesContainerRef(tilesContainer: HTMLDivElement) { if (!tilesContainer) return; - if(tilesContainerHeight != tilesContainer.clientHeight) { + if(tilesContainerHeight !== tilesContainer.clientHeight) { setTilesContainerHeight(tilesContainer.clientHeight) } } diff --git a/static-site/src/components/ListResources/IndividualResource.tsx b/static-site/src/components/ListResources/IndividualResource.tsx index 91db2798a..178b71c9e 100644 --- a/static-site/src/components/ListResources/IndividualResource.tsx +++ b/static-site/src/components/ListResources/IndividualResource.tsx @@ -130,7 +130,7 @@ export const IndividualResource = ({resource, isMobile}: IndividualResourceProps // don't do anything if the ref is undefined or the parent is not a div (IndividualResourceContainer) if (!ref.current || !ref.current.parentNode - || ref.current.parentNode.nodeName != 'DIV') return; + || ref.current.parentNode.nodeName !== 'DIV') return; /* The column CSS is great but doesn't allow us to know if an element is at the top of its column, so we resort to JS */ diff --git a/static-site/src/components/nav-bar/index.tsx b/static-site/src/components/nav-bar/index.tsx index 644130234..7a4f37501 100644 --- a/static-site/src/components/nav-bar/index.tsx +++ b/static-site/src/components/nav-bar/index.tsx @@ -119,7 +119,7 @@ const NavBar = ({ minified }: { return ( - {Router.pathname != "/" && <> + {Router.pathname !== "/" && <> }