JavaScript Style Guide - Comments

Jang Seok Woo·2022년 8월 11일
0

실무

목록 보기
115/136

18. Comments

18.1 Use /** ... */ for multiline comments.

// bad
// make() returns a new element
// based on the passed in tag name
//
// @param {String} tag
// @return {Element} element
function make(tag) {

  // ...

  return element;
}

// good
/**
 * make() returns a new element
 * based on the passed-in tag name
 */
function make(tag) {

  // ...

  return element;
}

18.2 Use // for single line comments.

Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it’s on the first line of a block.

// bad
const active = true;  // is current tab

// good
// is current tab
const active = true;

// bad
function getType() {
  console.log('fetching type...');
  // set the default type to 'no type'
  const type = this.type || 'no type';

  return type;
}

// good
function getType() {
  console.log('fetching type...');

  // set the default type to 'no type'
  const type = this.type || 'no type';

  return type;
}

// also good
function getType() {
  // set the default type to 'no type'
  const type = this.type || 'no type';

  return type;
}

18.3 Start all comments with a space to make it easier to read.

eslint: spaced-comment

// bad
//is current tab
const active = true;

// good
// is current tab
const active = true;

// bad
/**
 *make() returns a new element
 *based on the passed-in tag name
 */
function make(tag) {

  // ...

  return element;
}

// good
/**
 * make() returns a new element
 * based on the passed-in tag name
 */
function make(tag) {

  // ...

  return element;
}

18.4 Prefixing your comments with FIXME or TODO helps other developers quickly understand if you’re pointing out a problem that needs to be revisited, or if you’re suggesting a solution to the problem that needs to be implemented.

These are different than regular comments because they are actionable. The actions are FIXME: -- need to figure this out or TODO: -- need to implement.

18.5 Use // FIXME: to annotate problems.

class Calculator extends Abacus {
  constructor() {
    super();

    // FIXME: shouldn’t use a global here
    total = 0;
  }
}

18.6 Use // TODO: to annotate solutions to problems.

class Calculator extends Abacus {
  constructor() {
    super();

    // TODO: total should be configurable by an options param
    this.total = 0;
  }
}

출처 : https://github.com/airbnb/javascript

profile
https://github.com/jsw4215

6개의 댓글

comment-user-thumbnail
2022년 10월 6일

I thought it is very important and helpful. your writing is such a inspiration but I know another article that helped me a lot. visit this article

https://addandclick.com/itsShivaniroy
https://www.7sky.life/members/itsshaivaniroy/
https://www.prep4usmle.com/forum/thread/138171/
https://geto.space/read-blog/82505
https://alternativeconversation.com/read-blog/2773
https://blaquecat.com/community/read-blog/5534
http://volunters.com/Shivaniroy
https://ai.wiki/read-blog/23618
https://community.tccwpg.com/read-blog/111986
http://aulavirtual.cali.edu.co/index.php/comunicacion/foro/lithium-battery-packs-for-utility-scale-energy-storage/?start=100
https://scrolllink.com/read-blog/50289
https://www.dizalty.com/read-blog/6903
https://mygetawayzone.com/read-blog/3511
https://www.bondhuplus.com/read-blog/3450
https://www.linkspreed.com/read-blog/23917
https://komunikado.mx/read-blog/2171
https://www.whateverwant.com/read-blog/8438
https://matesbook.in/read-blog/2516
https://vietuniversity.com/read-blog/6240
https://social.kubo.chat/read-blog/3378
https://mpnccc.net/extranet//read-blog/62096
https://fansitemanagement.com/read-blog/2262
https://www.connect.aauaalumni.com/read-blog/2175
https://www.pickmemo.com/read-blog/80960
https://formyanmarbymyanmar.com/read-blog/4246
http://demo.advised360.com/read-blog/49172
https://bimindonesia.id/read-blog/2091
https://www.sdssocial.world/read-blog/43693
https://www.xn--gber-0ra.com/read-blog/12313
https://cariblime.net/read-blog/8648
https://netgork.com/read-blog/11039
https://tokemonkey.com/read-blog/74958
https://social.urgclub.com/read-blog/36140
http://networks786.ovh/read-blog/51072
https://www.plingue.com/read-blog/83657
https://talknchat.net/read-blog/7825
https://community.tccwpg.com/read-blog/113963
https://www.b-webdesign.org/dir-wowonder/read-blog/111655
https://frustratedgamers.com/read-blog/38380
https://www.rolonet.com/blogs/132381/Enjoy-VIP-Escort-services-in-Chennai
https://social.mactan.com.br/read-blog/73837
https://richonline.club/read-blog/71399
https://community.wongcw.com/blogs/201439/Russian-Escorts-Service-In-Chennai
http://social.marksedgwick.net/blogs/14395/Find-The-Gorgeous-Female-Escorts-Service-in-Chennai
https://www.xaphyr.com/blogs/154143/We-Provide-luxury-Escort-Service-In-Chennai
https://ontimewld.com/read-blog/9316
https://inobee.com/read-blog/109505
https://anynote.co/read-blog/78060
https://tcsocialnetwork.tk/blogs/11043/High-profile-Chennai-Escort-Service
https://www.chat-hozn3.com/blogs/54045/Russian-Escorts-Service-In-Chennai-Full-night-with-Cheapest-Price
https://demo.sngine.com/blogs/111888/Chennai-Escort-Services-provided-by-beautiful-call-girls-24-7

답글 달기
comment-user-thumbnail
2023년 2월 15일

We award you to keep a solid association with Indore goes with rather than scouring their vagina with your chicken. https://www.sanakhan.in/indore-call-girls.html It's a dated improvement for getting captivated by watching a Indore Escort Connection stripping down and playing out a few provocative moves with her boobs and an uncovered post dance.

1개의 답글
comment-user-thumbnail
2024년 9월 17일

They don’t have any knowledge of anything except sex. Classy Agra Escort are classy not just because they are beautiful, but also because they have high class manners, etiquette, Agra Female Escorts and finally are people that you would not be ashamed to have at your side for an evening or even the night.

답글 달기
comment-user-thumbnail
2024년 9월 24일

They are willing to do anything and are too intelligent to make you satisfied. These Call Girl in Delhi know how to satisfy their clients' wants effectively. Moreover, they are experts in certain skills which can make you wild. It is quite assured that you will experience the finest part of your life with them.

답글 달기