eslint识别不了es6反引号?

mod1.js

/**
 * Says hello.
 * @param  {String} name a name
 * @return {String}      a greeting for `name`
 */
export function sayHelloTo( name ) {
  const toSay = `Hello, ${name}!`;

  return toSay;
}

/**
 * Says goodbye.
 * @param  {String} name a name
 * @return {String}      a farewell for `name`
 */
export function sayGoodbyeTo( name ) {
  const toSay = `Later, ${name}!`;

  return toSay;
}

执行命令

wangle@DESKTOP-ANE8VEN MINGW32 /e/md-project/learn-rollup (master)
$ npm run rollup-build

> learn-rollup@1.0.0 rollup-build E:\md-project\learn-rollup
> rollup -c


E:\md-project\learn-rollup\src\scripts\modules\mod1.js
   7:15  error  Strings must use singlequote  quotes
   7:34  error  Strings must use singlequote  quotes
  18:15  error  Strings must use singlequote  quotes
  18:34  error  Strings must use singlequote  quotes

✖ 4 problems (4 errors, 0 warnings)

当我编译的时候报这个错,怎么解决阿?

阅读 8.7k
3 个回答

这不是它不识别的问题,是默认设置的问题;默认只识别单引号
可参见: http://eslint.cn/docs/2.0.0/r...
可以在对应的项目 .eslintrc.js 文件中进行修改;

如果需要用到像这样:let str = 'jeff\jade'(字符串中带有反斜杠)你应该再加一个反斜杠,予以转义。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进