Search code examples
javascriptnode.jsjsdocjsdoc3

JSDoc 3.3.3 Unexpected token ILLEGAL on ES6 template string tick mark


In a terminal, I run the following commands:

$ node sample.js
hello, Stephen MC
$ node_modules/.bin/jsdoc --version
JSDoc 3.3.3 (Tue, 22 Sep 2015 23:14:17 GMT)
$ node_modules/.bin/jsdoc -c jsdocConf.json
Parsing /**/sample.js ...ERROR: Unable to parse /**/sample.js: Line 14: Unexpected token ILLEGAL
complete.
Generating output files...complete.
Finished running in 0.29 seconds.

My sample.js file looks like this:

/** @module myjsdoc/sample */

"use strict";

const me = "Stephen MC";

/** This function logs the parameter.
 * @param {string} param - The string to log.
 */
const myFunc = function ( param ) {
  console.log( param );
};

myFunc( `hello, ${me}` );

My conf.json for jsdoc looks like this:

{
    "tags": {
        "allowUnknownTags": true,
        "dictionaries": ["jsdoc","closure"]
    },
    "source": {
        "include": [ "./" ],
        "exclude": [ "documentation", "node_modules" ],
        "includePattern": ".+\\.js(doc)?$",
        "excludePattern": "(^|\\/|\\\\)_|.+[Ss]pec\\.js"
    },
    "templates": {
        "cleverLinks": false,
        "monospaceLinks": false
    },
    "opts": {
      "destination": "./documentation/",
      "readme": "./README.md",
      "recurse": true,
      "verbose": true
    }
}

Is there any way to configure jsdoc 3.3.3 to tolerate ES6 template strings? Perhaps there is a plugin that might work?


Solution

  • jsdoc in master branch uses different parser, which handles es6 better:

    npm install git+https://github.com/jsdoc3/jsdoc.git

    works nicely for me, I'll switch back with release of version 3.4.0