piuccio / esformatter-diff Goto Github PK
View Code? Open in Web Editor NEWCompute the difference between your code and the formatted version with esformatter
Compute the difference between your code and the formatted version with esformatter
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)
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.
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%?
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
).
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.