Skip to content

Commit

Permalink
[[FIX]] Correctly enforce maxparams:0
Browse files Browse the repository at this point in the history
Previously setting maxparams:0 would cause the check to short-circuit,
permitting any number of parameters without issuing a warning. This PR
fixes the bug by testing whether maxparams is a number, instead of
whether it is truthy.
  • Loading branch information
mbildner committed Mar 2, 2015
1 parent a8cfae6 commit 011364e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ var JSHINT = (function() {
verifyMaxParametersPerFunction: function(params) {
params = params || [];

if (state.option.maxparams && params.length > state.option.maxparams) {
if (_.isNumber(state.option.maxparams) && params.length > state.option.maxparams) {
warning("W072", functionStartToken, params.length);
}
},
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,10 @@ exports.maxparams = function (test) {
TestRun(test)
.test(src, { es3: true, maxparams: 3 });

TestRun(test)
.addError(4, "This function has too many parameters. (3)")
.test(src, {es3: true, maxparams: 0 });

TestRun(test)
.test(src, { es3: true });

Expand Down

0 comments on commit 011364e

Please sign in to comment.