Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsfmt diff #13

Closed
brettlangdon opened this issue May 12, 2014 · 10 comments
Closed

jsfmt diff #13

brettlangdon opened this issue May 12, 2014 · 10 comments

Comments

@brettlangdon
Copy link
Contributor

jsfmt diff ignores space changes git diff -b and when running jsfmt --diff=true --format=true ./rewrite.js I missed a bunch of continuation changes that I didn't actually intend to make:

diff --git a/rewrite.js b/rewrite.js
index 3675a93..9a638b0 100644
--- a/rewrite.js
+++ b/rewrite.js
@@ -84,13 +84,13 @@ function match(wildcards, pattern, node) {
         return false;
       }
       return match(wildcards, pattern.key, node.key)
-          && match(wildcards, pattern.value, node.value);
+      && match(wildcards, pattern.value, node.value);
     case 'MemberExpression':
       if (pattern.computed != node.computed) {
         return false;
       }
       return match(wildcards, pattern.object, node.object)
-          && match(wildcards, pattern.property, node.property);
+      && match(wildcards, pattern.property, node.property);
     case 'ArrayExpression':
       return partial(wildcards, pattern.elements, node.elements);
     case 'ObjectExpression':
@@ -100,12 +100,12 @@ function match(wildcards, pattern, node) {
         return false;
       }
       return match(wildcards, pattern.left, node.left)
-          && match(wildcards, pattern.right, node.right);
+      && match(wildcards, pattern.right, node.right);
     case 'ForStatement':
       return match(wildcards, pattern.init, node.init)
-          && match(wildcards, pattern.test, node.test)
-          && match(wildcards, pattern.update, node.update)
-          && match(wildcards, pattern.body, node.body);
+      && match(wildcards, pattern.test, node.test)
+      && match(wildcards, pattern.update, node.update)
+      && match(wildcards, pattern.body, node.body);
     case 'VariableDeclaration':

is this the desired behavior? if not, I might suggest removing the -b option from jsfmt diff.

@jimfleming
Copy link
Contributor

Nope, not desired, good catch.

@jimfleming
Copy link
Contributor

I think this is the last known issue. Going to resolve it real quick then bump the npm version. I'll post it as a PR so its all out in the open now that jsfmt is public.

@brettlangdon
Copy link
Contributor Author

One last thing I wanted to ask, should it be --format=true by default to match the behavior of running gofmt without any parameters?

@jimfleming
Copy link
Contributor

Yah, I can get behind that. One reason I went with no default action is discoverability of other options but I think familiarity with gofmt is part of the draw towards jsfmt.

@brettlangdon
Copy link
Contributor Author

Adding --help might... "Help"
On May 12, 2014 1:01 PM, "Jim Fleming" [email protected] wrote:

Yah, I can get behind that. One reason I went with no default action is
discoverability of other options but I think familiarity with gofmt is part
of the draw towards jsfmt.


Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-42858730
.

@jimfleming
Copy link
Contributor

Haha, well, --help works out of the box because any unrecognized flag prints the help.

@brettlangdon
Copy link
Contributor Author

haha, nice.

On the topic of help text/etc, I am a complete http://docopt.org/ fanboy... so I have to at least mention it once ;)

@jimfleming
Copy link
Contributor

Interesting, so you just describe the help doc and it figures out the params for you? I like that.

This issue is of concern but assuming it doesn't interfere with jsfmt's functionality I don't mind switching.

@brettlangdon
Copy link
Contributor Author

ooo, that seems like a fun issue.

but yeah, just give it the help text and it does the rest. I'll see if I can do a port later today and do a PR so you can see what it would look like.

@jimfleming
Copy link
Contributor

#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants