"no-async-promise-executor" 是一个在 ESLint 中常用的规则,用于检测在 Promise 构造函数中是否错误地使用了 async 函数作为执行器(executor)。这个规则的目的是防止在 Promise 的执行器函数中不正确地处理异步操作,从而可能导致未捕获的异常或逻辑错误。 2. 说明为什么不应该在 Promise executor 中使用 async 函数...
你把异步抽成一个函数 调用就行了 这样 Promise executor 本身就不是异步函数了 const getOSQueryBuilder = async (): Promise<Repository<ConfigEntities>> => { return Database.getRepository(ConfigEntities) } class OSService { // 根据ID查询操作 static async getConfig(id: string): Promise<unknown> {...
The executor function can also be an async function. However, this is usually a mistake, for a few reasons:If an async executor function throws an error, the error will be lost and won’t cause the newly-constructed Promise to reject. This could make it difficult to debug and handle ...
使其不违反eslint规则no-async-promise-executor?EN当您将函数标记为异步时,它将自动将返回值包装在pr...
1:1 error Definition for rule 'no-async-promise-executor' was not found no-async-promise-executor 1:1 error Definition for rule 'no-misleading-character-class' was not found no-misleading-character-class 1:1 error Definition for rule 'no-useless-catch' was not found no-useless-catch ...
no-async-promise-executor 禁止使用异步函数作为 Promise 执行器,`new Promise` 构造函数接受一个执行器函数作为参数,该函数具有 `resolve` 和 `reject` 参数,可用于控制创建的 Promise 的状态。
const osQueryBuilder = await getOSQueryBuilder() const data = (await osQueryBuilder).findOne({ where: { id } }) resolve(data) }) } } 报错信息: Promise executor functions should not be async.eslintno-async-promise-executor 请问这里应该如何整改呢?