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 to use tabs #232

Open
muuvmuuv opened this issue May 15, 2024 · 11 comments
Open

Option to use tabs #232

muuvmuuv opened this issue May 15, 2024 · 11 comments

Comments

@muuvmuuv
Copy link

Rule(s) related to or rule(s) missing

  • Whitespace\IndentRule
  • Whitespace\IndentStyle ← missing

Expected behavior

Should convert spaces to tabs by indention rule.

Actual behavior

No rule to use tabs instead of spaces.

@VincentLanglet
Copy link
Owner

Hi @muuvmuuv,

Should convert spaces to tabs by indention rule.

If you have the following code

Tab - 5 spaces - Foo - 5 spaces - Bar

Do you expect:

Tab - Tab - 1 space - Foo - 5 spaces - Bar

?

And what do you mean by

Whitespace\IndentStyle ← missing

@muuvmuuv
Copy link
Author

If I say my setting is one tab indention and one tab equals two spaces it would just be

Tab - Foo - 5 Spaces - Bar

In the GitHub issue template it says "...rule(s) missing", so I expected that means I need to provide an example of a missing rule?

@VincentLanglet
Copy link
Owner

In the GitHub issue template it says "...rule(s) missing", so I expected that means I need to provide an example of a missing rule?

I think it will be more an option to add to Whitespace\IndentRule

If I say my setting is one tab indention and one tab equals two spaces it would just be

Tab - Foo - 5 Spaces - Bar

I kinda disagree here. Code ca be indented with

  • 0 tab
  • 1 tab
  • 2 tabs
  • etc

for instance

<div class="div1">
	<div class="div2>
		<p> Text </p>
	</div>
</div>

I agree on the fact I need a spaceRatio between tabs and space (you use one tab for two spaces, I generally see one tab for 4 spaces). But I can only replace x spaces by one tab, without removing tabs or extra spaces. So the rule (with a 4 space ratio) will replace

  • 8 spaces by 2 tabs
  • 10 spaces by 2 tabs and 2 spaces
  • 1 tab and 4 spaces by 2 tabs
  • 1 tab and 6 spaces by 2 tabs and 2 spaces

This is the best I can do IMHO.

@muuvmuuv
Copy link
Author

Oh, sorry I misunderstood you with the "5 spaces", yes you are right, some ratio is needed in order to replace them correctly.

If tabs are used, I would expect overflowing spaces to be removed if they aren't in the ratio range, otherwise the option wouldn't make sense for a fixed indention.

@VincentLanglet
Copy link
Owner

If tabs are used, I would expect overflowing spaces to be removed if they aren't in the ratio range, otherwise the option wouldn't make sense for a fixed indention.

I let this to another Rule in creation which would be IndentLengthRule checking that indentation is a multiple of space ratio or tabs.

@muuvmuuv
Copy link
Author

Maybe something like "style" and "size" makes more sense and its set to spaces by default? Biome does something similar: https://biomejs.dev/reference/configuration/#formatterindentstyle

@rrenteria-dev
Copy link

+1

@VincentLanglet
Copy link
Owner

WIP #236 ; any feedback is welcome

@rrenteria-dev
Copy link

rrenteria-dev commented May 31, 2024

WIP #236 ; any feedback is welcome

Amazing! Will test it out!
Thank you for your hard work, this linter is amazing.

Not trying to hijack the subject, but by any chance can you give me a pointer about how to use your tool inside vscode? php-cs-fixer does a terrible job as a twig* formatter.

@VincentLanglet
Copy link
Owner

Not trying to hijack the subject, but by any chance can you give me a pointer about how to use your tool inside vscode? php-cs-fixer does a terrible job as a twig* formatter.

There is no native integration of twig-cs-fixer inside phpstorm/vscode so far.
I assume someone need to implement an integration ; I won't be this guy.

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

3 participants