-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix #25 hook for post-processing formatter output #26
Conversation
@purcell how does this look? |
Thanks. I'm going to have a deeper think about how best to support extending |
How's the deep think going? |
I started doing a bit of hacking a week or two ago and I think I'm getting a clearer picture of how things should work. Hoping to have some free time this week. |
Now that I've landed #27, this works: (defcustom eslint-fix-program "eslint"
"Program name or path for eslint."
:type 'string)
(defcustom eslint-fix-arguments nil
"Extra arguments for eslint --fix, e.g.'(\"--no-eslintrc\")."
:type '(list string))
(reformatter-define eslint-fix
:program eslint-fix-program
:stdin nil
:stdout nil
:input-file (reformatter-temp-file-in-current-directory "js")
:args (append eslint-fix-arguments (list "--fix" input-file))) |
So... in an effort to reduce options, you've managed to introduce more options than this PR lol What's the advantage of introducing |
Erm, this PR is for a different purpose, so I don't understand your "lol" at all. But it just so happens that with my changes in
I think the docs for those options should explain that. |
Suffice to say I spent a number of hours thinking about the modes of operation and configuration I would want |
The docstring just tells me what these options are but not the rationale. Granted eslint is the odd one out but your PR requires 4 different things to be set right for eslint to work. Are there code formatters where its only mode of operation is to require a file path and puts out the result in stdout or vice versa? This approach also requires making a temp copy of the file instead of just sending the buffer content, because, in-place. Also, presumably the user won't even notice the file was formatted if AFAIK every modern code formatter I know of supports stdin/stdout mode, even |
Hmm, thanks, you could be right. I just took a look at |
There's a reason I kept asking you what you were thinking man 😉 |
Yeah, if you had said: "Are there code formatters where its only mode of operation is to require a file path and puts out the result in stdout or vice versa?" initially instead of "in an effort to reduce options, you've managed to introduce more options than this PR lol" this whole conversation would have gone a lot smoother. |
I asked |
e91e585
to
ba0d8b7
Compare
Let's get concrete. I think there are 2 issues with this PR:
I've reimplemented this PR with tests in #28, in a different way such that it avoids dangling temp files, but the no-op issue still needs to be addressed. In the meantime, for |
I've addressed the blocker and updated the snippet in the description. If anyone is interested, this PR should work with eslint via stdin/stdout without any major issues. There is now a callback supplied that will automatically create a temp file for the output, and it will be clean up for reformatter afterwards. |
This enables eslint to work with reformatter using the following configuration: