diff --git a/web/.eslintrc b/web/.eslintrc index e4a43f0c..0985071a 100644 --- a/web/.eslintrc +++ b/web/.eslintrc @@ -42,7 +42,13 @@ "space-before-function-paren": ["error", "never"], "no-trailing-spaces": ["error", { "ignoreComments": true }], "eol-last": ["error", "always"], - // "no-var": ["error"], + "no-var": ["error"], + "prefer-const": [ + "error", + { + "destructuring": "all" + } + ], "curly": ["error", "all"], "brace-style": ["error", "1tbs", { "allowSingleLine": true }], "no-mixed-spaces-and-tabs": "error", @@ -89,7 +95,7 @@ // 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": "warn", + "no-case-declarations": "off", "react/jsx-key": "warn" } } diff --git a/web/src/AccountTable.js b/web/src/AccountTable.js index 77c9557b..dd2dd7e5 100644 --- a/web/src/AccountTable.js +++ b/web/src/AccountTable.js @@ -38,7 +38,7 @@ class AccountTable extends React.Component { } addRow(table) { - let row = {name: Setting.getNewRowNameForTable(table, "Please select an account item"), visible: true, viewRule: "Public", modifyRule: "Self"}; + const row = {name: Setting.getNewRowNameForTable(table, "Please select an account item"), visible: true, viewRule: "Public", modifyRule: "Self"}; if (table === undefined) { table = []; } @@ -141,7 +141,7 @@ class AccountTable extends React.Component { return null; } - let options = [ + const options = [ {id: "Public", name: "Public"}, {id: "Self", name: "Self"}, {id: "Admin", name: "Admin"}, diff --git a/web/src/App.js b/web/src/App.js index d17c015f..2ca8c857 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -182,7 +182,7 @@ class App extends Component { } setLanguage(account) { - let language = account?.language; + const language = account?.language; if (language !== "" && language !== i18next.language) { Setting.setLanguage(language); } @@ -242,7 +242,7 @@ class App extends Component { }); Setting.showMessage("success", "Logged out successfully"); - let redirectUri = res.data2; + const redirectUri = res.data2; if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") { Setting.goToLink(redirectUri); } else if (owner !== "built-in") { @@ -322,7 +322,7 @@ class App extends Component { } renderAccount() { - let res = []; + const res = []; if (this.state.account === undefined) { return null; @@ -349,7 +349,7 @@ class App extends Component { } renderMenu() { - let res = []; + const res = []; if (this.state.account === null || this.state.account === undefined) { return []; diff --git a/web/src/ApplicationEditPage.js b/web/src/ApplicationEditPage.js index 89c3f076..755958e2 100644 --- a/web/src/ApplicationEditPage.js +++ b/web/src/ApplicationEditPage.js @@ -120,7 +120,7 @@ class ApplicationEditPage extends React.Component { updateApplicationField(key, value) { value = this.parseApplicationField(key, value); - let application = this.state.application; + const application = this.state.application; application[key] = value; this.setState({ application: application, @@ -566,8 +566,8 @@ class ApplicationEditPage extends React.Component { renderSignupSigninPreview() { let signUpUrl = `/signup/${this.state.application.name}`; - let signInUrl = `/login/oauth/authorize?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`; - let maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"}; + const signInUrl = `/login/oauth/authorize?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`; + const maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"}; if (!this.state.application.enablePassword) { signUpUrl = signInUrl.replace("/login/oauth/authorize", "/signup/oauth/authorize"); } @@ -613,8 +613,8 @@ class ApplicationEditPage extends React.Component { } renderPromptPreview() { - let promptUrl = `/prompt/${this.state.application.name}`; - let maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"}; + const promptUrl = `/prompt/${this.state.application.name}`; + const maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"}; return (