How to disable “use strict” in JSHint

梦想的初衷 提交于 2019-12-13 02:16:36

问题


I'd like to eliminate the 'Missing "use strict" statement.' warning that JSHint shows in my .js files. Now, I want to keep the rest of the functionality intact, and I want a global way to disable the "use strict;" thing, because inserting the "use strict" command into every file is not an option for me.

I haven't been able to find any solutions that don't involve adding "use strict;" to each file, so I'm hoping this question will point me in the right direction.

Thanks.


回答1:


Just set strict option to false, for more details look http://jshint.com/docs/options/#strict

false - disable warnings about strict mode


This option requires the code to run in ECMAScript 5's strict mode. Strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode eliminates some JavaScript pitfalls that didn't cause errors by changing them to produce errors. It also fixes mistakes that made it difficult for the JavaScript engines to perform certain optimizations.

  • "global" - there must be a "use strict"; directive at global level
  • "implied" - lint the code as if there is the "use strict"; directive
  • false - disable warnings about strict mode
  • true - there must be a "use strict"; directive at function level; this is preferable for scripts intended to be loaded in web browsers directly because enabling strict mode globally could adversely effect other scripts running on the same page


来源:https://stackoverflow.com/questions/37977344/how-to-disable-use-strict-in-jshint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!