Skip to content

Commit

Permalink
Lint unnecessary-type-assertion (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley authored Oct 27, 2023
1 parent 59ebbd5 commit 5fcab88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
21 changes: 12 additions & 9 deletions web/tests/integration/components/related-resources/add-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module("Integration | Component | related-resources/add", function (hooks) {

const reducerFunction = (
acc: Record<string, HermesDocument>,
document: { attrs: HermesDocument }
document: { attrs: HermesDocument },
) => {
acc[document.attrs.objectID] = document.attrs;
return acc;
Expand All @@ -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<string, HermesDocument>);
.reduce(
(acc, key) => {
acc[key] = documents[key];
return acc;
},
{} as Record<string, HermesDocument>,
);
};

suggestions = getFirstFourRecords(suggestions);
Expand All @@ -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);
Expand All @@ -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) => {
Expand Down Expand Up @@ -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<void>((resolve) => {
setTimeout(() => {
resolve();
}, 1000);
}) as Promise<void>;
});
});

await render<RelatedResourcesAddTestContext>(hbs`
Expand Down

0 comments on commit 5fcab88

Please sign in to comment.