Question

For example, I have the following script "test.js":

/**
 * Adds two numbers.
 * @param {number} a First number.
 * @param {number} b First number.
 * @return {number} Sum of two numbers.
 */
function add(a, b) {
  return a + b;
}

var sum = add(1, 2);
var sum1 = add(1, 2, 4);
var sum2 = add('1', '2');

The function "add" is annotated by jsdoc. It accepts two numbers. I would like to check the input parameters by gjslint.

gjslint --strict --jslint_error "all" --jsdoc test.js

I expect to see 2 errors for lines where sum1 (3 input parameters) and sum2 (2 string parameters) are calculated. But the tools says "1 files checked, no errors found."

Was it helpful?

Solution

I have not used the Closure Linter, but I believe that is more used for style issues - missing semicolons and such (adherence to http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml)

The Closure Compiler, however, will give a JSC_WRONG_ARGUMENT_COUNT warning for the use case above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top