-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement the beautifier #1
base: master
Are you sure you want to change the base?
Conversation
lassik
commented
Oct 2, 2018
•
edited
Loading
edited
- This PR contains one test that passes.
- elm-format doesn't have any options.
- The current version of elm-format adds ANSI color codes to the error messages that it outputs to stderr, even when stderr is not a terminal. This is discussed in elm-format issue #372.
beautifier-template commit 1bc3ac0aed659b8d33a04e1c76995923efc83d86
Includes a basic test that passes.
Consider using something like: https://www.npmjs.com/package/strip-ansi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests currently failing.
@Glavin001 please give me more access to this so I can add to CodeClimate. |
It would be really nice to make do without us caring about ANSI colors. Since this is still work in progress, I'll try to persuade upstream to take care of it so we get plain text output without ANSI. |
@lassik I'll add this to the beautifier-template as well, but could you please add a |
cache: | ||
directories: | ||
- node_modules | ||
before_script: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to install elm as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Travis build log, at least elm-format --help
is running fine when we have only elm-format installed without the rest of the Elm toolchain. Does it show an error somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the error is being written to stdout for some reason.
"I couldn't figure out what version of Elm you are using!
You should either run elm-format from the directory containing
your elm.json (for Elm 0.19) or elm-package.json (for Elm 0.18),
or tell me which version of Elm with --elm-version=0.19 or --elm-version=0.18
"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome that you noticed that, I didn't notice at all and still can't find it :-D Tried grepping the raw logs of the latest build. Anyway, I think it's saying we need an Elm project file or a command line option to let it know the Elm version. Probably we don't actually need to have that version of Elm installed. I'll try adding --elm-version=
to the unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's reporting an error to stdout when you try to format stdin->stdout, we need to file a bug report about that..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try adding --elm-version= to the unit test.
I would send the projectPath into the beautify method, then include cwd: projectPath
in the options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might work. The latest version of elm-format supports both Elm 0.18 and Elm 0.19. It determines the version based on the presence of elm-package.json
(0.18) or elm.json
(0.19) in the current directory. That means strictly the current directory only - it doesn't look in parent directories. There's also a command line flag to control the Elm version but that seems like a more difficult solution for end users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been debating whether elm-format should check the elm version for each file starting at the file and traversing up directories until it finds elm.json or elm-package.json, instead of looking in the current directory. It seems like that would probably be more correct for more cases. What do you think? (In any case, that would be in elm-format 0.8.2 at the earliest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see you here @avh4. You really care about your project! You already seem to have an issue about this at avh4/elm-format#561 so let's continue discussion there to make sure everyone can find it :) For this plugin, the most useful missing elm-format feature would be using isatty()
(in Haskell, queryTerminal
) to disable ANSI output when stderr is not going a terminal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion about Elm version number is ongoing in #2
@stevenzeck Try now, you should be an Admin 👍 . |
.travis.yml
Outdated
@@ -0,0 +1,35 @@ | |||
env: | |||
global: | |||
- CC_TEST_REPORTER_ID= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID is: 0288dbd5e8a04d83f7e4e86710d77c540968fc4e791afe95e5d3aa79e20b90f9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Committed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests running within Travis CI are currently failing.
To make the test pass, we need to decide how to pass the Elm version number. |
Until we do a language version option in Unibeautify core, I think you'll need to have those config json files. |
Yeah, I guess we could add an empty |
Then again, maybe the failing test is a good reminder that we have to solve the problem properly at some point. |
It may take a little while before I have time to implement Unibeautify/unibeautify#196 I think adding a note in this README that |