function-definition-argname
Ast Rule: function definition
function-definition-argname
function visit(node, filename, code) {
// check that we have more than one argument
if(node.parameters && node.parameters.values && node.parameters.values.length > 0){
const argumentsToUpdate = node.parameters.values.filter(a => a.name && a.name.value === "foo");
argumentsToUpdate.forEach(a => {
console.log(a);
// Edit the argument name and use "bar"
const editChangeFunctionName = buildEditUpdate(a.name.start.line, a.name.start.col, a.name.end.line, a.name.end.col, "bar");
const fix = buildFix("use bar", [editChangeFunctionName]);
const error = buildError(a.name.start.line, a.name.start.col, a.name.end.line, a.name.end.col, "do not use foo for an argument name", "CRITICAL", "SAFETY");
addError(error.addFix(fix));
});
}
}
function.js
Expected test result: has error