-
-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule proposal: call-arguments-length
#1356
Labels
Comments
I think we should ship with a default preset for this rule that covers a lot of built-ins. |
This is now accepted. |
This rule should support {
rules: {
'unicorn/call-arguments-length': ['error', {
'parseInt': 2,
'*.drawImage': [3, 5, 9],
'*.addEventListener': {min: 2},
'new Set': {max: 1}
}]
}
} One edge case: spreading operator like |
I think spreading parameters should be regarded as error if the function has specified the arguments length // config
{
rules: {
'unicorn/call-arguments-length': ['error', {
'new Set': {max: 1}
}]
}
}
// code
new Set(); // pass
new Set(foo); // pass
new Set(...foo); // fail So that, the issue #2412 can be solved by this rule. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 with3
or5
or9
arguments.This rule accepts a configurable list, for each method of function, value can be a number or a range, or allowed lengths.
Ref: #974 (comment)
The text was updated successfully, but these errors were encountered: