Jump to content
Mikie

Styleguide: strip trailing whitespace

Recommended Posts

I think the ProcessWire style guide should move to recommending stripping trailing whitespace, and this should be implemented throughout core / recommened for all modules.

This would be inline with official php style guides, eg https://www.php-fig.org/psr/psr-12/

Just a thought. To me it is better to keep things cleaner than not. Would make diffing easier for those whose editors automatically highlight and strip whitespace on save, eg when trying to diff htaccess.txt and an edited .htaccess.

  • Like 3

Share this post


Link to post
Share on other sites

I completely agree - I always have my editor set to remove all trailing whitespace on save. It makes diffs so much easier to read/interpret because you don't end up with all the whitespace changes that can happen.

Unfortunately this has been discussed before and Ryan actually said "I find a space at the end of lines helpful in my editing environment" (https://github.com/ryancramerdesign/ProcessWire/issues/1757). I don't understand why, but it sounds like he doesn't want to change this, although of course that discussion was some time ago.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for that @adrian. I thought it might specifically be part of the current styleguide for a reason. Understandable if Ryan works that way, we all want him to be as productive as possible!

  • Like 1

Share this post


Link to post
Share on other sites

I agree too that this should be added to the styleguide, and I also configured my IDE to strip trailing whitespace on save.

However, if we're talking about diff tools, it's just as easy to configure them to ignore whitespace (and even empty lines).

diff-options.PNG.4e7096f391dbf611afb1aa5bf7641092.PNG

PHPStorm

Git has the option --ignore-whitespace you can use.

VSCode: File => Preferences => Settings => Diff Editor => Ignore Trim Whitespace.

  • Like 2

Share this post


Link to post
Share on other sites
7 hours ago, dragan said:

However, if we're talking about diff tools, it's just as easy to configure them to ignore whitespace (and even empty lines).

Yeah I didnt even know about this until the replies here. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...