From a741c5179aaf9d4599dc930840df246f2a89a226 Mon Sep 17 00:00:00 2001 From: q1anx1 <55543743+qianxi0410@users.noreply.github.com> Date: Sat, 13 Aug 2022 00:04:18 +0800 Subject: [PATCH] chore(style): modify eslint rules (#1011) * chore(style): use strict rules * chore: modify position * chore(style): warn about `console.log` and `==` * fix: fix `console.log` error * Update CropperDiv.js * Update HomePage.js Co-authored-by: Yang Luo --- web/.eslintrc | 14 +++++++------- web/src/CropperDiv.js | 1 - web/src/auth/ForgetPage.js | 1 + web/src/basic/HomePage.js | 1 - web/src/serviceWorker.js | 6 ++++++ 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/web/.eslintrc b/web/.eslintrc index 0985071a61e2..c7ce7e73bd1c 100644 --- a/web/.eslintrc +++ b/web/.eslintrc @@ -20,7 +20,6 @@ "plugins": ["unused-imports"], "extends": ["eslint:recommended", "plugin:react/recommended"], "rules": { - // "eqeqeq": "error", "semi": ["error", "always"], "indent": ["error", 2], // follow antd's style guide @@ -87,15 +86,16 @@ "argsIgnorePattern": "^_" } ], + "no-unused-vars": "off", + "react/no-deprecated": "error", + "react/jsx-key": "error", + // TODO(qianxi): should be error + "no-console": "error", + "eqeqeq": "warn", "react/prop-types": "off", "react/display-name": "off", "react/react-in-jsx-scope": "off", - - // don't use strict mod now, otherwise there are a lot of errors in the codebase - "no-unused-vars": "off", - "react/no-deprecated": "warn", - "no-case-declarations": "off", - "react/jsx-key": "warn" + "no-case-declarations": "off" } } diff --git a/web/src/CropperDiv.js b/web/src/CropperDiv.js index 88b62e9ed4e0..2b7c72bd2d16 100644 --- a/web/src/CropperDiv.js +++ b/web/src/CropperDiv.js @@ -81,7 +81,6 @@ export const CropperDiv = (props) => { }; const handleCancel = () => { - console.log("Clicked cancel button"); setVisible(false); }; diff --git a/web/src/auth/ForgetPage.js b/web/src/auth/ForgetPage.js index b4a771863075..27a1c13b0c49 100644 --- a/web/src/auth/ForgetPage.js +++ b/web/src/auth/ForgetPage.js @@ -207,6 +207,7 @@ class ForgetPage extends React.Component { hidden={this.state.current !== 0} ref={this.form} name="step1" + // eslint-disable-next-line no-console onFinishFailed={(errorInfo) => console.log(errorInfo)} initialValues={{ application: application.name, diff --git a/web/src/basic/HomePage.js b/web/src/basic/HomePage.js index 0376d1921728..ecb1af563dbb 100644 --- a/web/src/basic/HomePage.js +++ b/web/src/basic/HomePage.js @@ -61,7 +61,6 @@ class HomePage extends React.Component { } } else { this.state.applications.forEach(application => { - console.log(application); items.push({ link: application.homepageUrl, name: application.displayName, organizer: application.description, logo: application.logo, createdTime: "", }); diff --git a/web/src/serviceWorker.js b/web/src/serviceWorker.js index a3e984fc233c..31300b13174e 100644 --- a/web/src/serviceWorker.js +++ b/web/src/serviceWorker.js @@ -55,6 +55,7 @@ export function register(config) { // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { + // eslint-disable-next-line no-console console.log( "This web app is being served cache-first by a service " + "worker. To learn more, visit https://bit.ly/CRA-PWA" @@ -83,6 +84,7 @@ function registerValidSW(swUrl, config) { // At this point, the updated precached content has been fetched, // but the previous service worker will still serve the older // content until all client tabs are closed. + // eslint-disable-next-line no-console console.log( "New content is available and will be used when all " + "tabs for this page are closed. See https://bit.ly/CRA-PWA." @@ -96,6 +98,7 @@ function registerValidSW(swUrl, config) { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. + // eslint-disable-next-line no-console console.log("Content is cached for offline use."); // Execute callback @@ -108,6 +111,7 @@ function registerValidSW(swUrl, config) { }; }) .catch(error => { + // eslint-disable-next-line no-console console.error("Error during service worker registration:", error); }); } @@ -136,6 +140,7 @@ function checkValidServiceWorker(swUrl, config) { } }) .catch(() => { + // eslint-disable-next-line no-console console.log( "No internet connection found. App is running in offline mode." ); @@ -149,6 +154,7 @@ export function unregister() { registration.unregister(); }) .catch(error => { + // eslint-disable-next-line no-console console.error(error.message); }); }