jscs-dev / jscs-jsdoc

JsDoc validation rules for jscs
MIT License
99 stars 35 forks source link

check default values #100

Open AlexanderZeilmann opened 9 years ago

AlexanderZeilmann commented 9 years ago

One thing, which came to my mind while thinking about #96, is the checking of default values. The following snippet should raise an error:

/**
 * Function with wrong default value
 *
 * @param {number} [a = 17] - This parameter has the wrong default value
 * @return {number} description
 */
var test = function (a = 42) {
  return a;
}

Thoughts?

qfox commented 9 years ago

Yeah, it should.

What about denying default values in docs if it exists in code?

AlexanderZeilmann commented 9 years ago

Why do you want to disallow default values in the docs, if they exist in code? Shouldn't they then be required in the docs? I am a bit confused...

My plan introducing a new rule named checkDefaultValues which does something like:

qfox commented 9 years ago

@alawatthe Yeah, it was a bad idea. You're going right, I like your plan :+1:

And of course the other way round, if there is a default value in the docs, there should be one in the code. If not, throw an error.

This one should works only in ES6+, of course. The rest is good to me.

Not sure what we decide about default mode but looks like we should pass these: https://github.com/jscs-dev/node-jscs/blob/master/lib/config/configuration.js#L167-L178

dtracers commented 9 years ago

you could have each bullet point as 3 different options passed in.

one option for each bullet point. That way we can worry about the issues each one causes separably.

And so people who do not have ES6 won't have to worry about their code failing to pass.