Skip to content

A local-first personal finance app

Re-enable linting on the server (#4363)

Matt Fiddamanf1a4c888b219
diff --git a/eslint.config.mjs b/eslint.config.mjs
index c4ed9c4b18..7f065e79b8 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -113,7 +113,6 @@ export default [
'packages/loot-core/**/node_modules/*',
'packages/loot-core/**/lib-dist/*',
'packages/loot-core/**/proto/*',
- 'packages/sync-server',
'.yarn/*',
'.github/*',
],
@@ -818,6 +817,7 @@ export default [
'**/*.test.ts',
'**/*.test.jsx',
'**/*.test.tsx',
+ '**/*.spec.js',
],
rules: {
@@ -835,4 +835,21 @@ export default [
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
},
},
+ {
+ files: ['packages/sync-server/**/*'],
+ // TODO: fix the issues in these files
+ rules: {
+ 'import/extensions': 'off',
+ 'rulesdir/typography': 'off',
+ },
+ },
+ {
+ files: ['packages/sync-server/src/app-gocardless/banks/*.js'],
+ rules: {
+ 'import/no-anonymous-default-export': 'off',
+ 'import/no-default-export': 'off',
+ // can be re-enabled after https://github.com/actualbudget/actual/pull/4253
+ '@typescript-eslint/no-unused-vars': 'off',
+ },
+ },
];
diff --git a/packages/sync-server/app.js b/packages/sync-server/app.js
index e98462498c..62f5d1d7fa 100644
--- a/packages/sync-server/app.js
+++ b/packages/sync-server/app.js
@@ -1,9 +1,9 @@
-import runMigrations from './src/migrations.js';
+import { run as runMigrations } from './src/migrations.js';
runMigrations()
.then(() => {
//import the app here becasue initial migrations need to be run first - they are dependencies of the app.js
- import('./src/app.js').then(app => app.default()); // run the app
+ import('./src/app.js').then(app => app.run()); // run the app
})
.catch(err => {
console.log('Error starting app:', err);
diff --git a/packages/sync-server/jest.global-setup.js b/packages/sync-server/jest.global-setup.js
index 524054dd5d..e518f7d8c4 100644
--- a/packages/sync-server/jest.global-setup.js
+++ b/packages/sync-server/jest.global-setup.js
@@ -1,5 +1,5 @@
-import getAccountDb from './src/account-db.js';
-import runMigrations from './src/migrations.js';
+import { getAccountDb } from './src/account-db.js';
+import { run as runMigrations } from './src/migrations.js';
const GENERIC_ADMIN_ID = 'genericAdmin';
const GENERIC_USER_ID = 'genericUser';
@@ -60,6 +60,7 @@ const setSessionUser = (userId, token = 'valid-token') => {
}
};
+// eslint-disable-next-line import/no-default-export
export default async function setup() {
const NEVER_EXPIRES = -1; // or consider using a far future timestamp
diff --git a/packages/sync-server/jest.global-teardown.js b/packages/sync-server/jest.global-teardown.js
index 4e19fc3854..bb08df663b 100644
--- a/packages/sync-server/jest.global-teardown.js
+++ b/packages/sync-server/jest.global-teardown.js
@@ -1,5 +1,6 @@
-import runMigrations from './src/migrations.js';
+import { run as runMigrations } from './src/migrations.js';
+// eslint-disable-next-line import/no-default-export
export default async function teardown() {
await runMigrations('down');
}
diff --git a/packages/sync-server/migrations/1694360000000-create-folders.js b/packages/sync-server/migrations/1694360000000-create-folders.js
index 00cdea3478..fd5043783e 100644
--- a/packages/sync-server/migrations/1694360000000-create-folders.js
+++ b/packages/sync-server/migrations/1694360000000-create-folders.js
@@ -1,12 +1,12 @@
import fs from 'node:fs/promises';
-import config from '../src/load-config.js';
+import { config } from '../src/load-config.js';
async function ensureExists(path) {
try {
await fs.mkdir(path);
} catch (err) {
- if (err.code == 'EEXIST') {
+ if (err.code === 'EEXIST') {
return null;
}
diff --git a/packages/sync-server/migrations/1694360479680-create-account-db.js b/packages/sync-server/migrations/1694360479680-create-account-db.js
index fd57b79cc8..3c9647174b 100644
--- a/packages/sync-server/migrations/1694360479680-create-account-db.js
+++ b/packages/sync-server/migrations/1694360479680-create-account-db.js
@@ -1,4 +1,4 @@
-import getAccountDb from '../src/account-db.js';
+import { getAccountDb } from '../src/account-db.js';
export const up = async function () {
await getAccountDb().exec(`
diff --git a/packages/sync-server/migrations/1694362247011-create-secret-table.js b/packages/sync-server/migrations/1694362247011-create-secret-table.js
index 2f60a08151..6a85c88150 100644
--- a/packages/sync-server/migrations/1694362247011-create-secret-table.js
+++ b/packages/sync-server/migrations/1694362247011-create-secret-table.js
@@ -1,4 +1,4 @@
-import getAccountDb from '../src/account-db.js';
+import { getAccountDb } from '../src/account-db.js';
export const up = async function () {
await getAccountDb().exec(`
diff --git a/packages/sync-server/migrations/1702667624000-rename-nordigen-secrets.js b/packages/sync-server/migrations/1702667624000-rename-nordigen-secrets.js
index 5dcaff7357..81b7a1e387 100644
--- a/packages/sync-server/migrations/1702667624000-rename-nordigen-secrets.js
+++ b/packages/sync-server/migrations/1702667624000-rename-nordigen-secrets.js
@@ -1,4 +1,4 @@
-import getAccountDb from '../src/account-db.js';
+import { getAccountDb } from '../src/account-db.js';
export const up = async function () {
await getAccountDb().exec(
diff --git a/packages/sync-server/migrations/1718889148000-openid.js b/packages/sync-server/migrations/1718889148000-openid.js
index b170aea05d..607d638099 100644
--- a/packages/sync-server/migrations/1718889148000-openid.js
+++ b/packages/sync-server/migrations/1718889148000-openid.js
@@ -1,4 +1,4 @@
-import getAccountDb from '../src/account-db.js';
+import { getAccountDb } from '../src/account-db.js';
export const up = async function () {
await getAccountDb().exec(
diff --git a/packages/sync-server/migrations/1719409568000-multiuser.js b/packages/sync-server/migrations/1719409568000-multiuser.js
index 59d8e78c71..a5c83aa098 100644
--- a/packages/sync-server/migrations/1719409568000-multiuser.js
+++ b/packages/sync-server/migrations/1719409568000-multiuser.js
@@ -1,6 +1,6 @@
-import * as uuid from 'uuid';
+import { v4 as uuidv4 } from 'uuid';
-import getAccountDb from '../src/account-db.js';
+import { getAccountDb } from '../src/account-db.js';
export const up = async function () {
const accountDb = getAccountDb();
@@ -10,7 +10,7 @@ export const up = async function () {
`
CREATE TABLE users
(id TEXT PRIMARY KEY,
- user_name TEXT,
+ user_name TEXT,
display_name TEXT,
role TEXT,
enabled INTEGER NOT NULL DEFAULT 1,
@@ -22,11 +22,11 @@ export const up = async function () {
PRIMARY KEY (user_id, file_id),
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (file_id) REFERENCES files(id)
- );
+ );
ALTER TABLE files
ADD COLUMN owner TEXT;
-
+
ALTER TABLE sessions
ADD COLUMN expires_at INTEGER;
@@ -38,7 +38,7 @@ export const up = async function () {
`,
);
- const userId = uuid.v4();
+ const userId = uuidv4();
accountDb.mutate(
'INSERT INTO users (id, user_name, display_name, enabled, owner, role) VALUES (?, ?, ?, 1, 1, ?)',
[userId, '', '', 'ADMIN'],
@@ -66,7 +66,7 @@ export const down = async function () {
SELECT token FROM sessions;
DROP TABLE sessions;
-
+
ALTER TABLE sessions_backup RENAME TO sessions;
CREATE TABLE files_backup (
diff --git a/packages/sync-server/src/account-db.js b/packages/sync-server/src/account-db.js
index 0ea069a606..7d6fa1f27d 100644
--- a/packages/sync-server/src/account-db.js
+++ b/packages/sync-server/src/account-db.js
@@ -4,12 +4,12 @@ import * as bcrypt from 'bcrypt';
import { bootstrapOpenId } from './accounts/openid.js';
import { bootstrapPassword, loginWithPassword } from './accounts/password.js';
-import openDatabase from './db.js';
-import config from './load-config.js';
+import { openDatabase } from './db.js';
+import { config } from './load-config.js';
let _accountDb;
-export default function getAccountDb() {
+export function getAccountDb() {
if (_accountDb === undefined) {
const dbPath = join(config.serverFiles, 'account.sqlite');
_accountDb = openDatabase(dbPath);
@@ -179,10 +179,10 @@ export async function disableOpenID(loginSettings) {
accountDb.transaction(() => {
accountDb.mutate('DELETE FROM sessions');
accountDb.mutate(
- `DELETE FROM user_access
+ `DELETE FROM user_access
WHERE user_access.user_id IN (
- SELECT users.id
- FROM users
+ SELECT users.id
+ FROM users
WHERE users.user_name <> ?
);`,
[''],
diff --git a/packages/sync-server/src/accounts/openid.js b/packages/sync-server/src/accounts/openid.js
index d989966795..508e85d00c 100644
--- a/packages/sync-server/src/accounts/openid.js
+++ b/packages/sync-server/src/accounts/openid.js
@@ -1,8 +1,8 @@
import { generators, Issuer } from 'openid-client';
-import * as uuid from 'uuid';
+import { v4 as uuidv4 } from 'uuid';
-import getAccountDb, { clearExpiredSessions } from '../account-db.js';
-import finalConfig from '../load-config.js';
+import { clearExpiredSessions, getAccountDb } from '../account-db.js';
+import { config as finalConfig } from '../load-config.js';
import {
getUserByUsername,
transferAllFilesFromUser,
@@ -207,7 +207,7 @@ export async function loginWithOpenIdFinalize(body) {
[''],
);
if (countUsersWithUserName === 0) {
- userId = uuid.v4();
+ userId = uuidv4();
// Check if user was created by another transaction
const existingUser = accountDb.first(
'SELECT id FROM users WHERE user_name = ?',
@@ -261,7 +261,7 @@ export async function loginWithOpenIdFinalize(body) {
}
}
- const token = uuid.v4();
+ const token = uuidv4();
let expiration;
if (finalConfig.token_expiration === 'openid-provider') {
diff --git a/packages/sync-server/src/accounts/password.js b/packages/sync-server/src/accounts/password.js
index a6fbe869fb..57a0e46e3c 100644
--- a/packages/sync-server/src/accounts/password.js
+++ b/packages/sync-server/src/accounts/password.js
@@ -1,8 +1,8 @@
import * as bcrypt from 'bcrypt';
-import * as uuid from 'uuid';
+import { v4 as uuidv4 } from 'uuid';
-import getAccountDb, { clearExpiredSessions } from '../account-db.js';
-import finalConfig from '../load-config.js';
+import { clearExpiredSessions, getAccountDb } from '../account-db.js';
+import { config } from '../load-config.js';
import { TOKEN_EXPIRATION_NEVER } from '../util/validate-user.js';
function isValidPassword(password) {
@@ -58,14 +58,14 @@ export function loginWithPassword(password) {
['password'],
);
- const token = sessionRow ? sessionRow.token : uuid.v4();
+ const token = sessionRow ? sessionRow.token : uuidv4();
const { totalOfUsers } = accountDb.first(
'SELECT count(*) as totalOfUsers FROM users',
);
let userId = null;
if (totalOfUsers === 0) {
- userId = uuid.v4();
+ userId = uuidv4();
accountDb.mutate(
'INSERT INTO users (id, user_name, display_name, enabled, owner, role) VALUES (?, ?, ?, 1, 1, ?)',
[userId, '', '', 'ADMIN'],
@@ -85,12 +85,11 @@ export function loginWithPassword(password) {
let expiration = TOKEN_EXPIRATION_NEVER;
if (
- finalConfig.token_expiration != 'never' &&
- finalConfig.token_expiration != 'openid-provider' &&
- typeof finalConfig.token_expiration === 'number'
+ config.token_expiration !== 'never' &&
+ config.token_expiration !== 'openid-provider' &&
+ typeof config.token_expiration === 'number'
) {
- expiration =
- Math.floor(Date.now() / 1000) + finalConfig.token_expiration * 60;
+ expiration = Math.floor(Date.now() / 1000) + config.token_expiration * 60;
}
if (!sessionRow) {
diff --git a/packages/sync-server/src/app-account.js b/packages/sync-server/src/app-account.js
index df31c2ee74..8809189013 100644
--- a/packages/sync-server/src/app-account.js
+++ b/packages/sync-server/src/app-account.js
@@ -14,7 +14,7 @@ import {
errorMiddleware,
requestLoggerMiddleware,
} from './util/middlewares.js';
-import validateSession, { validateAuthHeader } from './util/validate-user.js';
+import { validateAuthHeader, validateSession } from './util/validate-user.js';
const app = express();
app.use(express.json());
@@ -66,7 +66,7 @@ app.post('/login', async (req, res) => {
const obfuscated =
'*'.repeat(headerVal.length) || 'No password provided.';
console.debug('HEADER VALUE: ' + obfuscated);
- if (headerVal == '') {
+ if (headerVal === '') {
res.send({ status: 'error', reason: 'invalid-header' });
return;
} else {
diff --git a/packages/sync-server/src/app-admin.js b/packages/sync-server/src/app-admin.js
index 994dbb9659..f12ef11802 100644
--- a/packages/sync-server/src/app-admin.js
+++ b/packages/sync-server/src/app-admin.js
@@ -1,5 +1,5 @@
import express from 'express';
-import * as uuid from 'uuid';
+import { v4 as uuidv4 } from 'uuid';
import { isAdmin } from './account-db.js';
import * as UserService from './services/user-service.js';
@@ -8,7 +8,7 @@ import {
requestLoggerMiddleware,
validateSessionMiddleware,
} from './util/middlewares.js';
-import validateSession from './util/validate-user.js';
+import { validateSession } from './util/validate-user.js';
const app = express();
app.use(express.json());
@@ -78,7 +78,7 @@ app.post('/users', validateSessionMiddleware, async (req, res) => {
return;
}
- const userId = uuid.v4();
+ const userId = uuidv4();
UserService.insertUser(
userId,
userName,
diff --git a/packages/sync-server/src/app-admin.test.js b/packages/sync-server/src/app-admin.test.js
index 95556b1145..796945495c 100644
--- a/packages/sync-server/src/app-admin.test.js
+++ b/packages/sync-server/src/app-admin.test.js
@@ -1,7 +1,7 @@
import request from 'supertest';
import { v4 as uuidv4 } from 'uuid';
-import getAccountDb from './account-db.js';
+import { getAccountDb } from './account-db.js';
import { handlers as app } from './app-admin.js';
const ADMIN_ROLE = 'ADMIN';
diff --git a/packages/sync-server/src/app-gocardless/bank-factory.js b/packages/sync-server/src/app-gocardless/bank-factory.js
index f830bc2287..d0cf32cfb5 100644
--- a/packages/sync-server/src/app-gocardless/bank-factory.js
+++ b/packages/sync-server/src/app-gocardless/bank-factory.js
@@ -24,8 +24,11 @@ async function loadBanks() {
export const banks = await loadBanks();
-export default institutionId =>
- banks.find(b => b.institutionIds.includes(institutionId)) || IntegrationBank;
+export function BankFactory(institutionId) {
+ return (
+ banks.find(b => b.institutionIds.includes(institutionId)) || IntegrationBank
+ );
+}
export const BANKS_WITH_LIMITED_HISTORY = [
'BANCA_AIDEXA_AIDXITMM',
diff --git a/packages/sync-server/src/app-gocardless/banks/easybank_bawaatww.js b/packages/sync-server/src/app-gocardless/banks/easybank_bawaatww.js
index 48523b783f..7becc29b2e 100644
--- a/packages/sync-server/src/app-gocardless/banks/easybank_bawaatww.js
+++ b/packages/sync-server/src/app-gocardless/banks/easybank_bawaatww.js
@@ -17,7 +17,7 @@ export default {
const diff =
+new Date(b.valueDate || b.bookingDate) -
+new Date(a.valueDate || a.bookingDate);
- if (diff != 0) return diff;
+ if (diff !== 0) return diff;
return parseInt(b.transactionId) - parseInt(a.transactionId);
}),
diff --git a/packages/sync-server/src/app-gocardless/banks/hype_hyeeit22.js b/packages/sync-server/src/app-gocardless/banks/hype_hyeeit22.js
index c277620c79..e165a2f51b 100644
--- a/packages/sync-server/src/app-gocardless/banks/hype_hyeeit22.js
+++ b/packages/sync-server/src/app-gocardless/banks/hype_hyeeit22.js
@@ -12,7 +12,7 @@ export default {
/** Online card payments - identified by "crd" transaction code
* always start with PAGAMENTO PRESSO + <payee name>
*/
- if (transaction.proprietaryBankTransactionCode == 'crd') {
+ if (transaction.proprietaryBankTransactionCode === 'crd') {
// remove PAGAMENTO PRESSO and set payee name
transaction.debtorName =
transaction.remittanceInformationUnstructured?.slice(
@@ -25,15 +25,15 @@ export default {
* HAI (INVIATO/RICEVUTO) UN BONIFICO (A/DA) {payee_name} - {payment_info} (bon)
*/
if (
- transaction.proprietaryBankTransactionCode == 'p2p' ||
- transaction.proprietaryBankTransactionCode == 'bon'
+ transaction.proprietaryBankTransactionCode === 'p2p' ||
+ transaction.proprietaryBankTransactionCode === 'bon'
) {
// keep only {payment_info} portion of remittance info
// NOTE: if {payee_name} contains dashes (unlikely / impossible?), this probably gets bugged!
const infoIdx =
transaction.remittanceInformationUnstructured.indexOf(' - ') + 3;
transaction.remittanceInformationUnstructured =
- infoIdx == -1
+ infoIdx === -1
? transaction.remittanceInformationUnstructured
: transaction.remittanceInformationUnstructured.slice(infoIdx).trim();
}
@@ -44,7 +44,7 @@ export default {
* so it groups them in 4bytes bundles
* the code below assumes this is always the case
*/
- if (transaction.proprietaryBankTransactionCode == 'p2p') {
+ if (transaction.proprietaryBankTransactionCode === 'p2p') {
let str = transaction.remittanceInformationUnstructured;
let idx = str.indexOf('\\U');
let start_idx = idx;
@@ -52,7 +52,7 @@ export default {
while (idx !== -1) {
codepoints.push(parseInt(str.slice(idx + 2, idx + 6), 16));
const next_idx = str.indexOf('\\U', idx + 6);
- if (next_idx == idx + 6) {
+ if (next_idx === idx + 6) {
idx = next_idx;
continue;
}
diff --git a/packages/sync-server/src/app-gocardless/services/gocardless-service.js b/packages/sync-server/src/app-gocardless/services/gocardless-service.js
index 8c1a2d765b..cecffabdbb 100644
--- a/packages/sync-server/src/app-gocardless/services/gocardless-service.js
+++ b/packages/sync-server/src/app-gocardless/services/gocardless-service.js
@@ -1,9 +1,9 @@
import jwt from 'jws';
import * as nordigenNode from 'nordigen-node';
-import * as uuid from 'uuid';
+import { v4 as uuidv4 } from 'uuid';
import { SecretName, secretsService } from '../../services/secrets-service.js';
-import BankFactory, { BANKS_WITH_LIMITED_HISTORY } from '../bank-factory.js';
+import { BankFactory, BANKS_WITH_LIMITED_HISTORY } from '../bank-factory.js';
import {
AccessDeniedError,
AccountNotLinkedToRequisition,
@@ -319,7 +319,7 @@ export const goCardlessService = {
response = await client.initSession({
redirectUrl: host + '/gocardless/link',
institutionId,
- referenceId: uuid.v4(),
+ referenceId: uuidv4(),
accessValidForDays: institution.max_access_valid_for_days,
maxHistoricalDays: BANKS_WITH_LIMITED_HISTORY.includes(institutionId)
? Number(institution.transaction_total_days) >= 90
diff --git a/packages/sync-server/src/app-gocardless/tests/bank-factory.spec.js b/packages/sync-server/src/app-gocardless/tests/bank-factory.spec.js
index 6874f35075..4078856ed7 100644
--- a/packages/sync-server/src/app-gocardless/tests/bank-factory.spec.js
+++ b/packages/sync-server/src/app-gocardless/tests/bank-factory.spec.js
@@ -1,4 +1,4 @@
-import BankFactory, { banks } from '../bank-factory.js';
+import { BankFactory, banks } from '../bank-factory.js';
import IntegrationBank from '../banks/integration-bank.js';
describe('BankFactory', () => {
diff --git a/packages/sync-server/src/app-secrets.js b/packages/sync-server/src/app-secrets.js
index c1a57989f0..ee2326a3a9 100644
--- a/packages/sync-server/src/app-secrets.js
+++ b/packages/sync-server/src/app-secrets.js
@@ -1,6 +1,6 @@
import express from 'express';
-import getAccountDb, { isAdmin } from './account-db.js';
+import { getAccountDb, isAdmin } from './account-db.js';
import { secretsService } from './services/secrets-service.js';
import {
requestLoggerMiddleware,
diff --git a/packages/sync-server/src/app-simplefin/app-simplefin.js b/packages/sync-server/src/app-simplefin/app-simplefin.js
index facca196d3..9885a96231 100644
--- a/packages/sync-server/src/app-simplefin/app-simplefin.js
+++ b/packages/sync-server/src/app-simplefin/app-simplefin.js
@@ -77,7 +77,7 @@ app.post(
return;
}
- if (Array.isArray(accountId) != Array.isArray(startDate)) {
+ if (Array.isArray(accountId) !== Array.isArray(startDate)) {
console.log({ accountId, startDate });
throw new Error(
'accountId and startDate must either both be arrays or both be strings',
@@ -205,7 +205,7 @@ function getAccountResponse(results, accountId, startDate) {
let dateToUse = 0;
- if (trans.pending ?? trans.posted == 0) {
+ if (trans.pending ?? trans.posted === 0) {
newTrans.booked = false;
dateToUse = trans.transacted_at;
} else {
diff --git a/packages/sync-server/src/app-sync.js b/packages/sync-server/src/app-sync.js
index 20e3f11485..92a354d4e1 100644
--- a/packages/sync-server/src/app-sync.js
+++ b/packages/sync-server/src/app-sync.js
@@ -3,9 +3,9 @@ import fs from 'node:fs/promises';
import { SyncProtoBuf } from '@actual-app/crdt';
import express from 'express';
-import * as uuid from 'uuid';
+import { v4 as uuidv4 } from 'uuid';
-import getAccountDb from './account-db.js';
+import { getAccountDb } from './account-db.js';
import { FileNotFound } from './app-sync/errors.js';
import {
File,
@@ -239,7 +239,7 @@ app.post('/upload-user-file', async (req, res) => {
if (!currentFile) {
// it's new
- groupId = uuid.v4();
+ groupId = uuidv4();
filesService.set(
new File({
@@ -262,7 +262,7 @@ app.post('/upload-user-file', async (req, res) => {
if (!groupId) {
// sync state was reset, create new group
- groupId = uuid.v4();
+ groupId = uuidv4();
filesService.update(fileId, new FileUpdate({ groupId }));
}
diff --git a/packages/sync-server/src/app-sync.test.js b/packages/sync-server/src/app-sync.test.js
index 248b493da6..cf31da927e 100644
--- a/packages/sync-server/src/app-sync.test.js
+++ b/packages/sync-server/src/app-sync.test.js
@@ -4,7 +4,7 @@ import fs from 'node:fs';
import { SyncProtoBuf } from '@actual-app/crdt';
import request from 'supertest';
-import getAccountDb from './account-db.js';
+import { getAccountDb } from './account-db.js';
import { handlers as app } from './app-sync.js';
import { getPathForUserFile } from './util/paths.js';
diff --git a/packages/sync-server/src/app-sync/services/files-service.js b/packages/sync-server/src/app-sync/services/files-service.js
index a7234de92b..bea40910bf 100644
--- a/packages/sync-server/src/app-sync/services/files-service.js
+++ b/packages/sync-server/src/app-sync/services/files-service.js
@@ -1,4 +1,4 @@
-import getAccountDb, { isAdmin } from '../../account-db.js';
+import { getAccountDb, isAdmin } from '../../account-db.js';
import { FileNotFound, GenericFileError } from '../errors.js';
class FileBase {
@@ -130,7 +130,7 @@ class FilesService {
limit,
])
: this.accountDb.all(
- `SELECT files.*
+ `SELECT files.*
FROM files
WHERE files.owner = ? and deleted = 0
UNION
@@ -152,7 +152,7 @@ class FilesService {
FROM files
JOIN user_access UA ON UA.file_id = files.id
JOIN users on users.id = UA.user_id
- WHERE files.id = ?
+ WHERE files.id = ?
UNION ALL
SELECT users.id, users.display_name, users.user_name
FROM files
@@ -209,7 +209,7 @@ class FilesService {
const res = this.accountDb.mutate(query, params);
- if (res.changes != 1) {
+ if (res.changes !== 1) {
throw new GenericFileError('Could not update File', { id });
}
}
diff --git a/packages/sync-server/src/app-sync/tests/services/files-service.test.js b/packages/sync-server/src/app-sync/tests/services/files-service.test.js
index 6ed7d2dd5c..e2183b3746 100644
--- a/packages/sync-server/src/app-sync/tests/services/files-service.test.js
+++ b/packages/sync-server/src/app-sync/tests/services/files-service.test.js
@@ -1,6 +1,6 @@
import crypto from 'node:crypto';
-import getAccountDb from '../../../account-db.js';
+import { getAccountDb } from '../../../account-db.js';
import { FileNotFound } from '../../errors.js';
import {
FilesService,
diff --git a/packages/sync-server/src/app.js b/packages/sync-server/src/app.js
index ef38f8090c..78bde184e5 100644
--- a/packages/sync-server/src/app.js
+++ b/packages/sync-server/src/app.js
@@ -13,7 +13,7 @@ import * as openidApp from './app-openid.js';
import * as secretApp from './app-secrets.js';
import * as simpleFinApp from './app-simplefin/app-simplefin.js';
import * as syncApp from './app-sync.js';
-import config from './load-config.js';
+import { config } from './load-config.js';
const app = express();
@@ -78,7 +78,7 @@ function parseHTTPSConfig(value) {
return fs.readFileSync(value);
}
-export default async function run() {
+export async function run() {
if (config.https) {
const https = await import('node:https');
const httpsOptions = {
diff --git a/packages/sync-server/src/db.js b/packages/sync-server/src/db.js
index 71fae7078d..3e0a997979 100644
--- a/packages/sync-server/src/db.js
+++ b/packages/sync-server/src/db.js
@@ -53,6 +53,6 @@ class WrappedDatabase {
}
/** @param {string} filename */
-export default function openDatabase(filename) {
+export function openDatabase(filename) {
return new WrappedDatabase(new Database(filename));
}
diff --git a/packages/sync-server/src/load-config.js b/packages/sync-server/src/load-config.js
index 78b0f99945..d991d8e6e2 100644
--- a/packages/sync-server/src/load-config.js
+++ b/packages/sync-server/src/load-config.js
@@ -189,6 +189,7 @@ const finalConfig = {
userinfo_endpoint: process.env.ACTUAL_OPENID_USERINFO_ENDPOINT,
};
const missing = Object.entries(required)
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
.filter(([_, value]) => !value)
.map(([key]) => key);
if (missing.length > 0) {
@@ -250,4 +251,4 @@ if (finalConfig.upload) {
debug(`using file limit ${finalConfig.upload.fileSizeLimitMB}mb`);
}
-export default finalConfig;
+export { finalConfig as config };
diff --git a/packages/sync-server/src/migrations.js b/packages/sync-server/src/migrations.js
index 34e5debeb1..1795f0e65e 100644
--- a/packages/sync-server/src/migrations.js
+++ b/packages/sync-server/src/migrations.js
@@ -2,9 +2,9 @@ import path from 'node:path';
import migrate from 'migrate';
-import config from './load-config.js';
+import { config } from './load-config.js';
-export default function run(direction = 'up') {
+export function run(direction = 'up') {
console.log(
`Checking if there are any migrations to run for direction "${direction}"...`,
);
diff --git a/packages/sync-server/src/run-migrations.js b/packages/sync-server/src/run-migrations.js
index b0de64e8c6..5fcf4231ec 100644
--- a/packages/sync-server/src/run-migrations.js
+++ b/packages/sync-server/src/run-migrations.js
@@ -1,4 +1,4 @@
-import run from './migrations.js';
+import { run } from './migrations.js';
const direction = process.argv[2] || 'up';
diff --git a/packages/sync-server/src/scripts/enable-openid.js b/packages/sync-server/src/scripts/enable-openid.js
index caf782ff1a..22f877aaf2 100644
--- a/packages/sync-server/src/scripts/enable-openid.js
+++ b/packages/sync-server/src/scripts/enable-openid.js
@@ -3,7 +3,7 @@ import {
getActiveLoginMethod,
needsBootstrap,
} from '../account-db.js';
-import finalConfig from '../load-config.js';
+import { config } from '../load-config.js';
if (needsBootstrap()) {
console.log(
@@ -21,7 +21,7 @@ if (needsBootstrap()) {
console.log('OpenID already enabled.');
process.exit(0);
}
- const { error } = (await enableOpenID(finalConfig)) || {};
+ const { error } = (await enableOpenID(config)) || {};
if (error) {
console.log('Error enabling openid:', error);
diff --git a/packages/sync-server/src/scripts/health-check.js b/packages/sync-server/src/scripts/health-check.js
index 2e9a4ceb20..dfbec31525 100644
--- a/packages/sync-server/src/scripts/health-check.js
+++ b/packages/sync-server/src/scripts/health-check.js
@@ -1,6 +1,6 @@
import fetch from 'node-fetch';
-import config from '../load-config.js';
+import { config } from '../load-config.js';
const protocol = config.https ? 'https' : 'http';
const hostname = config.hostname === '::' ? 'localhost' : config.hostname;
diff --git a/packages/sync-server/src/services/secrets-service.js b/packages/sync-server/src/services/secrets-service.js
index a32af90fde..b78b8c610a 100644
--- a/packages/sync-server/src/services/secrets-service.js
+++ b/packages/sync-server/src/services/secrets-service.js
@@ -1,6 +1,6 @@
import createDebug from 'debug';
-import getAccountDb from '../account-db.js';
+import { getAccountDb } from '../account-db.js';
/**
* An enum of valid secret names.
diff --git a/packages/sync-server/src/services/user-service.js b/packages/sync-server/src/services/user-service.js
index 5400054e49..7896bf3053 100644
--- a/packages/sync-server/src/services/user-service.js
+++ b/packages/sync-server/src/services/user-service.js
@@ -1,4 +1,4 @@
-import getAccountDb from '../account-db.js';
+import { getAccountDb } from '../account-db.js';
export function getUserByUsername(userName) {
if (!userName || typeof userName !== 'string') {
diff --git a/packages/sync-server/src/sync-simple.js b/packages/sync-server/src/sync-simple.js
index 81aa5d9d12..e3d041fb68 100644
--- a/packages/sync-server/src/sync-simple.js
+++ b/packages/sync-server/src/sync-simple.js
@@ -3,7 +3,7 @@ import { join } from 'node:path';
import { merkle, SyncProtoBuf, Timestamp } from '@actual-app/crdt';
-import openDatabase from './db.js';
+import { openDatabase } from './db.js';
import { sqlDir } from './load-config.js';
import { getPathForGroupFile } from './util/paths.js';
diff --git a/packages/sync-server/src/util/middlewares.js b/packages/sync-server/src/util/middlewares.js
index 460e15a72b..37fd559dfd 100644
--- a/packages/sync-server/src/util/middlewares.js
+++ b/packages/sync-server/src/util/middlewares.js
@@ -1,7 +1,7 @@
import * as expressWinston from 'express-winston';
import * as winston from 'winston';
-import validateSession from './validate-user.js';
+import { validateSession } from './validate-user.js';
/**
* @param {Error} err
diff --git a/packages/sync-server/src/util/paths.js b/packages/sync-server/src/util/paths.js
index d89426dfc6..59f54cd354 100644
--- a/packages/sync-server/src/util/paths.js
+++ b/packages/sync-server/src/util/paths.js
@@ -1,6 +1,6 @@
import { join } from 'node:path';
-import config from '../load-config.js';
+import { config } from '../load-config.js';
/** @param {string} fileId */
export function getPathForUserFile(fileId) {
diff --git a/packages/sync-server/src/util/validate-user.js b/packages/sync-server/src/util/validate-user.js
index bb7daa4804..89ca19d21e 100644
--- a/packages/sync-server/src/util/validate-user.js
+++ b/packages/sync-server/src/util/validate-user.js
@@ -1,7 +1,7 @@
import ipaddr from 'ipaddr.js';
import { getSession } from '../account-db.js';
-import config from '../load-config.js';
+import { config } from '../load-config.js';
export const TOKEN_EXPIRATION_NEVER = -1;
const MS_PER_SECOND = 1000;
@@ -10,7 +10,7 @@ const MS_PER_SECOND = 1000;
* @param {import('express').Request} req
* @param {import('express').Response} res
*/
-export default function validateSession(req, res) {
+export function validateSession(req, res) {
let { token } = req.body || {};
if (!token) {
@@ -57,7 +57,7 @@ export function validateAuthHeader(req) {
// @ts-ignore : there is an error in the ts definition for the function, but this is valid
const matched = ipaddr.subnetMatch(peerIp, rangeList, 'fail');
- if (matched == 'allowed_ips') {
+ if (matched === 'allowed_ips') {
console.info(`Header Auth Login permitted from ${peer}`);
return true;
} else {
diff --git a/upcoming-release-notes/4363.md b/upcoming-release-notes/4363.md
new file mode 100644
index 0000000000..170fdc3565
--- /dev/null
+++ b/upcoming-release-notes/4363.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [matt-fidd]
+---
+
+Bring server in line with actual linting rules