From 2e18e8dc5a626d0fb02c973baff85e034bf217c2 Mon Sep 17 00:00:00 2001 From: "Qiaosen (Joeson) Huang" Date: Wed, 20 Jan 2021 15:54:19 +0800 Subject: [PATCH 1/2] Time/Duration naming convention --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 420237a1..98572f8d 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ - [English language](#english-language) - [Naming convention](#naming-convention) +- [Time/Duration naming convention](#time-duration-naming-convention) - [S-I-D](#s-i-d) - [Avoid contractions](#avoid-contractions) - [Avoid context duplication](#avoid-context-duplication) @@ -59,6 +60,23 @@ const page_count = 5 const should_update = true ``` +## Time/Duration naming convention + +Name your variables with **units**. For timestamps, if not using a native date/timestamp type, be sure to have something like `seconds` or `ns`. + +```js +/* Bad */ +const startAt = Date.now() +const delay = 5 + +/* Good */ +const startAtUnixMilliseconds = Date.now() +const delaySeconds = 5 + +/* Good as well */ +const start_at_unix_ms = Date.now() +``` + ## S-I-D A name must be _short_, _intuitive_ and _descriptive_: From 4f443062e81043fc666cb6066a161f894ba222b8 Mon Sep 17 00:00:00 2001 From: "Qiaosen (Joeson) Huang" Date: Wed, 20 Jan 2021 15:55:59 +0800 Subject: [PATCH 2/2] fix anchor --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98572f8d..158542a4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ - [English language](#english-language) - [Naming convention](#naming-convention) -- [Time/Duration naming convention](#time-duration-naming-convention) +- [Time/Duration naming convention](#timeduration-naming-convention) - [S-I-D](#s-i-d) - [Avoid contractions](#avoid-contractions) - [Avoid context duplication](#avoid-context-duplication)