Skip to content

Commit

Permalink
ESLint no-default-exports 12 - all loot-core folders except server (
Browse files Browse the repository at this point in the history
actualbudget#2184)

* ESLint no-default-exports 12 - All loot-core folders except server

* Release notes

* Fix imports
  • Loading branch information
joel-jeremy authored Jan 6, 2024
1 parent ca631f0 commit b905c1d
Show file tree
Hide file tree
Showing 77 changed files with 202 additions and 228 deletions.
18 changes: 9 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ module.exports = {
'./packages/api/app/**/*',
'./packages/crdt/**/*',
'./packages/desktop-client/**/*',
// './packages/desktop-electron/**/*',
// './packages/eslint-plugin-actual/**/*',
// './packages/loot-core/*',
// './packages/loot-core/src/client/**/*',
// './packages/loot-core/src/mocks/**/*',
// './packages/loot-core/src/platform/**/*',
'./packages/desktop-electron/**/*',
'./packages/eslint-plugin-actual/**/*',
'./packages/loot-core/*',
'./packages/loot-core/src/*',
'./packages/loot-core/src/client/**/*',
'./packages/loot-core/src/mocks/**/*',
'./packages/loot-core/src/platform/**/*',
// './packages/loot-core/src/server/**/*',
// './packages/loot-core/src/shared/**/*',
// './packages/loot-core/src/types/**/*',
// './packages/loot-core/webpack/**/*',
'./packages/loot-core/src/shared/**/*',
'./packages/loot-core/src/types/**/*',
],
rules: {
'import/no-default-export': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import hotkeys from 'hotkeys-js';
import { AccountsProvider } from 'loot-core/src/client/data-hooks/accounts';
import { PayeesProvider } from 'loot-core/src/client/data-hooks/payees';
import { SpreadsheetProvider } from 'loot-core/src/client/SpreadsheetProvider';
import checkForUpdateNotification from 'loot-core/src/client/update-notification';
import { checkForUpdateNotification } from 'loot-core/src/client/update-notification';
import * as undo from 'loot-core/src/platform/client/undo';

import { useActions } from '../hooks/useActions';
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/NotesButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react';

import q from 'loot-core/src/client/query-helpers';
import { useLiveQuery } from 'loot-core/src/client/query-hooks';
import { send } from 'loot-core/src/platform/client/fetch';
import { q } from 'loot-core/src/shared/query';

import { SvgCustomNotesPaper } from '../icons/v2';
import { type CSSProperties, theme } from '../style';
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/PrivacyFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
type ReactNode,
} from 'react';

import usePrivacyMode from 'loot-core/src/client/privacy';
import { usePrivacyMode } from 'loot-core/src/client/privacy';

import { useResponsive } from '../ResponsiveProvider';

Expand Down
10 changes: 8 additions & 2 deletions packages/desktop-client/src/components/accounts/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
useCachedSchedules,
} from 'loot-core/src/client/data-hooks/schedules';
import * as queries from 'loot-core/src/client/queries';
import q, { runQuery, pagedQuery } from 'loot-core/src/client/query-helpers';
import { runQuery, pagedQuery } from 'loot-core/src/client/query-helpers';
import { send, listen } from 'loot-core/src/platform/client/fetch';
import { currentDay } from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import { getScheduledAmount } from 'loot-core/src/shared/schedules';
import {
deleteTransaction,
Expand Down Expand Up @@ -864,7 +865,12 @@ class AccountInternal extends PureComponent {
}
};

