diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 01:10:54 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 13:46:36 +0200 |
commit | 08bd3dc0e8a3c2370e4e8abbaa241eaafc144f4c (patch) | |
tree | 9a55a5734718e7c278ccb24733425184fb8cea34 /src/pages/show-db.ts | |
parent | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (diff) | |
download | wallet-core-08bd3dc0e8a3c2370e4e8abbaa241eaafc144f4c.tar.xz |
add linting rules and fix them
Diffstat (limited to 'src/pages/show-db.ts')
-rw-r--r-- | src/pages/show-db.ts | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/pages/show-db.ts b/src/pages/show-db.ts index 955253680..d95951385 100644 --- a/src/pages/show-db.ts +++ b/src/pages/show-db.ts @@ -23,32 +23,32 @@ function replacer(match: string, pIndent: string, pKey: string, pVal: string, pEnd: string) { - var key = '<span class=json-key>'; - var val = '<span class=json-value>'; - var str = '<span class=json-string>'; - var r = pIndent || ''; + const key = "<span class=json-key>"; + const val = "<span class=json-value>"; + const str = "<span class=json-string>"; + let r = pIndent || ""; if (pKey) { - r = r + key + '"' + pKey.replace(/[": ]/g, '') + '":</span> '; + r = r + key + '"' + pKey.replace(/[": ]/g, "") + '":</span> '; } if (pVal) { - r = r + (pVal[0] == '"' ? str : val) + pVal + '</span>'; + r = r + (pVal[0] === '"' ? str : val) + pVal + "</span>"; } - return r + (pEnd || ''); + return r + (pEnd || ""); } function prettyPrint(obj: any) { - var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg; + const jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg; return JSON.stringify(obj, null as any, 3) - .replace(/&/g, '&').replace(/\\"/g, '"') - .replace(/</g, '<').replace(/>/g, '>') + .replace(/&/g, "&").replace(/\\"/g, """) + .replace(/</g, "<").replace(/>/g, ">") .replace(jsonLine, replacer); } document.addEventListener("DOMContentLoaded", () => { - chrome.runtime.sendMessage({type: 'dump-db'}, (resp) => { - const el = document.getElementById('dump'); + chrome.runtime.sendMessage({type: "dump-db"}, (resp) => { + const el = document.getElementById("dump"); if (!el) { throw Error(); } @@ -56,7 +56,7 @@ document.addEventListener("DOMContentLoaded", () => { document.getElementById("download")!.addEventListener("click", (evt) => { console.log("creating download"); - let element = document.createElement("a"); + const element = document.createElement("a"); element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(JSON.stringify(resp))); element.setAttribute("download", "wallet-dump.txt"); element.style.display = "none"; @@ -67,9 +67,9 @@ document.addEventListener("DOMContentLoaded", () => { }); - let fileInput = document.getElementById("fileInput")! as HTMLInputElement; + const fileInput = document.getElementById("fileInput")! as HTMLInputElement; fileInput.onchange = (evt) => { - if (!fileInput.files || fileInput.files.length != 1) { + if (!fileInput.files || fileInput.files.length !== 1) { alert("please select exactly one file to import"); return; } @@ -77,9 +77,9 @@ document.addEventListener("DOMContentLoaded", () => { const fr = new FileReader(); fr.onload = (e: any) => { console.log("got file"); - let dump = JSON.parse(e.target.result); + const dump = JSON.parse(e.target.result); console.log("parsed contents", dump); - chrome.runtime.sendMessage({ type: 'import-db', detail: { dump } }, (resp) => { + chrome.runtime.sendMessage({ type: "import-db", detail: { dump } }, (resp) => { alert("loaded"); }); }; |