jslint

How do I change Eclipse to use spaces instead of tabs in Javascript editor?

Deadly 提交于 2019-12-04 15:41:17
问题 I use the Eclipse JavaScript plugin, I have my text editor settings to "insert spaces as tabs" this works fine until I select a block of code and tab it or shift tab it, run JSLint and AARGghh! "Mixed spaces and tabs." is there something I am missing, is this possible? 回答1: I am not exactly sure where you set the editor property "insert spaces as tabs". To set the tab policy you need to go to Window > Preferences > Javascript > Code Style > Formatter , create a new profile, edit it and set

Unexpected 'continue'

雨燕双飞 提交于 2019-12-04 15:40:38
问题 I have: while (i < l) { if (one === two) { continue; } i++; } But JSLint says: Problem at line 1 character 20: Unexpected 'continue'. if (one === two) { continue; } What mistake did I make? How should my code really look? 回答1: From the JSLint docs: continue Statement Avoid use of the continue statement. It tends to obscure the control flow of the function. So take it out entirely if you want to conform to the conventions that JSLint follows. 回答2: What JSLint actually tries to say is to invert

Empty functions in Javascript

血红的双手。 提交于 2019-12-04 15:15:13
问题 If I have something like this: var blah = function() { }; and then later in code blah is being used, what is the JSLint hint that says remove the empty block? 回答1: I don't know what jsLint thinks but if this is a problem and you need a solution then you can do something like the following: var blah = function() { return undefined; }; // or just return; Update : I think, Bergi 's guess is right because, on the jslint site in the Required Blocks section : JSLint expects that if, while, do and

JSLint validation for Javascript with JQuery

╄→гoц情女王★ 提交于 2019-12-04 13:14:57
I am using JavaScript patterns with JQuery. I want JSLint to validate my code with maximum code quality. I have below screen shot for JSLint option to enable. Someone tell me what option should I check when coding JavaScript with JQuery. Please Check the assume a browser checkbox and on the Predefined section, type jQuery and $ . 来源: https://stackoverflow.com/questions/10557583/jslint-validation-for-javascript-with-jquery

What is the JSLint approved way to convert a number to a string?

Deadly 提交于 2019-12-04 09:55:13
问题 I've always converted numbers to strings by adding an empty string to them: var string = 1 + ''; However, JSLint complains of this method with Expected 'String' and instead saw ''''. , and it does look a little ugly. Is there a better way? 回答1: I believe that the JSLint approved way is to call .toString() on the number: var stringified = 1..toString(); // Note the use of the double .. to ensure the the interpreter knows // that we are calling the toString method on a number -- // not courting

jslint - Don't make functions within a loop

夙愿已清 提交于 2019-12-04 09:47:52
Refering to this topic: Don't make functions within a loop. - jslint error How would you handle a jquery .each(function () {...} within a for loop? knowing that i need the context of the "for" in my "each" function. Sure I could map every required to parameters to a function a function declared outside of the loop but from my perspective, it impacts the readability. Any thoughts? Thanks in advance. ruffin Well, you can keep the context of the for in your loop, as everything in the for is actually in the same context as a function declared at the start. So let's take Frits' example, but first

Is there an offline version of JSLint for Windows?

亡梦爱人 提交于 2019-12-04 09:07:22
问题 I would like to check my JavaScript files without going to JSLint web site. Is there a desktop version of this tool for Windows? 回答1: From http://www.jslint.com/lint.html: The analysis is done by a script running on your machine. Your script is not sent over the network. It is also available as a Konfabulator widget. You can check a file by dragging it and dropping it on the widget. You can recheck the file by double-clicking the widget. It is also available in a WSH Command Line version. It

JavaScript: JSLint throws "Read Only

北战南征 提交于 2019-12-04 08:55:08
问题 My code: note: the Slider Object is declared but omitted in the snippet below for better readability "use strict"; /*global arrayContainer, SliderInstance, DomObjects */ arrayContainer = new Slider.constructArray(); SliderInstance = Object.beget(Slider); DomObjects = { animationContainer: document.getElementById('animationContainer'), buttonRight: document.getElementById('buttonRight'), buttonRightDots: document.getElementById('buttonRightDots'), ieEffectImg: document.getElementById('ie

JSLint reports unexpected use of '&' and '|' — I'd like to clean this

走远了吗. 提交于 2019-12-04 07:53:37
问题 I'm trying to get my Javascript code 100% JSLint clean. I've got some JS code that I've lifted from elsewhere to create a UUID. That code has the following line: s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); This line incites JSLint to generate two error messages: 1) Unexpected use of '&' 2) Unexpected use of '|' I don't understand why -- I'd appreciate counsel regarding how to recode to eliminate the error message. 回答1: The reason "why" is that actual bitwise operations are exceedingly

Suppress `Expected an identifier and instead saw 'default' (a reserved word)` in JSLint with Mongoose

五迷三道 提交于 2019-12-04 06:26:51
I'm using jshint to validate my JavaScript files. On the server-side I'm using node.js with Mongoose. In Mongoose I'm encouraged to write schemata in a fashion like: var UserSchema = new mongoose.Schema({ firstname : { type: String, default: '' } }); When running linting, I get error: Expected an identifier and instead saw 'default' (a reserved word). Is there a way to suppress this error? I really would prefer that behaviour instead of writing: var UserSchema = new mongoose.Schema({ firstname : { type: String, "default": '' } }); You can also use the "es5" option to disable this from