这是我的文件:app/scripts/controllers/main.js
"use strict";
angular.module('appApp')
.controller('MainCtrl', ['$scope', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
}]);我的Gruntfile.coffee有:
jshint:
options:
globals:
require: false
module: false
console: false
__dirname: false
process: false
exports: false
server:
options:
node: true
src: ["server/**/*.js"]
app:
options:
globals:
angular: true
strict: true
src: ["app/scripts/**/*.js"]当我运行grunt时,我得到:
Linting app/scripts/controllers/main.js ...ERROR
[L1:C1] W097: Use the function form of "use strict".
"use strict";发布于 2013-11-12 00:56:13
问题是,如果你不使用函数形式,它适用于所有东西,而不仅仅是你的代码。解决这个问题的方法是在你控制的函数中设置use strict的作用域。
请参考这个问题:JSLint is suddenly reporting: Use the function form of “use strict”。
而不是做
"use strict";
angular.module('appApp')
.controller('MainCtrl', ['$scope', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
}]);你应该做的是
angular.module('appApp')
.controller('MainCtrl', ['$scope', function ($scope) {
"use strict";
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
}]);要么这样,要么将你的代码包装在一个自动执行的闭包中,如下所示。
(function(){
"use strict";
// your stuff
})();发布于 2013-11-12 04:58:55
将我的Gruntfile.coffee更改为包含globalstrict
jshint:
options:
globalstrict: true
globals:
require: false
module: false
console: false
__dirname: false
process: false
exports: falsehttps://stackoverflow.com/questions/19910134
复制相似问题