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

Remove final newline based on file type? #4

Closed
mhulse opened this issue Oct 7, 2019 · 11 comments · Fixed by #5
Closed

Remove final newline based on file type? #4

mhulse opened this issue Oct 7, 2019 · 11 comments · Fixed by #5

Comments

@mhulse
Copy link

mhulse commented Oct 7, 2019

Any chance this can, or could, work with an array of file extensions? I would like to remove all newlines from end of specific file types.

Thanks!

@DoCode
Copy link
Owner

DoCode commented Oct 8, 2019

Thanks @mhulse for your feedback!

Yes, I think it's possible. I look at this ASAP.
What's your opinion about the defaults?

@mhulse
Copy link
Author

mhulse commented Oct 8, 2019

Oh, no rush on my behalf!

Thinking out loud here:

  • If the array of file types not filled-in, then the extension will work on all file types? (thus, not introducing any backwards-incompatible changes)
  • If file types added to options array, then the extension only works on provided extensions?

Thanks so much for your consideration and for the plugin!

@DoCode
Copy link
Owner

DoCode commented Oct 8, 2019

Ok, then we should implement this setting, e.g. for JSON, JS and TS file extensions:

{
  "files.removeFinalNewlines.fileTypes": ["json", "js", "ts"]
}

@mhulse
Copy link
Author

mhulse commented Oct 9, 2019

That looks awesome! I think this feature would really be a nice addition to this extension. I might have some time this weekend to possibly do a PR. I'll keep you posted. 👍

@mhulse
Copy link
Author

mhulse commented Oct 9, 2019

Wondering, would it make sense to have a blacklist/whitelist type of thing?

So, whitelist would be extensions this plugin would work on, and blacklist would be extensions this plugin would ignore.

This might give people more flexibility?

Of course, I maybe be overthinking things here.

@DoCode
Copy link
Owner

DoCode commented Oct 9, 2019

Yes, nice!
I think the same last night.
What about includes/excludes like

{
  "files.removeFinalNewlines.fileTypes.include": ["json", "js", "ts"],
  "files.removeFinalNewlines.fileTypes.exclude": ["md", "mdown", "log"]
}

@mhulse
Copy link
Author

mhulse commented Oct 9, 2019

I think that's a winner.

Was also wondering, would regex support be overkill? like md*, for example? Or, .*.hb maybe? I'm not sure how complicated it would be to implement, but I'm reminded of something like EditorConfig regex (for example):

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = false
indent_size = 4
indent_style = tab

[*.py]
indent_style = space

[*.{ini,json,rb,yml,sh,bash}]
indent_size = 2
indent_style = space

[.*rc]
indent_size = 2
indent_style = space

[{gemfile*,rakefile,vagrantfile}]
indent_size = 2
indent_style = space

[*.bat]
end_of_line = crlf

[cname]
insert_final_newline = false

Or, node-glob.

@DoCode
Copy link
Owner

DoCode commented Oct 9, 2019

No, I think it's no overkill, eventually an additional feature!?
After we have the include/exclude implementation, it's no big deal for globbing or regex support.

@DoCode
Copy link
Owner

DoCode commented Jan 14, 2020

@mhulse sorry for the silence...
Should we respect or implement like this here?

@mhulse
Copy link
Author

mhulse commented Feb 14, 2020

Sorry for being afk. I have actually been using IntelliJ as my primary code tool since I last filed this issue ... Apologies for not helping. :(

Anyway, Looks like you got it solved! Nice work. :)

@DoCode
Copy link
Owner

DoCode commented Feb 14, 2020

No problem. Thanks Michael!

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

Successfully merging a pull request may close this issue.

2 participants