JavaScript-Scope-Context-Coloring icon indicating copy to clipboard operation
JavaScript-Scope-Context-Coloring copied to clipboard

Variables only matched once per scope

Open nadinengland opened this issue 12 years ago • 4 comments

Each variable is only matched once per function to its original scope:

Screen Shot 2013-04-07 at 11 01 21

As you can above, nested scoped seems to reset it.

This is awesome btw :+1:

nadinengland avatar Apr 07 '13 10:04 nadinengland

I've added a unit test for this, pull request welcome :) http://daniellmb.github.io/JavaScript-Scope-Context-Coloring/test

daniellmb avatar Apr 09 '13 16:04 daniellmb

Here is what I've been able to ascertain so far. The bug isn't in the color function but rather as the expression is being parsed.

I've done some extensive testing with the color function and it does correctly break up the input based on the given scope level. So that's how I've determined the problem comes from earlier on in the pipeline.

nadinengland avatar Apr 10 '13 18:04 nadinengland

I found many bugs in JsLint scope coloring, so I've just shiped an alternative to jslint color: https://github.com/mazurov/eslevels. It based on esprima and escope libraries that support the latest javascript standards.

Web demo page: http://mazurov.github.io/eslevels-demo/

mazurov avatar Apr 26 '13 18:04 mazurov

Nice work @mazurov! However, eslevels is not compatible with JSLint color API, so in its current form unfortunately it can't be swapped in.

daniellmb avatar May 01 '13 16:05 daniellmb