Search Results

Search found 72 results on 3 pages for 'jslint'.

Page 1/3 | 1 2 3  | Next Page >

  • Pre Commit Hook for JSLint in Mercurial and Git

    - by jrburke
    I want to run JSLint before a commit into either a Mercurial or Git repo is done. I want this as an automatic step that is set up instead of relying on the developer (mainly me) remembering to run JSLint before-hand. I normally run JSLint while developing, but want to specify a contract on JS files that they pass JSLint before being committed to the repo. For Mercurial, this page spells out the precommit syntax, but the only variables that seem to be available are the parent1 and parent2 changeset IDs involved in the commit. What I really want are a list of file names that are involved with the commit, so that I can then choose the .js file and run jslint over them. Similar issue for GIT, the default info available as part of the precommit script seems limited. What might work is calling hg status/git status as part of the precommit script, parse that output to find JS files then do the work that way. I was hoping for something easier though, and I am not sure if calling status as part of a precommit hook reflect the correct information. For instance in Git if the changes files have not been added yet, but the git commit uses -a, would the files show up in the correct section of the git status output as being part of the commit set? Update: I got something working, it is visible here: http://github.com/jrburke/dvcs_jslint/

    Read the article

  • JSLint reports "Unexpected dangling" character in an underscore prefixed variable name

    - by Zhami
    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 Google's variables names... so, I guess I can't get 100% "clean." I post here in case I've misunderstood the message, and can do something to comply with JSLint practices.

    Read the article

  • Does JSLint parse DOM functions?

    - by Paul
    I tried to use the parse() function of JSLint to parse three pieces of JavaScript code: function(b, c){var a = b + c; return a; } window.addEventListener('click', click_hanlder, true); document.documentElement.innerHTML; Here's the code, which is copied and pasted from the JSLint self-parse example: ` try { parse = make_parse(); var source = "something to parse";//replaced by the code above tree = parse(source); if (tree) { document.write(JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4)); } } catch (e) { document.write(JSON.stringify(e, ['name', 'message', 'from', 'to', 'key', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4)); } ` The output: returns a correct tree. returns a tree with only one node of "window". crashes the browser. I'm wondering whether JSLint doesn't support DOM function.

    Read the article

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

    - by Zhami
    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.

    Read the article

  • JSLint with Textmate

    - by mehdi
    I tried the instructions at this tutorial (http://www.phpied.com/jslint-on-mac-textmate/) to run jslint with textmate but getting stuck at step at the last step of "Step 1" Here is the error: Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/javascript/tools/shell/Main Caused by: java.lang.ClassNotFoundException: org.mozilla.javascript.tools.shell.Main at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Thanks

    Read the article

  • JsLint 'out of scope' error

    - by Rajat
    function test(){ if(true){ var a = 5; } alert(a); } test(); I keep getting 'out of scope' errors in my JS code when I check with JsLint which make no sense to me.So I quickly created an example. Is there something actually wrong with this code piece, as the variable is eventually hoisted to the top of the function anyways.

    Read the article

  • JSLint -Tolerate inefficient subscripting?

    - by James Wiseman
    I'm reading the JSlint Options Documentation to understand each of the available options, and have come across one that I don't quite understand, and can't find any useful information regarding it elsewhere. sub - Tolerate inefficient subscripting true if subscript notation may be used for expressions better expressed in dot notation. Can anyone shed more light as to what this means? Thanks

    Read the article

  • Unescaped '^' with jslint

    - by Ben
    This is my code: /********************************************************** * remove non-standard characters to give a valid html id * **********************************************************/ function htmlid(s) { return s.gsub(/[^A-Z^a-z^0-9^\-^_^:^\.]/, "."); } Why does jslint throw this error? Lint at line 5 character 25: Unescaped '^'. return s.gsub(/[^A-Z^a-z^0-9^\-^_^:^\.]/, ".");

    Read the article

  • customisable JSLint

    - by Don
    Hi, I'm looking for a tool that checks JS code, which can be integrated into a Maven build. I need a tool that will check for errors such as use of reserved words as identifiers trailing semi-colon, e.g. var obj = { a: 1, b, 2, } JSLint seems like a perfect candidate, but the problem is that it is too strict, because it also checks for various coding patterns which are (arguably) bad style, but do not actually generate errors in a browser. Examples of such issues include Disallow ++ and -- and Allow one var statement per function If possible, I would like the errors to fail the build, and I would like the other rules to only print warnings (or disable them completely). Obviously, I need the ability to specify which of the available rules I consider errors and which I consider warnings. Thanks, Don

    Read the article

  • WHY JSLint complains: "someFunction() was used before it was defined"?

    - by 7hi4g0
    Searching for the JSLint error "was used before it was defined" i've found these: JSLint: Using a function before it's defined error Function was used before it was defined - JSLint JSLint: was used before it was defined jsLint error: “somefunction() was used before it was defined” jslint - Should we tolerate misordered definitions? Problem None of those answers WHY the error is shown. Elaboration According to the ECMA-262 Specification functions are evaluated before execution starts, hence all functions declared using the function keyword are available to all the code idenpendent of the place they were declared (assuming they are acessible on that scope). This is otherwise known as hoisting. Douglas Crockford seems to think it is better to declare every function before the code that uses it regardless of the hoisting effect. According to StackOverflowNewbie in his question, this raises some code organization problems. Not to mention some people, like me, prefer to declare their functions underneath the main/init code. On those questions there are some ways to avoid or fix the error, such as using function expressions vs function declarations. But none of them showed me the reason of the error. Not even Crockford's site. Question(s) Why is it an error to call a function before the declaration, even if it was declared using the function keyword? Is it better to use function expressions instead of function declaration in the JSLint context? If one is preferred, why? Note Not looking for answers like: Crockford is a tyrant Is just Crockford's opinion Thank you :*

    Read the article

  • How to get around the jslint error 'Don't make functions within a loop.'

    - by Ernelli
    I am working on making all of our JS code pass through jslint, sometimes with a lot of tweaking with the options to get legacy code pass for now on with the intention to fix it properly later. There is one thing that jslint complains about that I do not have a workround for. That is when using constructs like this, we get the error 'Don't make functions within a loop.' for (prop in newObject) { // Check if we're overwriting an existing function if (typeof newObject[prop] === "function" && typeof _super[prop] === "function" && fnTest.test(newObject[prop])) { prototype[prop] = (function (name, func) { return function () { var result, old_super; old_super = this._super; this._super = _super[name]; result = func.apply(this, arguments); this._super = old_super; return result; }; })(prop, newObject[prop]); } This loop is part of a JS implementation of classical inheritance where classes that extend existing classes retain the super property of the extended class when invoking a member of the extended class. Just to clarify, the implementation above is inspired by this blog post by John Resig. But we also have other instances of functions created within a loop. The only workaround so far is to exclude these JS files from jslint, but we would like to use jslint for code validation and syntax checking as part of our continuous integration and build workflow. Is there a better way to implement functionality like this or is there a way to tweak code like this through jslint?

    Read the article

  • JSLINT error: Move all 'var' declarations to the top of the function.

    - by Oleg Yaroshevych
    JSLINT site updated, and I cannot check JS scripts anymore. For me, this warning is not critical, and I don't want to go through thousands of lines to fix this, I want to find more critical problems. Does anybody know how to turn off this error, or use legacy JSLINT? UPDATE Example: function doSomethingWithNodes(nodes){ this.doSomething(); for (var i = 0; i < nodes.length; ++i){ this.doSomethingElse(nodes[i]); } doSomething(); // want to find this problem } jslint.com output: Error: Problem at line 4 character 8: Move all 'var' declarations to the top of the function. for (var i = 0; i < nodes.length; ++i){ Problem at line 4 character 8: Stopping, unable to continue. (44% scanned). Problem: Having variables on top of the functions is new requirement. I cannot use JSLINT to test code, because it stops scanning script on this error. I have a lot of code, and do not want to threat this warning as critical error.

    Read the article

  • How should I define a JavaScript 'namespace' to satisfy JSLint?

    - by Matthew Murdoch
    I want to be able to package my JavaScript code into a 'namespace' to prevent name clashes with other libraries. Since the declaration of a namespace should be a simple piece of code I don't want to depend on any external libraries to provide me with this functionality. I've found various pieces of advice on how to do this simply but none seem to be free of errors when run through JSLint (using 'The Good Parts' options). As an example, I tried this from Advanced JavaScript (section Namespaces without YUI): "use strict"; if (typeof(MyNamespace) === 'undefined') { MyNamespace = {}; } Running this through JSLint gives the following errors: Problem at line 2 character 12: 'MyNamespace' is not defined. Problem at line 3 character 5: 'MyNamespace' is not defined. Implied global: MyNamespace 2,3 The 'Implied global' error can be fixed by explicitly declaring MyNamespace... "use strict"; if (typeof(MyNamespace) === 'undefined') { var MyNamespace = {}; } ...and the other two errors can be fixed by declaring the variable outside the if block. "use strict"; var MyNamespace; if (typeof(MyNamespace) === 'undefined') { MyNamespace = {}; } So that works, but it seems to me that (since MyNamespace will always be undefined at the point it is checked?) it is equivalent to the much simpler: "use strict"; var MyNamespace = {}; JSLint is content with this but I'm concerned that I've simplified the code to such an extent that it will no longer function correctly as a namespace. Is this final formulation sensible?

    Read the article

  • What does JSLint's "Bad Escapement" mean in this case?

    - by karlthorwald
    I thougth "bad escapement" stands for wrong use escaping with slash. Why does JSLint bring up the message in this function on the 3d line (for...) ? function splitTags(commaSeparated) { var tagArray = commaSeparated.split(','); for (var i=tagArray.length - 1; i>=0; --i ){ tagArray[i] = f.trim(tagArray[i]); } return tagArray; }

    Read the article

  • emacs: Can I set compilation-error-regexp-alist in a mode hook fn?

    - by Cheeso
    I am trying to set the compilation-error-regexp-alist in a function that I add as a mode hook. (defun cheeso-javascript-mode-fn () (turn-on-font-lock) ...bunch of other stuff ;; for JSLINT (make-local-variable 'compilation-error-regexp-alist) (setq compilation-error-regexp-alist '( ("^[ \t]*\\([A-Za-z.0-9_: \\-]+\\)(\\([0-9]+\\)[,]\\( *[0-9]+\\))\\( Microsoft JScript runtime error\\| JSLINT\\): \\(.+\\)$" 1 2 3) )) ;;(make-local-variable 'compile-command) (setq compile-command (let ((file (file-name-nondirectory buffer-file-name))) (concat "%windir%\\system32\\cscript.exe \\cheeso\\bin\\jslint.js " file))) ) (add-hook 'javascript-mode-hook 'cheeso-javascript-mode-fn) The mode hook runs. The various things I Set in the mode hook work. The compile-command gets set. But for some reason, the compilation-error-regexp-alist value doesn't take effect. If I later do a M-x describe-variable on compilation-error-regexp-alist, it shows me the value I think it should have. But .. the errors in the compilation buffer don't get highlighted, and M-x next-error does not work. If I add the error regexp value to the compilation-error-regexp-alist via setq-default, like this: (setq-default compilation-error-regexp-alist '( ... jslint regexp here ... ... many other regexp's here... )) ...then it works. The errors in the compilation buffer get properly highlighted and M-x next-error functions as expected.

    Read the article

1 2 3  | Next Page >