ethereumjs-monorepo
ethereumjs-monorepo copied to clipboard
Review and enable `require-await` rule for `eslint`
Extracting the enabling of require-await into this issue from https://github.com/ethereumjs/ethereumjs-monorepo/issues/1935 so that issue can be closed as the majority of rules there has been enabled.
Did some more testing and enabling this rule is extremely annoying because it can't handle async
functions that do not have an await
but only return the results of other async
functions. For example it complains that the getTestsFromArgs
function has no await
but if you remove the async
keyword all uses of it fail because it no longer signals that it returns a Promise
in all cases. This can be worked around by forcing return types but is just as hacky as leaving it as-is.
export async function getTestsFromArgs(testType: string, onFile: Function, args: any = {}) {
let fileFilter, excludeDir, skipFn
skipFn = (name: string) => {
return skipTest(name, args.skipTests)
}
if (new RegExp(`BlockchainTests`).test(testType)) {
const forkFilter = new RegExp(`${args.forkConfig}$`)
skipFn = (name: string, test: any) => {
return forkFilter.test(test.network) === false || skipTest(name, args.skipTests)
}
}
if (new RegExp(`GeneralStateTests`).test(testType)) {
const forkFilter = new RegExp(`${args.forkConfig}$`)
skipFn = (name: string, test: any) => {
return (
Object.keys(test['post'])
.map((key) => forkFilter.test(key))
.every((e) => !e) || skipTest(name, args.skipTests)
)
}
}
if (testType === 'VMTests') {
skipFn = (name: string) => {
return skipTest(name, args.skipVM)
}
}
if (isTruthy(args.singleSource)) {
return getTestFromSource(args.singleSource, onFile)
}
if (isTruthy(args.file)) {
fileFilter = new RegExp(args.file)
}
if (isTruthy(args.excludeDir)) {
excludeDir = new RegExp(args.excludeDir)
}
if (isTruthy(args.test)) {
skipFn = (testName: string) => {
return testName !== args.test
}
}
return getTests(onFile, fileFilter, skipFn, args.directory, excludeDir)
}
Does #2272 close this issue?
@ScottyPoi this issue is for require
while the linked PR was for return
so this issue isn't resolved yet.