diff --git a/.eslintrc b/.eslintrc index cfac49d..2f63d64 100644 --- a/.eslintrc +++ b/.eslintrc @@ -50,6 +50,7 @@ "no-param-reassign": "off", "no-plusplus": "off", "no-prototype-builtins": "off", + "no-redeclare": "off", "no-restricted-globals": "off", "no-restricted-syntax": "off", "no-return-await": "off", @@ -59,11 +60,12 @@ "no-use-before-define": "off", "no-useless-escape": "off", "no-useless-return": "off", - "no-var": "off", + "no-var": "error", "object-curly-spacing": ["warn", "always"], "object-shorthand": "off", "operator-linebreak": "off", "prefer-arrow-callback": "off", + "prefer-const": "warn", "prefer-destructuring": "off", "prefer-template": "off", "quote-props": "off", @@ -89,6 +91,7 @@ "assertTOTPField": true, "AssociatedAction": true, "Autocomplete": true, + "BLUE_BUTTON": true, "bootstrap": true, "browser": true, "browserAction": true, @@ -102,7 +105,10 @@ "debugLogMessage": true, "EXTENSION_NAME": true, "getCurrentTab": true, + "getLoginData": true, "getTopLevelDomainFromUrl": true, + "GRAY_BUTTON_CLASS": true, + "GREEN_BUTTON": true, "httpAuth": true, "Icon": true, "IGNORE_AUTOSUBMIT": true, @@ -148,13 +154,14 @@ "MIN_OPACITY": true, "MIN_TOTP_INPUT_LENGTH": true, "nacl": true, + "ORANGE_BUTTON": true, "page": true, "Pixels": true, "PREDEFINED_SITELIST": true, + "RED_BUTTON": true, "resizePopup": true, "sendMessage": true, "showNotification": true, - "useMonochromToolbarIcon": false, "siteMatch": true, "slashNeededForUrl": true, "SORT_BY_GROUP_AND_TITLE": true, @@ -166,6 +173,15 @@ "statusResponse": true, "Tests": true, "tr": true, - "trimURL": true - } + "trimURL": true, + "useMonochromToolbarIcon": true + }, + "overrides": [ + { + "files": ["./*.js"], + "env": { + "node": true + } + } + ] } diff --git a/.gitignore b/.gitignore index a667390..a592d53 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ .bz .bz2 .xz -node_modules/* +node_modules diff --git a/build.js b/build.js old mode 100644 new mode 100755 index 42c968a..a5c6a40 --- a/build.js +++ b/build.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node 'use strict'; const fs = require('@npmcli/fs'); diff --git a/keepassxc-browser/background/browserAction.js b/keepassxc-browser/background/browserAction.js index c61920d..7b6a7af 100755 --- a/keepassxc-browser/background/browserAction.js +++ b/keepassxc-browser/background/browserAction.js @@ -54,16 +54,16 @@ browserAction.generateIconName = function(iconType) { let name = 'icon_'; name += (keepass.keePassXCUpdateAvailable()) ? 'new_' : ''; name += (!iconType || iconType === 'normal') ? 'normal' : iconType; - - let style = 'colored' + + let style = 'colored'; if (page.settings.useMonochromeToolbarIcon) { - if (page.settings.colorTheme == 'system') { + if (page.settings.colorTheme === 'system') { style = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; - } else { - style = page.settings.colorTheme; - } + } else { + style = page.settings.colorTheme; + } } - let filetype = (isFirefox() ? 'svg' : 'png') + const filetype = (isFirefox() ? 'svg' : 'png'); return `/icons/toolbar/${style}/${name}.${filetype}`; }; diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js index a59aa78..1c72400 100755 --- a/keepassxc-browser/background/page.js +++ b/keepassxc-browser/background/page.js @@ -34,7 +34,7 @@ const defaultSettings = { const AUTO_SUBMIT_TIMEOUT = 5000; -var page = {}; +const page = {}; page.autoSubmitPerformed = false; page.attributeMenuItemIds = []; page.blockedTabs = []; @@ -310,8 +310,8 @@ page.updateContextMenu = async function(tab, credentials) { // Show username inside [] if there are KPH attributes inside multiple credentials const attributeName = Object.keys(attribute)[0].slice(5); const finalName = credentials.length > 1 - ? `[${cred.login}] ${attributeName}` - : attributeName; + ? `[${cred.login}] ${attributeName}` + : attributeName; page.attributeMenuItemIds.push(createContextMenuItem({ action: 'fill_attribute', @@ -325,7 +325,7 @@ page.updateContextMenu = async function(tab, credentials) { page.updatePopup = function(tab) { browserAction.showDefault(tab); -} +}; const createContextMenuItem = function({ action, args, ...options }) { return browser.contextMenus.create({ diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 743940e..a75c5d3 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -262,8 +262,8 @@ kpxc.initCombinations = async function(inputs = []) { } const combinations = isCustomLoginFieldsUsed - ? await kpxcFields.useCustomLoginFields() - : await kpxcFields.getAllCombinations(inputs); + ? await kpxcFields.useCustomLoginFields() + : await kpxcFields.getAllCombinations(inputs); if (!combinations || combinations.length === 0) { if (isCustomLoginFieldsUsed) { kpxcUI.createNotification('warning', tr('optionsCustomFieldsNotFound')); @@ -343,8 +343,8 @@ kpxc.initLoginPopup = function() { // Returns a login item with additional information for sorting const getLoginItem = function(credential, withGroup, loginId) { const title = credential.name.length < MAX_AUTOCOMPLETE_NAME_LEN - ? credential.name - : credential.name.substr(0, MAX_AUTOCOMPLETE_NAME_LEN) + '…'; + ? credential.name + : credential.name.substr(0, MAX_AUTOCOMPLETE_NAME_LEN) + '…'; const group = (withGroup && credential.group) ? `[${credential.group}] ` : ''; const visibleLogin = (credential.login.length > 0) ? credential.login : tr('credentialsNoUsername'); let text = `${group}${title} (${visibleLogin})`; diff --git a/keepassxc-browser/content/totp-field.js b/keepassxc-browser/content/totp-field.js index 3192d35..1ed6f50 100644 --- a/keepassxc-browser/content/totp-field.js +++ b/keepassxc-browser/content/totp-field.js @@ -24,7 +24,7 @@ const acceptedParents = [ '.mfa-verify', ]; -var kpxcTOTPIcons = {}; +const kpxcTOTPIcons = {}; kpxcTOTPIcons.icons = []; kpxcTOTPIcons.newIcon = function(field, databaseState = DatabaseState.DISCONNECTED, segmented = false) { diff --git a/keepassxc-browser/content/ui.js b/keepassxc-browser/content/ui.js index e3293d3..1b7d11c 100644 --- a/keepassxc-browser/content/ui.js +++ b/keepassxc-browser/content/ui.js @@ -153,8 +153,8 @@ kpxcUI.setIconPosition = function(icon, field, rtl = false, segmented = false) { const scrollLeft = kpxcUI.getScrollLeft(); icon.style.top = Pixels(top + scrollTop + offset + 1); icon.style.left = rtl - ? Pixels((left + scrollLeft) + offset) - : Pixels(left + scrollLeft + field.offsetWidth - size - offset); + ? Pixels((left + scrollLeft) + offset) + : Pixels(left + scrollLeft + field.offsetWidth - size - offset); }; kpxcUI.getScrollTop = function() { diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html index f000033..4ea88ae 100644 --- a/keepassxc-browser/options/options.html +++ b/keepassxc-browser/options/options.html @@ -33,34 +33,34 @@
@@ -195,7 +196,7 @@
+
- +
- +
- +