This question already has an answer here:
Here's my file: app/scripts/controllers/main.js
"use strict";
angular.module('appApp')
.controller('MainCtrl', ['$scope', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
}]);
My Gruntfile.coffee
has:
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"]
When I run grunt
, I get:
Linting app/scripts/controllers/main.js ...ERROR
[L1:C1] W097: Use the function form of "use strict".
"use strict";
The issue is that if you don't use the function form it applies to everything, and not just your code. The solution to that is to scope
use strict
inside functions you control.Refer to this question: JSLint is suddenly reporting: Use the function form of “use strict”.
Rather than doing
You should be doing
It's either that or wrapping your code in a self-executing closure, like below.
Changed my
Gruntfile.coffee
to includeglobalstrict