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

TypeScript styleguide #232

Closed
sverps opened this issue Mar 10, 2023 · 3 comments
Closed

TypeScript styleguide #232

sverps opened this issue Mar 10, 2023 · 3 comments
Labels
discussion Further information is discussed

Comments

@sverps
Copy link
Collaborator

sverps commented Mar 10, 2023

I propose choosing and following a style guide to get more consistency throughout the code.

My choice would be to follow google's style guide.

Some possible exceptions:

  • To avoid having to rename practically all files, I think we could opt to disregard the filename rule.
  • [anything else?]
@carletex
Copy link
Member

carletex commented Mar 10, 2023

Thanks for this @sverps !

I think being consistent is the key here.

The google guide is huge and we shouldn't try to follow it word by word. Just use it as a reference / starting point and stick to what works for us. We can also use it when we don't have a strong opinion about something, to help us decide.

  • I like this for Identifiers:

image

For JSDocs comments

  • Remove @dev (inherited from Solidity, not valid JSdocs. Talked with Shiv about this)

  • love this also :D
    image

  • They use single quotes (even if they don't mention it, they just use them in their example). Let's stick with double quotes :D

  • I prefer using "~/whatever", than "../.../whatever"
    image


Left a few notes and... actionable items?

And lets keep discussing! Thanks.

@carletex carletex added the discussion Further information is discussed label Mar 10, 2023
@rin-st
Copy link
Member

rin-st commented Mar 12, 2023

To avoid having to rename practically all files, I think we could opt to disregard the filename rule.

Yep, let's leave it as is:
UpperCamelCase for components/solidity contracts and tests for them
kebab-case for pages
snake_case ? for hardhat/deploy files
lowerCamelCase for everything else


Agree with everything @carletex wrote.

Interface vs Types

I prefer to use Types

Rename all the Types that start with T?

Yes, except types in generics, as @sverps wrote here #231 (comment)


Again, regarding default export

Next.js supports lazy loading for named exports using next/dynamic docs.

So, if you're ok with writing one additional then for potential lazy loading, we probably don't need default exports anymore

@ByteAtATime
Copy link
Contributor

My personal opinion, I think we can leave default exports as-is, since it's very common in React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Further information is discussed
Projects
None yet
Development

No branches or pull requests

5 participants