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 2) #2256

Merged
merged 5 commits into from
Jan 21, 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
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ module.exports = {
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
Expand Down
10 changes: 5 additions & 5 deletions packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ global.Actual = {
window.location.reload();
},

openFileDialog: async ({ filters = [], properties }) => {
openFileDialog: async ({ filters = [] }) => {
return new Promise(resolve => {
let createdElement = false;
// Attempt to reuse an already-created file input.
Expand Down Expand Up @@ -91,7 +91,7 @@ global.Actual = {
.uploadFile(filename, ev.target.result)
.then(() => resolve([filepath]));
};
reader.onerror = function (ev) {
reader.onerror = function () {
alert('Error reading file');
};
}
Expand All @@ -107,7 +107,7 @@ global.Actual = {
});
},

saveFile: (contents, defaultFilename, dialogTitle) => {
saveFile: (contents, defaultFilename) => {
const temp = document.createElement('a');
temp.style = 'display: none';
temp.download = defaultFilename;
Expand All @@ -121,9 +121,9 @@ global.Actual = {
openURLInBrowser: url => {
window.open(url, '_blank');
},
onEventFromMain: (type, handler) => {},
onEventFromMain: () => {},
applyAppUpdate: () => {},
updateAppMenu: isBudgetOpen => {},
updateAppMenu: () => {},

ipcConnect: () => {},
getServerSocket: async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/FatalError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function SharedArrayBufferOverride() {
>
<Checkbox
checked={understand}
onChange={_ => setUnderstand(!understand)}
onChange={() => setUnderstand(!understand)}
/>{' '}
I understand the risks, run Actual in the unsupported fallback mode
</label>
Expand Down
67 changes: 24 additions & 43 deletions packages/desktop-client/src/components/FixedSizeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {
createRef,
PureComponent,
type ReactElement,
type ReactNode,
type Ref,
type MutableRefObject,
Expand All @@ -11,7 +10,6 @@ import {

import memoizeOne from 'memoize-one';

import { useResizeObserver } from '../hooks/useResizeObserver';
import { type CSSProperties } from '../style';

import { View } from './common/View';
Expand All @@ -20,16 +18,6 @@ const IS_SCROLLING_DEBOUNCE_INTERVAL = 150;

const defaultItemKey: FixedSizeListProps['itemKey'] = (index: number) => index;

type ResizeObserverProps = {
onResize: Parameters<typeof useResizeObserver>[0];
children: (ref: Ref<HTMLDivElement>) => ReactElement;
};

function ResizeObserver({ onResize, children }: ResizeObserverProps) {
const ref = useResizeObserver(onResize);
return children(ref);
}

type FixedSizeListProps = {
className?: string;
direction?: 'rtl' | 'ltr';
Expand Down Expand Up @@ -262,33 +250,29 @@ export class FixedSizeList extends PureComponent<
const estimatedTotalSize = this.getEstimatedTotalSize();

return (
<ResizeObserver onResize={this.onHeaderResize}>
{headerRef => (
<div
className={className}
onScroll={this._onScrollVertical}
ref={this._outerRefSetter}
style={{
height,
width,
overflow: 'hidden auto',
}}
>
<View innerRef={headerRef}>{header}</View>
<div
ref={innerRef}
style={{
position: 'relative',
height: estimatedTotalSize,
width: '100%',
pointerEvents: isScrolling ? 'none' : undefined,
}}
>
{items}
</div>
</div>
)}
</ResizeObserver>
<div
className={className}
onScroll={this._onScrollVertical}
ref={this._outerRefSetter}
style={{
height,
width,
overflow: 'hidden auto',
}}
>
<View>{header}</View>
<div
ref={innerRef}
style={{
position: 'relative',
height: estimatedTotalSize,
width: '100%',
pointerEvents: isScrolling ? 'none' : undefined,
}}
>
{items}
</div>
</div>
);
}

Expand All @@ -305,10 +289,6 @@ export class FixedSizeList extends PureComponent<
}
};

onHeaderResize = (rect: { height: number }) => {
// this.setState({ headerHeight: rect.height });
};

anchor() {
const itemKey = this.props.itemKey || defaultItemKey;

Expand Down Expand Up @@ -499,6 +479,7 @@ export class FixedSizeList extends PureComponent<
return style;
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
_getItemStyleCache = memoizeOne((_, __, ___) => ({}));

_getRangeToRender() {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/ManageRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function ManageRulesContent({
dispatch(
pushModal('edit-rule', {
rule,
onSave: async newRule => {
onSave: async () => {
await loadRules();
setLoading(false);
},
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/accounts/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class AccountInternal extends PureComponent {
}
};

const onUndo = async ({ tables, messages, undoTag }) => {
const onUndo = async ({ tables, messages }) => {
await maybeRefetch(tables);

// If all the messages are dealing with transactions, find the
Expand Down Expand Up @@ -516,7 +516,7 @@ class AccountInternal extends PureComponent {
});
}
},
mappedData => {
() => {
return data;
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getSchedulesTransform = memoizeOne((id, hasSearch) => {
};
});

function PreviewTransactions({ accountId, children }) {
function PreviewTransactions({ children }) {
const scheduleData = useCachedSchedules();

if (scheduleData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,15 @@ function BudgetInner(props: BudgetInnerProps) {
await sync();
}}
>
{({ refreshing, onRefresh }) => (
{({ onRefresh }) => (
<BudgetTable
// This key forces the whole table rerender when the number
// format changes
key={numberFormat + hideFraction}
categoryGroups={categoryGroups}
categories={categories}
type={budgetType}
month={currentMonth}
monthBounds={bounds}
// refreshControl={
// <RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
// }
editMode={editMode}
onEditMode={flag => setEditMode(flag)}
onShowBudgetSummary={onShowBudgetSummary}
Expand All @@ -438,9 +434,6 @@ function BudgetInner(props: BudgetInnerProps) {
onBudgetAction={applyBudgetAction}
onRefresh={onRefresh}
onSwitchBudgetType={onSwitchBudgetType}
onSaveNotes={onSaveNotes}
onEditGroupNotes={onEditGroupNotes}
onEditCategoryNotes={onEditCategoryNotes}
savePrefs={savePrefs}
pushModal={pushModal}
onEditGroup={onEditGroup}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function BudgetCell({
});
}

function onAmountClick(e) {
function onAmountClick() {
onEdit?.(categoryId);
}

Expand Down Expand Up @@ -243,7 +243,6 @@ const ExpenseCategory = memo(function ExpenseCategory({
blank,
style,
month,
editMode,
onEdit,
isEditingBudget,
onEditBudget,
Expand Down Expand Up @@ -569,7 +568,6 @@ const IncomeGroupTotals = memo(function IncomeGroupTotals({
budgeted,
balance,
style,
editMode,
onEdit,
}) {
const listItemRef = useRef();
Expand Down Expand Up @@ -657,7 +655,6 @@ const IncomeCategory = memo(function IncomeCategory({
balance,
month,
style,
editMode,
onEdit,
onBudgetAction,
isEditingBudget,
Expand Down Expand Up @@ -1122,7 +1119,6 @@ function BudgetGroups({
export function BudgetTable({
type,
categoryGroups,
categories,
month,
monthBounds,
editMode,
Expand All @@ -1143,9 +1139,6 @@ export function BudgetTable({
onBudgetAction,
onRefresh,
onSwitchBudgetType,
onSaveNotes,
onEditGroupNotes,
onEditCategoryNotes,
savePrefs,
pushModal,
onEditGroup,
Expand All @@ -1154,7 +1147,6 @@ export function BudgetTable({
onEditCategoryBudget,
openBalanceActionMenuId,
onOpenBalanceActionMenu,
...props
}) {
const { width } = useResponsive();
const show3Cols = width >= 360;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function SidebarCategory({
>
<InputCell
value={category.name}
formatter={value => displayed}
formatter={() => displayed}
width="flex"
exposed={editing || temporary}
onUpdate={value => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type SidebarGroupProps = {
collapsed: boolean;
dragPreview?: boolean;
innerRef?: ConnectDragSource;
borderColor?: string;
style?: CSSProperties;
onEdit?: (id: string) => void;
onSave?: (group: object) => Promise<void>;
Expand All @@ -44,7 +43,6 @@ export function SidebarGroup({
dragPreview,
innerRef,
style,
borderColor = theme.tableBorder,
onEdit,
onSave,
onDelete,
Expand All @@ -63,7 +61,7 @@ export function SidebarGroup({
userSelect: 'none',
WebkitUserSelect: 'none',
}}
onClick={e => {
onClick={() => {
onToggleCollapse(group.id);
}}
>
Expand Down Expand Up @@ -181,7 +179,7 @@ export function SidebarGroup({
>
<InputCell
value={group.name}
formatter={value => displayed}
formatter={() => displayed}
width="flex"
exposed={editing}
onUpdate={value => {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/budget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ const RolloverBudgetSummary = memo<{ month: string }>(props => {
);
});

export function Budget(props) {
export function Budget() {
const startMonth = useSelector(
state => state.prefs.local['budget.startMonth'],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function BalanceTooltip({
{...tooltipProps}
>
<Menu
onMenuSelect={type => {
onMenuSelect={() => {
onBudgetAction(monthIndex, 'carryover', {
category: categoryId,
flag: !carryover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function CoverTooltip({
categoryGroups={categoryGroups}
value={null}
openOnFocus={true}
onUpdate={id => {}}
onUpdate={() => {}}
onSelect={id => setCategory(id)}
inputProps={{
inputRef: node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function TransferTooltip({
categoryGroups={categoryGroups}
value={null}
openOnFocus={true}
onUpdate={id => {}}
onUpdate={() => {}}
onSelect={id => setCategory(id)}
inputProps={{ onEnter: submit, placeholder: '(none)' }}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function BudgetSummary({
} = useRollover();

const [menuOpen, setMenuOpen] = useState(false);
function onMenuOpen(e) {
function onMenuOpen() {
setMenuOpen(true);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/common/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function Menu<T extends MenuItem>({
}}
onMouseEnter={() => setHoveredIndex(idx)}
onMouseLeave={() => setHoveredIndex(null)}
onClick={e =>
onClick={() =>
!item.disabled && onMenuSelect && onMenuSelect(item.name)
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function CategoryGroupMenu({
notes={notes?.length > 0 ? notes : 'No notes'}
editable={false}
focused={false}
getStyle={editable => ({
getStyle={() => ({
...styles.mediumText,
borderRadius: 6,
...((!notes || notes.length === 0) && {
Expand Down
Loading