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

Add prettier to autoformat source, docs, and config #207

Merged
merged 10 commits into from
Mar 22, 2023

Conversation

mcous
Copy link
Member

@mcous mcous commented Mar 22, 2023

Overview

After a very scientific poll in Slack with four 👍's and no 👎's, this PR adds prettier to this repository. I attempted to follow the config found in the eslint settings, the source itself, and viamrobotics/viam-typescript-sdk.

I also added some brief usage instructions for development tasks/scripts to CONTRIBUTING.md.

Change log

This PR is split into three various commits to aid reviewing:

  1. The config changes themselves
  2. Running npm run format
  3. A single file rename I found where a test file did not match existing conventions of lowercase file names
  4. ...fixups and review requests

If helpful, I can split these changes into multiple PRs.

Test plan

Given automated tests in place (though they're a bit flaky on my machine; requiring increased timeouts for the code editor tests), I think giving Storybook a quick visual comparison to prod should be pretty good here.

You may notice that the browser table in the README is broken in Storybook. This an existing issue on the site due to Storybook v7 dropping GFM by default, and not caused by this PR.

@mcous mcous marked this pull request as draft March 22, 2023 15:59
@mcous mcous removed the request for review from micheal-parks March 22, 2023 15:59
@@ -4,6 +4,6 @@
"csstools.postcss",
"bradlc.vscode-tailwindcss",
"svelte.svelte-vscode",
"silvenon.mdx"
"unifiedjs.vscode-mdx"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I assume silvenon.mdx is now deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this is the new one

@@ -35,3 +35,41 @@ More detailed docs exist on [the storybook](https://www.viam.com/prime).
Linked below are some articles that provide knowledge for how to best build reusable, generic web components.

- [Custom Elements Best Practices](https://web.dev/custom-elements-best-practices/)

## Development tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

</script>

<div class='relative w-full'>
<div class="relative w-full">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Since we're interspersing JS + HTML here could we have prettier using single quotes for everything? I'd rather not have to mentally switch between the two in the same file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely agree, and attempted to do so by setting jsxSingleQuote to true, but ran right into sveltejs/prettier-plugin-svelte#253.

Options, depending on how much we care about this:

  1. Live with it until issue is resolved
  2. Don't format .svelte files until issue is resolved
  3. Ditch the PR 😭

In my personal experience working in projects that used ' in JS and " in JSX, I stopped thinking about it quite quickly once "format on save" was turned on, but YMMV

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm cool with 1., my only rec would be to link sveltejs/prettier-plugin-svelte#271 somewhere in the eslint config so that we don't forget to track

@mcous mcous marked this pull request as ready for review March 22, 2023 16:15
Copy link
Member

@micheal-parks micheal-parks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Are you planning on replicating in APP and RDK next?

@mcous mcous merged commit 2669321 into viamrobotics:main Mar 22, 2023
@mcous mcous deleted the add-prettier branch March 22, 2023 19:03
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

Successfully merging this pull request may close these issues.

3 participants