mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fix: Resolve no-floating-promises lint errors (#12196)
* fix: Resolve no-floating-promises lint errors Adds await or void to 10 unhandled promises. Notable fixes: a test assertion using `.resolves` was never awaited, and a custom emoji fetch with setState was running during render instead of in an effect. * chore: Promote no-floating-promises to error Now that all occurrences are fixed, prevent regressions.
This commit is contained in:
@@ -87,6 +87,7 @@
|
||||
"import/no-named-as-default": "off",
|
||||
"import/no-named-as-default-member": "off",
|
||||
"typescript/consistent-type-imports": "error",
|
||||
"typescript/no-floating-promises": "error",
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
|
||||
@@ -49,13 +49,15 @@ const useTooltipContent = ({
|
||||
);
|
||||
|
||||
// If the emoji is a custom emoji ID, we need to get its short name for display
|
||||
if (isUUID(emoji)) {
|
||||
emojis.fetch(emoji).then((ce) => {
|
||||
if (ce) {
|
||||
setTransformedEmoji(ce.shortName);
|
||||
}
|
||||
});
|
||||
}
|
||||
React.useEffect(() => {
|
||||
if (isUUID(emoji)) {
|
||||
void emojis.fetch(emoji).then((ce) => {
|
||||
if (ce) {
|
||||
setTransformedEmoji(ce.shortName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [emoji, emojis]);
|
||||
|
||||
if (!reactedUsers.length) {
|
||||
return;
|
||||
|
||||
@@ -229,7 +229,7 @@ const Sidebar = React.forwardRef<HTMLDivElement, Props>(function Sidebar_(
|
||||
);
|
||||
|
||||
const handleCloseSidebar = () => {
|
||||
trigger("light");
|
||||
void trigger("light");
|
||||
ui.toggleMobileSidebar();
|
||||
};
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ function Overview({ collection, readOnly }: Props) {
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
handleSave.flush();
|
||||
void handleSave.flush();
|
||||
},
|
||||
[handleSave]
|
||||
);
|
||||
|
||||
@@ -364,7 +364,7 @@ const Content = styled.div`
|
||||
const RecentDocuments = observer(
|
||||
({ collection, documents }: { collection: Collection; documents: any }) => {
|
||||
useEffect(() => {
|
||||
collection.fetchDocuments();
|
||||
void collection.fetchDocuments();
|
||||
}, [collection]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -121,7 +121,7 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
provider.shouldConnect = false;
|
||||
retryCount.current++;
|
||||
|
||||
sleep(retryCount.current * 1000 - 1000).then(() =>
|
||||
void sleep(retryCount.current * 1000 - 1000).then(() =>
|
||||
auth
|
||||
.fetchAuth()
|
||||
.then(() => {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class APIUpdateExtension implements Extension {
|
||||
});
|
||||
|
||||
// Subscribe to the API update channel pattern
|
||||
this.subscriber.psubscribe(`${CHANNEL_PREFIX}:*`, (err) => {
|
||||
await this.subscriber.psubscribe(`${CHANNEL_PREFIX}:*`, (err) => {
|
||||
if (err) {
|
||||
Logger.error("Failed to subscribe to API update channel", err);
|
||||
return;
|
||||
|
||||
@@ -73,7 +73,7 @@ export default class ShareSubscriptionNotificationsTask extends BaseTask<Revisio
|
||||
? `${baseShareUrl.replace(/\/$/, "")}${document.path}`
|
||||
: baseShareUrl;
|
||||
|
||||
new ShareDocumentUpdatedEmail({
|
||||
await new ShareDocumentUpdatedEmail({
|
||||
to: subscription.email,
|
||||
shareSubscriptionId: subscription.id,
|
||||
documentTitle: document.titleWithDefault,
|
||||
|
||||
@@ -756,7 +756,7 @@ describe("#comments.create", () => {
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.json()).resolves.toMatchObject({
|
||||
await expect(res.json()).resolves.toMatchObject({
|
||||
data: {
|
||||
data: {
|
||||
content: [
|
||||
|
||||
@@ -540,7 +540,7 @@ router.post(
|
||||
const confirmUrl = ShareSubscriptionHelper.confirmUrl(subscription);
|
||||
const usePublicBranding =
|
||||
share.team?.getPreference(TeamPreference.PublicBranding) ?? false;
|
||||
new ShareSubscriptionConfirmEmail({
|
||||
await new ShareSubscriptionConfirmEmail({
|
||||
to: email,
|
||||
documentTitle: document?.titleWithDefault ?? "",
|
||||
confirmUrl,
|
||||
|
||||
@@ -85,7 +85,7 @@ export const downloadImageNode = async (
|
||||
document.body.removeChild(link);
|
||||
} catch {
|
||||
if (cache !== "reload") {
|
||||
downloadImageNode(node, "reload");
|
||||
await downloadImageNode(node, "reload");
|
||||
} else {
|
||||
window.open(sanitizeUrl(node.attrs.src), "_blank");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user