Skip to content

Coding Standards: Naming conventions for abbreviated camel-case #2511

@aduth

Description

@aduth

How should we capitalize abbreviations and acronyms? This is an area where Core JavaScript Coding Standards are not prescriptive (but perhaps should be).

For example, in assigning a user ID variable, which is preferable:

  • userId
  • userID

The language / DOM are not especially consistent here:

There was a similar discussion in developing adapted standards in Calypso, resulting in camel-case covering abbreviations and acronyms:

https://github.com/Automattic/wp-calypso/blob/master/docs/coding-guidelines/javascript.md#naming-conventions

The reasoning being: It simplified the documentation and thought-process to recommend camelCase for everything, including abbreviations and acronyms.

In retrospect, the language itself is quite consistent on upper-cased abbreviations and acronyms (getElementById and XMLHttpRequest are browser-specific additions). Anecdotally, other libraries tend toward the same, e.g. ReactDOM, TinyMCE. I've started to adopt this in my Gutenberg work (withAPIData), but I feel we should formalize one way or the other, and update inconsistencies (withInstanceId).

Yes, this is a bikeshed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] QuestionQuestions about the design or development of the editor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions