diff --git a/.eslintrc.js b/.eslintrc.js index c411995fc87..d757f5187a8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -38,6 +38,7 @@ module.exports = { extends: [ 'react-app', 'plugin:react/recommended', + 'plugin:prettier/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:import/typescript', ], @@ -46,6 +47,7 @@ module.exports = { reportUnusedDisableDirectives: true, globals: { globalThis: false, + vi: true, }, rules: { 'prettier/prettier': 'warn', diff --git a/package.json b/package.json index db6163d7b54..62c6175f39c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "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" @@ -44,15 +44,16 @@ "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", diff --git a/packages/crdt/src/crdt/timestamp.ts b/packages/crdt/src/crdt/timestamp.ts index 4eb8f399c21..ab54cf707dd 100644 --- a/packages/crdt/src/crdt/timestamp.ts +++ b/packages/crdt/src/crdt/timestamp.ts @@ -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) { diff --git a/packages/desktop-client/src/components/Notifications.tsx b/packages/desktop-client/src/components/Notifications.tsx index 122a1231870..d134ed26148 100644 --- a/packages/desktop-client/src/components/Notifications.tsx +++ b/packages/desktop-client/src/components/Notifications.tsx @@ -119,8 +119,8 @@ function Notification({ color: positive ? theme.noticeText : error - ? theme.errorTextDark - : theme.warningTextDark, + ? theme.errorTextDark + : theme.warningTextDark, }} > diff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsx index e3487eddac9..57e16344bb8 100644 --- a/packages/desktop-client/src/components/Titlebar.tsx +++ b/packages/desktop-client/src/components/Titlebar.tsx @@ -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 ? { @@ -263,8 +263,8 @@ function SyncButton({ style, isMobile = false }: SyncButtonProps) { {syncState === 'disabled' ? 'Disabled' : syncState === 'offline' - ? 'Offline' - : 'Sync'} + ? 'Offline' + : 'Sync'} diff --git a/packages/desktop-client/src/components/accounts/Balance.jsx b/packages/desktop-client/src/components/accounts/Balance.jsx index f2cb12c752f..d1df3c59a3b 100644 --- a/packages/desktop-client/src/components/accounts/Balance.jsx +++ b/packages/desktop-client/src/components/accounts/Balance.jsx @@ -159,8 +159,8 @@ export function Balances({ value < 0 ? theme.errorText : value > 0 - ? theme.noticeTextLight - : theme.pageTextSubdued, + ? theme.noticeTextLight + : theme.pageTextSubdued, })} privacyFilter={{ blurIntensity: 5, diff --git a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx index 3b514ac2f01..f296e7b297f 100644 --- a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx @@ -41,8 +41,8 @@ function AccountList({ item.closed ? 'Closed Accounts' : item.offbudget - ? 'Off Budget' - : 'For Budget' + ? 'Off Budget' + : 'For Budget' }`; lastItem = item; diff --git a/packages/desktop-client/src/components/budget/BudgetCategories.jsx b/packages/desktop-client/src/components/budget/BudgetCategories.jsx index a223fea97e7..c80bfb2ab35 100644 --- a/packages/desktop-client/src/components/budget/BudgetCategories.jsx +++ b/packages/desktop-client/src/components/budget/BudgetCategories.jsx @@ -292,8 +292,8 @@ export const BudgetCategories = memo( item.value ? item.value.id : item.type === 'income-separator' - ? 'separator' - : idx + ? 'separator' + : idx } value={pos} > diff --git a/packages/desktop-client/src/components/budget/MobileBudgetTable.jsx b/packages/desktop-client/src/components/budget/MobileBudgetTable.jsx index fb5b9d5c24d..3c2251d77b3 100644 --- a/packages/desktop-client/src/components/budget/MobileBudgetTable.jsx +++ b/packages/desktop-client/src/components/budget/MobileBudgetTable.jsx @@ -117,8 +117,8 @@ function Saved({ projected, onClick }) { color: projected ? theme.warningText : isNegative - ? theme.errorTextDark - : theme.formInputText, + ? theme.errorTextDark + : theme.formInputText, }} /> diff --git a/packages/desktop-client/src/components/budget/report/budgetsummary/Saved.tsx b/packages/desktop-client/src/components/budget/report/budgetsummary/Saved.tsx index 3575bd63f07..b17906ec4d9 100644 --- a/packages/desktop-client/src/components/budget/report/budgetsummary/Saved.tsx +++ b/packages/desktop-client/src/components/budget/report/budgetsummary/Saved.tsx @@ -81,8 +81,8 @@ export function Saved({ projected, style }: SavedProps) { color: projected ? theme.warningText : isNegative - ? theme.errorTextDark - : theme.upcomingText, + ? theme.errorTextDark + : theme.upcomingText, }, ])}`} > diff --git a/packages/desktop-client/src/components/budget/util.ts b/packages/desktop-client/src/components/budget/util.ts index ed0f93bb953..cb7b926b734 100644 --- a/packages/desktop-client/src/components/budget/util.ts +++ b/packages/desktop-client/src/components/budget/util.ts @@ -73,8 +73,8 @@ export function makeAmountFullStyle(value: number) { value < 0 ? theme.errorText : value === 0 - ? theme.tableTextSubdued - : theme.noticeText, + ? theme.tableTextSubdued + : theme.noticeText, }; } diff --git a/packages/desktop-client/src/components/common/MenuButton.tsx b/packages/desktop-client/src/components/common/MenuButton.tsx index 30cd077226c..b707ef6ba74 100644 --- a/packages/desktop-client/src/components/common/MenuButton.tsx +++ b/packages/desktop-client/src/components/common/MenuButton.tsx @@ -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 ( -