"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> {...
no-array-constructorno-async-promise-executorno-await-in-loopno-bitwiseno-callerno-case-declarationsno-class-assignno-compare-neg-zerono-cond-assignno-confusing-arrowno-consoleno-const-assignno-constant-binary-expressionno-constant-conditionno-constructor-returnno-continueno-control-regexno-debuggerno-...
使其不违反eslint规则no-async-promise-executor?EN当您将函数标记为异步时,它将自动将返回值包装在pr...
https://eslint.org/docs/latest/rules/no-async-promise-executor#rule-details This rule uncovered a case where an error inside of loadOrganization() could result in a stalled sudo auth page, and wher...
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 的状态。