diff --git a/.eslintrc.yml b/.eslintrc.yml index 8bded3c..3504314 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,6 +4,9 @@ extends: - plugin:import/errors - plugin:import/warnings +plugins: + - sort-imports-es6-autofix + parserOptions: ecmaVersion: 8 sourceType: module @@ -19,6 +22,8 @@ rules: no-unused-vars: - 2 - argsIgnorePattern: ^_ + sort-imports-es6-autofix/sort-imports-es6: + - 2 env: browser: true diff --git a/package.json b/package.json index aceeb42..61e9ab2 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "date-fns": "^2.21.1", "eslint": "^7.24.0", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-sort-imports-es6-autofix": "^0.6.0", "file-saver": "^2.0.5", "html-webpack-plugin": "^5.3.1", "i18next": "^20.2.1", diff --git a/src/api.js b/src/api.js index 85e6a2e..c7a2952 100644 --- a/src/api.js +++ b/src/api.js @@ -1,5 +1,5 @@ -import { getAPIURL, getToken, removeDoubleSlash } from "./utils.js"; import { DoesNotExistError } from "./types/internalErrors.js"; +import { getAPIURL, getToken, removeDoubleSlash } from "./utils.js"; export async function lookupSelf() { const request = new Request(getAPIURL() + "/v1/auth/token/lookup-self", { diff --git a/src/elements/CopyableInputBox.js b/src/elements/CopyableInputBox.js index b78c45a..7e1e3a0 100644 --- a/src/elements/CopyableInputBox.js +++ b/src/elements/CopyableInputBox.js @@ -1,7 +1,7 @@ -import ClipboardJS from "clipboard"; +import { MarginInline } from "./MarginInline.js"; import { addClipboardNotifications } from "../pageUtils.js"; import { makeElement } from "../htmlUtils.js"; -import { MarginInline } from "./MarginInline.js"; +import ClipboardJS from "clipboard"; import i18next from "i18next"; export function CopyableInputBox(text, copyable = true) { diff --git a/src/elements/CopyableModal.js b/src/elements/CopyableModal.js index 1c2c55a..e1a3ead 100644 --- a/src/elements/CopyableModal.js +++ b/src/elements/CopyableModal.js @@ -1,5 +1,5 @@ -import { makeElement } from "../htmlUtils.js"; import { addClipboardNotifications } from "../pageUtils.js"; +import { makeElement } from "../htmlUtils.js"; import ClipboardJS from "clipboard"; import FileSaver from 'file-saver'; import i18next from 'i18next'; diff --git a/src/elements/QRScanner.js b/src/elements/QRScanner.js index 191634a..f083e2f 100644 --- a/src/elements/QRScanner.js +++ b/src/elements/QRScanner.js @@ -1,5 +1,5 @@ -import { makeElement } from "../htmlUtils.js"; import { Margin } from "./Margin.js"; +import { makeElement } from "../htmlUtils.js"; import QrScanner from 'qr-scanner'; /* eslint-disable import/no-unresolved */ diff --git a/src/formatDistance.js b/src/formatDistance.js index 60bdef9..b2badf6 100644 --- a/src/formatDistance.js +++ b/src/formatDistance.js @@ -1,4 +1,4 @@ -import { de, enGB, fr, nl, ru, it } from 'date-fns/locale' +import { de, enGB, fr, it, nl, ru } from 'date-fns/locale' import { formatDistance as formatDistanceReal} from 'date-fns'; function getLocale() { diff --git a/src/main.js b/src/main.js index ad81fd5..f556cb7 100644 --- a/src/main.js +++ b/src/main.js @@ -3,44 +3,44 @@ // JS & CSS import "./scss/main.scss"; -import UIkit from 'uikit/dist/js/uikit.min.js'; import Icons from 'uikit/dist/js/uikit-icons.min.js'; +import UIkit from 'uikit/dist/js/uikit.min.js'; UIkit.use(Icons); -import Prism from "prismjs"; import "prismjs/components/prism-json"; +import Prism from "prismjs"; Prism.highlightAll(); +import { PageState } from "./PageState.js"; import { changePage, renderPage, } from "./pageUtils.js"; -import { PageState } from "./PageState.js"; -import { makeElement } from "./htmlUtils.js"; import { getSealStatus } from './api.js'; +import { makeElement } from "./htmlUtils.js"; // Pages import { HomePage, - MePage, - TOTPViewPage, - NewTOTPPage, - LoginPage, - SetVaultURLPage, - UnsealPage, - TransitViewPage, - TransitViewSecretPage, - TransitEncryptPage, - TransitDecryptPage, - KeyValueViewPage, + KeyValueDeletePage, + KeyValueNewPage, + KeyValueSecretEditPage, KeyValueSecretPage, KeyValueVersionsPage, - KeyValueNewPage, - KeyValueDeletePage, - KeyValueSecretEditPage, + KeyValueViewPage, + LoginPage, + MePage, + NewTOTPPage, PwGenPage, SetLanguagePage, + SetVaultURLPage, + TOTPViewPage, + TransitDecryptPage, + TransitEncryptPage, + TransitViewPage, + TransitViewSecretPage, + UnsealPage, } from "./pages"; const pages = { @@ -66,13 +66,13 @@ const pages = { }; // Translations -import i18next from 'i18next'; -import translation_en from './translations/en.js' -import translation_de from './translations/de.js' -import translation_ru from './translations/ru.js' -import translation_nl from './translations/nl.js' -import translation_fr from './translations/fr.js' import {formatDistance} from './formatDistance.js'; +import i18next from 'i18next'; +import translation_de from './translations/de.js' +import translation_en from './translations/en.js' +import translation_fr from './translations/fr.js' +import translation_nl from './translations/nl.js' +import translation_ru from './translations/ru.js' /*import "en-GB" as date_locale_en from 'date-fns/locale' diff --git a/src/pageUtils.js b/src/pageUtils.js index 21ea1c7..cdee964 100644 --- a/src/pageUtils.js +++ b/src/pageUtils.js @@ -1,6 +1,6 @@ -import { makeElement } from "./htmlUtils.js"; -import { lookupSelf, getSealStatus } from './api.js'; import { getAPIURL } from "./utils.js"; +import { getSealStatus, lookupSelf } from './api.js'; +import { makeElement } from "./htmlUtils.js"; import UIkit from 'uikit/dist/js/uikit.min.js'; import i18next from 'i18next'; @@ -15,14 +15,10 @@ async function prePageChecksReal() { throw new Error("Vault URL Not Set"); } - try { - let sealStatus = await getSealStatus(); - if (sealStatus.sealed) { - changePage("UNSEAL"); - throw new Error("Vault Sealed"); - } - } catch (e) { - throw e; + let sealStatus = await getSealStatus(); + if (sealStatus.sealed) { + changePage("UNSEAL"); + throw new Error("Vault Sealed"); } try { diff --git a/src/pages/Home.js b/src/pages/Home.js index 995c0b2..e59ecc9 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -1,8 +1,8 @@ import { Page } from "../types/Page.js"; -import { setErrorText, changePage, prePageChecks } from "../pageUtils.js"; -import { getAPIURL, getToken } from "../utils.js"; +import { changePage, prePageChecks, setErrorText } from "../pageUtils.js"; +import { getAPIURL } from "../utils.js"; +import { getMounts, lookupSelf } from "../api.js"; import { makeElement } from "../htmlUtils.js"; -import { getSealStatus, lookupSelf, getMounts } from "../api.js"; import i18next from 'i18next'; export class HomePage extends Page { diff --git a/src/pages/KeyValue/KeyValueDelete.js b/src/pages/KeyValue/KeyValueDelete.js index 6302ef6..c31ba74 100644 --- a/src/pages/KeyValue/KeyValueDelete.js +++ b/src/pages/KeyValue/KeyValueDelete.js @@ -1,6 +1,6 @@ import { Page } from "../../types/Page.js"; +import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js"; import { deleteSecret } from "../../api.js"; -import { setPageContent, setTitleElement, changePage } from "../../pageUtils.js"; import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; diff --git a/src/pages/KeyValue/KeyValueNew.js b/src/pages/KeyValue/KeyValueNew.js index 0d7ca07..eb9660e 100644 --- a/src/pages/KeyValue/KeyValueNew.js +++ b/src/pages/KeyValue/KeyValueNew.js @@ -1,6 +1,6 @@ import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { createOrUpdateSecret } from "../../api.js"; -import { setPageContent, setTitleElement, setErrorText, changePage } from "../../pageUtils.js"; import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; diff --git a/src/pages/KeyValue/KeyValueSecret.js b/src/pages/KeyValue/KeyValueSecret.js index 7afab96..d857a6b 100644 --- a/src/pages/KeyValue/KeyValueSecret.js +++ b/src/pages/KeyValue/KeyValueSecret.js @@ -1,7 +1,7 @@ -import { Page } from "../../types/Page.js"; -import { getSecret, undeleteSecret, getCapabilities } from "../../api.js"; -import { setPageContent, setTitleElement, changePage } from "../../pageUtils.js"; import { CopyableInputBox } from "../../elements/CopyableInputBox.js"; +import { Page } from "../../types/Page.js"; +import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js"; +import { getCapabilities, getSecret, undeleteSecret } from "../../api.js"; import { makeElement } from "../../htmlUtils.js"; import Prism from "prismjs"; import i18next from 'i18next'; diff --git a/src/pages/KeyValue/KeyValueSecretsEdit.js b/src/pages/KeyValue/KeyValueSecretsEdit.js index f7a39da..519b3fd 100644 --- a/src/pages/KeyValue/KeyValueSecretsEdit.js +++ b/src/pages/KeyValue/KeyValueSecretsEdit.js @@ -1,9 +1,9 @@ -import { Page } from "../../types/Page.js"; -import { getSecret, createOrUpdateSecret } from "../../api.js"; -import { verifyJSONString } from "../../utils.js"; -import { setPageContent, setTitleElement, setErrorText, changePage } from "../../pageUtils.js"; -import { makeElement } from "../../htmlUtils.js"; import { CodeJar } from "codejar"; +import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; +import { createOrUpdateSecret, getSecret } from "../../api.js"; +import { makeElement } from "../../htmlUtils.js"; +import { verifyJSONString } from "../../utils.js"; import i18next from 'i18next'; export class KeyValueSecretEditPage extends Page { diff --git a/src/pages/KeyValue/KeyValueVersions.js b/src/pages/KeyValue/KeyValueVersions.js index 32c2c23..5655c32 100644 --- a/src/pages/KeyValue/KeyValueVersions.js +++ b/src/pages/KeyValue/KeyValueVersions.js @@ -1,6 +1,6 @@ import { Page } from "../../types/Page.js"; +import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js"; import { getSecretMetadata } from "../../api.js"; -import { setPageContent, setTitleElement, changePage } from "../../pageUtils.js"; import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; diff --git a/src/pages/KeyValue/KeyValueView.js b/src/pages/KeyValue/KeyValueView.js index 293c511..f648ee3 100644 --- a/src/pages/KeyValue/KeyValueView.js +++ b/src/pages/KeyValue/KeyValueView.js @@ -1,8 +1,8 @@ -import { Page } from "../../types/Page.js"; -import { getSecrets } from "../../api.js"; -import { setErrorText, setTitleElement, changePage } from "../../pageUtils.js"; -import { makeElement } from "../../htmlUtils.js"; import { DoesNotExistError } from "../../types/internalErrors.js"; +import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js"; +import { getSecrets } from "../../api.js"; +import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; diff --git a/src/pages/Login.js b/src/pages/Login.js index 5889667..e3476e8 100644 --- a/src/pages/Login.js +++ b/src/pages/Login.js @@ -1,9 +1,9 @@ -import { Page } from "../types/Page.js"; -import { lookupSelf, usernameLogin } from "../api.js"; -import { setPageContent, setErrorText, changePage } from "../pageUtils.js"; -import { makeElement } from "../htmlUtils.js"; import { Margin } from "../elements/Margin.js"; import { MarginInline } from "../elements/MarginInline.js"; +import { Page } from "../types/Page.js"; +import { changePage, setErrorText, setPageContent } from "../pageUtils.js"; +import { lookupSelf, usernameLogin } from "../api.js"; +import { makeElement } from "../htmlUtils.js"; import i18next from 'i18next'; export class LoginPage extends Page { diff --git a/src/pages/Me.js b/src/pages/Me.js index 2fc84a8..e55111a 100644 --- a/src/pages/Me.js +++ b/src/pages/Me.js @@ -1,8 +1,8 @@ import { Page } from "../types/Page.js"; -import { addClipboardNotifications, setErrorText, setPageContent, changePage, prePageChecks } from "../pageUtils.js"; -import { makeElement } from "../htmlUtils.js"; +import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils.js"; +import { getCapabilitiesPath, renewSelf, sealVault } from "../api.js"; import { getToken } from "../utils.js"; -import { renewSelf, getCapabilitiesPath, sealVault } from "../api.js"; +import { makeElement } from "../htmlUtils.js"; import ClipboardJS from "clipboard"; import i18next from 'i18next'; diff --git a/src/pages/PwGen.js b/src/pages/PwGen.js index efd9f92..d370832 100644 --- a/src/pages/PwGen.js +++ b/src/pages/PwGen.js @@ -1,7 +1,7 @@ -import { Page } from "../types/Page.js"; -import { setPageContent } from "../pageUtils.js"; -import { makeElement } from "../htmlUtils.js"; import { CopyableInputBox } from "../elements/CopyableInputBox.js"; +import { Page } from "../types/Page.js"; +import { makeElement } from "../htmlUtils.js"; +import { setPageContent } from "../pageUtils.js"; import i18next from 'i18next'; diff --git a/src/pages/SetLanguage.js b/src/pages/SetLanguage.js index f9c9f3b..717e656 100644 --- a/src/pages/SetLanguage.js +++ b/src/pages/SetLanguage.js @@ -1,7 +1,7 @@ -import { Page } from "../types/Page.js"; -import { setPageContent, changePage } from "../pageUtils.js"; -import { makeElement } from "../htmlUtils.js"; import { Margin } from "../elements/Margin.js"; +import { Page } from "../types/Page.js"; +import { changePage, setPageContent } from "../pageUtils.js"; +import { makeElement } from "../htmlUtils.js"; import i18next from 'i18next'; let languages = ["en", "de", "nl", "ru", "fr"]; diff --git a/src/pages/SetVaultURL.js b/src/pages/SetVaultURL.js index 07532b3..0b457b7 100644 --- a/src/pages/SetVaultURL.js +++ b/src/pages/SetVaultURL.js @@ -1,5 +1,5 @@ import { Page } from "../types/Page.js"; -import { setPageContent, changePage } from "../pageUtils.js"; +import { changePage, setPageContent } from "../pageUtils.js"; import { makeElement } from "../htmlUtils.js"; export class SetVaultURLPage extends Page { diff --git a/src/pages/TOTP/NewTOTP.js b/src/pages/TOTP/NewTOTP.js index 27df540..fb0ae4e 100644 --- a/src/pages/TOTP/NewTOTP.js +++ b/src/pages/TOTP/NewTOTP.js @@ -1,9 +1,9 @@ -import { Page } from "../../types/Page.js"; -import { addNewTOTP } from "../../api.js"; -import { setTitleElement, setPageContent, setErrorText, changePage } from "../../pageUtils.js"; -import { makeElement } from "../../htmlUtils.js"; import { Margin } from "../../elements/Margin.js"; import { MarginInline } from "../../elements/MarginInline.js"; +import { Page } from "../../types/Page.js"; +import { addNewTOTP } from "../../api.js"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; +import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; export class NewTOTPPage extends Page { diff --git a/src/pages/TOTP/TOTPView.js b/src/pages/TOTP/TOTPView.js index 581ea40..c49ccfc 100644 --- a/src/pages/TOTP/TOTPView.js +++ b/src/pages/TOTP/TOTPView.js @@ -1,9 +1,9 @@ -import { Page } from "../../types/Page.js"; -import { getTOTPKeys, getTOTPCode } from "../../api.js"; -import { setTitleElement, setPageContent, changePage, setErrorText } from "../../pageUtils.js"; import { CopyableInputBox } from "../../elements/CopyableInputBox.js"; -import { makeElement } from "../../htmlUtils.js"; import { DoesNotExistError } from "../../types/internalErrors.js"; +import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; +import { getTOTPCode, getTOTPKeys } from "../../api.js"; +import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; export class TOTPViewPage extends Page { diff --git a/src/pages/Template.js b/src/pages/Template.js index abeaa7e..59256bb 100644 --- a/src/pages/Template.js +++ b/src/pages/Template.js @@ -1,5 +1,5 @@ import { Page } from "../types/Page.js"; -import { setPageContent, setTitleElement, changePage } from "../pageUtils.js"; +import { changePage, setPageContent, setTitleElement } from "../pageUtils.js"; import { makeElement } from "../htmlUtils.js"; export class TemplatePage extends Page { diff --git a/src/pages/Transit/TransitDecrypt.js b/src/pages/Transit/TransitDecrypt.js index f9f59e9..93a0a83 100644 --- a/src/pages/Transit/TransitDecrypt.js +++ b/src/pages/Transit/TransitDecrypt.js @@ -1,9 +1,9 @@ -import { Page } from "../../types/Page.js"; -import { transitDecrypt } from "../../api.js"; -import { setPageContent, setTitleElement, setErrorText, changePage } from "../../pageUtils.js"; -import { makeElement } from "../../htmlUtils.js"; -import { Margin } from "../../elements/Margin.js"; import { CopyableModal } from "../../elements/CopyableModal.js"; +import { Margin } from "../../elements/Margin.js"; +import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; +import { makeElement } from "../../htmlUtils.js"; +import { transitDecrypt } from "../../api.js"; import UIkit from 'uikit/dist/js/uikit.min.js'; import i18next from "i18next"; diff --git a/src/pages/Transit/TransitEncrypt.js b/src/pages/Transit/TransitEncrypt.js index 1edf957..5eeb598 100644 --- a/src/pages/Transit/TransitEncrypt.js +++ b/src/pages/Transit/TransitEncrypt.js @@ -1,9 +1,9 @@ -import { Page } from "../../types/Page.js"; -import { transitEncrypt } from "../../api.js"; -import { setPageContent, setTitleElement, setErrorText, changePage } from "../../pageUtils.js"; -import { makeElement } from "../../htmlUtils.js"; -import { Margin } from "../../elements/Margin.js"; import { CopyableModal } from "../../elements/CopyableModal.js"; +import { Margin } from "../../elements/Margin.js"; +import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; +import { makeElement } from "../../htmlUtils.js"; +import { transitEncrypt } from "../../api.js"; import UIkit from 'uikit/dist/js/uikit.min.js'; import i18next from "i18next"; diff --git a/src/pages/Transit/TransitView.js b/src/pages/Transit/TransitView.js index ba9bc8f..2d874c1 100644 --- a/src/pages/Transit/TransitView.js +++ b/src/pages/Transit/TransitView.js @@ -1,8 +1,8 @@ -import { Page } from "../../types/Page.js"; -import { getTransitKeys } from "../../api.js"; -import { setErrorText, setTitleElement, changePage } from "../../pageUtils.js"; -import { makeElement } from "../../htmlUtils.js"; import { DoesNotExistError } from "../../types/internalErrors.js"; +import { Page } from "../../types/Page.js"; +import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js"; +import { getTransitKeys } from "../../api.js"; +import { makeElement } from "../../htmlUtils.js"; import i18next from 'i18next'; export class TransitViewPage extends Page { diff --git a/src/pages/Unseal.js b/src/pages/Unseal.js index c2a85c3..dc0a068 100644 --- a/src/pages/Unseal.js +++ b/src/pages/Unseal.js @@ -1,11 +1,13 @@ -import { Page } from "../types/Page.js"; -import { submitUnsealKey, getSealStatus } from "../api.js"; -import { setPageContent, setErrorText, changePage } from "../pageUtils.js"; -import { makeElement } from "../htmlUtils.js"; -import { MarginInline } from "../elements/MarginInline.js"; -import { QRScanner } from "../elements/QRScanner.js"; import i18next from 'i18next'; +import { changePage, setErrorText, setPageContent } from "../pageUtils.js"; +import { getSealStatus, submitUnsealKey } from "../api.js"; + +import { MarginInline } from "../elements/MarginInline.js"; +import { Page } from "../types/Page.js"; +import { QRScanner } from "../elements/QRScanner.js"; +import { makeElement } from "../htmlUtils.js"; + const UnsealInputModes = { FORM_INPUT: "FORM_INPUT", QR_INPUT: "QR_INPUT"