jshint

How can I suppress the JSHint “JSCS: Illegal Space” warnings in Visual Studio 2013?

旧街凉风 提交于 2019-12-12 11:29:00
问题 We're using JSHint in a Visual Studio 2013 solution. When building, we are seeing some formatting warnings for items that break style warnings, but are functionally valid. Specifically, I would like to suppress the "Illegal Space" warnings. I consider warnings like this in the build error list visual chaff: JSCS: Illegal space before opening curly brace JSCS: Illegal space before opening round brace Here's why. I'm a fan of using the Visual Studio auto-formatting feature (Ctrl+K+D). In a

Can I prevent passing wrong number of parameters to methods with JS Lint, JS Hint, or some other tool?

本小妞迷上赌 提交于 2019-12-12 10:46:03
问题 I'm new to javascript programming (and scripting languages in general), but I've been using JS Lint to help me when I make syntax errors or accidentally declare a global variable. However, there is a scenario that JS Lint does not cover, which I feel would be incredibly handy. See the code below: (function () { "use strict"; /*global alert */ var testFunction = function (someMessage) { alert("stuff is happening: " + someMessage); }; testFunction(1, 2); testFunction(); }()); Notice that I am

Extending jshint with custom checks

眉间皱痕 提交于 2019-12-12 08:24:28
问题 In the Python world there are multiple static code analysis tools that can be easily extended with custom checks via writing plugins or extensions , for example: pylint flake8 In the JavaScript world, as far as I understand, jshint is the number one tool for static code analysis. I've been using it for a while and it definitely helps to find lots of code style violations, but, recently, I've encountered the need to extend jshint with a custom check. How can I do that? Is it extendable? I've

disallowTrailingComma does not work in jscs

陌路散爱 提交于 2019-12-12 06:07:14
问题 I am using http://jscs.info. I need to get a warning if my app has left trailing comma, example, using: var x = { prop1: 10, prop2: 20, }; I should get a warning. With the following settings: disallowTrailingComma true requireTrailingComma true I cannot get the warning. What I am doing wrong here? { "disallowCommaBeforeLineBreak": null, "disallowDanglingUnderscores": true, "disallowEmptyBlocks": true, "disallowImplicitTypeConversion": [ "string" ], "disallowKeywordsOnNewLine": [ "else" ],

How to get JSHint smarttabs option working in Sublime Text 2

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:34:35
问题 I can't seem to get the Sublime Text 2 SublimeLinter package to stop showing the "Mixed tabs and spaces" warning. I've set "smarttabs" : true in the settings, but it's still not taking. Has anyone else solved this problem yet? Here's my user settings for the SublimeLinter package: https://gist.github.com/3737558 Thanks. 回答1: I solve the problem like this. First do not use mix tabs and spaces in the files. Use spaces only. Sublime can finely handle the indentation without a hard tab character.

How do we not allow hard tabs in my codebase? We are using JSHint

时光总嘲笑我的痴心妄想 提交于 2019-12-11 13:08:05
问题 How do we not allow hard tabs in my codebase? We are using JSHint. I think smarttabs only disallows mixed tabs on the same line. What option should we be using to achieve this? 回答1: JSCS validateIndentation is the relevant option. It corresponds to the (deprecated) JSHint indent option. 来源: https://stackoverflow.com/questions/28897776/how-do-we-not-allow-hard-tabs-in-my-codebase-we-are-using-jshint

JSHint error Don't make functions within a loop

 ̄綄美尐妖づ 提交于 2019-12-11 12:28:34
问题 I'm running some code through JSHint and I keep getting the following error: Don't make functions within a loop. I tried turning off the warning for 'About functions inside loops' off which does nothing to stop the error from being reported. I have decided to refactor the code, using JSHint's suggestions here, http://www.jshint.com/options/ but I'm still getting the error. I was hoping that somebody could help me to refactor this code slightly so it will pass. Here's a copy of the function:

Using JsHint with Angular, ignore angular styles

末鹿安然 提交于 2019-12-11 12:27:24
问题 I am using angular and would like to use JSHint. However, I get a lot of warnings like '$' is not defined. , which would be correct in angular but JSHint does not know this. Is there a way to ignore some certain errors (as this $-error occurs rather often) or is there a better linter for the JS of angular? 回答1: JsHint allows you define globals variables across your source code and a per file basis. You can add a .jshintrc file and put the following snippet which will effect your entire code {

expected identifier instead saw new (a reserved word)

旧街凉风 提交于 2019-12-11 11:54:51
问题 I want to know how can i disable JSHint's checking for this type of declarations, so i can do: obj.new = function(){ //... }; instead of obj['new'] = function(){ //... }; thanks 回答1: You can use the es5 option, since reserved words as property names are only valid as of ES5. Put this directive at the top of the file(s) in question: /*jshint es5: true */ However, it's worth bearing in mind that older browsers will throw errors if they encounter such syntax. If your code needs to run in older

Jshint | Passing default settings | Function declarations and 'this'

旧街凉风 提交于 2019-12-11 09:19:16
问题 for ( element = 0; element < this.tag_array.length; element++ ) { document.getElementById( this.tag_array[element] ).addEventListener( "click", function(){ /* constructor function here */ } ); // jshint.com error #1 } This code will cause an error in jshint.com b.c. it does not want to see functions declared in a loop. However, if I pass in a simple function reference then I can not extract out 'this' with out once again breaking jshint. for ( element = 0; element < this.tag_array.length;