if (name === 'amount' || name === 'payee' || name === 'account' || name === 'date') {
if (
name === 'amount' ||
name === 'payee' ||
name === 'account' ||
name === 'date'
) {
const { data } = await runQuery(
q('transactions')
.filter({ id: { $oneof: ids }, reconciled: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { useCachedSchedules } from 'loot-core/src/client/data-hooks/schedules';
import q from 'loot-core/src/client/query-helpers';
import { q } from 'loot-core/src/shared/query';
import { getScheduledAmount } from 'loot-core/src/shared/schedules';

import { useSelectedItems } from '../../hooks/useSelected';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { memo, useState } from 'react';

import { reportBudget } from 'loot-core/src/client/queries';
import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { evalArithmetic } from 'loot-core/src/shared/arithmetic';
import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util';

import { useFeatureFlag } from '../../../hooks/useFeatureFlag';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
} from 'react';

import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider';
import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { evalArithmetic } from 'loot-core/src/shared/arithmetic';
import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util';

import { Button } from '../../common/Button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { memo, useState } from 'react';

import { rolloverBudget } from 'loot-core/src/client/queries';
import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { evalArithmetic } from 'loot-core/src/shared/arithmetic';
import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util';

import { useFeatureFlag } from '../../../hooks/useFeatureFlag';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
} from 'react';

import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider';
import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { evalArithmetic } from 'loot-core/src/shared/arithmetic';
import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util';

import { useCategories } from '../../../hooks/useCategories';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { type ComponentProps, useState } from 'react';

import { useLiveQuery } from 'loot-core/src/client/query-hooks';
import q from 'loot-core/src/shared/query';
import { q } from 'loot-core/src/shared/query';
import { type CategoryGroupEntity } from 'loot-core/src/types/models';

import { useCategories } from '../../hooks/useCategories';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';

import { useLiveQuery } from 'loot-core/src/client/query-hooks';
import q from 'loot-core/src/shared/query';
import { q } from 'loot-core/src/shared/query';
import { type CategoryEntity } from 'loot-core/src/types/models';

import { useCategories } from '../../hooks/useCategories';
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop-client/src/components/modals/EditRule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
setUndoEnabled,
} from 'loot-core/src/client/actions/queries';
import { useSchedules } from 'loot-core/src/client/data-hooks/schedules';
import q, { runQuery } from 'loot-core/src/client/query-helpers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import {
mapField,
friendlyOp,
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/modals/Notes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';

import { useLiveQuery } from 'loot-core/src/client/query-hooks';
import q from 'loot-core/src/shared/query';
import { q } from 'loot-core/src/shared/query';

import { SvgCheck } from '../../icons/v2';
import { type CommonModalProps } from '../../types/modals';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ResponsiveContainer,
} from 'recharts';

import usePrivacyMode from 'loot-core/src/client/privacy';
import { usePrivacyMode } from 'loot-core/src/client/privacy';
import { amountToCurrency } from 'loot-core/src/shared/util';

import { theme } from '../../../style';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ResponsiveContainer,
} from 'recharts';

import usePrivacyMode from 'loot-core/src/client/privacy';
import { usePrivacyMode } from 'loot-core/src/client/privacy';
import { amountToCurrency } from 'loot-core/src/shared/util';

import { theme } from '../../../style';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ResponsiveContainer,
} from 'recharts';

import usePrivacyMode from 'loot-core/src/client/privacy';
import { usePrivacyMode } from 'loot-core/src/client/privacy';
import { amountToCurrency } from 'loot-core/src/shared/util';

import { theme } from '../../../style';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';

import * as d from 'date-fns';

import q from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import { integerToCurrency, integerToAmount } from 'loot-core/src/shared/util';

import { AlignedText } from '../../common/AlignedText';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import React from 'react';
import * as d from 'date-fns';

import { rolloverBudget } from 'loot-core/src/client/queries';
import q, { runQuery } from 'loot-core/src/client/query-helpers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import * as monthUtils from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import { integerToAmount, integerToCurrency } from 'loot-core/src/shared/util';

import { AlignedText } from '../../common/AlignedText';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import q from 'loot-core/src/client/query-helpers';
import { q } from 'loot-core/src/shared/query';
import { type CategoryEntity } from 'loot-core/src/types/models';

export function makeQuery(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as d from 'date-fns';

import q, { runQuery } from 'loot-core/src/client/query-helpers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import {
integerToCurrency,
integerToAmount,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import q, { runQuery } from 'loot-core/src/client/query-helpers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import { q } from 'loot-core/src/shared/query';
import { integerToAmount } from 'loot-core/src/shared/util';

export function createSpreadsheet(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import q from 'loot-core/src/client/query-helpers';
import { liveQueryContext } from 'loot-core/src/client/query-hooks';
import { q } from 'loot-core/src/shared/query';

export const SchedulesQuery = liveQueryContext(q('schedules').select('*'));
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState } from 'react';
import { useSelector } from 'react-redux';

import q, { runQuery } from 'loot-core/src/client/query-helpers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import { q } from 'loot-core/src/shared/query';
import { getRecurringDescription } from 'loot-core/src/shared/schedules';
import type { DiscoverScheduleEntity } from 'loot-core/src/types/models';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { useDispatch, useSelector } from 'react-redux';

import { pushModal } from 'loot-core/src/client/actions/modals';
import { useCachedPayees } from 'loot-core/src/client/data-hooks/payees';
import q, { runQuery, liveQuery } from 'loot-core/src/client/query-helpers';
import { runQuery, liveQuery } from 'loot-core/src/client/query-helpers';
import { send, sendCatch } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import { extractScheduleConds } from 'loot-core/src/shared/schedules';

import { useSelected, SelectedProvider } from '../../hooks/useSelected';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import {
} from 'date-fns';
import { css } from 'glamor';

import q, { runQuery } from 'loot-core/src/client/query-helpers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { q } from 'loot-core/src/shared/query';
import { getScheduledAmount } from 'loot-core/src/shared/schedules';
import {
isPreviewId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
getPayeesById,
getCategoriesById,
} from 'loot-core/src/client/reducers/queries';
import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { evalArithmetic } from 'loot-core/src/shared/arithmetic';
import { currentDay } from 'loot-core/src/shared/months';
import { getScheduledAmount } from 'loot-core/src/shared/schedules';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
type FocusEventHandler,
} from 'react';

