diff --git a/packages/host/.eslintrc.js b/packages/host/.eslintrc.js index 1375fcb578..b4274ff725 100644 --- a/packages/host/.eslintrc.js +++ b/packages/host/.eslintrc.js @@ -1,13 +1,19 @@ 'use strict'; +const { resolve } = require('path'); + module.exports = { root: true, + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, env: { browser: true, }, overrides: [ { - files: ['**/*.{js,ts}'], + files: ['**/*.ts'], parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 'latest', @@ -21,6 +27,7 @@ module.exports = { ], ], }, + project: [resolve(__dirname, './tsconfig.json')], }, plugins: ['ember', '@typescript-eslint', 'window-mock'], extends: [ @@ -43,6 +50,7 @@ module.exports = { '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-this-alias': 'off', '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/await-thenable': 'error', 'no-undef': 'off', 'ember/no-runloop': 'off', 'window-mock/mock-window-only': 'error', diff --git a/packages/host/app/lib/current-run.ts b/packages/host/app/lib/current-run.ts index b687ff0317..7ba1e26f03 100644 --- a/packages/host/app/lib/current-run.ts +++ b/packages/host/app/lib/current-run.ts @@ -345,7 +345,7 @@ export class CurrentRun { log.warn( `encountered error loading module "${url.href}": ${err.message}`, ); - let deps = await ( + let deps = ( await this.loaderService.loader.getConsumedModules(url.href) ).filter((u) => u !== url.href); await this.batch.updateEntry(url, { diff --git a/packages/host/app/lib/matrix-handlers/index.ts b/packages/host/app/lib/matrix-handlers/index.ts index 05b24f798b..de0952350f 100644 --- a/packages/host/app/lib/matrix-handlers/index.ts +++ b/packages/host/app/lib/matrix-handlers/index.ts @@ -68,12 +68,11 @@ export async function addRoomEvent(context: MatrixService, event: Event) { room = new RoomState(); context.setRoom(roomId, room); } - let resolvedRoom = await room; //look at the note in the MatrixService interface for why this is awaited // duplicate events may be emitted from matrix, as well as the resolved room card might already contain this event - if (!resolvedRoom.events.find((e) => e.event_id === eventId)) { - resolvedRoom.events = [ - ...(resolvedRoom.events ?? []), + if (!room.events.find((e) => e.event_id === eventId)) { + room.events = [ + ...(room.events ?? []), event as unknown as DiscreteMatrixEvent, ]; } @@ -105,14 +104,10 @@ export async function updateRoomEvent( `bug: unknown room for event ${JSON.stringify(event, null, 2)}`, ); } - let resolvedRoom = await room; //look at the note in the MatrixService interface for why this is awaited - let oldEventIndex = resolvedRoom.events.findIndex( - (e) => e.event_id === oldEventId, - ); + let oldEventIndex = room.events.findIndex((e) => e.event_id === oldEventId); if (oldEventIndex >= 0) { - resolvedRoom.events[oldEventIndex] = - event as unknown as DiscreteMatrixEvent; - resolvedRoom.events = [...resolvedRoom.events]; + room.events[oldEventIndex] = event as unknown as DiscreteMatrixEvent; + room.events = [...room.events]; } } @@ -126,8 +121,7 @@ export async function getRoomEvents( ); } let room = context.getRoom(roomId); - let resolvedRoom = await room; - return resolvedRoom?.events ?? []; + return room?.events ?? []; } export async function getCommandResultEvents( diff --git a/packages/host/app/lib/matrix-handlers/timeline.ts b/packages/host/app/lib/matrix-handlers/timeline.ts index 5dcaf7c1da..13206f5ec7 100644 --- a/packages/host/app/lib/matrix-handlers/timeline.ts +++ b/packages/host/app/lib/matrix-handlers/timeline.ts @@ -104,7 +104,7 @@ async function processDecryptedEvent( return; } - let roomState = await MatrixService.getRoom(roomId); + let roomState = MatrixService.getRoom(roomId); // patch in any missing room events--this will support dealing with local // echoes, migrating older histories as well as handle any matrix syncing gaps // that might occur diff --git a/packages/host/app/resources/room.ts b/packages/host/app/resources/room.ts index baa5a72894..e93d92bb5b 100644 --- a/packages/host/app/resources/room.ts +++ b/packages/host/app/resources/room.ts @@ -84,6 +84,8 @@ export class RoomResource extends Resource { private load = restartableTask(async (roomId: string) => { try { + // TODO: figure out why the line below requires await despite not being a promise. Probably related to e-concurrency + // eslint-disable-next-line @typescript-eslint/await-thenable this.room = roomId ? await this.matrixService.getRoom(roomId) : undefined; //look at the note in the EventSendingContext interface for why this is awaited if (this.room) { await this.loadRoomMembers(roomId); diff --git a/packages/host/tests/acceptance/ai-assistant-test.gts b/packages/host/tests/acceptance/ai-assistant-test.gts index 848ea1d60b..f8f3ba246d 100644 --- a/packages/host/tests/acceptance/ai-assistant-test.gts +++ b/packages/host/tests/acceptance/ai-assistant-test.gts @@ -38,7 +38,7 @@ async function selectCardFromCatalog(cardId: string) { await click('[data-test-card-catalog-go-button]'); } -async function assertMessages( +function assertMessages( assert: Assert, messages: { from: string; diff --git a/packages/host/tests/acceptance/code-submode/schema-editor-test.ts b/packages/host/tests/acceptance/code-submode/schema-editor-test.ts index 1018159430..78abc80233 100644 --- a/packages/host/tests/acceptance/code-submode/schema-editor-test.ts +++ b/packages/host/tests/acceptance/code-submode/schema-editor-test.ts @@ -585,10 +585,8 @@ module('Acceptance | code submode | schema editor tests', function (hooks) { ?.textContent?.includes('BigInteger'), ); - await assert.dom('[data-test-selected-field-realm-icon] img').exists(); - await assert - .dom('[data-test-selected-field-display-name]') - .hasText('BigInteger'); + assert.dom('[data-test-selected-field-realm-icon] img').exists(); + assert.dom('[data-test-selected-field-display-name]').hasText('BigInteger'); await click('[data-test-choose-card-button]'); @@ -609,7 +607,7 @@ module('Acceptance | code submode | schema editor tests', function (hooks) { ?.textContent?.includes('Date'), ); - await assert.dom('[data-test-selected-field-display-name]').hasText('Date'); + assert.dom('[data-test-selected-field-display-name]').hasText('Date'); assert.dom('[data-test-save-field-button]').hasAttribute('disabled'); await fillIn('[data-test-field-name-input]', ' birth date'); diff --git a/packages/host/tests/helpers/adapter.ts b/packages/host/tests/helpers/adapter.ts index 34763972dd..ed11ff6279 100644 --- a/packages/host/tests/helpers/adapter.ts +++ b/packages/host/tests/helpers/adapter.ts @@ -171,7 +171,7 @@ export class TestRealmAdapter implements RealmAdapter { // a quirk of our test file system's traverse is that it creates // directories as it goes--so do our best to determine if we are checking for // a file that exists (because of this behavior directories always exist) - await this.#traverse( + this.#traverse( path.split('/'), maybeFilename.includes('.') ? 'file' : 'directory', ); @@ -182,7 +182,7 @@ export class TestRealmAdapter implements RealmAdapter { } if (err.name === 'TypeMismatchError') { try { - await this.#traverse(path.split('/'), 'file'); + this.#traverse(path.split('/'), 'file'); return true; } catch (err: any) { if (err.name === 'NotFoundError') {