jslint

Can JSLint be configured using an external config file in the same manner as JSHint's .jshintrc?

霸气de小男生 提交于 2019-12-02 02:02:18
I've been developing a lot of small web development projects in various IDEs, and find myself laboriously typing in jslint configuration headers to silence JSLint. Its warnings and errors are all valid, and I want to keep JSLint in my work cycle, but I spin up 2-3 isolated environments a day, sometimes from generators in Yeoman, other times by hand. These all end up with gripes from JSLint that require the following in every .js file: /*jslint browser:true*/ /*global require,yada,yada,yada*/ JSHint has a wonderful feature whereby you can declare all these in a parent folder using the body of

Is there a way to make JSLint happy with this regex?

流过昼夜 提交于 2019-12-01 22:38:52
问题 When running my JavaScript through JSLint, I get the following two errors from the same line of code. Problem at line 398 character 29: Insecure '.'. if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) Problem at line 398 character 41: Unescaped '^'. if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) I understand that JSLint may be being "over-cautious". I read the comments on a similar question, Purpose of JSLint "disallow insecure in regex" option. Nonetheless, I would like to have the

Is there a way to make JSLint happy with this regex?

蹲街弑〆低调 提交于 2019-12-01 21:14:18
When running my JavaScript through JSLint, I get the following two errors from the same line of code. Problem at line 398 character 29: Insecure '.'. if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) Problem at line 398 character 41: Unescaped '^'. if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) I understand that JSLint may be being "over-cautious". I read the comments on a similar question, Purpose of JSLint "disallow insecure in regex" option . Nonetheless, I would like to have the best of all worlds, and have a working regular expression that also doesn't cause JSLint to complain.

Getting a JSLint warning concerning labels in Javascript

一世执手 提交于 2019-12-01 20:45:23
In my javascript I have this loopDeLoop: while (foo !== bar) { switch (fubar) { case reallyFubar: if (anotherFoo == anotherBar) { break loopDeLoop; } break; default: break; } } But JSLint says... lint warning: use of label Here's the notes from JSLint Labels JavaScript allows any statement to have a label, and labels have a separate name space. JSLint is more strict. JSLint expects labels only on statements that interact with break: switch, while, do, and for. JSLint expects that labels will be distinct from vars and parameters. How do I construct the above to get rid of the warning? Thanks,

JSLint: used out of scope for ternary variable set

无人久伴 提交于 2019-12-01 20:18:13
问题 I have a code block like this: /*global MYAPP: true*/ var MYAPP = MYAPP || {}; JSLint highlights "MYAPP" after equal sign with message "MYAPP used out of scope". What's wrong with that? 回答1: If you use var then you are declaring a local variable. If you do MYAPP || {} then you are typically trying to set a default value for a global variable, or for a variable declared earlier. What is the scope of MYAPP supposed to be? If it is global, then something like MYAPP = window.MYAPP || {}; window.

JSLint: used out of scope for ternary variable set

六眼飞鱼酱① 提交于 2019-12-01 18:50:55
I have a code block like this: /*global MYAPP: true*/ var MYAPP = MYAPP || {}; JSLint highlights "MYAPP" after equal sign with message "MYAPP used out of scope". What's wrong with that? If you use var then you are declaring a local variable. If you do MYAPP || {} then you are typically trying to set a default value for a global variable, or for a variable declared earlier. What is the scope of MYAPP supposed to be? If it is global, then something like MYAPP = window.MYAPP || {}; window. stops it from complaining that it is undefined If it is not global but declared earlier, then MYAPP = MYAPP

JSLint “out of scope” error due to function ordering?

别说谁变了你拦得住时间么 提交于 2019-12-01 17:59:48
JSLint seems to be picky about function ordering. This passes fine: function a() { 'use strict'; return 1; } function b() { 'use strict'; a(); } While this gives an 'a' is out of scope error message: function b() { 'use strict'; a(); } function a() { 'use strict'; return 1; } Is this by design? Should I care? How can it be avoided in larger (more complex) cases, where it might not always be possible to give the functions a clear order? Juan Mendes JSLint/JSHint expect you to define functions before you reference them. However, JavaScript doesn't care because functions and variables are hoisted

Problems with jslint-v8 Ruby gem installation on Windows7 64-bit

╄→гoц情女王★ 提交于 2019-12-01 10:56:05
There is a problem during Rally App SDK 2.0p environment setup on Windows 7 (64-bit). I have installed Ruby 1.8.7-p358 from rubyinstaller.org and managed to install rake Ruby gem. But I have problems installing jslint-v8 gem. It has dependencies on therubyracer and libv8 gems which need to be built using Ruby DevKit. During the installation I got the following error: C:\ruby> gem install jslint-v8 Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing jslint-v8: ERROR: Failed to build gem native extension. C:/ruby/bin/ruby

Fix JSLint bad escapement warning in RegEx

元气小坏坏 提交于 2019-12-01 10:00:25
问题 I have the following code in a 3rd party jQuery control called jquery.facebox.js that JSLint doesn't like. It's a bad escapement error in a RegEx. Regular expression are like Romulan to me, so I can't see how to fix the error (which is with the period character in the RegEx): var imageTypes = $.facebox.settings.imageTypes.join('|'); $.facebox.settings.imageTypesRegexp = new RegExp('\.(' + imageTypes + ')$', 'i'); 回答1: Add a second \ after '\ . This is a string problem, not a regex problem :-)

“[Variable] was used before it was defined” error

旧城冷巷雨未停 提交于 2019-12-01 08:10:49
问题 I have several of these errors and I am not sure how to "properly" solve it, the thing is that I have many javascript files (Seperated for easier maintainability) and I include plugins et cetera. So in this example I use shortcut which is from http://www.openjs.com/scripts/events/keyboard_shortcuts/ This just defines shortcut to shortcut = {....... then when I in my code use it like shortcut.add("F1", function () { showDialog(); }, { 'type': 'keydown', 'propagate': false, 'target': editor