no-async-promise-executor 是ESLint 中的一个规则,用于检测在创建 Promise 时,其执行器(executor)函数是否错误地使用了 async 函数。Promise 构造函数应该接受一个同步的执行函数,而不应该包含异步操作。 2. 阐述为什么应该避免在 Promise 执行器函数中使用 async/await 在Promise 的执行器函数中使用 async 函数通常...
16Contribute to ESLint10Extend ESLint3integrate ESLint237Rules accessor-pairsarray-bracket-spacingarray-callback-returnarrow-body-stylearrow-parensarrow-spacingblock-scoped-varblock-spacingbrace-stylecamelcasecapitalized-commentsclass-methods-use-thiscomma-danglecomma-spacingcomma-stylecomplexitycomputed-property...
使用async/await定义报错:Promise executor functions should not be async.eslintno-async-promise-executor? klim 606139173 发布于 2024-09-03 四川 现有这样的定义async/await的场景: const getOSQueryBuilder = async (): Promise<Repository<ConfigEntities>> => { return Database.getRepository(ConfigEntities)...
使其不违反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...
解决方法: 方案一: 将eslint-config-standard的npm版本降至12以下 cnpm i eslint-config-standard@10.2.1 --save-dev 方案二: 在eslintrc.js的rules里添加off 'no-async-promise-executor' : 'off', 'no-misleading-character-class' : 'off', ...
配置文件中的 "extends": "eslint:recommended" 属性启用了该规则 new Promise构造函数接受一个执行器函数作为参数,该函数具有resolve和reject参数,可用于控制创建的 Promise 的状态。例如: constresult=newPromise(functionexecutor(resolve,reject){readFile('foo.txt',function(err,result){if(err){reject(err);}...