jshint

JSHint behave differently in Webstorm and Grunt

佐手、 提交于 2019-12-01 01:05:43
I have created a new service with Grunt using the angular-generator and then reformatted the code with WebStorm Ctrl + ALT + L as the tabs / spaces seem to be different. Then when using Grunt and the task JShint complains I get the following errors: app/scripts/services/poteservice.js line 11 col 13 Expected '}' to have an indentation at 15 instead at 13. line 14 col 13 Expected '}' to have an indentation at 15 instead at 13. Another strange issue is that I found that I can enabled JSHint inside WebStorm but then I get issues like JSHINT: angular not defined and Use the function form of use

JSHint behave differently in Webstorm and Grunt

与世无争的帅哥 提交于 2019-11-30 19:31:36
问题 I have created a new service with Grunt using the angular-generator and then reformatted the code with WebStorm Ctrl + ALT + L as the tabs / spaces seem to be different. Then when using Grunt and the task JShint complains I get the following errors: app/scripts/services/poteservice.js line 11 col 13 Expected '}' to have an indentation at 15 instead at 13. line 14 col 13 Expected '}' to have an indentation at 15 instead at 13. Another strange issue is that I found that I can enabled JSHint

how could I reduce the cyclomatic complexity?

痴心易碎 提交于 2019-11-30 17:39:38
Whenever I lint a piece of code I'm working on I get the This function's cyclomatic complexity is too high. (7) . But I'm a bit confused on how I could rewrite it in such way so it works. This would be the function that keeps throwing that message: function () { var duration = +new Date() - start.time, isPastHalf = Number(duration) < 250 && Math.abs(delta.x) > 20 || Math.abs(delta.x) > viewport / 2, direction = delta.x < 0; if (!isScrolling) { if (isPastHalf) { if (direction) { this.close(); } else { if (this.content.getBoundingClientRect().left > viewport / 2 && pulled === true) { this.close(

How do you use JSHint and Browserify together?

大城市里の小女人 提交于 2019-11-30 11:50:07
I'm attempting to build a project using Angular and Browserify. My controllers.js file looks like this... 'use strict'; module.exports.testController = function($scope){ $scope.message = 'Controller 1'; console.log( 'hello' ); }; As you may expect, that generates three linting errors. Use the function form of Strict 'module' is not defined 'console' is not defined I did find a bit of a solution here that enables JSHint to process Node.js files by putting jslint node: true at the top of the file like this /*jslint node: true */ 'use strict'; module.exports.testController = function($scope){

How do you use JsHint “.jshintrc” file with Visual Studio 2013 Web Essentials extension?

和自甴很熟 提交于 2019-11-30 11:37:41
I have installed the "Web Essentials" extension into Visual Studio 2013. I am now getting JSHint warnings appearing in my "Error List" window under the Messages section. However, it is complaining about some global variables that it thinks are not defined. From what I read, you can use JSHint's .jshintrc file to list global variables so it will stop complaining about them. I want to have it set up as follows. (so that it will stop complaining about "ko"... which is a KnockoutJs global variable.) "globals": { "$": false, "jQuery": false, "ko": false } How and where are you supposed to create

Why does jshint not recognize an assignment as an expression?

耗尽温柔 提交于 2019-11-30 08:13:49
How do I need to modify these lines to make jshint happy? An assignment is an expression. Why doesn't jshint understand this? Obviously the interpreter does. Line 572: while(bookmark_element=bookmark_list[iterator++]) Expected a conditional expression and instead saw an assignment. Line 582: while(bookmark_element=bookmark_list[iterator++]) Expected a conditional expression and instead saw an assignment. Line 623: while(element_iterator=element_iterator.nextSibling) Expected a conditional expression and instead saw an assignment. If you really want to listen to JSHint, convert the expression

JSHint thinks Jasmine functions are undefined

喜夏-厌秋 提交于 2019-11-30 05:46:56
I've got a Grunt setup which uses Karma+Jasmine and JSHint. Whenever I run JSHint on my spec file, I get a series of "undefined" errors, most of which are for Jasmine's built-in functions. For example: Running "jshint:test" (jshint) task js/main.spec.js 3 |describe("loadMatrix()", function() { ^ 'describe' is not defined. 4 | it("should not assign a value if no arg is passed.", function() { ^ 'it' is not defined. (I also get some undefined errors for the variables and functions from the JS file that my spec is meant to test against, but I'm not sure why that is and it may be a separate issue.)

How to integrate syntax check in Ace Editor using custom mode?

我只是一个虾纸丫 提交于 2019-11-30 02:35:02
问题 I'm new to ace-editor and I have included custom mode to validate my code and every line should end up with semicolon, If semicolon is not present in my query by mistake then the editor should gives up the warning like "Missing Semicolon". define('ace/mode/javascript-custom', [], function(require, exports, module) { var oop = require("ace/lib/oop"); var TextMode = require("ace/mode/text").Mode; var Tokenizer = require("ace/tokenizer").Tokenizer; var ExampleHighlightRules = require("ace/mode

how could I reduce the cyclomatic complexity?

╄→гoц情女王★ 提交于 2019-11-30 01:50:53
问题 Whenever I lint a piece of code I'm working on I get the This function's cyclomatic complexity is too high. (7) . But I'm a bit confused on how I could rewrite it in such way so it works. This would be the function that keeps throwing that message: function () { var duration = +new Date() - start.time, isPastHalf = Number(duration) < 250 && Math.abs(delta.x) > 20 || Math.abs(delta.x) > viewport / 2, direction = delta.x < 0; if (!isScrolling) { if (isPastHalf) { if (direction) { this.close();

Expected an assignment or function call and instead saw an expression

断了今生、忘了曾经 提交于 2019-11-29 23:42:44
I'm totally cool with this JSLint error. How can I tolerate it? Is there a flag or checkbox for it? You get it when you do stuff like: v && arr.push(v); as opposed to: if (v) { arr.push(v); } Both do the same exact thing. If you put: window.test = function(v) { 'use strict'; var arr = []; if (v) { arr.push(v); } return arr; }; into the minifier it minifies down to this anyway: window.test=function(a){var b=[];a&&b.push(a);return b}; I don't think JSLint has an option to turn that off. JSHint (a fork with more options) has an option for it, though: The expr option, documented as "if