jslint

JSLint: Unexpected assignment expression

放肆的年华 提交于 2020-07-03 11:52:07
问题 I get this warning: Unexpected assignment expression. return task.completed = true; // Line 63, Pos 39 When using this code: completeAll: function () { this.tasks = this.tasks.filter(function (task) { return task.completed = true; }); } Why? And how else could I write this expression to avoid JSLint throwing warnings? P.S. The codeblock is taken from the Vue TodoMVC Example here: http://todomvc.dev/examples/vue/, therefore I assume that code review must have already been happened. 回答1: It's

Suppress “Expected '===' and instead saw '=='.” error in jslint

懵懂的女人 提交于 2020-06-07 13:38:05
问题 How can I stop the error message Expected '===' and instead saw '=='. from appearing in jslint. Doesn't seem to be an option. 回答1: For those using JSHint, you can turn off this warning by setting the option eqeqeq to false in your JSHint options (usually .jshintrc ) "eqeqeq": false From the documentation: http://jshint.com/docs/options/#eqeqeq Edit: If you want to be a good citizen and fix your code to use the recommended comparison instead of turning the warning off, make sure both sides of

最小化/解压缩JavaScript的工具[关闭]

最后都变了- 提交于 2020-02-28 05:07:12
关闭。 这个问题是 题外话 。 它当前不接受答案。 想改善这个问题吗? 更新问题 ,使其成为Stack Overflow 的主题 。 5年前 关闭。 是否有任何命令行脚本和/或在线工具可以逆转缩小效果,类似于Tidy如何清除可怕的HTML? (我特别希望缩小压缩的JavaScript文件的大小,因此变量重命名可能仍然是一个问题。) #1楼 得到它了! JSBeautifier 正是这样做的,您甚至可以选择自动格式设置。 #2楼 与 Stone 的答案类似,但对于Windows / .NET开发人员: 如果您拥有Visual Studio和ReSharper-一种格式化Javascript的简单替代方法是: 使用Visual Studio打开文件; 单击“ ReSharper”>“工具”>“清理代码”(Ctrl + E,C); 选择“默认:重新设置代码格式”,然后单击“确定”。 开裂啤酒。 #3楼 漂亮的DIFF 会美化(代码)的JavaScript的方式,符合 JSLint的 和 JSHint 空白算法。 #4楼 http://unminify.appspot.com/ 统一javascript和json的绝佳工具 #5楼 作为一种替代方法(因为到目前为止我还不了解jsbeautifier.org),我使用了一个书签小书签,该书签小书签重新启用了Dean Edward's

如何在JavaScript中初始化数组的长度?

社会主义新天地 提交于 2020-02-26 02:36:00
我阅读过的有关JavaScript数组的大多数教程(包括 w3schools 和 devguru )都建议您可以通过使用 var test = new Array(4); 将整数传递给Array构造函数来初始化具有一定长度的数组 var test = new Array(4); 句法。 在我的js文件中自由使用此语法后,我通过 jsLint 运行了其中一个文件,结果很 糟糕 : 错误:第1行第22个字符处出现问题:预期为“)”,而是看到了“ 4”。 var test = new Array(4); 第1行第23个字元的问题:预期为';' 而是看到')'。 var test = new Array(4); 第1行第23个字符处的问题:需要一个标识符,而看到了')'。 阅读完 jsLint对其行为的解释之后 ,看起来jsLint并不真正喜欢 new Array() 语法,而是在声明数组时更喜欢 [] 。 所以我有几个问题。 首先,为什么? 通过使用 new Array() 语法是否会冒任何风险? 我应该注意浏览器的不兼容性吗? 其次,如果我切换到方括号语法,是否有任何方法可以声明一个数组并将其长度全部设置在一行上,或者我必须执行以下操作: var test = []; test.length = 4; #1楼 如上所述,使用 new Array(size) 有点危险。 而不是直接使用它

JSLint and the “Expected to see a statement and instead saw a block.” error

丶灬走出姿态 提交于 2020-02-23 04:30:42
问题 I have picked up the habit of wrapping all of my case statements in curly brackets from programming in C because of this but JSLint is throwing a fit. It stops validating at that point. My question is: Is this such a bad practice in JS? Do I not have to worry about the scope issue because JS has function scope (I understand how that would be the case, I just want a good reason not to be 'consistent' on this)? (I know that different languages call for different practices, but i am trying to be

Why does not JSLint allow “var” in a for loop?

我是研究僧i 提交于 2020-02-14 19:54:19
问题 Something is wrong with my code or with plovr. I went to JSLint to get some help. However, JSLint seems to consider this as a fatal error and refuses to check more of the code: for (var i = 0; i < data.length; i += 4) { Why? I like this way of declaring "I". JSHint does not seem to be an alternative if you are on Windows. I am trying The Online Lint at the moment. I have a feeling that this bug will be a bit difficult to find so I would be glad for suggestions about good code checkers. 回答1: I

Why does not JSLint allow “var” in a for loop?

强颜欢笑 提交于 2020-02-14 19:47:03
问题 Something is wrong with my code or with plovr. I went to JSLint to get some help. However, JSLint seems to consider this as a fatal error and refuses to check more of the code: for (var i = 0; i < data.length; i += 4) { Why? I like this way of declaring "I". JSHint does not seem to be an alternative if you are on Windows. I am trying The Online Lint at the moment. I have a feeling that this bug will be a bit difficult to find so I would be glad for suggestions about good code checkers. 回答1: I

How to run JSLint / JSHint in a file with templates?

こ雲淡風輕ζ 提交于 2020-02-03 09:49:40
问题 I'm trying to introduce some tools at work to improve code quality. An obvious solution that I'd used at a previous company was to run jslint before checking in code. The problem is that we are using Django to do our templating (though, I assume we would have a similar problem with other templating languages). How is it possible to take code like the below, and have it JSLint/JSHint properly while ignoring the template tags? var a = { "test" : "test"}; {% comment %} {% endcomment %} {{ my

How to run JSLint / JSHint in a file with templates?

匆匆过客 提交于 2020-02-03 09:49:17
问题 I'm trying to introduce some tools at work to improve code quality. An obvious solution that I'd used at a previous company was to run jslint before checking in code. The problem is that we are using Django to do our templating (though, I assume we would have a similar problem with other templating languages). How is it possible to take code like the below, and have it JSLint/JSHint properly while ignoring the template tags? var a = { "test" : "test"}; {% comment %} {% endcomment %} {{ my

How do I turn off JSLint in Visual Studio 2017?

佐手、 提交于 2020-01-16 17:26:36
问题 I loaded up an older aspnet mvc project in Visual Studio 2017, and I can't build it because thousands of warnings/errors from jslint are telling me that the jQuery package has bad bracket placement, among many other things. Frankly, I don't care about any of the errors from jslint, least of all the jQuery errors. I can't find any options for jslint in the GUI. Right-clicking on the project gives no jslint context menu It doesn't seem to exist in Tools > Options I tried this solution, of