From 50d2bc944f99bee72406ba66ff31f93138fe3156 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Mon, 14 Jun 2021 10:52:00 +0200 Subject: [PATCH] [eslint] Add rules matching codebase style --- .eslintrc.js | 13 +++++++++++-- src/api.ts | 3 ++- src/session.ts | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index afb10ffbc..dff30870c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,8 +23,17 @@ module.exports = { } ], rules: { - indent: ["error", 2, { "SwitchCase": 1 }], - semi: "off", // We use the typescript-specific rule as it's more accurate. + "indent": ["error", 2, { "SwitchCase": 1 }], + "semi": "off", // We use the typescript-specific rule as it's more accurate. + "curly": ["error", "multi-line", "consistent"], + "keyword-spacing": ["error"], + "no-trailing-spaces": ["error"], + "space-before-function-paren": ["error", { + "anonymous": "always", + "named": "never", + "asyncArrow": "always", + }], + "eol-last": ["error"], "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/semi": ["error"], "@typescript-eslint/member-delimiter-style": [ diff --git a/src/api.ts b/src/api.ts index 856af3fd3..7984f9b2e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -5,8 +5,9 @@ export async function get( params: Record, config: Config ): Promise { - if (! config.seed.api) + if (! config.seed.api) { throw new Error("Seed HTTP API unavailable"); + } const query: Record = {}; for (const [key, val] of Object.entries(params)) { diff --git a/src/session.ts b/src/session.ts index fd6b7956c..3caa37305 100644 --- a/src/session.ts +++ b/src/session.ts @@ -163,8 +163,9 @@ export const loadState = (initial: State): Store => { case Connection.Connected: // In case of locking Metamask the accountsChanged event returns undefined. // To prevent out of sync state, the wallet gets disconnected. - if (address === undefined) disconnectWallet(); - else { + if (address === undefined) { + disconnectWallet(); + } else { s.session.address = address; window.localStorage.setItem("session", JSON.stringify({ address, tokenBalance: s.session.tokenBalance, tx: s.session.tx })); }