import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { evalArithmetic } from 'loot-core/src/shared/arithmetic';
import { amountToInteger } from 'loot-core/src/shared/util';

import { useMergedRefs } from '../../hooks/useMergedRefs';
Expand Down
5 changes: 3 additions & 2 deletions packages/desktop-client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import thunk from 'redux-thunk';

import * as actions from 'loot-core/src/client/actions';
import * as constants from 'loot-core/src/client/constants';
import q, { runQuery } from 'loot-core/src/client/query-helpers';
import reducers from 'loot-core/src/client/reducers';
import { runQuery } from 'loot-core/src/client/query-helpers';
import { reducers } from 'loot-core/src/client/reducers';
import { initialState as initialAppState } from 'loot-core/src/client/reducers/app';
import { send } from 'loot-core/src/platform/client/fetch';
import { q } from 'loot-core/src/shared/query';

import { App } from './components/App';
import { ServerProvider } from './components/ServerContext';
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/data-hooks/accounts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { createContext, useContext } from 'react';

import { q } from '../../shared/query';
import { type AccountEntity } from '../../types/models';
import q from '../query-helpers';
import { useLiveQuery } from '../query-hooks';
import { getAccountsById } from '../reducers/queries';

Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/data-hooks/filters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';

import { q } from '../../shared/query';
import { type TransactionFilterEntity } from '../../types/models';
import q from '../query-helpers';
import { useLiveQuery } from '../query-hooks';

function toJS(rows) {
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/data-hooks/payees.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { createContext, useContext } from 'react';

import { q } from '../../shared/query';
import { type PayeeEntity } from '../../types/models';
import q from '../query-helpers';
import { useLiveQuery } from '../query-hooks';
import { getPayeesById } from '../reducers/queries';

Expand Down
4 changes: 2 additions & 2 deletions packages/loot-core/src/client/data-hooks/schedules.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { createContext, useEffect, useState, useContext } from 'react';

import { type Query } from '../../shared/query';
import { q, type Query } from '../../shared/query';
import { getStatus, getHasTransactionsQuery } from '../../shared/schedules';
import { type ScheduleEntity } from '../../types/models';
import q, { liveQuery } from '../query-helpers';
import { liveQuery } from '../query-helpers';

export type ScheduleStatusType = ReturnType<typeof getStatus>;
export type ScheduleStatuses = Map<ScheduleEntity['id'], ScheduleStatusType>;
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/privacy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSelector } from 'react-redux';

export default function usePrivacyMode() {
export function usePrivacyMode() {
return useSelector(state => state.prefs?.local?.isPrivacyEnabled ?? false);
}
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getShortYearRegex,
getShortYearFormat,
} from '../shared/months';
import q from '../shared/query';
import { q } from '../shared/query';
import { currencyToAmount, amountToInteger } from '../shared/util';

export function getAccountFilter(accountId, field = 'account') {
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/query-helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { initServer, serverPush } from '../platform/client/fetch';
import { subDays } from '../shared/months';
import q from '../shared/query';
import { q } from '../shared/query';
import { tracer } from '../shared/test-helpers';

import { runQuery, liveQuery, pagedQuery } from './query-helpers';
Expand Down
3 changes: 1 addition & 2 deletions packages/loot-core/src/client/query-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { listen, send } from '../platform/client/fetch';
import { once } from '../shared/async';
import q, { getPrimaryOrderBy } from '../shared/query';
export default q;
import { getPrimaryOrderBy } from '../shared/query';

export async function runQuery(query) {
return send('query', query.serialize());
Expand Down
5 changes: 1 addition & 4 deletions packages/loot-core/src/client/reducers/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ const initialState: AccountState = {
accountsSyncing: null,
};

export default function update(
state = initialState,
action: Action,
): AccountState {
export function update(state = initialState, action: Action): AccountState {
switch (action.type) {
case constants.SET_ACCOUNTS_SYNCING:
return {
Expand Down
Loading

0 comments on commit b905c1d

Please sign in to comment.