jslint

JSLint Weird assignment, required for closure compiler

回眸只為那壹抹淺笑 提交于 2019-12-11 05:29:14
问题 I'm using the closure compiler to minify and speed up my code but I'm running into some issues with JSLint when I try to export my functions. Basically, I have an object, foo{} with a function, foo.bar() that gets called via an external file as. In order for this function to be called externally I need to add some declarations to my script before it gets compiled: window['foo'] = foo; window['foo']['bar'] = foo.bar; This works great, but—as ever—JSLint thinks I'm mental for even attempting

kebab-case in angular 2 selectors (tslint)

只谈情不闲聊 提交于 2019-12-11 00:06:02
问题 This is my tslint.json file: { "rulesDirectory": [ "node_modules/codelyzer" ], "rules": { "class-name": true, "comment-format": [ true, "check-space" ], "curly": true, "eofline": true, "forin": false, "indent": [ true, "spaces" ], "label-position": true, "label-undefined": true, "max-line-length": [ true, 140 ], "member-access": false, "member-ordering": [ true, "static-before-instance", "variables-before-functions" ], "no-arg": true, "no-bitwise": true, "no-console": [ true, "debug", "info",

jslint - Should we tolerate misordered definitions?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 17:17:41
问题 Update: Turns out that this is a duplicate of: JSLint: Using a function before it's defined error We have freshly adopted jslint in our project, and as it promised - jslint starts hurting our feelings. But not only that, it makes us questioning quite a few of the rules it has. To be honest, to me it resembles ANSI C programming style somehow. Here's one: JS Lint: 'someMethodFoo' was used before it was defined. This occurs because we use a top-down coding style: Each file first contains the

Unexpected '.' from wrapped expression to chain

孤街醉人 提交于 2019-12-10 15:34:24
问题 I have this method that is calculating a total, and part of it is giving a warning in JS Lint. We're trying to get cleaner JS Lint inspections at work, so I want to see if there's a rational way to get around this that I'm not thinking of. calculateTotal = function() { var hours = parseFloat($hours.val()); var rate = parserFloat($rate.val()); var total = ''; if (!isNaN(hours) && !isNaN(rate)) { // This throws the error. total = (rate * hours).toFixed(2); } $total.val(total); } I can avoid the

Generating JavaScript from a JSLINT parse tree

爷,独闯天下 提交于 2019-12-10 13:18:03
问题 With Crockford's JSLINT, after calling JSLINT() to parse some JavaScript source, it provides access to the parse tree via JSLINT.tree It would be really powerful to be able to analyse the tree, make structural changes to it based on the analysis and then generate new JavaScript from the modified tree. Is there an open source project that builds on JSLINT by providing a conversion from a parse tree back to JavaScript? (Is this even possible, i.e. does JSLINT keep complete enough information

JSLint Braces around If-Block

邮差的信 提交于 2019-12-10 12:53:27
问题 In Javascript, if an if expression does not have a curly bracket after it, the following statement is put inside the if block. That is, if(foo) bar(); baz(); is equivalent to if(foo) { bar(); } baz(); Douglas Crockford recommends not using the first because it is confusing and can cause hard-to-trace bugs if a programmer tries to add a statement to an if block without braces. For this reason, JsLint complains if you use the first form. I use this all the time, and I feel like it's a non-issue

JSLint complaining about my try/catch

孤街醉人 提交于 2019-12-10 03:11:17
问题 The javascript, when run through JSLint yells at me and I am not sure why. /*jslint browser: true, devel: true, evil: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, newcap: true, immed: true */ var foo = function() { try { console.log('foo'); } catch(e) { alert(e); } try { console.log('bar'); } catch(e) { alert(e); } }; foo(); It tells me: Problem at line 12 character 11: 'e' is already defined. } catch(e) { It appears to be upset that I have a second catch(e) .

JSLint - problems declaring variables

浪子不回头ぞ 提交于 2019-12-10 01:52:30
问题 The following code passes JSLint: var sGreeting = 'hello world'; switch (sGreeting) { case 'Hello world!': var a = 'some a value'; break; case 'Kamusta mundo!': var b = 'some b value'; break; case 'Salut le Monde!': var c = 'some c value'; break; default: break; } However, once I put that code in a function, JSLint complains that I should Combine ... with the previous 'var' statement. If I follow JSLint, I would be defining variables that may never need to be used. How should I deal with this

lint warning: parseInt missing radix parameter [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-10 01:45:26
问题 This question already has answers here : JSLint says “missing radix parameter” (11 answers) Closed 6 years ago . I have the following code that gives the warning described in the title: year: parseInt(dateParts[0]), ......................^ Any help is much appreciated 回答1: See the manual for parseInt; it takes 2 arguments. The second one tells it which number base you want to use. This is almost always going to be 10 (decimal). parseInt(dateParts[0],10) If you don't specify it, then it will

Static-analysis with custom rules for JavaScript?

我是研究僧i 提交于 2019-12-09 13:23:11
问题 Does JSLint, JSHint, or some other open-source static code analysis tool support adding custom rules for code compliance, or are there some ECMAScript compliant parsers that I can use to get the results as close as possible to the ones seen in the snippet below? For example, I’d like to look into JavaScript code and list what functions are called, if it calls a library (or APIs provided by smartphones for HTML5 widgets) to register all that fall under the namespaces of that API, to make a