A generic rule to enforce correct call arguments length.
For example CanvasRenderingContext2D.drawImage() can config as {'*.drawImage': [3, 5, 9]}
, so it must be called with 3
or 5
or 9
arguments.
// Fail
context.drawImage(image, dx);
context.drawImage(image, dx, dy, dWidth, );
// Pass
context.drawImage(image, dx, dy);
This rule accepts a configurable list, for each method of function, value can be a number or a range, or allowed lengths.
{
rules: {
'unicorn/call-arguments-length':[
'error',
{
'parseInt': 2,
'*.drawImage': [3, 5, 9],
'*.addEventListener': {min: 2}
}
]
}
}
Ref: #974 (comment)
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too