From f86d4ca78ec9540517d4e97eb975e08183eb6fdb Mon Sep 17 00:00:00 2001 From: DCoded <dicoded@email.com> Date: Wed, 28 Apr 2021 14:20:01 -0400 Subject: [PATCH] Updated documentation to specifiy enums --- CONTRIBUTING.md | 40 +++++++++++++++++++++++++++++++++++----- js/003-data/constants.js | 1 + 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0bf368aeb2..577bcb95858 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,16 +68,46 @@ let FooBar; let fooBar; ``` -* JavaScript constants should be `ALLCAPS`. +* Enum members should be `ALLCAPS`. + +```ts +// bad +enum Foo { + bar = 'bar', + Baz = 'baz', +} + +// good +enum Foo { + BAR = 'bar', + BAZ = 'baz', +} +``` + +This also applies to JavaScript objects that are used as enums. ```js // bad -const foo = 'foo'; -const fooBar = 'fooBar'; +/** @enum {string} */ +const foo = { + bar: 'bar', + Baz: 'baz', +} // good -const FOO = 'foo'; -const FOOBAR = 'fooBar'; +/** @enum {string} */ +const foo = { + BAR: 'bar', + BAZ: 'baz', +} + + +// better +/** @enum {string} */ +const Foo = { + BAR: 'bar', + BAZ: 'baz', +} ``` * JavaScript classes and namespaces should be `PascalCase`. diff --git a/js/003-data/constants.js b/js/003-data/constants.js index 96a0787e125..e95ba10df9f 100644 --- a/js/003-data/constants.js +++ b/js/003-data/constants.js @@ -68,6 +68,7 @@ globalThis.Job = Object.freeze({ TANK: '@lay in tank' }); + /** * @enum {string} */ -- GitLab