jslint

Jquery and Jslint - '$' was used before it was defined

孤街醉人 提交于 2019-12-17 10:44:23
问题 I have some third party javascript im working with, I added some jquery code into it the javascript file. But it seems to fail on the above code when validating using Jslint '$' was used before it was defined. I can see at the top of the javascript file it states: /*global alert: false, console: false, jQuery: false */ Im relatively new to Javascript, and JQuery, so any help would be welcome. 回答1: Add these options to your comments: /*jslint browser: true*/ /*global $, jQuery, alert*/ 回答2: If

JSLint reports “Unexpected dangling” character in an underscore prefixed variable name

送分小仙女□ 提交于 2019-12-17 10:26:02
问题 I know that some people consider the presence of a leading underscore to imply that a variable is "private," that such privacy is a fiction, and assume this is why JSLint reports such names with an error message. I use Google Analytics on a Web site I am building. I make reference to GA's variables, such as "_gaq." I am trying to get my JS code to be 100% JSLint clean (I'm not religious about my coding style, and so will go with Mr. Crockford's counsel). That said, I can't do anything about

JSLint: Using a function before it's defined error

旧城冷巷雨未停 提交于 2019-12-17 08:56:16
问题 I'm using JSLint to verify most of my external Javascript files, but the largest amount of errors I'm getting is from functions being used before they're defined. Is this really an issue I should worry about ? It seems Firefox, IE7 and Chrome don't care. Functions like the popular init() (which I use often) normally stick at the top as that makes sense to me (I like to pretend it's analogous to main() ) will, according to JSLint, need to be pushed to the bottom of the file. 回答1: If you

JSLint: Using a function before it's defined error

前提是你 提交于 2019-12-17 08:56:07
问题 I'm using JSLint to verify most of my external Javascript files, but the largest amount of errors I'm getting is from functions being used before they're defined. Is this really an issue I should worry about ? It seems Firefox, IE7 and Chrome don't care. Functions like the popular init() (which I use often) normally stick at the top as that makes sense to me (I like to pretend it's analogous to main() ) will, according to JSLint, need to be pushed to the bottom of the file. 回答1: If you

JSLint “insecure ^” in regular expression

我的未来我决定 提交于 2019-12-17 06:49:22
问题 JSLint reports Insecure '^' for the following line. Why is that? Or is it just going to complain any time I want to negate a character class? // remove all non alphanumeric, comma and dash characters "!$7s-gd,&j5d-a#".replace(/[^\w,\-]/g, ''); 回答1: It only will do this if you have the option selected at the bottom: Disallow insecure . and [^...] in /RegExp/ From the docs: true if . and [^...] should not be allowed in RegExp literals. These forms should not be used when validating in secure

(…()) vs. (…)() in javascript closures [duplicate]

戏子无情 提交于 2019-12-17 02:09:29
问题 This question already has answers here : Location of parenthesis for auto-executing anonymous JavaScript functions? (4 answers) Closed 4 years ago . I know this is silly, but there's any difference between this: (function() { var foo = 'bar'; })(); and this? (function() { var foo = 'bar'; }()); JSLint tells us to Move the invocation into the parens that contain the function , but I see no need to. Edit: The answers are too cool. ~function , the JSHint alternative along with jQuery's

Can JsLint be integrated into xCode?

强颜欢笑 提交于 2019-12-13 17:20:40
问题 I'm editing some Javascript files using XCode's editor (I know, you want to ask me why, but bear with me here), and I'd like to have lint run on my edits, regularly. I don't have a real preference - it might be every time the file saves, or on each edit, or, worst case scenario, automatically when I hit the build or run button. Can a setup along these lines be put together? Any pointers? 回答1: You could use the jslint command line utility (installed as a ruby gem) and add a pre-action to your

JSLint says new keyword is missing [duplicate]

久未见 提交于 2019-12-13 12:28:12
问题 This question already has answers here : How to fix JSLint “missing new” error (2 answers) Closed 6 years ago . Let's say I have some JavaScript that looks like this: function A() { var MyVar, SomeParameter; // do work MyVar = FunctionB(SomeParameter); } JsLint says I'm Missing 'new'. at the line MyVar = FunctionB(SomeParameter); Why should I rewrite as MyVar = new FunctionB(SomeParameter); Is there going to be any benefit? 回答1: It is the convention that constructors (eg: Array , Object ) are

Visual Studio 2013 - JSLint.NET installed but not showing in tools?

懵懂的女人 提交于 2019-12-12 19:40:55
问题 I am new to VS. Went to Extensions and installed JSLint.NET, it is also enabled. But I get no item under Tools to configure or use it? 回答1: JSLint.NET is configured on per project basis. Right click on your project and you should see a menu choice for JSLint.NET Project Settings. You can see an example of this on the Visual Studio gallery page for the extension. JSLint.NET Extension 来源: https://stackoverflow.com/questions/21802536/visual-studio-2013-jslint-net-installed-but-not-showing-in

Custom settings with jshint-rhino.js

心不动则不痛 提交于 2019-12-12 19:02:08
问题 I've been using jshint with node but just recently had to switch over to using it with Rhino. I used to be able to do: jshint --config=jsHintConfig.json fileToLint.js Now, I've tried replacing that call with: rhino jshint-rhino.js --config=jsHintConfig.json fileToLint.js But it doesn't seem to work. I only get the following printed to the console: Usage: jshint.js file.js Does jshint-rhino not accept a json configuration file? Update: http://anton.kovalyov.net/2011/03/01/jshint-edition-update