Coder Social home page Coder Social logo

Comments (3)

sharon-wang avatar sharon-wang commented on June 2, 2024

We've decided that multi-line comment format, i.e.

/*
 *
 */

is reserved for documentation outside of functions/code.

// will be used for single line comments only, such as in-line documentation with code.


All comments should use sentence case (i.e. start with a capital), but only multi-line comments should include periods. Single line comments should not end with a period.

Multi-line example

/**
 * Retrieve the favicon path.
 * 
 * @return {String} The absolute or relative path from the site origin to the favicon.
 */

Single line example

// Default favicon path is at the root of the origin

from akita.

vezwork avatar vezwork commented on June 2, 2024

We've decided that early returns in functions are preferred over returning once at the end of a function, i.e.
✅ PREFERRED:

function example(input) {
  if (input !== null) {
    return true;
  }
  return false;
}

❌ NOT-PREFERRED:

function example(input) {
  const result = false;
  if (input !== null) {
    result = true;
  }
  return result;
}

Justification: early returns make it easier to understand a code-path of a function without having to read the entire function. They also make it so that you do not have to think about and keep track of function-scoped variables while reading the function.

Note that there are cases where it could be better to not early return, for example if you have to cleanup resources before returning, it may be better to have that cleanup code once at the end of the function before you return.

from akita.

vezwork avatar vezwork commented on June 2, 2024

It would be good to have html style opinions. The formatting is quite strange and not especially readable right now. (Sharon thinks so too).

from akita.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.