Skip to content

A local-first personal finance app

Enable most of the disabled ESLint rules (#720)

Jed Fox49eda0f4a0e9
diff --git a/.eslintrc.js b/.eslintrc.js
index 687caf2108..20a1bf6ad3 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,6 +1,7 @@
module.exports = {
plugins: ['prettier', 'import'],
extends: ['react-app'],
+ reportUnusedDisableDirectives: true,
rules: {
'prettier/prettier': 'error',
'no-unused-vars': [
@@ -11,12 +12,16 @@ module.exports = {
ignoreRestSiblings: true,
},
],
+
+ 'no-restricted-globals': ['error'].concat(
+ require('confusing-browser-globals').filter(g => g !== 'self'),
+ ),
+
+ // https://github.com/eslint/eslint/issues/16954
+ // https://github.com/eslint/eslint/issues/16953
'no-loop-func': 'off',
- 'no-restricted-globals': 'off',
// TODO: re-enable these rules
- 'import/no-anonymous-default-export': 'off',
- 'react/destructuring-assignment': 'off',
'react-hooks/exhaustive-deps': 'off',
'import/no-useless-path-segments': 'error',
diff --git a/packages/desktop-client/src/browser-server.js b/packages/desktop-client/src/browser-server.js
index b4bca929e5..c90c764e25 100644
--- a/packages/desktop-client/src/browser-server.js
+++ b/packages/desktop-client/src/browser-server.js
@@ -1,3 +1,4 @@
+/* globals importScripts, backend */
let hasInitialized = false;
self.addEventListener('message', e => {
@@ -18,10 +19,8 @@ self.addEventListener('message', e => {
return;
}
- // eslint-disable-next-line
importScripts(`${msg.publicUrl}/kcab/kcab.worker.${hash}.js`);
- // eslint-disable-next-line
backend.initApp(version, isDev, self).then(
() => {
if (isDev) {
diff --git a/packages/desktop-client/src/components/GlobalKeys.js b/packages/desktop-client/src/components/GlobalKeys.js
index 0b38966b3f..daa9ca8065 100644
--- a/packages/desktop-client/src/components/GlobalKeys.js
+++ b/packages/desktop-client/src/components/GlobalKeys.js
@@ -1,7 +1,7 @@
import React from 'react';
import { withRouter } from 'react-router-dom';
-import Platform from 'loot-core/src/client/platform';
+import * as Platform from 'loot-core/src/client/platform';
class GlobalKeys extends React.Component {
componentDidMount() {
diff --git a/packages/desktop-client/src/components/ManageRules.js b/packages/desktop-client/src/components/ManageRules.js
index 7fa9fea110..5dbf9d71ad 100644
--- a/packages/desktop-client/src/components/ManageRules.js
+++ b/packages/desktop-client/src/components/ManageRules.js
@@ -182,7 +182,7 @@ export function Value({
{numHidden > 0 && (
<Text style={{ color: colors.p4 }}>
&nbsp;&nbsp;
- {/* eslint-disable-next-line */}
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a
href="#"
onClick={onExpand}
diff --git a/packages/desktop-client/src/components/Notifications.js b/packages/desktop-client/src/components/Notifications.js
index 9ded51a928..2d62775fb4 100644
--- a/packages/desktop-client/src/components/Notifications.js
+++ b/packages/desktop-client/src/components/Notifications.js
@@ -32,7 +32,7 @@ function compileMessage(message, actions, setLoading, onRemove) {
if (href[0] === '#') {
let actionName = href.slice(1);
return (
- // eslint-disable-next-line
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
<a
href="#"
onClick={async e => {
diff --git a/packages/desktop-client/src/components/SidebarWithData.js b/packages/desktop-client/src/components/SidebarWithData.js
index 96b146b129..b63092b183 100644
--- a/packages/desktop-client/src/components/SidebarWithData.js
+++ b/packages/desktop-client/src/components/SidebarWithData.js
@@ -7,7 +7,7 @@ import { bindActionCreators } from 'redux';
import * as actions from 'loot-core/src/client/actions';
import { closeBudget } from 'loot-core/src/client/actions/budgets';
-import Platform from 'loot-core/src/client/platform';
+import * as Platform from 'loot-core/src/client/platform';
import * as queries from 'loot-core/src/client/queries';
import { send } from 'loot-core/src/platform/client/fetch';
import {
diff --git a/packages/desktop-client/src/components/Titlebar.js b/packages/desktop-client/src/components/Titlebar.js
index 585af85a88..5233286ea3 100644
--- a/packages/desktop-client/src/components/Titlebar.js
+++ b/packages/desktop-client/src/components/Titlebar.js
@@ -5,7 +5,7 @@ import { Switch, Route, withRouter } from 'react-router-dom';
import { css, media } from 'glamor';
import * as actions from 'loot-core/src/client/actions';
-import Platform from 'loot-core/src/client/platform';
+import * as Platform from 'loot-core/src/client/platform';
import * as queries from 'loot-core/src/client/queries';
import { listen } from 'loot-core/src/platform/client/fetch';
import {
@@ -230,7 +230,8 @@ function BudgetTitlebar({ globalPrefs, saveGlobalPrefs, localPrefs }) {
</ButtonWithLoading>
</P>
<P isLast={true}>
- <a // eslint-disable-line
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
+ <a
href="#"
style={{
color: colors.n4,
diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.js b/packages/desktop-client/src/components/accounts/TransactionsTable.js
index 54d15ac2c7..104d67c2ac 100644
--- a/packages/desktop-client/src/components/accounts/TransactionsTable.js
+++ b/packages/desktop-client/src/components/accounts/TransactionsTable.js
@@ -1526,7 +1526,6 @@ export let TransactionTable = React.forwardRef((props, ref) => {
let latestState = useRef({ newTransactions, newNavigator, tableNavigator });
let savePending = useRef(false);
let afterSaveFunc = useRef(false);
- // eslint-disable-next-line
let [_, forceRerender] = useState({});
let selectedItems = useSelectedItems();
@@ -1799,7 +1798,7 @@ export let TransactionTable = React.forwardRef((props, ref) => {
);
return (
- // eslint-disable-next-line
+ // eslint-disable-next-line react/jsx-pascal-case
<TransactionTable_
tableRef={mergedRef}
{...props}
diff --git a/packages/desktop-client/src/components/debug/index.js b/packages/desktop-client/src/components/debug/index.js
index e25ef7fcaf..7a9a4410c2 100644
--- a/packages/desktop-client/src/components/debug/index.js
+++ b/packages/desktop-client/src/components/debug/index.js
@@ -56,9 +56,10 @@ class Debug extends React.Component {
}
async fetchSqlGenResult() {
- let row = {}; // eslint-disable-line
+ let row = {};
try {
- row = (0, eval)('(' + this.state.sqlgenRow + ')'); // eslint-disable-line
+ // eslint-disable-next-line no-unused-vars, no-eval
+ row = (0, eval)('(' + this.state.sqlgenRow + ')');
} catch (e) {}
const res = await send('debug-sqlgen', {
diff --git a/packages/desktop-client/src/components/modals/ManageRulesModal.js b/packages/desktop-client/src/components/modals/ManageRulesModal.js
index fcd03ffad8..30d544f217 100644
--- a/packages/desktop-client/src/components/modals/ManageRulesModal.js
+++ b/packages/desktop-client/src/components/modals/ManageRulesModal.js
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
+import { useLocation } from 'react-router-dom-v5-compat';
import { Modal } from 'loot-design/src/components/common';
import {
@@ -10,6 +11,7 @@ import ManageRules from '../ManageRules';
export default function ManageRulesModal({ modalProps, payeeId }) {
let [loading, setLoading] = useState(true);
+ let location = useLocation();
if (isDevelopmentEnvironment() || isPreviewEnvironment()) {
if (location.pathname !== '/payees') {
throw new Error(
diff --git a/packages/desktop-client/src/components/reports/chart-theme.js b/packages/desktop-client/src/components/reports/chart-theme.js
index 04137fa19e..280bfae6f9 100644
--- a/packages/desktop-client/src/components/reports/chart-theme.js
+++ b/packages/desktop-client/src/components/reports/chart-theme.js
@@ -41,7 +41,7 @@ const axisBaseStyles = {
tickLabels: baseLabelStyles,
};
-export default {
+const theme = {
colors: {
...colorFades,
red: colors.r7,
@@ -111,3 +111,4 @@ export default {
},
},
};
+export default theme;
diff --git a/packages/desktop-client/src/components/settings/index.js b/packages/desktop-client/src/components/settings/index.js
index bb7b2f589c..3a370d72f5 100644
--- a/packages/desktop-client/src/components/settings/index.js
+++ b/packages/desktop-client/src/components/settings/index.js
@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { css, media } from 'glamor';
import * as actions from 'loot-core/src/client/actions';
-import Platform from 'loot-core/src/client/platform';
+import * as Platform from 'loot-core/src/client/platform';
import { listen } from 'loot-core/src/platform/client/fetch';
import { View, Text, Button, Input } from 'loot-design/src/components/common';
import { FormField, FormLabel } from 'loot-design/src/components/forms';
diff --git a/packages/desktop-client/src/index.js b/packages/desktop-client/src/index.js
index 5658e3b87a..75eaa1c2c7 100644
--- a/packages/desktop-client/src/index.js
+++ b/packages/desktop-client/src/index.js
@@ -20,7 +20,7 @@ import {
import thunk from 'redux-thunk';
import * as actions from 'loot-core/src/client/actions';
-import constants from 'loot-core/src/client/constants';
+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 { initialState as initialAppState } from 'loot-core/src/client/reducers/app';
diff --git a/packages/loot-core/src/client/actions/account.js b/packages/loot-core/src/client/actions/account.js
index ede6c96ea6..55686982b6 100644
--- a/packages/loot-core/src/client/actions/account.js
+++ b/packages/loot-core/src/client/actions/account.js
@@ -1,5 +1,5 @@
import { send } from '../../platform/client/fetch';
-import constants from '../constants';
+import * as constants from '../constants';
import { addNotification } from './notifications';
import { getPayees, getAccounts } from './queries';
diff --git a/packages/loot-core/src/client/actions/app.js b/packages/loot-core/src/client/actions/app.js
index f976e24044..1230fc76d3 100644
--- a/packages/loot-core/src/client/actions/app.js
+++ b/packages/loot-core/src/client/actions/app.js
@@ -1,5 +1,5 @@
import { send } from '../../platform/client/fetch';
-import constants from '../constants';
+import * as constants from '../constants';
export function setAppState(state) {
return {
diff --git a/packages/loot-core/src/client/actions/budgets.js b/packages/loot-core/src/client/actions/budgets.js
index 295761727f..aea38d9f98 100644
--- a/packages/loot-core/src/client/actions/budgets.js
+++ b/packages/loot-core/src/client/actions/budgets.js
@@ -1,6 +1,6 @@
import { send } from '../../platform/client/fetch';
import { getDownloadError, getSyncError } from '../../shared/errors';
-import constants from '../constants';
+import * as constants from '../constants';
import { setAppState } from './app';
import { closeModal, pushModal } from './modals';
@@ -68,10 +68,8 @@ export function loadBudget(id, loadingText = '', options = {}) {
let message = getSyncError(error, id);
if (error === 'out-of-sync-migrations' || error === 'out-of-sync-data') {
// confirm is not available on iOS
- // eslint-disable-next-line
- if (typeof confirm !== 'undefined') {
- // eslint-disable-next-line
- let showBackups = confirm(
+ if (typeof window.confirm !== 'undefined') {
+ let showBackups = window.confirm(
message +
' Make sure the app is up-to-date. Do you want to load a backup?',
);
@@ -112,7 +110,7 @@ export function closeBudget() {
await send('close-budget');
dispatch(setAppState({ loadingText: null }));
if (localStorage.getItem('SharedArrayBufferOverride')) {
- location.reload();
+ window.location.reload();
}
}
};
diff --git a/packages/loot-core/src/client/actions/debug.js b/packages/loot-core/src/client/actions/debug.js
index 0c44b8df39..cad70bd366 100644
--- a/packages/loot-core/src/client/actions/debug.js
+++ b/packages/loot-core/src/client/actions/debug.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
export function debugCell(sheet, name) {
return {
diff --git a/packages/loot-core/src/client/actions/modals.js b/packages/loot-core/src/client/actions/modals.js
index d1e33ee8f8..04d5d31a44 100644
--- a/packages/loot-core/src/client/actions/modals.js
+++ b/packages/loot-core/src/client/actions/modals.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
export function pushModal(name, options) {
return { type: constants.PUSH_MODAL, name, options };
diff --git a/packages/loot-core/src/client/actions/notifications.js b/packages/loot-core/src/client/actions/notifications.js
index 2610cf1828..9bd8be621f 100644
--- a/packages/loot-core/src/client/actions/notifications.js
+++ b/packages/loot-core/src/client/actions/notifications.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const uuid = require('../../platform/uuid');
diff --git a/packages/loot-core/src/client/actions/prefs.js b/packages/loot-core/src/client/actions/prefs.js
index 8aedebe070..e0236cdd40 100644
--- a/packages/loot-core/src/client/actions/prefs.js
+++ b/packages/loot-core/src/client/actions/prefs.js
@@ -1,5 +1,5 @@
import { send } from '../../platform/client/fetch';
-import constants from '../constants';
+import * as constants from '../constants';
import { closeModal } from './modals';
diff --git a/packages/loot-core/src/client/actions/queries.js b/packages/loot-core/src/client/actions/queries.js
index e52c06c1c6..d324a627f6 100644
--- a/packages/loot-core/src/client/actions/queries.js
+++ b/packages/loot-core/src/client/actions/queries.js
@@ -1,7 +1,7 @@
import throttle from 'throttleit';
import { send } from '../../platform/client/fetch';
-import constants from '../constants';
+import * as constants from '../constants';
import { pushModal } from './modals';
import { addNotification, addGenericErrorNotification } from './notifications';
diff --git a/packages/loot-core/src/client/actions/sync.js b/packages/loot-core/src/client/actions/sync.js
index d5776a1027..0c4a7b02fa 100644
--- a/packages/loot-core/src/client/actions/sync.js
+++ b/packages/loot-core/src/client/actions/sync.js
@@ -1,6 +1,6 @@
import { send } from '../../platform/client/fetch';
import { getUploadError } from '../../shared/errors';
-import constants from '../constants';
+import * as constants from '../constants';
import { syncAccounts } from './account';
import { pushModal } from './modals';
diff --git a/packages/loot-core/src/client/actions/tutorial.js b/packages/loot-core/src/client/actions/tutorial.js
index f1c848188f..3e67185797 100644
--- a/packages/loot-core/src/client/actions/tutorial.js
+++ b/packages/loot-core/src/client/actions/tutorial.js
@@ -1,5 +1,5 @@
import { send } from '../../platform/client/fetch';
-import Platform from '../platform';
+import * as Platform from '../platform';
import { pushModal } from './modals';
diff --git a/packages/loot-core/src/client/actions/user.js b/packages/loot-core/src/client/actions/user.js
index 5fe274dae9..accdd2b413 100644
--- a/packages/loot-core/src/client/actions/user.js
+++ b/packages/loot-core/src/client/actions/user.js
@@ -1,5 +1,5 @@
import { send } from '../../platform/client/fetch';
-import constants from '../constants';
+import * as constants from '../constants';
import { loadAllFiles, closeBudget } from './budgets';
import { loadGlobalPrefs } from './prefs';
diff --git a/packages/loot-core/src/client/constants.js b/packages/loot-core/src/client/constants.js
index 469f413bf8..528d2769cf 100644
--- a/packages/loot-core/src/client/constants.js
+++ b/packages/loot-core/src/client/constants.js
@@ -1,43 +1,41 @@
-export default {
- LOAD_TRANSACTIONS: 'LOAD_TRANSACTIONS',
- SET_NEW_TRANSACTIONS: 'SET_NEW_TRANSACTIONS',
- UPDATE_NEW_TRANSACTIONS: 'UPDATE_NEW_TRANSACTIONS',
- SET_LAST_TRANSACTION: 'SET_LAST_TRANSACTION',
- MARK_ACCOUNT_READ: 'MARK_ACCOUNT_READ',
- LOAD_ACCOUNTS: 'LOAD_ACCOUNTS',
- UPDATE_ACCOUNT: 'UPDATE_ACCOUNT',
- LOAD_CATEGORIES: 'LOAD_CATEGORIES',
- ADD_CATEGORY: 'ADD_CATEGORY',
- DELETE_CATEGORY: 'DELETE_CATEGORY',
- LOAD_PAYEES: 'LOAD_PAYEES',
- LOAD_BANKS: 'LOAD_BANKS',
- SET_PROFILE: 'SET_PROFILE',
- SET_PREFS: 'SET_PREFS',
- MERGE_LOCAL_PREFS: 'MERGE_LOCAL_PREFS',
- MERGE_GLOBAL_PREFS: 'MERGE_GLOBAL_PREFS',
- SET_BUDGETS: 'SET_BUDGETS',
- SET_REMOTE_FILES: 'SET_REMOTE_FILES',
- SET_ALL_FILES: 'SET_ALL_FILES',
- SET_AVAILABLE_IMPORTS: 'SET_AVAILABLE_IMPORTS',
- CLOSE_BUDGET: 'CLOSE_BUDGET',
- SET_APP_STATE: 'SET_APP_STATE',
- DEBUG_CELL: 'DEBUG_CELL',
- PUSH_MODAL: 'PUSH_MODAL',
- REPLACE_MODAL: 'REPLACE_MODAL',
- HIDE_MODALS: 'HIDE_MODALS',
- SHOW_MODALS: 'SHOW_MODALS',
- CLOSE_MODAL: 'CLOSE_MODAL',
- POP_MODAL: 'POP_MODAL',
- ADD_NOTIFICATION: 'ADD_NOTIFICATION',
- REMOVE_NOTIFICATION: 'REMOVE_NOTIFICATION',
- GET_USER_DATA: 'GET_USER_DATA',
- SET_LAST_UNDO_STATE: 'SET_LAST_UNDO_STATE',
- SET_LAST_SPLIT_STATE: 'SET_LAST_SPLIT_STATE',
- SET_ACCOUNTS_SYNCING: 'SET_ACCOUNTS_SYNCING',
- ACCOUNT_SYNC_STATUS: 'ACCOUNT_SYNC_STATUS',
- ACCOUNT_SYNC_FAILURES: 'ACCOUNT_SYNC_FAILURES',
- SIGN_OUT: 'SIGN_OUT',
+export const LOAD_TRANSACTIONS = 'LOAD_TRANSACTIONS';
+export const SET_NEW_TRANSACTIONS = 'SET_NEW_TRANSACTIONS';
+export const UPDATE_NEW_TRANSACTIONS = 'UPDATE_NEW_TRANSACTIONS';
+export const SET_LAST_TRANSACTION = 'SET_LAST_TRANSACTION';
+export const MARK_ACCOUNT_READ = 'MARK_ACCOUNT_READ';
+export const LOAD_ACCOUNTS = 'LOAD_ACCOUNTS';
+export const UPDATE_ACCOUNT = 'UPDATE_ACCOUNT';
+export const LOAD_CATEGORIES = 'LOAD_CATEGORIES';
+export const ADD_CATEGORY = 'ADD_CATEGORY';
+export const DELETE_CATEGORY = 'DELETE_CATEGORY';
+export const LOAD_PAYEES = 'LOAD_PAYEES';
+export const LOAD_BANKS = 'LOAD_BANKS';
+export const SET_PROFILE = 'SET_PROFILE';
+export const SET_PREFS = 'SET_PREFS';
+export const MERGE_LOCAL_PREFS = 'MERGE_LOCAL_PREFS';
+export const MERGE_GLOBAL_PREFS = 'MERGE_GLOBAL_PREFS';
+export const SET_BUDGETS = 'SET_BUDGETS';
+export const SET_REMOTE_FILES = 'SET_REMOTE_FILES';
+export const SET_ALL_FILES = 'SET_ALL_FILES';
+export const SET_AVAILABLE_IMPORTS = 'SET_AVAILABLE_IMPORTS';
+export const CLOSE_BUDGET = 'CLOSE_BUDGET';
+export const SET_APP_STATE = 'SET_APP_STATE';
+export const DEBUG_CELL = 'DEBUG_CELL';
+export const PUSH_MODAL = 'PUSH_MODAL';
+export const REPLACE_MODAL = 'REPLACE_MODAL';
+export const HIDE_MODALS = 'HIDE_MODALS';
+export const SHOW_MODALS = 'SHOW_MODALS';
+export const CLOSE_MODAL = 'CLOSE_MODAL';
+export const POP_MODAL = 'POP_MODAL';
+export const ADD_NOTIFICATION = 'ADD_NOTIFICATION';
+export const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION';
+export const GET_USER_DATA = 'GET_USER_DATA';
+export const SET_LAST_UNDO_STATE = 'SET_LAST_UNDO_STATE';
+export const SET_LAST_SPLIT_STATE = 'SET_LAST_SPLIT_STATE';
+export const SET_ACCOUNTS_SYNCING = 'SET_ACCOUNTS_SYNCING';
+export const ACCOUNT_SYNC_STATUS = 'ACCOUNT_SYNC_STATUS';
+export const ACCOUNT_SYNC_FAILURES = 'ACCOUNT_SYNC_FAILURES';
+export const SIGN_OUT = 'SIGN_OUT';
- SET_TUTORIAL_STAGE: 'SET_TUTORIAL_STAGE',
- DEACTIVATE_TUTORIAL: 'DEACTIVATE_TUTORIAL',
-};
+export const SET_TUTORIAL_STAGE = 'SET_TUTORIAL_STAGE';
+export const DEACTIVATE_TUTORIAL = 'DEACTIVATE_TUTORIAL';
diff --git a/packages/loot-core/src/client/platform.js b/packages/loot-core/src/client/platform.js
index 9152366391..20e2fd00bd 100644
--- a/packages/loot-core/src/client/platform.js
+++ b/packages/loot-core/src/client/platform.js
@@ -4,13 +4,10 @@ const isWindows =
const isMac =
navigator.platform && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
-const isProbablySafari = /^((?!chrome|android).)*safari/i.test(
+export const isProbablySafari = /^((?!chrome|android).)*safari/i.test(
navigator.userAgent,
);
-export default {
- OS: isWindows ? 'windows' : isMac ? 'mac' : 'linux',
- env: 'web',
- isBrowser: !!window.Actual?.IS_FAKE_WEB,
- isProbablySafari,
-};
+export const OS = isWindows ? 'windows' : isMac ? 'mac' : 'linux';
+export const env = 'web';
+export const isBrowser = !!window.Actual?.IS_FAKE_WEB;
diff --git a/packages/loot-core/src/client/reducers/account.js b/packages/loot-core/src/client/reducers/account.js
index 3c42c00cef..3fb71e659c 100644
--- a/packages/loot-core/src/client/reducers/account.js
+++ b/packages/loot-core/src/client/reducers/account.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
banks: [],
diff --git a/packages/loot-core/src/client/reducers/app.js b/packages/loot-core/src/client/reducers/app.js
index 558bc5cbe6..6fe4dc3685 100644
--- a/packages/loot-core/src/client/reducers/app.js
+++ b/packages/loot-core/src/client/reducers/app.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
export const initialState = {
loadingText: null,
diff --git a/packages/loot-core/src/client/reducers/budgets.js b/packages/loot-core/src/client/reducers/budgets.js
index 6359a8f447..45a7ee28fc 100644
--- a/packages/loot-core/src/client/reducers/budgets.js
+++ b/packages/loot-core/src/client/reducers/budgets.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
function sortFiles(arr) {
arr.sort((x, y) => {
diff --git a/packages/loot-core/src/client/reducers/debug.js b/packages/loot-core/src/client/reducers/debug.js
index be86400e57..24d461269f 100644
--- a/packages/loot-core/src/client/reducers/debug.js
+++ b/packages/loot-core/src/client/reducers/debug.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
selectedCell: null,
diff --git a/packages/loot-core/src/client/reducers/index.js b/packages/loot-core/src/client/reducers/index.js
index 0a90b63619..1253ce09e0 100644
--- a/packages/loot-core/src/client/reducers/index.js
+++ b/packages/loot-core/src/client/reducers/index.js
@@ -10,7 +10,7 @@ import queries from './queries';
import tutorial from './tutorial';
import user from './user';
-export default {
+const reducers = {
app,
queries,
account,
@@ -23,3 +23,4 @@ export default {
tutorial,
user,
};
+export default reducers;
diff --git a/packages/loot-core/src/client/reducers/modals.js b/packages/loot-core/src/client/reducers/modals.js
index 85beb36f46..0bdd2246d5 100644
--- a/packages/loot-core/src/client/reducers/modals.js
+++ b/packages/loot-core/src/client/reducers/modals.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
modalStack: [],
diff --git a/packages/loot-core/src/client/reducers/notifications.js b/packages/loot-core/src/client/reducers/notifications.js
index ef94ff2b2d..3bacabe343 100644
--- a/packages/loot-core/src/client/reducers/notifications.js
+++ b/packages/loot-core/src/client/reducers/notifications.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
notifications: [],
diff --git a/packages/loot-core/src/client/reducers/prefs.js b/packages/loot-core/src/client/reducers/prefs.js
index f15fcc1b69..56010e5d37 100644
--- a/packages/loot-core/src/client/reducers/prefs.js
+++ b/packages/loot-core/src/client/reducers/prefs.js
@@ -1,5 +1,5 @@
import { setNumberFormat } from '../../shared/util.js';
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
local: null,
diff --git a/packages/loot-core/src/client/reducers/profile.js b/packages/loot-core/src/client/reducers/profile.js
index cb4a8a52f2..740c8cb31a 100644
--- a/packages/loot-core/src/client/reducers/profile.js
+++ b/packages/loot-core/src/client/reducers/profile.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {};
diff --git a/packages/loot-core/src/client/reducers/queries.js b/packages/loot-core/src/client/reducers/queries.js
index 8a10c36a30..96fa91b71a 100644
--- a/packages/loot-core/src/client/reducers/queries.js
+++ b/packages/loot-core/src/client/reducers/queries.js
@@ -1,7 +1,7 @@
import memoizeOne from 'memoize-one';
import { groupById } from '../../shared/util';
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
newTransactions: [],
diff --git a/packages/loot-core/src/client/reducers/tutorial.js b/packages/loot-core/src/client/reducers/tutorial.js
index 70abf855c2..ea4bcc7571 100644
--- a/packages/loot-core/src/client/reducers/tutorial.js
+++ b/packages/loot-core/src/client/reducers/tutorial.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
stage: null,
diff --git a/packages/loot-core/src/client/reducers/user.js b/packages/loot-core/src/client/reducers/user.js
index 0d13621631..5af8ed05d1 100644
--- a/packages/loot-core/src/client/reducers/user.js
+++ b/packages/loot-core/src/client/reducers/user.js
@@ -1,4 +1,4 @@
-import constants from '../constants';
+import * as constants from '../constants';
const initialState = {
data: null,
diff --git a/packages/loot-core/src/client/upgrade-notifications.js b/packages/loot-core/src/client/upgrade-notifications.js
index 989b171f26..c2eca0d2a1 100644
--- a/packages/loot-core/src/client/upgrade-notifications.js
+++ b/packages/loot-core/src/client/upgrade-notifications.js
@@ -1,6 +1,6 @@
import { send } from '../platform/client/fetch';
-import Platform from './platform';
+import * as Platform from './platform';
export default function checkForUpgradeNotifications(
addNotification,
@@ -33,12 +33,9 @@ export default function checkForUpgradeNotifications(
button: Platform.env !== 'mobile' && {
title: 'Find schedules',
action: async () => {
- // eslint-disable-next-line
- __history &&
- // eslint-disable-next-line
- __history.push('/schedule/discover', {
- // eslint-disable-next-line
- locationPtr: __history.location
+ window.__history &&
+ window.__history.push('/schedule/discover', {
+ locationPtr: window.__history.location,
});
},
},
diff --git a/packages/loot-core/src/mocks/arbitrary-schema.js b/packages/loot-core/src/mocks/arbitrary-schema.js
index 13fcd11f8f..0e1715b22d 100644
--- a/packages/loot-core/src/mocks/arbitrary-schema.js
+++ b/packages/loot-core/src/mocks/arbitrary-schema.js
@@ -3,7 +3,7 @@ import fc from 'fast-check';
import { schema } from '../server/aql';
import { addDays } from '../shared/months';
-function typeArbitrary(typeDesc, name) {
+export function typeArbitrary(typeDesc, name) {
let arb;
switch (typeDesc.type) {
case 'id':
@@ -51,7 +51,7 @@ function typeArbitrary(typeDesc, name) {
return arb;
}
-function flattenSortTransactions(arr) {
+export function flattenSortTransactions(arr) {
let flattened = arr.reduce((list, trans) => {
let { subtransactions, ...fields } = trans;
@@ -117,7 +117,7 @@ function tableArbitrary(tableSchema, extraArbs, requiredKeys = []) {
return arb;
}
-function makeTransaction({ splitFreq = 1, payeeIds } = {}) {
+export function makeTransaction({ splitFreq = 1, payeeIds } = {}) {
let payeeField = payeeIds
? { payee: fc.oneof(...payeeIds.map(id => fc.constant(id))) }
: null;
@@ -137,18 +137,13 @@ function makeTransaction({ splitFreq = 1, payeeIds } = {}) {
);
}
-export default {
- typeArbitrary,
- flattenSortTransactions,
- makeTransaction: makeTransaction,
- makeTransactionArray: (options = {}) => {
- let { minLength, maxLength, ...transOpts } = options;
- return fc
- .array(makeTransaction(transOpts), { minLength, maxLength })
- .map(arr => flattenSortTransactions(arr));
- },
- payee: tableArbitrary(schema.payees),
- account: tableArbitrary(schema.accounts),
- category: tableArbitrary(schema.categories),
- category_group: tableArbitrary(schema.category_groups),
+export const makeTransactionArray = (options = {}) => {
+ let { minLength, maxLength, ...transOpts } = options;
+ return fc
+ .array(makeTransaction(transOpts), { minLength, maxLength })
+ .map(arr => flattenSortTransactions(arr));
};
+export const payee = tableArbitrary(schema.payees);
+export const account = tableArbitrary(schema.accounts);
+export const category = tableArbitrary(schema.categories);
+export const category_group = tableArbitrary(schema.category_groups);
diff --git a/packages/loot-core/src/platform/server/connection/index.web.js b/packages/loot-core/src/platform/server/connection/index.web.js
index 2bd1e317da..d80cff1ed8 100644
--- a/packages/loot-core/src/platform/server/connection/index.web.js
+++ b/packages/loot-core/src/platform/server/connection/index.web.js
@@ -27,7 +27,6 @@ function coerceError(error) {
function init(serverChannel, handlers) {
getGlobalObject().__globalServerChannel = serverChannel;
- // eslint-disable-next-line
serverChannel.addEventListener(
'message',
e => {
diff --git a/packages/loot-core/src/platform/server/log/index.api.js b/packages/loot-core/src/platform/server/log/index.api.js
index 9c4c7b023c..53750a6f75 100644
--- a/packages/loot-core/src/platform/server/log/index.api.js
+++ b/packages/loot-core/src/platform/server/log/index.api.js
@@ -1,4 +1,4 @@
-export default {
+const logger = {
info: (...args) => {
console.log(...args);
},
@@ -6,3 +6,4 @@ export default {
console.warn(...args);
},
};
+export default logger;
diff --git a/packages/loot-core/src/platform/server/log/index.web.js b/packages/loot-core/src/platform/server/log/index.web.js
index 9c4c7b023c..53750a6f75 100644
--- a/packages/loot-core/src/platform/server/log/index.web.js
+++ b/packages/loot-core/src/platform/server/log/index.web.js
@@ -1,4 +1,4 @@
-export default {
+const logger = {
info: (...args) => {
console.log(...args);
},
@@ -6,3 +6,4 @@ export default {
console.warn(...args);
},
};
+export default logger;
diff --git a/packages/loot-core/src/server/api.js b/packages/loot-core/src/server/api.js
index 57c328a17b..0c348226ea 100644
--- a/packages/loot-core/src/server/api.js
+++ b/packages/loot-core/src/server/api.js
@@ -574,7 +574,7 @@ handlers['api/payee-rule-delete'] = withMutation(async function ({ id }) {
return handlers['payees-delete-rule']({ id });
});
-export default function (serverHandlers) {
+export default function installAPI(serverHandlers) {
handlers = Object.assign({}, serverHandlers, handlers);
return handlers;
}
diff --git a/packages/loot-core/src/server/aql/compiler.js b/packages/loot-core/src/server/aql/compiler.js
index 0bf6642eb8..a5ad99f43f 100644
--- a/packages/loot-core/src/server/aql/compiler.js
+++ b/packages/loot-core/src/server/aql/compiler.js
@@ -218,7 +218,7 @@ function inferParam(param, type) {
(!casts[type] || !casts[type].includes(existingType))
) {
throw new Error(
- `Parameter "${name}" can't convert to ${type} (already inferred as ${existingType})`,
+ `Parameter "${param.paramName}" can't convert to ${type} (already inferred as ${existingType})`,
);
}
} else {
diff --git a/packages/loot-core/src/server/aql/schema/executors.js b/packages/loot-core/src/server/aql/schema/executors.js
index 2784f1f2c7..df3c229a98 100644
--- a/packages/loot-core/src/server/aql/schema/executors.js
+++ b/packages/loot-core/src/server/aql/schema/executors.js
@@ -215,6 +215,6 @@ async function execTransactionsBasic(
return execQuery(queryState, state, s, params, outputTypes);
}
-export default {
+export const schemaExecutors = {
transactions: execTransactions,
};
diff --git a/packages/loot-core/src/server/aql/schema/executors.test.js b/packages/loot-core/src/server/aql/schema/executors.test.js
index 1d9d9187f7..6559186809 100644
--- a/packages/loot-core/src/server/aql/schema/executors.test.js
+++ b/packages/loot-core/src/server/aql/schema/executors.test.js
@@ -1,6 +1,6 @@
import fc from 'fast-check';
-import arbs from '../../../mocks/arbitrary-schema';
+import * as arbs from '../../../mocks/arbitrary-schema';
import query from '../../../shared/query';
import { groupById } from '../../../shared/util';
import { setClock } from '../../crdt';
diff --git a/packages/loot-core/src/server/aql/schema/run-query.js b/packages/loot-core/src/server/aql/schema/run-query.js
index de78a332cc..9235717ba2 100644
--- a/packages/loot-core/src/server/aql/schema/run-query.js
+++ b/packages/loot-core/src/server/aql/schema/run-query.js
@@ -4,7 +4,7 @@ import {
runCompiledQuery as _runCompiledQuery,
} from '../exec';
-import schemaExecutors from './executors';
+import { schemaExecutors } from './executors';
import { schema, schemaConfig } from './index';
diff --git a/packages/loot-core/src/server/cloud-storage.js b/packages/loot-core/src/server/cloud-storage.js
index 04096a6241..fd5a9a5cdb 100644
--- a/packages/loot-core/src/server/cloud-storage.js
+++ b/packages/loot-core/src/server/cloud-storage.js
@@ -4,7 +4,7 @@ import fs from '../platform/server/fs';
import * as sqlite from '../platform/server/sqlite';
import * as monthUtils from '../shared/months';
-import encryption from './encryption';
+import * as encryption from './encryption';
import {
HTTPError,
PostError,
@@ -54,11 +54,11 @@ export async function checkKey() {
return { error: { reason: 'network' } };
}
- // This == comparison is important, they could be null or undefined
- // eslint-disable-next-line
return {
valid:
- res.id == encryptKeyId && // eslint-disable-line
+ // This == comparison is important, they could be null or undefined
+ // eslint-disable-next-line eqeqeq
+ res.id == encryptKeyId &&
(encryptKeyId == null || encryption.hasKey(encryptKeyId)),
};
}
diff --git a/packages/loot-core/src/server/encryption.js b/packages/loot-core/src/server/encryption.js
index c76ea23352..85502e8a16 100644
--- a/packages/loot-core/src/server/encryption.js
+++ b/packages/loot-core/src/server/encryption.js
@@ -7,7 +7,7 @@ let uuid = require('../platform/uuid/index.electron.js');
let keys = {};
class Key {
- constructor({ id, value }) {
+ constructor({ id }) {
this.id = id || uuid.v4Sync();
}
@@ -35,30 +35,30 @@ class Key {
}
}
-function getKey(keyId) {
+export function getKey(keyId) {
if (keyId == null || keys[keyId] == null) {
throw new Error('missing-key');
}
return keys[keyId];
}
-function hasKey(keyId) {
+export function hasKey(keyId) {
return keyId in keys;
}
-function encrypt(value, keyId) {
+export function encrypt(value, keyId) {
return internals.encrypt(getKey(keyId), value);
}
-function decrypt(encrypted, meta) {
+export function decrypt(encrypted, meta) {
return internals.decrypt(getKey(meta.keyId), encrypted, meta);
}
-function randomBytes(n) {
+export function randomBytes(n) {
return internals.randomBytes(n);
}
-async function loadKey(key) {
+export async function loadKey(key) {
let keyInstance;
if (!(key instanceof Key)) {
keyInstance = new Key({ id: key.id });
@@ -70,28 +70,16 @@ async function loadKey(key) {
keys[keyInstance.getId()] = keyInstance;
}
-function unloadKey(key) {
+export function unloadKey(key) {
delete keys[key.getId()];
}
-function unloadAllKeys() {
+export function unloadAllKeys() {
keys = {};
}
-async function createKey({ id, password, salt }) {
+export async function createKey({ id, password, salt }) {
let key = new Key({ id });
await key.createFromPassword({ password, salt });
return key;
}
-
-export default {
- decrypt,
- encrypt,
- randomBytes,
- createKey,
- loadKey,
- getKey,
- hasKey,
- unloadKey,
- unloadAllKeys,
-};
diff --git a/packages/loot-core/src/server/encryption.test.js b/packages/loot-core/src/server/encryption.test.js
index a1dfe57a1d..3a9b249986 100644
--- a/packages/loot-core/src/server/encryption.test.js
+++ b/packages/loot-core/src/server/encryption.test.js
@@ -1,4 +1,4 @@
-import encryption from './encryption';
+import * as encryption from './encryption';
afterEach(() => encryption.unloadAllKeys());
diff --git a/packages/loot-core/src/server/errors.js b/packages/loot-core/src/server/errors.js
index 1c88de3106..418c2df774 100644
--- a/packages/loot-core/src/server/errors.js
+++ b/packages/loot-core/src/server/errors.js
@@ -25,7 +25,7 @@ export class SyncError extends Error {
}
export class TransactionError extends Error {
- // eslint-disable-next-line
+ // eslint-disable-next-line no-useless-constructor
constructor(message) {
super(message);
}
diff --git a/packages/loot-core/src/server/main.js b/packages/loot-core/src/server/main.js
index cb8ae00984..89e0ba1a26 100644
--- a/packages/loot-core/src/server/main.js
+++ b/packages/loot-core/src/server/main.js
@@ -45,12 +45,12 @@ import {
} from './crdt';
import * as db from './db';
import * as mappings from './db/mappings';
-import encryption from './encryption';
+import * as encryption from './encryption';
import { APIError, TransactionError, PostError, RuleError } from './errors';
import app from './main-app';
import { mutator, runHandler } from './mutators';
import notesApp from './notes/app';
-import Platform from './platform';
+import * as Platform from './platform';
import { get, post } from './post';
import * as prefs from './prefs';
import schedulesApp from './schedules/app';
@@ -2412,7 +2412,7 @@ export async function initApp(version, isDev, socketName) {
export async function init(config) {
// Get from build
- // eslint-disable-next-line
+ // eslint-disable-next-line no-undef
VERSION = ACTUAL_APP_VERSION;
let dataDir, serverURL;
diff --git a/packages/loot-core/src/server/platform.js b/packages/loot-core/src/server/platform.js
index 75692d92ee..0c67da480a 100644
--- a/packages/loot-core/src/server/platform.js
+++ b/packages/loot-core/src/server/platform.js
@@ -1,5 +1,3 @@
-export default {
- isMobile: false,
- isWeb: false,
- isDesktop: true,
-};
+export const isMobile = false;
+export const isWeb = false;
+export const isDesktop = true;
diff --git a/packages/loot-core/src/server/platform.web.js b/packages/loot-core/src/server/platform.web.js
index 71d68d5424..c502596036 100644
--- a/packages/loot-core/src/server/platform.web.js
+++ b/packages/loot-core/src/server/platform.web.js
@@ -1,5 +1,3 @@
-export default {
- isMobile: false,
- isWeb: true,
- isDesktop: false,
-};
+export const isMobile = false;
+export const isWeb = true;
+export const isDesktop = false;
diff --git a/packages/loot-core/src/server/post.js b/packages/loot-core/src/server/post.js
index 104fb4d7ac..42e2f02d00 100644
--- a/packages/loot-core/src/server/post.js
+++ b/packages/loot-core/src/server/post.js
@@ -1,4 +1,4 @@
-import Platform from './platform';
+import * as Platform from './platform';
const { fetch } = require('../platform/server/fetch');
diff --git a/packages/loot-core/src/server/sheet.js b/packages/loot-core/src/server/sheet.js
index a11eafccdd..dc23c4b5b0 100644
--- a/packages/loot-core/src/server/sheet.js
+++ b/packages/loot-core/src/server/sheet.js
@@ -2,7 +2,7 @@ import { captureBreadcrumb } from '../platform/exceptions';
import * as sqlite from '../platform/server/sqlite';
import { sheetForMonth } from '../shared/months';
-import Platform from './platform';
+import * as Platform from './platform';
import * as prefs from './prefs';
import Spreadsheet from './spreadsheet/spreadsheet';
diff --git a/packages/loot-core/src/server/sync/encoder.js b/packages/loot-core/src/server/sync/encoder.js
index 51f096e2ff..baa976edd0 100644
--- a/packages/loot-core/src/server/sync/encoder.js
+++ b/packages/loot-core/src/server/sync/encoder.js
@@ -1,4 +1,4 @@
-import encryption from '../encryption';
+import * as encryption from '../encryption';
import * as prefs from '../prefs';
let { SyncError } = require('../errors');
diff --git a/packages/loot-core/src/server/sync/make-test-message.js b/packages/loot-core/src/server/sync/make-test-message.js
index 88ebf1c420..01af04b3f8 100644
--- a/packages/loot-core/src/server/sync/make-test-message.js
+++ b/packages/loot-core/src/server/sync/make-test-message.js
@@ -1,4 +1,4 @@
-import encryption from '../encryption';
+import * as encryption from '../encryption';
let SyncPb = require('./proto/sync_pb');
diff --git a/packages/loot-core/src/server/sync/migrate.test.js b/packages/loot-core/src/server/sync/migrate.test.js
index d1f58a626b..41a061fb76 100644
--- a/packages/loot-core/src/server/sync/migrate.test.js
+++ b/packages/loot-core/src/server/sync/migrate.test.js
@@ -1,6 +1,6 @@
import fc from 'fast-check';
-import arbs from '../../mocks/arbitrary-schema';
+import * as arbs from '../../mocks/arbitrary-schema';
import { execTracer } from '../../shared/test-helpers';
import { convertInputType, schema, schemaConfig } from '../aql';
import * as db from '../db';
diff --git a/packages/loot-design/src/components/common.js b/packages/loot-design/src/components/common.js
index cc86b99627..1d7ac6b0d1 100644
--- a/packages/loot-design/src/components/common.js
+++ b/packages/loot-design/src/components/common.js
@@ -185,7 +185,6 @@ function ButtonLink_({
);
}
-// eslint-disable-next-line
export const ButtonLink = withRouter(ButtonLink_);
export const Button = React.forwardRef(
diff --git a/packages/loot-design/src/components/modals/CloseAccount.js b/packages/loot-design/src/components/modals/CloseAccount.js
index a1e08274dc..66b7f6817e 100644
--- a/packages/loot-design/src/components/modals/CloseAccount.js
+++ b/packages/loot-design/src/components/modals/CloseAccount.js
@@ -178,7 +178,8 @@ function CloseAccount({
{!canDelete && (
<View style={{ marginBottom: 15 }}>
<Text style={{ fontSize: 12 }}>
- You can also {/* eslint-disable-next-line */}
+ You can also{' '}
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a
href="#"
onClick={e => {
diff --git a/packages/loot-design/src/components/sidebar.js b/packages/loot-design/src/components/sidebar.js
index 6c44bf753c..b751c73b5e 100644
--- a/packages/loot-design/src/components/sidebar.js
+++ b/packages/loot-design/src/components/sidebar.js
@@ -3,7 +3,7 @@ import { useLocation } from 'react-router';
import { css } from 'glamor';
-import Platform from 'loot-core/src/client/platform';
+import * as Platform from 'loot-core/src/client/platform';
import { styles, colors } from '../style';
import Add from '../svg/v1/Add';
diff --git a/packages/loot-design/src/components/sort.js b/packages/loot-design/src/components/sort.js
index 55c2abb99a..859d0757af 100644
--- a/packages/loot-design/src/components/sort.js
+++ b/packages/loot-design/src/components/sort.js
@@ -38,7 +38,7 @@ export function useDraggable({
}) {
let _onDragChange = useRef(onDragChange);
- //eslint-disable-next-line
+ //eslint-disable-next-line no-unused-vars
const [{ isDragging }, dragRef] = useDrag({
item: { type, item },
collect: monitor => ({ isDragging: monitor.isDragging() }),
@@ -71,7 +71,6 @@ export function useDroppable({ types, id, onDrop, onLongHover }) {
let ref = useRef(null);
let [dropPos, setDropPos] = useState(null);
- // eslint-disable-next-line
let [{ isOver }, dropRef] = useDrop({
accept: types,
drop({ item }, monitor) {
diff --git a/packages/loot-design/src/style.js b/packages/loot-design/src/style.js
index 298a8969e6..7ca66f8356 100644
--- a/packages/loot-design/src/style.js
+++ b/packages/loot-design/src/style.js
@@ -1,4 +1,4 @@
-import Platform from 'loot-core/src/client/platform';
+import * as Platform from 'loot-core/src/client/platform';
import tokens from './tokens';
diff --git a/packages/loot-design/src/tokens.js b/packages/loot-design/src/tokens.js
index ed2ce56313..5521b9a38b 100644
--- a/packages/loot-design/src/tokens.js
+++ b/packages/loot-design/src/tokens.js
@@ -1,5 +1,6 @@
-export default {
+const tokens = {
breakpoint_narrow: '512px',
breakpoint_medium: '768px',
breakpoint_wide: '1024px',
};
+export default tokens;