From ca1324757259c2a15aea60572adba50446e0cdbe Mon Sep 17 00:00:00 2001 From: q1anx1 <55543743+qianxi0410@users.noreply.github.com> Date: Sat, 13 Aug 2022 11:23:16 +0800 Subject: [PATCH] chore(style): use `eqeqeq` (#1013) --- web/.eslintrc | 3 +-- web/src/auth/LoginPage.js | 6 +++--- web/src/auth/SignupPage.js | 2 +- web/src/i18n.js | 2 +- web/src/serviceWorker.js | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/web/.eslintrc b/web/.eslintrc index c7ce7e73..a5f3ef2a 100644 --- a/web/.eslintrc +++ b/web/.eslintrc @@ -89,9 +89,8 @@ "no-unused-vars": "off", "react/no-deprecated": "error", "react/jsx-key": "error", - // TODO(qianxi): should be error "no-console": "error", - "eqeqeq": "warn", + "eqeqeq": "error", "react/prop-types": "off", "react/display-name": "off", diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index 372c482d..17f89e23 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -164,7 +164,7 @@ class LoginPage extends React.Component { } else { // OAuth const oAuthParams = Util.getOAuthGetParameters(); - if (oAuthParams !== null && oAuthParams.responseType != null && oAuthParams.responseType !== "") { + if (oAuthParams !== null && oAuthParams.responseType !== null && oAuthParams.responseType !== "") { values["type"] = oAuthParams.responseType; } else { values["type"] = this.state.type; @@ -175,11 +175,11 @@ class LoginPage extends React.Component { values["samlRequest"] = oAuthParams.samlRequest; } - if (values["samlRequest"] != null && values["samlRequest"] !== "") { + if (values["samlRequest"] !== null && values["samlRequest"] !== "" && values["samlRequest"] !== undefined) { values["type"] = "saml"; } - if (this.state.owner != null) { + if (this.state.owner !== null) { values["organization"] = this.state.owner; } diff --git a/web/src/auth/SignupPage.js b/web/src/auth/SignupPage.js index 330847be..503b24ef 100644 --- a/web/src/auth/SignupPage.js +++ b/web/src/auth/SignupPage.js @@ -582,7 +582,7 @@ class SignupPage extends React.Component {   {i18next.t("signup:Have account?")}  { const linkInStorage = sessionStorage.getItem("signinUrl"); - if(linkInStorage != null) { + if(linkInStorage !== null && linkInStorage !== "") { Setting.goToLink(linkInStorage); }else{ Setting.goToLogin(this, application); diff --git a/web/src/i18n.js b/web/src/i18n.js index 4683ef6a..b056890d 100644 --- a/web/src/i18n.js +++ b/web/src/i18n.js @@ -35,7 +35,7 @@ const resources = { function initLanguage() { let language = localStorage.getItem("language"); - if (language === undefined || language == null) { + if (language === undefined || language === null || language === "") { if (Conf.ForceLanguage !== "") { language = Conf.ForceLanguage; } else { diff --git a/web/src/serviceWorker.js b/web/src/serviceWorker.js index 31300b13..47d84a49 100644 --- a/web/src/serviceWorker.js +++ b/web/src/serviceWorker.js @@ -75,7 +75,7 @@ function registerValidSW(swUrl, config) { .then(registration => { registration.onupdatefound = () => { const installingWorker = registration.installing; - if (installingWorker == null) { + if (installingWorker === null) { return; } installingWorker.onstatechange = () => { @@ -126,7 +126,7 @@ function checkValidServiceWorker(swUrl, config) { const contentType = response.headers.get("content-type"); if ( response.status === 404 || - (contentType != null && contentType.indexOf("javascript") === -1) + (contentType !== null && contentType.indexOf("javascript") === -1) ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => {