You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b69903a
Browse filesBrowse the repository at this point in the historyBrowse files
- Create loggers once at module scope, not inside functions.
103
103
- Do not use the logger in scripts (locally-run code); `console.log` is fine there.
104
+
105
+
## Code comments
106
+
107
+
- Comments explain _why_ and not _what_. Use variables, names, types, and structure to convey _what_ the code does. If the code doesn't need a _why_, don't write a comment.
- Use active voice and active, specific verbs. Avoid phrases like "there is", "should", or vague "uses". Prefer "does x" over "is x". Do not hedge. If needed, write the action then the reason, such as "do X, so Y".
111
+
- Do not narrate, restate, or summarize the code.
112
+
- Avoid jargon, or define jargon if you must use it.
113
+
- Describe the current state. Avoid framing such as "now" or "recently". Do not include the previous state.
114
+
- In TypeScript and JavaScript, prefer `//` over `/*` comments. Only use `/*` if `//` makes the formatting too awkward or in JSX. Do not use JSDoc or TSDoc style comments.
115
+
- Do not use comments to add headings, dividers, steps, or other structures.
116
+
- Comments that need more than one line: break at sentence ends and clauses. Prettier does not reflow comment format.
117
+
- Avoid excessive formatting. Only use parentheses to refer to literal syntax. Do not use markdown-style formatting. Do not use emdashes. You may use uppercase to emphasize words, rarely.
118
+
- Keep comments inside a function body to a single line. Place multiline comments above the function.
119
+
- Do not reference issues, pull requests, or discussions in the `github` organization, such as numbers or URLs. Include the context directly in the comment or in a nearby markdown file. You may use a full URL to an issue in an external open source project.
120
+
- Do not reference line numbers or line counts. Do not reference specific versions unless a future version requires action.
121
+
- Do not leave TODO, FIXME, or HACK comments.
122
+
- Do not keep commented out code.
123
+
- You may label deliberately absent fields.
124
+
- You may write a simple input and output example for regular expressions. Use realistic data and not garbage like foo/bar or Alice/Bob.
125
+
- You may use internal cross-reference identifiers in comments, such as unique error codes.
126
+
- You may use tool directives such as `@ts-expect-error` or `eslint-disable` in rare cases.
127
+
- You may add legally required comments like license and copyright.
0 commit comments