eslint/doctrine

Optional parameter

cwgreene opened this issue · 1 comments

What version are you using?

Version on 'https://tonicdev.com/npm/doctrine'

Tested locally with following using 1.2.2

  1 var doctrine = require("doctrine")                                                                                                                                                                               
  2 
  3 var ast = doctrine.parse(
  4     [
  5         "/**",
  6         " * This function comment is parsed by doctrine",
  7         " * @param {string} [doom] - doom",
  8         "*/"
  9     ].join('\n'), { unwrap: true});
 10 console.log(JSON.stringify(ast));

What JSDoc comment were you trying to parse?

/**
 * @param {string} [somebody] - Somebody's name.
 */

What Doctrine options were you using (sloppy, unwrap, etc.)?
unwrap: true

sloppy will parse it.

What happened? Include output if possible.

{ description: 'This function comment is parsed by doctrine',
  tags: [] }

With 'sloppy':

{
  "description": "This function comment is parsed by doctrine",
  "tags": [
    {
      "title": "param",
      "description": "doom",
      "type": {
        "type": "OptionalType",
        "expression": {
          "type": "NameExpression",
          "name": "String"
        }
      },
      "name": "doom"
    }
  ]
}

What did you expect to happen?
Non-sloppy mode to parse it, and in both cases, mark the parameter as 'optional'.

Reference to jsdoc

http://usejsdoc.org/tags-param.html

So other issues seem note that 'sloppy' is actually the way that jsdoc3 support is handled. This is very confusing. However, since sloppy marks the parameter as "OptionalType", I guess this resolves the issue.

(Updated description to accurately show output of sloppy, I follishly forgot to convert to JSON the first time).