File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -1070,10 +1070,12 @@ const { fontSizes } = useTheme();
10701070
10711071### Comments
10721072
1073- In general, try to avoid comments by writing expressive code and naming things what they are.
1073+ Favor expressive code over comments by using meaningful names and clear logic. Comments should primarily explain "why," not " what" or "how."
10741074
1075- Use comments when you need to add context or explain choices that cannot be expressed through code (e.g., config files).
1076- As a rule of thumb, try to explain "why" in comments, not "how" and "what".
1075+ Use comments when:
1076+
1077+ - Context or reasoning isn't obvious from the code (e.g., config files, workarounds).
1078+ - You need to reference related issues, PRs, or future improvements.
10771079
10781080` ` ` ts
10791081// ❌ Avoid
@@ -1082,12 +1084,12 @@ const m = s * 60;
10821084// avg users per minute
10831085const myAvg = u / m ;
10841086
1085- // ✅ Use - Expressive code and name things what they are
1087+ // ✅ Use - Prefer expressive code by naming things what they are
10861088const SECONDS_IN_MINUTE = 60 ;
10871089const minutes = seconds * SECONDS_IN_MINUTE ;
10881090const averageUsersPerMinute = noOfUsers / minutes ;
10891091
1090- // ✅ Use - Add context to explain why in comments
1092+ // ✅ Use - Add context to explain why
10911093// TODO: Filtering should be moved to the backend once API changes are released.
10921094// Issue/PR - https://github.com/foo/repo/pulls/55124
10931095const filteredUsers = frontendFiltering (selectedUsers );
You can’t perform that action at this time.
0 commit comments