Giter Club home page Giter Club logo

esformatter-diff's People

Contributors

nisaacson avatar piuccio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nisaacson

esformatter-diff's Issues

TypeError: Cannot set property 'parent' of null

I just tried running this in the root of my project, and it threw an error. I then tried just running it in the context of my lib/ directory, which threw the second error.

First Error (at root):

$ esformatter-diff --default
OK: Analizyng 32 files with [email protected]
ERROR: Error progressing node_modules/expect.js                            ] 25%
Message:EISDIR, read
[#######################################################                   ] 75%
/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:77
        node.parent = parent;
                    ^
TypeError: Cannot set property 'parent' of null
    at instrumentNodes (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:77:21)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:347:10)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:372:17)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:368:13)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:372:17)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:368:13)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:372:17)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:368:13)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:372:17)
    at recursiveWalk (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/rocambole.js:368:13)

Second Error (in lib/):

OK: Analizyng 41 files with [email protected]
[####################################################                      ] 70%
/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3872
            throw e;
                  ^
Error: Line 1: Illegal return statement
    at throwError (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:1161:21)
    at throwErrorTolerant (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:1172:24)
    at parseReturnStatement (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2485:13)
    at parseStatement (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2765:24)
    at /opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3609:38
    at parseIfStatement (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2200:22)
    at parseStatement (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2763:24)
    at /opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3609:38
    at parseSourceElement (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3057:24)
    at parseSourceElements (/opt/node/v0.10.24/lib/node_modules/esformatter-diff/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3095:29)

feature: option to set which files/folders to check

it would be cool if we had the option to specify the folder and/or files that you want to check. maybe you only care about the source files, maybe you only care about the distribution files. (keep the current behavior as the default)

an exclusion glob would also be useful if you want to bypass the check on 3rd party libs or specific files that goes against the rules.

Some notes and ideas

Just saw your comment on millermedeiros/esformatter#2 and wanted to leave some feedback here.

The tool is interesting, but could be more useful by actually telling you what the differences are. The diffs that esformatter has in its tests are a pretty good reference here, using colored output to show you actual and (un)expected whitespace and linebreaks.

You could make the --default flag the default, so that I can just run esformatter-diif to get the same result.

It would also be interesting to have a programmatic API, especially if you implement the diff output described above.

I just ran this tool inside the esformatter project folder, and it analized only 8 files, while the lib folder (and subdirs) has 10 js files, with a lot more in the test folder. Not sure how the tool looks for file.

The output was this:

Processed 8 files for a total of 1002 lines of code, 304 differ from the original code
ERROR: 70 %

Isn't that an error rate of 30%?

feature: exit with status code != 0 if found diffs

process.exit(1) (or any other error code) for cases where it finds diffs so it could be easily hooked into a CI process to block commits that have code that doesn't follow the style guide (maybe toggled by a flag --strict).

feature: options to limit amount of logged diffs

I would also want to see an option that limits the amount of errors that it will output/check.

lets say you are checking a large project for the first time and it contains 1000+ errors, I don't want to see it log the diff of 1000 files at once. I know you could just pipe the results like esformatter-diff --diff | more to read it one by one but it might take a while to check 1000's of files and it would be a waste of time if you only care about the first 10.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.