Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 0ae102c

Browse files
committed
chore: fix the types of getNotification
1 parent b97e925 commit 0ae102c

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

spec/linter-eslint-spec.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,17 @@ export async function copyFileToTempDir(fileToCopyPath) {
5757
return copyFileToDir(fileToCopyPath, tempFixtureDir)
5858
}
5959

60-
async function getNotification(expectedMessage) {
61-
return new Promise((resolve) => {
60+
/**
61+
* @param {string} expectedMessage
62+
* @returns {Promise<import("atom").Notification>}
63+
*/
64+
function getNotification(expectedMessage) {
65+
return new Promise((resolve, reject) => {
66+
/** @type {import("atom").Disposable | undefined} */
6267
let notificationSub
68+
/**
69+
* @param {Promise<import("atom").Notification>} notification
70+
*/
6371
const newNotification = (notification) => {
6472
if (notification.getMessage() !== expectedMessage) {
6573
// As the specs execute asynchronously, it's possible a notification
@@ -68,8 +76,12 @@ async function getNotification(expectedMessage) {
6876
return
6977
}
7078
// Dispose of the notification subscription
71-
notificationSub.dispose()
72-
resolve(notification)
79+
if (notificationSub !== undefined) {
80+
notificationSub.dispose()
81+
resolve(notification)
82+
} else {
83+
reject()
84+
}
7385
}
7486
// Subscribe to Atom's notifications
7587
notificationSub = atom.notifications.onDidAddNotification(newNotification)
@@ -81,6 +93,7 @@ async function getNotification(expectedMessage) {
8193
* @returns {Promise<void>}
8294
*/
8395
async function makeFixes(textEditor) {
96+
/** @type {Promise<void>} */
8497
const editorReloadPromise = new Promise((resolve) => {
8598
// Subscribe to file reload events
8699
const editorReloadSubscription = textEditor.getBuffer().onDidReload(() => {

0 commit comments

Comments
 (0)