no-async-promise-executor 是ESLint 中的一个规则,用于检测在创建 Promise 时,其执行器(executor)函数是否错误地使用了 async 函数。Promise 构造函数应该接受一个同步的执行函数,而不应该包含异步操作。 2. 阐述为什么应该避免在 Promise 执行器函数中使用 async/await 在Promise 的执行器函数中使用 async 函数通常...
使用async/await定义报错:Promise executor functions should not be async.eslintno-async-promise-executor? klim 596139171 发布于 2024-09-03 四川 现有这样的定义async/await的场景: const getOSQueryBuilder = async (): Promise<Repository<ConfigEntities>> => { return Database.getRepository(ConfigEntities)...
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...
使其不违反eslint规则no-async-promise-executor?EN当您将函数标记为异步时,它将自动将返回值包装在pr...
解决方法: 方案一: 将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 的状态。例如:const result = new Promise(function executor(resolve, reject) { readFile('foo.txt', function(err, result) { if ...
使用async/await定义报错:Promise executor functions should not be async.eslintno-async-promise-executor? 现有这样的定义async/await的场景: const getOSQueryBuilder = async (): Promise<Repository<ConfigEntities>> => { return Database.getRepository(ConfigEntities)...