如何禁用“严格使用"在JSHint [英] How to disable "use strict" in JSHint

查看:148
本文介绍了如何禁用“严格使用"在JSHint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想消除缺少严格使用"的声明".警告JSHint在我的.js文件中显示.现在,我想保持其余功能不变,并且我想要一种全局的方式来禁用"use strict;".事情,因为在每个文件中插入使用严格"命令对我来说不是一种选择.

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.

我找不到任何不涉及添加"use strict;"的解决方案.到每个文件,所以我希望这个问题能为我指明正确的方向.

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.

谢谢.

推荐答案

只需将strict选项设置为false,有关更多详细信息,请参见 http://jshint.com/docs/options/#strict

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

false-禁用有关严格模式的警告

false - disable warnings about strict mode


此选项要求代码在ECMAScript 5的严格模式下运行. 严格模式是选择加入JavaScript的受限变体的一种方式. 严格模式消除了一些没有引起的JavaScript陷阱 通过更改它们以产生错误来纠正错误.它还修复了错误 使JavaScript引擎难以执行某些操作 优化.

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.

  • 全局"-必须有一个严格使用";全球一级的指令
  • 暗示"-仿佛存在"use strict"的代码;指令
  • false-禁用有关严格模式的警告
  • true-必须有一个使用 严格";功能级别的指令; 这对于打算在Web中加载的脚本是更可取的 直接浏览器,因为在全局启用严格模式 可能会对在同一脚本上运行的其他脚本产生不利影响 页面
  • "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

这篇关于如何禁用“严格使用"在JSHint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