Skip to content

A local-first personal finance app

remove useless assignments to local variables (#7354)

Matt Fiddamana394aa1a571e
diff --git a/.oxlintrc.json b/.oxlintrc.json
index 3d13385eb6..0591f88f45 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -361,7 +361,9 @@
],
"eslint/no-useless-constructor": "error",
"eslint/no-undef": "error",
- "eslint/no-unused-expressions": "error"
+ "eslint/no-unused-expressions": "error",
+ "eslint/no-return-assign": "error",
+ "eslint/no-unused-vars": "error"
},
"overrides": [
{
diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx
index fea973690d..5515fd31a5 100644
--- a/packages/desktop-client/src/components/FinancesApp.tsx
+++ b/packages/desktop-client/src/components/FinancesApp.tsx
@@ -6,7 +6,6 @@ import { Navigate, Route, Routes, useHref, useLocation } from 'react-router';
import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { useQuery } from '@tanstack/react-query';
import * as undo from 'loot-core/platform/client/undo';
@@ -28,7 +27,6 @@ import { FloatableSidebar } from './sidebar';
import { ManageTagsPage } from './tags/ManageTagsPage';
import { Titlebar } from './Titlebar';
-import { accountQueries } from '@desktop-client/accounts';
import { getLatestAppVersion, sync } from '@desktop-client/app/appSlice';
import { ProtectedRoute } from '@desktop-client/auth/ProtectedRoute';
import { Permissions } from '@desktop-client/auth/types';
diff --git a/packages/desktop-client/src/components/FixedSizeList.tsx b/packages/desktop-client/src/components/FixedSizeList.tsx
index 65dbf570a0..62b378ac81 100644
--- a/packages/desktop-client/src/components/FixedSizeList.tsx
+++ b/packages/desktop-client/src/components/FixedSizeList.tsx
@@ -134,8 +134,7 @@ export class FixedSizeList extends PureComponent<
const { initialScrollOffset } = this.props;
if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
- let outerRef = this._outerRef;
- outerRef = this._outerRef;
+ const outerRef = this._outerRef;
outerRef.scrollTop = initialScrollOffset;
}
diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsx
index ab753b8f1c..597ba27a78 100644
--- a/packages/desktop-client/src/components/accounts/Account.tsx
+++ b/packages/desktop-client/src/components/accounts/Account.tsx
@@ -263,7 +263,6 @@ type AccountInternalState = {
workingHard: boolean;
reconcileAmount: null | number;
transactions: TransactionEntity[];
- transactionCount: number;
transactionsFiltered?: boolean;
showBalances?: boolean | undefined;
balances: Record<TransactionEntity['id'], IntegerAmount> | null;
@@ -315,7 +314,6 @@ class AccountInternal extends PureComponent<
workingHard: false,
reconcileAmount: null,
transactions: [],
- transactionCount: 0,
showBalances: props.showBalances,
balances: null,
showCleared: props.showCleared,
@@ -501,7 +499,6 @@ class AccountInternal extends PureComponent<
this.setState(
{
transactions: data,
- transactionCount: this.paged?.totalCount ?? 0,
transactionsFiltered: isFiltered,
loading: false,
workingHard: false,
@@ -836,7 +833,6 @@ class AccountInternal extends PureComponent<
this.setState(
{
transactions: [],
- transactionCount: 0,
filterConditions: [],
search: '',
sort: null,
@@ -1552,7 +1548,6 @@ class AccountInternal extends PureComponent<
this.setState(
{
transactions: [],
- transactionCount: 0,
filterConditions: conditions,
},
() => {
diff --git a/packages/desktop-client/src/components/filters/PayeeFilter.tsx b/packages/desktop-client/src/components/filters/PayeeFilter.tsx
index 4dff583cbc..8238ee29c5 100644
--- a/packages/desktop-client/src/components/filters/PayeeFilter.tsx
+++ b/packages/desktop-client/src/components/filters/PayeeFilter.tsx
@@ -32,7 +32,7 @@ export const PayeeFilter = ({ value, op, onChange }: PayeeFilterProps) => {
const { t } = useTranslation();
const multi = ['oneOf', 'notOneOf'].includes(op);
- let coercedValue: PayeeFilterValue = value;
+ let coercedValue: PayeeFilterValue;
if (multi) {
coercedValue = Array.isArray(value) ? value : [];
} else {
diff --git a/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx b/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx
index f886790e35..93894c0b0c 100644
--- a/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx
+++ b/packages/desktop-client/src/components/manager/BudgetFileSelection.tsx
@@ -203,10 +203,9 @@ function BudgetFileState({ file, currentUserId }: BudgetFileStateProps) {
ownerName = t('You');
break;
case 'broken':
- ownerName = 'unknown';
Icon = SvgFileDouble;
status = t('Local');
- ownerName = t('You');
+ ownerName = t('Unknown');
break;
default:
Icon = SvgCloudCheck;
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index 5eda05ad3d..f82a2bac65 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -154,7 +154,6 @@ const ActiveShapeMobile = ({
value,
expandInward,
chartInnerRadius,
- chartMidRadius,
chartOuterRadius,
}: ActiveShapeProps) => {
const format = useFormat();
@@ -230,8 +229,6 @@ const ActiveShapeDesktop = ({
value,
expandInward,
chartInnerRadius,
- chartMidRadius,
- chartOuterRadius,
}: ActiveShapeProps) => {
const format = useFormat();
// Fix 2: guard against undefined payload.name and payload.date
diff --git a/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx b/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx
index 163034241e..44a8160a9f 100644
--- a/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx
@@ -97,7 +97,7 @@ function SankeyNode({
y,
width,
height,
- index,
+ index: _index,
payload,
containerWidth,
containerHeight,
diff --git a/packages/desktop-client/src/components/reports/reports/Sankey.tsx b/packages/desktop-client/src/components/reports/reports/Sankey.tsx
index a4fd1465e9..0791fd8b86 100644
--- a/packages/desktop-client/src/components/reports/reports/Sankey.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Sankey.tsx
@@ -8,12 +8,9 @@ import { SvgArrowDown, SvgList } from '@actual-app/components/icons/v1';
import { Menu } from '@actual-app/components/menu';
import { Paragraph } from '@actual-app/components/paragraph';
import { Popover } from '@actual-app/components/popover';
-import { Select } from '@actual-app/components/select';
import { SpaceBetween } from '@actual-app/components/space-between';
-import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
-import { Tooltip } from '@actual-app/components/tooltip';
import { View } from '@actual-app/components/view';
import * as d from 'date-fns';
import type { SankeyData } from 'recharts/types/chart/Sankey';
@@ -27,8 +24,6 @@ import type {
} from 'loot-core/types/models';
import { EditablePageHeaderTitle } from '@desktop-client/components/EditablePageHeaderTitle';
-import { AppliedFilters } from '@desktop-client/components/filters/AppliedFilters';
-import { FilterButton } from '@desktop-client/components/filters/FiltersMenu';
import { MobileBackButton } from '@desktop-client/components/mobile/MobileBackButton';
import {
MobilePageHeader,
diff --git a/packages/desktop-client/src/components/reports/reports/SankeyCard.tsx b/packages/desktop-client/src/components/reports/reports/SankeyCard.tsx
index ca76a697e4..a29a0bb961 100644
--- a/packages/desktop-client/src/components/reports/reports/SankeyCard.tsx
+++ b/packages/desktop-client/src/components/reports/reports/SankeyCard.tsx
@@ -9,7 +9,6 @@ import * as d from 'date-fns';
import type { SankeyWidget } from 'loot-core/types/models';
-import { DateRange } from '@desktop-client/components/reports/DateRange';
import { SankeyGraph } from '@desktop-client/components/reports/graphs/SankeyGraph';
import { LoadingIndicator } from '@desktop-client/components/reports/LoadingIndicator';
import { ReportCard } from '@desktop-client/components/reports/ReportCard';
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts
index 1d18959e10..3fe0ce141e 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts
@@ -188,7 +188,7 @@ export function createCustomSpreadsheet({
(asset[groupByLabel] === (item.id ?? null) ||
(item.uncategorized_id && groupsByCategory)),
)
- .reduce((a, v) => (a = a + v.amount), 0);
+ .reduce((a, v) => a + v.amount, 0);
perIntervalAssets += intervalAssets;
const intervalDebts = filterHiddenItems(
@@ -205,7 +205,7 @@ export function createCustomSpreadsheet({
(debt[groupByLabel] === (item.id ?? null) ||
(item.uncategorized_id && groupsByCategory)),
)
- .reduce((a, v) => (a = a + v.amount), 0);
+ .reduce((a, v) => a + v.amount, 0);
perIntervalDebts += intervalDebts;
const netAmounts = intervalAssets + intervalDebts;
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts b/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts
index 6859caab94..204e2abdc7 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts
@@ -55,7 +55,7 @@ export function recalculate({
(asset[groupByLabel] === (item.id ?? null) ||
(item.uncategorized_id && groupsByCategory)),
)
- .reduce((a, v) => (a = a + v.amount), 0);
+ .reduce((a, v) => a + v.amount, 0);
totalAssets += intervalAssets;
const intervalDebts = filterHiddenItems(
@@ -72,7 +72,7 @@ export function recalculate({
(debt[groupByLabel] === (item.id ?? null) ||
(item.uncategorized_id && groupsByCategory)),
)
- .reduce((a, v) => (a = a + v.amount), 0);
+ .reduce((a, v) => a + v.amount, 0);
totalDebts += intervalDebts;
const intervalTotals = intervalAssets + intervalDebts;
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
index 2bf113a7a6..94eae3501e 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
@@ -136,7 +136,7 @@ export function createSpendingSpreadsheet({
const dailyBudget =
budgets &&
- budgets.reduce((a, v) => (a = a + v.amount), 0) / compareInterval.length;
+ budgets.reduce((a, v) => a + v.amount, 0) / compareInterval.length;
const intervals = monthUtils.dayRangeInclusive(startDate, endDate);
if (endDateTo < startDate || startDateTo > endDate) {
@@ -182,13 +182,13 @@ export function createSpendingSpreadsheet({
const intervalAssets = combineAssets
.filter(e => !e.categoryIncome && !e.accountOffBudget)
.filter(asset => asset.date === intervalItem)
- .reduce((a, v) => (a = a + v.amount), 0);
+ .reduce((a, v) => a + v.amount, 0);
perIntervalAssets += intervalAssets;
const intervalDebts = combineDebts
.filter(e => !e.categoryIncome && !e.accountOffBudget)
.filter(debt => debt.date === intervalItem)
- .reduce((a, v) => (a = a + v.amount), 0);
+ .reduce((a, v) => a + v.amount, 0);
perIntervalDebts += intervalDebts;
totalAssets += perIntervalAssets;
@@ -242,7 +242,7 @@ export function createSpendingSpreadsheet({
b.cumulative === null ? a : b,
).cumulative;
- const totalDaily = data.reduce((a, v) => (a = a + v.totalTotals), 0);
+ const totalDaily = data.reduce((a, v) => a + v.totalTotals, 0);
return {
date: data[0].date,
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx
index 582a01b6ca..6a0ab5cc2d 100644
--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx
+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx
@@ -1104,7 +1104,7 @@ describe('Transactions', () => {
});
}
- let input = await editField(container, 'category', 0);
+ await editField(container, 'category', 0);
// Make it clear that we are expected a negative transaction
expect(getTransactions()[0].amount).toBe(-2777);
@@ -1128,7 +1128,7 @@ describe('Transactions', () => {
// Enter an amount for the new split transaction and make sure the
// toolbar updates
- input = await editField(container, 'debit', 1);
+ let input = await editField(container, 'debit', 1);
await userEvent.clear(input);
await userEvent.type(input, '10.00[tab]');
expect(toolbar.innerHTML.includes('17.77')).toBeTruthy();
@@ -1221,7 +1221,7 @@ describe('Transactions', () => {
test('transaction with splits shows 0 in correct column', async () => {
const { container, getTransactions } = renderTransactions();
- let input = await editField(container, 'category', 0);
+ await editField(container, 'category', 0);
// The first transaction should always be a negative amount
expect(getTransactions()[0].amount).toBe(-2777);
@@ -1240,7 +1240,7 @@ describe('Transactions', () => {
expect(queryField(container, 'credit', '', 2).textContent).toBe('');
// Change it to a credit transaction
- input = await editField(container, 'credit', 0);
+ const input = await editField(container, 'credit', 0);
await userEvent.type(input, '55.00{Tab}');
// The zeros should now display in the credit column
diff --git a/packages/desktop-client/src/shared-browser-server-core.test.ts b/packages/desktop-client/src/shared-browser-server-core.test.ts
index a06ae5b31e..4915bfe4ee 100644
--- a/packages/desktop-client/src/shared-browser-server-core.test.ts
+++ b/packages/desktop-client/src/shared-browser-server-core.test.ts
@@ -202,7 +202,7 @@ describe('SharedWorker coordinator', () => {
});
it('second tab joins existing budget as follower', () => {
- const leader = setupBudgetGroup(coordinator, 'budget-1');
+ setupBudgetGroup(coordinator, 'budget-1');
const follower = connectTab(coordinator);
sendInit(follower);
diff --git a/packages/loot-core/src/platform/server/fs/index.ts b/packages/loot-core/src/platform/server/fs/index.ts
index 7608228fbd..79cd74ec77 100644
--- a/packages/loot-core/src/platform/server/fs/index.ts
+++ b/packages/loot-core/src/platform/server/fs/index.ts
@@ -409,7 +409,7 @@ export const removeDirRecursively = async function (dirpath) {
}
};
-export const getModifiedTime = async (filepath: string): Promise<Date> => {
+export const getModifiedTime = async (_filepath: string): Promise<Date> => {
throw new Error(
'getModifiedTime not supported on the web (only used for backups)',
);
diff --git a/packages/loot-core/src/server/budget/category-template-context.ts b/packages/loot-core/src/server/budget/category-template-context.ts
index f715bc3bf0..4b60ff5ecf 100644
--- a/packages/loot-core/src/server/budget/category-template-context.ts
+++ b/packages/loot-core/src/server/budget/category-template-context.ts
@@ -711,7 +711,7 @@ export class CategoryTemplateContext {
const cat = template.category.toLowerCase();
const prev = template.previous;
let sheetName;
- let monthlyIncome = 1;
+ let monthlyIncome;
//choose the sheet to find income for
if (prev) {
diff --git a/packages/loot-core/src/server/main.test.ts b/packages/loot-core/src/server/main.test.ts
index 50015bea46..4db6031934 100644
--- a/packages/loot-core/src/server/main.test.ts
+++ b/packages/loot-core/src/server/main.test.ts
@@ -139,7 +139,6 @@ describe('Accounts', () => {
await db.all<db.DbTransaction>('SELECT * FROM transactions'),
);
- let transaction = await db.getTransaction(id);
await runHandler(handlers['transaction-update'], {
...(await db.getTransaction(id)),
payee: 'transfer-three',
@@ -149,7 +148,7 @@ describe('Accounts', () => {
await db.all<db.DbTransaction>('SELECT * FROM transactions'),
);
- transaction = await db.getTransaction(id);
+ const transaction = await db.getTransaction(id);
await runHandler(handlers['transaction-delete'], transaction);
differ.expectToMatchDiff(
await db.all<db.DbTransaction>('SELECT * FROM transactions'),
diff --git a/packages/loot-core/src/server/transactions/transaction-rules.ts b/packages/loot-core/src/server/transactions/transaction-rules.ts
index 68c860fc2f..6cbe5087ab 100644
--- a/packages/loot-core/src/server/transactions/transaction-rules.ts
+++ b/packages/loot-core/src/server/transactions/transaction-rules.ts
@@ -772,8 +772,7 @@ function* getOneOfSetterRules(
rule.actions[0].field === actionField &&
(actionValue == null || rule.actions[0].value === actionValue) &&
rule.conditions.length === 1 &&
- (rule.conditions[0].op === 'oneOf' ||
- rule.conditions[0].op === 'oneOf') &&
+ rule.conditions[0].op === 'oneOf' &&
rule.conditions[0].field === condField &&
(condValue == null || rule.conditions[0].value.indexOf(condValue) !== -1)
) {
diff --git a/packages/loot-core/vitest.config.ts b/packages/loot-core/vitest.config.ts
index 4a183e46b5..109b213520 100644
--- a/packages/loot-core/vitest.config.ts
+++ b/packages/loot-core/vitest.config.ts
@@ -1,5 +1,3 @@
-import path from 'path';
-
import peggyLoader from 'vite-plugin-peggy-loader';
import { defineConfig } from 'vitest/config';
diff --git a/packages/loot-core/vitest.web.config.ts b/packages/loot-core/vitest.web.config.ts
index faa24a0e8b..ed393f64d7 100644
--- a/packages/loot-core/vitest.web.config.ts
+++ b/packages/loot-core/vitest.web.config.ts
@@ -1,5 +1,3 @@
-import path from 'path';
-
import peggyLoader from 'vite-plugin-peggy-loader';
import { defineConfig } from 'vitest/config';
diff --git a/upcoming-release-notes/7354.md b/upcoming-release-notes/7354.md
new file mode 100644
index 0000000000..4d48cb148c
--- /dev/null
+++ b/upcoming-release-notes/7354.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [matt-fidd]
+---
+
+Fix useless assignments to local variables