意外的令牌在ES6模板字符串上是非法的
JSDoc 3.3.3 Unexpected token ILLEGAL on ES6 template string tick mark
在终端中,我运行以下命令:
$ 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.
我的sample.js文件看起来像这样:
/** @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}` );
jsdoc的conf.json是这样的:
{
"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
}
}
是否有办法配置jsdoc 3.3.3容忍ES6模板字符串?也许有一个插件可以工作?
主分支中的jsdoc使用不同的解析器,这可以更好地处理es6:
npm install git+https://github.com/jsdoc3/jsdoc.git
对我来说工作得很好,我将切换到3.4.0版本
通过使用npm install安装esprima 2.6.0并将该目录从node_modules/esprima复制到node_modules/jsdoc/node_modules/esprima(覆盖过时的1.2.6 esprima版本),jsdoc能够解析'标记并发出警告。
我知道从esprima的v1跳到v2是一个突破性的变化,但它为我完成了工作。
相关文章:
- 如何在JavaScript中将字符串转换为函数引用
- jQuery中是否内置了任何字符串格式化函数
- Javascript,有没有一种方法可以将数组写成没有逗号或空格的单个文本字符串
- ng打开空字符串
- 正则表达式在字符串中找到base64
- 如何将字符串值从php页面发送到java脚本页面
- 子字符串/正则表达式以获取字符串中保存的 SRC 值
- 在实现基本Sharethis代码时指定了无效或非法的字符串
- 为什么我得到“;非法字符语法错误未终止的字符串文字“;当我使用javascript时
- 铬 - 意外令牌 非法.火狐和.字符串文字
- WebSocket 语法错误:指定了无效或非法的字符串
- gap.client.load未调用回调:在console.log中指定了一个无效或非法的字符串
- SyntaxError:非法的返回语句-正在url中搜索字符串
- 意外的令牌在ES6模板字符串上是非法的
- 为什么在ajax上发送的HTML字符串中,尾行字符是非法的?
- 将非法字符串保存在隐藏输入中
- 避免在字符串赋值时意外令牌非法
- 通过模板工具箱从多行字符串中获得的意外令牌是非法的
- 未捕获的SyntaxError:意外的令牌非法和SyntaxError:未终止的字符串文字
- 将javascript字符串中的非法字符替换为合法字符