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

[Project SfC]: Implement a formatter to format new/edited files #26804

Closed
Tracked by #26646
valentinpalkovic opened this issue Apr 11, 2024 · 0 comments · Fixed by #26809
Closed
Tracked by #26646

[Project SfC]: Implement a formatter to format new/edited files #26804

valentinpalkovic opened this issue Apr 11, 2024 · 0 comments · Fixed by #26809
Assignees
Labels

Comments

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Apr 11, 2024

As a user, I want to have correctly formatted files after Storybook edits story files or creates new ones.

  1. Format with prettier if available

If we can resolve a prettier config, we will format the file with prettier. We will resolve the user's installed prettier version to load their prettier file and to format files before saving them.

  1. Basic formatting by considering .editorconfig

If we can't find a prettier config, we will format the file by taking into account the settings in the user's .editorconfig for basic formatting. The editorconfig has properties to define end_of_line, tab_width, indent_size, indent_style, trim_trailing_whitespace and insert_final_newline.

Requirements

  • Provide a helper util in @storybook/core-common to format the content of a file by following the rules mentioned above.
  • When an error occurs, the content should be returned without any formatting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant