webhook/node_modules/eslint-plugin-github/lib/rules/async-currenttarget.js
Joel Male 1ada95e04a
v2.0.0 (#12)
- Convert project to Javascript/Typescript
- Allow custom headers to be passed in (optional)
- Allow body to be optional
2020-08-26 10:52:47 +10:00

24 lines
568 B
JavaScript

module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
const scopeDidWait = new WeakSet()
return {
AwaitExpression() {
scopeDidWait.add(context.getScope(), true)
},
MemberExpression(node) {
if (node.property && node.property.name === 'currentTarget') {
const scope = context.getScope()
if (scope.block.async && scopeDidWait.has(scope)) {
context.report(node, 'event.currentTarget inside an async function is error prone')
}
}
}
}
}
}