jscs-dev / jscs-jsdoc

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

Type expression parses breaks with nested curly braces #20

Closed pigulla closed 10 years ago

pigulla commented 10 years ago

It looks like the code to parse type expressions from the comments does not work properly with nested curly braces:

// test.js
/**
 * @return {{a: number, b: string}}
 */
function foo() {
    return {};
}
// .jscsrc
{
    "additionalRules": [
        "node_modules/jscs-jsdoc/lib/rules/*.js"
    ],
    "jsDoc": {
        "checkTypes": true
    }
}
// jscs --config .jscsrc test.js
Invalid JsDoc type definition at test.js :
     1 |/**
     2 | * @return {{a: number, b: string}}
-----------^
     3 | */
     4 |function foo() {

1 code style error found.

If you look at the string that gets passed to jsDocParseType you will notice that it is {a: number, b: string, so it is missing the closing curly brace.

qfox commented 10 years ago

Ouh, shame on me :( do you want to fix that?

I'll try to fix that today.

pigulla commented 10 years ago

Please, go ahead. Thanks!