jslint

JSLint error: Expected 'ignore' and instead saw 'ex'

前提是你 提交于 2019-11-29 09:11:22
I use JSLint all the time, but just today, I came across an error that I've never seen before. With the following code, I got the error shown below: try { document.execCommand('BackgroundImageCache', false, true); } catch (ex) {} Error: Expected 'ignore' and instead saw 'ex'. } catch (ex) {} So I changed my code to the following, and the error went away: try { document.execCommand('BackgroundImageCache', false, true); } catch (ignore) {} I can't find any explanation on the Internet regarding why this would fix the error. Does anyone know what's up or why this fixed the problem? Thank you.

Justifying Crockford claims

久未见 提交于 2019-11-29 06:37:03
问题 I have read Crockford's JavaScript: The Good Parts and have used his validator JSLint. I am sometimes left wondering the justification behind his recommendations. Below is a list of examples I want substantiated. Why does JSLint signal an error if you don't include "use strict"; ? [See this SO thread.] Why should variable declarations within a function be done using a single var ? [See this SO thread.] Why do we need to put a space between function and () in function () ? Why can't we use

Unexpected token operator «=», expected punc «,»

我与影子孤独终老i 提交于 2019-11-29 06:11:19
i am getting the following error Parse error: Unexpected token operator «=», expected punc «,» Line 159, column 26 This is my code function fitBounds(type="all", shape=null) { var bounds = new google.maps.LatLngBounds(); if ( type == "all" ){ if ((circles.length > 0) | (polygons.length > 0)){ $.each(circles, function(index, circle){ bounds.union(circle.getBounds()); }); $.each(polygons, function(index, polygon){ polygon.getPath().getArray().forEach(function(latLng){ bounds.extend(latLng); }); }); } } else if ( (type == "single") && (shape != null) ) { if (shape.type == google.maps.drawing

How come JQuery doesn't pass JSLint? [duplicate]

我与影子孤独终老i 提交于 2019-11-29 05:43:08
Possible Duplicate: What good is JSLint if jQuery fails the validation http://code.jquery.com/jquery-1.4.4.js Go to there and paste it in www.jslint.com Isn't Jquery supposed to be valid.... It's far too much work to comply with it AND be cross-browser compliant. JSLint is useful but its only a generic parser. jQuery has good reasons to throw errors in it. Sometimes you just need simple dirty hacks to get code working in non-compliant browsers. let's look at them one by one : Problem at line 231 character 20: Expected '===' and instead saw '=='. return num == null ? Here jquery uses == on null

Is JSLint available for offline use?

筅森魡賤 提交于 2019-11-29 05:34:03
问题 I'd like to use JSLint, but I am wary of tools that have access to my unfiltered source code. Is there an offline version or is there another similar tool that does " lint error checking" for JavaScript offline? Edit: One with a GUI and that shows you a styled list of errors, instead of a command line interface? 回答1: If you like the JSLint web interface, you can do File > Save Page As... and Save as type: Web Page, complete (in Firefox, doing it in Internet Explorer may be slightly different)

How can I change jslint(VS 2010 extension) to ignore files?

五迷三道 提交于 2019-11-29 05:28:30
I have js lint installed in Vs 2010 as a extension through the extension manager. It finds lots of errors but they are all from external plugins or from the jquery library. I am not going to go and fix stuff in an external plugin or jquery file. So how can I get it to not check these files? I am also wondering how can I get it to ignore checking href links. I am using asp.net mvc so my links are like this <a href="/account/reg">reg </a> So it can't find this path as it is the path to the controller action method not a file. So how can I get it to not look at these? Thanks You can exclude files

How do I safely “eval” user code in a webpage?

浪子不回头ぞ 提交于 2019-11-29 03:56:17
I'm working on a webapp to teach programming concepts. Webpages have some text about a programming concept, then let the user type in javascript code into a text editor window to try to answer a programming problem. When the user clicks "submit", I analyse the text they've typed to see if they have solved the problem. For example, I ask them to "write a function named f that adds three to its argument". Here's what I'm doing to analyse the user's text: Run JSLint on the text with strict settings, in particular without assuming browser or console functions. If there are any errors, show the

Have jshint ignore certain files when building Twitter Bootstrap

独自空忆成欢 提交于 2019-11-29 02:07:11
问题 I often have this problem when using Twitter Bootstrap with other 3rd-party JS libraries, such as html5.js from WordPress' "Twenty Twelve" theme, where the build fails because jshint (or jslint in previous versions of TB I think) throws an error due to the third-party JS library, e.g. \n################################################## Building Bootstrap... ##################################################\n js/html5.js: line 3, col 122, Expected ')' to match '(' from line 3 and instead saw

Purpose of JSLint “disallow insecure in regex” option

 ̄綄美尐妖づ 提交于 2019-11-29 00:59:56
I have a line of code that gets the following error when run through JSLint: Lint at line 604 character 48: Insecure '^'. numExp = parseInt(val[1].replace(/[^\-+\d]/g, ""), 10); This error seems to refer to the following description from JSLint's option page: "true if . and [^...] should not be allowed in RegExp literals. These forms should not be used when validating in secure applications." I don't quite understand how a client-side javascript application can really be considered secure. Even with the most airtight regex, it's still possible to fire up something like firebug and change the

JSLint - ignore sections of code

こ雲淡風輕ζ 提交于 2019-11-28 22:31:55
I have a huge script that passes JSLint (including avoidance of all bad parts). Except for one stretch, which is some very convoluted obfuscated code that is embedded within the larger context. JSLint generates quite a bit of complaints for this section, and I'd like to selectively disable it for that stretch of code. I already do use selective /*jlsint xxx:true/false*/ directives to disable particular warnings for certain tiny stretches of code that do things contrary to the struct interpretation. The obfuscated code I have uses constructs that I don't know if they can be disabled. For