ni / javascript-styleguide

JavaScript and TypeScript Style Guide
MIT License
9 stars 9 forks source link

naming-convention for objects that act as enums #89

Closed jattasNI closed 2 years ago

jattasNI commented 2 years ago

In nimble we want to use a pattern from FAST where we use const objects instead of enums. But when we create these objects, they violate our naming-convention configuration because we require enums to use PascalCase for their name and items but we require variables and object fields to use camelCase names. image

Should we:

  1. not adopt this pattern?
  2. use camelCase naming even for enum-like objects?
  3. relax our rules to allow both naming conventions?
  4. see if we can configure the rule to allow exactly the cases we want (e.g. use selector to say that export const variables can be PascalCase)?
jattasNI commented 2 years ago

Discussed in our meeting today with @rajsite and @TrevorKarjanis. Consensus was that all of these are repo-specific decisions:

  1. whether to use enum or const objects
  2. if using const objects, what the capitalization should be
  3. how to enforce that capitalization via linting Eventually we may want to encourage/enforce a preference for not using TS-only features like enums and private fields, but that is a long way away.

So for now, the styleguide provides a good default and repos should feel free to override those decisions if their APIs require it (as Nimble is now doing). Closing with no action.

@mure, feel free to comment if you disagree with this direction.