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

⬆️ (prettier) upgrade, fix issues and enable for jsx files #2253

Merged
merged 2 commits 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
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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to target jsx files. We previously did not target them (oops).

"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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export const PayeeTableRow = memo(
backgroundColor: hovered
? theme.tableRowBackgroundHover
: selected
? theme.tableRowBackgroundHighlight
: backgroundFocus
? theme.tableRowBackgroundHover
: theme.tableBackground,
? theme.tableRowBackgroundHighlight
: backgroundFocus
? theme.tableRowBackgroundHover
: theme.tableBackground,
...(selected && {
backgroundColor: theme.tableRowBackgroundHighlight,
zIndex: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export function ChooseGraph({
groupBy === 'Category'
? 'groupedData'
: ['Month', 'Year'].includes(groupBy)
? 'monthData'
: 'data';
? 'monthData'
: 'data';

const saveScrollWidth = value => {
setScrollWidth(!value ? 0 : value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export function ReportSidebar({
mode === 'time'
? ['Month', 'Year']
: graphType === 'AreaGraph'
? ['Category', 'Group', 'Payee', 'Account', 'Year']
: ['Year']
? ['Category', 'Group', 'Payee', 'Account', 'Year']
: ['Year']
}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export function ReportSummary({
{balanceTypeOp === 'totalDebts'
? 'TOTAL SPENDING'
: balanceTypeOp === 'totalAssets'
? 'TOTAL DEPOSITS'
: 'NET ' + net}
? 'TOTAL DEPOSITS'
: 'NET ' + net}
</Text>
<Text
style={{
Expand Down Expand Up @@ -118,8 +118,8 @@ export function ReportSummary({
{balanceTypeOp === 'totalDebts'
? 'AVERAGE SPENDING'
: balanceTypeOp === 'totalAssets'
? 'AVERAGE DEPOSIT'
: 'AVERAGE NET'}
? 'AVERAGE DEPOSIT'
: 'AVERAGE NET'}
</Text>
<Text
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export function calculateLegend(
graphType === 'DonutGraph'
? colorScale[index % colorScale.length]
: ['Month', 'Year'].includes(groupBy)
? balanceTypeOp === 'totalDebts'
? theme.reportsRed
: theme.reportsBlue
: colorScale[index % colorScale.length],
? balanceTypeOp === 'totalDebts'
? theme.reportsRed
: theme.reportsBlue
: colorScale[index % colorScale.length],
};
});
}
Loading