I am working on a Gulp file and I just set JSHint, I see this option in the .jshintrc file:
"strict" : true
then I went to my files I put this at the very beginning:
'use strict';
angular.module('MyApp', ['ngRoute'])
.config(function($locationProvider, $routeProvider) {. . .});
and I now I am getting a new error
public/app.js line 1 col 1 Use the function form of "use strict".
so I did:
angular.module('MyApp', ['ngRoute'])
.config(function($locationProvider, $routeProvider) {
'use strict';
return { . . . }
});
and the error its gone.
So, what is the difference here and what is wrong if I don't use the strict mode?
JSHint by default doesn't allow you to have 'use strict'; at a global scope when set to true, because it will interfere with Javascript libraries and legacy code that isn't designed for strict mode in mind.
Use
strict: 'global'
if you want to be able to do that.
or
strict: false
if you do not want to lint code to require strict mode.
strict option reference for JSHint
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With