Home

Awesome

원문: https://github.com/airbnb/javascript

Airbnb JavaScript 스타일 가이드() {

대체로 합리적인 JavaScript 접근 방법

참고: 이 가이드는 사용자가 Babelbabel-preset-airbnb 또는 이와 동등한 것을 사용한다고 가정합니다. 또한 사용자가 어플리케이션에 airbnb-browser-shims와 함께 shims/polyfills 또는 이와 동등한 것을 설치했다고 가정합니다.

Downloads Downloads Gitter

이 스타일 가이드는 다른 언어로도 제공됩니다. Translation을 보세요.

다른 스타일 가이드

목차

  1. 형 (Types)
  2. 참조 (References)
  3. 객체 (Objects)
  4. 배열 (Arrays)
  5. 비구조화 Destructuring
  6. 문자열 (Strings)
  7. 함수 (Functions)
  8. 화살표 함수 (Arrow Functions)
  9. 클래스 & 생성자 (Classes & Constructors)
  10. 모듈 (Modules)
  11. 이터레이터와 제너레이터 (Iterators and Generators)
  12. 속성 (Properties)
  13. 변수 (Variables)
  14. 호이스팅 (Hoisting)
  15. 비교 연산자 (Comparison Operators & Equality)
  16. 블록 (Blocks)
  17. 제어문 (Control Statements)
  18. 주석 (Comments)
  19. 공백 (Whitespace)
  20. 쉼표 (Commas)
  21. 세미콜론 (Semicolons)
  22. 형변환과 강제 (Type Casting & Coercion)
  23. 명명규칙 (Naming Conventions)
  24. 접근자 (Accessors)
  25. 이벤트 (Events)
  26. 제이쿼리 (jQuery)
  27. ES5 호환성 (ECMAScript 5 Compatibility)
  28. ECMAScript 6+ (ES 2015+) 스타일
  29. 표준 라이브러리 (Standard Library)
  30. 테스트 (Testing)
  31. 성능 (Performance)
  32. 자료 (Resources)
  33. In the Wild
  34. Translation
  35. The JavaScript Style Guide Guide
  36. Chat With Us About JavaScript
  37. Contributors
  38. License
  39. Amendments

형 (Types)

<a name="types--primitives"></a><a name="1.1"></a>

<a name="types--complex"></a><a name="1.2"></a>

⬆ back to top

참조 (References)

<a name="references--prefer-const"></a><a name="2.1"></a>

<a name="references--disallow-var"></a><a name="2.2"></a>

<a name="references--block-scope"></a><a name="2.3"></a>

⬆ back to top

객체 (Objects)

<a name="objects--no-new"></a><a name="3.1"></a>

<a name="es6-computed-properties"></a><a name="3.4"></a>

<a name="es6-object-shorthand"></a><a name="3.5"></a>

<a name="es6-object-concise"></a><a name="3.6"></a>

<a name="objects--grouped-shorthand"></a><a name="3.7"></a>

<a name="objects--quoted-props"></a><a name="3.8"></a>

<a name="objects--prototype-builtins"></a>

<a name="objects--rest-spread"></a>

⬆ back to top

배열 (Arrays)

<a name="arrays--literals"></a><a name="4.1"></a>

<a name="arrays--push"></a><a name="4.2"></a>

<a name="es6-array-spreads"></a><a name="4.3"></a>

<a name="arrays--from"></a> <a name="arrays--from-iterable"></a><a name="4.4"></a>

<a name="arrays--from-array-like"></a>

<a name="arrays--mapping"></a>

<a name="arrays--callback-return"></a><a name="4.5"></a>

<a name="arrays--bracket-newline"></a>

⬆ back to top

비구조화 (Destructuring)

<a name="destructuring--object"></a><a name="5.1"></a>

<a name="destructuring--array"></a><a name="5.2"></a>

<a name="destructuring--object-over-array"></a><a name="5.3"></a>

⬆ back to top

문자열 (Strings)

<a name="strings--quotes"></a><a name="6.1"></a>

<a name="strings--line-length"></a><a name="6.2"></a>

<a name="es6-template-literals"></a><a name="6.4"></a>

<a name="strings--eval"></a><a name="6.5"></a>

<a name="strings--escaping"></a>

⬆ back to top

함수 (Functions)

<a name="functions--declarations"></a><a name="7.1"></a>

<a name="functions--iife"></a><a name="7.2"></a>

<a name="functions--in-blocks"></a><a name="7.3"></a>

<a name="functions--note-on-blocks"></a><a name="7.4"></a>

<a name="functions--arguments-shadow"></a><a name="7.5"></a>

<a name="es6-rest"></a><a name="7.6"></a>

<a name="es6-default-parameters"></a><a name="7.7"></a>

<a name="functions--default-side-effects"></a><a name="7.8"></a>

<a name="functions--defaults-last"></a><a name="7.9"></a>

<a name="functions--constructor"></a><a name="7.10"></a>

<a name="functions--signature-spacing"></a><a name="7.11"></a>

<a name="functions--mutate-params"></a><a name="7.12"></a>

<a name="functions--reassign-params"></a><a name="7.13"></a>

<a name="functions--spread-vs-apply"></a><a name="7.14"></a>

<a name="functions--signature-invocation-indentation"></a>

⬆ back to top

화살표 함수 (Arrow Functions)

<a name="arrows--use-them"></a><a name="8.1"></a>

<a name="arrows--implicit-return"></a><a name="8.2"></a>

<a name="arrows--paren-wrap"></a><a name="8.3"></a>

<a name="arrows--one-arg-parens"></a><a name="8.4"></a>

<a name="arrows--confusing"></a><a name="8.5"></a>

<a name="whitespace--implicit-arrow-linebreak"></a>

⬆ back to top

클래스 & 생성자 (Classes & Constructors)

<a name="constructors--use-class"></a><a name="9.1"></a>

<a name="constructors--extends"></a><a name="9.2"></a>

<a name="constructors--chaining"></a><a name="9.3"></a>

<a name="constructors--tostring"></a><a name="9.4"></a>

<a name="constructors--no-useless"></a><a name="9.5"></a>

<a name="classes--no-duplicate-members"></a>

<a name="classes--methods-use-this"></a>

⬆ back to top

모듈 (Modules)

<a name="modules--use-them"></a><a name="10.1"></a>

<a name="modules--no-wildcard"></a><a name="10.2"></a>

<a name="modules--no-export-from-import"></a><a name="10.3"></a>

<a name="modules--no-duplicate-imports"></a>

<a name="modules--no-mutable-exports"></a>

<a name="modules--prefer-default-export"></a>

<a name="modules--imports-first"></a>

<a name="modules--multiline-imports-over-newlines"></a>

<a name="modules--no-webpack-loader-syntax"></a>

<a name="modules--import-extensions"></a>

⬆ back to top

이터레이터와 제너레이터 (Iterators and Generators)

<a name="iterators--nope"></a><a name="11.1"></a>

<a name="generators--nope"></a><a name="11.2"></a>

<a name="generators--spacing"></a>

⬆ back to top

속성 (Properties)

<a name="properties--dot"></a><a name="12.1"></a>

<a name="properties--bracket"></a><a name="12.2"></a>

<a name="es2016-properties--exponentiation-operator"></a>

⬆ back to top

변수 (Variables)

<a name="variables--const"></a><a name="13.1"></a>

<a name="variables--one-const"></a><a name="13.2"></a>

<a name="variables--const-let-group"></a><a name="13.3"></a>

<a name="variables--define-where-used"></a><a name="13.4"></a>

<a name="variables--no-chain-assignment"></a><a name="13.5"></a>

<a name="variables--unary-increment-decrement"></a><a name="13.6"></a>

<a name="variables--linebreak"></a>

<a name="variables--no-unused-vars"></a>

⬆ back to top

호이스팅 (Hoisting)

<a name="hoisting--about"></a><a name="14.1"></a>

<a name="hoisting--anon-expressions"></a><a name="14.2"></a>

<a name="hoisting--named-expresions"></a><a name="hoisting--named-expressions"></a><a name="14.3"></a>

<a name="hoisting--declarations"></a><a name="14.4"></a>

⬆ back to top

비교 연산자 (Comparison Operators & Equality)

<a name="comparison--eqeqeq"></a><a name="15.1"></a>

<a name="comparison--if"></a><a name="15.2"></a>

<a name="comparison--shortcuts"></a><a name="15.3"></a>

<a name="comparison--moreinfo"></a><a name="15.4"></a>

<a name="comparison--switch-blocks"></a><a name="15.5"></a>

<a name="comparison--nested-ternaries"></a><a name="15.6"></a>

<a name="comparison--unneeded-ternary"></a><a name="15.7"></a>

<a name="comparison--no-mixed-operators"></a>

⬆ back to top

블록 (Blocks)

<a name="blocks--braces"></a><a name="16.1"></a>

<a name="blocks--cuddled-elses"></a><a name="16.2"></a>

<a name="blocks--no-else-return"></a><a name="16.3"></a>

⬆ back to top

제어문 (Control Statements)

<a name="control-statements"></a>

<a name="control-statement--value-selection"></a>

⬆ back to top

주석 (Comments)

<a name="comments--multiline"></a><a name="17.1"></a>

<a name="comments--singleline"></a><a name="17.2"></a>

<a name="comments--spaces"></a>

<a name="comments--actionitems"></a><a name="17.3"></a>

<a name="comments--fixme"></a><a name="17.4"></a>

<a name="comments--todo"></a><a name="17.5"></a>

⬆ back to top

공백 (Whitespace)

<a name="whitespace--spaces"></a><a name="18.1"></a>

<a name="whitespace--before-blocks"></a><a name="18.2"></a>

<a name="whitespace--around-keywords"></a><a name="18.3"></a>

<a name="whitespace--infix-ops"></a><a name="18.4"></a>

<a name="whitespace--newline-at-end"></a><a name="18.5"></a>

<a name="whitespace--chains"></a><a name="18.6"></a>

<a name="whitespace--after-blocks"></a><a name="18.7"></a>

<a name="whitespace--padded-blocks"></a><a name="18.8"></a>

<a name="whitespace--no-multiple-blanks"></a>

<a name="whitespace--in-parens"></a><a name="18.9"></a>

<a name="whitespace--in-brackets"></a><a name="18.10"></a>

<a name="whitespace--in-braces"></a><a name="18.11"></a>

<a name="whitespace--max-len"></a><a name="18.12"></a>

<a name="whitespace--comma-spacing"></a>

<a name="whitespace--computed-property-spacing"></a>

<a name="whitespace--func-call-spacing"></a>

<a name="whitespace--no-multiple-empty-lines"></a>

⬆ back to top

쉼표 (Commas)

<a name="commas--leading-trailing"></a><a name="19.1"></a>

<a name="commas--dangling"></a><a name="19.2"></a>

⬆ back to top

세미콜론 (Semicolons)

<a name="semicolons--required"></a><a name="20.1"></a>

⬆ back to top

형변환과 강제 (Type Casting & Coercion)

<a name="coercion--explicit"></a><a name="21.1"></a>

<a name="coercion--strings"></a><a name="21.2"></a>

<a name="coercion--numbers"></a><a name="21.3"></a>

<a name="coercion--comment-deviations"></a><a name="21.4"></a>

<a name="coercion--bitwise"></a><a name="21.5"></a>

<a name="coercion--booleans"></a><a name="21.6"></a>

⬆ back to top

명명규칙 (Naming Conventions)

<a name="naming--descriptive"></a><a name="22.1"></a>

<a name="naming--camelCase"></a><a name="22.2"></a>

<a name="naming--PascalCase"></a><a name="22.3"></a>

<a name="naming--leading-underscore"></a><a name="22.4"></a>

<a name="naming--self-this"></a><a name="22.5"></a>

<a name="naming--filename-matches-export"></a><a name="22.6"></a>

<a name="naming--camelCase-default-export"></a><a name="22.7"></a>

<a name="naming--PascalCase-singleton"></a><a name="22.8"></a>

<a name="naming--Acronyms-and-Initialisms"></a>

<a name="naming--uppercase"></a>

⬆ back to top

접근자 (Accessors)

<a name="accessors--not-required"></a><a name="23.1"></a>

<a name="accessors--no-getters-setters"></a><a name="23.2"></a>

<a name="accessors--boolean-prefix"></a><a name="23.3"></a>

<a name="accessors--consistent"></a><a name="23.4"></a>

⬆ back to top

이벤트 (Events)

<a name="events--hash"></a><a name="24.1"></a>

⬆ back to top

제이쿼리 (jQuery)

<a name="jquery--dollar-prefix"></a><a name="25.1"></a>

<a name="jquery--cache"></a><a name="25.2"></a>

<a name="jquery--queries"></a><a name="25.3"></a>

<a name="jquery--find"></a><a name="25.4"></a>

⬆ back to top

ES5 호환성 (ECMAScript 5 Compatibility)

<a name="es5-compat--kangax"></a><a name="26.1"></a>

⬆ back to top

<a name="ecmascript-6-styles"></a>

ECMAScript 6+ (ES 2015+) 스타일

<a name="es6-styles"></a><a name="27.1"></a>

  1. 화살표 함수 (Arrow Functions)
  2. 클래스 (Classes)
  3. 객체 단축형 (Object Shorthand)
  4. 객체 속성 단축형 (Object Concise)
  5. 객체 속성 계산 (Object Computed Properties)
  6. 템플릿 문자열 (Template Strings)
  7. 비구조화 (Destructuring)
  8. 기본 매개변수 (Default Parameters)
  9. 나머지 구문 (Rest)
  10. 배열 전개 (Array Spreads)
  11. Let과 Const (Let and Const)
  12. 제곱 연산자 (Exponentiation Operator)
  13. 이터레이터와 제너레이터 (Iterators and Generators)
  14. 모듈 (Modules)

<a name="tc39-proposals"></a>

⬆ back to top

표준 라이브러리 (Standard Library)

표준 라이브러리는 기능적으로 문제가 있지만 레거시 이유로 아직 남아있는 유틸리티들을 포함하고 있습니다.

<a name="standard-library--isnan"></a>

<a name="standard-library--isfinite"></a>

⬆ back to top

테스트 (Testing)

<a name="testing--yup"></a><a name="28.1"></a>

<a name="testing--for-real"></a><a name="28.2"></a>

⬆ back to top

성능 (Performance)

⬆ back to top

자료 (Resources)

Learning ES6+

Read This

Tools

Other Style Guides

Other Styles

Further Reading

Books

Blogs

Podcasts

⬆ back to top

In the Wild

아래 목록은 이 스타일 가이드를 사용하고 있는 단체들입니다. 우리에게 풀 리퀘스트를 보내면 리스트에 추가해드리겠습니다.

⬆ back to top

Translation

이 스타일 가이드는 다른 언어로도 제공됩니다:

The JavaScript Style Guide Guide

Chat With Us About JavaScript

Contributors

License

(The MIT License)

Copyright (c) 2012 Airbnb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

⬆ back to top

Amendments

우리는 당신이 이 가이드를 포크해서 당신의 팀에 알맞도록 고쳐 쓰기를 바랍니다. 아래에 스타일 가이드의 수정 사항을 나열하세요. 이렇게 하면 병합 충돌(marge conflicts)을 신경쓰지 않고 스타일 가이드를 정기적으로 업데이트 할 수 있습니다.

};