Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 removing unused variables (batch 1) #2255

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/api/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function getFileType(filepath) {
return rawType;
}

function ParsedDate({ parseDateFormat, showParsed, dateFormat, date }) {
function ParsedDate({ parseDateFormat, dateFormat, date }) {
const parsed =
date &&
formatDate(
Expand Down Expand Up @@ -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 &&
Expand All @@ -216,7 +216,7 @@ function getInitialMappings(transactions) {

const inOutField = key(
fields.find(
([name, value]) =>
([name]) =>
name !== dateField &&
name !== amountField &&
name !== payeeField &&
Expand Down Expand Up @@ -1019,7 +1019,7 @@ export function ImportTransactions({ modalProps, options }) {
</View>
);
}}
renderItem={({ key, style, item, editing, focusedField }) => (
renderItem={({ key, style, item }) => (
<View key={key} style={style}>
<Transaction
transaction={item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function CategorySelector({
<Checkbox
id={`form_${categoryGroup.id}`}
checked={allCategoriesInGroupSelected}
onChange={e => {
onChange={() => {
const selectedCategoriesExcludingGroupCategories =
selectedCategories.filter(
selectedCategory =>
Expand Down Expand Up @@ -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,
);
Expand All @@ -206,7 +206,7 @@ export function CategorySelector({
<Checkbox
id={`form_${category.id}`}
checked={isChecked}
onChange={e => {
onChange={() => {
if (isChecked) {
setSelectedCategories(
selectedCategories.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function RulesHeader() {
const dispatchSelected = useSelectedDispatch();

return (
<TableHeader version="v2" style={{}}>
<TableHeader style={{}}>
<SelectCell
exposed={true}
focused={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export function SchedulesTable({

return (
<View style={{ flex: 1, ...tableStyle }}>
<TableHeader height={ROW_HEIGHT} inset={15} version="v2">
<TableHeader height={ROW_HEIGHT} inset={15}>
<Field width="flex">Name</Field>
<Field width="flex">Payee</Field>
<Field width="flex">Account</Field>
Expand All @@ -365,7 +365,6 @@ export function SchedulesTable({
<Table
rowHeight={ROW_HEIGHT}
backgroundColor="transparent"
version="v2"
style={{ flex: 1, backgroundColor: 'transparent', ...style }}
items={items as ScheduleEntity[]}
renderItem={renderItem}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export function DateSelect({
{...inputProps}
inputRef={inputRef}
value={value}
onPointerUp={e => {
onPointerUp={() => {
if (!embedded) {
setOpen(true);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop-client/src/components/sidebar/Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -118,7 +118,7 @@ export function Accounts({
query={getBalanceQuery(account)}
onDragChange={onDragChange}
onDrop={onReorder}
outerStyle={makeDropPadding(i, budgetedAccounts.length)}
outerStyle={makeDropPadding(i)}
/>
))}

Expand All @@ -143,7 +143,7 @@ export function Accounts({
query={getBalanceQuery(account)}
onDragChange={onDragChange}
onDrop={onReorder}
outerStyle={makeDropPadding(i, offbudgetAccounts.length)}
outerStyle={makeDropPadding(i)}
/>
))}

Expand All @@ -157,7 +157,7 @@ export function Accounts({
)}

{showClosedAccounts &&
closedAccounts.map((account, i) => (
closedAccounts.map(account => (
<Account
key={account.id}
name={account.name}
Expand Down
8 changes: 2 additions & 6 deletions packages/desktop-client/src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,10 @@ export function SheetCell({

type TableHeaderProps = ComponentProps<typeof Row> & {
headers?: Array<ComponentProps<typeof Cell>>;
version?: string;
};
export function TableHeader({
headers,
children,
version,
...rowProps
}: TableHeaderProps) {
return (
Expand Down Expand Up @@ -853,7 +851,7 @@ type TableWithNavigatorProps = TableProps & {
export const TableWithNavigator = forwardRef<
TableHandleRef<TableItem>,
TableWithNavigatorProps
>(({ fields, ...props }, ref) => {
>(({ fields, ...props }) => {
const navigator = useTableNavigator(props.items, fields);
return <Table {...props} navigator={navigator} />;
});
Expand Down Expand Up @@ -883,7 +881,6 @@ type TableProps<T extends TableItem = TableItem> = {
navigator?: ReturnType<typeof useTableNavigator<T>>;
listRef?: unknown;
onScroll?: () => void;
version?: string;
allowPopupsEscape?: boolean;
isSelected?: (id: TableItem['id']) => boolean;
saveScrollWidth?: (parent, child) => void;
Expand All @@ -906,7 +903,6 @@ export const Table = forwardRef(
style,
navigator,
onScroll,
version = 'v1',
allowPopupsEscape,
isSelected,
saveScrollWidth,
Expand Down Expand Up @@ -1045,7 +1041,7 @@ export const Table = forwardRef(
);
}

function onItemsRendered({ overscanStartIndex, overscanStopIndex }) {
function onItemsRendered({ overscanStopIndex }) {
if (loadMore && overscanStopIndex > items.length - 100) {
loadMore();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function serializeTransaction(transaction, dateFormat) {
const TransactionRow = memo(function TransactionRow({
transaction,
fields,
payees,
categories,
accounts,
selected,
Expand Down Expand Up @@ -137,7 +136,6 @@ const TransactionRow = memo(function TransactionRow({

export function SimpleTransactionsTable({
transactions,
schedules,
renderEmpty,
fields = ['date', 'payee', 'amount'],
style,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ describe('Transactions', () => {
updateProps({ transactions });

function expectErrorToNotExist(transactions) {
transactions.forEach((transaction, idx) => {
transactions.forEach(transaction => {
expect(transaction.error).toBeFalsy();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function AmountInput({
textStyle,
focused,
disabled = false,
...props
}: AmountInputProps) {
const format = useFormat();
const negative = (initialValue === 0 && zeroSign === '-') || initialValue < 0;
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop-electron/security.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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();
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop-electron/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function fireEvent(type, args) {
lastEvent = type;
}

function start(handler) {
function start() {
if (updateTimer) {
return null;
}
Expand All @@ -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)
});
}
Expand All @@ -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)
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/actions/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/loot-core/src/client/query-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ 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();
await wait(2);
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)]);
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/platform/client/fetch/index.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const unlisten: T.Unlisten = function (name) {
};

async function closeSocket(onClose) {
socketClient.onclose = event => {
socketClient.onclose = () => {
socketClient = null;
onClose();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {};
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {};
4 changes: 2 additions & 2 deletions packages/loot-core/src/platform/exceptions/index.testing.ts
Original file line number Diff line number Diff line change
@@ -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 () {};
2 changes: 1 addition & 1 deletion packages/loot-core/src/platform/exceptions/index.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {};
Loading