From 6aaba6debd0af23127ef2b988e900785001d684e Mon Sep 17 00:00:00 2001 From: qianxi0410 <894871277@qq.com> Date: Sat, 6 Aug 2022 23:43:09 +0800 Subject: [PATCH] feat: space between infix op --- web/.eslintrc | 2 ++ web/src/ApplicationEditPage.js | 4 ++-- web/src/CertEditPage.js | 2 +- web/src/ModelEditPage.js | 2 +- web/src/OrganizationEditPage.js | 2 +- web/src/PaymentEditPage.js | 2 +- web/src/PermissionEditPage.js | 2 +- web/src/ProductEditPage.js | 4 ++-- web/src/ProviderEditPage.js | 2 +- web/src/RoleEditPage.js | 2 +- web/src/Setting.js | 12 ++++++------ web/src/SyncerEditPage.js | 2 +- web/src/TokenEditPage.js | 2 +- web/src/UserEditPage.js | 2 +- web/src/WebhookEditPage.js | 2 +- web/src/auth/Util.js | 2 +- web/src/backend/ResourceBackend.js | 4 ++-- web/src/basic/HomePage.js | 2 +- 18 files changed, 27 insertions(+), 25 deletions(-) diff --git a/web/.eslintrc b/web/.eslintrc index e1c7ceaa..c3fce332 100644 --- a/web/.eslintrc +++ b/web/.eslintrc @@ -49,6 +49,8 @@ "ignoreDeclarationSort": true }], "no-multiple-empty-lines": ["error", { "max": 1, "maxBOF": 0, "maxEOF": 0 }], + "space-unary-ops": ["error", { "words": true, "nonwords": false }], + "space-infix-ops": "error", "react/prop-types": "off", diff --git a/web/src/ApplicationEditPage.js b/web/src/ApplicationEditPage.js index 84fe13d8..069871ba 100644 --- a/web/src/ApplicationEditPage.js +++ b/web/src/ApplicationEditPage.js @@ -156,7 +156,7 @@ class ApplicationEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} : @@ -181,7 +181,7 @@ class ApplicationEditPage extends React.Component { {Setting.getLabel(i18next.t("general:Logo"), i18next.t("general:Logo - Tooltip"))} : - + {Setting.getLabel(i18next.t("general:URL"), i18next.t("general:URL - Tooltip"))} : diff --git a/web/src/CertEditPage.js b/web/src/CertEditPage.js index d2910a68..6e8eea12 100644 --- a/web/src/CertEditPage.js +++ b/web/src/CertEditPage.js @@ -73,7 +73,7 @@ class CertEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} : diff --git a/web/src/ModelEditPage.js b/web/src/ModelEditPage.js index d850654f..d90fe5be 100644 --- a/web/src/ModelEditPage.js +++ b/web/src/ModelEditPage.js @@ -97,7 +97,7 @@ class ModelEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} : diff --git a/web/src/OrganizationEditPage.js b/web/src/OrganizationEditPage.js index 4d7767b5..b299f6d6 100644 --- a/web/src/OrganizationEditPage.js +++ b/web/src/OrganizationEditPage.js @@ -91,7 +91,7 @@ class OrganizationEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} : diff --git a/web/src/PaymentEditPage.js b/web/src/PaymentEditPage.js index c6e5e4db..50dce1ae 100644 --- a/web/src/PaymentEditPage.js +++ b/web/src/PaymentEditPage.js @@ -152,7 +152,7 @@ class PaymentEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} : diff --git a/web/src/PermissionEditPage.js b/web/src/PermissionEditPage.js index bf9feff7..de7b3a15 100644 --- a/web/src/PermissionEditPage.js +++ b/web/src/PermissionEditPage.js @@ -132,7 +132,7 @@ class PermissionEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} : diff --git a/web/src/ProductEditPage.js b/web/src/ProductEditPage.js index 856f91d1..a3571e66 100644 --- a/web/src/ProductEditPage.js +++ b/web/src/ProductEditPage.js @@ -85,7 +85,7 @@ class ProductEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} : @@ -110,7 +110,7 @@ class ProductEditPage extends React.Component { {Setting.getLabel(i18next.t("product:Image"), i18next.t("product:Image - Tooltip"))} : - + {Setting.getLabel(i18next.t("general:URL"), i18next.t("general:URL - Tooltip"))} : diff --git a/web/src/ProviderEditPage.js b/web/src/ProviderEditPage.js index 242f527e..a2f24614 100644 --- a/web/src/ProviderEditPage.js +++ b/web/src/ProviderEditPage.js @@ -167,7 +167,7 @@ class ProviderEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} : diff --git a/web/src/RoleEditPage.js b/web/src/RoleEditPage.js index dddf3c85..21c4dde4 100644 --- a/web/src/RoleEditPage.js +++ b/web/src/RoleEditPage.js @@ -107,7 +107,7 @@ class RoleEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} : diff --git a/web/src/Setting.js b/web/src/Setting.js index aea70cf3..d61ece62 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -305,7 +305,7 @@ export function isPromptAnswered(user, application) { } const providerItems = getAllPromptedProviderItems(application); - for (let i = 0; i < providerItems.length; i ++) { + for (let i = 0; i < providerItems.length; i++) { if (!isProviderItemAnswered(user, application, providerItems[i])) { return false; } @@ -432,7 +432,7 @@ export function getShortName(s) { return s.split("/").slice(-1)[0]; } -export function getShortText(s, maxLength=35) { +export function getShortText(s, maxLength = 35) { if (s.length > maxLength) { return `${s.slice(0, maxLength)}...`; } else { @@ -449,13 +449,13 @@ export function getFriendlyFileSize(size) { let num = (size / Math.pow(1024, i)); let round = Math.round(num); num = round < 10 ? num.toFixed(2) : round < 100 ? num.toFixed(1) : round; - return `${num} ${"KMGTPEZY"[i-1]}B`; + return `${num} ${"KMGTPEZY"[i - 1]}B`; } function getRandomInt(s) { let hash = 0; if (s.length !== 0) { - for (let i = 0; i < s.length; i ++) { + for (let i = 0; i < s.length; i++) { let char = s.charCodeAt(i); hash = ((hash << 5) - hash) + char; hash = hash & hash; @@ -723,7 +723,7 @@ export function goToForget(ths, application) { } export function renderHelmet(application) { - if (application === undefined || application === null || application.organizationObj === undefined || application.organizationObj === null ||application.organizationObj === "") { + if (application === undefined || application === null || application.organizationObj === undefined || application.organizationObj === null || application.organizationObj === "") { return null; } @@ -791,7 +791,7 @@ export function getDeduplicatedArray(array, filterArray, key) { export function getNewRowNameForTable(table, rowName) { const emptyCount = table.filter(row => row.name.includes(rowName)).length; let res = rowName; - for (let i = 0; i < emptyCount; i ++) { + for (let i = 0; i < emptyCount; i++) { res = res + " "; } return res; diff --git a/web/src/SyncerEditPage.js b/web/src/SyncerEditPage.js index 7d16cd7a..7ae67410 100644 --- a/web/src/SyncerEditPage.js +++ b/web/src/SyncerEditPage.js @@ -89,7 +89,7 @@ class SyncerEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} : diff --git a/web/src/TokenEditPage.js b/web/src/TokenEditPage.js index 98f6610c..bbfbc0de 100644 --- a/web/src/TokenEditPage.js +++ b/web/src/TokenEditPage.js @@ -68,7 +68,7 @@ class TokenEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {i18next.t("general:Name")}: diff --git a/web/src/UserEditPage.js b/web/src/UserEditPage.js index 13c0affa..b5fc2553 100644 --- a/web/src/UserEditPage.js +++ b/web/src/UserEditPage.js @@ -567,7 +567,7 @@ class UserEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> { this.state.application?.organizationObj.accountItems?.map(accountItem => { return ( diff --git a/web/src/WebhookEditPage.js b/web/src/WebhookEditPage.js index 640e7164..3a945dc8 100644 --- a/web/src/WebhookEditPage.js +++ b/web/src/WebhookEditPage.js @@ -155,7 +155,7 @@ class WebhookEditPage extends React.Component { {this.state.mode === "add" ? : null} - } style={(Setting.isMobile())? {margin: "5px"}:{}} type="inner"> + } style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner"> {Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} : diff --git a/web/src/auth/Util.js b/web/src/auth/Util.js index 1a9a9fa7..6702ad23 100644 --- a/web/src/auth/Util.js +++ b/web/src/auth/Util.js @@ -76,7 +76,7 @@ export function renderMessageLarge(ths, msg) { } function getRefinedValue(value) { - return (value === null)? "" : value; + return (value === null) ? "" : value; } export function getCasParameters(params) { diff --git a/web/src/backend/ResourceBackend.js b/web/src/backend/ResourceBackend.js index 9a4f17d1..3c6b6aed 100644 --- a/web/src/backend/ResourceBackend.js +++ b/web/src/backend/ResourceBackend.js @@ -46,7 +46,7 @@ export function addResource(resource) { }).then(res => res.json()); } -export function deleteResource(resource, provider="") { +export function deleteResource(resource, provider = "") { let newResource = Setting.deepCopy(resource); return fetch(`${Setting.ServerUrl}/api/delete-resource?provider=${provider}`, { method: "POST", @@ -55,7 +55,7 @@ export function deleteResource(resource, provider="") { }).then(res => res.json()); } -export function uploadResource(owner, user, tag, parent, fullFilePath, file, provider="") { +export function uploadResource(owner, user, tag, parent, fullFilePath, file, provider = "") { const application = "app-built-in"; let formData = new FormData(); formData.append("file", file); diff --git a/web/src/basic/HomePage.js b/web/src/basic/HomePage.js index 8cb3d1b2..ef8a3c2b 100644 --- a/web/src/basic/HomePage.js +++ b/web/src/basic/HomePage.js @@ -51,7 +51,7 @@ class HomePage extends React.Component { {link: "/applications", name: i18next.t("general:Applications"), organizer: i18next.t("general:Applications that require authentication")}, ]; - for (let i = 0; i < items.length; i ++) { + for (let i = 0; i < items.length; i++) { let filename = items[i].link; if (filename === "/account") { filename = "/users";