Browse files

Add anchors to sections

  • Loading branch information...
1 parent cd1d04b commit a25108defe1a0019625a91d53879c87fa2274c44 @kangax committed Apr 7, 2014
Showing with 6 additions and 6 deletions.
  1. +6 −6 _posts/
@@ -64,7 +64,7 @@ I have to say that JSCritic is more of a prototype at the moment. Static analysi
If you want to know more about tests, implementation details, and drawbacks, read on. Otherwise, hope you find it as useful as I do.
-### Global variables
+<h3 id="globals">Global variables</h3>
Let's first take a look at global variables detection. Unfortunately, it seems to be very simplistic in JSHint, failing to catch cases other than plain variable/function declarations in top level code.
@@ -103,7 +103,7 @@ var foo = 1;
It gives a decent overview, but you should still look through variables carefully as some of them might be false positives. I'm hoping this will be made more robust in the future JSHint versions (or we could try using hybrid detection method — both via static analysis and through global object signature).
-### Extended natives
+<h3 id="natives">Extended natives</h3>
Detecting native object extensions has few limitations as well. While it catches both Array and String in example like this:
@@ -137,7 +137,7 @@ Detecting native object extensions has few limitations as well. While it catches
As you can see, it's also simplistic and could have false negatives. There's an [open JSHint issue]( for this.
-### eval &amp; document.write
+<h3 id="eval">eval &amp; document.write</h3>
Just like with other checks, there are false positives and false negatives. Here's some of them, just to give an idea of what to expect:
@@ -170,15 +170,15 @@ and with <code>document.write</code>:
{% gist kangax/f7be5ebdbad1e1b1c409 %}
-### Browser compatibility
+<h3 id="compatibility">Browser compatibility</h3>
I included 3 checks for browser/engine compatibility — Mozilla-only extensions (let expressions, [expression closures](/a-closer-look-at-expression-closures), multiple catch blocks, etc.), things IE chokes on (e.g. extra comma), and ES6 additions (array comprehensions, generators, imports, etc.). All of these things could affect cross-browser support.
-### Browser sniffing
+<h3 id="sniffing">Browser sniffing</h3>
To detect browser sniffing, we first check statically for occurance of `navigator` implied global (via JSHint), then check source for occurance of `navigator.userAgent`. This covers a lot of cases, but obviously won't catch any obscurities, so be careful. To make things easier, a chunk of code surrounding `navigator.userAgent` is pasted for expection purposes. You can quickly check what it's there for (is it for non-critical enhancement purposes or could it cause subtle bugs and/or full breakage?)
-### Unused variables
+<h3 id="unused">Unused variables</h3>
Finally, I included unused variables check from JSHint. While not exactly an indication of external script behavior, seeing lots of those could be an indication of sloppy (and potentially buggy) code. I put it all the way at the end, as this is the least important check.

0 comments on commit a25108d

Please sign in to comment.