From 5fcab88c52890af821d6e2bb5361a04d52cf0bb0 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Fri, 27 Oct 2023 09:12:10 -0400 Subject: [PATCH] Lint `unnecessary-type-assertion` (#381) --- web/.eslintrc.js | 1 - .../sidebar/related-resources/list-item.ts | 2 +- .../components/related-resources/add-test.ts | 21 +++++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/web/.eslintrc.js b/web/.eslintrc.js index 75571978a..2c672aeef 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -31,7 +31,6 @@ module.exports = { "@typescript-eslint/restrict-plus-operands": "off", "@typescript-eslint/await-thenable": "off", "@typescript-eslint/no-unsafe-enum-comparison": "off", - "@typescript-eslint/no-unnecessary-type-assertion": "off", "no-case-declarations": "off", "no-fallthrough": "off", "prefer-const": "off", diff --git a/web/app/components/document/sidebar/related-resources/list-item.ts b/web/app/components/document/sidebar/related-resources/list-item.ts index d3caf4459..c463678dd 100644 --- a/web/app/components/document/sidebar/related-resources/list-item.ts +++ b/web/app/components/document/sidebar/related-resources/list-item.ts @@ -71,7 +71,7 @@ export default class DocumentSidebarRelatedResourcesListItemComponent extends Co */ protected get documentObjectID(): string | null { if ("googleFileID" in this.args.resource) { - return (this.args.resource as RelatedHermesDocument).googleFileID; + return this.args.resource.googleFileID; } else { return null; } diff --git a/web/tests/integration/components/related-resources/add-test.ts b/web/tests/integration/components/related-resources/add-test.ts index 24281afaa..b2d924226 100644 --- a/web/tests/integration/components/related-resources/add-test.ts +++ b/web/tests/integration/components/related-resources/add-test.ts @@ -40,7 +40,7 @@ module("Integration | Component | related-resources/add", function (hooks) { const reducerFunction = ( acc: Record, - document: { attrs: HermesDocument } + document: { attrs: HermesDocument }, ) => { acc[document.attrs.objectID] = document.attrs; return acc; @@ -51,10 +51,13 @@ module("Integration | Component | related-resources/add", function (hooks) { const getFirstFourRecords = (documents: any) => { return Object.keys(documents) .slice(0, 4) - .reduce((acc, key) => { - acc[key] = documents[key]; - return acc; - }, {} as Record); + .reduce( + (acc, key) => { + acc[key] = documents[key]; + return acc; + }, + {} as Record, + ); }; suggestions = getFirstFourRecords(suggestions); @@ -66,7 +69,7 @@ module("Integration | Component | related-resources/add", function (hooks) { ( dd: XDropdownListAnchorAPI | null, query: string, - shouldIgnoreDelay?: boolean + shouldIgnoreDelay?: boolean, ) => { if (query === "") { this.set("shownDocuments", suggestions); @@ -79,7 +82,7 @@ module("Integration | Component | related-resources/add", function (hooks) { this.set("shownDocuments", getFirstFourRecords(matches)); } return Promise.resolve(); - } + }, ); this.set("getObject", (dd: XDropdownListAnchorAPI | null, id: string) => { @@ -150,11 +153,11 @@ module("Integration | Component | related-resources/add", function (hooks) { // Here, we set it to resolve a promise after a timeout to // allow us to capture its `isRunning` state. this.set("search", () => { - return new Promise((resolve) => { + return new Promise((resolve) => { setTimeout(() => { resolve(); }, 1000); - }) as Promise; + }); }); await render(hbs`