jshint

Why is JSHINT complaining that this is a strict violation?

旧城冷巷雨未停 提交于 2019-11-27 03:47:47
I think this may be a duplicate of Strict Violation using this keyword and revealing module pattern I have this code: function gotoPage(s){ if(s<=this.d&&s>0){this.g=s; this.page((s-1)*this.p.size);} } function pageChange(event, sorter) { var dd = event.currentTarget; gotoPage.call(sorter, dd[dd.selectedIndex].value); } And JSHINT (JSLINT) is complaining. It says "Strict violation." for the highlighted line: Is my use of Function.call() and then referencing the instance, somehow inappropriate? Is this considered to be bad style? JSHint says "Possible strict violation" because you are using

How to disable the warning 'define' is not defined using JSHint and RequireJS

不羁的心 提交于 2019-11-27 02:59:51
I uses RequireJS AMD in my project. When i run jshint on my project, it throws error like In AMD Scripts 'define' is not defined. In Mocha test cases 'describe' is not defined. 'it' is not defined. How to remove this warning in jshint? Just to expand a bit, here's a .jshintrc setup for Mocha: { .... "globals" : { /* MOCHA */ "describe" : false, "it" : false, "before" : false, "beforeEach" : false, "after" : false, "afterEach" : false } } From the JSHint Docs - the false (the default) means the variable is read-only. If you are defining globals only for a specific file, you can do this: /

Prevent JSHint warning that 'functionName is defined but never used'

倖福魔咒の 提交于 2019-11-27 01:00:34
问题 I have just started using JSHint (through the Sublime-Linter package for Sublime Text 2). I would like to suppress its warnings regarding functions that are used before they are defined, as I see no problem with using function definitions like this. For example, the following code generates warnings: (function($){ $(document).ready(function() { formValidationSetup(); refreshErrorMessages(); }); function formValidationSetup() { } function refreshErrorMessages() { } })(jQuery); The warnings:

Should I use JSLint or JSHint JavaScript validation? [closed]

安稳与你 提交于 2019-11-26 18:00:27
I am currently validating my JavaScript against JSLint and making progress on, it's assisting me to write better JavaScript - in particular in working with the Jquery library. I have now come across JSHint , a fork of JSLint . So I am wondering for web applications, which are very much JavaScript was driven, which is the better or most applicable validation tool to work against: JSLint or JSHint? I want to decide now on a validation mechanism and moving forward, use this for client side validation. And Difference between jshint and jslint? Please explain in single javascript example. Links:

Is there a way to suppress JSHint warning for one given line?

本小妞迷上赌 提交于 2019-11-26 11:45:46
问题 I have a (single) case in my app were eval is used, and I would like to suppress JSHint warning only for this case. Is there a way to achieve that? Configuration, magic comment, ...? 回答1: Yes, there is a way. Two in fact. In October 2013 jshint added a way to ignore blocks of code like this: // Code here will be linted with JSHint. /* jshint ignore:start */ // Code here will be ignored by JSHint. /* jshint ignore:end */ // Code here will be linted with JSHint. You can also ignore a single

Why is JSHINT complaining that this is a strict violation?

孤街浪徒 提交于 2019-11-26 10:49:09
问题 I think this may be a duplicate of Strict Violation using this keyword and revealing module pattern I have this code: function gotoPage(s){ if(s<=this.d&&s>0){this.g=s; this.page((s-1)*this.p.size);} } function pageChange(event, sorter) { var dd = event.currentTarget; gotoPage.call(sorter, dd[dd.selectedIndex].value); } And JSHINT (JSLINT) is complaining. It says \"Strict violation.\" for the highlighted line: Is my use of Function.call() and then referencing the instance, somehow

How to disable the warning &#39;define&#39; is not defined using JSHint and RequireJS

℡╲_俬逩灬. 提交于 2019-11-26 10:19:20
问题 I uses RequireJS AMD in my project. When i run jshint on my project, it throws error like In AMD Scripts \'define\' is not defined. In Mocha test cases \'describe\' is not defined. \'it\' is not defined. How to remove this warning in jshint? 回答1: Just to expand a bit, here's a .jshintrc setup for Mocha: { .... "globals" : { /* MOCHA */ "describe" : false, "it" : false, "before" : false, "beforeEach" : false, "after" : false, "afterEach" : false } } From the JSHint Docs - the false (the

Should I use JSLint or JSHint JavaScript validation? [closed]

末鹿安然 提交于 2019-11-26 06:10:05
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 months ago . I am currently validating my JavaScript against JSLint and making progress on, it\'s assisting me to write better JavaScript - in particular in working with the Jquery library. I have now come across JSHint , a fork of JSLint . So I am wondering for web applications, which

Turning off eslint rule for a specific line

一世执手 提交于 2019-11-26 04:02:37
问题 In order to turn off linting rule for a particular line in JSHint we use the following rule: /* jshint ignore:start*/ $scope.someVar = ConstructorFunction(); /* jshint ignore:end */ I have been trying to locate the equivalent of the above for eslint. 回答1: You can use the single line syntax now: var thing = new Thing(); // eslint-disable-line no-use-before-define thing.sayHello(); function Thing() { this.sayHello = function() { console.log("hello"); }; } Or if you don't want to have a comment

JavaScript function order: why does it matter?

我们两清 提交于 2019-11-26 03:47:11
问题 Original Question: JSHint complains when my JavaScript calls a function that is defined further down the page than the call to it. However, my page is for a game, and no functions are called until the whole thing has downloaded. So why does the order functions appear in my code matter? EDIT: I think I may have found the answer. http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting I am groaning inside. Looks like I need to spend ANOTHER day re-ordering six thousand lines of