loading...
Cover image for You must read: Deno Style Guide.

You must read: Deno Style Guide.

qm3ster profile image Mihail Malo Updated on ・2 min read

Good afternoon.
Without further ado, please go read the Deno Style Guide
Especially if you don't use deno, and don't intend to try it out any time soon.

If, for no apparent reason, you want to read some excerpts with emojis in between, here are some of the many gems in that little document:

  1. A function that is part of the public API takes 0-2 required arguments, plus (if necessary) an options object (so max 3 total).
  2. Optional parameters should generally go into the options object.

  3. The 'options' argument is the only argument that is a regular 'Object'.

    Other arguments can be objects, but they must be distinguishable from a 'plain' Object at runtime, by having either:

    • a distinguishing prototype (e.g. Array, Map, Date, class MyThing)
    • a well-known symbol property (e.g. an iterable with Symbol.iterator).

This allows the API to evolve in a backwards compatible way, even when the position of the options object changes.

Finger Up

Meta-programming is discouraged. Including the use of Proxy.

Be explicit even when it means more code.

Palms Up Together

Do not document function arguments unless they are non-obvious in their intent (though if they are non-obvious, the API should be reconsidered anyways). Therefore @param should generally not be used.

Fire

Code examples should not contain additional comments. It is already inside a comment. If it needs further comments it isn't a good example.

Sick Burn

If you want to steal it for your project, this is where the markdown lives.

Deno Logo Animated

Disclaimer: The author is not affiliated with the deno project or its authors. Copyright of all images belongs to their respective owners.

Have fun!

Posted on by:

Discussion

markdown guide