【问题标题】:"Use the function form of "use strict" when using Gulp + Babel + JsHint"使用 Gulp + Babel + JsHint 时使用 "use strict" 的函数形式
【发布时间】:2015-11-29 18:38:08
【问题描述】:

我收到此警告:

"Use the function form of "use strict"

当 gulp 观看我的 js 文件时。

如何解决这个问题? 我正在使用 gulp、gulp-babel 和 gulp-jshint。

代码示例:

.pipe( babel() )
.pipe( jshint( ".jshintrc" ) )

我没有在我的代码上写 'use strict'。它是由 babel 生成的。

【问题讨论】:

  • 只是不要使用 jshint。或者更确切地说,将它您的babel() 之前通过管道传输。您应该对 ES6 代码进行 lint,而不是转译器生成的代码。
  • gulp-jshint 适用于所有 ES6 规范?
  • @Patric:我不知道——试试看。如果没有,请检查文档(可能需要一个标志),也许 a) 将其作为错误报告归档 b) 使用不同的 linter。

标签: javascript gulp jshint babeljs


【解决方案1】:

重申一下 Bergi 在 cmets 中所说的话,您不应该对不是您编写的代码进行 linting。您应该切换顺序并使用 babel before 运行 jshint。

【讨论】:

    猜你喜欢
    • 2012-02-15
    • 2016-12-15
    • 1970-01-01
    • 2015-05-13
    • 2015-01-22
    • 2015-05-29
    相关资源
    最近更新 更多