sindresorhus/eslint-plugin-unicorn
Rule proposal: `call-arguments-length`
Chiusa
#1356 aperta il 15 giu 2021
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
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: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/974#issuecomment-768746222