如何在 JSHint 中禁用 "use strict"
How to disable "use strict" in JSHint
我想消除 JSHint 在我的 .js 文件中显示的 'Missing "use strict" statement.' 警告。现在,我想保持其余功能不变,并且我想要一种全局方式来禁用 "use strict;" 东西,因为将 "use strict" 命令插入每个文件对我来说不是一个选项。
我还没有找到任何不涉及向每个文件添加 "use strict;" 的解决方案,所以我希望这个问题能给我指明正确的方向。
谢谢。
只需将 strict
选项设置为 false
,有关详细信息,请查看 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
我想消除 JSHint 在我的 .js 文件中显示的 'Missing "use strict" statement.' 警告。现在,我想保持其余功能不变,并且我想要一种全局方式来禁用 "use strict;" 东西,因为将 "use strict" 命令插入每个文件对我来说不是一个选项。
我还没有找到任何不涉及向每个文件添加 "use strict;" 的解决方案,所以我希望这个问题能给我指明正确的方向。
谢谢。
只需将 strict
选项设置为 false
,有关详细信息,请查看 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