Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Sheikh Mahmud
51 PointsWhy does the Brackets text editor, which I am using instead of Sublime, give error: must use function 'use strict'?
In line 1 for both the maze and maze spaces JavaScript class, the instructor Randy Hoyt, uses notation "use strict"; and then write the individual function. I do the same on Brackets but my problem is it says error: use function for use strict? I don't know where I went wrong if all I am doing is the same thing that Randy is doing...Please help
4 Answers
Steven Parker
243,318 PointsIt is a "best practice" to invoke "use strict" inside closures (functions) instead of for an entire file. It sounds like your editor has elevated this from a practice to a syntax imperative.
Perhaps there is a configuration parameter you can set to prevent this enforcement, check your documentation.
Sheikh Mahmud
51 PointsDo i need to enable this extension then? On Brackets, it seems to use JSLint error message console to point out "use strict" is needed
Steven Parker
243,318 PointsIt sounds like you might want to disable that extension. It seems to be giving you that error already.
Sheikh Mahmud
51 PointsOkie dokie Steven. Thanks :)
Sheikh Mahmud
51 Pointshttps://github.com/adobe/brackets/issues/9563 This is the site that talks about various JSLint problems. But what I want to know is that what code do I enter in brackets.json. Because in the defaultPreferences.json file, I cannot be able to change the code since it is a read only file. I was thinking if doingL
"language": { "javascript": { "linting.prefer": ["JSHint"], "linting.usePreferredOnly": true } },
would disable JSLint. So do I add this on brackets.json? Thx
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherI believe it might have something to do with an extension called "JSLint". JSLint tends to require the function form of the
use strict;directive which means that the directive will have to be added inside each individual function.