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

feat(code-formatter): Implement new code formatter #2268

Merged
merged 61 commits into from
Jan 15, 2023
Merged

Conversation

barak007
Copy link
Collaborator

@barak007 barak007 commented Jan 17, 2022

  • normalize all newlines
  • handle declaration value
    • normalize whitespace
    • inline and wrap value segments at default 80 characters wrapLineLength
    • prefer to wrap at current line last comma (if available)
    • if first top space contains a newline then respect source top level newlines
    • spread function arguments according to available wrapLineLength
  • handle case where decls "raws" contains comments or newlines
  • handle case where rule "raws" contains comments or newlines (not after separation ,\n)
  • handle case where at-rule "raws" contains comments or newlines
  • handle case where rule before atRule with no children
  • handle at-rule params
    • normalize all whitespace
    • format args-like body inside function()/[]/() according to indented newlines if first space includes a newline, otherwise inline
  • support new formatter in CLI
    • support --experimental for new formatter
    • support limited config: indentSize, endWithNewline, and wrapLineLength
    • documentation
  • support new formatter in language service

Unfinished in this PR

  • support existing config: newLineBetweenSelectors, newLineBetweenRulesets, and ignore

- run each test to see that the re-running the result stay the same
- added ToDos with issues or things that need to be discussed
- new test util to improve test visibility
- set `wrapLineLength` option with default to 80 chars
- respect newlines if value is placed in a newline from decl prop
- respect newlines for `grid-template` props in any case
- break function arguments into newlines if there is no space for them
- limit function break if total inlined length is under 30 chars or if it has a single non function arg value
- wrap value according to available space
- lookback to previous comma to wrap from
- remove custom property final space
@idoros idoros requested a review from tomrav January 5, 2023 11:28
@idoros idoros added the tooling CLI, stylable-scripts boilerplate label Jan 8, 2023
@idoros idoros merged commit b7e21fc into master Jan 15, 2023
@idoros idoros deleted the barak/code-format-2 branch January 15, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling CLI, stylable-scripts boilerplate
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

4 participants