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

Option "eol" not working #60

Open
Matumba2 opened this issue Sep 30, 2016 · 1 comment
Open

Option "eol" not working #60

Matumba2 opened this issue Sep 30, 2016 · 1 comment

Comments

@Matumba2
Copy link

I was wondering why the plugin ignores my configuration concerning the option "eol".
If I use "\r\n" as eol, everything works fine except by empty lines at the end of a file.
I took a look at the code. In line 98 - 101 of the file "lib/jsbeautifier.js" you're replacing the empty line at the end of a file. As you can see in line 100, you are using "\n" as the line terminator, without considering if there is any option about which line terminator should be used. The result is that everywhere in my code is "\r\n" used as the line terminator except the empty line at the end of the file.
I would recommend to check if the option "eol" is set instead of using always the same line terminator.

By the way: What is the purpose of this lines? If you set the option "endWithNewline" to true, the beautifier will insert an empty line with the correct line terminator at the end of the file. So in my mind you can cut these lines out because there is no really use...

I also figured out that the option "eol" get's overriden. If you trying to use "\n" as the line terminator, the plugin always use "\r\n". If you insert some bullshit like "\n" it works correctly.

@vkadam
Copy link
Owner

vkadam commented Sep 30, 2016

Appending "\n" was added when jsbeautify didn't supported eol for file of kind js. So had to implement it in this plugin. And it can enable or disable by '''--end-with-newline''' parameter. Caveat I see here is only not using '''eol''' instead of "\n" which was again because eol was added by jsbeautify way later this feature was developed.
I would love the PR for this if you get this working with backward compatibility, remember plugin does support using diff version of "jsbeautify" as per user requirement

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