Files
codeql-action/node_modules/eslint-plugin-no-async-foreach/lib/no-async-foreach.js
2020-09-14 10:42:37 +01:00

34 lines
1.1 KiB
JavaScript

/**
* @fileoverview Blah
* @author El
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
create: function(context) {
return {
ExpressionStatement: function(node) {
const { callee } = node.expression
if (!callee || !callee.property || !callee.property.name) return;
if (callee.property.name === "forEach") {
const functionArguments = node.expression.arguments.find(n => {
return n.type === 'ArrowFunctionExpression' || n.type === 'FunctionExpression'
})
if(functionArguments){
if (functionArguments.async) {
context.report(node, "No async function in forEachs");
}
}
}
}
};
}
}