Skip to content

A local-first personal finance app

:arrow_up: upgrade prettier and fix new issues (#442)

Matiss Janis Aboltinse58e00d454f6
diff --git a/.prettierrc.json b/.prettierrc.json
index f62e834cd8..b0a179d48c 100644
--- a/.prettierrc.json
+++ b/.prettierrc.json
@@ -1,4 +1,5 @@
{
- "singleQuote": true,
- "trailingComma": "none"
+ "singleQuote": true,
+ "trailingComma": "none",
+ "arrowParens": "avoid"
}
diff --git a/package.json b/package.json
index f71dfadcda..a6bf48b1a4 100644
--- a/package.json
+++ b/package.json
@@ -37,7 +37,7 @@
"husky": "^3.0.4",
"npm-run-all": "^4.1.3",
"patch-package": "^6.1.2",
- "prettier": "^1.18.1",
+ "prettier": "2.8.2",
"pretty-quick": "^1.11.1",
"react-refresh": "^0.14.0",
"shelljs": "^0.8.2",
diff --git a/packages/desktop-client/src/browser-preload.browser.js b/packages/desktop-client/src/browser-preload.browser.js
index 423e6a7328..714ff4a8c7 100644
--- a/packages/desktop-client/src/browser-preload.browser.js
+++ b/packages/desktop-client/src/browser-preload.browser.js
@@ -106,14 +106,14 @@ global.Actual = {
if (file) {
var reader = new FileReader();
reader.readAsArrayBuffer(file);
- reader.onload = async function(ev) {
+ reader.onload = async function (ev) {
let filepath = `/uploads/${filename}`;
window.__actionsForMenu
.uploadFile(filename, ev.target.result)
.then(() => resolve([filepath]));
};
- reader.onerror = function(ev) {
+ reader.onerror = function (ev) {
alert('Error reading file');
};
}
diff --git a/packages/desktop-client/src/browser-preload.js b/packages/desktop-client/src/browser-preload.js
index 7e30323b5e..37bd75cf88 100644
--- a/packages/desktop-client/src/browser-preload.js
+++ b/packages/desktop-client/src/browser-preload.js
@@ -2,8 +2,7 @@ import * as Sentry from '@sentry/electron';
if (process.env.NODE_ENV !== 'development') {
Sentry.init({
- dsn:
- 'https://f2fa901455894dc8bf28210ef1247e2d:[email protected]/261029',
+ dsn: 'https://f2fa901455894dc8bf28210ef1247e2d:[email protected]/261029',
release: window.Actual.ACTUAL_VERSION
});
diff --git a/packages/desktop-client/src/components/ManageRules.js b/packages/desktop-client/src/components/ManageRules.js
index e621937d9a..957f113579 100644
--- a/packages/desktop-client/src/components/ManageRules.js
+++ b/packages/desktop-client/src/components/ManageRules.js
@@ -157,12 +157,11 @@ export function Value({
</Text>
);
})}
- {// prettier-ignore
- numHidden > 0 && (
+ {numHidden > 0 && (
<Text style={{ color: colors.p4 }}>
&nbsp;&nbsp;
- { // eslint-disable-next-line
- }<a
+ {/* eslint-disable-next-line */}
+ <a
href="#"
onClick={onExpand}
{...css({
@@ -405,7 +404,8 @@ let SimpleTable = React.forwardRef(
useEffect(() => {
if (contentRef.current) {
- contentHeight.current = contentRef.current.getBoundingClientRect().height;
+ contentHeight.current =
+ contentRef.current.getBoundingClientRect().height;
} else {
contentHeight.current = null;
}
diff --git a/packages/desktop-client/src/components/Notifications.js b/packages/desktop-client/src/components/Notifications.js
index fdba9838f8..d16e505b43 100644
--- a/packages/desktop-client/src/components/Notifications.js
+++ b/packages/desktop-client/src/components/Notifications.js
@@ -65,15 +65,8 @@ function compileMessage(message, actions, setLoading, onRemove) {
}
function Notification({ notification, onRemove }) {
- let {
- type,
- title,
- message,
- messageActions,
- sticky,
- internal,
- button
- } = notification;
+ let { type, title, message, messageActions, sticky, internal, button } =
+ notification;
let [loading, setLoading] = useState(false);
let [overlayLoading, setOverlayLoading] = useState(false);
diff --git a/packages/desktop-client/src/components/accounts/Account.js b/packages/desktop-client/src/components/accounts/Account.js
index e2fe874e02..e835f27d54 100644
--- a/packages/desktop-client/src/components/accounts/Account.js
+++ b/packages/desktop-client/src/components/accounts/Account.js
@@ -1823,9 +1823,10 @@ export default function Account(props) {
}));
let dispatch = useDispatch();
- let actionCreators = useMemo(() => bindActionCreators(actions, dispatch), [
- dispatch
- ]);
+ let actionCreators = useMemo(
+ () => bindActionCreators(actions, dispatch),
+ [dispatch]
+ );
let params = useParams();
let location = useLocation();
diff --git a/packages/desktop-client/src/components/accounts/MobileAccount.js b/packages/desktop-client/src/components/accounts/MobileAccount.js
index 10e71f4fcc..52907681f1 100644
--- a/packages/desktop-client/src/components/accounts/MobileAccount.js
+++ b/packages/desktop-client/src/components/accounts/MobileAccount.js
@@ -82,9 +82,10 @@ function Account(props) {
}));
let dispatch = useDispatch();
- let actionCreators = useMemo(() => bindActionCreators(actions, dispatch), [
- dispatch
- ]);
+ let actionCreators = useMemo(
+ () => bindActionCreators(actions, dispatch),
+ [dispatch]
+ );
const { id: accountId } = props.match.params;
diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.test.js b/packages/desktop-client/src/components/accounts/TransactionsTable.test.js
index b372f4170a..e1e32f16d2 100644
--- a/packages/desktop-client/src/components/accounts/TransactionsTable.test.js
+++ b/packages/desktop-client/src/components/accounts/TransactionsTable.test.js
@@ -698,12 +698,8 @@ describe('Transactions', () => {
});
test('adding a new transaction works', async () => {
- const {
- queryByTestId,
- container,
- getTransactions,
- updateProps
- } = renderTransactions();
+ const { queryByTestId, container, getTransactions, updateProps } =
+ renderTransactions();
expect(getTransactions().length).toBe(5);
expect(queryByTestId('new-transaction')).toBe(null);
diff --git a/packages/desktop-client/src/components/budget/MobileBudget.js b/packages/desktop-client/src/components/budget/MobileBudget.js
index 50d793fec4..90c6054052 100644
--- a/packages/desktop-client/src/components/budget/MobileBudget.js
+++ b/packages/desktop-client/src/components/budget/MobileBudget.js
@@ -230,13 +230,8 @@ class Budget extends React.Component {
};
render() {
- const {
- currentMonth,
- bounds,
- editMode,
- initialized,
- showBudgetDetails
- } = this.state;
+ const { currentMonth, bounds, editMode, initialized, showBudgetDetails } =
+ this.state;
const {
categories,
categoryGroups,
diff --git a/packages/desktop-client/src/components/budget/MobileBudgetTable.js b/packages/desktop-client/src/components/budget/MobileBudgetTable.js
index a5a3d29440..708f144d94 100644
--- a/packages/desktop-client/src/components/budget/MobileBudgetTable.js
+++ b/packages/desktop-client/src/components/budget/MobileBudgetTable.js
@@ -500,14 +500,8 @@ export class TotalsRow extends React.PureComponent {
export class IncomeCategory extends React.PureComponent {
render() {
- const {
- name,
- budget,
- balance,
- style,
- nameTextStyle,
- amountTextStyle
- } = this.props;
+ const { name, budget, balance, style, nameTextStyle, amountTextStyle } =
+ this.props;
return (
<ListItem
style={[
diff --git a/packages/desktop-client/src/components/modals/EditRule.js b/packages/desktop-client/src/components/modals/EditRule.js
index bdef8cbff4..513046425d 100644
--- a/packages/desktop-client/src/components/modals/EditRule.js
+++ b/packages/desktop-client/src/components/modals/EditRule.js
@@ -580,9 +580,7 @@ export default function EditRule({
if (filters.length > 0) {
let { data: transactions } = await runQuery(
- q('transactions')
- .filter({ $and: filters })
- .select('*')
+ q('transactions').filter({ $and: filters }).select('*')
);
setTransactions(transactions);
} else {
diff --git a/packages/desktop-client/src/components/schedules/DiscoverSchedules.js b/packages/desktop-client/src/components/schedules/DiscoverSchedules.js
index ac8dfc3a69..8c60930581 100644
--- a/packages/desktop-client/src/components/schedules/DiscoverSchedules.js
+++ b/packages/desktop-client/src/components/schedules/DiscoverSchedules.js
@@ -146,9 +146,7 @@ export default function DiscoverSchedules() {
if (filters.length > 0) {
let { data: transactions } = await runQuery(
- q('transactions')
- .filter({ $and: filters })
- .select('id')
+ q('transactions').filter({ $and: filters }).select('id')
);
await send('transactions-batch-update', {
updated: transactions.map(t => ({
diff --git a/packages/desktop-client/src/components/schedules/EditSchedule.js b/packages/desktop-client/src/components/schedules/EditSchedule.js
index d3f3dfb66c..b68db6d6d9 100644
--- a/packages/desktop-client/src/components/schedules/EditSchedule.js
+++ b/packages/desktop-client/src/components/schedules/EditSchedule.js
@@ -211,11 +211,7 @@ export default function ScheduleDetails() {
);
async function loadSchedule() {
- let { data } = await runQuery(
- q('schedules')
- .filter({ id })
- .select('*')
- );
+ let { data } = await runQuery(q('schedules').filter({ id }).select('*'));
return data[0];
}
diff --git a/packages/loot-core/package.json b/packages/loot-core/package.json
index eef1020b0f..a1595b0580 100644
--- a/packages/loot-core/package.json
+++ b/packages/loot-core/package.json
@@ -65,7 +65,6 @@
"murmurhash": "^0.0.2",
"npm-run-all": "^4.1.3",
"perf-deets": "^1.0.15",
- "prettier": "^1.19.1",
"sanitize-filename": "^1.6.1",
"search-query-parser": "^1.3.0",
"snapshot-diff": "^0.10.0",
diff --git a/packages/loot-core/src/client/SpreadsheetProvider.js b/packages/loot-core/src/client/SpreadsheetProvider.js
index dd0bc45245..4d036b4a9d 100644
--- a/packages/loot-core/src/client/SpreadsheetProvider.js
+++ b/packages/loot-core/src/client/SpreadsheetProvider.js
@@ -41,7 +41,7 @@ function makeSpreadsheet() {
}
listen() {
- return listen('cells-changed', function(nodes) {
+ return listen('cells-changed', function (nodes) {
if (!observersDisabled) {
// TODO: batch react so only renders once
nodes.forEach(node => {
diff --git a/packages/loot-core/src/client/actions/account.js b/packages/loot-core/src/client/actions/account.js
index 13b76438f6..9066603ba0 100644
--- a/packages/loot-core/src/client/actions/account.js
+++ b/packages/loot-core/src/client/actions/account.js
@@ -86,12 +86,8 @@ export function syncAccounts(id) {
dispatch(setAccountsSyncing('__all'));
}
- const {
- errors,
- newTransactions,
- matchedTransactions,
- updatedAccounts
- } = await send('accounts-sync', { id });
+ const { errors, newTransactions, matchedTransactions, updatedAccounts } =
+ await send('accounts-sync', { id });
dispatch(setAccountsSyncing(null));
if (id) {
@@ -169,7 +165,11 @@ export function parseTransactions(filepath, options) {
export function importTransactions(id, transactions) {
return async dispatch => {
- let { errors = [], added, updated } = await send('transactions-import', {
+ let {
+ errors = [],
+ added,
+ updated
+ } = await send('transactions-import', {
accountId: id,
transactions
});
diff --git a/packages/loot-core/src/client/actions/queries.js b/packages/loot-core/src/client/actions/queries.js
index e33a0c7fd2..732d2cfbff 100644
--- a/packages/loot-core/src/client/actions/queries.js
+++ b/packages/loot-core/src/client/actions/queries.js
@@ -6,7 +6,7 @@ import { pushModal } from './modals';
import { addNotification, addGenericErrorNotification } from './notifications';
export function applyBudgetAction(month, type, args) {
- return async function() {
+ return async function () {
switch (type) {
case 'budget-amount':
await send('budget/budget-amount', {
@@ -69,7 +69,7 @@ export function applyBudgetAction(month, type, args) {
}
export function getCategories() {
- return async function(dispatch) {
+ return async function (dispatch) {
const categories = await send('get-categories');
dispatch({
type: constants.LOAD_CATEGORIES,
@@ -80,7 +80,7 @@ export function getCategories() {
}
export function createCategory(name, groupId, isIncome) {
- return async function(dispatch) {
+ return async function (dispatch) {
let id = await send('category-create', {
name,
groupId,
@@ -92,7 +92,7 @@ export function createCategory(name, groupId, isIncome) {
}
export function deleteCategory(id, transferId) {
- return async function(dispatch, getState) {
+ return async function (dispatch, getState) {
let { error } = await send('category-delete', { id, transferId });
if (error) {
@@ -162,7 +162,7 @@ export function updateGroup(group) {
}
export function deleteGroup(id, transferId) {
- return async function(dispatch, getState) {
+ return async function (dispatch, getState) {
await send('category-group-delete', { id, transferId });
await dispatch(getCategories());
// See `deleteCategory` for why we need this
@@ -171,7 +171,7 @@ export function deleteGroup(id, transferId) {
}
export function getPayees() {
- return async function(dispatch) {
+ return async function (dispatch) {
let payees = await send('payees-get');
dispatch({
type: constants.LOAD_PAYEES,
@@ -182,7 +182,7 @@ export function getPayees() {
}
export function initiallyLoadPayees() {
- return async function(dispatch, getState) {
+ return async function (dispatch, getState) {
if (getState().queries.payees.length === 0) {
return dispatch(getPayees());
}
@@ -196,7 +196,7 @@ export function createPayee(name) {
}
export function getAccounts() {
- return async function(dispatch) {
+ return async function (dispatch) {
const accounts = await send('accounts-get');
dispatch({ type: constants.LOAD_ACCOUNTS, accounts });
return accounts;
@@ -204,14 +204,14 @@ export function getAccounts() {
}
export function updateAccount(account) {
- return async function(dispatch) {
+ return async function (dispatch) {
dispatch({ type: constants.UPDATE_ACCOUNT, account });
await send('account-update', account);
};
}
export function createAccount(name, type, balance, offBudget) {
- return async function(dispatch) {
+ return async function (dispatch) {
let id = await send('account-create', { name, type, balance, offBudget });
await dispatch(getAccounts());
await dispatch(getPayees());
@@ -220,7 +220,7 @@ export function createAccount(name, type, balance, offBudget) {
}
export function openAccountCloseModal(accountId) {
- return async function(dispatch, getState) {
+ return async function (dispatch, getState) {
const { balance, numTransactions } = await send('account-properties', {
id: accountId
});
@@ -239,7 +239,7 @@ export function openAccountCloseModal(accountId) {
}
export function closeAccount(accountId, transferAccountId, categoryId, forced) {
- return async function(dispatch) {
+ return async function (dispatch) {
await send('account-close', {
id: accountId,
transferAccountId,
@@ -251,7 +251,7 @@ export function closeAccount(accountId, transferAccountId, categoryId, forced) {
}
export function reopenAccount(accountId) {
- return async function(dispatch) {
+ return async function (dispatch) {
await send('account-reopen', { id: accountId });
dispatch(getAccounts());
};
diff --git a/packages/loot-core/src/mocks/budget.js b/packages/loot-core/src/mocks/budget.js
index 8647338e1b..b1d9633a6e 100644
--- a/packages/loot-core/src/mocks/budget.js
+++ b/packages/loot-core/src/mocks/budget.js
@@ -213,12 +213,8 @@ async function fillPrimaryChecking(handlers, account, payees, groups) {
}
async function fillChecking(handlers, account, payees, groups) {
- let {
- incomePayee,
- expensePayees,
- incomeGroup,
- expenseCategories
- } = extractCommonThings(payees, groups);
+ let { incomePayee, expensePayees, incomeGroup, expenseCategories } =
+ extractCommonThings(payees, groups);
let numTransactions = integer(20, 40);
let transactions = [];
@@ -301,12 +297,8 @@ async function fillInvestment(handlers, account, payees, groups) {
}
async function fillSavings(handlers, account, payees, groups) {
- let {
- incomePayee,
- expensePayees,
- incomeGroup,
- expenseCategories
- } = extractCommonThings(payees, groups);
+ let { incomePayee, expensePayees, incomeGroup, expenseCategories } =
+ extractCommonThings(payees, groups);
let numTransactions = integer(15, 40);
diff --git a/packages/loot-core/src/mocks/setup.js b/packages/loot-core/src/mocks/setup.js
index 7282931385..20adeb4048 100644
--- a/packages/loot-core/src/mocks/setup.js
+++ b/packages/loot-core/src/mocks/setup.js
@@ -56,7 +56,7 @@ global.randomId = () => {
return 'id' + _id++;
};
-global.getDatabaseDump = async function(tables) {
+global.getDatabaseDump = async function (tables) {
if (!tables) {
const rows = await sqlite.runQuery(
db.getDatabase(),
@@ -106,7 +106,7 @@ global.getDatabaseDump = async function(tables) {
// where to find the webassembly file
// process.env.PUBLIC_URL = __dirname + '/../../../../node_modules/sql.js/dist/';
-global.emptyDatabase = function(avoidUpdate) {
+global.emptyDatabase = function (avoidUpdate) {
return async () => {
let path = ':memory:';
// let path = `/tmp/foo-${Math.random()}.sqlite`;
diff --git a/packages/loot-core/src/platform/client/fetch/index.browser.js b/packages/loot-core/src/platform/client/fetch/index.browser.js
index 369c2dcf35..a044b78c81 100644
--- a/packages/loot-core/src/platform/client/fetch/index.browser.js
+++ b/packages/loot-core/src/platform/client/fetch/index.browser.js
@@ -14,10 +14,10 @@ class ReconstructedError extends Error {
this.message = message;
Object.defineProperty(this, 'stack', {
- get: function() {
+ get: function () {
return 'extended ' + this._stack;
},
- set: function(value) {
+ set: function (value) {
this._stack = value;
}
});
diff --git a/packages/loot-core/src/platform/client/fetch/index.testing.js b/packages/loot-core/src/platform/client/fetch/index.testing.js
index bef3633b8e..1667ad3dc2 100644
--- a/packages/loot-core/src/platform/client/fetch/index.testing.js
+++ b/packages/loot-core/src/platform/client/fetch/index.testing.js
@@ -36,7 +36,11 @@ module.exports.serverPush = (name, args) => {
});
};
-module.exports.send = async function(name, args, { catchErrors = false } = {}) {
+module.exports.send = async function (
+ name,
+ args,
+ { catchErrors = false } = {}
+) {
if (serverHandler) {
return serverHandler({ name, args, catchErrors });
} else {
diff --git a/packages/loot-core/src/platform/client/fetch/index.web.js b/packages/loot-core/src/platform/client/fetch/index.web.js
index c52f65a70e..36e897176f 100644
--- a/packages/loot-core/src/platform/client/fetch/index.web.js
+++ b/packages/loot-core/src/platform/client/fetch/index.web.js
@@ -6,7 +6,7 @@ let messageQueue = [];
let socketClient = null;
function connectSocket(name, onOpen) {
- global.Actual.ipcConnect(name, function(client) {
+ global.Actual.ipcConnect(name, function (client) {
client.on('message', data => {
const msg = data;
diff --git a/packages/loot-core/src/platform/server/asyncStorage/index.electron.js b/packages/loot-core/src/platform/server/asyncStorage/index.electron.js
index b2a8853306..bae6efced3 100644
--- a/packages/loot-core/src/platform/server/asyncStorage/index.electron.js
+++ b/packages/loot-core/src/platform/server/asyncStorage/index.electron.js
@@ -23,19 +23,21 @@ function init({ persist = true } = {}) {
function _saveStore() {
if (persisted) {
- return new Promise(function(resolve, reject) {
- fs.writeFile(getStorePath(), JSON.stringify(store), 'utf8', function(
- err,
- _
- ) {
- return err ? reject(err) : resolve();
- });
+ return new Promise(function (resolve, reject) {
+ fs.writeFile(
+ getStorePath(),
+ JSON.stringify(store),
+ 'utf8',
+ function (err, _) {
+ return err ? reject(err) : resolve();
+ }
+ );
});
}
}
function getItem(key) {
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
return resolve(store[key]);
});
}
@@ -51,9 +53,9 @@ function removeItem(key) {
}
function multiGet(keys) {
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
return resolve(
- keys.map(function(key) {
+ keys.map(function (key) {
return [key, store[key]];
})
);
@@ -61,14 +63,14 @@ function multiGet(keys) {
}
function multiSet(keyValues) {
- keyValues.forEach(function([key, value]) {
+ keyValues.forEach(function ([key, value]) {
store[key] = value;
});
return _saveStore();
}
function multiRemove(keys) {
- keys.forEach(function(key) {
+ keys.forEach(function (key) {
delete store[key];
});
return _saveStore();
diff --git a/packages/loot-core/src/platform/server/asyncStorage/index.testing.js b/packages/loot-core/src/platform/server/asyncStorage/index.testing.js
index 646756c3ba..05bbc421c9 100644
--- a/packages/loot-core/src/platform/server/asyncStorage/index.testing.js
+++ b/packages/loot-core/src/platform/server/asyncStorage/index.testing.js
@@ -3,7 +3,7 @@ const store = {};
function init() {}
function getItem(key) {
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
return resolve(store[key]);
});
}
@@ -17,9 +17,9 @@ function removeItem(key) {
}
function multiGet(keys) {
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
return resolve(
- keys.map(function(key) {
+ keys.map(function (key) {
return [key, store[key]];
})
);
@@ -27,13 +27,13 @@ function multiGet(keys) {
}
function multiSet(keyValues) {
- keyValues.forEach(function([key, value]) {
+ keyValues.forEach(function ([key, value]) {
store[key] = value;
});
}
function multiRemove(keys) {
- keys.forEach(function(key) {
+ keys.forEach(function (key) {
delete store[key];
});
}
diff --git a/packages/loot-core/src/platform/server/fetch/index.electron.js b/packages/loot-core/src/platform/server/fetch/index.electron.js
index a5532196ec..bc79d0f7d5 100644
--- a/packages/loot-core/src/platform/server/fetch/index.electron.js
+++ b/packages/loot-core/src/platform/server/fetch/index.electron.js
@@ -10,7 +10,7 @@ async function fetchBinary(url, filepath) {
res.body.on('error', err => {
reject(err);
});
- fileStream.on('finish', function() {
+ fileStream.on('finish', function () {
resolve();
});
});
diff --git a/packages/loot-core/src/platform/server/fs/index.electron.js b/packages/loot-core/src/platform/server/fs/index.electron.js
index 8775d97195..bd174d66f1 100644
--- a/packages/loot-core/src/platform/server/fs/index.electron.js
+++ b/packages/loot-core/src/platform/server/fs/index.electron.js
@@ -118,21 +118,21 @@ module.exports = {
});
},
writeFile: (filepath, contents) => {
- return new Promise(function(resolve, reject) {
- fs.writeFile(filepath, contents, 'utf8', function(err, _) {
+ return new Promise(function (resolve, reject) {
+ fs.writeFile(filepath, contents, 'utf8', function (err, _) {
return err ? reject(err) : resolve();
});
});
},
removeFile: filepath => {
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
fs.unlink(filepath, err => {
return err ? reject(err) : resolve();
});
});
},
removeDir: dirpath => {
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
fs.rmdir(dirpath, err => {
return err ? reject(err) : resolve();
});
@@ -154,7 +154,7 @@ module.exports = {
}
},
getModifiedTime: filepath => {
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
fs.stat(filepath, (err, stats) => {
if (err) {
reject(err);
diff --git a/packages/loot-core/src/platform/server/indexeddb/index.web.js b/packages/loot-core/src/platform/server/indexeddb/index.web.js
index 2fc7d29fd6..7b809c1d9a 100644
--- a/packages/loot-core/src/platform/server/indexeddb/index.web.js
+++ b/packages/loot-core/src/platform/server/indexeddb/index.web.js
@@ -6,7 +6,7 @@ function _openDatabase() {
let dbVersion = 9;
let openRequest = indexedDB.open('actual', dbVersion);
- openRequest.onupgradeneeded = function(e) {
+ openRequest.onupgradeneeded = function (e) {
let db = e.target.result;
// Remove old stores
@@ -33,7 +33,7 @@ function _openDatabase() {
reject(new Error('indexeddb-failure: Could not open IndexedDB'));
};
- openRequest.onsuccess = function(e) {
+ openRequest.onsuccess = function (e) {
let db = e.target.result;
db.onversionchange = () => {
@@ -41,7 +41,7 @@ function _openDatabase() {
db.close();
};
- db.onerror = function(event) {
+ db.onerror = function (event) {
console.log('Database error: ' + (event.target && event.target.error));
if (event.target && event.target.error) {
diff --git a/packages/loot-core/src/platform/uuid/index.electron.js b/packages/loot-core/src/platform/uuid/index.electron.js
index ae0dec2e57..495211d3a3 100644
--- a/packages/loot-core/src/platform/uuid/index.electron.js
+++ b/packages/loot-core/src/platform/uuid/index.electron.js
@@ -1,11 +1,11 @@
const uuid = require('uuid');
module.exports = {
- v4: function() {
+ v4: function () {
return Promise.resolve(uuid.v4());
},
- v4Sync: function() {
+ v4Sync: function () {
return uuid.v4();
}
};
diff --git a/packages/loot-core/src/platform/uuid/index.testing.js b/packages/loot-core/src/platform/uuid/index.testing.js
index c190701a84..0704644649 100644
--- a/packages/loot-core/src/platform/uuid/index.testing.js
+++ b/packages/loot-core/src/platform/uuid/index.testing.js
@@ -1,9 +1,9 @@
module.exports = {
- v4: function() {
+ v4: function () {
return Promise.resolve(global.randomId());
},
- v4Sync: function() {
+ v4Sync: function () {
return global.randomId();
}
};
diff --git a/packages/loot-core/src/platform/uuid/index.web.js b/packages/loot-core/src/platform/uuid/index.web.js
index ae0dec2e57..495211d3a3 100644
--- a/packages/loot-core/src/platform/uuid/index.web.js
+++ b/packages/loot-core/src/platform/uuid/index.web.js
@@ -1,11 +1,11 @@
const uuid = require('uuid');
module.exports = {
- v4: function() {
+ v4: function () {
return Promise.resolve(uuid.v4());
},
- v4Sync: function() {
+ v4Sync: function () {
return uuid.v4();
}
};
diff --git a/packages/loot-core/src/server/accounts/transaction-rules.test.js b/packages/loot-core/src/server/accounts/transaction-rules.test.js
index eb57fe4cd9..726c2dc3c9 100644
--- a/packages/loot-core/src/server/accounts/transaction-rules.test.js
+++ b/packages/loot-core/src/server/accounts/transaction-rules.test.js
@@ -29,9 +29,7 @@ beforeEach(async () => {
async function getMatchingTransactions(conds) {
let { filters } = conditionsToAQL(conds);
let { data } = await runQuery(
- q('transactions')
- .filter({ $and: filters })
- .select('*')
+ q('transactions').filter({ $and: filters }).select('*')
);
return data;
}
diff --git a/packages/loot-core/src/server/accounts/transfer.js b/packages/loot-core/src/server/accounts/transfer.js
index 015a867676..4cf54158df 100644
--- a/packages/loot-core/src/server/accounts/transfer.js
+++ b/packages/loot-core/src/server/accounts/transfer.js
@@ -6,27 +6,24 @@ async function getPayee(acct) {
async function getTransferredAccount(transaction) {
if (transaction.payee) {
- let {
- transfer_acct
- } = await db.first('SELECT id, transfer_acct FROM v_payees WHERE id = ?', [
- transaction.payee
- ]);
+ let { transfer_acct } = await db.first(
+ 'SELECT id, transfer_acct FROM v_payees WHERE id = ?',
+ [transaction.payee]
+ );
return transfer_acct;
}
return null;
}
async function clearCategory(transaction, transferAcct) {
- const {
- offbudget: fromOffBudget
- } = await db.first('SELECT offbudget FROM accounts WHERE id = ?', [
- transaction.account
- ]);
- const {
- offbudget: toOffBudget
- } = await db.first('SELECT offbudget FROM accounts WHERE id = ?', [
- transferAcct
- ]);
+ const { offbudget: fromOffBudget } = await db.first(
+ 'SELECT offbudget FROM accounts WHERE id = ?',
+ [transaction.account]
+ );
+ const { offbudget: toOffBudget } = await db.first(
+ 'SELECT offbudget FROM accounts WHERE id = ?',
+ [transferAcct]
+ );
// We should clear the category to make sure it's not being
// accounted for in the budget, unless it should be in the case of
@@ -39,11 +36,10 @@ async function clearCategory(transaction, transferAcct) {
}
export async function addTransfer(transaction, transferredAccount) {
- let {
- id: fromPayee
- } = await db.first('SELECT id FROM payees WHERE transfer_acct = ?', [
- transaction.account
- ]);
+ let { id: fromPayee } = await db.first(
+ 'SELECT id FROM payees WHERE transfer_acct = ?',
+ [transaction.account]
+ );
// We need to enforce certain constraints with child transaction transfers
if (transaction.parent_id) {
diff --git a/packages/loot-core/src/server/api.js b/packages/loot-core/src/server/api.js
index a7984825d8..c9fd340d8a 100644
--- a/packages/loot-core/src/server/api.js
+++ b/packages/loot-core/src/server/api.js
@@ -99,7 +99,7 @@ async function validateExpenseCategory(debug, id) {
let batchPromise = null;
-handlers['api/batch-budget-start'] = async function() {
+handlers['api/batch-budget-start'] = async function () {
if (batchPromise) {
throw APIError('Cannot start a batch process: batch already started');
}
@@ -122,7 +122,7 @@ handlers['api/batch-budget-start'] = async function() {
}
};
-handlers['api/batch-budget-end'] = async function() {
+handlers['api/batch-budget-end'] = async function () {
if (!batchPromise) {
throw APIError('Cannot end a batch process: no batch started');
}
@@ -131,7 +131,7 @@ handlers['api/batch-budget-end'] = async function() {
batchPromise = null;
};
-handlers['api/load-budget'] = async function({ id }) {
+handlers['api/load-budget'] = async function ({ id }) {
let { id: currentId } = prefs.getPrefs() || {};
if (currentId !== id) {
@@ -160,7 +160,7 @@ handlers['api/load-budget'] = async function({ id }) {
}
};
-handlers['api/start-import'] = async function({ budgetName }) {
+handlers['api/start-import'] = async function ({ budgetName }) {
// Notify UI to close budget
await handlers['close-budget']();
@@ -178,7 +178,7 @@ handlers['api/start-import'] = async function({ budgetName }) {
IMPORT_MODE = true;
};
-handlers['api/finish-import'] = async function() {
+handlers['api/finish-import'] = async function () {
sheet.get().markCacheDirty();
// We always need to fully reload the app. Importing doesn't touch
@@ -197,7 +197,7 @@ handlers['api/finish-import'] = async function() {
IMPORT_MODE = false;
};
-handlers['api/abort-import'] = async function() {
+handlers['api/abort-import'] = async function () {
if (IMPORT_MODE) {
let { id } = prefs.getPrefs();
@@ -209,16 +209,16 @@ handlers['api/abort-import'] = async function() {
IMPORT_MODE = false;
};
-handlers['api/query'] = async function({ query }) {
+handlers['api/query'] = async function ({ query }) {
return aqlQuery(query);
};
-handlers['api/budget-months'] = async function() {
+handlers['api/budget-months'] = async function () {
let { start, end } = await handlers['get-budget-bounds']();
return monthUtils.range(start, end);
};
-handlers['api/budget-month'] = async function({ month }) {
+handlers['api/budget-month'] = async function ({ month }) {
await validateMonth(month);
let groups = await db.getCategoriesGrouped();
@@ -275,7 +275,7 @@ handlers['api/budget-month'] = async function({ month }) {
};
};
-handlers['api/budget-set-amount'] = withMutation(async function({
+handlers['api/budget-set-amount'] = withMutation(async function ({
month,
categoryId,
amount
@@ -287,7 +287,7 @@ handlers['api/budget-set-amount'] = withMutation(async function({
});
});
-handlers['api/budget-set-carryover'] = withMutation(async function({
+handlers['api/budget-set-carryover'] = withMutation(async function ({
month,
categoryId,
flag
@@ -301,7 +301,7 @@ handlers['api/budget-set-carryover'] = withMutation(async function({
});
});
-handlers['api/transactions-export'] = async function({
+handlers['api/transactions-export'] = async function ({
transactions,
categoryGroups,
payees
@@ -313,14 +313,14 @@ handlers['api/transactions-export'] = async function({
});
};
-handlers['api/transactions-import'] = withMutation(async function({
+handlers['api/transactions-import'] = withMutation(async function ({
accountId,
transactions
}) {
return handlers['transactions-import']({ accountId, transactions });
});
-handlers['api/transactions-add'] = withMutation(async function({
+handlers['api/transactions-add'] = withMutation(async function ({
accountId,
transactions
}) {
@@ -328,7 +328,7 @@ handlers['api/transactions-add'] = withMutation(async function({
return 'ok';
});
-handlers['api/transactions-get'] = async function({
+handlers['api/transactions-get'] = async function ({
accountId,
startDate,
endDate
@@ -348,19 +348,16 @@ handlers['api/transactions-get'] = async function({
return data;
};
-handlers['api/transactions-filter'] = async function({ text, accountId }) {
+handlers['api/transactions-filter'] = async function ({ text, accountId }) {
throw new Error('`filterTransactions` is deprecated, use `runQuery` instead');
};
-handlers['api/transaction-update'] = withMutation(async function({
+handlers['api/transaction-update'] = withMutation(async function ({
id,
fields
}) {
let { data } = await aqlQuery(
- q('transactions')
- .filter({ id })
- .select('*')
- .options({ splits: 'grouped' })
+ q('transactions').filter({ id }).select('*').options({ splits: 'grouped' })
);
let transactions = ungroupTransactions(data);
@@ -372,12 +369,9 @@ handlers['api/transaction-update'] = withMutation(async function({
return handlers['transactions-batch-update'](diff);
});
-handlers['api/transaction-delete'] = withMutation(async function({ id }) {
+handlers['api/transaction-delete'] = withMutation(async function ({ id }) {
let { data } = await aqlQuery(
- q('transactions')
- .filter({ id })
- .select('*')
- .options({ splits: 'grouped' })
+ q('transactions').filter({ id }).select('*').options({ splits: 'grouped' })
);
let transactions = ungroupTransactions(data);
@@ -389,12 +383,12 @@ handlers['api/transaction-delete'] = withMutation(async function({ id }) {
return handlers['transactions-batch-update'](diff);
});
-handlers['api/accounts-get'] = async function() {
+handlers['api/accounts-get'] = async function () {
let accounts = await db.getAccounts();
return accounts.map(account => accountModel.toExternal(account));
};
-handlers['api/account-create'] = withMutation(async function({
+handlers['api/account-create'] = withMutation(async function ({
account,
initialBalance = null
}) {
@@ -409,11 +403,11 @@ handlers['api/account-create'] = withMutation(async function({
});
});
-handlers['api/account-update'] = withMutation(async function({ id, fields }) {
+handlers['api/account-update'] = withMutation(async function ({ id, fields }) {
return db.updateAccount({ id, ...accountModel.fromExternal(fields) });
});
-handlers['api/account-close'] = withMutation(async function({
+handlers['api/account-close'] = withMutation(async function ({
id,
transferAccountId,
transferCategoryId
@@ -425,26 +419,28 @@ handlers['api/account-close'] = withMutation(async function({
});
});
-handlers['api/account-reopen'] = withMutation(async function({ id }) {
+handlers['api/account-reopen'] = withMutation(async function ({ id }) {
return handlers['account-reopen']({ id });
});
-handlers['api/account-delete'] = withMutation(async function({ id }) {
+handlers['api/account-delete'] = withMutation(async function ({ id }) {
return handlers['account-close']({ id, forced: true });
});
-handlers['api/categories-get'] = async function({ grouped } = {}) {
+handlers['api/categories-get'] = async function ({ grouped } = {}) {
let result = await handlers['get-categories']();
return grouped
? result.grouped.map(categoryGroupModel.toExternal)
: result.list.map(categoryModel.toExternal);
};
-handlers['api/category-group-create'] = withMutation(async function({ group }) {
+handlers['api/category-group-create'] = withMutation(async function ({
+ group
+}) {
return handlers['category-group-create']({ name: group.name });
});
-handlers['api/category-group-update'] = withMutation(async function({
+handlers['api/category-group-update'] = withMutation(async function ({
id,
fields
}) {
@@ -454,7 +450,7 @@ handlers['api/category-group-update'] = withMutation(async function({
});
});
-handlers['api/category-group-delete'] = withMutation(async function({
+handlers['api/category-group-delete'] = withMutation(async function ({
id,
transferCategoryId
}) {
@@ -464,7 +460,7 @@ handlers['api/category-group-delete'] = withMutation(async function({
});
});
-handlers['api/category-create'] = withMutation(async function({ category }) {
+handlers['api/category-create'] = withMutation(async function ({ category }) {
return handlers['category-create']({
name: category.name,
groupId: category.group_id,
@@ -472,14 +468,14 @@ handlers['api/category-create'] = withMutation(async function({ category }) {
});
});
-handlers['api/category-update'] = withMutation(async function({ id, fields }) {
+handlers['api/category-update'] = withMutation(async function ({ id, fields }) {
return handlers['category-update']({
id,
...categoryModel.fromExternal(fields)
});
});
-handlers['api/category-delete'] = withMutation(async function({
+handlers['api/category-delete'] = withMutation(async function ({
id,
transferCategoryId
}) {
@@ -489,31 +485,31 @@ handlers['api/category-delete'] = withMutation(async function({
});
});
-handlers['api/payees-get'] = async function() {
+handlers['api/payees-get'] = async function () {
let payees = await handlers['payees-get']();
return payees.map(payeeModel.toExternal);
};
-handlers['api/payee-create'] = withMutation(async function({ payee }) {
+handlers['api/payee-create'] = withMutation(async function ({ payee }) {
return handlers['payee-create']({ name: payee.name });
});
-handlers['api/payee-update'] = withMutation(async function({ id, fields }) {
+handlers['api/payee-update'] = withMutation(async function ({ id, fields }) {
return handlers['payees-batch-change']({
updated: [{ id, ...payeeModel.fromExternal(fields) }]
});
});
-handlers['api/payee-delete'] = withMutation(async function({ id }) {
+handlers['api/payee-delete'] = withMutation(async function ({ id }) {
return handlers['payees-batch-change']({ deleted: [{ id }] });
});
-handlers['api/payee-rules-get'] = async function({ payeeId }) {
+handlers['api/payee-rules-get'] = async function ({ payeeId }) {
let rules = await handlers['payees-get-rules']({ id: payeeId });
return rules.map(payeeRuleModel.toExternal);
};
-handlers['api/payee-rule-create'] = withMutation(async function({
+handlers['api/payee-rule-create'] = withMutation(async function ({
payee_id,
rule
}) {
@@ -524,7 +520,7 @@ handlers['api/payee-rule-create'] = withMutation(async function({
});
});
-handlers['api/payee-rule-update'] = withMutation(async function({
+handlers['api/payee-rule-update'] = withMutation(async function ({
id,
fields
}) {
@@ -534,11 +530,11 @@ handlers['api/payee-rule-update'] = withMutation(async function({
});
});
-handlers['api/payee-rule-delete'] = withMutation(async function({ id }) {
+handlers['api/payee-rule-delete'] = withMutation(async function ({ id }) {
return handlers['payees-delete-rule']({ id });
});
-export default function(serverHandlers) {
+export default function (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 65e3a444e1..3e0efc80f5 100644
--- a/packages/loot-core/src/server/aql/compiler.js
+++ b/packages/loot-core/src/server/aql/compiler.js
@@ -765,13 +765,8 @@ const compileWhere = saveStack('filter', (state, conds) => {
function compileJoins(state, tableRef, internalTableFilters) {
let joins = [];
state.paths.forEach((desc, path) => {
- let {
- tableName,
- tableId,
- joinField,
- joinTable,
- noMapping
- } = state.paths.get(path);
+ let { tableName, tableId, joinField, joinTable, noMapping } =
+ state.paths.get(path);
let on = `${tableId}.id = ${tableRef(joinTable)}.${quoteAlias(joinField)}`;
diff --git a/packages/loot-core/src/server/aql/compiler.test.js b/packages/loot-core/src/server/aql/compiler.test.js
index ad9e09f640..0577ff721e 100644
--- a/packages/loot-core/src/server/aql/compiler.test.js
+++ b/packages/loot-core/src/server/aql/compiler.test.js
@@ -108,9 +108,7 @@ describe('sheet language', () => {
// By default, it should do id ref validation
result = generateSQLWithState(
- query('accounts')
- .select(['trans1', 'trans2'])
- .serialize(),
+ query('accounts').select(['trans1', 'trans2']).serialize(),
schemaWithRefs
);
expect(sqlLines(result.sql)).toEqual(
@@ -137,9 +135,7 @@ describe('sheet language', () => {
it('`select` allows selecting all fields with *', () => {
let result = generateSQLWithState(
- query('accounts')
- .select(['*'])
- .serialize(),
+ query('accounts').select(['*']).serialize(),
schemaWithRefs
);
expect(sqlLines(result.sql)).toEqual(
@@ -154,9 +150,7 @@ describe('sheet language', () => {
// Test selecting from joined tables
result = generateSQLWithState(
- query('accounts')
- .select(['*', 'trans1.*'])
- .serialize(),
+ query('accounts').select(['*', 'trans1.*']).serialize(),
schemaWithRefs
);
expect(sqlLines(result.sql)).toEqual(
@@ -175,19 +169,14 @@ describe('sheet language', () => {
// The tombstone flag is not added if not necessary (the table
// doesn't have it )
let result = generateSQLWithState(
- query('accounts')
- .select(['trans'])
- .withoutValidatedRefs()
- .serialize(),
+ query('accounts').select(['trans']).withoutValidatedRefs().serialize(),
schemaWithTombstone
);
expect(result.sql).not.toMatch('tombstone');
// By default, the tombstone flag should be added if necessary
result = generateSQLWithState(
- query('transactions')
- .select(['amount'])
- .serialize(),
+ query('transactions').select(['amount']).serialize(),
schemaWithTombstone
);
expect(sqlLines(result.sql)).toEqual(
@@ -199,10 +188,7 @@ describe('sheet language', () => {
// `withDead` should not add the tombstone flag
result = generateSQLWithState(
- query('transactions')
- .select(['amount'])
- .withDead()
- .serialize(),
+ query('transactions').select(['amount']).withDead().serialize(),
schemaWithTombstone
);
expect(sqlLines(result.sql)).toEqual(
@@ -234,17 +220,13 @@ describe('sheet language', () => {
it('`select` always includes the id', () => {
let result = generateSQLWithState(
- query('payees')
- .select('name')
- .serialize(),
+ query('payees').select('name').serialize(),
schemaWithRefs
);
expect(result.sql).toMatch('payees.id AS id');
result = generateSQLWithState(
- query('payees')
- .select(['name', 'id'])
- .serialize(),
+ query('payees').select(['name', 'id']).serialize(),
schemaWithRefs
);
// id is only included once, we manually selected it
@@ -253,10 +235,7 @@ describe('sheet language', () => {
);
result = generateSQLWithState(
- query('payees')
- .select('name')
- .groupBy('account')
- .serialize(),
+ query('payees').select('name').groupBy('account').serialize(),
schemaWithRefs
);
// id should not automatically by selected if using `groupBy`
@@ -361,10 +340,7 @@ describe('sheet language', () => {
it('groupBy should work', () => {
let result = generateSQLWithState(
- query('transactions')
- .groupBy('payee.name')
- .select('id')
- .serialize(),
+ query('transactions').groupBy('payee.name').select('id').serialize(),
schemaWithRefs
);
expect(sqlLines(result.sql)).toEqual(
@@ -389,10 +365,7 @@ describe('sheet language', () => {
it('orderBy should work', () => {
let result = generateSQLWithState(
- query('transactions')
- .orderBy('payee.name')
- .select('id')
- .serialize(),
+ query('transactions').orderBy('payee.name').select('id').serialize(),
schemaWithRefs
);
expect(sqlLines(result.sql)).toEqual(
@@ -612,29 +585,19 @@ describe('sheet language', () => {
it('allows limit and offset', () => {
let result = generateSQLWithState(
- query('transactions')
- .select(['id'])
- .limit(10)
- .serialize(),
+ query('transactions').select(['id']).limit(10).serialize(),
schemaWithRefs
);
expect(result.sql).toMatch(/\s+LIMIT 10\s*$/);
result = generateSQLWithState(
- query('transactions')
- .select(['id'])
- .offset(11)
- .serialize(),
+ query('transactions').select(['id']).offset(11).serialize(),
schemaWithRefs
);
expect(result.sql).toMatch(/\s+OFFSET 11\s*$/);
result = generateSQLWithState(
- query('transactions')
- .select(['id'])
- .limit(10)
- .offset(11)
- .serialize(),
+ query('transactions').select(['id']).limit(10).offset(11).serialize(),
schemaWithRefs
);
expect(result.sql).toMatch(/\s+LIMIT 10\s*\n\s*OFFSET 11\s*$/);
@@ -675,9 +638,7 @@ describe('sheet language', () => {
it('allows customizing generated SQL', () => {
let result = generateSQLWithState(
- query('transactions')
- .select(['amount'])
- .serialize(),
+ query('transactions').select(['amount']).serialize(),
schemaWithRefs,
{
tableViews: { transactions: 'v_transactions' },
@@ -694,9 +655,7 @@ describe('sheet language', () => {
// Make sure the same customizations are applied when joining
result = generateSQLWithState(
- query('accounts')
- .select(['trans1.amount'])
- .serialize(),
+ query('accounts').select(['trans1.amount']).serialize(),
schemaWithRefs,
{
tableViews: { transactions: 'v_transactions' },
@@ -721,9 +680,7 @@ describe('sheet language', () => {
// Internal table filters can't use paths
expect(() =>
generateSQLWithState(
- query('accounts')
- .select(['trans1.amount'])
- .serialize(),
+ query('accounts').select(['trans1.amount']).serialize(),
schemaWithRefs,
{
tableViews: { transactions: 'v_transactions' },
@@ -736,10 +693,7 @@ describe('sheet language', () => {
it('raw mode avoids any internal filters', () => {
let result = generateSQLWithState(
- query('transactions')
- .select(['amount'])
- .raw()
- .serialize(),
+ query('transactions').select(['amount']).raw().serialize(),
schemaWithRefs,
{
tableViews: { transactions: 'v_transactions' },
@@ -914,10 +868,7 @@ describe('Type conversions', () => {
it('allows conversions from string to id', () => {
expect(() => {
generateSQLWithState(
- query('transactions')
- .filter({ id: 'foo' })
- .select(['id'])
- .serialize(),
+ query('transactions').filter({ id: 'foo' }).select(['id']).serialize(),
schemaWithRefs
);
}).not.toThrow();
@@ -935,10 +886,7 @@ describe('Type conversions', () => {
// Numbers cannot be converted to ids
expect(() => {
generateSQLWithState(
- query('transactions')
- .filter({ id: 5 })
- .select(['id'])
- .serialize(),
+ query('transactions').filter({ id: 5 }).select(['id']).serialize(),
schemaWithRefs
);
}).toThrow(/Can't convert/);
@@ -970,10 +918,7 @@ describe('Type conversions', () => {
it('allows fields to be nullable', () => {
// With validated refs
let result = generateSQLWithState(
- query('transactions')
- .filter({ payee: null })
- .select()
- .serialize(),
+ query('transactions').filter({ payee: null }).select().serialize(),
schemaWithRefs
);
expect(result.sql).toMatch('WHERE (payees1.id IS NULL)');
diff --git a/packages/loot-core/src/server/aql/exec.test.js b/packages/loot-core/src/server/aql/exec.test.js
index 7f854ba78f..466fb29d8b 100644
--- a/packages/loot-core/src/server/aql/exec.test.js
+++ b/packages/loot-core/src/server/aql/exec.test.js
@@ -75,9 +75,7 @@ describe('runQuery', () => {
// date
let { data } = await runQuery(
- query('transactions')
- .select('date')
- .serialize()
+ query('transactions').select('date').serialize()
);
expect(data[0].date).toBe('2020-01-04');
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 528cad82f8..8e2c7c26f9 100644
--- a/packages/loot-core/src/server/aql/schema/executors.test.js
+++ b/packages/loot-core/src/server/aql/schema/executors.test.js
@@ -103,10 +103,7 @@ async function expectPagedData(query, numTransactions, allData) {
// Pull in all the data via pages
let { data } = await runQuery(
- query
- .limit(pageCount)
- .offset(pagedData.length)
- .serialize()
+ query.limit(pageCount).offset(pagedData.length).serialize()
);
expect(data.length).toBeLessThanOrEqual(pageCount);
diff --git a/packages/loot-core/src/server/crdt/timestamp.js b/packages/loot-core/src/server/crdt/timestamp.js
index cf1f5fa9ad..ea1fec3340 100644
--- a/packages/loot-core/src/server/crdt/timestamp.js
+++ b/packages/loot-core/src/server/crdt/timestamp.js
@@ -65,10 +65,7 @@ export function deserializeClock(clock) {
}
export function makeClientId() {
- return uuid
- .v4Sync()
- .replace(/-/g, '')
- .slice(-16);
+ return uuid.v4Sync().replace(/-/g, '').slice(-16);
}
var config = {
@@ -98,12 +95,7 @@ export class Timestamp {
toString() {
return [
new Date(this.millis()).toISOString(),
- (
- '0000' +
- this.counter()
- .toString(16)
- .toUpperCase()
- ).slice(-4),
+ ('0000' + this.counter().toString(16).toUpperCase()).slice(-4),
('0000000000000000' + this.node()).slice(-16)
].join('-');
}
@@ -150,7 +142,7 @@ MutableTimestamp.from = timestamp => {
// Timestamp generator initialization
// * sets the node ID to an arbitrary value
// * useful for mocking/unit testing
-Timestamp.init = function(options = {}) {
+Timestamp.init = function (options = {}) {
if (options.maxDrift) {
config.maxDrift = options.maxDrift;
}
@@ -173,7 +165,7 @@ Timestamp.init = function(options = {}) {
* Timestamp send. Generates a unique, monotonic timestamp suitable
* for transmission to another system in string format
*/
-Timestamp.send = function() {
+Timestamp.send = function () {
if (!clock) {
return null;
}
@@ -213,7 +205,7 @@ Timestamp.send = function() {
// Timestamp receive. Parses and merges a timestamp from a remote
// system with the local timeglobal uniqueness and monotonicity are
// preserved
-Timestamp.recv = function(msg) {
+Timestamp.recv = function (msg) {
if (!clock) {
return null;
}
@@ -276,7 +268,7 @@ Timestamp.recv = function(msg) {
* timestamp parsing
* converts a fixed-length string timestamp to the structured value
*/
-Timestamp.parse = function(timestamp) {
+Timestamp.parse = function (timestamp) {
if (typeof timestamp === 'string') {
var parts = timestamp.split('-');
if (parts && parts.length === 5) {
@@ -302,7 +294,7 @@ Timestamp.parse = function(timestamp) {
* zero/minimum timestamp
*/
var zero = Timestamp.parse('1970-01-01T00:00:00.000Z-0000-0000000000000000');
-Timestamp.zero = function() {
+Timestamp.zero = function () {
return zero;
};
@@ -310,7 +302,7 @@ Timestamp.zero = function() {
* maximum timestamp
*/
var max = Timestamp.parse('9999-12-31T23:59:59.999Z-FFFF-FFFFFFFFFFFFFFFF');
-Timestamp.max = function() {
+Timestamp.max = function () {
return max;
};
diff --git a/packages/loot-core/src/server/crdt/timestamp.test.js b/packages/loot-core/src/server/crdt/timestamp.test.js
index a9c04fab99..2e6f35e158 100644
--- a/packages/loot-core/src/server/crdt/timestamp.test.js
+++ b/packages/loot-core/src/server/crdt/timestamp.test.js
@@ -1,9 +1,9 @@
import { Timestamp } from './timestamp';
-describe('Timestamp', function() {
+describe('Timestamp', function () {
let now = 0;
- beforeEach(function() {
+ beforeEach(function () {
Date.prevNow = Date.now;
Date.now = () => now;
Timestamp.init({ node: '1' });
@@ -13,8 +13,8 @@ describe('Timestamp', function() {
Date.now = Date.prevNow;
});
- describe('comparison', function() {
- it('should be in order', function() {
+ describe('comparison', function () {
+ it('should be in order', function () {
expect(Timestamp.zero()).toBe(Timestamp.zero());
expect(Timestamp.max() > Timestamp.zero()).toBeTruthy();
expect(Timestamp.send() > Timestamp.zero()).toBeTruthy();
@@ -22,8 +22,8 @@ describe('Timestamp', function() {
});
});
- describe('parsing', function() {
- it('should not parse', function() {
+ describe('parsing', function () {
+ it('should not parse', function () {
var invalidInputs = [
null,
undefined,
@@ -45,7 +45,7 @@ describe('Timestamp', function() {
}
});
- it('should parse', function() {
+ it('should parse', function () {
var validInputs = [
'1970-01-01T00:00:00.000Z-0000-0000000000000000',
'2015-04-24T22:23:42.123Z-1000-0123456789ABCDEF',
@@ -64,8 +64,8 @@ describe('Timestamp', function() {
});
});
- describe('send', function() {
- it('should send monotonically with a monotonic clock', function() {
+ describe('send', function () {
+ it('should send monotonically with a monotonic clock', function () {
now = 10;
expect(Timestamp.send()).toEqual(
Timestamp.parse('1970-01-01T00:00:00.010Z-0000-0000000000000001')
@@ -80,7 +80,7 @@ describe('Timestamp', function() {
);
});
- it('should send monotonically with a stuttering clock', function() {
+ it('should send monotonically with a stuttering clock', function () {
now = 20;
expect(Timestamp.send()).toEqual(
Timestamp.parse('1970-01-01T00:00:00.020Z-0000-0000000000000001')
@@ -97,7 +97,7 @@ describe('Timestamp', function() {
);
});
- it('should send monotonically with a regressing clock', function() {
+ it('should send monotonically with a regressing clock', function () {
now = 30;
expect(Timestamp.send()).toEqual(
Timestamp.parse('1970-01-01T00:00:00.030Z-0000-0000000000000001')
@@ -115,20 +115,20 @@ describe('Timestamp', function() {
);
});
- it('should fail with counter overflow', function() {
+ it('should fail with counter overflow', function () {
now = 40;
for (var i = 0; i < 65536; i++) Timestamp.send();
expect(Timestamp.send).toThrow(Timestamp.OverflowError);
});
- it('should fail with clock drift', function() {
+ it('should fail with clock drift', function () {
now = -(5 * 60 * 1000 + 1);
expect(Timestamp.send).toThrow(Timestamp.ClockDriftError);
});
});
- describe('recv', function() {
- it('should receive monotonically with a global monotonic clock', function() {
+ describe('recv', function () {
+ it('should receive monotonically with a global monotonic clock', function () {
now = 52;
expect(
Timestamp.recv(
@@ -155,7 +155,7 @@ describe('Timestamp', function() {
);
});
- it('should receive monotonically with a global stuttering clock', function() {
+ it('should receive monotonically with a global stuttering clock', function () {
now = 61;
expect(
Timestamp.recv(
@@ -190,7 +190,7 @@ describe('Timestamp', function() {
);
});
- it('should receive monotonically with a local stuttering clock', function() {
+ it('should receive monotonically with a local stuttering clock', function () {
now = 73;
expect(
Timestamp.recv(
@@ -217,7 +217,7 @@ describe('Timestamp', function() {
);
});
- it('should receive monotonically with a remote stuttering clock', function() {
+ it('should receive monotonically with a remote stuttering clock', function () {
now = 81;
expect(
Timestamp.recv(
@@ -251,7 +251,7 @@ describe('Timestamp', function() {
Timestamp.parse('1970-01-01T00:00:00.084Z-0000-0000000000000001')
);
});
- it('should receive monotonically with a local regressing clock', function() {
+ it('should receive monotonically with a local regressing clock', function () {
now = 93;
expect(
Timestamp.recv(
@@ -277,7 +277,7 @@ describe('Timestamp', function() {
Timestamp.parse('1970-01-01T00:00:00.093Z-0002-0000000000000001')
);
});
- it('should receive monotonically with a remote regressing clock', function() {
+ it('should receive monotonically with a remote regressing clock', function () {
now = 101;
expect(
Timestamp.recv(
@@ -312,8 +312,8 @@ describe('Timestamp', function() {
// }).toThrow(Timestamp.DuplicateNodeError);
// });
- it('should fail with clock drift', function() {
- expect(function() {
+ it('should fail with clock drift', function () {
+ expect(function () {
Timestamp.recv(
Timestamp.parse('1980-01-01T00:00:00.101Z-0000-0000000000000002')
);
diff --git a/packages/loot-core/src/server/encryption-internals.js b/packages/loot-core/src/server/encryption-internals.js
index 51a52045bf..d330ecbe04 100644
--- a/packages/loot-core/src/server/encryption-internals.js
+++ b/packages/loot-core/src/server/encryption-internals.js
@@ -3,10 +3,7 @@ let crypto = require('crypto');
let ENCRYPTION_ALGORITHM = 'aes-256-gcm';
export async function sha256String(str) {
- return crypto
- .createHash('sha256')
- .update(str)
- .digest('base64');
+ return crypto.createHash('sha256').update(str).digest('base64');
}
export function randomBytes(n) {
diff --git a/packages/loot-core/src/server/main.js b/packages/loot-core/src/server/main.js
index f8f4106377..e9773bef76 100644
--- a/packages/loot-core/src/server/main.js
+++ b/packages/loot-core/src/server/main.js
@@ -101,15 +101,15 @@ function onSheetChange({ names }) {
export let handlers = {};
-handlers['undo'] = mutator(async function() {
+handlers['undo'] = mutator(async function () {
return undo();
});
-handlers['redo'] = mutator(function() {
+handlers['redo'] = mutator(function () {
return redo();
});
-handlers['transactions-batch-update'] = mutator(async function({
+handlers['transactions-batch-update'] = mutator(async function ({
added,
deleted,
updated,
@@ -128,22 +128,22 @@ handlers['transactions-batch-update'] = mutator(async function({
});
});
-handlers['transaction-add'] = mutator(async function(transaction) {
+handlers['transaction-add'] = mutator(async function (transaction) {
await handlers['transactions-batch-update']({ added: [transaction] });
return {};
});
-handlers['transaction-update'] = mutator(async function(transaction) {
+handlers['transaction-update'] = mutator(async function (transaction) {
await handlers['transactions-batch-update']({ updated: [transaction] });
return {};
});
-handlers['transaction-delete'] = mutator(async function(transaction) {
+handlers['transaction-delete'] = mutator(async function (transaction) {
await handlers['transactions-batch-update']({ deleted: [transaction] });
return {};
});
-handlers['transactions-filter'] = async function({
+handlers['transactions-filter'] = async function ({
term,
accountId,
latestDate,
@@ -160,11 +160,11 @@ handlers['transactions-filter'] = async function({
);
};
-handlers['transactions-parse-file'] = async function({ filepath, options }) {
+handlers['transactions-parse-file'] = async function ({ filepath, options }) {
return parseFile(filepath, options);
};
-handlers['transactions-export'] = async function({
+handlers['transactions-export'] = async function ({
transactions,
accounts,
categoryGroups,
@@ -173,18 +173,18 @@ handlers['transactions-export'] = async function({
return exportToCSV(transactions, accounts, categoryGroups, payees);
};
-handlers['transactions-export-query'] = async function({ query: queryState }) {
+handlers['transactions-export-query'] = async function ({ query: queryState }) {
return exportQueryToCSV(new Query(queryState));
};
-handlers['get-categories'] = async function() {
+handlers['get-categories'] = async function () {
return {
grouped: await db.getCategoriesGrouped(),
list: await db.getCategories()
};
};
-handlers['get-earliest-transaction'] = async function() {
+handlers['get-earliest-transaction'] = async function () {
let { data } = await aqlQuery(
q('transactions')
.options({ splits: 'none' })
@@ -195,11 +195,11 @@ handlers['get-earliest-transaction'] = async function() {
return data[0] || null;
};
-handlers['get-budget-bounds'] = async function() {
+handlers['get-budget-bounds'] = async function () {
return budget.createAllBudgets();
};
-handlers['rollover-budget-month'] = async function({ month }) {
+handlers['rollover-budget-month'] = async function ({ month }) {
let groups = await db.getCategoriesGrouped();
let sheetName = monthUtils.sheetForMonth(month);
@@ -249,7 +249,7 @@ handlers['rollover-budget-month'] = async function({ month }) {
return values;
};
-handlers['report-budget-month'] = async function({ month }) {
+handlers['report-budget-month'] = async function ({ month }) {
let groups = await db.getCategoriesGrouped();
let sheetName = monthUtils.sheetForMonth(month);
@@ -291,7 +291,7 @@ handlers['report-budget-month'] = async function({ month }) {
return values;
};
-handlers['budget-set-type'] = async function({ type }) {
+handlers['budget-set-type'] = async function ({ type }) {
if (type !== 'rollover' && type !== 'report') {
throw new Error('Invalid budget type: ' + type);
}
@@ -305,7 +305,7 @@ handlers['budget-set-type'] = async function({ type }) {
return prefs.savePrefs({ budgetType: type });
};
-handlers['category-create'] = mutator(async function({
+handlers['category-create'] = mutator(async function ({
name,
groupId,
isIncome
@@ -323,7 +323,7 @@ handlers['category-create'] = mutator(async function({
});
});
-handlers['category-update'] = mutator(async function(category) {
+handlers['category-update'] = mutator(async function (category) {
return withUndo(async () => {
try {
await db.updateCategory(category);
@@ -337,7 +337,7 @@ handlers['category-update'] = mutator(async function(category) {
});
});
-handlers['category-move'] = mutator(async function({ id, groupId, targetId }) {
+handlers['category-move'] = mutator(async function ({ id, groupId, targetId }) {
return withUndo(async () => {
await batchMessages(async () => {
await db.moveCategory(id, groupId, targetId);
@@ -346,7 +346,7 @@ handlers['category-move'] = mutator(async function({ id, groupId, targetId }) {
});
});
-handlers['category-delete'] = mutator(async function({ id, transferId }) {
+handlers['category-delete'] = mutator(async function ({ id, transferId }) {
return withUndo(async () => {
let result = {};
await batchMessages(async () => {
@@ -388,7 +388,10 @@ handlers['category-delete'] = mutator(async function({ id, transferId }) {
});
});
-handlers['category-group-create'] = mutator(async function({ name, isIncome }) {
+handlers['category-group-create'] = mutator(async function ({
+ name,
+ isIncome
+}) {
return withUndo(async () => {
return db.insertCategoryGroup({
name,
@@ -397,13 +400,13 @@ handlers['category-group-create'] = mutator(async function({ name, isIncome }) {
});
});
-handlers['category-group-update'] = mutator(async function(group) {
+handlers['category-group-update'] = mutator(async function (group) {
return withUndo(async () => {
return db.updateCategoryGroup(group);
});
});
-handlers['category-group-move'] = mutator(async function({ id, targetId }) {
+handlers['category-group-move'] = mutator(async function ({ id, targetId }) {
return withUndo(async () => {
await batchMessages(async () => {
await db.moveCategoryGroup(id, targetId);
@@ -412,7 +415,10 @@ handlers['category-group-move'] = mutator(async function({ id, targetId }) {
});
});
-handlers['category-group-delete'] = mutator(async function({ id, transferId }) {
+handlers['category-group-delete'] = mutator(async function ({
+ id,
+ transferId
+}) {
return withUndo(async () => {
const groupCategories = await db.all(
'SELECT id FROM categories WHERE cat_group = ? AND tombstone = 0',
@@ -431,7 +437,7 @@ handlers['category-group-delete'] = mutator(async function({ id, transferId }) {
});
});
-handlers['must-category-transfer'] = async function({ id }) {
+handlers['must-category-transfer'] = async function ({ id }) {
const res = await db.runQuery(
`SELECT count(t.id) as count FROM transactions t
LEFT JOIN category_mapping cm ON cm.id = t.category
@@ -456,17 +462,17 @@ handlers['must-category-transfer'] = async function({ id }) {
});
};
-handlers['payee-create'] = mutator(async function({ name }) {
+handlers['payee-create'] = mutator(async function ({ name }) {
return withUndo(async () => {
return db.insertPayee({ name });
});
});
-handlers['payees-get'] = async function() {
+handlers['payees-get'] = async function () {
return db.getPayees();
};
-handlers['payees-get-rule-counts'] = async function() {
+handlers['payees-get-rule-counts'] = async function () {
let payeeCounts = {};
rules.iterateIds(rules.getRules(), 'payee', (rule, id) => {
@@ -479,7 +485,7 @@ handlers['payees-get-rule-counts'] = async function() {
return payeeCounts;
};
-handlers['payees-merge'] = mutator(async function({ targetId, mergeIds }) {
+handlers['payees-merge'] = mutator(async function ({ targetId, mergeIds }) {
return withUndo(
async () => {
return db.mergePayees(targetId, mergeIds);
@@ -488,7 +494,7 @@ handlers['payees-merge'] = mutator(async function({ targetId, mergeIds }) {
);
});
-handlers['payees-batch-change'] = mutator(async function({
+handlers['payees-batch-change'] = mutator(async function ({
added,
deleted,
updated
@@ -510,16 +516,16 @@ handlers['payees-batch-change'] = mutator(async function({
});
});
-handlers['payees-check-orphaned'] = async function({ ids }) {
+handlers['payees-check-orphaned'] = async function ({ ids }) {
let orphaned = new Set(await db.getOrphanedPayees());
return ids.filter(id => orphaned.has(id));
};
-handlers['payees-get-rules'] = async function({ id }) {
+handlers['payees-get-rules'] = async function ({ id }) {
return rules.getRulesForPayee(id).map(rule => rule.serialize());
};
-handlers['payees-delete-rule'] = mutator(async function({ id, payee_id }) {
+handlers['payees-delete-rule'] = mutator(async function ({ id, payee_id }) {
return withUndo(
async () => {
return await db.deletePayeeRule({ id });
@@ -528,7 +534,7 @@ handlers['payees-delete-rule'] = mutator(async function({ id, payee_id }) {
);
});
-handlers['payees-update-rule'] = mutator(async function(rule) {
+handlers['payees-update-rule'] = mutator(async function (rule) {
return withUndo(
async () => {
return await db.updatePayeeRule(rule);
@@ -537,7 +543,7 @@ handlers['payees-update-rule'] = mutator(async function(rule) {
);
});
-handlers['payees-add-rule'] = mutator(async function(rule) {
+handlers['payees-add-rule'] = mutator(async function (rule) {
return withUndo(
async () => {
let id = await db.insertPayeeRule(rule);
@@ -601,12 +607,12 @@ function validateRule(rule) {
return null;
}
-handlers['rule-validate'] = async function(rule) {
+handlers['rule-validate'] = async function (rule) {
let error = validateRule(rule);
return { error };
};
-handlers['rule-add'] = mutator(async function(rule) {
+handlers['rule-add'] = mutator(async function (rule) {
let error = validateRule(rule);
if (error) {
return { error };
@@ -616,7 +622,7 @@ handlers['rule-add'] = mutator(async function(rule) {
return { id };
});
-handlers['rule-update'] = mutator(async function(rule) {
+handlers['rule-update'] = mutator(async function (rule) {
let error = validateRule(rule);
if (error) {
return { error };
@@ -626,11 +632,11 @@ handlers['rule-update'] = mutator(async function(rule) {
return {};
});
-handlers['rule-delete'] = mutator(async function(rule) {
+handlers['rule-delete'] = mutator(async function (rule) {
return rules.deleteRule(rule);
});
-handlers['rule-delete-all'] = mutator(async function(ids) {
+handlers['rule-delete-all'] = mutator(async function (ids) {
let someDeletionsFailed = false;
await batchMessages(async () => {
@@ -645,39 +651,39 @@ handlers['rule-delete-all'] = mutator(async function(ids) {
return { someDeletionsFailed };
});
-handlers['rule-apply-actions'] = mutator(async function({
+handlers['rule-apply-actions'] = mutator(async function ({
transactionIds,
actions
}) {
return rules.applyActions(transactionIds, actions, handlers);
});
-handlers['rule-add-payee-rename'] = mutator(async function({ fromNames, to }) {
+handlers['rule-add-payee-rename'] = mutator(async function ({ fromNames, to }) {
return rules.updatePayeeRenameRule(fromNames, to);
});
-handlers['rules-get'] = async function() {
+handlers['rules-get'] = async function () {
return rankRules(rules.getRules()).map(rule => rule.serialize());
};
-handlers['rule-get'] = async function({ id }) {
+handlers['rule-get'] = async function ({ id }) {
let rule = rules.getRules().find(rule => rule.id === id);
return rule ? rule.serialize() : null;
};
-handlers['rules-run'] = async function({ transaction }) {
+handlers['rules-run'] = async function ({ transaction }) {
return rules.runRules(transaction);
};
-handlers['rules-migrate'] = async function() {
+handlers['rules-migrate'] = async function () {
await rules.migrateOldRules();
};
-handlers['make-filters-from-conditions'] = async function({ conditions }) {
+handlers['make-filters-from-conditions'] = async function ({ conditions }) {
return rules.conditionsToAQL(conditions);
};
-handlers['getCell'] = async function({ sheetName, name }) {
+handlers['getCell'] = async function ({ sheetName, name }) {
// Fields is no longer used - hardcode
let fields = ['name', 'value'];
let node = sheet.get()._getNode(resolveName(sheetName, name));
@@ -696,16 +702,13 @@ handlers['getCell'] = async function({ sheetName, name }) {
}
};
-handlers['getCells'] = async function({ names }) {
+handlers['getCells'] = async function ({ names }) {
return names.map(name => ({ value: sheet.get()._getNode(name).value }));
};
-handlers['getCellNamesInSheet'] = async function({ sheetName }) {
+handlers['getCellNamesInSheet'] = async function ({ sheetName }) {
let names = [];
- for (let name of sheet
- .get()
- .getNodes()
- .keys()) {
+ for (let name of sheet.get().getNodes().keys()) {
let { sheet: nodeSheet, name: nodeName } = unresolveName(name);
if (nodeSheet === sheetName) {
names.push(nodeName);
@@ -714,7 +717,7 @@ handlers['getCellNamesInSheet'] = async function({ sheetName }) {
return names;
};
-handlers['debugCell'] = async function({ sheetName, name }) {
+handlers['debugCell'] = async function ({ sheetName, name }) {
let node = sheet.get().getNode(resolveName(sheetName, name));
return {
...node,
@@ -722,14 +725,14 @@ handlers['debugCell'] = async function({ sheetName, name }) {
};
};
-handlers['create-query'] = async function({ sheetName, name, query }) {
+handlers['create-query'] = async function ({ sheetName, name, query }) {
// Always run it regardless of cache. We don't know anything has changed
// between the cache value being saved and now
sheet.get().createQuery(sheetName, name, query);
return 'ok';
};
-handlers['query'] = async function(query) {
+handlers['query'] = async function (query) {
if (query.table == null) {
throw new Error('query has no table, did you forgot to call `.serialize`?');
}
@@ -737,7 +740,7 @@ handlers['query'] = async function(query) {
return aqlQuery(query);
};
-handlers['bank-delete'] = async function({ id }) {
+handlers['bank-delete'] = async function ({ id }) {
const accts = await db.runQuery(
'SELECT * FROM accounts WHERE bank = ?',
[id],
@@ -756,27 +759,23 @@ handlers['bank-delete'] = async function({ id }) {
return 'ok';
};
-handlers['account-update'] = mutator(async function({ id, name }) {
+handlers['account-update'] = mutator(async function ({ id, name }) {
return withUndo(async () => {
await db.update('accounts', { id, name });
return {};
});
});
-handlers['accounts-get'] = async function() {
+handlers['accounts-get'] = async function () {
return db.getAccounts();
};
-handlers['account-properties'] = async function({ id }) {
- const {
- balance
- } = await db.first(
+handlers['account-properties'] = async function ({ id }) {
+ const { balance } = await db.first(
'SELECT sum(amount) as balance FROM transactions WHERE acct = ? AND isParent = 0 AND tombstone = 0',
[id]
);
- const {
- count
- } = await db.first(
+ const { count } = await db.first(
'SELECT count(id) as count FROM transactions WHERE acct = ? AND tombstone = 0',
[id]
);
@@ -784,7 +783,7 @@ handlers['account-properties'] = async function({ id }) {
return { balance: balance || 0, numTransactions: count };
};
-handlers['accounts-link'] = async function({
+handlers['accounts-link'] = async function ({
institution,
publicToken,
accountId,
@@ -829,7 +828,7 @@ handlers['accounts-link'] = async function({
return 'ok';
};
-handlers['accounts-connect'] = async function({
+handlers['accounts-connect'] = async function ({
institution,
publicToken,
accountIds,
@@ -840,7 +839,7 @@ handlers['accounts-connect'] = async function({
return ids;
};
-handlers['account-create'] = mutator(async function({
+handlers['account-create'] = mutator(async function ({
name,
type,
balance,
@@ -878,7 +877,7 @@ handlers['account-create'] = mutator(async function({
});
});
-handlers['account-close'] = mutator(async function({
+handlers['account-close'] = mutator(async function ({
id,
transferAccountId,
categoryId,
@@ -915,9 +914,10 @@ handlers['account-close'] = mutator(async function({
true
);
- let {
- id: payeeId
- } = await db.first('SELECT id FROM payees WHERE transfer_acct = ?', [id]);
+ let { id: payeeId } = await db.first(
+ 'SELECT id FROM payees WHERE transfer_acct = ?',
+ [id]
+ );
await batchMessages(() => {
// TODO: what this should really do is send a special message that
@@ -951,11 +951,10 @@ handlers['account-close'] = mutator(async function({
// If there is a balance we need to transfer it to the specified
// account (and possibly categorize it)
if (balance !== 0) {
- let {
- id: payeeId
- } = await db.first('SELECT id FROM payees WHERE transfer_acct = ?', [
- transferAccountId
- ]);
+ let { id: payeeId } = await db.first(
+ 'SELECT id FROM payees WHERE transfer_acct = ?',
+ [transferAccountId]
+ );
await handlers['transaction-add']({
id: uuid.v4Sync(),
@@ -971,13 +970,13 @@ handlers['account-close'] = mutator(async function({
});
});
-handlers['account-reopen'] = mutator(async function({ id }) {
+handlers['account-reopen'] = mutator(async function ({ id }) {
return withUndo(async () => {
await db.update('accounts', { id, closed: 0 });
});
});
-handlers['account-move'] = mutator(async function({ id, targetId }) {
+handlers['account-move'] = mutator(async function ({ id, targetId }) {
return withUndo(async () => {
await db.moveAccount(id, targetId);
});
@@ -985,7 +984,7 @@ handlers['account-move'] = mutator(async function({ id, targetId }) {
let stopPolling = false;
-handlers['poll-web-token'] = async function({ token }) {
+handlers['poll-web-token'] = async function ({ token }) {
let [[, userId], [, key]] = await asyncStorage.multiGet([
'user-id',
'user-key'
@@ -1035,12 +1034,12 @@ handlers['poll-web-token'] = async function({ token }) {
});
};
-handlers['poll-web-token-stop'] = async function() {
+handlers['poll-web-token-stop'] = async function () {
stopPolling = true;
return 'ok';
};
-handlers['accounts-sync'] = async function({ id }) {
+handlers['accounts-sync'] = async function ({ id }) {
let [[, userId], [, userKey]] = await asyncStorage.multiGet([
'user-id',
'user-key'
@@ -1121,7 +1120,7 @@ handlers['accounts-sync'] = async function({ id }) {
return { errors, newTransactions, matchedTransactions, updatedAccounts };
};
-handlers['transactions-import'] = mutator(function({
+handlers['transactions-import'] = mutator(function ({
accountId,
transactions
}) {
@@ -1142,10 +1141,11 @@ handlers['transactions-import'] = mutator(function({
});
});
-handlers['account-unlink'] = mutator(async function({ id }) {
- let {
- bank: bankId
- } = await db.first('SELECT bank FROM accounts WHERE id = ?', [id]);
+handlers['account-unlink'] = mutator(async function ({ id }) {
+ let { bank: bankId } = await db.first(
+ 'SELECT bank FROM accounts WHERE id = ?',
+ [id]
+ );
if (!bankId) {
return 'ok';
@@ -1160,11 +1160,10 @@ handlers['account-unlink'] = mutator(async function({ id }) {
balance_limit: null
});
- let {
- count
- } = await db.first('SELECT COUNT(*) as count FROM accounts WHERE bank = ?', [
- bankId
- ]);
+ let { count } = await db.first(
+ 'SELECT COUNT(*) as count FROM accounts WHERE bank = ?',
+ [bankId]
+ );
if (count === 0) {
// No more accounts are associated with this bank. We can remove
@@ -1185,7 +1184,7 @@ handlers['account-unlink'] = mutator(async function({ id }) {
return 'ok';
});
-handlers['make-plaid-public-token'] = async function({ bankId }) {
+handlers['make-plaid-public-token'] = async function ({ bankId }) {
let [[, userId], [, userKey]] = await asyncStorage.multiGet([
'user-id',
'user-key'
@@ -1204,7 +1203,7 @@ handlers['make-plaid-public-token'] = async function({ bankId }) {
return { linkToken: data.link_token };
};
-handlers['save-global-prefs'] = async function(prefs) {
+handlers['save-global-prefs'] = async function (prefs) {
if ('maxMonths' in prefs) {
await asyncStorage.setItem('max-months', '' + prefs.maxMonths);
}
@@ -1223,7 +1222,7 @@ handlers['save-global-prefs'] = async function(prefs) {
return 'ok';
};
-handlers['load-global-prefs'] = async function() {
+handlers['load-global-prefs'] = async function () {
let [
[, floatingSidebar],
[, seenTutorial],
@@ -1249,7 +1248,7 @@ handlers['load-global-prefs'] = async function() {
};
};
-handlers['save-prefs'] = async function(prefsToSet) {
+handlers['save-prefs'] = async function (prefsToSet) {
let { cloudFileId } = prefs.getPrefs();
// Need to sync the budget name on the server as well
@@ -1267,15 +1266,15 @@ handlers['save-prefs'] = async function(prefsToSet) {
return 'ok';
};
-handlers['load-prefs'] = async function() {
+handlers['load-prefs'] = async function () {
return prefs.getPrefs();
};
-handlers['sync-reset'] = async function() {
+handlers['sync-reset'] = async function () {
return await resetSync();
};
-handlers['sync-repair'] = async function() {
+handlers['sync-repair'] = async function () {
await repairSync();
};
@@ -1283,7 +1282,7 @@ handlers['sync-repair'] = async function() {
// will change in the future: during onboarding the user should be
// able to enable encryption. (Imagine if they are importing data from
// another source, they should be able to encrypt first)
-handlers['key-make'] = async function({ password }) {
+handlers['key-make'] = async function ({ password }) {
if (!prefs.getPrefs()) {
throw new Error('user-set-key must be called with file loaded');
}
@@ -1313,7 +1312,7 @@ handlers['key-make'] = async function({ password }) {
// This can be called both while a file is already loaded or not. This
// will see if a key is valid and if so save it off.
-handlers['key-test'] = async function({ fileId, password }) {
+handlers['key-test'] = async function ({ fileId, password }) {
let userToken = await asyncStorage.getItem('user-token');
if (fileId == null) {
@@ -1367,17 +1366,17 @@ handlers['key-test'] = async function({ fileId, password }) {
return {};
};
-handlers['should-pitch-subscribe'] = async function() {
+handlers['should-pitch-subscribe'] = async function () {
let seenSubscribe = await asyncStorage.getItem('seenSubscribe');
return seenSubscribe !== 'true';
};
-handlers['has-pitched-subscribe'] = async function() {
+handlers['has-pitched-subscribe'] = async function () {
await asyncStorage.setItem('seenSubscribe', 'true');
return 'ok';
};
-handlers['subscribe-needs-bootstrap'] = async function({ url } = {}) {
+handlers['subscribe-needs-bootstrap'] = async function ({ url } = {}) {
if (getServer(url).BASE_SERVER === UNCONFIGURED_SERVER) {
return { bootstrapped: true };
}
@@ -1402,7 +1401,7 @@ handlers['subscribe-needs-bootstrap'] = async function({ url } = {}) {
return { bootstrapped: res.data.bootstrapped };
};
-handlers['subscribe-bootstrap'] = async function({ password }) {
+handlers['subscribe-bootstrap'] = async function ({ password }) {
let res;
try {
res = await post(getServer().SIGNUP_SERVER + '/bootstrap', { password });
@@ -1417,11 +1416,11 @@ handlers['subscribe-bootstrap'] = async function({ password }) {
return { error: 'internal' };
};
-handlers['subscribe-set-user'] = async function({ token }) {
+handlers['subscribe-set-user'] = async function ({ token }) {
await asyncStorage.setItem('user-token', token);
};
-handlers['subscribe-get-user'] = async function() {
+handlers['subscribe-get-user'] = async function () {
if (getServer() && getServer().BASE_SERVER === UNCONFIGURED_SERVER) {
return { offline: false };
}
@@ -1454,7 +1453,7 @@ handlers['subscribe-get-user'] = async function() {
return null;
};
-handlers['subscribe-change-password'] = async function({ password }) {
+handlers['subscribe-change-password'] = async function ({ password }) {
let userToken = await asyncStorage.getItem('user-token');
try {
await post(getServer().SIGNUP_SERVER + '/change-password', {
@@ -1468,7 +1467,7 @@ handlers['subscribe-change-password'] = async function({ password }) {
return {};
};
-handlers['subscribe-sign-in'] = async function({ password }) {
+handlers['subscribe-sign-in'] = async function ({ password }) {
let res = await post(getServer().SIGNUP_SERVER + '/login', {
password
});
@@ -1481,7 +1480,7 @@ handlers['subscribe-sign-in'] = async function({ password }) {
return { error: 'invalid-password' };
};
-handlers['subscribe-sign-out'] = async function() {
+handlers['subscribe-sign-out'] = async function () {
encryption.unloadAllKeys();
await asyncStorage.multiRemove([
'user-token',
@@ -1492,7 +1491,7 @@ handlers['subscribe-sign-out'] = async function() {
return 'ok';
};
-handlers['get-server-version'] = async function() {
+handlers['get-server-version'] = async function () {
if (!getServer() || getServer().BASE_SERVER === UNCONFIGURED_SERVER) {
return { error: 'no-server' };
}
@@ -1510,11 +1509,11 @@ handlers['get-server-version'] = async function() {
return { version };
};
-handlers['get-server-url'] = async function() {
+handlers['get-server-url'] = async function () {
return getServer() && getServer().BASE_SERVER;
};
-handlers['set-server-url'] = async function({ url }) {
+handlers['set-server-url'] = async function ({ url }) {
if (url != null) {
// Validate the server is running
let { error } = await runHandler(handlers['subscribe-needs-bootstrap'], {
@@ -1533,15 +1532,15 @@ handlers['set-server-url'] = async function({ url }) {
return {};
};
-handlers['sync'] = async function() {
+handlers['sync'] = async function () {
return fullSync();
};
-handlers['get-version'] = async function() {
+handlers['get-version'] = async function () {
return { version: VERSION };
};
-handlers['get-budgets'] = async function() {
+handlers['get-budgets'] = async function () {
const paths = await fs.listDir(fs.getDocumentDir());
const budgets = (
await Promise.all(
@@ -1578,22 +1577,22 @@ handlers['get-budgets'] = async function() {
return budgets;
};
-handlers['get-ynab4-files'] = async function() {
+handlers['get-ynab4-files'] = async function () {
return YNAB4.findBudgets();
};
-handlers['get-remote-files'] = async function() {
+handlers['get-remote-files'] = async function () {
return cloudStorage.listRemoteFiles();
};
-handlers['reset-budget-cache'] = mutator(async function() {
+handlers['reset-budget-cache'] = mutator(async function () {
// Recomputing everything will update the cache
await sheet.loadUserBudgets(db);
sheet.get().recomputeAll();
await sheet.waitOnSpreadsheet();
});
-handlers['upload-budget'] = async function({ id } = {}) {
+handlers['upload-budget'] = async function ({ id } = {}) {
if (id) {
if (prefs.getPrefs()) {
throw new Error('upload-budget: id given but prefs already loaded');
@@ -1620,7 +1619,7 @@ handlers['upload-budget'] = async function({ id } = {}) {
return {};
};
-handlers['download-budget'] = async function({ fileId, replace }) {
+handlers['download-budget'] = async function ({ fileId, replace }) {
let result;
try {
result = await cloudStorage.download(fileId, replace);
@@ -1657,7 +1656,7 @@ handlers['download-budget'] = async function({ fileId, replace }) {
return { id };
};
-handlers['load-budget'] = async function({ id }) {
+handlers['load-budget'] = async function ({ id }) {
let currentPrefs = prefs.getPrefs();
if (currentPrefs) {
@@ -1675,7 +1674,7 @@ handlers['load-budget'] = async function({ id }) {
return res;
};
-handlers['create-demo-budget'] = async function() {
+handlers['create-demo-budget'] = async function () {
// Make sure the read only flag isn't leftover (normally it's
// reset when signing in, but you don't have to sign in for the
// demo budget)
@@ -1688,7 +1687,7 @@ handlers['create-demo-budget'] = async function() {
});
};
-handlers['close-budget'] = async function() {
+handlers['close-budget'] = async function () {
captureBreadcrumb({ message: 'Closing budget' });
// The spreadsheet may be running, wait for it to complete
@@ -1713,7 +1712,7 @@ handlers['close-budget'] = async function() {
return 'ok';
};
-handlers['delete-budget'] = async function({ id, cloudFileId }) {
+handlers['delete-budget'] = async function ({ id, cloudFileId }) {
// If it's a cloud file, you can delete it from the server by
// passing its cloud id
if (cloudFileId && !process.env.IS_BETA) {
@@ -1729,7 +1728,7 @@ handlers['delete-budget'] = async function({ id, cloudFileId }) {
return 'ok';
};
-handlers['create-budget'] = async function({
+handlers['create-budget'] = async function ({
budgetName,
avoidUpload,
testMode,
@@ -1790,12 +1789,12 @@ handlers['create-budget'] = async function({
return {};
};
-handlers['set-tutorial-seen'] = async function() {
+handlers['set-tutorial-seen'] = async function () {
await asyncStorage.setItem('seen-tutorial', 'true');
return 'ok';
};
-handlers['import-budget'] = async function({ filepath, type }) {
+handlers['import-budget'] = async function ({ filepath, type }) {
try {
if (!(await fs.exists(filepath))) {
throw new Error(`File not found at the provided path: ${filepath}`);
@@ -1877,7 +1876,7 @@ handlers['import-budget'] = async function({ filepath, type }) {
return {};
};
-handlers['export-budget'] = async function() {
+handlers['export-budget'] = async function () {
return await cloudStorage.exportBuffer();
};
@@ -2003,7 +2002,7 @@ async function loadBudget(id, appVersion, { showUpdate } = {}) {
return {};
}
-handlers['get-upgrade-notifications'] = async function() {
+handlers['get-upgrade-notifications'] = async function () {
let { id } = prefs.getPrefs();
if (id === TEST_BUDGET_ID || id === DEMO_BUDGET_ID) {
return [];
@@ -2022,12 +2021,12 @@ handlers['get-upgrade-notifications'] = async function() {
return unseen;
};
-handlers['seen-upgrade-notification'] = async function({ type }) {
+handlers['seen-upgrade-notification'] = async function ({ type }) {
let key = `notifications.${type}`;
prefs.savePrefs({ [key]: true });
};
-handlers['upload-file-web'] = async function({ filename, contents }) {
+handlers['upload-file-web'] = async function ({ filename, contents }) {
if (!Platform.isWeb) {
return null;
}
@@ -2036,19 +2035,19 @@ handlers['upload-file-web'] = async function({ filename, contents }) {
return 'ok';
};
-handlers['backups-get'] = async function({ id }) {
+handlers['backups-get'] = async function ({ id }) {
return getAvailableBackups(id);
};
-handlers['backup-load'] = async function({ id, backupId }) {
+handlers['backup-load'] = async function ({ id, backupId }) {
await loadBackup(id, backupId);
};
-handlers['backup-make'] = async function({ id }) {
+handlers['backup-make'] = async function ({ id }) {
await makeBackup(id);
};
-handlers['get-last-opened-backup'] = async function() {
+handlers['get-last-opened-backup'] = async function () {
const id = await asyncStorage.getItem('lastBudget');
if (id && id !== '') {
const budgetDir = fs.getBudgetDir(id);
@@ -2062,7 +2061,7 @@ handlers['get-last-opened-backup'] = async function() {
return null;
};
-handlers['app-focused'] = async function() {
+handlers['app-focused'] = async function () {
if (prefs.getPrefs() && prefs.getPrefs().id) {
// First we sync
fullSync();
diff --git a/packages/loot-core/src/server/schedules/app.js b/packages/loot-core/src/server/schedules/app.js
index 0adc795a21..273152bba2 100644
--- a/packages/loot-core/src/server/schedules/app.js
+++ b/packages/loot-core/src/server/schedules/app.js
@@ -95,18 +95,14 @@ export async function getRuleForSchedule(id) {
}
let { data: ruleId } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .calculate('rule')
+ q('schedules').filter({ id }).calculate('rule')
);
return getRules().find(rule => rule.id === ruleId);
}
export async function fixRuleForSchedule(id) {
let { data: ruleId } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .calculate('rule')
+ q('schedules').filter({ id }).calculate('rule')
);
if (ruleId) {
@@ -141,9 +137,7 @@ export async function setNextDate({ id, start, conditions, reset }) {
let { date: dateCond } = extractScheduleConds(conditions);
let { data: nextDate } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .calculate('next_date')
+ q('schedules').filter({ id }).calculate('next_date')
);
// Only do this if a date condition exists
@@ -293,9 +287,7 @@ export async function updateSchedule({ schedule, conditions, resetNextDate }) {
export async function deleteSchedule({ id }) {
let { data: ruleId } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .calculate('rule')
+ q('schedules').filter({ id }).calculate('rule')
);
await batchMessages(async () => {
@@ -393,11 +385,7 @@ function onApplySync(oldValues, newValues) {
// posts transactions
async function postTransactionForSchedule({ id }) {
- let { data } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .select('*')
- );
+ let { data } = await aqlQuery(q('schedules').filter({ id }).select('*'));
let schedule = data[0];
if (schedule == null || schedule._account == null) {
return;
diff --git a/packages/loot-core/src/server/schedules/app.test.js b/packages/loot-core/src/server/schedules/app.test.js
index b8864e77c8..35860c3079 100644
--- a/packages/loot-core/src/server/schedules/app.test.js
+++ b/packages/loot-core/src/server/schedules/app.test.js
@@ -103,11 +103,7 @@ describe('schedule app', () => {
let {
data: [row]
- } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .select('*')
- );
+ } = await aqlQuery(q('schedules').filter({ id }).select('*'));
expect(row).toBeTruthy();
expect(row.rule).toBeTruthy();
@@ -140,9 +136,7 @@ describe('schedule app', () => {
});
let res = await aqlQuery(
- q('schedules')
- .filter({ id })
- .select(['next_date', 'posts_transaction'])
+ q('schedules').filter({ id }).select(['next_date', 'posts_transaction'])
);
let row = res.data[0];
@@ -170,9 +164,7 @@ describe('schedule app', () => {
});
res = await aqlQuery(
- q('schedules')
- .filter({ id })
- .select(['next_date', 'posts_transaction'])
+ q('schedules').filter({ id }).select(['next_date', 'posts_transaction'])
);
row = res.data[0];
@@ -226,9 +218,7 @@ describe('schedule app', () => {
});
let { data: ruleId } = await aqlQuery(
- q('schedules')
- .filter({ id })
- .calculate('rule')
+ q('schedules').filter({ id }).calculate('rule')
);
// Manually update the rule
@@ -251,9 +241,7 @@ describe('schedule app', () => {
});
let res = await aqlQuery(
- q('schedules')
- .filter({ id })
- .select(['next_date'])
+ q('schedules').filter({ id }).select(['next_date'])
);
let row = res.data[0];
@@ -262,11 +250,7 @@ describe('schedule app', () => {
MockDate.set(new Date(2021, 4, 17));
await setNextDate({ id });
- res = await aqlQuery(
- q('schedules')
- .filter({ id })
- .select(['next_date'])
- );
+ res = await aqlQuery(q('schedules').filter({ id }).select(['next_date']));
row = res.data[0];
expect(row.next_date).toBe('2021-05-18');
diff --git a/packages/loot-core/src/server/schedules/find-schedules.js b/packages/loot-core/src/server/schedules/find-schedules.js
index 679870e16d..497a9efd67 100644
--- a/packages/loot-core/src/server/schedules/find-schedules.js
+++ b/packages/loot-core/src/server/schedules/find-schedules.js
@@ -304,9 +304,7 @@ async function findStartDate(schedule) {
}
let { data } = await aqlQuery(
- q('transactions')
- .filter({ $and: filters })
- .select('*')
+ q('transactions').filter({ $and: filters }).select('*')
);
if (data.length === 0) {
@@ -340,9 +338,7 @@ export async function findSchedules() {
// and find the best one...
let { data: accounts } = await aqlQuery(
- q('accounts')
- .filter({ closed: false })
- .select('*')
+ q('accounts').filter({ closed: false }).select('*')
);
let allSchedules = [];
diff --git a/packages/loot-core/src/server/spreadsheet/graph-data-structure.js b/packages/loot-core/src/server/spreadsheet/graph-data-structure.js
index 2f68b52b09..f6fb66e677 100644
--- a/packages/loot-core/src/server/spreadsheet/graph-data-structure.js
+++ b/packages/loot-core/src/server/spreadsheet/graph-data-structure.js
@@ -104,7 +104,7 @@ function Graph(serialized) {
function generateDOT() {
let edgeStrings = [];
- edges.forEach(function(adj, edge) {
+ edges.forEach(function (adj, edge) {
if (adj.length !== 0) {
edgeStrings.push(`${edge} -> {${adj.join(',')}}`);
}
diff --git a/packages/loot-core/src/server/spreadsheet/sqlinterp.js b/packages/loot-core/src/server/spreadsheet/sqlinterp.js
index e295f1d17b..623022df6b 100644
--- a/packages/loot-core/src/server/spreadsheet/sqlinterp.js
+++ b/packages/loot-core/src/server/spreadsheet/sqlinterp.js
@@ -21,10 +21,10 @@ function bind(args, func) {
}
const builtinFuncs = {
- concat: function(str1, str2) {
+ concat: function (str1, str2) {
return str1 + str2;
},
- date: function(str) {
+ date: function (str) {
return dateFns.parseISO(str);
}
};
diff --git a/packages/loot-core/src/server/spreadsheet/tests/graph.js b/packages/loot-core/src/server/spreadsheet/tests/graph.js
index c938e09b2e..d097d9fbb8 100644
--- a/packages/loot-core/src/server/spreadsheet/tests/graph.js
+++ b/packages/loot-core/src/server/spreadsheet/tests/graph.js
@@ -5,9 +5,9 @@ var assert = require('assert');
// var Graph = require("graph-data-structure");
var Graph = require('../data-compute/graph-data-structure');
-describe('Graph', function() {
- describe('Data structure', function() {
- it('Should add nodes and list them.', function() {
+describe('Graph', function () {
+ describe('Data structure', function () {
+ it('Should add nodes and list them.', function () {
var graph = Graph();
graph.addNode('a');
graph.addNode('b');
@@ -16,16 +16,14 @@ describe('Graph', function() {
assert(contains(graph.nodes(), 'b'));
});
- it('Should chain addNode.', function() {
- var graph = Graph()
- .addNode('a')
- .addNode('b');
+ it('Should chain addNode.', function () {
+ var graph = Graph().addNode('a').addNode('b');
assert.equal(graph.nodes().length, 2);
assert(contains(graph.nodes(), 'a'));
assert(contains(graph.nodes(), 'b'));
});
- it('Should remove nodes.', function() {
+ it('Should remove nodes.', function () {
var graph = Graph();
graph.addNode('a');
graph.addNode('b');
@@ -34,7 +32,7 @@ describe('Graph', function() {
assert.equal(graph.nodes().length, 0);
});
- it('Should chain removeNode.', function() {
+ it('Should chain removeNode.', function () {
var graph = Graph()
.addNode('a')
.addNode('b')
@@ -43,7 +41,7 @@ describe('Graph', function() {
assert.equal(graph.nodes().length, 0);
});
- it('Should add edges and query for adjacent nodes.', function() {
+ it('Should add edges and query for adjacent nodes.', function () {
var graph = Graph();
graph.addNode('a');
graph.addNode('b');
@@ -52,7 +50,7 @@ describe('Graph', function() {
assert.equal(graph.adjacent('a')[0], 'b');
});
- it('Should implicitly add nodes when edges are added.', function() {
+ it('Should implicitly add nodes when edges are added.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
assert.equal(graph.adjacent('a').length, 1);
@@ -62,27 +60,25 @@ describe('Graph', function() {
assert(contains(graph.nodes(), 'b'));
});
- it('Should chain addEdge.', function() {
+ it('Should chain addEdge.', function () {
var graph = Graph().addEdge('a', 'b');
assert.equal(graph.adjacent('a').length, 1);
assert.equal(graph.adjacent('a')[0], 'b');
});
- it('Should remove edges.', function() {
+ it('Should remove edges.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
graph.removeEdge('a', 'b');
assert.equal(graph.adjacent('a').length, 0);
});
- it('Should chain removeEdge.', function() {
- var graph = Graph()
- .addEdge('a', 'b')
- .removeEdge('a', 'b');
+ it('Should chain removeEdge.', function () {
+ var graph = Graph().addEdge('a', 'b').removeEdge('a', 'b');
assert.equal(graph.adjacent('a').length, 0);
});
- it('Should not remove nodes when edges are removed.', function() {
+ it('Should not remove nodes when edges are removed.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
graph.removeEdge('a', 'b');
@@ -91,21 +87,21 @@ describe('Graph', function() {
assert(contains(graph.nodes(), 'b'));
});
- it('Should remove outgoing edges when a node is removed.', function() {
+ it('Should remove outgoing edges when a node is removed.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
graph.removeNode('a');
assert.equal(graph.adjacent('a').length, 0);
});
- it('Should remove incoming edges when a node is removed.', function() {
+ it('Should remove incoming edges when a node is removed.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
graph.removeNode('b');
assert.equal(graph.adjacent('a').length, 0);
});
- it('Should compute indegree.', function() {
+ it('Should compute indegree.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
assert.equal(graph.indegree('a'), 0);
@@ -115,7 +111,7 @@ describe('Graph', function() {
assert.equal(graph.indegree('b'), 2);
});
- it('Should compute outdegree.', function() {
+ it('Should compute outdegree.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
assert.equal(graph.outdegree('a'), 1);
@@ -126,9 +122,9 @@ describe('Graph', function() {
});
});
- describe('Algorithms', function() {
+ describe('Algorithms', function () {
// This example is from Cormen et al. "Introduction to Algorithms" page 550
- it('Should compute topological sort.', function() {
+ it('Should compute topological sort.', function () {
var graph = Graph();
// Shoes depend on socks.
@@ -155,7 +151,7 @@ describe('Graph', function() {
assert.equal(sorted.length, 8);
});
- it('Should compute topological sort, excluding source nodes.', function() {
+ it('Should compute topological sort, excluding source nodes.', function () {
var graph = Graph();
graph.addEdge('a', 'b');
graph.addEdge('b', 'c');
@@ -165,7 +161,7 @@ describe('Graph', function() {
assert.equal(sorted[1], 'c');
});
- it('Should compute topological sort tricky case.', function() {
+ it('Should compute topological sort tricky case.', function () {
var graph = Graph(); // a
// / \
graph.addEdge('a', 'b'); // b |
@@ -187,18 +183,15 @@ describe('Graph', function() {
assert(comesBefore(sorted, 'd', 'e'));
});
- it('Should exclude source nodes with a cycle.', function() {
- var graph = Graph()
- .addEdge('a', 'b')
- .addEdge('b', 'c')
- .addEdge('c', 'a');
+ it('Should exclude source nodes with a cycle.', function () {
+ var graph = Graph().addEdge('a', 'b').addEdge('b', 'c').addEdge('c', 'a');
var sorted = graph.topologicalSort(['a'], false);
assert.equal(sorted.length, 2);
assert.equal(sorted[0], 'b');
assert.equal(sorted[1], 'c');
});
- it('Should exclude source nodes with multiple cycles.', function() {
+ it('Should exclude source nodes with multiple cycles.', function () {
var graph = Graph()
.addEdge('a', 'b')
.addEdge('b', 'a')
@@ -214,32 +207,32 @@ describe('Graph', function() {
});
});
- describe('Edge cases and error handling', function() {
- it('Should return empty array of adjacent nodes for unknown nodes.', function() {
+ describe('Edge cases and error handling', function () {
+ it('Should return empty array of adjacent nodes for unknown nodes.', function () {
var graph = Graph();
assert.equal(graph.adjacent('a').length, 0);
assert.equal(graph.nodes(), 0);
});
- it('Should do nothing if removing an edge that does not exist.', function() {
- assert.doesNotThrow(function() {
+ it('Should do nothing if removing an edge that does not exist.', function () {
+ assert.doesNotThrow(function () {
var graph = Graph();
graph.removeEdge('a', 'b');
});
});
- it('Should return indegree of 0 for unknown nodes.', function() {
+ it('Should return indegree of 0 for unknown nodes.', function () {
var graph = Graph();
assert.equal(graph.indegree('z'), 0);
});
- it('Should return outdegree of 0 for unknown nodes.', function() {
+ it('Should return outdegree of 0 for unknown nodes.', function () {
var graph = Graph();
assert.equal(graph.outdegree('z'), 0);
});
});
- describe('Serialization', function() {
+ describe('Serialization', function () {
var serialized;
function checkSerialized(graph) {
@@ -256,26 +249,24 @@ describe('Graph', function() {
assert.equal(graph.links[1].target, 'c');
}
- it('Should serialize a graph.', function() {
- var graph = Graph()
- .addEdge('a', 'b')
- .addEdge('b', 'c');
+ it('Should serialize a graph.', function () {
+ var graph = Graph().addEdge('a', 'b').addEdge('b', 'c');
serialized = graph.serialize();
checkSerialized(serialized);
});
- it('Should deserialize a graph.', function() {
+ it('Should deserialize a graph.', function () {
var graph = Graph();
graph.deserialize(serialized);
checkSerialized(graph.serialize());
});
- it('Should chain deserialize a graph.', function() {
+ it('Should chain deserialize a graph.', function () {
var graph = Graph().deserialize(serialized);
checkSerialized(graph.serialize());
});
- it('Should deserialize a graph passed to constructor.', function() {
+ it('Should deserialize a graph passed to constructor.', function () {
var graph = Graph(serialized);
checkSerialized(graph.serialize());
});
@@ -284,7 +275,7 @@ describe('Graph', function() {
function contains(arr, item) {
return (
- arr.filter(function(d) {
+ arr.filter(function (d) {
return d === item;
}).length > 0
);
@@ -292,7 +283,7 @@ function contains(arr, item) {
function comesBefore(arr, a, b) {
var aIndex, bIndex;
- arr.forEach(function(d, i) {
+ arr.forEach(function (d, i) {
if (d === a) {
aIndex = i;
}
diff --git a/packages/loot-core/src/server/spreadsheet/usage.js b/packages/loot-core/src/server/spreadsheet/usage.js
index cbcd85fb3e..dc95dee07f 100644
--- a/packages/loot-core/src/server/spreadsheet/usage.js
+++ b/packages/loot-core/src/server/spreadsheet/usage.js
@@ -43,7 +43,7 @@ const sheet = new Spreadsheet({
},
run: sql => {
return new Promise(resolve => {
- db.all(sql, function(err, rows) {
+ db.all(sql, function (err, rows) {
if (err) {
throw new Error(err);
}
@@ -55,7 +55,7 @@ const sheet = new Spreadsheet({
}
});
-db.on('preupdate', function(type, dbname, table, old, _new, oldId, newId) {
+db.on('preupdate', function (type, dbname, table, old, _new, oldId, newId) {
sheet.resolve().then(() => {
const start = Date.now();
sheet.startTransaction();
@@ -77,7 +77,7 @@ function insertRow() {
db.run(
'INSERT INTO transactions (acct, category, amount, description, date)' +
' VALUES (3, 2, 944, "shirt", 1456808400000);',
- function() {
+ function () {
console.log('[insertRow] fired', Date.now() - start);
const t = Math.random() * 100;
console.log('[insertRow] waiting', t);
diff --git a/packages/loot-core/src/server/sync/index.js b/packages/loot-core/src/server/sync/index.js
index 5f51b1c618..e08d57f095 100644
--- a/packages/loot-core/src/server/sync/index.js
+++ b/packages/loot-core/src/server/sync/index.js
@@ -528,7 +528,7 @@ export async function initialFullSync() {
}
}
-export const fullSync = once(async function() {
+export const fullSync = once(async function () {
app.events.emit('sync', { type: 'start' });
let messages;
diff --git a/packages/loot-design/package.json b/packages/loot-design/package.json
index 7a6ad51d10..764b3b900a 100644
--- a/packages/loot-design/package.json
+++ b/packages/loot-design/package.json
@@ -24,7 +24,6 @@
"node-noop": "1.0.0",
"npm-run-all": "^4.1.3",
"polished": "^1.8.1",
- "prettier": "^1.14.2",
"prop-types": "15.6.0",
"react": "16.13.1",
"react-dnd-html5-backend": "^10.0.2",
diff --git a/packages/loot-design/src/components/Autocomplete.js b/packages/loot-design/src/components/Autocomplete.js
index 52c17594e3..00cbaf39d7 100644
--- a/packages/loot-design/src/components/Autocomplete.js
+++ b/packages/loot-design/src/components/Autocomplete.js
@@ -107,9 +107,7 @@ function componentWillReceiveProps(bag, nextProps) {
}
export function defaultFilterSuggestion(suggestion, value) {
- return getItemName(suggestion)
- .toLowerCase()
- .includes(value.toLowerCase());
+ return getItemName(suggestion).toLowerCase().includes(value.toLowerCase());
}
export function defaultFilterSuggestions(suggestions, value) {
diff --git a/packages/loot-design/src/components/FixedSizeList.js b/packages/loot-design/src/components/FixedSizeList.js
index 44732a41db..eaaa74719d 100644
--- a/packages/loot-design/src/components/FixedSizeList.js
+++ b/packages/loot-design/src/components/FixedSizeList.js
@@ -392,11 +392,8 @@ export class FixedSizeList extends React.PureComponent {
}
if (typeof this.props.onScroll === 'function') {
- const {
- scrollDirection,
- scrollOffset,
- scrollUpdateWasRequested
- } = this.state;
+ const { scrollDirection, scrollOffset, scrollUpdateWasRequested } =
+ this.state;
this._callOnScroll(
scrollDirection,
scrollOffset,
diff --git a/packages/loot-design/src/components/NotesButton.js b/packages/loot-design/src/components/NotesButton.js
index 9f077673c1..915ee71143 100644
--- a/packages/loot-design/src/components/NotesButton.js
+++ b/packages/loot-design/src/components/NotesButton.js
@@ -49,13 +49,7 @@ export default function NotesButton({
}) {
let tooltip = useTooltip();
let { data } = useLiveQuery(
- useMemo(
- () =>
- q('notes')
- .filter({ id })
- .select('*'),
- [id]
- )
+ useMemo(() => q('notes').filter({ id }).select('*'), [id])
);
let note = data && data.length > 0 ? data[0].note : null;
let hasNotes = note && note !== '';
diff --git a/packages/loot-design/src/components/budget/index.usage.js b/packages/loot-design/src/components/budget/index.usage.js
index 5ed2c40c85..8fd3f46984 100644
--- a/packages/loot-design/src/components/budget/index.usage.js
+++ b/packages/loot-design/src/components/budget/index.usage.js
@@ -125,12 +125,8 @@ export class LiveBudgetPage extends React.Component {
render() {
let { maxMonths } = this.props;
- let {
- startMonth,
- categoryGroups,
- collapsed,
- newCategoryForGroup
- } = this.state;
+ let { startMonth, categoryGroups, collapsed, newCategoryForGroup } =
+ this.state;
let rolloverComponents = {
SummaryComponent: rollover.BudgetSummary,
diff --git a/packages/loot-design/src/components/icons.usage.js b/packages/loot-design/src/components/icons.usage.js
index f7f313af08..76f69cf09d 100644
--- a/packages/loot-design/src/components/icons.usage.js
+++ b/packages/loot-design/src/components/icons.usage.js
@@ -5,7 +5,7 @@ import { View, Button } from './common';
const context = require.context('../svg/v1', false, /\.web.js$/);
const modules = {};
-context.keys().forEach(function(key) {
+context.keys().forEach(function (key) {
var module = context(key);
modules[key] = module;
});
diff --git a/packages/loot-design/src/components/modals/ImportTransactions.js b/packages/loot-design/src/components/modals/ImportTransactions.js
index 89a97231ff..9bd419aa73 100644
--- a/packages/loot-design/src/components/modals/ImportTransactions.js
+++ b/packages/loot-design/src/components/modals/ImportTransactions.js
@@ -652,8 +652,9 @@ export function ImportTransactions({
? trans.date
: parseDate(trans.date, parseDateFormat);
if (date == null) {
- errorMessage = `Unable to parse date ${trans.date ||
- '(empty)'} with given date format`;
+ errorMessage = `Unable to parse date ${
+ trans.date || '(empty)'
+ } with given date format`;
break;
}
diff --git a/packages/loot-design/src/components/modals/ImportTransactions.test.js b/packages/loot-design/src/components/modals/ImportTransactions.test.js
index 1c5b35f52d..bb502ae4a2 100644
--- a/packages/loot-design/src/components/modals/ImportTransactions.test.js
+++ b/packages/loot-design/src/components/modals/ImportTransactions.test.js
@@ -1,8 +1,8 @@
import { parseDate } from './ImportTransactions';
-describe('Import transactions', function() {
- describe('date parsing', function() {
- it('should not parse', function() {
+describe('Import transactions', function () {
+ describe('date parsing', function () {
+ it('should not parse', function () {
const invalidInputs = [
{ str: '', order: 'yyyy mm dd' },
{ str: null, order: 'yyyy mm dd' },
@@ -35,7 +35,7 @@ describe('Import transactions', function() {
}
});
- it('should parse', function() {
+ it('should parse', function () {
const validInputs = [
{
order: 'yyyy mm dd',
diff --git a/packages/loot-design/src/components/table.usage.js b/packages/loot-design/src/components/table.usage.js
index c7bc5a0978..afe36bf233 100644
--- a/packages/loot-design/src/components/table.usage.js
+++ b/packages/loot-design/src/components/table.usage.js
@@ -92,12 +92,8 @@ export default () => (
let [items, setItems] = useState(() => {
return [...people];
});
- let {
- onEdit,
- editingId,
- focusedField,
- getNavigatorProps
- } = useTableNavigator(items, getFields);
+ let { onEdit, editingId, focusedField, getNavigatorProps } =
+ useTableNavigator(items, getFields);
function onUpdate(id, name, value) {
let idx = items.findIndex(item => item.id === id);
diff --git a/packages/loot-design/src/guide/document.js b/packages/loot-design/src/guide/document.js
index 0ac8aa08ad..7614d2ac91 100644
--- a/packages/loot-design/src/guide/document.js
+++ b/packages/loot-design/src/guide/document.js
@@ -94,23 +94,23 @@ export default async function render(rootNode) {
var context = require.context('../components', true, /\.usage.js$/);
-context.keys().forEach(function(key) {
+context.keys().forEach(function (key) {
var module = context(key);
modules[key] = module;
});
if (module.hot) {
- module.hot.accept(context.id, function() {
+ module.hot.accept(context.id, function () {
var reloadedContext = require.context('../components', true, /\.usage.js$/);
var changedModules = reloadedContext
.keys()
- .map(function(key) {
+ .map(function (key) {
return [key, reloadedContext(key)];
})
- .filter(function(reloadedModule) {
+ .filter(function (reloadedModule) {
return modules[reloadedModule[0]] !== reloadedModule[1];
});
- changedModules.forEach(function(module) {
+ changedModules.forEach(function (module) {
modules[module[0]] = module[1];
reloadUsage(module[0], module[1]);
});
diff --git a/packages/loot-design/src/setupTests.js b/packages/loot-design/src/setupTests.js
index 396239dabe..90b848eb2e 100644
--- a/packages/loot-design/src/setupTests.js
+++ b/packages/loot-design/src/setupTests.js
@@ -8,8 +8,11 @@ const uuid = require('loot-core/src/platform/uuid');
global.IS_TESTING = true;
global.Actual = {};
-jest.mock('react-virtualized-auto-sizer', () => ({ children }) =>
- children({ height: 1000, width: 600 })
+jest.mock(
+ 'react-virtualized-auto-sizer',
+ () =>
+ ({ children }) =>
+ children({ height: 1000, width: 600 })
);
// Why 2? There were already tests written assuming a specific
@@ -22,11 +25,11 @@ Math.random = function random() {
global.Date.now = () => 123456789;
-uuid.v4 = function() {
+uuid.v4 = function () {
return Promise.resolve('testing-uuid-' + Math.floor(Math.random() * 1000000));
};
-uuid.v4Sync = function() {
+uuid.v4Sync = function () {
return 'testing-uuid-' + Math.floor(Math.random() * 1000000);
};
diff --git a/yarn.lock b/yarn.lock
index 7c5bc462c1..d984571572 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5310,7 +5310,7 @@ __metadata:
husky: ^3.0.4
npm-run-all: ^4.1.3
patch-package: ^6.1.2
- prettier: ^1.18.1
+ prettier: 2.8.2
pretty-quick: ^1.11.1
react-refresh: ^0.14.0
shelljs: ^0.8.2
@@ -15502,7 +15502,6 @@ __metadata:
node-libofx: "*"
npm-run-all: ^4.1.3
perf-deets: ^1.0.15
- prettier: ^1.19.1
regenerator-runtime: ^0.13.7
sanitize-filename: ^1.6.1
search-query-parser: ^1.3.0
@@ -15548,7 +15547,6 @@ __metadata:
npm-run-all: ^4.1.3
pikaday: 1.8.0
polished: ^1.8.1
- prettier: ^1.14.2
prop-types: 15.6.0
react: 16.13.1
react-dnd: ^10.0.2
@@ -19124,7 +19122,16 @@ __metadata:
languageName: node
linkType: hard
-"prettier@npm:^1.14.2, prettier@npm:^1.18.1, prettier@npm:^1.19.1":
+"prettier@npm:2.8.2":
+ version: 2.8.2
+ resolution: "prettier@npm:2.8.2"
+ bin:
+ prettier: bin-prettier.js
+ checksum: 740c56c2128d587d656ea1dde9bc9c3503dfc94db4f3ac387259215eeb2e216680bdad9d18a0c9feecc6b42cfa188d6fa777df4c36c1d00cedd4199074fbfbd2
+ languageName: node
+ linkType: hard
+
+"prettier@npm:^1.14.2":
version: 1.19.1
resolution: "prettier@npm:1.19.1"
bin: