From ae3be13aa816abec0d84a481580617a97852a6ba Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Fri, 19 Jan 2024 23:02:21 +0000 Subject: [PATCH] :fire: removing unused variables (batch 1) (#2255) --- packages/api/methods.js | 4 ---- .../components/modals/ImportTransactions.jsx | 20 +++++++++---------- .../components/reports/CategorySelector.tsx | 6 +++--- .../src/components/rules/RulesHeader.tsx | 2 +- .../components/schedules/SchedulesTable.tsx | 3 +-- .../src/components/select/DateSelect.tsx | 2 +- .../src/components/sidebar/Accounts.tsx | 8 ++++---- .../desktop-client/src/components/table.tsx | 8 ++------ .../transactions/SimpleTransactionsTable.jsx | 2 -- .../transactions/TransactionsTable.test.jsx | 2 +- .../src/components/util/AmountInput.tsx | 1 - packages/desktop-electron/security.js | 6 +++--- packages/desktop-electron/updater.js | 6 +++--- .../migrations/1632571489012_remove_cache.js | 2 +- .../loot-core/src/client/actions/account.ts | 2 +- .../loot-core/src/client/actions/queries.ts | 2 +- .../src/client/query-helpers.test.ts | 4 ++-- .../src/platform/client/fetch/index.web.ts | 2 +- .../src/platform/exceptions/index.browser.ts | 2 +- .../src/platform/exceptions/index.electron.ts | 2 +- .../src/platform/exceptions/index.testing.ts | 4 ++-- .../src/platform/exceptions/index.web.ts | 2 +- .../platform/server/asyncStorage/index.web.ts | 8 ++++---- .../platform/server/connection/index.api.ts | 2 +- .../src/platform/server/fs/index.web.ts | 2 +- .../platform/server/indexeddb/index.web.ts | 8 ++++---- .../loot-core/src/server/__mocks__/post.ts | 2 +- .../src/server/accounts/rules.test.ts | 2 +- .../loot-core/src/server/accounts/rules.ts | 4 ++-- packages/loot-core/src/server/api.ts | 6 +----- packages/loot-core/src/server/aql/compiler.ts | 2 +- packages/loot-core/src/server/bench.ts | 2 +- .../loot-core/src/server/cloud-storage.ts | 2 +- packages/loot-core/src/server/db/index.ts | 9 --------- .../loot-core/src/server/importers/actual.ts | 2 +- .../loot-core/src/server/importers/ynab4.ts | 4 ++-- packages/loot-core/src/server/main.ts | 2 +- packages/loot-core/src/server/migrate/cli.ts | 2 +- .../loot-core/src/server/schedules/app.ts | 2 +- .../src/server/schedules/find-schedules.ts | 20 ++++--------------- .../src/server/spreadsheet/spreadsheet.ts | 2 +- packages/loot-core/src/server/sync/index.ts | 2 +- .../src/server/tests/mockSyncServer.ts | 2 +- packages/loot-core/src/shared/async.test.ts | 4 ++-- .../loot-core/src/types/api-handlers.d.ts | 3 --- upcoming-release-notes/2255.md | 6 ++++++ 46 files changed, 79 insertions(+), 113 deletions(-) create mode 100644 upcoming-release-notes/2255.md diff --git a/packages/api/methods.js b/packages/api/methods.js index 9af541f2670..5ca8226c47f 100644 --- a/packages/api/methods.js +++ b/packages/api/methods.js @@ -79,10 +79,6 @@ export function getTransactions(accountId, startDate, endDate) { return send('api/transactions-get', { accountId, startDate, endDate }); } -export function filterTransactions(accountId, text) { - return send('api/transactions-filter', { accountId, text }); -} - export function updateTransaction(id, fields) { return send('api/transaction-update', { id, fields }); } diff --git a/packages/desktop-client/src/components/modals/ImportTransactions.jsx b/packages/desktop-client/src/components/modals/ImportTransactions.jsx index db53af08937..53b289d3fff 100644 --- a/packages/desktop-client/src/components/modals/ImportTransactions.jsx +++ b/packages/desktop-client/src/components/modals/ImportTransactions.jsx @@ -132,7 +132,7 @@ function getFileType(filepath) { return rawType; } -function ParsedDate({ parseDateFormat, showParsed, dateFormat, date }) { +function ParsedDate({ parseDateFormat, dateFormat, date }) { const parsed = date && formatDate( @@ -184,29 +184,29 @@ function getInitialMappings(transactions) { } const dateField = key( - fields.find(([name, value]) => name.toLowerCase().includes('date')) || - fields.find(([name, value]) => value.match(/^\d+[-/]\d+[-/]\d+$/)), + fields.find(([name]) => name.toLowerCase().includes('date')) || + fields.find(([, value]) => value.match(/^\d+[-/]\d+[-/]\d+$/)), ); const amountField = key( - fields.find(([name, value]) => name.toLowerCase().includes('amount')) || - fields.find(([name, value]) => value.match(/^-?[.,\d]+$/)), + fields.find(([name]) => name.toLowerCase().includes('amount')) || + fields.find(([, value]) => value.match(/^-?[.,\d]+$/)), ); const categoryField = key( - fields.find(([name, value]) => name.toLowerCase().includes('category')), + fields.find(([name]) => name.toLowerCase().includes('category')), ); const payeeField = key( fields.find( - ([name, value]) => + ([name]) => name !== dateField && name !== amountField && name !== categoryField, ), ); const notesField = key( fields.find( - ([name, value]) => + ([name]) => name !== dateField && name !== amountField && name !== categoryField && @@ -216,7 +216,7 @@ function getInitialMappings(transactions) { const inOutField = key( fields.find( - ([name, value]) => + ([name]) => name !== dateField && name !== amountField && name !== payeeField && @@ -1019,7 +1019,7 @@ export function ImportTransactions({ modalProps, options }) { ); }} - renderItem={({ key, style, item, editing, focusedField }) => ( + renderItem={({ key, style, item }) => ( { + onChange={() => { const selectedCategoriesExcludingGroupCategories = selectedCategories.filter( selectedCategory => @@ -189,7 +189,7 @@ export function CategorySelector({ paddingLeft: 10, }} > - {categoryGroup.categories.map((category, index) => { + {categoryGroup.categories.map(category => { const isChecked = selectedCategories.some( selectedCategory => selectedCategory.id === category.id, ); @@ -206,7 +206,7 @@ export function CategorySelector({ { + onChange={() => { if (isChecked) { setSelectedCategories( selectedCategories.filter( diff --git a/packages/desktop-client/src/components/rules/RulesHeader.tsx b/packages/desktop-client/src/components/rules/RulesHeader.tsx index c4dbfacf790..40ac46cf06c 100644 --- a/packages/desktop-client/src/components/rules/RulesHeader.tsx +++ b/packages/desktop-client/src/components/rules/RulesHeader.tsx @@ -8,7 +8,7 @@ export function RulesHeader() { const dispatchSelected = useSelectedDispatch(); return ( - + - + Name Payee Account @@ -365,7 +365,6 @@ export function SchedulesTable({ { + onPointerUp={() => { if (!embedded) { setOpen(true); } diff --git a/packages/desktop-client/src/components/sidebar/Accounts.tsx b/packages/desktop-client/src/components/sidebar/Accounts.tsx index c77a9ae365c..cd20ccb5856 100644 --- a/packages/desktop-client/src/components/sidebar/Accounts.tsx +++ b/packages/desktop-client/src/components/sidebar/Accounts.tsx @@ -78,7 +78,7 @@ export function Accounts({ setIsDragging(drag.state === 'start'); } - const makeDropPadding = (i, length) => { + const makeDropPadding = i => { if (i === 0) { return { paddingTop: isDragging ? 15 : 0, @@ -118,7 +118,7 @@ export function Accounts({ query={getBalanceQuery(account)} onDragChange={onDragChange} onDrop={onReorder} - outerStyle={makeDropPadding(i, budgetedAccounts.length)} + outerStyle={makeDropPadding(i)} /> ))} @@ -143,7 +143,7 @@ export function Accounts({ query={getBalanceQuery(account)} onDragChange={onDragChange} onDrop={onReorder} - outerStyle={makeDropPadding(i, offbudgetAccounts.length)} + outerStyle={makeDropPadding(i)} /> ))} @@ -157,7 +157,7 @@ export function Accounts({ )} {showClosedAccounts && - closedAccounts.map((account, i) => ( + closedAccounts.map(account => ( & { headers?: Array>; - version?: string; }; export function TableHeader({ headers, children, - version, ...rowProps }: TableHeaderProps) { return ( @@ -853,7 +851,7 @@ type TableWithNavigatorProps = TableProps & { export const TableWithNavigator = forwardRef< TableHandleRef, TableWithNavigatorProps ->(({ fields, ...props }, ref) => { +>(({ fields, ...props }) => { const navigator = useTableNavigator(props.items, fields); return
; }); @@ -883,7 +881,6 @@ type TableProps = { navigator?: ReturnType>; listRef?: unknown; onScroll?: () => void; - version?: string; allowPopupsEscape?: boolean; isSelected?: (id: TableItem['id']) => boolean; saveScrollWidth?: (parent, child) => void; @@ -906,7 +903,6 @@ export const Table = forwardRef( style, navigator, onScroll, - version = 'v1', allowPopupsEscape, isSelected, saveScrollWidth, @@ -1045,7 +1041,7 @@ export const Table = forwardRef( ); } - function onItemsRendered({ overscanStartIndex, overscanStopIndex }) { + function onItemsRendered({ overscanStopIndex }) { if (loadMore && overscanStopIndex > items.length - 100) { loadMore(); } diff --git a/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.jsx b/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.jsx index bc849565393..4d6f6610a6d 100644 --- a/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.jsx +++ b/packages/desktop-client/src/components/transactions/SimpleTransactionsTable.jsx @@ -36,7 +36,6 @@ function serializeTransaction(transaction, dateFormat) { const TransactionRow = memo(function TransactionRow({ transaction, fields, - payees, categories, accounts, selected, @@ -137,7 +136,6 @@ const TransactionRow = memo(function TransactionRow({ export function SimpleTransactionsTable({ transactions, - schedules, renderEmpty, fields = ['date', 'payee', 'amount'], style, diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx index 56bf5d3cf75..2d1e51c2e9c 100644 --- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx +++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx @@ -765,7 +765,7 @@ describe('Transactions', () => { updateProps({ transactions }); function expectErrorToNotExist(transactions) { - transactions.forEach((transaction, idx) => { + transactions.forEach(transaction => { expect(transaction.error).toBeFalsy(); }); } diff --git a/packages/desktop-client/src/components/util/AmountInput.tsx b/packages/desktop-client/src/components/util/AmountInput.tsx index 151936a042b..fd110d6817f 100644 --- a/packages/desktop-client/src/components/util/AmountInput.tsx +++ b/packages/desktop-client/src/components/util/AmountInput.tsx @@ -46,7 +46,6 @@ export function AmountInput({ textStyle, focused, disabled = false, - ...props }: AmountInputProps) { const format = useFormat(); const negative = (initialValue === 0 && zeroSign === '-') || initialValue < 0; diff --git a/packages/desktop-electron/security.js b/packages/desktop-electron/security.js index e961bf7e5fb..8e8a9934db5 100644 --- a/packages/desktop-electron/security.js +++ b/packages/desktop-electron/security.js @@ -1,7 +1,7 @@ const electron = require('electron'); electron.app.on('web-contents-created', function (event, contents) { - contents.on('will-attach-webview', function (event, webPreferences, params) { + contents.on('will-attach-webview', function (event, webPreferences) { delete webPreferences.preloadURL; delete webPreferences.preload; @@ -15,11 +15,11 @@ electron.app.on('web-contents-created', function (event, contents) { event.preventDefault(); }); - contents.on('will-navigate', (event, navigationUrl) => { + contents.on('will-navigate', event => { event.preventDefault(); }); - contents.on('new-window', (event, navigationUrl) => { + contents.on('new-window', event => { event.preventDefault(); }); }); diff --git a/packages/desktop-electron/updater.js b/packages/desktop-electron/updater.js index 3a9edae4be5..5c95e745d1c 100644 --- a/packages/desktop-electron/updater.js +++ b/packages/desktop-electron/updater.js @@ -43,7 +43,7 @@ function fireEvent(type, args) { lastEvent = type; } -function start(handler) { +function start() { if (updateTimer) { return null; } @@ -53,7 +53,7 @@ function start(handler) { updateTimer = setInterval(() => { if (!isCheckingForUpdates) { - autoUpdater.checkForUpdates().catch(err => { + autoUpdater.checkForUpdates().catch(() => { // Do nothing with the error (make sure it's not logged to sentry) }); } @@ -74,7 +74,7 @@ function stop() { function check() { if (!isDev && !isCheckingForUpdates) { - autoUpdater.checkForUpdates().catch(err => { + autoUpdater.checkForUpdates().catch(() => { // Do nothing with the error (make sure it's not logged to sentry) }); } diff --git a/packages/loot-core/migrations/1632571489012_remove_cache.js b/packages/loot-core/migrations/1632571489012_remove_cache.js index bbd3e213849..77fdac7962c 100644 --- a/packages/loot-core/migrations/1632571489012_remove_cache.js +++ b/packages/loot-core/migrations/1632571489012_remove_cache.js @@ -1,4 +1,4 @@ -export default async function runMigration(db, uuid) { +export default async function runMigration(db) { function getValue(node) { return node.expr != null ? node.expr : node.cachedValue; } diff --git a/packages/loot-core/src/client/actions/account.ts b/packages/loot-core/src/client/actions/account.ts index 8dcdfe599c0..3591f96a866 100644 --- a/packages/loot-core/src/client/actions/account.ts +++ b/packages/loot-core/src/client/actions/account.ts @@ -200,7 +200,7 @@ export function setLastTransaction( } export function parseTransactions(filepath, options) { - return async (dispatch: Dispatch) => { + return async () => { return await send('transactions-parse-file', { filepath, options, diff --git a/packages/loot-core/src/client/actions/queries.ts b/packages/loot-core/src/client/actions/queries.ts index 1cb86185fa8..1e2082d1249 100644 --- a/packages/loot-core/src/client/actions/queries.ts +++ b/packages/loot-core/src/client/actions/queries.ts @@ -221,7 +221,7 @@ export function updateGroup(group) { } export function deleteGroup(id, transferId?) { - return async function (dispatch, getState) { + return async function (dispatch) { await send('category-group-delete', { id, transferId }); await dispatch(getCategories()); // See `deleteCategory` for why we need this diff --git a/packages/loot-core/src/client/query-helpers.test.ts b/packages/loot-core/src/client/query-helpers.test.ts index a5ab249d287..81d703b976f 100644 --- a/packages/loot-core/src/client/query-helpers.test.ts +++ b/packages/loot-core/src/client/query-helpers.test.ts @@ -362,7 +362,7 @@ describe('query helpers', () => { await tracer.expect('server-query', [{ result: { $count: '*' } }]); await tracer.expect('server-query', ['id']); - await tracer.expect('data', data => {}); + await tracer.expect('data', () => {}); paged.fetchNext(); paged.fetchNext(); @@ -370,7 +370,7 @@ describe('query helpers', () => { paged.fetchNext(); await tracer.expect('server-query', ['id']); - await tracer.expect('data', data => {}); + await tracer.expect('data', () => {}); // Wait a bit and make sure nothing comes through const p = Promise.race([tracer.expect('server-query'), wait(200)]); diff --git a/packages/loot-core/src/platform/client/fetch/index.web.ts b/packages/loot-core/src/platform/client/fetch/index.web.ts index 83fb068843f..055871e885a 100644 --- a/packages/loot-core/src/platform/client/fetch/index.web.ts +++ b/packages/loot-core/src/platform/client/fetch/index.web.ts @@ -134,7 +134,7 @@ export const unlisten: T.Unlisten = function (name) { }; async function closeSocket(onClose) { - socketClient.onclose = event => { + socketClient.onclose = () => { socketClient = null; onClose(); }; diff --git a/packages/loot-core/src/platform/exceptions/index.browser.ts b/packages/loot-core/src/platform/exceptions/index.browser.ts index 56ccc5c37bb..95adc82959a 100644 --- a/packages/loot-core/src/platform/exceptions/index.browser.ts +++ b/packages/loot-core/src/platform/exceptions/index.browser.ts @@ -4,4 +4,4 @@ export const captureException: T.CaptureException = function (exc) { console.log('[Exception]', exc); }; -export const captureBreadcrumb: T.CaptureBreadcrumb = function (breadcrumb) {}; +export const captureBreadcrumb: T.CaptureBreadcrumb = function () {}; diff --git a/packages/loot-core/src/platform/exceptions/index.electron.ts b/packages/loot-core/src/platform/exceptions/index.electron.ts index 56ccc5c37bb..95adc82959a 100644 --- a/packages/loot-core/src/platform/exceptions/index.electron.ts +++ b/packages/loot-core/src/platform/exceptions/index.electron.ts @@ -4,4 +4,4 @@ export const captureException: T.CaptureException = function (exc) { console.log('[Exception]', exc); }; -export const captureBreadcrumb: T.CaptureBreadcrumb = function (breadcrumb) {}; +export const captureBreadcrumb: T.CaptureBreadcrumb = function () {}; diff --git a/packages/loot-core/src/platform/exceptions/index.testing.ts b/packages/loot-core/src/platform/exceptions/index.testing.ts index 988d67f8266..82e6c5422d3 100644 --- a/packages/loot-core/src/platform/exceptions/index.testing.ts +++ b/packages/loot-core/src/platform/exceptions/index.testing.ts @@ -1,5 +1,5 @@ import type * as T from '.'; -export const captureException: T.CaptureException = function (exc) {}; +export const captureException: T.CaptureException = function () {}; -export const captureBreadcrumb: T.CaptureBreadcrumb = function (info) {}; +export const captureBreadcrumb: T.CaptureBreadcrumb = function () {}; diff --git a/packages/loot-core/src/platform/exceptions/index.web.ts b/packages/loot-core/src/platform/exceptions/index.web.ts index 56ccc5c37bb..95adc82959a 100644 --- a/packages/loot-core/src/platform/exceptions/index.web.ts +++ b/packages/loot-core/src/platform/exceptions/index.web.ts @@ -4,4 +4,4 @@ export const captureException: T.CaptureException = function (exc) { console.log('[Exception]', exc); }; -export const captureBreadcrumb: T.CaptureBreadcrumb = function (breadcrumb) {}; +export const captureBreadcrumb: T.CaptureBreadcrumb = function () {}; diff --git a/packages/loot-core/src/platform/server/asyncStorage/index.web.ts b/packages/loot-core/src/platform/server/asyncStorage/index.web.ts index 1243f97b666..c9bc80c7f7a 100644 --- a/packages/loot-core/src/platform/server/asyncStorage/index.web.ts +++ b/packages/loot-core/src/platform/server/asyncStorage/index.web.ts @@ -34,7 +34,7 @@ export const setItem: T.SetItem = async function (key, value) { new Promise((resolve, reject) => { const req = objectStore.put(value, key); req.onerror = e => reject(e); - req.onsuccess = e => resolve(undefined); + req.onsuccess = () => resolve(undefined); commit(transaction); }); }; @@ -48,7 +48,7 @@ export const removeItem: T.RemoveItem = async function (key) { return new Promise((resolve, reject) => { const req = objectStore.delete(key); req.onerror = e => reject(e); - req.onsuccess = e => resolve(undefined); + req.onsuccess = () => resolve(undefined); commit(transaction); }); }; @@ -84,7 +84,7 @@ export const multiSet: T.MultiSet = async function (keyValues) { return new Promise((resolve, reject) => { const req = objectStore.put(value, key); req.onerror = e => reject(e); - req.onsuccess = e => resolve(undefined); + req.onsuccess = () => resolve(undefined); }); }), ); @@ -104,7 +104,7 @@ export const multiRemove: T.MultiRemove = async function (keys) { return new Promise((resolve, reject) => { const req = objectStore.delete(key); req.onerror = e => reject(e); - req.onsuccess = e => resolve(undefined); + req.onsuccess = () => resolve(undefined); }); }), ); diff --git a/packages/loot-core/src/platform/server/connection/index.api.ts b/packages/loot-core/src/platform/server/connection/index.api.ts index a28c787ae81..1aacd8372fa 100644 --- a/packages/loot-core/src/platform/server/connection/index.api.ts +++ b/packages/loot-core/src/platform/server/connection/index.api.ts @@ -2,7 +2,7 @@ import type * as T from '.'; export const init: T.Init = function () {}; -export const send: T.Send = function (type, args) { +export const send: T.Send = function () { // Nothing }; diff --git a/packages/loot-core/src/platform/server/fs/index.web.ts b/packages/loot-core/src/platform/server/fs/index.web.ts index 370a087d2d2..06eebb13ade 100644 --- a/packages/loot-core/src/platform/server/fs/index.web.ts +++ b/packages/loot-core/src/platform/server/fs/index.web.ts @@ -313,7 +313,7 @@ export const removeDirRecursively = async function (dirpath) { } }; -export const getModifiedTime = async function (filepath) { +export const getModifiedTime = async function () { throw new Error( 'getModifiedTime not supported on the web (only used for backups)', ); diff --git a/packages/loot-core/src/platform/server/indexeddb/index.web.ts b/packages/loot-core/src/platform/server/indexeddb/index.web.ts index 65f2dc7c86c..f7396545491 100644 --- a/packages/loot-core/src/platform/server/indexeddb/index.web.ts +++ b/packages/loot-core/src/platform/server/indexeddb/index.web.ts @@ -34,7 +34,7 @@ function _openDatabase() { openRequest.onblocked = e => console.log('blocked', e); - openRequest.onerror = event => { + openRequest.onerror = () => { console.log('openRequest error'); reject(new Error('indexeddb-failure: Could not open IndexedDB')); }; @@ -102,7 +102,7 @@ export const getStore: T.GetStore = function (db, name) { export const get: T.Get = async function (store, key, mapper = x => x) { return new Promise((resolve, reject) => { const req = store.get(key); - req.onsuccess = e => { + req.onsuccess = () => { resolve(mapper(req.result)); }; req.onerror = e => reject(e); @@ -112,7 +112,7 @@ export const get: T.Get = async function (store, key, mapper = x => x) { export const set: T.Set = async function (store, item) { return new Promise((resolve, reject) => { const req = store.put(item); - req.onsuccess = e => resolve(undefined); + req.onsuccess = () => resolve(undefined); req.onerror = e => reject(e); }); }; @@ -120,7 +120,7 @@ export const set: T.Set = async function (store, item) { export const del: T.Del = async function (store, key) { return new Promise((resolve, reject) => { const req = store.delete(key); - req.onsuccess = e => resolve(undefined); + req.onsuccess = () => resolve(undefined); req.onerror = e => reject(e); }); }; diff --git a/packages/loot-core/src/server/__mocks__/post.ts b/packages/loot-core/src/server/__mocks__/post.ts index 1eb6e4263a6..2040820551a 100644 --- a/packages/loot-core/src/server/__mocks__/post.ts +++ b/packages/loot-core/src/server/__mocks__/post.ts @@ -4,6 +4,6 @@ export { handleRequestBinary as postBinary, } from '../tests/mockSyncServer'; -export const get = function (url) { +export const get = function () { throw new Error('get unimplemented'); }; diff --git a/packages/loot-core/src/server/accounts/rules.test.ts b/packages/loot-core/src/server/accounts/rules.test.ts index 32389523355..8368131e657 100644 --- a/packages/loot-core/src/server/accounts/rules.test.ts +++ b/packages/loot-core/src/server/accounts/rules.test.ts @@ -490,7 +490,7 @@ describe('Rule', () => { ]; const foundRules = []; - iterateIds(rules, 'description', (rule, value) => { + iterateIds(rules, 'description', rule => { foundRules.push(rule.getId()); }); expect(foundRules).toEqual(['first', 'second', 'second', 'third']); diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index 0a514f75855..96b33b52512 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -520,7 +520,7 @@ export class Rule { }); } - execActions(object) { + execActions() { const changes = {}; this.actions.forEach(action => action.exec(changes)); return changes; @@ -528,7 +528,7 @@ export class Rule { exec(object) { if (this.evalConditions(object)) { - return this.execActions(object); + return this.execActions(); } return null; } diff --git a/packages/loot-core/src/server/api.ts b/packages/loot-core/src/server/api.ts index 9c42e25a606..a89625971e9 100644 --- a/packages/loot-core/src/server/api.ts +++ b/packages/loot-core/src/server/api.ts @@ -253,7 +253,7 @@ handlers['api/finish-import'] = async function () { await handlers['get-budget-bounds'](); await sheet.waitOnSpreadsheet(); - await cloudStorage.upload().catch(err => {}); + await cloudStorage.upload().catch(() => {}); connection.send('finish-import'); IMPORT_MODE = false; @@ -426,10 +426,6 @@ handlers['api/transactions-get'] = async function ({ return data; }; -handlers['api/transactions-filter'] = async function ({ text, accountId }) { - throw new Error('`filterTransactions` is deprecated, use `runQuery` instead'); -}; - handlers['api/transaction-update'] = withMutation(async function ({ id, fields, diff --git a/packages/loot-core/src/server/aql/compiler.ts b/packages/loot-core/src/server/aql/compiler.ts index e5c6397bbc0..8c6bb76b7d5 100644 --- a/packages/loot-core/src/server/aql/compiler.ts +++ b/packages/loot-core/src/server/aql/compiler.ts @@ -1015,7 +1015,7 @@ export function compileQuery( const { tableViews = {}, - tableFilters = name => [], + tableFilters = () => [], customizeQuery = queryState => queryState, } = schemaConfig; diff --git a/packages/loot-core/src/server/bench.ts b/packages/loot-core/src/server/bench.ts index ec2ff9fc0e4..46074934266 100644 --- a/packages/loot-core/src/server/bench.ts +++ b/packages/loot-core/src/server/bench.ts @@ -9,7 +9,7 @@ const queries = fs .split('___BOUNDARY') .map(q => q.trim()); -function runQueries(n?) { +function runQueries() { for (let i = 0; i < queries.length; i++) { if (queries[i] !== '') { db.runQuery(queries[i], [], true); diff --git a/packages/loot-core/src/server/cloud-storage.ts b/packages/loot-core/src/server/cloud-storage.ts index c4735c5ae06..7be08444ff5 100644 --- a/packages/loot-core/src/server/cloud-storage.ts +++ b/packages/loot-core/src/server/cloud-storage.ts @@ -334,7 +334,7 @@ export async function possiblyUpload() { } // Don't block on uploading - upload().catch(err => {}); + upload().catch(() => {}); } export async function removeFile(fileId) { diff --git a/packages/loot-core/src/server/db/index.ts b/packages/loot-core/src/server/db/index.ts index f662cf3c7a0..3a359f06590 100644 --- a/packages/loot-core/src/server/db/index.ts +++ b/packages/loot-core/src/server/db/index.ts @@ -618,15 +618,6 @@ export async function getTransaction(id) { return rows[0]; } -export async function getTransactionsByDate( - accountId, - startDate, - endDate, - options = {}, -) { - throw new Error('`getTransactionsByDate` is deprecated'); -} - export async function getTransactions(accountId) { if (arguments.length > 1) { throw new Error( diff --git a/packages/loot-core/src/server/importers/actual.ts b/packages/loot-core/src/server/importers/actual.ts index 31a4f40b590..675b8a1161e 100644 --- a/packages/loot-core/src/server/importers/actual.ts +++ b/packages/loot-core/src/server/importers/actual.ts @@ -43,5 +43,5 @@ export async function importActual(_filepath: string, buffer: Buffer) { await handlers['load-budget']({ id }); await handlers['get-budget-bounds'](); await waitOnSpreadsheet(); - await cloudStorage.upload().catch(err => {}); + await cloudStorage.upload().catch(() => {}); } diff --git a/packages/loot-core/src/server/importers/ynab4.ts b/packages/loot-core/src/server/importers/ynab4.ts index f285b8047c3..3fbf27d0a17 100644 --- a/packages/loot-core/src/server/importers/ynab4.ts +++ b/packages/loot-core/src/server/importers/ynab4.ts @@ -199,7 +199,7 @@ async function importTransactions( subtransactions: transaction.subTransactions && - transaction.subTransactions.map((t, i) => { + transaction.subTransactions.map(t => { return { id: entityIdMap.get(t.entityId), amount: amountToInteger(t.amount), @@ -346,7 +346,7 @@ export async function doImport(data: YNAB4.YFull) { console.log('Setting up...'); } -export function getBudgetName(filepath, _data) { +export function getBudgetName(filepath) { let unixFilepath = normalizePathSep(filepath); if (!/\.zip/.test(unixFilepath)) { diff --git a/packages/loot-core/src/server/main.ts b/packages/loot-core/src/server/main.ts index 3a80926cdc8..03d661f06df 100644 --- a/packages/loot-core/src/server/main.ts +++ b/packages/loot-core/src/server/main.ts @@ -1867,7 +1867,7 @@ handlers['delete-budget'] = async function ({ id, cloudFileId }) { // If it's a cloud file, you can delete it from the server by // passing its cloud id if (cloudFileId) { - await cloudStorage.removeFile(cloudFileId).catch(err => {}); + await cloudStorage.removeFile(cloudFileId).catch(() => {}); } // If a local file exists, you can delete it by passing its local id diff --git a/packages/loot-core/src/server/migrate/cli.ts b/packages/loot-core/src/server/migrate/cli.ts index bc3bdff7510..5928b671410 100755 --- a/packages/loot-core/src/server/migrate/cli.ts +++ b/packages/loot-core/src/server/migrate/cli.ts @@ -48,7 +48,7 @@ function create(migrationName) { async function list(db) { const migrationsDir = getMigrationsDir(); - const applied = await getAppliedMigrations(getDatabase()); + const applied = await getAppliedMigrations(db); const all = await getMigrationList(migrationsDir); const pending = getPending(applied, all); diff --git a/packages/loot-core/src/server/schedules/app.ts b/packages/loot-core/src/server/schedules/app.ts index 0b82e4248ff..1bd4c0eb010 100644 --- a/packages/loot-core/src/server/schedules/app.ts +++ b/packages/loot-core/src/server/schedules/app.ts @@ -563,7 +563,7 @@ app.method('schedule/get-upcoming-dates', getUpcomingDates); app.service(trackJSONPaths); -app.events.on('sync', ({ type, subtype }) => { +app.events.on('sync', ({ type }) => { const completeEvent = type === 'success' || type === 'error' || type === 'unauthorized'; diff --git a/packages/loot-core/src/server/schedules/find-schedules.ts b/packages/loot-core/src/server/schedules/find-schedules.ts index 373a2bbe8ae..8b45406138b 100644 --- a/packages/loot-core/src/server/schedules/find-schedules.ts +++ b/packages/loot-core/src/server/schedules/find-schedules.ts @@ -53,7 +53,7 @@ function getRank(day1, day2) { return 1 / (dayDiff + 1); } -function matchSchedules(allOccurs, config, partialMatchRank = 0.5) { +function matchSchedules(allOccurs, config) { allOccurs = [...allOccurs].reverse(); const baseOccur = allOccurs[0]; const occurs = allOccurs.slice(1); @@ -107,13 +107,7 @@ function matchSchedules(allOccurs, config, partialMatchRank = 0.5) { return schedules; } -async function schedulesForPattern( - baseStart, - numDays, - baseConfig, - accountId, - partialMatchRank?: number, -) { +async function schedulesForPattern(baseStart, numDays, baseConfig, accountId) { let schedules = []; for (let i = 0; i < numDays; i++) { @@ -142,9 +136,7 @@ async function schedulesForPattern( }); } - schedules = schedules.concat( - matchSchedules(data, config, partialMatchRank), - ); + schedules = schedules.concat(matchSchedules(data, config)); } return schedules; } @@ -196,9 +188,6 @@ async function monthlyLastDay(startDate, accountId) { 1, { frequency: 'monthly', patterns: [{ type: 'day', value: -1 }] }, accountId, - // Last day patterns should win over day-specific ones that just - // happen to match - 0.75, ); const s2 = await schedulesForPattern( @@ -206,7 +195,6 @@ async function monthlyLastDay(startDate, accountId) { 1, { frequency: 'monthly', patterns: [{ type: 'day', value: -1 }] }, accountId, - 0.75, ); return s1.concat(s2); @@ -368,7 +356,7 @@ export async function findSchedules() { } const schedules = [...groupBy(allSchedules, 'payee').entries()].map( - ([payeeId, schedules]) => { + ([, schedules]) => { schedules.sort((s1, s2) => s2.rank - s1.rank); const winner = schedules[0]; diff --git a/packages/loot-core/src/server/spreadsheet/spreadsheet.ts b/packages/loot-core/src/server/spreadsheet/spreadsheet.ts index 4fbeacd436f..4aff0f00622 100644 --- a/packages/loot-core/src/server/spreadsheet/spreadsheet.ts +++ b/packages/loot-core/src/server/spreadsheet/spreadsheet.ts @@ -78,7 +78,7 @@ export class Spreadsheet { return this.nodes.has(name); } - add(name, expr, value) { + add(name, expr) { this.set(name, expr); } diff --git a/packages/loot-core/src/server/sync/index.ts b/packages/loot-core/src/server/sync/index.ts index c2fa6e30168..0cd7386bb4b 100644 --- a/packages/loot-core/src/server/sync/index.ts +++ b/packages/loot-core/src/server/sync/index.ts @@ -131,7 +131,7 @@ async function fetchAll(table, ids) { } sql += ` WHERE `; - sql += partIds.map(id => `${column} = ?`).join(' OR '); + sql += partIds.map(() => `${column} = ?`).join(' OR '); try { const rows = await db.runQuery(sql, partIds, true); diff --git a/packages/loot-core/src/server/tests/mockSyncServer.ts b/packages/loot-core/src/server/tests/mockSyncServer.ts index 79994dc174a..4852c095507 100644 --- a/packages/loot-core/src/server/tests/mockSyncServer.ts +++ b/packages/loot-core/src/server/tests/mockSyncServer.ts @@ -82,7 +82,7 @@ handlers['/plaid/handoff_public_token'] = () => { // Do nothing }; -handlers['/plaid/accounts'] = ({ client_id, group_id, item_id }) => { +handlers['/plaid/accounts'] = () => { // Ignore the parameters and just return the accounts. return { accounts: currentMockData.accounts }; }; diff --git a/packages/loot-core/src/shared/async.test.ts b/packages/loot-core/src/shared/async.test.ts index 6f3c5e9fff9..4aa9f9000e5 100644 --- a/packages/loot-core/src/shared/async.test.ts +++ b/packages/loot-core/src/shared/async.test.ts @@ -60,7 +60,7 @@ describe('async', () => { test('sequential fn should still flush queue when error is thrown', async () => { const test = async fn => { fn(1); - fn(2, { throwError: true }).catch(err => {}); + fn(2, { throwError: true }).catch(() => {}); await fn(3); }; @@ -86,7 +86,7 @@ describe('async', () => { // happened in here, it wouldn't effect anything else) expect(data).toEqual([1, 1, 1, 2]); }); - fn(2, { throwError: true }).catch(err => { + fn(2, { throwError: true }).catch(() => { // Same as above expect(data).toEqual([1, 1, 1, 2, 3]); }); diff --git a/packages/loot-core/src/types/api-handlers.d.ts b/packages/loot-core/src/types/api-handlers.d.ts index c4e8c2b11b8..1a667eba315 100644 --- a/packages/loot-core/src/types/api-handlers.d.ts +++ b/packages/loot-core/src/types/api-handlers.d.ts @@ -72,9 +72,6 @@ export interface ApiHandlers { endDate; }) => Promise; - /** @deprecated `filterTransactions` is deprecated, use `runQuery` instead' */ - 'api/transactions-filter': (arg: { text; accountId }) => Promise; - 'api/transaction-update': (arg: { id; fields }) => Promise; 'api/transaction-delete': (arg: { id }) => Promise; diff --git a/upcoming-release-notes/2255.md b/upcoming-release-notes/2255.md new file mode 100644 index 00000000000..0ab94f27b77 --- /dev/null +++ b/upcoming-release-notes/2255.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Code clean-up: removing unused variables