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

Match Expressions alignments #590

Open
jacobcassidy opened this issue Aug 9, 2024 · 2 comments
Open

Match Expressions alignments #590

jacobcassidy opened this issue Aug 9, 2024 · 2 comments

Comments

@jacobcassidy
Copy link

Should Match Expressions have alignment like those under the Generic.Formatting.MultipleStatementAlignment.NotSameWarning and WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAlign rules?

For example, this is not aligned:

$asset_dir = match ( $asset_type ) {
	'style' => 'build/base/css',
	'script' => 'build/base/js',
	'editor_ui_style' => 'build/blocks/css',
	'editor_ui_script' => 'build/blocks/js',
	default   => 'build/base'
};

The desired alignment:

$asset_dir = match ( $asset_type ) {
	'style'            => 'build/base/css',
	'script'           => 'build/base/js',
	'editor_ui_style'  => 'build/blocks/css',
	'editor_ui_script' => 'build/blocks/js',
	default            => 'build/base'
};
@jrfnl
Copy link
Member

jrfnl commented Aug 9, 2024

@jacobcassidy Good question. AFAICS, the PER standard does not have rules about this. Might be an idea to open an issue in the PER repo ?

Independently of the outcome of such a discussion, I'd be open to accepting two different, but related sniffs for match arrow alignment:

  1. To align the arrows.
  2. To disallow alignment and enforce one space either side of the arrows.

Having both sniffs available would allow either style to be enforced, depending on the preference of the coding standard including the sniffs.

P.S.: Please use the appropriate issue template when opening an issue (and do not remove the template).

@jacobcassidy
Copy link
Author

@jrfnl Sounds good. I'll open an issue with the PER repo, and when I have extra time, I'll review this repo to see how to create the sniffs you mentioned.

P.S.: Please use the appropriate issue template when opening an issue (and do not remove the template).

Noted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants