4

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?

1

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Oh, I see. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… This tells you how strict mode behaves

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.