| Rules | Lint? | Notes |
|---|---|---|
| Types | ⬛ | Skip: #1.1, #1.2 |
| References | ✅ | Skip: #2.3 |
| Objects | ✅ | Other Rules: |
Prettier: #3.6 | | Arrays | ✅ | Other Rules:
... to copy arrays. (#4.3)... instead of Array.from (#4.4)Array.from for converting an array-like object to an array. (#4.5)Array.from instead of spread ... for mapping over iterables, because it avoids creating an intermediate array. (#4.6)Prettier: #4.8 | | Destructuring | ✅ | **Other Rules:
Prettier: #6.1 | | Functions | ✅ | Other Rules:
Prettier: #7.11, #7.15 | | Arrow Functions | ✅ | Prettier: #8.3, #8.4, #8.5, #8.6 | | Classes & Constructors | ✅ | Other Rules:
class. Avoid manipulating prototype directly. (#9.1)extends for inheritance. (#9.2)this to help with method chaining. (#9.3)toString() method, just make sure it works successfully and causes no side effects. (#9.4) |
| Modules | ✅ | Other Rules:import/export) over a non-standard module system. You can always transpile to your preferred module system. (#10.1)Prettier: #10.4, #10.8 | | Iterators and Generators | ✅ | Prettier: #11.3 | | Properties | ✅ | Prettier: #12.1 | | Variables | ✅ | Other Rules:
Prettier: #13.2, #13.3
Skip: #13.7, #13.8 (handled by eslint-plugin-unused-imports) |
| Hoisting | ✅ | Skip: #14.1, #14.2, #14.3, #14.4 |
| Comparison Operators & Equality | ✅ | Other Rules:
Prettier: #15.7, #15.8 Skip: #15.2, #15.4, #15.9 | | Blocks | ⬛ | Prettier: #16.1, #16.2, #16.3 | | Control Statements | ⬛ | Other Rules:
Prettier: #17.1 | | Comments | ✅ | Other Rules:
/** ... */ for multiline comments. (#18.1)// 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. (#18.2)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.4)// FIXME: to annotate problems. (#18.5)// TODO: to annotate solutions to problems. (#18.6)Prettier: #18.3 | | Whitespace | ✅ | **Other Rules:
Prettier:** #19.1, #19.2, #19.3, #19.4, #19.5, #19.6, #19.8, #19.9, #19.10, #19,11, #19.12, #19.13, #19.14, #19.16, #19.17, #19.18, #19.19, #19.20 |
| Commas | ⬛ | Prettier: #20.1, #20.2 |
| Semicolons | ⬛ | Prettier: #21.1 |
| Type Casting & Coercion | ✅ | Other Rules:
1. If for whatever reason you are doing something wild and parseInt is your bottleneck and need to use Bitshift for performance reasons, leave a comment explaining why and what you’re doing. (#22.4)
Skip: #22.1, #22.5 | | Naming Conventions | ✅ | Other Rules:
this. Use arrow functions or Function#bind. (#23.5)const (it can not be reassigned), and (3) the programmer can trust it (and its nested properties) to never change. (#23.10)Skip: #23.1 (airbnb 設置是 off) |
| Accessors | ⬛ | Other Rules:
getVal() and setVal('hello'). (#24.2)boolean, use isVal() or hasVal(). (#24.3)get() and set() functions, but be consistent. (#24.4)Skip: #24.1 | | Events | ⬛ | Other Rules:
$. (#26.1)$('.sidebar ul') or parent > child $('.sidebar > ul'). jsPerf (#26.3)find with scoped jQuery object queries. (#26.4) |
| ECMAScript 5 Compatibility | ⬛ | Skip: #27.1 |
| ECMAScript 6+ (ES 2015+) Styles | ⬛ | Other Rules:Skip: #28.1 |
| Standard Library | ✅ | |
| Testing | ⬛ | Other Rules:
1. Whichever testing framework you use, you should be writing tests!
2. Strive to write many small pure functions, and minimize where mutations occur.
3. Be cautious about stubs and mocks - they can make your tests more brittle.
4. We primarily use mocha and jest at Airbnb. tape is also used occasionally for small, separate modules.
5. 100% test coverage is a good goal to strive for, even if it’s not always practical to reach it.
6. Whenever you fix a bug, write a regression test. A bug fixed without a regression test is almost certainly going to break again in the future.
Skip: #30.1 |
| Rules | Lint? | Notes |
|---|---|---|
| Basic Rules | ✅ | |
| Class vs React.createClass vs stateless | ✅ | |
| Mixins | ⬛ | Skip |
| Naming | ✅ | Other Rules: |
.jsx, .tsx extension for React components.ReservationCard.jsxReservationCard.jsx should have a reference name of ReservationCard. |
| Declaration | ✅ | |
| Alignment | ⬛ | Prettier |
| Quotes | ✅ | |
| Spacing | ⬛ | Prettier |
| Props | ✅ | Other Rules: