diff --git a/eslint.config.mjs b/eslint.config.mjs index 2d2385cbdb..c497974612 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -51,8 +51,23 @@ export default [ }, rules: { - "no-self-assign": "off", - "prefer-const": "off", + "no-self-compare": "error", + "no-template-curly-in-string": "error", + "no-unmodified-loop-condition": "error", + "no-unreachable-loop": "error", + "no-implied-eval": "error", + "no-extend-native": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-new-wrappers": "error", + "no-octal-escape": "error", + "no-return-assign": "error", + "no-useless-concat": "error", + "no-useless-constructor": "error", + "no-useless-rename": "error", + "no-var": "error", + "no-void": "error", + "no-unused-vars": [ "error", { @@ -65,64 +80,69 @@ export default [ ], }, }, - ...eslintPluginSvelte.configs["flat/recommended"].map(config => { - return { - ...config, - files: ["**/*.svelte"], + ...eslintPluginSvelte.configs["flat/recommended"].map(config => ({ + ...config, + files: ["**/*.svelte"], - languageOptions: { - parser: svelteParser, - ecmaVersion: 2019, - sourceType: "script", + languageOptions: { + parser: svelteParser, + ecmaVersion: 2019, + sourceType: "script", - parserOptions: { - parser: "@typescript-eslint/parser", - allowImportExportEverywhere: true, + parserOptions: { + parser: "@typescript-eslint/parser", + allowImportExportEverywhere: true, + }, + }, + })), + ...tseslint.configs.strict.map(config => ({ + ...config, + files: ["**/*.ts"], + + languageOptions: { + globals: { + NodeJS: true, + }, + + parser: tsParser, + }, + + rules: { + "local-rules/no-barrel-imports": "error", + "local-rules/no-budibase-imports": "error", + "local-rules/no-console-error": "error", + + "@typescript-eslint/no-inferrable-types": "error", + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/class-literal-property-style": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", + "@typescript-eslint/no-unnecessary-parameter-property-assignment": + "error", + "@typescript-eslint/no-useless-empty-export": "error", + + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + varsIgnorePattern: "^_", + argsIgnorePattern: "^_", + destructuredArrayIgnorePattern: "^_", + ignoreRestSiblings: true, + caughtErrors: "none", }, - }, - } - }), - ...tseslint.configs.recommended.map(config => { - return { - ...config, - files: ["**/*.ts"], + ], - languageOptions: { - globals: { - NodeJS: true, - }, + "no-redeclare": "off", + "@typescript-eslint/no-redeclare": "error", - parser: tsParser, - }, + // @typescript-eslint/no-dupe-class-members supersedes no-dupe-class-members + "no-dupe-class-members": "off", + "@typescript-eslint/no-dupe-class-members": "error", - rules: { - "local-rules/no-barrel-imports": "error", - "local-rules/no-budibase-imports": "error", - "local-rules/no-console-error": "error", - - // @typscript-eslint/no-unused-vars supersedes no-unused-vars - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - varsIgnorePattern: "^_", - argsIgnorePattern: "^_", - destructuredArrayIgnorePattern: "^_", - ignoreRestSiblings: true, - caughtErrors: "none", - }, - ], - - // @typescript-eslint/no-redeclare supersedes no-redeclare - "no-redeclare": "off", - "@typescript-eslint/no-redeclare": "error", - - // @typescript-eslint/no-dupe-class-members supersedes no-dupe-class-members - "no-dupe-class-members": "off", - "@typescript-eslint/no-dupe-class-members": "error", - }, - } - }), + "no-useless-constructor": "off", + "@typescript-eslint/no-useless-constructor": "error", + }, + })), { files: ["**/*.spec.ts", "**/*.spec.js"], diff --git a/packages/backend-core/src/db/couch/DatabaseImpl.ts b/packages/backend-core/src/db/couch/DatabaseImpl.ts index 371f3dc997..98e24e0996 100644 --- a/packages/backend-core/src/db/couch/DatabaseImpl.ts +++ b/packages/backend-core/src/db/couch/DatabaseImpl.ts @@ -289,7 +289,7 @@ export class DatabaseImpl implements Database { return } let errorFound = false - let errorMessage: string = "Unable to bulk remove documents: " + let errorMessage = "Unable to bulk remove documents: " for (let res of response) { if (res.error) { errorFound = true diff --git a/packages/backend-core/src/db/couch/utils.ts b/packages/backend-core/src/db/couch/utils.ts index 270d953320..2200024bb2 100644 --- a/packages/backend-core/src/db/couch/utils.ts +++ b/packages/backend-core/src/db/couch/utils.ts @@ -4,7 +4,7 @@ import { checkSlashesInUrl } from "../../helpers" export async function directCouchCall( path: string, - method: string = "GET", + method = "GET", body?: any ) { let { url, cookie } = getCouchInfo() @@ -43,7 +43,7 @@ export async function directCouchUrlCall({ export async function directCouchQuery( path: string, - method: string = "GET", + method = "GET", body?: any ) { const response = await directCouchCall(path, method, body) diff --git a/packages/backend-core/src/db/lucene.ts b/packages/backend-core/src/db/lucene.ts index 0206bb2140..9d897553dd 100644 --- a/packages/backend-core/src/db/lucene.ts +++ b/packages/backend-core/src/db/lucene.ts @@ -279,7 +279,7 @@ export class QueryBuilder { let query = allOr ? "" : "*:*" let allFiltersEmpty = true const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true } - let tableId: string = "" + let tableId = "" if (this.#query.equal!.tableId) { tableId = this.#query.equal!.tableId delete this.#query.equal!.tableId diff --git a/packages/backend-core/src/events/processors/Processors.ts b/packages/backend-core/src/events/processors/Processors.ts index 72de945d44..8fe8034280 100644 --- a/packages/backend-core/src/events/processors/Processors.ts +++ b/packages/backend-core/src/events/processors/Processors.ts @@ -2,7 +2,7 @@ import { Event, Identity, Group } from "@budibase/types" import { EventProcessor } from "./types" export default class Processor implements EventProcessor { - initialised: boolean = false + initialised = false processors: EventProcessor[] = [] constructor(processors: EventProcessor[]) { diff --git a/packages/backend-core/src/middleware/authenticated.ts b/packages/backend-core/src/middleware/authenticated.ts index 6713cc7687..54d808de86 100644 --- a/packages/backend-core/src/middleware/authenticated.ts +++ b/packages/backend-core/src/middleware/authenticated.ts @@ -137,9 +137,9 @@ export default function ( } const tenantId = getHeader(ctx, Header.TENANT_ID) - let authenticated: boolean = false, + let authenticated = false, user: User | { tenantId: string } | undefined = undefined, - internal: boolean = false, + internal = false, loginMethod: LoginMethod | undefined = undefined if (authCookie && !apiKey) { const sessionId = authCookie.sessionId diff --git a/packages/backend-core/src/middleware/passport/sso/sso.ts b/packages/backend-core/src/middleware/passport/sso/sso.ts index 8901fcc56f..1bb43d4466 100644 --- a/packages/backend-core/src/middleware/passport/sso/sso.ts +++ b/packages/backend-core/src/middleware/passport/sso/sso.ts @@ -20,7 +20,7 @@ export const ssoSaveUserNoOp: SaveSSOUserFunction = (user: SSOUser) => */ export async function authenticate( details: SSOAuthDetails, - requireLocalAccount: boolean = true, + requireLocalAccount = true, done: any, saveUserFn: SaveSSOUserFunction ) { diff --git a/packages/backend-core/src/objectStore/objectStore.ts b/packages/backend-core/src/objectStore/objectStore.ts index 68b1b10ec2..79875b5e99 100644 --- a/packages/backend-core/src/objectStore/objectStore.ts +++ b/packages/backend-core/src/objectStore/objectStore.ts @@ -334,7 +334,7 @@ export async function listAllObjects(bucketName: string, path: string) { export function getPresignedUrl( bucketName: string, key: string, - durationSeconds: number = 3600 + durationSeconds = 3600 ) { const objectStore = ObjectStore(bucketName, { presigning: true }) const params = { diff --git a/packages/backend-core/src/redis/redlockImpl.ts b/packages/backend-core/src/redis/redlockImpl.ts index adeb5b12ec..a48fac0c3d 100644 --- a/packages/backend-core/src/redis/redlockImpl.ts +++ b/packages/backend-core/src/redis/redlockImpl.ts @@ -92,7 +92,7 @@ function getLockName(opts: LockOptions) { // determine lock name // by default use the tenantId for uniqueness, unless using a system lock const prefix = opts.systemLock ? "system" : context.getTenantId() - let name: string = `lock:${prefix}_${opts.name}` + let name = `lock:${prefix}_${opts.name}` // add additional unique name if required if (opts.resource) { name = name + `_${opts.resource}` diff --git a/packages/backend-core/tests/core/utilities/structures/quotas.ts b/packages/backend-core/tests/core/utilities/structures/quotas.ts index 83c3a8a766..4b3c357b13 100644 --- a/packages/backend-core/tests/core/utilities/structures/quotas.ts +++ b/packages/backend-core/tests/core/utilities/structures/quotas.ts @@ -1,6 +1,6 @@ import { MonthlyQuotaName, QuotaUsage } from "@budibase/types" -export const usage = (users: number = 0, creators: number = 0): QuotaUsage => { +export const usage = (users = 0, creators = 0): QuotaUsage => { return { _id: "usage_quota", quotaReset: new Date().toISOString(), diff --git a/packages/bbui/src/Form/Core/Signature.svelte b/packages/bbui/src/Form/Core/Signature.svelte index 729d3ac5e2..e02560568c 100644 --- a/packages/bbui/src/Form/Core/Signature.svelte +++ b/packages/bbui/src/Form/Core/Signature.svelte @@ -85,7 +85,7 @@ } const getPos = e => { - var rect = canvasRef.getBoundingClientRect() + let rect = canvasRef.getBoundingClientRect() const canvasX = e.offsetX || e.targetTouches?.[0].pageX - rect.left const canvasY = e.offsetY || e.targetTouches?.[0].pageY - rect.top diff --git a/packages/builder/src/components/backend/RoleEditor/BracketEdge.svelte b/packages/builder/src/components/backend/RoleEditor/BracketEdge.svelte index 182b56f122..058c47f00c 100644 --- a/packages/builder/src/components/backend/RoleEditor/BracketEdge.svelte +++ b/packages/builder/src/components/backend/RoleEditor/BracketEdge.svelte @@ -24,9 +24,9 @@ const j = 32 // Outer radius strength (higher is stronger) // Calculate unit vector - var dx = x1 - x2 - var dy = y1 - y2 - var len = Math.sqrt(dx * dx + dy * dy) + let dx = x1 - x2 + let dy = y1 - y2 + let len = Math.sqrt(dx * dx + dy * dy) dx = dx / len dy = dy / len diff --git a/packages/client/src/components/app/embedded-map/EmbeddedMapControls.js b/packages/client/src/components/app/embedded-map/EmbeddedMapControls.js index de14190b64..190bc810bf 100644 --- a/packages/client/src/components/app/embedded-map/EmbeddedMapControls.js +++ b/packages/client/src/components/app/embedded-map/EmbeddedMapControls.js @@ -30,7 +30,7 @@ const FullScreenControl = L.Control.extend({ fullScreenTitle: "Enter Fullscreen", }, onAdd: function () { - var fullScreenClassName = "leaflet-control-fullscreen", + let fullScreenClassName = "leaflet-control-fullscreen", container = L.DomUtil.create("div", fullScreenClassName + " leaflet-bar"), options = this.options @@ -45,7 +45,7 @@ const FullScreenControl = L.Control.extend({ return container }, _fullScreen: function () { - var map = this._map + let map = this._map if (screenfull.isEnabled) { screenfull.toggle(map.getContainer()) } @@ -80,7 +80,7 @@ const LocationControl = L.Control.extend({ locationTitle: "Show Your Location", }, onAdd: function () { - var locationClassName = "leaflet-control-location", + let locationClassName = "leaflet-control-location", container = L.DomUtil.create("div", locationClassName + " leaflet-bar"), options = this.options @@ -136,7 +136,7 @@ const LocationControl = L.Control.extend({ }) }, _getPosition: function () { - var options = { + let options = { enableHighAccuracy: false, timeout: 5000, maximumAge: 30000, diff --git a/packages/client/src/stores/theme.js b/packages/client/src/stores/theme.js index 523d34cdc5..5171449a91 100644 --- a/packages/client/src/stores/theme.js +++ b/packages/client/src/stores/theme.js @@ -1,3 +1,4 @@ +/* eslint-disable no-useless-concat */ import { derived } from "svelte/store" import { appStore } from "./app" import { builderStore } from "./builder" diff --git a/packages/server/src/api/controllers/dev.ts b/packages/server/src/api/controllers/dev.ts index ad0909a294..099f297cd4 100644 --- a/packages/server/src/api/controllers/dev.ts +++ b/packages/server/src/api/controllers/dev.ts @@ -22,7 +22,7 @@ import { async function redirect( ctx: any, method: "GET" | "POST" | "DELETE", - path: string = "global" + path = "global" ) { const { devPath } = ctx.params const queryString = ctx.originalUrl.split("?")[1] || "" diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 5f01f323e6..e0171a062e 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -378,7 +378,7 @@ export class ExternalRequest { } // many to one else { - const thisKey: string = "id" + const thisKey = "id" // @ts-ignore const otherKey: string = field.fieldName for (const relationship of row[key]) { diff --git a/packages/server/src/api/controllers/row/utils/basic.ts b/packages/server/src/api/controllers/row/utils/basic.ts index a7aa82e1f2..214080382c 100644 --- a/packages/server/src/api/controllers/row/utils/basic.ts +++ b/packages/server/src/api/controllers/row/utils/basic.ts @@ -45,7 +45,7 @@ export function getInternalRowId(row: Row, table: Table): string { export function generateIdForRow( row: Row | undefined, table: Table, - isLinked: boolean = false + isLinked = false ): string { const primary = table.primary if (!row || !primary) { diff --git a/packages/server/src/api/controllers/view/exporters.ts b/packages/server/src/api/controllers/view/exporters.ts index 87e4bfc056..76e5f865a3 100644 --- a/packages/server/src/api/controllers/view/exporters.ts +++ b/packages/server/src/api/controllers/view/exporters.ts @@ -16,7 +16,7 @@ function escapeCsvString(str: string) { export function csv( headers: string[], rows: Row[], - delimiter: string = ",", + delimiter = ",", customHeaders: { [key: string]: string } = {} ) { let csvRows = [getHeaders(headers, customHeaders)] diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 6aac1d2069..6276d38e25 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -2133,7 +2133,7 @@ if (descriptions.length) { // repeat the search many times to check the first row is always the same let bookmark: string | number | undefined, hasNextPage: boolean | undefined = true, - rowCount: number = 0 + rowCount= 0 do { const response = await config.api.row.search( tableOrViewId, diff --git a/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts b/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts index 7a0d489f80..a3ea174da1 100644 --- a/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts +++ b/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts @@ -263,7 +263,7 @@ class AutomationBuilder extends BaseStepBuilder { private automationConfig: Automation private config: TestConfiguration private triggerOutputs: any - private triggerSet: boolean = false + private triggerSet = false constructor( options: { name?: string; appId?: string; config?: TestConfiguration } = {} diff --git a/packages/server/src/integrations/microsoftSqlServer.ts b/packages/server/src/integrations/microsoftSqlServer.ts index 7d886fc33a..f3590d1885 100644 --- a/packages/server/src/integrations/microsoftSqlServer.ts +++ b/packages/server/src/integrations/microsoftSqlServer.ts @@ -223,7 +223,7 @@ const COLUMN_DEFINITION_METADATA: Record = { class SqlServerIntegration extends Sql implements DatasourcePlus { private readonly config: MSSQLConfig - private index: number = 0 + private index= 0 private client?: sqlServer.ConnectionPool MASTER_TABLES = [ diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index d8708d9053..5fbb95aab3 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -116,7 +116,7 @@ const OracleContraintTypes = { class OracleIntegration extends Sql implements DatasourcePlus { private readonly config: OracleConfig - private index: number = 1 + private index = 1 private static readonly COLUMNS_SQL = ` SELECT diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index b41ac28ede..f4db9d6959 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -149,7 +149,7 @@ const SCHEMA: Integration = { class PostgresIntegration extends Sql implements DatasourcePlus { private readonly client: Client private readonly config: PostgresConfig - private index: number = 1 + private index= 1 private open: boolean PRIMARY_KEYS_SQL = () => ` @@ -252,7 +252,7 @@ class PostgresIntegration extends Sql implements DatasourcePlus { }) } - async internalQuery(query: SqlQuery, close: boolean = true) { + async internalQuery(query: SqlQuery, close = true) { if (!this.open) { await this.openConnection() } diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 1b00a18f18..4f8b246233 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -171,7 +171,7 @@ export class RestIntegration implements IntegrationBase { path.basename(parse(contentDisposition).parameters?.filename) || "" } - let triedParsing: boolean = false, + let triedParsing = false, responseTxt: string | undefined try { if (filename) { diff --git a/packages/server/src/integrations/tests/sqlAlias.spec.ts b/packages/server/src/integrations/tests/sqlAlias.spec.ts index 3d67a7aa41..b94f0c4c87 100644 --- a/packages/server/src/integrations/tests/sqlAlias.spec.ts +++ b/packages/server/src/integrations/tests/sqlAlias.spec.ts @@ -245,7 +245,7 @@ describe("Captures of real examples", () => { tableNames.push(generator.guid()) } const aliasing = new AliasTables(tableNames) - let alias: string = "" + let alias= "" for (let table of tableNames) { alias = aliasing.getAlias(table) } diff --git a/packages/server/src/middleware/builder.ts b/packages/server/src/middleware/builder.ts index bc775991df..90bbd368ef 100644 --- a/packages/server/src/middleware/builder.ts +++ b/packages/server/src/middleware/builder.ts @@ -59,9 +59,7 @@ async function updateAppUpdatedAt(ctx: UserCtx) { await setDebounce(appId, DEBOUNCE_TIME_SEC) } catch (err: any) { // if a 409 occurs, then multiple clients connected at the same time - ignore - if (err?.status === 409) { - return - } else { + if (err && err.status !== 409) { throw err } } diff --git a/packages/server/src/sdk/app/permissions/index.ts b/packages/server/src/sdk/app/permissions/index.ts index 7c385864f4..6e912a0235 100644 --- a/packages/server/src/sdk/app/permissions/index.ts +++ b/packages/server/src/sdk/app/permissions/index.ts @@ -104,8 +104,6 @@ export async function getDependantResources( return p }, {} as Record) } - - return } export async function updatePermissionOnRole( diff --git a/packages/server/src/sdk/app/rows/search/internal/sqs.ts b/packages/server/src/sdk/app/rows/search/internal/sqs.ts index 19380bde43..aa799390b8 100644 --- a/packages/server/src/sdk/app/rows/search/internal/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/internal/sqs.ts @@ -437,7 +437,7 @@ export async function search( ) // check for pagination final row - let nextRow: boolean = false + let nextRow = false if (paginate && params.limit && rows.length > params.limit) { // remove the extra row that confirmed if there is another row to move to nextRow = true diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts index beb03ecf08..33e6e407dc 100644 --- a/packages/server/src/tests/utilities/structures.ts +++ b/packages/server/src/tests/utilities/structures.ts @@ -535,7 +535,7 @@ export function basicRow(tableId: string) { export function basicLinkedRow( tableId: string, linkedRowId: string, - linkField: string = "link" + linkField = "link" ) { // this is based on the basic linked tables you get from the test configuration return { @@ -586,14 +586,14 @@ export function basicUser(role: string) { } } -export function basicScreen(route: string = "/") { +export function basicScreen(route = "/") { return createHomeScreen({ roleId: BUILTIN_ROLE_IDS.BASIC, route, }) } -export function powerScreen(route: string = "/") { +export function powerScreen(route = "/") { return createHomeScreen({ roleId: BUILTIN_ROLE_IDS.POWER, route, diff --git a/packages/server/src/utilities/retry.ts b/packages/server/src/utilities/retry.ts index af5d4d7cb5..f6e8cbd0e5 100644 --- a/packages/server/src/utilities/retry.ts +++ b/packages/server/src/utilities/retry.ts @@ -1,6 +1,6 @@ export async function retry any>( fn: T, - maxTry: number = 5, + maxTry = 5, retryCount = 1 ): Promise>> { const currRetry = typeof retryCount === "number" ? retryCount : 1 diff --git a/packages/server/src/websockets/websocket.ts b/packages/server/src/websockets/websocket.ts index e8cd306fd2..607cf12b78 100644 --- a/packages/server/src/websockets/websocket.ts +++ b/packages/server/src/websockets/websocket.ts @@ -33,7 +33,7 @@ export class BaseSocket { constructor( app: Koa, server: http.Server, - path: string = "/", + path = "/", additionalMiddlewares?: any[] ) { this.app = app diff --git a/packages/shared-core/src/helpers/cron.ts b/packages/shared-core/src/helpers/cron.ts index a13c19c265..dab45ebcab 100644 --- a/packages/shared-core/src/helpers/cron.ts +++ b/packages/shared-core/src/helpers/cron.ts @@ -33,7 +33,7 @@ function improveErrors(errors: string[]): string[] { export function getNextExecutionDates( cronExpression: string, - limit: number = 4 + limit = 4 ): string[] { const parsed = cronParser.parseExpression(cronExpression) const nextRuns = [] diff --git a/packages/string-templates/test/hbsToJs.spec.ts b/packages/string-templates/test/hbsToJs.spec.ts index ae071cfe37..51fba083aa 100644 --- a/packages/string-templates/test/hbsToJs.spec.ts +++ b/packages/string-templates/test/hbsToJs.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-template-curly-in-string */ import { convertToJS } from "../src/index" function checkLines(response: string, lines: string[]) { diff --git a/packages/string-templates/test/utils.ts b/packages/string-templates/test/utils.ts index 957366fc59..4934567788 100644 --- a/packages/string-templates/test/utils.ts +++ b/packages/string-templates/test/utils.ts @@ -11,7 +11,7 @@ function tryParseJson(str: string) { try { return JSON.parse(str.replace(/'/g, '"')) } catch (e) { - return + // do nothing } } diff --git a/packages/types/src/sdk/db.ts b/packages/types/src/sdk/db.ts index 9feecbdb2b..eb922bd81e 100644 --- a/packages/types/src/sdk/db.ts +++ b/packages/types/src/sdk/db.ts @@ -128,13 +128,13 @@ export interface Database { name: string exists(): Promise + exists(docId: string): Promise /** * @deprecated the plan is to get everything using `tryGet` instead, then rename * `tryGet` to `get`. */ get(id?: string): Promise tryGet(id?: string): Promise - exists(docId: string): Promise getMultiple( ids: string[], opts?: { allowMissing?: boolean; excludeDocs?: boolean } diff --git a/packages/worker/src/sdk/accounts/metadata.ts b/packages/worker/src/sdk/accounts/metadata.ts index 11ab069839..1cace19981 100644 --- a/packages/worker/src/sdk/accounts/metadata.ts +++ b/packages/worker/src/sdk/accounts/metadata.ts @@ -40,10 +40,7 @@ export const getMetadata = async ( try { return await db.get(accountId) } catch (e: any) { - if (e.status === 404) { - // do nothing - return - } else { + if (e.status !== 404) { throw e } } diff --git a/packages/worker/src/tests/api/accounts.ts b/packages/worker/src/tests/api/accounts.ts index bc6d055b77..25861226f9 100644 --- a/packages/worker/src/tests/api/accounts.ts +++ b/packages/worker/src/tests/api/accounts.ts @@ -1,12 +1,7 @@ import { Account, AccountMetadata } from "@budibase/types" -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class AccountAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - saveMetadata = async (account: Account) => { const res = await this.request .put(`/api/system/accounts/${account.accountId}/metadata`) diff --git a/packages/worker/src/tests/api/auditLogs.ts b/packages/worker/src/tests/api/auditLogs.ts index d7bc4d99fb..c79b4ea934 100644 --- a/packages/worker/src/tests/api/auditLogs.ts +++ b/packages/worker/src/tests/api/auditLogs.ts @@ -1,12 +1,7 @@ import { AuditLogSearchParams, SearchAuditLogsResponse } from "@budibase/types" -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class AuditLogAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - search = async (search: AuditLogSearchParams) => { const res = await this.request .post("/api/global/auditlogs/search") diff --git a/packages/worker/src/tests/api/auth.ts b/packages/worker/src/tests/api/auth.ts index 552d4da505..2587fe4c8f 100644 --- a/packages/worker/src/tests/api/auth.ts +++ b/packages/worker/src/tests/api/auth.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI, TestAPIOpts } from "./base" export class AuthAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - updatePassword = ( resetCode: string, password: string, diff --git a/packages/worker/src/tests/api/configs.ts b/packages/worker/src/tests/api/configs.ts index e0c1c806af..36d145412a 100644 --- a/packages/worker/src/tests/api/configs.ts +++ b/packages/worker/src/tests/api/configs.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class ConfigAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - getConfigChecklist = () => { return this.request .get(`/api/global/configs/checklist`) diff --git a/packages/worker/src/tests/api/email.ts b/packages/worker/src/tests/api/email.ts index b2f30e6ac1..a8f5967d58 100644 --- a/packages/worker/src/tests/api/email.ts +++ b/packages/worker/src/tests/api/email.ts @@ -1,12 +1,7 @@ import { EmailAttachment } from "@budibase/types" -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class EmailAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - sendEmail = (purpose: string, attachments?: EmailAttachment[]) => { return this.request .post(`/api/global/email/send`) diff --git a/packages/worker/src/tests/api/environment.ts b/packages/worker/src/tests/api/environment.ts index d6a76f3b06..b394f692ec 100644 --- a/packages/worker/src/tests/api/environment.ts +++ b/packages/worker/src/tests/api/environment.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class EnvironmentAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - getEnvironment = () => { return this.request .get(`/api/system/environment`) diff --git a/packages/worker/src/tests/api/groups.ts b/packages/worker/src/tests/api/groups.ts index 5153c19db0..5d983a53d4 100644 --- a/packages/worker/src/tests/api/groups.ts +++ b/packages/worker/src/tests/api/groups.ts @@ -1,12 +1,7 @@ import { UserGroup } from "@budibase/types" -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class GroupsAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - saveGroup = ( group: UserGroup, { expect }: { expect: number | object } = { expect: 200 } diff --git a/packages/worker/src/tests/api/license.ts b/packages/worker/src/tests/api/license.ts index a6645226af..bf7c952ab0 100644 --- a/packages/worker/src/tests/api/license.ts +++ b/packages/worker/src/tests/api/license.ts @@ -1,4 +1,3 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" import { ActivateLicenseKeyRequest, @@ -6,10 +5,6 @@ import { } from "@budibase/types" export class LicenseAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - refresh = async () => { return this.request .post("/api/global/license/refresh") diff --git a/packages/worker/src/tests/api/migrations.ts b/packages/worker/src/tests/api/migrations.ts index 6038cbd5d8..6d62fe994a 100644 --- a/packages/worker/src/tests/api/migrations.ts +++ b/packages/worker/src/tests/api/migrations.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI, TestAPIOpts } from "./base" export class MigrationAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - runMigrations = (opts?: TestAPIOpts) => { return this.request .post(`/api/system/migrations/run`) diff --git a/packages/worker/src/tests/api/restore.ts b/packages/worker/src/tests/api/restore.ts index c6a646317d..a39428da07 100644 --- a/packages/worker/src/tests/api/restore.ts +++ b/packages/worker/src/tests/api/restore.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI, TestAPIOpts } from "./base" export class RestoreAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - restored = (opts?: TestAPIOpts) => { return this.request .post(`/api/system/restored`) diff --git a/packages/worker/src/tests/api/roles.ts b/packages/worker/src/tests/api/roles.ts index 8e7647583a..6c7be76054 100644 --- a/packages/worker/src/tests/api/roles.ts +++ b/packages/worker/src/tests/api/roles.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI, TestAPIOpts } from "./base" export class RolesAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - get = (opts?: TestAPIOpts) => { return this.request .get(`/api/global/roles`) diff --git a/packages/worker/src/tests/api/scim/groups.ts b/packages/worker/src/tests/api/scim/groups.ts index d2df007614..0ec705fc52 100644 --- a/packages/worker/src/tests/api/scim/groups.ts +++ b/packages/worker/src/tests/api/scim/groups.ts @@ -4,14 +4,9 @@ import { ScimGroupResponse, ScimUpdateRequest, } from "@budibase/types" -import TestConfiguration from "../../TestConfiguration" import { RequestSettings, ScimTestAPI } from "./shared" export class ScimGroupsAPI extends ScimTestAPI { - constructor(config: TestConfiguration) { - super(config) - } - get = async ( requestSettings?: Partial & { params?: { diff --git a/packages/worker/src/tests/api/scim/shared.ts b/packages/worker/src/tests/api/scim/shared.ts index 546a940093..fca6f77abd 100644 --- a/packages/worker/src/tests/api/scim/shared.ts +++ b/packages/worker/src/tests/api/scim/shared.ts @@ -1,4 +1,3 @@ -import TestConfiguration from "../../TestConfiguration" import { TestAPI } from "../base" const defaultConfig: RequestSettings = { @@ -14,10 +13,6 @@ export type RequestSettings = { } export abstract class ScimTestAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - call = ( url: string, method: "get" | "post" | "patch" | "delete", diff --git a/packages/worker/src/tests/api/scim/users.ts b/packages/worker/src/tests/api/scim/users.ts index 318492d378..f518d49ce6 100644 --- a/packages/worker/src/tests/api/scim/users.ts +++ b/packages/worker/src/tests/api/scim/users.ts @@ -4,14 +4,9 @@ import { ScimUserResponse, ScimUpdateRequest, } from "@budibase/types" -import TestConfiguration from "../../TestConfiguration" import { RequestSettings, ScimTestAPI } from "./shared" export class ScimUsersAPI extends ScimTestAPI { - constructor(config: TestConfiguration) { - super(config) - } - get = async ( requestSettings?: Partial & { params?: { diff --git a/packages/worker/src/tests/api/self.ts b/packages/worker/src/tests/api/self.ts index 1c1492f37f..6f8cd8decf 100644 --- a/packages/worker/src/tests/api/self.ts +++ b/packages/worker/src/tests/api/self.ts @@ -1,12 +1,7 @@ -import TestConfiguration from "../TestConfiguration" import { User } from "@budibase/types" import { TestAPI } from "./base" export class SelfAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - updateSelf = (user: User, update: any) => { return this.request .post(`/api/global/self`) diff --git a/packages/worker/src/tests/api/status.ts b/packages/worker/src/tests/api/status.ts index 5b0f77efc6..c658411abc 100644 --- a/packages/worker/src/tests/api/status.ts +++ b/packages/worker/src/tests/api/status.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" export class StatusAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - getStatus = () => { return this.request.get(`/api/system/status`).expect(200) } diff --git a/packages/worker/src/tests/api/templates.ts b/packages/worker/src/tests/api/templates.ts index 0c8110394f..23e327b392 100644 --- a/packages/worker/src/tests/api/templates.ts +++ b/packages/worker/src/tests/api/templates.ts @@ -1,11 +1,6 @@ -import TestConfiguration from "../TestConfiguration" import { TestAPI, TestAPIOpts } from "./base" export class TemplatesAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - definitions = (opts?: TestAPIOpts) => { return this.request .get(`/api/global/template/definitions`) diff --git a/packages/worker/src/tests/api/users.ts b/packages/worker/src/tests/api/users.ts index b54fb45d2c..b964ba5112 100644 --- a/packages/worker/src/tests/api/users.ts +++ b/packages/worker/src/tests/api/users.ts @@ -9,14 +9,9 @@ import { } from "@budibase/types" import structures from "../structures" import { generator } from "@budibase/backend-core/tests" -import TestConfiguration from "../TestConfiguration" import { TestAPI, TestAPIOpts } from "./base" export class UserAPI extends TestAPI { - constructor(config: TestConfiguration) { - super(config) - } - // INVITE sendUserInvite = async (sendMailMock: any, email: string, status = 200) => { @@ -178,11 +173,7 @@ export class UserAPI extends TestAPI { .expect(opts?.status ? opts.status : 200) } - grantBuilderToApp = ( - userId: string, - appId: string, - statusCode: number = 200 - ) => { + grantBuilderToApp = (userId: string, appId: string, statusCode = 200) => { return this.request .post(`/api/global/users/${userId}/app/${appId}/builder`) .set(this.config.defaultHeaders()) diff --git a/scripts/build.js b/scripts/build.js index 93a2a1e589..d96b27b166 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -42,7 +42,7 @@ const svelteCompilePlugin = { }, } -var { argv } = require("yargs") +let { argv } = require("yargs") async function runBuild(entry, outfile) { const isDev = process.env.NODE_ENV !== "production"