你如何一起使用JSHint和Browserify? [英] How do you use JSHint and Browserify together?
问题描述
我正在尝试使用Angular和Browserify构建项目。我的 controllers.js
文件看起来像这样......
I'm attempting to build a project using Angular and Browserify. My controllers.js
file looks like this...
'use strict';
module.exports.testController = function($scope){
$scope.message = 'Controller 1';
console.log( 'hello' );
};
如您所料,这会产生三个linting错误。
As you may expect, that generates three linting errors.
- 使用严格的函数形式
- '模块'未定义
- 'console'是未定义
我确实找到了一些解决方案这里使JSHint能够通过在文件顶部放置 jslint node:true
来处理Node.js文件,如下所示
I did find a bit of a solution here that enables JSHint to process Node.js files by putting jslint node: true
at the top of the file like this
/*jslint node: true */
'use strict';
module.exports.testController = function($scope){
$scope.message = 'Controller 1';
console.log( 'hello' );
};
然而,这显然修复了太多; 'console.log(...)'仍然应该是未定义的。
However, that obviously fixes too much; 'console.log(...)' should still be undefined.
有没有人知道如何在Browserify中使用JSHint?
Does anyone know how to use JSHint with Browserify?
推荐答案
自版本 2.5.3 JSHint支持 browserify
标志。
As of version 2.5.3 JSHint supports the browserify
flag.
像所有标志一样,您可以直接在源文件中使用它:
Like all flags you can use it directly in a source file:
/*jshint browserify: true */
// browserify code here
或者将它添加到 .jshintrc
file:
Or add it to a .jshintrc
file:
{
"browserify": true
}
这篇关于你如何一起使用JSHint和Browserify?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!