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 <hsluoyz@qq.com>
This commit is contained in:
q1anx1 2022-08-13 00:04:18 +08:00 committed by GitHub
parent 6676cc8ff3
commit a741c5179a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 9 deletions

View File

@ -20,7 +20,6 @@
"plugins": ["unused-imports"], "plugins": ["unused-imports"],
"extends": ["eslint:recommended", "plugin:react/recommended"], "extends": ["eslint:recommended", "plugin:react/recommended"],
"rules": { "rules": {
// "eqeqeq": "error",
"semi": ["error", "always"], "semi": ["error", "always"],
"indent": ["error", 2], "indent": ["error", 2],
// follow antd's style guide // follow antd's style guide
@ -87,15 +86,16 @@
"argsIgnorePattern": "^_" "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/prop-types": "off",
"react/display-name": "off", "react/display-name": "off",
"react/react-in-jsx-scope": "off", "react/react-in-jsx-scope": "off",
"no-case-declarations": "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"
} }
} }

View File

@ -81,7 +81,6 @@ export const CropperDiv = (props) => {
}; };
const handleCancel = () => { const handleCancel = () => {
console.log("Clicked cancel button");
setVisible(false); setVisible(false);
}; };

View File

@ -207,6 +207,7 @@ class ForgetPage extends React.Component {
hidden={this.state.current !== 0} hidden={this.state.current !== 0}
ref={this.form} ref={this.form}
name="step1" name="step1"
// eslint-disable-next-line no-console
onFinishFailed={(errorInfo) => console.log(errorInfo)} onFinishFailed={(errorInfo) => console.log(errorInfo)}
initialValues={{ initialValues={{
application: application.name, application: application.name,

View File

@ -61,7 +61,6 @@ class HomePage extends React.Component {
} }
} else { } else {
this.state.applications.forEach(application => { this.state.applications.forEach(application => {
console.log(application);
items.push({ items.push({
link: application.homepageUrl, name: application.displayName, organizer: application.description, logo: application.logo, createdTime: "", link: application.homepageUrl, name: application.displayName, organizer: application.description, logo: application.logo, createdTime: "",
}); });

View File

@ -55,6 +55,7 @@ export function register(config) {
// Add some additional logging to localhost, pointing developers to the // Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation. // service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => { navigator.serviceWorker.ready.then(() => {
// eslint-disable-next-line no-console
console.log( console.log(
"This web app is being served cache-first by a service " + "This web app is being served cache-first by a service " +
"worker. To learn more, visit https://bit.ly/CRA-PWA" "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, // At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older // but the previous service worker will still serve the older
// content until all client tabs are closed. // content until all client tabs are closed.
// eslint-disable-next-line no-console
console.log( console.log(
"New content is available and will be used when all " + "New content is available and will be used when all " +
"tabs for this page are closed. See https://bit.ly/CRA-PWA." "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. // At this point, everything has been precached.
// It's the perfect time to display a // It's the perfect time to display a
// "Content is cached for offline use." message. // "Content is cached for offline use." message.
// eslint-disable-next-line no-console
console.log("Content is cached for offline use."); console.log("Content is cached for offline use.");
// Execute callback // Execute callback
@ -108,6 +111,7 @@ function registerValidSW(swUrl, config) {
}; };
}) })
.catch(error => { .catch(error => {
// eslint-disable-next-line no-console
console.error("Error during service worker registration:", error); console.error("Error during service worker registration:", error);
}); });
} }
@ -136,6 +140,7 @@ function checkValidServiceWorker(swUrl, config) {
} }
}) })
.catch(() => { .catch(() => {
// eslint-disable-next-line no-console
console.log( console.log(
"No internet connection found. App is running in offline mode." "No internet connection found. App is running in offline mode."
); );
@ -149,6 +154,7 @@ export function unregister() {
registration.unregister(); registration.unregister();
}) })
.catch(error => { .catch(error => {
// eslint-disable-next-line no-console
console.error(error.message); console.error(error.message);
}); });
} }