jscs-dev / jscs-jsdoc

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

[Question] easiest way to give number as an option #113

Open dtracers opened 9 years ago

dtracers commented 9 years ago

I am making the new rule for description style for params and basically I want them to either put a string or an object that contains a number.

ex:

validTagDescription: "single-line"

or

validTagDescription: { spaces: 10 }

I did not know if there was a way to put in the valid values space like

validTagDescription: { allowedValues: ['single-line', { spaces: '#' }]

or something that represents the number type?

I saw that the check annotations just did the check by hand and then stored a value locally.

Also I do not want to allow true as it does not make sense as to what the default should be (but false is allowed obviously)

qfox commented 9 years ago

There were no real use-cases for Numbers so I've left them to the further researches. In the JSCS repo we thinking about some schema: https://github.com/jscs-dev/node-jscs/issues/895

I think it can be a function for a while with a pure checking like: function (v) { return typeof v === 'number' || v === true; }