Skip to content

Commit

Permalink
Merge branch 'master' into matiss/strict-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Jan 19, 2024
2 parents 7ec4ac8 + edba670 commit c12c56a
Show file tree
Hide file tree
Showing 67 changed files with 520 additions and 383 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = {
extends: [
'react-app',
'plugin:react/recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
Expand All @@ -46,6 +47,7 @@ module.exports = {
reportUnusedDisableDirectives: true,
globals: {
globalThis: false,
vi: true,
},
rules: {
'prettier/prettier': 'warn',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,24 @@
"vrt": "yarn workspaces foreach --all --parallel --verbose run vrt",
"rebuild-electron": "./node_modules/.bin/electron-rebuild -f -m ./packages/loot-core",
"rebuild-node": "yarn workspace loot-core rebuild",
"lint": "eslint . --max-warnings 0",
"lint": "eslint . --max-warnings 0 --ext .js,.jsx,.ts,.tsx",
"lint:verbose": "DEBUG=eslint:cli-engine eslint . --max-warnings 0",
"typecheck": "yarn tsc && tsc-strict",
"jq": "./node_modules/node-jq/bin/jq"
},
"devDependencies": {
"cross-env": "^7.0.3",
"eslint": "^8.37.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "7.0.1",
"eslint-import-resolver-typescript": "3.5.5",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-rulesdir": "^0.2.2",
"node-jq": "^4.0.1",
"npm-run-all": "^4.1.3",
"prettier": "2.8.2",
"prettier": "3.2.4",
"react-refresh": "^0.14.0",
"source-map-support": "^0.5.21",
"typescript": "^5.0.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/crdt/src/crdt/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ export class Timestamp {
lNew === lOld && lNew === lMsg
? Math.max(cOld, cMsg) + 1
: lNew === lOld
? cOld + 1
: lNew === lMsg
? cMsg + 1
: 0;
? cOld + 1
: lNew === lMsg
? cMsg + 1
: 0;

// check the result for drift and counter overflow
if (lNew - phys > config.maxDrift) {
Expand Down
20 changes: 10 additions & 10 deletions packages/desktop-client/src/components/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ function Notification({
color: positive
? theme.noticeText
: error
? theme.errorTextDark
: theme.warningTextDark,
? theme.errorTextDark
: theme.warningTextDark,
}}
>
<Stack
Expand All @@ -132,14 +132,14 @@ function Notification({
backgroundColor: positive
? theme.noticeBackgroundLight
: error
? theme.errorBackground
: theme.warningBackground,
? theme.errorBackground
: theme.warningBackground,
borderTop: `3px solid ${
positive
? theme.noticeBorder
: error
? theme.errorBorder
: theme.warningBorder
? theme.errorBorder
: theme.warningBorder
}`,
...styles.shadowLarge,
maxWidth: 550,
Expand Down Expand Up @@ -184,8 +184,8 @@ function Notification({
positive
? theme.noticeBorder
: error
? theme.errorBorder
: theme.warningBorder
? theme.errorBorder
: theme.warningBorder
}`,
color: 'currentColor',
fontSize: 14,
Expand All @@ -194,8 +194,8 @@ function Notification({
backgroundColor: positive
? theme.noticeBackground
: error
? theme.errorBackground
: theme.warningBackground,
? theme.errorBackground
: theme.warningBackground,
},
}}
>
Expand Down
20 changes: 10 additions & 10 deletions packages/desktop-client/src/components/Titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,18 @@ function SyncButton({ style, isMobile = false }: SyncButtonProps) {
syncState === 'error'
? theme.errorText
: syncState === 'disabled' ||
syncState === 'offline' ||
syncState === 'local'
? theme.mobileHeaderTextSubdued
: theme.mobileHeaderText;
syncState === 'offline' ||
syncState === 'local'
? theme.mobileHeaderTextSubdued
: theme.mobileHeaderText;
const desktopColor =
syncState === 'error'
? theme.errorTextDark
: syncState === 'disabled' ||
syncState === 'offline' ||
syncState === 'local'
? theme.tableTextLight
: 'inherit';
syncState === 'offline' ||
syncState === 'local'
? theme.tableTextLight
: 'inherit';

const activeStyle = isMobile
? {
Expand Down Expand Up @@ -263,8 +263,8 @@ function SyncButton({ style, isMobile = false }: SyncButtonProps) {
{syncState === 'disabled'
? 'Disabled'
: syncState === 'offline'
? 'Offline'
: 'Sync'}
? 'Offline'
: 'Sync'}
</Text>
</Button>
</>
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/accounts/Balance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ export function Balances({
value < 0
? theme.errorText
: value > 0
? theme.noticeTextLight
: theme.pageTextSubdued,
? theme.noticeTextLight
: theme.pageTextSubdued,
})}
privacyFilter={{
blurIntensity: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function AccountList({
item.closed
? 'Closed Accounts'
: item.offbudget
? 'Off Budget'
: 'For Budget'
? 'Off Budget'
: 'For Budget'
}`;

lastItem = item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ export const BudgetCategories = memo(
item.value
? item.value.id
: item.type === 'income-separator'
? 'separator'
: idx
? 'separator'
: idx
}
value={pos}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function Saved({ projected, onClick }) {
color: projected
? theme.warningText
: isNegative
? theme.errorTextDark
: theme.formInputText,
? theme.errorTextDark
: theme.formInputText,
}}
/>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export function Saved({ projected, style }: SavedProps) {
color: projected
? theme.warningText
: isNegative
? theme.errorTextDark
: theme.upcomingText,
? theme.errorTextDark
: theme.upcomingText,
},
])}`}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/budget/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export function makeAmountFullStyle(value: number) {
value < 0
? theme.errorText
: value === 0
? theme.tableTextSubdued
: theme.noticeText,
? theme.tableTextSubdued
: theme.noticeText,
};
}

Expand Down
12 changes: 9 additions & 3 deletions packages/desktop-client/src/components/common/MenuButton.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// @ts-strict-ignore
import React from 'react';

import { SvgDotsHorizontalTriple } from '../../icons/v1';
import { type CSSProperties } from '../../style';

import { Button } from './Button';

export function MenuButton({ onClick }) {
export function MenuButton({
onClick,
style,
}: {
onClick: () => void;
style?: CSSProperties;
}) {
return (
<Button type="bare" onClick={onClick} aria-label="Menu">
<Button type="bare" onClick={onClick} aria-label="Menu" style={style}>
<SvgDotsHorizontalTriple
width={15}
height={15}
Expand Down
27 changes: 15 additions & 12 deletions packages/desktop-client/src/components/common/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ import { Text } from './Text';
import { View } from './View';

function getChildren(key, children) {
return Children.toArray(children).reduce((list, child) => {
if (child) {
if (
typeof child === 'object' &&
'type' in child &&
child.type === Fragment
) {
return list.concat(getChildren(child.key, child.props.children));
return Children.toArray(children).reduce(
(list, child) => {
if (child) {
if (
typeof child === 'object' &&
'type' in child &&
child.type === Fragment
) {
return list.concat(getChildren(child.key, child.props.children));
}
list.push({ key: key + child['key'], child });
return list;
}
list.push({ key: key + child['key'], child });
return list;
}
return list;
}, [] as Array<{ key: string; child: ReactNode }>);
},
[] as Array<{ key: string; child: ReactNode }>,
);
}

type StackProps = ComponentProps<typeof View> & {
Expand Down
12 changes: 6 additions & 6 deletions packages/desktop-client/src/components/filters/FiltersMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ function ConfigureField({
['amount-outflow', 'Amount (outflow)'],
]
: field === 'date'
? [
['date', 'Date'],
['month', 'Month'],
['year', 'Year'],
]
: null
? [
['date', 'Date'],
['month', 'Month'],
['year', 'Year'],
]
: null
}
value={subfield}
onChange={sub => {
Expand Down
30 changes: 17 additions & 13 deletions packages/desktop-client/src/components/manager/DeleteFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) {
null,
);

async function onDelete() {
setLoadingState(isCloudFile ? 'cloud' : 'local');
await actions.deleteBudget(
'id' in file ? file.id : undefined,
isCloudFile ? file.cloudFileId : undefined,
);
setLoadingState(null);

modalProps.onBack();
}

return (
<Modal
{...modalProps}
Expand Down Expand Up @@ -75,7 +64,16 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) {
padding: '10px 30px',
fontSize: 14,
}}
onClick={onDelete}
onClick={async () => {
setLoadingState('cloud');
await actions.deleteBudget(
'id' in file ? file.id : undefined,
file.cloudFileId,
);
setLoadingState(null);

modalProps.onBack();
}}
>
Delete file from all devices
</ButtonWithLoading>
Expand Down Expand Up @@ -125,7 +123,13 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) {
backgroundColor: theme.errorText,
}),
}}
onClick={onDelete}
onClick={async () => {
setLoadingState('local');
await actions.deleteBudget(file.id);
setLoadingState(null);

modalProps.onBack();
}}
>
Delete file locally
</ButtonWithLoading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ export function GoCardlessExternalMsg({
{isConfigurationLoading
? 'Checking GoCardless configuration..'
: waiting === 'browser'
? 'Waiting on GoCardless...'
: waiting === 'accounts'
? 'Loading accounts...'
: null}
? 'Waiting on GoCardless...'
: waiting === 'accounts'
? 'Loading accounts...'
: null}
</View>

{waiting === 'browser' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from 'loot-core/src/shared/util';

import { useActions } from '../../hooks/useActions';
import { useFeatureFlag } from '../../hooks/useFeatureFlag';
import { theme, styles } from '../../style';
import { Button, ButtonWithLoading } from '../common/Button';
import { Input } from '../common/Input';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import { View } from '../common/View';

const highlightStyle = { color: theme.pageTextPositive };

export function MergeUnusedPayees({
modalProps,
payeeIds,
targetPayeeId,
}) {
export function MergeUnusedPayees({ modalProps, payeeIds, targetPayeeId }) {
const { payees: allPayees, modalStack } = useSelector(state => ({
payees: state.queries.payees,
modalStack: state.modals.modalStack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export function PlaidExternalMsg({
{waiting === 'browser'
? 'Waiting on browser...'
: waiting === 'accounts'
? 'Loading accounts...'
: null}
? 'Loading accounts...'
: null}
</View>
</View>
) : success ? (
Expand Down
Loading

0 comments on commit c12c56a

Please sign in to comment.