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

New Universal.WhiteSpace.DisallowInlineTabs sniff #43

Merged
merged 1 commit into from
Mar 31, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Mar 31, 2020

New sniff to enforce using spaces for mid-line alignment.

While tab versus space based indentation is a question of preference, for mid-line alignment, spaces should always be preferred, as using tabs will result in inconsistent formatting depending on the dev-user's chosen tab width.

This sniff is especially useful for tab-indentation based standards which use the Generic.Whitespace.DisallowSpaceIndent sniff to enforce this.

DO make sure to set the PHPCS native tab-width configuration for the best results.

   <arg name="tab-width" value="4"/>

The PHPCS native Generic.Whitespace.DisallowTabIndent sniff (used for space-based standards) oversteps its reach and silently does mid-line tab to space replacements as well.

However, the sister-sniff Generic.Whitespace.DisallowSpaceIndent leaves mid-line tabs/spaces alone.
This sniff fills that gap.

Implementation notes:

  • Includes a DummyTokenizer to allow use of the PHPCS native intelligent tabs to spaces replacement using the default tab-width if none was set.

Includes fixers.
Includes unit tests.
Includes documentation.

@jrfnl jrfnl added this to the 1.0 milestone Mar 31, 2020
@jrfnl jrfnl force-pushed the feature/universal/new-disallow-inline-tab-sniff branch 3 times, most recently from e5f7386 to c63e010 Compare March 31, 2020 17:27
New sniff to enforce using spaces for mid-line alignment.

While tab versus space based indentation is a question of preference, for mid-line alignment, spaces should always be preferred, as using tabs will result in inconsistent formatting depending on the dev-user's chosen tab width.

> _This sniff is especially useful for tab-indentation based standards which use the `Generic.Whitespace.DisallowSpaceIndent` sniff to enforce this._
>
> **DO** make sure to set the PHPCS native `tab-width` configuration for the best results.
> ```xml
>    <arg name="tab-width" value="4"/>
> ```
>
> The PHPCS native `Generic.Whitespace.DisallowTabIndent` sniff (used for space-based standards) oversteps its reach and silently does mid-line tab to space replacements as well.
>
> However, the sister-sniff `Generic.Whitespace.DisallowSpaceIndent` leaves mid-line tabs/spaces alone.
> This sniff fills that gap.

Implementation notes:
* Includes a `DummyTokenizer` to allow use of the PHPCS native intelligent tabs to spaces replacement using the default tab-width if none was set.

Includes fixers.
Includes unit tests.
Includes documentation.
@jrfnl jrfnl force-pushed the feature/universal/new-disallow-inline-tab-sniff branch from c63e010 to 25e84d4 Compare March 31, 2020 18:33
@jrfnl jrfnl merged commit 04f9414 into develop Mar 31, 2020
@jrfnl jrfnl deleted the feature/universal/new-disallow-inline-tab-sniff branch March 31, 2020 19:33
@jrfnl jrfnl modified the milestones: 1.0, 1.0.0-alpha3 Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant