diff options
author | Yuchen Pei <hi@ypei.me> | 2022-04-06 17:35:05 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-04-07 12:18:45 +1000 |
commit | 34bcc1a5c2750b6f6fa9d9b971ac8aff796ddd1c (patch) | |
tree | 8e2a4e27fd168c45bb9a5157e172822258417d13 /common | |
parent | 2e10129fa088584af25dcb34834551380e8f4521 (diff) |
linting
- eslint
- also adding eslintrc
Diffstat (limited to 'common')
-rw-r--r-- | common/Storage.js | 24 | ||||
-rw-r--r-- | common/Test.js | 6 |
2 files changed, 15 insertions, 15 deletions
diff --git a/common/Storage.js b/common/Storage.js index 47261c5..6254d66 100644 --- a/common/Storage.js +++ b/common/Storage.js @@ -23,7 +23,7 @@ A tiny wrapper around extensions storage API, supporting CSV serialization for retro-compatibility */ -"use strict"; +'use strict'; var Storage = { ARRAY: { @@ -45,7 +45,7 @@ var Storage = { }, async save(key, list) { - return await browser.storage.local.set({ [key]: [...list].join(",") }); + return await browser.storage.local.set({ [key]: [...list].join(',') }); } } }; @@ -68,20 +68,20 @@ class ListStore { static inlineItem(url) { // here we simplify and hash inline script references - return url.startsWith("inline:") ? url - : url.startsWith("view-source:") - && url.replace(/^view-source:[\w-+]+:\/+([^/]+).*#line\d+/, "inline://$1#") - .replace(/\n[^]*/, s => s.replace(/\s+/g, ' ').substring(0, 16) + "…" + hash(s.trim())); + return url.startsWith('inline:') ? url + : url.startsWith('view-source:') + && url.replace(/^view-source:[\w-+]+:\/+([^/]+).*#line\d+/, 'inline://$1#') + .replace(/\n[^]*/, s => s.replace(/\s+/g, ' ').substring(0, 16) + '…' + hash(s.trim())); } static hashItem(hash) { - return hash.startsWith("(") ? hash : `(${hash})`; + return hash.startsWith('(') ? hash : `(${hash})`; } static urlItem(url) { - let queryPos = url.indexOf("?"); + let queryPos = url.indexOf('?'); return queryPos === -1 ? url : url.substring(0, queryPos); } static siteItem(url) { - if (url.endsWith("/*")) return url; + if (url.endsWith('/*')) return url; try { return `${new URL(url).origin}/*`; } catch (e) { @@ -134,12 +134,12 @@ class ListStore { } function hash(source) { - var shaObj = new jssha("SHA-256", "TEXT") + var shaObj = new jssha('SHA-256', 'TEXT') shaObj.update(source); - return shaObj.getHash("HEX"); + return shaObj.getHash('HEX'); } -if (typeof module === "object") { +if (typeof module === 'object') { module.exports = { ListStore, Storage, hash }; var jssha = require('jssha'); } diff --git a/common/Test.js b/common/Test.js index 7acbfa0..88baff2 100644 --- a/common/Test.js +++ b/common/Test.js @@ -19,9 +19,9 @@ * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. */ -"use strict"; +'use strict'; var Test = (() => { - const RUNNER_URL = browser.extension.getURL("/test/SpecRunner.html"); + const RUNNER_URL = browser.extension.getURL('/test/SpecRunner.html'); return { /* returns RUNNER_URL if it's a test-enabled build or an about:debugging @@ -50,6 +50,6 @@ var Test = (() => { } }; })(); -if (typeof module === "object") { +if (typeof module === 'object') { module.exports = Test; } |