1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-30 23:44:55 +02:00

Tools: Add eslint rule prefer-await-to-then

This commit is contained in:
Laurent Cozic
2022-09-30 17:23:14 +01:00
parent cc6620a7e1
commit 44a96f347a
34 changed files with 65 additions and 0 deletions

View File

@ -90,6 +90,8 @@ module.exports = {
// Disable because of this: https://github.com/facebook/react/issues/16265 // Disable because of this: https://github.com/facebook/react/issues/16265
// "react-hooks/exhaustive-deps": "warn", // "react-hooks/exhaustive-deps": "warn",
'promise/prefer-await-to-then': 'error',
// ------------------------------- // -------------------------------
// Formatting // Formatting
// ------------------------------- // -------------------------------
@ -141,6 +143,7 @@ module.exports = {
'@seiyab/eslint-plugin-react-hooks', '@seiyab/eslint-plugin-react-hooks',
// 'react-hooks', // 'react-hooks',
'import', 'import',
'promise',
], ],
'overrides': [ 'overrides': [
{ {

View File

@ -69,6 +69,7 @@
"eslint": "^8.22.0", "eslint": "^8.22.0",
"eslint-interactive": "^10.0.0", "eslint-interactive": "^10.0.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-react": "^7.30.1", "eslint-plugin-react": "^7.30.1",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"glob": "^7.1.6", "glob": "^7.1.6",

View File

@ -124,6 +124,7 @@ async function handleAutocompletionPromise(line) {
return line; return line;
} }
function handleAutocompletion(str, callback) { function handleAutocompletion(str, callback) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
handleAutocompletionPromise(str).then(function(res) { handleAutocompletionPromise(str).then(function(res) {
callback(undefined, res); callback(undefined, res);
}); });

View File

@ -36,6 +36,7 @@ async function createClients() {
const client = createClient(clientId); const client = createClient(clientId);
promises.push(fs.remove(client.profileDir)); promises.push(fs.remove(client.profileDir));
promises.push( promises.push(
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
execCommand(client, 'config sync.target 2').then(() => { execCommand(client, 'config sync.target 2').then(() => {
return execCommand(client, `config sync.2.path ${syncDir}`); return execCommand(client, `config sync.2.path ${syncDir}`);
}) })
@ -2324,10 +2325,12 @@ async function main() {
clients[clientId].activeCommandCount++; clients[clientId].activeCommandCount++;
execRandomCommand(clients[clientId]) execRandomCommand(clients[clientId])
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch(error => { .catch(error => {
logger.info(`Client ${clientId}:`); logger.info(`Client ${clientId}:`);
logger.error(error); logger.error(error);
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(r => { .then(r => {
if (r) { if (r) {
logger.info(`Client ${clientId}:\n${r.trim()}`); logger.info(`Client ${clientId}:\n${r.trim()}`);

View File

@ -50,6 +50,7 @@ export default class PluginRunner extends BasePluginRunner {
const callId = `${pluginId}::${path}::${uuid.createNano()}`; const callId = `${pluginId}::${path}::${uuid.createNano()}`;
this.activeSandboxCalls_[callId] = true; this.activeSandboxCalls_[callId] = true;
const promise = executeSandboxCall(pluginId, sandbox, `joplin.${path}`, mapEventHandlersToIds(args, this.eventHandlers_), this.eventHandler); const promise = executeSandboxCall(pluginId, sandbox, `joplin.${path}`, mapEventHandlersToIds(args, this.eventHandlers_), this.eventHandler);
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
promise.finally(() => { promise.finally(() => {
delete this.activeSandboxCalls_[callId]; delete this.activeSandboxCalls_[callId];
}); });

View File

@ -502,6 +502,7 @@ class Application extends BaseApplication {
if (Setting.value('env') === 'dev') { if (Setting.value('env') === 'dev') {
void AlarmService.updateAllNotifications(); void AlarmService.updateAllNotifications();
} else { } else {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
void reg.scheduleSync(1000).then(() => { void reg.scheduleSync(1000).then(() => {
// Wait for the first sync before updating the notifications, since synchronisation // Wait for the first sync before updating the notifications, since synchronisation
// might change the notifications. // might change the notifications.

View File

@ -45,6 +45,7 @@ class ClipperConfigScreenComponent extends React.Component {
if (confirm(_('Are you sure you want to renew the authorisation token?'))) { if (confirm(_('Are you sure you want to renew the authorisation token?'))) {
void EncryptionService.instance() void EncryptionService.instance()
.generateApiToken() .generateApiToken()
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((token) => { .then((token) => {
Setting.setValue('api.token', token); Setting.setValue('api.token', token);
}); });

View File

@ -174,9 +174,11 @@ class ResourceScreenComponent extends React.Component<Props, State> {
return; return;
} }
Resource.delete(resource.id) Resource.delete(resource.id)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch((error: Error) => { .catch((error: Error) => {
bridge().showErrorMessageBox(error.message); bridge().showErrorMessageBox(error.message);
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.finally(() => { .finally(() => {
void this.reloadResources(this.state.sorting); void this.reloadResources(this.state.sorting);
}); });

View File

@ -50,6 +50,7 @@ class FolderScreenComponent extends BaseScreenComponent {
lastSavedFolder: Object.assign({}, folder), lastSavedFolder: Object.assign({}, folder),
}); });
} else { } else {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
Folder.load(this.props.folderId).then(folder => { Folder.load(this.props.folderId).then(folder => {
this.setState({ this.setState({
folder: folder, folder: folder,

View File

@ -151,10 +151,12 @@ class NotesScreenComponent extends BaseScreenComponent {
} }
deleteFolder_onPress(folderId) { deleteFolder_onPress(folderId) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
dialogs.confirm(this, _('Delete notebook? All notes and sub-notebooks within this notebook will also be deleted.')).then(ok => { dialogs.confirm(this, _('Delete notebook? All notes and sub-notebooks within this notebook will also be deleted.')).then(ok => {
if (!ok) return; if (!ok) return;
Folder.delete(folderId) Folder.delete(folderId)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(() => { .then(() => {
this.props.dispatch({ this.props.dispatch({
type: 'NAV_GO', type: 'NAV_GO',
@ -162,6 +164,7 @@ class NotesScreenComponent extends BaseScreenComponent {
smartFilterId: 'c3176726992c11e9ac940492261af972', smartFilterId: 'c3176726992c11e9ac940492261af972',
}); });
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch(error => { .catch(error => {
alert(error.message); alert(error.message);
}); });

View File

@ -633,6 +633,7 @@ async function initialize(dispatch: Function) {
// start almost immediately to get the latest data. // start almost immediately to get the latest data.
// doWifiConnectionCheck set to true so initial sync // doWifiConnectionCheck set to true so initial sync
// doesn't happen on mobile data // doesn't happen on mobile data
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
void reg.scheduleSync(1000, null, true).then(() => { void reg.scheduleSync(1000, null, true).then(() => {
// Wait for the first sync before updating the notifications, since synchronisation // Wait for the first sync before updating the notifications, since synchronisation
// might change the notifications. // might change the notifications.

View File

@ -39,6 +39,7 @@ export default (dispatch: Function, folderId: string) => {
void Note.save({ void Note.save({
parent_id: folderId, parent_id: folderId,
is_todo: isTodo, is_todo: isTodo,
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
}, { provisional: true }).then((newNote: any) => { }, { provisional: true }).then((newNote: any) => {
dispatch({ dispatch({
type: 'NAV_GO', type: 'NAV_GO',
@ -51,6 +52,7 @@ export default (dispatch: Function, folderId: string) => {
DeviceEventEmitter.addListener('quickActionShortcut', handleQuickAction); DeviceEventEmitter.addListener('quickActionShortcut', handleQuickAction);
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
QuickActions.popInitialAction().then(handleQuickAction).catch((reason: any) => reg.logger().error(reason)); QuickActions.popInitialAction().then(handleQuickAction).catch((reason: any) => reg.logger().error(reason));
}; };

View File

@ -41,6 +41,7 @@ class DatabaseDriverReactNative {
} }
selectAll(sql, params = null) { selectAll(sql, params = null) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
return this.exec(sql, params).then(r => { return this.exec(sql, params).then(r => {
const output = []; const output = [];
for (let i = 0; i < r.rows.length; i++) { for (let i = 0; i < r.rows.length; i++) {

View File

@ -880,6 +880,7 @@ export default class BaseApplication {
if (!Setting.value('api.token')) { if (!Setting.value('api.token')) {
void EncryptionService.instance() void EncryptionService.instance()
.generateApiToken() .generateApiToken()
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((token: string) => { .then((token: string) => {
Setting.setValue('api.token', token); Setting.setValue('api.token', token);
}); });

View File

@ -248,6 +248,7 @@ class BaseModel {
if (options.where) sql += ` WHERE ${options.where}`; if (options.where) sql += ` WHERE ${options.where}`;
return this.db() return this.db()
.selectOne(sql) .selectOne(sql)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((r: any) => { .then((r: any) => {
return r ? r['total'] : 0; return r ? r['total'] : 0;
}); });
@ -335,6 +336,7 @@ class BaseModel {
if (params === null) params = []; if (params === null) params = [];
return this.db() return this.db()
.selectOne(sql, params) .selectOne(sql, params)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((model: any) => { .then((model: any) => {
return this.filter(this.addModelMd(model)); return this.filter(this.addModelMd(model));
}); });
@ -344,6 +346,7 @@ class BaseModel {
if (params === null) params = []; if (params === null) params = [];
return this.db() return this.db()
.selectAll(sql, params) .selectAll(sql, params)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((models: any[]) => { .then((models: any[]) => {
return this.filterArray(this.addModelMd(models)); return this.filterArray(this.addModelMd(models));
}); });

View File

@ -292,6 +292,7 @@ export default class JoplinDatabase extends Database {
queries.push(this.wrapQuery('DELETE FROM table_fields')); queries.push(this.wrapQuery('DELETE FROM table_fields'));
return this.selectAll('SELECT name FROM sqlite_master WHERE type="table"') return this.selectAll('SELECT name FROM sqlite_master WHERE type="table"')
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(tableRows => { .then(tableRows => {
const chain = []; const chain = [];
for (let i = 0; i < tableRows.length; i++) { for (let i = 0; i < tableRows.length; i++) {
@ -303,6 +304,7 @@ export default class JoplinDatabase extends Database {
if (tableName === 'notes_spellfix') continue; if (tableName === 'notes_spellfix') continue;
if (tableName === 'search_aux') continue; if (tableName === 'search_aux') continue;
chain.push(() => { chain.push(() => {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
return this.selectAll(`PRAGMA table_info("${tableName}")`).then(pragmas => { return this.selectAll(`PRAGMA table_info("${tableName}")`).then(pragmas => {
for (let i = 0; i < pragmas.length; i++) { for (let i = 0; i < pragmas.length; i++) {
const item = pragmas[i]; const item = pragmas[i];
@ -325,6 +327,7 @@ export default class JoplinDatabase extends Database {
return promiseChain(chain); return promiseChain(chain);
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(() => { .then(() => {
queries.push({ sql: 'UPDATE version SET table_fields_version = ?', params: [newVersion] }); queries.push({ sql: 'UPDATE version SET table_fields_version = ?', params: [newVersion] });
return this.transactionExecBatch(queries); return this.transactionExecBatch(queries);

View File

@ -231,11 +231,14 @@ class Logger {
// when many log operations are being done (eg. during sync in // when many log operations are being done (eg. during sync in
// dev mode). // dev mode).
let release: Function = null; let release: Function = null;
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
writeToFileMutex_.acquire().then((r: Function) => { writeToFileMutex_.acquire().then((r: Function) => {
release = r; release = r;
return Logger.fsDriver().appendFile(target.path, `${line.join(': ')}\n`, 'utf8'); return Logger.fsDriver().appendFile(target.path, `${line.join(': ')}\n`, 'utf8');
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
}).catch((error: any) => { }).catch((error: any) => {
console.error('Cannot write to log file:', error); console.error('Cannot write to log file:', error);
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
}).finally(() => { }).finally(() => {
if (release) release(); if (release) release();
}); });

View File

@ -70,9 +70,11 @@ export default class TaskQueue {
task task
.callback() .callback()
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((result: any) => { .then((result: any) => {
completeTask(task, result, null); completeTask(task, result, null);
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch((error: Error) => { .catch((error: Error) => {
if (!error) error = new Error('Unknown error'); if (!error) error = new Error('Unknown error');
completeTask(task, null, error); completeTask(task, null, error);

View File

@ -102,6 +102,7 @@ shared.saveNoteButton_press = async function(comp, folderId = null, options = nu
comp.setState(newState); comp.setState(newState);
if (isProvisionalNote) { if (isProvisionalNote) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
Note.updateGeolocation(note.id).then(geoNote => { Note.updateGeolocation(note.id).then(geoNote => {
const stateNote = comp.state.note; const stateNote = comp.state.note;
if (!stateNote || !geoNote) return; if (!stateNote || !geoNote) return;

View File

@ -588,6 +588,7 @@ export default async function importEnex(parentFolderId: string, filePath: strin
notes.push(note); notes.push(note);
if (notes.length >= 10) { if (notes.length >= 10) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
processNotes().catch(error => { processNotes().catch(error => {
importOptions.onError(createErrorWithNoteTitle(this, error)); importOptions.onError(createErrorWithNoteTitle(this, error));
}); });
@ -648,6 +649,7 @@ export default async function importEnex(parentFolderId: string, filePath: strin
saxStream.on('end', handleSaxStreamEvent(function() { saxStream.on('end', handleSaxStreamEvent(function() {
// Wait till there is no more notes to process. // Wait till there is no more notes to process.
const iid = shim.setInterval(() => { const iid = shim.setInterval(() => {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
void processNotes().then(allDone => { void processNotes().then(allDone => {
if (allDone) { if (allDone) {
shim.clearTimeout(iid); shim.clearTimeout(iid);

View File

@ -55,6 +55,7 @@ export default class Folder extends BaseItem {
return this.db() return this.db()
.selectAll(`SELECT id FROM notes WHERE ${where.join(' AND ')}`, [parentId]) .selectAll(`SELECT id FROM notes WHERE ${where.join(' AND ')}`, [parentId])
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then((rows: any[]) => { .then((rows: any[]) => {
const output = []; const output = [];
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
@ -759,6 +760,7 @@ export default class Folder extends BaseItem {
syncDebugLog.info('Folder Save:', o); syncDebugLog.info('Folder Save:', o);
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
return super.save(o, options).then((folder: FolderEntity) => { return super.save(o, options).then((folder: FolderEntity) => {
this.dispatch({ this.dispatch({
type: 'FOLDER_UPDATE_ONE', type: 'FOLDER_UPDATE_ONE',

View File

@ -205,6 +205,7 @@ export default class Tag extends BaseItem {
} }
} }
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
return super.save(o, options).then((tag: TagEntity) => { return super.save(o, options).then((tag: TagEntity) => {
if (options.dispatchUpdateAction) { if (options.dispatchUpdateAction) {
this.dispatch({ this.dispatch({

View File

@ -82,12 +82,14 @@ class OneDriveApiNodeUtils {
this.api() this.api()
.execTokenRequest(query.code, `http://localhost:${port.toString()}`) .execTokenRequest(query.code, `http://localhost:${port.toString()}`)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(() => { .then(() => {
writeResponse(200, _('The application has been authorised - you may now close this browser tab.')); writeResponse(200, _('The application has been authorised - you may now close this browser tab.'));
targetConsole.log(''); targetConsole.log('');
targetConsole.log(_('The application has been successfully authorised.')); targetConsole.log(_('The application has been successfully authorised.'));
waitAndDestroy(); waitAndDestroy();
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch(error => { .catch(error => {
writeResponse(400, error.message); writeResponse(400, error.message);
targetConsole.log(''); targetConsole.log('');

View File

@ -4,6 +4,7 @@ function promiseChain(chain, defaultValue = null) {
}); });
for (let i = 0; i < chain.length; i++) { for (let i = 0; i < chain.length; i++) {
const f = chain[i]; const f = chain[i];
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
output = output.then(f); output = output.then(f);
} }
return output; return output;

View File

@ -49,6 +49,7 @@ describe('Registry', function() {
it('should sync if do wifi check is false', done => { it('should sync if do wifi check is false', done => {
void reg.scheduleSync(1, null, false) void reg.scheduleSync(1, null, false)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(() =>{ .then(() =>{
expect(sync.start).toHaveBeenCalled(); expect(sync.start).toHaveBeenCalled();
done(); done();

View File

@ -181,11 +181,13 @@ export default class ResourceFetcher extends BaseService {
fileApi fileApi
.get(remoteResourceContentPath, { path: localResourceContentPath, target: 'file' }) .get(remoteResourceContentPath, { path: localResourceContentPath, target: 'file' })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(async () => { .then(async () => {
await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_DONE }); await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_DONE });
this.logger().debug(`ResourceFetcher: Resource downloaded: ${resource.id}`); this.logger().debug(`ResourceFetcher: Resource downloaded: ${resource.id}`);
await completeDownload(true, localResourceContentPath); await completeDownload(true, localResourceContentPath);
}) })
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch(async (error: any) => { .catch(async (error: any) => {
this.logger().error(`ResourceFetcher: Could not download resource: ${resource.id}`, error); this.logger().error(`ResourceFetcher: Could not download resource: ${resource.id}`, error);
await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_ERROR, fetch_error: error.message }); await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_ERROR, fetch_error: error.message });

View File

@ -77,6 +77,7 @@ export default async function populateDatabase(db: any, options: Options = null)
let tagBatch = []; let tagBatch = [];
for (let i = 0; i < options.tagCount; i++) { for (let i = 0; i < options.tagCount; i++) {
const tagTitle = randomElement(wordList); // `tag${i}` const tagTitle = randomElement(wordList); // `tag${i}`
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
tagBatch.push(Tag.save({ title: tagTitle }, { dispatchUpdateAction: false }).then((savedTag: any) => { tagBatch.push(Tag.save({ title: tagTitle }, { dispatchUpdateAction: false }).then((savedTag: any) => {
createdTagIds.push(savedTag.id); createdTagIds.push(savedTag.id);
if (!options.silent) console.info(`Tags: ${i} / ${options.tagCount}`); if (!options.silent) console.info(`Tags: ${i} / ${options.tagCount}`);
@ -99,6 +100,7 @@ export default async function populateDatabase(db: any, options: Options = null)
const parentIndex = randomIndex(createdFolderIds); const parentIndex = randomIndex(createdFolderIds);
note.parent_id = createdFolderIds[parentIndex]; note.parent_id = createdFolderIds[parentIndex];
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
noteBatch.push(Note.save(note, { dispatchUpdateAction: false }).then((savedNote: any) => { noteBatch.push(Note.save(note, { dispatchUpdateAction: false }).then((savedNote: any) => {
createdNoteIds.push(savedNote.id); createdNoteIds.push(savedNote.id);
console.info(`Notes: ${i} / ${options.noteCount}`); console.info(`Notes: ${i} / ${options.noteCount}`);

View File

@ -36,6 +36,7 @@ export default class JoplinPlugins {
// We don't use `await` when calling onStart because the plugin might be awaiting // We don't use `await` when calling onStart because the plugin might be awaiting
// in that call too (for example, when opening a dialog on startup) so we don't // in that call too (for example, when opening a dialog on startup) so we don't
// want to get stuck here. // want to get stuck here.
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
void script.onStart({}).catch((error: any) => { void script.onStart({}).catch((error: any) => {
// For some reason, error thrown from the executed script do not have the type "Error" // For some reason, error thrown from the executed script do not have the type "Error"
// but are instead plain object. So recreate the Error object here so that it can // but are instead plain object. So recreate the Error object here so that it can
@ -43,6 +44,7 @@ export default class JoplinPlugins {
const newError: Error = new Error(error.message); const newError: Error = new Error(error.message);
newError.stack = error.stack; newError.stack = error.stack;
logger.error(`Uncaught exception in plugin "${this.plugin.id}":`, newError); logger.error(`Uncaught exception in plugin "${this.plugin.id}":`, newError);
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
}).then(() => { }).then(() => {
logger.info(`Finished running onStart handler: ${this.plugin.id} (Took ${Date.now() - startTime}ms)`); logger.info(`Finished running onStart handler: ${this.plugin.id} (Took ${Date.now() - startTime}ms)`);
this.plugin.emit('started'); this.plugin.emit('started');

View File

@ -502,7 +502,9 @@ function shimInit(options = null) {
const cleanUpOnError = error => { const cleanUpOnError = error => {
// We ignore any unlink error as we only want to report on the main error // We ignore any unlink error as we only want to report on the main error
fs.unlink(filePath) fs.unlink(filePath)
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.catch(() => {}) .catch(() => {})
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
.then(() => { .then(() => {
if (file) { if (file) {
file.close(() => { file.close(() => {

View File

@ -71,6 +71,7 @@ async function main() {
} }
if (require.main === module) { if (require.main === module) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
main().catch((error) => { main().catch((error) => {
console.error('Fatal error'); console.error('Fatal error');
console.error(error); console.error(error);

View File

@ -87,6 +87,7 @@ async function start(): Promise<void> {
} }
if (require.main === module) { if (require.main === module) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
start().catch((error) => { start().catch((error) => {
console.error('Fatal error'); console.error('Fatal error');
console.error(error); console.error(error);

View File

@ -48,6 +48,7 @@ const main = async () => {
}; };
if (require.main === module) { if (require.main === module) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
main().catch((error) => { main().catch((error) => {
console.error(error); console.error(error);
process.exit(1); process.exit(1);

View File

@ -12,6 +12,7 @@ async function main() {
} }
if (require.main === module) { if (require.main === module) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
main().catch((error) => { main().catch((error) => {
console.error('Fatal error'); console.error('Fatal error');
console.error(error); console.error(error);

View File

@ -15287,6 +15287,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"eslint-plugin-promise@npm:^6.0.1":
version: 6.0.1
resolution: "eslint-plugin-promise@npm:6.0.1"
peerDependencies:
eslint: ^7.0.0 || ^8.0.0
checksum: c1bb3c2e591787e97133dcaf764f908420a3a1959a3132e199db8f14d70dfa79fc9caf991ca60a4b60ae5f1f9823bc96c2e52304828a4278ef2f3964fe121de9
languageName: node
linkType: hard
"eslint-plugin-promise@npm:~3.4.0": "eslint-plugin-promise@npm:~3.4.0":
version: 3.4.2 version: 3.4.2
resolution: "eslint-plugin-promise@npm:3.4.2" resolution: "eslint-plugin-promise@npm:3.4.2"
@ -30008,6 +30017,7 @@ __metadata:
eslint: ^8.22.0 eslint: ^8.22.0
eslint-interactive: ^10.0.0 eslint-interactive: ^10.0.0
eslint-plugin-import: ^2.26.0 eslint-plugin-import: ^2.26.0
eslint-plugin-promise: ^6.0.1
eslint-plugin-react: ^7.30.1 eslint-plugin-react: ^7.30.1
fs-extra: ^8.1.0 fs-extra: ^8.1.0
glob: ^7.1.6 glob: ^7.1.6