Code Style #66
Replies: 4 comments 2 replies
-
Great stuff. If possible, let's draw attention to this discussion semi-regularly (meetings, reviews, etc) so that it can continue to grow and we can updated the related documentation. |
Beta Was this translation helpful? Give feedback.
-
Ok I have an initial bullet list, these are all things that I needed to learn about and/or tripped me up, causing me to spend time learning the hard way how code should be structured. There are doubtless many more we could (and should) include, but here's my starter... Third Party Libraries
Code Patterns
Some other Minor Rules
|
Beta Was this translation helpful? Give feedback.
-
Thats a very good list @NB-MikeRichardson great point to start from. There are some things that are more specific to AFJ and some things that are more generic TypeScript convention and a seperation between both would be good if we want to turn this into a proper guidelines document. Couple of minor notes:
I think the current pattern is: use kebab case for any file unless the entire file is a single
Now, the differences between I feel like some of this can be enforced with Also, I think should should abstract the type type SomeName<Key extends string | number | symbol = string, Value = unknown> = Record<Key, Value> We have to pick a good name for this, but this type could be documented saying that it just types a nested JSON object. Type aliasing might be interesting in the framework as well. It might help explaining that the return type of One last thing is that we should not add typings when they are infered perfectly. Something like this adds a lot of unnecessary text and can make reading the code a bit more cumbersome. const arr: Array<number> = [1, 2, 3] as const
const num: number = 1;
const x: Record<'foo' | 'bar', number> = {'foo': 1, 'bar': 2} as const Again, a great start @NB-MikeRichardson I really struggled to even think of 1 thing we should add :). |
Beta Was this translation helpful? Give feedback.
-
How should we version the docs so that they don't follow only the latest version? |
Beta Was this translation helpful? Give feedback.
-
During the AFJ WG call today we discussed the fact that we have some unwritten rules regarding the coding style in AFJ and related repositories. Because these rules are largely subjective, new contributors have a hard time understanding what these rules are, resulting in a large amount of PR review comments that are purely about code style.
The purpose of this discussion is to gather a list of all the code styling rules we follow, so we can start documenting them. A dedicated section in the documentation site will probably help new contributors get up to speed faster.
Beta Was this translation helpful? Give feedback.
All reactions