{"_id":"@caitech/eslint-config-caitech","_rev":"3-78204b40fda2900571a95695a2790ee7","name":"@caitech/eslint-config-caitech","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.1":{"name":"@caitech/eslint-config-caitech","version":"1.0.1","description":"A mostly reasonable approach to JavaScript amended for the CAI tech team.","main":"eslint.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/DataVoke/javascript-style-guide.git"},"keywords":["style guide","lint","airbnb","es6","es2015","es2016","es2017","es2018","react","jsx","eslint","eslintconfig"],"author":{"name":"Harrison Shoff","email":"hi@hshoff.com","url":"https://twitter.com/hshoff"},"maintainers":[{"name":"mercieral","email":"aaron.mercier@cagents.com"}],"license":"MIT","bugs":{"url":"https://github.com/DataVoke/javascript-style-guide/issues"},"homepage":"https://github.com/DataVoke/javascript-style-guide","devDependencies":{"markdownlint":"^0.20.4","markdownlint-cli":"^0.23.2"},"dependencies":{"eslint-plugin-import":"^2.26.0","eslint-plugin-jsx-a11y":"^6.5.1","eslint-plugin-react":"^7.29.4","eslint-plugin-react-hooks":"^4.5.0"},"peerDependencies":{"eslint":"^7.32.0 || ^8.2.0"},"gitHead":"4653bc01d895ff4e0f5c9608928edb66025905a1","_id":"@caitech/eslint-config-caitech@1.0.1","_nodeVersion":"14.19.0","_npmVersion":"7.24.2","dist":{"integrity":"sha512-ECEoU9ZzPoz2X+BMIemo8V9SjU67BhhBWe8Jp60F5IqeAAFlw4CVUKid6cX/Y1I3fn9woQKRSU0mQ2EhISEG0Q==","shasum":"51b1feb9eb8bb79b73fbede847f81d30aa79bdf5","tarball":"https://registry.npmjs.org/@caitech/eslint-config-caitech/-/eslint-config-caitech-1.0.1.tgz","fileCount":7,"unpackedSize":147819,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC86DXyNvMAI7fCWtmXNk4T8we9SyAO8vYSKq0OaTvE1wIgbYNMs7BKWOzzygUeTsdJ0fRzbQtTupDL6OOHT/kdmS0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJicWFVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmraHw//XcbyJI2bKHHdUqcZuBkQmOuaXpHhAu+0JQXsRYu9FV0H4TpJ\r\n70TGl9WRa7/mHh4/m2zXbROINY4YErT0VZxUeJiafIEG7rGfsGHbeWbVOv/K\r\nwq92apHe/905b7tGxwHJgwcYYLVE8H3UEl+x5FnECQU0sIzi2OJza5yQxAW3\r\nQgnFFd9oQlTcnBo2LBI4rwR+a3C0tF3OZIN1x/75p0nyfDoYj67EMmJfRY8F\r\n1YPDtMmrCSWDXPmDRad1DQAMXQrXt0p4xQcaJFBicFzLNy+qnp+zEGPRgqg1\r\nLWsIUmTdooIBFrZ1KMt7SKgf1uuJo4/IeIqKE7lchoxUVwUZfhGVQVzwaYIK\r\n203U5VlMjTuuhmLJLfbUdfr6JCInCsEP/REVyy9K4usMjsQnLeneHL4QnbKZ\r\n4tCGt9w1DlOOj9f5e/6lG8WlqBUSj+DtmIw5AsqTABzoorEumFGVckl7vohh\r\nBzPOsWLYk2r5X9jEcJgZierh7iA5N/t9BeI4ODk3umMtIr2WgqpGKm86UTuX\r\ncsxhbR7NrymUvUMvqvFyvFgSuAfAn0UNhAHtvFY/c2+mhTAJ49Xev9XZU/0R\r\nTm3RB8yA+FA4kGwNDdChND29ruT+c+BpUUxT/S8pN4xIe+2slgqZ3kON4KgO\r\nmYGe2rpqsxKKPGxJ0KvHnsGPEsan2cN2//8=\r\n=IUia\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mercieral","email":"aaron.mercier@cagents.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-config-caitech_1.0.1_1651597652934_0.9416112691504903"},"_hasShrinkwrap":false},"1.0.2":{"name":"@caitech/eslint-config-caitech","version":"1.0.2","description":"A mostly reasonable approach to JavaScript amended for the CAI tech team.","main":"eslint.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/DataVoke/javascript-style-guide.git"},"keywords":["style guide","lint","airbnb","es6","es2015","es2016","es2017","es2018","react","jsx","eslint","eslintconfig"],"author":{"name":"Harrison Shoff","email":"hi@hshoff.com","url":"https://twitter.com/hshoff"},"maintainers":[{"name":"mercieral","email":"aaron.mercier@cagents.com"}],"license":"MIT","bugs":{"url":"https://github.com/DataVoke/javascript-style-guide/issues"},"homepage":"https://github.com/DataVoke/javascript-style-guide","devDependencies":{"markdownlint":"^0.20.4","markdownlint-cli":"^0.23.2"},"dependencies":{"eslint-plugin-import":"^2.26.0","eslint-plugin-jsx-a11y":"^6.5.1","eslint-plugin-react":"^7.29.4","eslint-plugin-react-hooks":"^4.5.0"},"peerDependencies":{"eslint":"^7.32.0 || ^8.2.0"},"gitHead":"2a90421191850efd9db1a59d6d72a49b5c57a17f","_id":"@caitech/eslint-config-caitech@1.0.2","_nodeVersion":"14.19.0","_npmVersion":"7.24.2","dist":{"integrity":"sha512-Zgpze/mKh6wLOk1j4dnYRdlcKCjNPERo4Y4AXoBJDmVLJwXQyERlg8S/NApaaAsuJg8mjr/vuCb+fIOCvk7oeQ==","shasum":"96ec4c86220cc1b1ce1c20c643c5c5492aa73dde","tarball":"https://registry.npmjs.org/@caitech/eslint-config-caitech/-/eslint-config-caitech-1.0.2.tgz","fileCount":7,"unpackedSize":149304,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDYH3n3I/9ZPQOQEniRKoX/XMiywjainK7/OtVYJDnTlAiEA3LA8JhPPxiq8s3PtVqeTFLRzP4oWqNtw1Gjk1kDdIbU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJicX+vACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpN7g//VUxi4K7SdlpVdBYbS2lgMiU9NtZN+A3M1cppm2+vGKVFGCdD\r\nZ329uEqOCqQOT1LQc0HXHD2yBBTZ/IEB17jKaM9ywUkjdxcsq4/DV3cAfh+G\r\nMgAyRb7mCICn6kjzUaQ9GCqoBp0RRUJeLioEUgUO8N+JPRGa+LUU9YIpfTc+\r\nfj/KDOIzU/KCdex63HINxi0S2hDW5w1gfR+nsmnU1ipnkFV7nr6rwIBm3WBd\r\nZWSA9qxpwi7J/npJ+f5PHXMNZghzpv69F/xpqeQUKD2BRaxR+JO4NRPDghiR\r\nPU/cYZEC53dJVCfWVAGjK7ZSZD8TJdWJYWMjDLbh6WJtMF4LFs6fITCNHbza\r\n+gtIcxPPYMmYB/7TrQyY5E6LFNdyisGoqXmf0y5JvFHiLo4GjnwfnVxvsWKm\r\nseXwYSqrm6WmSiPFa2+OkDWNcrMA0dDgu49Ol7HH2lE5v26Q5tC9a3zl5MG7\r\ni72xMW2QWXgKI88TO4jArN8Ygb5d+3ePXDuP5ArJ29QlmnYiO0PBeC/SXkvf\r\n8j5SAUUgTkPXBqUglqcT2uDw5krcBzxfFpQLw8ncsc6XtvxIrpcL+bAMs/Hl\r\ng8kMoX77G5TezdnHRng7Kg6nbyYbbXfGuQPRbPV6DImnf96CeKx8/ntV2lKy\r\noBQgNghiMQ+5Ib+AhFQJvQL+l8QaPtMTxXo=\r\n=Uplu\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mercieral","email":"aaron.mercier@cagents.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-config-caitech_1.0.2_1651605423590_0.35845397796313994"},"_hasShrinkwrap":false},"1.0.3":{"name":"@caitech/eslint-config-caitech","version":"1.0.3","description":"A mostly reasonable approach to JavaScript amended for the CAI tech team.","main":"eslint.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/DataVoke/javascript-style-guide.git"},"keywords":["style guide","lint","airbnb","es6","es2015","es2016","es2017","es2018","react","jsx","eslint","eslintconfig"],"author":{"name":"Harrison Shoff","email":"hi@hshoff.com","url":"https://twitter.com/hshoff"},"maintainers":[{"name":"jhopper28","email":"npmjs@hopperland.net"},{"name":"mercieral","email":"aaron.mercier@cagents.com"}],"license":"MIT","bugs":{"url":"https://github.com/DataVoke/javascript-style-guide/issues"},"homepage":"https://github.com/DataVoke/javascript-style-guide","devDependencies":{"markdownlint":"^0.20.4","markdownlint-cli":"^0.23.2"},"dependencies":{"eslint-config-airbnb":"^19.0.4","eslint-plugin-import":"^2.26.0","eslint-plugin-jsx-a11y":"^6.5.1","eslint-plugin-react":"^7.29.4","eslint-plugin-react-hooks":"^4.5.0"},"peerDependencies":{"eslint":"^7.32.0 || ^8.2.0"},"gitHead":"1140f68a3419f25be266aa9a9aa80238e15de720","_id":"@caitech/eslint-config-caitech@1.0.3","_nodeVersion":"14.19.2","_npmVersion":"6.14.17","dist":{"integrity":"sha512-ZHIAC2G2Uq0/lxt7HdRSWewRYCZp2WE9/9mSoEvnFHXOu4YUMeyNv+BW0sbBvHxNQ9RQOmksDKDu9UDSqFahbA==","shasum":"d1741e91c3fea4239f0889da492f53dd3b05058c","tarball":"https://registry.npmjs.org/@caitech/eslint-config-caitech/-/eslint-config-caitech-1.0.3.tgz","fileCount":7,"unpackedSize":150420,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICmkrVluWdqt5PfDGV6DWnoEKDwgtV5uaS+7fg3jjwQWAiEA0dvkqJA/Tvki7ZRFY9a0589E4v7XtgID/bzdnLHTfnc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJij9TvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr+4Q/9G8rm/QazfjH38TSBBpKqH4l50H8jUSIWXDqFESj7oEi6jzOD\r\n5vNg73WD13oRLkiu7M0NNkNm4sjXKuc18lPFGeSh0LsVOARzj7iEtpTvohOi\r\nAQdaAZSogAa89UuENg2vnwPYAQQs3gLbAWFIVTzbWWhAO9kxCsRo/0GzExga\r\ntLCq8eqBbG4RLbRfkNKUuUA2uJZ7RVPO4rfKG0AU78ZUGUuJb8EQZWtx2dHy\r\n2As/0xKj+EWN8AIE0j3Nhc4Z/lOaZ7sPdXxj3wrKaj3hHDJaY3Sbc17xy1v8\r\nJP+SMWKgm3IzHq7Ibipll7NC/eksKi7f+RKhWBRmSq45cIq5p2StxSzxaAo2\r\nW5ZZfmSiXqtVra//f1fk74Zn5LUOSDFByxsN3DvJrBBI4vesw+tQwU6cddXj\r\nvPI0G8kKMDrgUMGYnvPBgUleq6z/pATEN3xFkGo+WpOmn7g1WRwlvt2lCWxG\r\nkSgGRfMLvGYjDk7/e4XTsCmlrWVLt+gmchIMkzfM9rMhxds76vpVSYVbop96\r\nnPV+JAzwYGvkm9DhqOai6HunPi13wz48qWlW6gXYHJeHUFga4mhUb4hgz1ZR\r\np+XSsxlLz9USyGSDcFsJhgUDaJxQMZhTTDodiLbmUIwkjQyEu/s17Rufs7Uy\r\nENcJ6mVHIIozDQsgAcv6zt4epbRujda5/rY=\r\n=VVYD\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"mercieral","email":"aaron.mercier@cagents.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-config-caitech_1.0.3_1653593327336_0.4735577659273671"},"_hasShrinkwrap":false}},"time":{"created":"2022-05-03T17:07:32.856Z","1.0.1":"2022-05-03T17:07:33.147Z","modified":"2022-05-26T19:28:47.617Z","1.0.2":"2022-05-03T19:17:03.788Z","1.0.3":"2022-05-26T19:28:47.546Z"},"maintainers":[{"name":"jhopper28","email":"npmjs@hopperland.net"},{"name":"mercieral","email":"aaron.mercier@cagents.com"}],"description":"A mostly reasonable approach to JavaScript amended for the CAI tech team.","homepage":"https://github.com/DataVoke/javascript-style-guide","keywords":["style guide","lint","airbnb","es6","es2015","es2016","es2017","es2018","react","jsx","eslint","eslintconfig"],"repository":{"type":"git","url":"git+https://github.com/DataVoke/javascript-style-guide.git"},"author":{"name":"Harrison Shoff","email":"hi@hshoff.com","url":"https://twitter.com/hshoff"},"bugs":{"url":"https://github.com/DataVoke/javascript-style-guide/issues"},"license":"MIT","readme":"# CAI Tech JavaScript Style Guide\n\nAn amended version of the AirBnB Javascript style guide\n\n## <a name=\"installation-and-usage\"></a>Installation and Usage\n\nPrerequisites: [ESlint v8](https://github.com/eslint/eslint)\n\nYou can install the config using npm:\n\n```sh\nnpm install @caitech/eslint-config-caitech --save-dev\n```\n\nAnd then extend the config in your eslintrc configuration\n\n```json\n{\n    \"extends\": \"@caitech/eslint-config-caitech\",\n    \"rules\": {}\n}\n```\n\n\nOther Style Guides\n  - [React](react/)\n  - [CSS-in-JavaScript](css-in-javascript/)\n  - [CSS & Sass](https://github.com/airbnb/css)\n\n## Table of Contents\n\n  1. [Types](#types)\n  1. [References](#references)\n  1. [Objects](#objects)\n  1. [Arrays](#arrays)\n  1. [Destructuring](#destructuring)\n  1. [Strings](#strings)\n  1. [Functions](#functions)\n  1. [Arrow Functions](#arrow-functions)\n  1. [Classes & Constructors](#classes--constructors)\n  1. [Modules](#modules)\n  1. [Iterators and Generators](#iterators-and-generators)\n  1. [Properties](#properties)\n  1. [Variables](#variables)\n  1. [Hoisting](#hoisting)\n  1. [Comparison Operators & Equality](#comparison-operators--equality)\n  1. [Blocks](#blocks)\n  1. [Control Statements](#control-statements)\n  1. [Comments](#comments)\n  1. [Whitespace](#whitespace)\n  1. [Commas](#commas)\n  1. [Semicolons](#semicolons)\n  1. [Type Casting & Coercion](#type-casting--coercion)\n  1. [Naming Conventions](#naming-conventions)\n  1. [Accessors](#accessors)\n  1. [Events](#events)\n  1. [jQuery](#jquery)\n  1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility)\n  1. [ECMAScript 6+ (ES 2015+) Styles](#ecmascript-6-es-2015-styles)\n  1. [Standard Library](#standard-library)\n  1. [License](#license)\n  1. [Amendments](#amendments)\n\n## Types\n\n  <a name=\"types--primitives\"></a><a name=\"1.1\"></a>\n  - [1.1](#types--primitives) **Primitives**: When you access a primitive type you work directly on its value.\n\n    - `string`\n    - `number`\n    - `boolean`\n    - `null`\n    - `undefined`\n    - `symbol`\n    - `bigint`\n\n    ```javascript\n    const foo = 1;\n    let bar = foo;\n\n    bar = 9;\n\n    console.log(foo, bar); // => 1, 9\n    ```\n\n    - Symbols and BigInts cannot be faithfully polyfilled, so they should not be used when targeting browsers/environments that don’t support them natively.\n\n  <a name=\"types--complex\"></a><a name=\"1.2\"></a>\n  - [1.2](#types--complex)  **Complex**: When you access a complex type you work on a reference to its value.\n\n    - `object`\n    - `array`\n    - `function`\n\n    ```javascript\n    const foo = [1, 2];\n    const bar = foo;\n\n    bar[0] = 9;\n\n    console.log(foo[0], bar[0]); // => 9, 9\n    ```\n\n  <a name=\"types--implicit-coercion\"></a><a name=\"1.3\"></a>\n  - [1.3](#types--implicit-coercion) Use explicit type constructors over implicit coercion. eslint: [`no-implicit-coercion`](https://eslint.org/docs/rules/no-implicit-coercion)\n\n    > This was modified from the original code style guide\n\n    > Why? Explicit type constructors are much more intuitive to read.\n\n    ```javascript\n    // bad\n    var b = !!foo;\n    var b = ~foo.indexOf(\".\");\n    var n = +foo;\n    var n = 1 * foo;\n    var s = \"\" + foo;\n    foo += ``;\n\n    // good\n    var b = Boolean(foo);\n    var b = foo.indexOf(\".\") !== -1;\n    var n = Number(foo);\n    var n = Number(foo);\n    var s = String(foo);\n    foo = String(foo);\n    ```\n    \n\n**[⬆ back to top](#table-of-contents)**\n\n## References\n\n  <a name=\"references--prefer-const\"></a><a name=\"2.1\"></a>\n  - [2.1](#references--prefer-const) Use `const` for all of your references; avoid using `var`. eslint: [`prefer-const`](https://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](https://eslint.org/docs/rules/no-const-assign.html)\n\n    > Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code.\n\n    ```javascript\n    // bad\n    var a = 1;\n    var b = 2;\n\n    // good\n    const a = 1;\n    const b = 2;\n    ```\n\n  <a name=\"references--disallow-var\"></a><a name=\"2.2\"></a>\n  - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](https://eslint.org/docs/rules/no-var.html)\n\n    > Why? `let` is block-scoped rather than function-scoped like `var`.\n\n    ```javascript\n    // bad\n    var count = 1;\n    if (true) {\n      count += 1;\n    }\n\n    // good, use the let.\n    let count = 1;\n    if (true) {\n      count += 1;\n    }\n    ```\n\n  <a name=\"references--block-scope\"></a><a name=\"2.3\"></a>\n  - [2.3](#references--block-scope) Note that both `let` and `const` are block-scoped, whereas `var` is function-scoped.\n\n    ```javascript\n    // const and let only exist in the blocks they are defined in.\n    {\n      let a = 1;\n      const b = 1;\n      var c = 1;\n    }\n    console.log(a); // ReferenceError\n    console.log(b); // ReferenceError\n    console.log(c); // Prints 1\n    ```\n\n    In the above code, you can see that referencing `a` and `b` will produce a ReferenceError, while `c` contains the number. This is because `a` and `b` are block scoped, while `c` is scoped to the containing function.\n\n**[⬆ back to top](#table-of-contents)**\n\n## Objects\n\n  <a name=\"objects--no-new\"></a><a name=\"3.1\"></a>\n  - [3.1](#objects--no-new) Use the literal syntax for object creation. eslint: [`no-new-object`](https://eslint.org/docs/rules/no-new-object.html)\n\n    ```javascript\n    // bad\n    const item = new Object();\n\n    // good\n    const item = {};\n    ```\n\n  <a name=\"es6-computed-properties\"></a><a name=\"3.4\"></a>\n  - [3.2](#es6-computed-properties) Use computed property names when creating objects with dynamic property names.\n\n    > Why? They allow you to define all the properties of an object in one place.\n\n    ```javascript\n\n    function getKey(k) {\n      return `a key named ${k}`;\n    }\n\n    // bad\n    const obj = {\n      id: 5,\n      name: 'San Francisco',\n    };\n    obj[getKey('enabled')] = true;\n\n    // good\n    const obj = {\n      id: 5,\n      name: 'San Francisco',\n      [getKey('enabled')]: true,\n    };\n    ```\n\n  <a name=\"es6-object-shorthand\"></a><a name=\"3.5\"></a>\n  - [3.3](#es6-object-shorthand) Use object method shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html)\n\n    ```javascript\n    // bad\n    const atom = {\n      value: 1,\n\n      addValue: function (value) {\n        return atom.value + value;\n      },\n    };\n\n    // good\n    const atom = {\n      value: 1,\n\n      addValue(value) {\n        return atom.value + value;\n      },\n    };\n    ```\n\n  <a name=\"es6-object-concise\"></a><a name=\"3.6\"></a>\n  - [3.4](#es6-object-concise) Use property value shorthand. eslint: [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand.html)\n\n    > Why? It is shorter and descriptive.\n\n    ```javascript\n    const lukeSkywalker = 'Luke Skywalker';\n\n    // bad\n    const obj = {\n      lukeSkywalker: lukeSkywalker,\n    };\n\n    // good\n    const obj = {\n      lukeSkywalker,\n    };\n    ```\n\n  <a name=\"objects--grouped-shorthand\"></a><a name=\"3.7\"></a>\n  - [3.5](#objects--grouped-shorthand) Group your shorthand properties at the beginning of your object declaration.\n\n    > Why? It’s easier to tell which properties are using the shorthand.\n\n    ```javascript\n    const anakinSkywalker = 'Anakin Skywalker';\n    const lukeSkywalker = 'Luke Skywalker';\n\n    // bad\n    const obj = {\n      episodeOne: 1,\n      twoJediWalkIntoACantina: 2,\n      lukeSkywalker,\n      episodeThree: 3,\n      mayTheFourth: 4,\n      anakinSkywalker,\n    };\n\n    // good\n    const obj = {\n      lukeSkywalker,\n      anakinSkywalker,\n      episodeOne: 1,\n      twoJediWalkIntoACantina: 2,\n      episodeThree: 3,\n      mayTheFourth: 4,\n    };\n    ```\n\n  <a name=\"objects--quoted-props\"></a><a name=\"3.8\"></a>\n  - [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html)\n\n    > Why? In general we consider it subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines.\n\n    ```javascript\n    // bad\n    const bad = {\n      'foo': 3,\n      'bar': 4,\n      'data-blah': 5,\n    };\n\n    // good\n    const good = {\n      foo: 3,\n      bar: 4,\n      'data-blah': 5,\n    };\n    ```\n\n  <a name=\"objects--prototype-builtins\"></a>\n  - [3.7](#objects--prototype-builtins) It is ok to call `Object.prototype` methods directly, such as `hasOwnProperty`, `propertyIsEnumerable`, and `isPrototypeOf`. eslint: [`no-prototype-builtins`](https://eslint.org/docs/rules/no-prototype-builtins)\n\n    > This was modified from the original code style guide\n\n    > However, be aware that these methods may be shadowed by properties on the object in question - consider `{ hasOwnProperty: false }` - or, the object may be a null object (`Object.create(null)`).\n\n    ```javascript\n    // acceptable\n    console.log(object.hasOwnProperty(key));\n\n    // good\n    console.log(Object.prototype.hasOwnProperty.call(object, key));\n\n    // best\n    const has = Object.prototype.hasOwnProperty; // cache the lookup once, in module scope.\n    console.log(has.call(object, key));\n    /* or */\n    import has from 'has'; // https://www.npmjs.com/package/has\n    console.log(has(object, key));\n    ```\n\n  <a name=\"objects--rest-spread\"></a>\n  - [3.8](#objects--rest-spread) Prefer the object spread syntax over [`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to shallow-copy objects. Use the object rest parameter syntax to get a new object with certain properties omitted. eslint: [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread)\n\n    ```javascript\n    // very bad\n    const original = { a: 1, b: 2 };\n    const copy = Object.assign(original, { c: 3 }); // this mutates `original` ಠ_ಠ\n    delete copy.a; // so does this\n\n    // bad\n    const original = { a: 1, b: 2 };\n    const copy = Object.assign({}, original, { c: 3 }); // copy => { a: 1, b: 2, c: 3 }\n\n    // good\n    const original = { a: 1, b: 2 };\n    const copy = { ...original, c: 3 }; // copy => { a: 1, b: 2, c: 3 }\n\n    const { a, ...noA } = copy; // noA => { b: 2, c: 3 }\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Arrays\n\n  <a name=\"arrays--literals\"></a><a name=\"4.1\"></a>\n  - [4.1](#arrays--literals) Use the literal syntax for array creation. eslint: [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor.html)\n\n    ```javascript\n    // bad\n    const items = new Array();\n\n    // good\n    const items = [];\n    ```\n\n  <a name=\"arrays--push\"></a><a name=\"4.2\"></a>\n  - [4.2](#arrays--push) Use [Array#push](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push) instead of direct assignment to add items to an array.\n\n    ```javascript\n    const someStack = [];\n\n    // bad\n    someStack[someStack.length] = 'abracadabra';\n\n    // good\n    someStack.push('abracadabra');\n    ```\n\n  <a name=\"es6-array-spreads\"></a><a name=\"4.3\"></a>\n  - [4.3](#es6-array-spreads) Use array spreads `...` to copy arrays.\n\n    ```javascript\n    // bad\n    const len = items.length;\n    const itemsCopy = [];\n    let i;\n\n    for (i = 0; i < len; i += 1) {\n      itemsCopy[i] = items[i];\n    }\n\n    // good\n    const itemsCopy = [...items];\n    ```\n\n  <a name=\"arrays--from\"></a>\n  <a name=\"arrays--from-iterable\"></a><a name=\"4.4\"></a>\n  - [4.4](#arrays--from-iterable) To convert an iterable object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from).\n\n    ```javascript\n    const foo = document.querySelectorAll('.foo');\n\n    // good\n    const nodes = Array.from(foo);\n\n    // best\n    const nodes = [...foo];\n    ```\n\n  <a name=\"arrays--from-array-like\"></a>\n  - [4.5](#arrays--from-array-like) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) for converting an array-like object to an array.\n\n    ```javascript\n    const arrLike = { 0: 'foo', 1: 'bar', 2: 'baz', length: 3 };\n\n    // bad\n    const arr = Array.prototype.slice.call(arrLike);\n\n    // good\n    const arr = Array.from(arrLike);\n    ```\n\n  <a name=\"arrays--mapping\"></a>\n  - [4.6](#arrays--mapping) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array.\n\n    ```javascript\n    // bad\n    const baz = [...foo].map(bar);\n\n    // good\n    const baz = Array.from(foo, bar);\n    ```\n\n  <a name=\"arrays--callback-return\"></a><a name=\"4.5\"></a>\n  - [4.7](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return)\n\n    ```javascript\n    // good\n    [1, 2, 3].map((x) => {\n      const y = x + 1;\n      return x * y;\n    });\n\n    // good\n    [1, 2, 3].map((x) => x + 1);\n\n    // bad - no returned value means `acc` becomes undefined after the first iteration\n    [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => {\n      const flatten = acc.concat(item);\n    });\n\n    // good\n    [[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => {\n      const flatten = acc.concat(item);\n      return flatten;\n    });\n\n    // bad\n    inbox.filter((msg) => {\n      const { subject, author } = msg;\n      if (subject === 'Mockingbird') {\n        return author === 'Harper Lee';\n      } else {\n        return false;\n      }\n    });\n\n    // good\n    inbox.filter((msg) => {\n      const { subject, author } = msg;\n      if (subject === 'Mockingbird') {\n        return author === 'Harper Lee';\n      }\n\n      return false;\n    });\n    ```\n\n  <a name=\"arrays--bracket-newline\"></a>\n  - [4.8](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines\n\n    ```javascript\n    // bad\n    const arr = [\n      [0, 1], [2, 3], [4, 5],\n    ];\n\n    const objectInArray = [{\n      id: 1,\n    }, {\n      id: 2,\n    }];\n\n    const numberInArray = [\n      1, 2,\n    ];\n\n    // good\n    const arr = [[0, 1], [2, 3], [4, 5]];\n\n    const objectInArray = [\n      {\n        id: 1,\n      },\n      {\n        id: 2,\n      },\n    ];\n\n    const numberInArray = [\n      1,\n      2,\n    ];\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Destructuring\n\n  <a name=\"destructuring--object\"></a><a name=\"5.1\"></a>\n  - [5.1](#destructuring--object) Use object destructuring when accessing and using multiple properties of an object. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring)\n\n    > Why? Destructuring saves you from creating temporary references for those properties, and from repetitive access of the object. Repeating object access creates more repetitive code, requires more reading, and creates more opportunities for mistakes. Destructuring objects also provides a single site of definition of the object structure that is used in the block, rather than requiring reading the entire block to determine what is used.\n\n    ```javascript\n    // bad\n    function getFullName(user) {\n      const firstName = user.firstName;\n      const lastName = user.lastName;\n\n      return `${firstName} ${lastName}`;\n    }\n\n    // good\n    function getFullName(user) {\n      const { firstName, lastName } = user;\n      return `${firstName} ${lastName}`;\n    }\n\n    // best\n    function getFullName({ firstName, lastName }) {\n      return `${firstName} ${lastName}`;\n    }\n    ```\n\n  <a name=\"destructuring--array\"></a><a name=\"5.2\"></a>\n  - [5.2](#destructuring--array) Use array destructuring. eslint: [`prefer-destructuring`](https://eslint.org/docs/rules/prefer-destructuring)\n\n    ```javascript\n    const arr = [1, 2, 3, 4];\n\n    // bad\n    const first = arr[0];\n    const second = arr[1];\n\n    // good\n    const [first, second] = arr;\n    ```\n\n  <a name=\"destructuring--object-over-array\"></a><a name=\"5.3\"></a>\n  - [5.3](#destructuring--object-over-array) Use object destructuring for multiple return values, not array destructuring.\n\n    > Why? You can add new properties over time or change the order of things without breaking call sites.\n\n    ```javascript\n    // bad\n    function processInput(input) {\n      // then a miracle occurs\n      return [left, right, top, bottom];\n    }\n\n    // the caller needs to think about the order of return data\n    const [left, __, top] = processInput(input);\n\n    // good\n    function processInput(input) {\n      // then a miracle occurs\n      return { left, right, top, bottom };\n    }\n\n    // the caller selects only the data they need\n    const { left, top } = processInput(input);\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Strings\n\n  <a name=\"strings--quotes\"></a><a name=\"6.1\"></a>\n  - [6.1](#strings--quotes) Use single quotes `''` for strings. eslint: [`quotes`](https://eslint.org/docs/rules/quotes.html)\n\n    ```javascript\n    // bad\n    const name = \"Capt. Janeway\";\n\n    // bad - template literals should contain interpolation or newlines\n    const name = `Capt. Janeway`;\n\n    // good\n    const name = 'Capt. Janeway';\n    ```\n\n  <a name=\"strings--line-length\"></a><a name=\"6.2\"></a>\n  - [6.2](#strings--line-length) Strings that cause the line to go over 100 characters should not be written across multiple lines using string concatenation.\n\n    > Why? Broken strings are painful to work with and make code less searchable.\n\n    ```javascript\n    // bad\n    const errorMessage = 'This is a super long error that was thrown because \\\n    of Batman. When you stop to think about how Batman had anything to do \\\n    with this, you would get nowhere \\\n    fast.';\n\n    // bad\n    const errorMessage = 'This is a super long error that was thrown because ' +\n      'of Batman. When you stop to think about how Batman had anything to do ' +\n      'with this, you would get nowhere fast.';\n\n    // good\n    const errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';\n    ```\n\n  <a name=\"es6-template-literals\"></a><a name=\"6.4\"></a>\n  - [6.3](#es6-template-literals) When programmatically building up strings, use template strings instead of concatenation. eslint: [`prefer-template`](https://eslint.org/docs/rules/prefer-template.html) [`template-curly-spacing`](https://eslint.org/docs/rules/template-curly-spacing)\n\n    > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features.\n\n    ```javascript\n    // bad\n    function sayHi(name) {\n      return 'How are you, ' + name + '?';\n    }\n\n    // bad\n    function sayHi(name) {\n      return ['How are you, ', name, '?'].join();\n    }\n\n    // bad\n    function sayHi(name) {\n      return `How are you, ${ name }?`;\n    }\n\n    // good\n    function sayHi(name) {\n      return `How are you, ${name}?`;\n    }\n    ```\n\n  <a name=\"strings--eval\"></a><a name=\"6.5\"></a>\n  - [6.4](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities. eslint: [`no-eval`](https://eslint.org/docs/rules/no-eval)\n\n  <a name=\"strings--escaping\"></a>\n  - [6.5](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](https://eslint.org/docs/rules/no-useless-escape)\n\n    > Why? Backslashes harm readability, thus they should only be present when necessary.\n\n    ```javascript\n    // bad\n    const foo = '\\'this\\' \\i\\s \\\"quoted\\\"';\n\n    // good\n    const foo = '\\'this\\' is \"quoted\"';\n    const foo = `my name is '${name}'`;\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Functions\n\n  <a name=\"functions--declarations\"></a><a name=\"7.1\"></a>\n  - [7.1](#functions--declarations) Prefer named function expressions instead of function declarations. eslint: [`func-style`](https://eslint.org/docs/rules/func-style)\n\n      > This was modified from the original code style guide\n\n    > Why? Function declarations are hoisted, which means that it’s easy - too easy - to reference the function before it is defined in the file. This harms readability and maintainability. If you find that a function’s definition is large or complex enough that it is interfering with understanding the rest of the file, then perhaps it’s time to extract it to its own module! Don’t forget to explicitly name the expression, regardless of whether or not the name is inferred from the containing variable (which is often the case in modern browsers or when using compilers such as Babel). This eliminates any assumptions made about the Error’s call stack. ([Discussion](https://github.com/airbnb/javascript/issues/794))\n\n    ```javascript\n    // acceptable\n    function foo() {\n      // ...\n    }\n\n    // acceptable\n    const foo = function () {\n      // ...\n    };\n\n    // good\n    // lexical name distinguished from the variable-referenced invocation(s)\n    const short = function longUniqueMoreDescriptiveLexicalFoo() {\n      // ...\n    };\n    ```\n\n  <a name=\"functions--iife\"></a><a name=\"7.2\"></a>\n  - [7.2](#functions--iife) Wrap immediately invoked function expressions in parentheses. eslint: [`wrap-iife`](https://eslint.org/docs/rules/wrap-iife.html)\n\n    > Why? An immediately invoked function expression is a single unit - wrapping both it, and its invocation parens, in parens, cleanly expresses this. Note that in a world with modules everywhere, you almost never need an IIFE.\n\n    ```javascript\n    // immediately-invoked function expression (IIFE)\n    (function () {\n      console.log('Welcome to the Internet. Please follow me.');\n    }());\n    ```\n\n  <a name=\"functions--in-blocks\"></a><a name=\"7.3\"></a>\n  - [7.3](#functions--in-blocks) Never declare a function in a non-function block (`if`, `while`, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears. eslint: [`no-loop-func`](https://eslint.org/docs/rules/no-loop-func.html)\n\n  <a name=\"functions--note-on-blocks\"></a><a name=\"7.4\"></a>\n  - [7.4](#functions--note-on-blocks) **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement.\n\n    ```javascript\n    // bad\n    if (currentUser) {\n      function test() {\n        console.log('Nope.');\n      }\n    }\n\n    // good\n    let test;\n    if (currentUser) {\n      test = () => {\n        console.log('Yup.');\n      };\n    }\n    ```\n\n  <a name=\"functions--arguments-shadow\"></a><a name=\"7.5\"></a>\n  - [7.5](#functions--arguments-shadow) Never name a parameter `arguments`. This will take precedence over the `arguments` object that is given to every function scope.\n\n    ```javascript\n    // bad\n    function foo(name, options, arguments) {\n      // ...\n    }\n\n    // good\n    function foo(name, options, args) {\n      // ...\n    }\n    ```\n\n  <a name=\"es6-rest\"></a><a name=\"7.6\"></a>\n  - [7.6](#es6-rest) Never use `arguments`, opt to use rest syntax `...` instead. eslint: [`prefer-rest-params`](https://eslint.org/docs/rules/prefer-rest-params)\n\n    > Why? `...` is explicit about which arguments you want pulled. Plus, rest arguments are a real Array, and not merely Array-like like `arguments`.\n\n    ```javascript\n    // bad\n    function concatenateAll() {\n      const args = Array.prototype.slice.call(arguments);\n      return args.join('');\n    }\n\n    // good\n    function concatenateAll(...args) {\n      return args.join('');\n    }\n    ```\n\n  <a name=\"es6-default-parameters\"></a><a name=\"7.7\"></a>\n  - [7.7](#es6-default-parameters) Use default parameter syntax rather than mutating function arguments.\n\n    ```javascript\n    // really bad\n    function handleThings(opts) {\n      // No! We shouldn’t mutate function arguments.\n      // Double bad: if opts is falsy it'll be set to an object which may\n      // be what you want but it can introduce subtle bugs.\n      opts = opts || {};\n      // ...\n    }\n\n    // still bad\n    function handleThings(opts) {\n      if (opts === void 0) {\n        opts = {};\n      }\n      // ...\n    }\n\n    // good\n    function handleThings(opts = {}) {\n      // ...\n    }\n    ```\n\n  <a name=\"functions--default-side-effects\"></a><a name=\"7.8\"></a>\n  - [7.8](#functions--default-side-effects) Avoid side effects with default parameters.\n\n    > Why? They are confusing to reason about.\n\n    ```javascript\n    var b = 1;\n    // bad\n    function count(a = b++) {\n      console.log(a);\n    }\n    count();  // 1\n    count();  // 2\n    count(3); // 3\n    count();  // 3\n    ```\n\n  <a name=\"functions--defaults-last\"></a><a name=\"7.9\"></a>\n  - [7.9](#functions--defaults-last) Always put default parameters last. eslint: [`default-param-last`](https://eslint.org/docs/rules/default-param-last)\n\n    ```javascript\n    // bad\n    function handleThings(opts = {}, name) {\n      // ...\n    }\n\n    // good\n    function handleThings(name, opts = {}) {\n      // ...\n    }\n    ```\n\n  <a name=\"functions--constructor\"></a><a name=\"7.10\"></a>\n  - [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](https://eslint.org/docs/rules/no-new-func)\n\n    > Why? Creating a function in this way evaluates a string similarly to `eval()`, which opens vulnerabilities.\n\n    ```javascript\n    // bad\n    var add = new Function('a', 'b', 'return a + b');\n\n    // still bad\n    var subtract = Function('a', 'b', 'return a - b');\n    ```\n\n  <a name=\"functions--signature-spacing\"></a><a name=\"7.11\"></a>\n  - [7.11](#functions--signature-spacing) Spacing in a function signature. eslint: [`space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) [`space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks)\n\n    > Why? Consistency is good, and you shouldn’t have to add or remove a space when adding or removing a name.\n\n    ```javascript\n    // bad\n    const f = function(){};\n    const g = function (){};\n    const h = function() {};\n\n    // good\n    const x = function () {};\n    const y = function a() {};\n    ```\n\n  <a name=\"functions--mutate-params\"></a><a name=\"7.12\"></a>\n  - [7.12](#functions--mutate-params) Never mutate parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign.html)\n\n    > Why? Manipulating objects passed in as parameters can cause unwanted variable side effects in the original caller.\n\n    ```javascript\n    // bad\n    function f1(obj) {\n      obj.key = 1;\n    }\n\n    // good\n    function f2(obj) {\n      const key = Object.prototype.hasOwnProperty.call(obj, 'key') ? obj.key : 1;\n    }\n    ```\n\n  <a name=\"functions--reassign-params\"></a><a name=\"7.13\"></a>\n  - [7.13](#functions--reassign-params) Never reassign parameters. eslint: [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign.html)\n\n    > Why? Reassigning parameters can lead to unexpected behavior, especially when accessing the `arguments` object. It can also cause optimization issues, especially in V8.\n\n    ```javascript\n    // bad\n    function f1(a) {\n      a = 1;\n      // ...\n    }\n\n    function f2(a) {\n      if (!a) { a = 1; }\n      // ...\n    }\n\n    // good\n    function f3(a) {\n      const b = a || 1;\n      // ...\n    }\n\n    function f4(a = 1) {\n      // ...\n    }\n    ```\n\n  <a name=\"functions--spread-vs-apply\"></a><a name=\"7.14\"></a>\n  - [7.14](#functions--spread-vs-apply) Prefer the use of the spread syntax `...` to call variadic functions. eslint: [`prefer-spread`](https://eslint.org/docs/rules/prefer-spread)\n\n    > Why? It’s cleaner, you don’t need to supply a context, and you can not easily compose `new` with `apply`.\n\n    ```javascript\n    // bad\n    const x = [1, 2, 3, 4, 5];\n    console.log.apply(console, x);\n\n    // good\n    const x = [1, 2, 3, 4, 5];\n    console.log(...x);\n\n    // bad\n    new (Function.prototype.bind.apply(Date, [null, 2016, 8, 5]));\n\n    // good\n    new Date(...[2016, 8, 5]);\n    ```\n\n  <a name=\"functions--signature-invocation-indentation\"></a>\n  - [7.15](#functions--signature-invocation-indentation) Functions with multiline signatures, or invocations, should be indented just like every other multiline list in this guide: with each item on a line by itself, with a trailing comma on the last item. eslint: [`function-paren-newline`](https://eslint.org/docs/rules/function-paren-newline)\n\n    ```javascript\n    // bad\n    function foo(bar,\n                 baz,\n                 quux) {\n      // ...\n    }\n\n    // good\n    function foo(\n      bar,\n      baz,\n      quux,\n    ) {\n      // ...\n    }\n\n    // bad\n    console.log(foo,\n      bar,\n      baz);\n\n    // good\n    console.log(\n      foo,\n      bar,\n      baz,\n    );\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Arrow Functions\n\n  <a name=\"arrows--use-them\"></a><a name=\"8.1\"></a>\n  - [8.1](#arrows--use-them) When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: [`prefer-arrow-callback`](https://eslint.org/docs/rules/prefer-arrow-callback.html), [`arrow-spacing`](https://eslint.org/docs/rules/arrow-spacing.html)\n\n    > Why? It creates a version of the function that executes in the context of `this`, which is usually what you want, and is a more concise syntax.\n\n    > Why not? If you have a fairly complicated function, you might move that logic out into its own named function expression.\n\n    ```javascript\n    // bad\n    [1, 2, 3].map(function (x) {\n      const y = x + 1;\n      return x * y;\n    });\n\n    // good\n    [1, 2, 3].map((x) => {\n      const y = x + 1;\n      return x * y;\n    });\n    ```\n\n  <a name=\"arrows--implicit-return\"></a><a name=\"8.2\"></a>\n  - [8.2](#arrows--implicit-return) If the function body consists of a single statement returning an [expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions) without side effects, omit the braces and use the implicit return. Otherwise, keep the braces and use a `return` statement. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html), [`arrow-body-style`](https://eslint.org/docs/rules/arrow-body-style.html)\n\n    > Why? Syntactic sugar. It reads well when multiple functions are chained together.\n\n    ```javascript\n    // bad\n    [1, 2, 3].map((number) => {\n      const nextNumber = number + 1;\n      `A string containing the ${nextNumber}.`;\n    });\n\n    // good\n    [1, 2, 3].map((number) => `A string containing the ${number + 1}.`);\n\n    // good\n    [1, 2, 3].map((number) => {\n      const nextNumber = number + 1;\n      return `A string containing the ${nextNumber}.`;\n    });\n\n    // good\n    [1, 2, 3].map((number, index) => ({\n      [index]: number,\n    }));\n\n    // No implicit return with side effects\n    function foo(callback) {\n      const val = callback();\n      if (val === true) {\n        // Do something if callback returns true\n      }\n    }\n\n    let bool = false;\n\n    // bad\n    foo(() => bool = true);\n\n    // good\n    foo(() => {\n      bool = true;\n    });\n    ```\n\n  <a name=\"arrows--paren-wrap\"></a><a name=\"8.3\"></a>\n  - [8.3](#arrows--paren-wrap) In case the expression spans over multiple lines, wrap it in parentheses for better readability.\n\n    > Why? It shows clearly where the function starts and ends.\n\n    ```javascript\n    // bad\n    ['get', 'post', 'put'].map((httpMethod) => Object.prototype.hasOwnProperty.call(\n        httpMagicObjectWithAVeryLongName,\n        httpMethod,\n      )\n    );\n\n    // good\n    ['get', 'post', 'put'].map((httpMethod) => (\n      Object.prototype.hasOwnProperty.call(\n        httpMagicObjectWithAVeryLongName,\n        httpMethod,\n      )\n    ));\n    ```\n\n  <a name=\"arrows--one-arg-parens\"></a><a name=\"8.4\"></a>\n  - [8.4](#arrows--one-arg-parens) Always include parentheses around arguments for clarity and consistency. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html)\n\n    > Why? Minimizes diff churn when adding or removing arguments.\n\n    ```javascript\n    // bad\n    [1, 2, 3].map(x => x * x);\n\n    // good\n    [1, 2, 3].map((x) => x * x);\n\n    // bad\n    [1, 2, 3].map(number => (\n      `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`\n    ));\n\n    // good\n    [1, 2, 3].map((number) => (\n      `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`\n    ));\n\n    // bad\n    [1, 2, 3].map(x => {\n      const y = x + 1;\n      return x * y;\n    });\n\n    // good\n    [1, 2, 3].map((x) => {\n      const y = x + 1;\n      return x * y;\n    });\n    ```\n\n  <a name=\"arrows--confusing\"></a><a name=\"8.5\"></a>\n  - [8.5](#arrows--confusing) Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [`no-confusing-arrow`](https://eslint.org/docs/rules/no-confusing-arrow)\n\n    ```javascript\n    // bad\n    const itemHeight = (item) => item.height <= 256 ? item.largeSize : item.smallSize;\n\n    // bad\n    const itemHeight = (item) => item.height >= 256 ? item.largeSize : item.smallSize;\n\n    // good\n    const itemHeight = (item) => (item.height <= 256 ? item.largeSize : item.smallSize);\n\n    // good\n    const itemHeight = (item) => {\n      const { height, largeSize, smallSize } = item;\n      return height <= 256 ? largeSize : smallSize;\n    };\n    ```\n\n  <a name=\"whitespace--implicit-arrow-linebreak\"></a>\n  - [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak)\n\n    ```javascript\n    // bad\n    (foo) =>\n      bar;\n\n    (foo) =>\n      (bar);\n\n    // good\n    (foo) => bar;\n    (foo) => (bar);\n    (foo) => (\n       bar\n    )\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Classes & Constructors\n\n  <a name=\"constructors--use-class\"></a><a name=\"9.1\"></a>\n  - [9.1](#constructors--use-class) Always use `class`. Avoid manipulating `prototype` directly.\n\n    > Why? `class` syntax is more concise and easier to reason about.\n\n    ```javascript\n    // bad\n    function Queue(contents = []) {\n      this.queue = [...contents];\n    }\n    Queue.prototype.pop = function () {\n      const value = this.queue[0];\n      this.queue.splice(0, 1);\n      return value;\n    };\n\n    // good\n    class Queue {\n      constructor(contents = []) {\n        this.queue = [...contents];\n      }\n      pop() {\n        const value = this.queue[0];\n        this.queue.splice(0, 1);\n        return value;\n      }\n    }\n    ```\n\n  <a name=\"constructors--extends\"></a><a name=\"9.2\"></a>\n  - [9.2](#constructors--extends) Use `extends` for inheritance.\n\n    > Why? It is a built-in way to inherit prototype functionality without breaking `instanceof`.\n\n    ```javascript\n    // bad\n    const inherits = require('inherits');\n    function PeekableQueue(contents) {\n      Queue.apply(this, contents);\n    }\n    inherits(PeekableQueue, Queue);\n    PeekableQueue.prototype.peek = function () {\n      return this.queue[0];\n    };\n\n    // good\n    class PeekableQueue extends Queue {\n      peek() {\n        return this.queue[0];\n      }\n    }\n    ```\n\n  <a name=\"constructors--chaining\"></a><a name=\"9.3\"></a>\n  - [9.3](#constructors--chaining) Methods can return `this` to help with method chaining.\n\n    ```javascript\n    // bad\n    Jedi.prototype.jump = function () {\n      this.jumping = true;\n      return true;\n    };\n\n    Jedi.prototype.setHeight = function (height) {\n      this.height = height;\n    };\n\n    const luke = new Jedi();\n    luke.jump(); // => true\n    luke.setHeight(20); // => undefined\n\n    // good\n    class Jedi {\n      jump() {\n        this.jumping = true;\n        return this;\n      }\n\n      setHeight(height) {\n        this.height = height;\n        return this;\n      }\n    }\n\n    const luke = new Jedi();\n\n    luke.jump()\n      .setHeight(20);\n    ```\n\n  <a name=\"constructors--tostring\"></a><a name=\"9.4\"></a>\n  - [9.4](#constructors--tostring) It’s okay to write a custom `toString()` method, just make sure it works successfully and causes no side effects.\n\n    ```javascript\n    class Jedi {\n      constructor(options = {}) {\n        this.name = options.name || 'no name';\n      }\n\n      getName() {\n        return this.name;\n      }\n\n      toString() {\n        return `Jedi - ${this.getName()}`;\n      }\n    }\n    ```\n\n  <a name=\"constructors--no-useless\"></a><a name=\"9.5\"></a>\n  - [9.5](#constructors--no-useless) Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary. eslint: [`no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor)\n\n    ```javascript\n    // bad\n    class Jedi {\n      constructor() {}\n\n      getName() {\n        return this.name;\n      }\n    }\n\n    // bad\n    class Rey extends Jedi {\n      constructor(...args) {\n        super(...args);\n      }\n    }\n\n    // good\n    class Rey extends Jedi {\n      constructor(...args) {\n        super(...args);\n        this.name = 'Rey';\n      }\n    }\n    ```\n\n  <a name=\"classes--no-duplicate-members\"></a>\n  - [9.6](#classes--no-duplicate-members) Avoid duplicate class members. eslint: [`no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members)\n\n    > Why? Duplicate class member declarations will silently prefer the last one - having duplicates is almost certainly a bug.\n\n    ```javascript\n    // bad\n    class Foo {\n      bar() { return 1; }\n      bar() { return 2; }\n    }\n\n    // good\n    class Foo {\n      bar() { return 1; }\n    }\n\n    // good\n    class Foo {\n      bar() { return 2; }\n    }\n    ```\n\n  <a name=\"classes--methods-use-this\"></a>\n  - [9.7](#classes--methods-use-this) Class methods should use `this` or be made into a static method unless an external library or framework requires using specific non-static methods. Being an instance method should indicate that it behaves differently based on properties of the receiver. eslint: [`class-methods-use-this`](https://eslint.org/docs/rules/class-methods-use-this)\n\n    ```javascript\n    // bad\n    class Foo {\n      bar() {\n        console.log('bar');\n      }\n    }\n\n    // good - this is used\n    class Foo {\n      bar() {\n        console.log(this.bar);\n      }\n    }\n\n    // good - constructor is exempt\n    class Foo {\n      constructor() {\n        // ...\n      }\n    }\n\n    // good - static methods aren't expected to use this\n    class Foo {\n      static bar() {\n        console.log('bar');\n      }\n    }\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Modules\n\n  <a name=\"modules--use-them\"></a><a name=\"10.1\"></a>\n  - [10.1](#modules--use-them) Prefer to use modules (`import`/`export`) over a non-standard module system when possible. You can always transpile to your preferred module system.\n\n    > This was modified from the original code style guide\n\n    > Why? Modules are the future, let’s start using the future now.\n\n    ```javascript\n    // acceptable\n    const AirbnbStyleGuide = require('./AirbnbStyleGuide');\n    module.exports = AirbnbStyleGuide.es6;\n\n    // ok\n    import AirbnbStyleGuide from './AirbnbStyleGuide';\n    export default AirbnbStyleGuide.es6;\n\n    // best\n    import { es6 } from './AirbnbStyleGuide';\n    export default es6;\n    ```\n\n  <a name=\"modules--no-wildcard\"></a><a name=\"10.2\"></a>\n  - [10.2](#modules--no-wildcard) wildcard imports are allowed.\n\n    > This was modified from the original code style guide\n\n    ```javascript\n    // acceptable\n    import * as AirbnbStyleGuide from './AirbnbStyleGuide';\n\n    // acceptable\n    import AirbnbStyleGuide from './AirbnbStyleGuide';\n    ```\n\n  <a name=\"modules--no-export-from-import\"></a><a name=\"10.3\"></a>\n  - [10.3](#modules--no-export-from-import) Exports directly from an import are allowed.\n\n    > This was modified from the original code style guide\n\n    ```javascript\n    // acceptable\n    // filename es6.js\n    export { es6 as default } from './AirbnbStyleGuide';\n\n    // acceptable\n    // filename es6.js\n    import { es6 } from './AirbnbStyleGuide';\n    export default es6;\n    ```\n\n  <a name=\"modules--no-duplicate-imports\"></a>\n  - [10.4](#modules--no-duplicate-imports) Only import from a path in one place.\n eslint: [`no-duplicate-imports`](https://eslint.org/docs/rules/no-duplicate-imports)\n    > Why? Having multiple lines that import from the same path can make code harder to maintain.\n\n    ```javascript\n    // bad\n    import foo from 'foo';\n    // … some other imports … //\n    import { named1, named2 } from 'foo';\n\n    // good\n    import foo, { named1, named2 } from 'foo';\n\n    // good\n    import foo, {\n      named1,\n      named2,\n    } from 'foo';\n    ```\n\n  <a name=\"modules--no-mutable-exports\"></a>\n  - [10.5](#modules--no-mutable-exports) Do not export mutable bindings.\n eslint: [`import/no-mutable-exports`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md)\n    > Why? Mutation should be avoided in general, but in particular when exporting mutable bindings. While this technique may be needed for some special cases, in general, only constant references should be exported.\n\n    ```javascript\n    // bad\n    let foo = 3;\n    export { foo };\n\n    // good\n    const foo = 3;\n    export { foo };\n    ```\n\n  <a name=\"modules--prefer-default-export\"></a>\n  - [10.6](#modules--prefer-default-export) In modules with a single export, prefer default export over named export.\n eslint: [`import/prefer-default-export`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md)\n    > Why? To encourage more files that only ever export one thing, which is better for readability and maintainability.\n\n    ```javascript\n    // bad\n    export function foo() {}\n\n    // good\n    export default function foo() {}\n    ```\n\n  <a name=\"modules--imports-first\"></a>\n  - [10.7](#modules--imports-first) Put all `import`s above non-import statements.\n eslint: [`import/first`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md)\n    > Why? Since `import`s are hoisted, keeping them all at the top prevents surprising behavior.\n\n    ```javascript\n    // bad\n    import foo from 'foo';\n    foo.init();\n\n    import bar from 'bar';\n\n    // good\n    import foo from 'foo';\n    import bar from 'bar';\n\n    foo.init();\n    ```\n\n  <a name=\"modules--multiline-imports-over-newlines\"></a>\n  - [10.8](#modules--multiline-imports-over-newlines) Multiline imports should be indented just like multiline array and object literals. However there is no restriction on imports always being multiline, unless it breaks the max character length rule.\n eslint: [`object-curly-newline`](https://eslint.org/docs/rules/object-curly-newline)\n\n    > This was modified from the original code style guide\n\n    > Why? The curly braces follow the same indentation rules as every other curly brace block in the style guide, as do the trailing commas.\n\n    ```javascript\n    // acceptable\n    import {longNameA, longNameB, longNameC, longNameD, longNameE} from 'path';\n\n    // acceptable\n    import {\n      longNameA,\n      longNameB,\n      longNameC,\n      longNameD,\n      longNameE,\n    } from 'path';\n    ```\n\n  <a name=\"modules--no-webpack-loader-syntax\"></a>\n  - [10.9](#modules--no-webpack-loader-syntax) Webpack loader syntax in module import statements is allowed but should be avoided unless necessary.\n eslint: [`import/no-webpack-loader-syntax`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md)\n    > This was modified from the original code style guide  \n\n    >Why? Since using Webpack syntax in the imports couples the code to a module bundler. Prefer using the loader syntax in webpack.config.js.\n\n    ```javascript\n    // acceptable\n    import fooSass from 'css!sass!foo.scss';\n    import barCss from 'style!css!bar.css';\n\n    // good\n    import fooSass from 'foo.scss';\n    import barCss from 'bar.css';\n    ```\n\n  <a name=\"modules--import-extensions\"></a>\n  - [10.10](#modules--import-extensions) Do not include JavaScript filename extensions\n eslint: [`import/extensions`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md)\n    > Why? Including extensions inhibits refactoring, and inappropriately hardcodes implementation details of the module you're importing in every consumer.\n\n    ```javascript\n    // bad\n    import foo from './foo.js';\n    import bar from './bar.jsx';\n    import baz from './baz/index.jsx';\n\n    // good\n    import foo from './foo';\n    import bar from './bar';\n    import baz from './baz';\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Iterators and Generators\n\n  <a name=\"iterators--nope\"></a><a name=\"11.1\"></a>\n  - [11.1](#iterators--nope) Usage of iterators are acceptable. Prefer JavaScript’s higher-order functions such as find/filter/map/some when possible. eslint: [`no-iterator`](https://eslint.org/docs/rules/no-iterator.html) [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax)\n\n    > This was modified from the original code style guide\n\n    > Use `map()` / `every()` / `filter()` / `find()` / `findIndex()` / `reduce()` / `some()` / ... to iterate over arrays, and `Object.keys()` / `Object.values()` / `Object.entries()` to produce arrays so you can iterate over objects.\n\n    ```javascript\n    const numbers = [1, 2, 3, 4, 5];\n\n    // acceptable\n    let sum = 0;\n    for (let num of numbers) {\n      sum += num;\n    }\n    sum === 15;\n\n    // acceptable\n    let sum = 0;\n    numbers.forEach((num) => {\n      sum += num;\n    });\n    sum === 15;\n\n    // best (use the functional force)\n    const sum = numbers.reduce((total, num) => total + num, 0);\n    sum === 15;\n\n    // acceptable\n    const increasedByOne = [];\n    for (let i = 0; i < numbers.length; i++) {\n      increasedByOne.push(numbers[i] + 1);\n    }\n\n    // acceptable\n    const increasedByOne = [];\n    numbers.forEach((num) => {\n      increasedByOne.push(num + 1);\n    });\n\n    // best (keeping it functional)\n    const increasedByOne = numbers.map((num) => num + 1);\n    ```\n\n  <a name=\"generators--nope\"></a><a name=\"11.2\"></a>\n  - [11.2](#generators--nope) Don’t use generators for now.\n\n    > Why? They don’t transpile well to ES5.\n\n  <a name=\"generators--spacing\"></a>\n  - [11.3](#generators--spacing) If you must use generators, or if you disregard [our advice](#generators--nope), make sure their function signature is spaced properly. eslint: [`generator-star-spacing`](https://eslint.org/docs/rules/generator-star-spacing)\n\n    > Why? `function` and `*` are part of the same conceptual keyword - `*` is not a modifier for `function`, `function*` is a unique construct, different from `function`.\n\n    ```javascript\n    // bad\n    function * foo() {\n      // ...\n    }\n\n    // bad\n    const bar = function * () {\n      // ...\n    };\n\n    // bad\n    const baz = function *() {\n      // ...\n    };\n\n    // bad\n    const quux = function*() {\n      // ...\n    };\n\n    // bad\n    function*foo() {\n      // ...\n    }\n\n    // bad\n    function *foo() {\n      // ...\n    }\n\n    // very bad\n    function\n    *\n    foo() {\n      // ...\n    }\n\n    // very bad\n    const wat = function\n    *\n    () {\n      // ...\n    };\n\n    // good\n    function* foo() {\n      // ...\n    }\n\n    // good\n    const foo = function* () {\n      // ...\n    };\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Properties\n\n  <a name=\"properties--dot\"></a><a name=\"12.1\"></a>\n  - [12.1](#properties--dot) Use dot notation when accessing properties. eslint: [`dot-notation`](https://eslint.org/docs/rules/dot-notation.html)\n\n    ```javascript\n    const luke = {\n      jedi: true,\n      age: 28,\n    };\n\n    // bad\n    const isJedi = luke['jedi'];\n\n    // good\n    const isJedi = luke.jedi;\n    ```\n\n  <a name=\"properties--bracket\"></a><a name=\"12.2\"></a>\n  - [12.2](#properties--bracket) Use bracket notation `[]` when accessing properties with a variable.\n\n    ```javascript\n    const luke = {\n      jedi: true,\n      age: 28,\n    };\n\n    function getProp(prop) {\n      return luke[prop];\n    }\n\n    const isJedi = getProp('jedi');\n    ```\n\n  <a name=\"es2016-properties--exponentiation-operator\"></a>\n  - [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` or `Math.pow` when calculating exponentiations. eslint: [`no-restricted-properties`](https://eslint.org/docs/rules/no-restricted-properties).\n\n      > This was modified from the original code style guide\n\n    ```javascript\n    // acceptable\n    const binary = Math.pow(2, 10);\n\n    // acceptable\n    const binary = 2 ** 10;\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Variables\n\n  <a name=\"variables--const\"></a><a name=\"13.1\"></a>\n  - [13.1](#variables--const) Always use `const` or `let` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that. eslint: [`no-undef`](https://eslint.org/docs/rules/no-undef) [`prefer-const`](https://eslint.org/docs/rules/prefer-const)\n\n    ```javascript\n    // bad\n    superPower = new SuperPower();\n\n    // good\n    const superPower = new SuperPower();\n    ```\n\n  <a name=\"variables--one-const\"></a><a name=\"13.2\"></a>\n  - [13.2](#variables--one-const) Use one `const` or `let` declaration per variable or assignment. eslint: [`one-var`](https://eslint.org/docs/rules/one-var.html)\n\n    > Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once.\n\n    ```javascript\n    // bad\n    const items = getItems(),\n        goSportsTeam = true,\n        dragonball = 'z';\n\n    // bad\n    // (compare to above, and try to spot the mistake)\n    const items = getItems(),\n        goSportsTeam = true;\n        dragonball = 'z';\n\n    // good\n    const items = getItems();\n    const goSportsTeam = true;\n    const dragonball = 'z';\n    ```\n\n  <a name=\"variables--const-let-group\"></a><a name=\"13.3\"></a>\n  - [13.3](#variables--const-let-group) Group all your `const`s and then group all your `let`s.\n\n    > Why? This is helpful when later on you might need to assign a variable depending on one of the previously assigned variables.\n\n    ```javascript\n    // bad\n    let i, len, dragonball,\n        items = getItems(),\n        goSportsTeam = true;\n\n    // bad\n    let i;\n    const items = getItems();\n    let dragonball;\n    const goSportsTeam = true;\n    let len;\n\n    // good\n    const goSportsTeam = true;\n    const items = getItems();\n    let dragonball;\n    let i;\n    let length;\n    ```\n\n  <a name=\"variables--define-where-used\"></a><a name=\"13.4\"></a>\n  - [13.4](#variables--define-where-used) Assign variables where you need them, but place them in a reasonable place.\n\n    > Why? `let` and `const` are block scoped and not function scoped.\n\n    ```javascript\n    // bad - unnecessary function call\n    function checkName(hasName) {\n      const name = getName();\n\n      if (hasName === 'test') {\n        return false;\n      }\n\n      if (name === 'test') {\n        this.setName('');\n        return false;\n      }\n\n      return name;\n    }\n\n    // good\n    function checkName(hasName) {\n      if (hasName === 'test') {\n        return false;\n      }\n\n      const name = getName();\n\n      if (name === 'test') {\n        this.setName('');\n        return false;\n      }\n\n      return name;\n    }\n    ```\n\n  <a name=\"variables--no-chain-assignment\"></a><a name=\"13.5\"></a>\n  - [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. eslint: [`no-multi-assign`](https://eslint.org/docs/rules/no-multi-assign)\n\n    > Why? Chaining variable assignments creates implicit global variables.\n\n    ```javascript\n    // bad\n    (function example() {\n      // JavaScript interprets this as\n      // let a = ( b = ( c = 1 ) );\n      // The let keyword only applies to variable a; variables b and c become\n      // global variables.\n      let a = b = c = 1;\n    }());\n\n    console.log(a); // throws ReferenceError\n    console.log(b); // 1\n    console.log(c); // 1\n\n    // good\n    (function example() {\n      let a = 1;\n      let b = a;\n      let c = a;\n    }());\n\n    console.log(a); // throws ReferenceError\n    console.log(b); // throws ReferenceError\n    console.log(c); // throws ReferenceError\n\n    // the same applies for `const`\n    ```\n\n  <a name=\"variables--unary-increment-decrement\"></a><a name=\"13.6\"></a>\n  - [13.6](#variables--unary-increment-decrement) Using unary increments and decrements (`++`, `--`) is acceptable. eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus)\n\n    > This was modified from the original code style guide\n\n    ```javascript\n    // acceptable\n    const array = [1, 2, 3];\n    let num = 1;\n    num++;\n    --num;\n\n    let sum = 0;\n    let truthyCount = 0;\n    for (let i = 0; i < array.length; i++) {\n      let value = array[i];\n      sum += value;\n      if (value) {\n        truthyCount++;\n      }\n    }\n\n    // acceptable\n    const array = [1, 2, 3];\n    let num = 1;\n    num += 1;\n    num -= 1;\n\n    const sum = array.reduce((a, b) => a + b, 0);\n    const truthyCount = array.filter(Boolean).length;\n    ```\n\n<a name=\"variables--linebreak\"></a>\n  - [13.7](#variables--linebreak) Avoid linebreaks before or after `=` in an assignment. If your assignment violates [`max-len`](https://eslint.org/docs/rules/max-len.html), surround the value in parens. eslint [`operator-linebreak`](https://eslint.org/docs/rules/operator-linebreak.html).\n\n    > Why? Linebreaks surrounding `=` can obfuscate the value of an assignment.\n\n    ```javascript\n    // bad\n    const foo =\n      superLongLongLongLongLongLongLongLongFunctionName();\n\n    // bad\n    const foo\n      = 'superLongLongLongLongLongLongLongLongString';\n\n    // good\n    const foo = (\n      superLongLongLongLongLongLongLongLongFunctionName()\n    );\n\n    // good\n    const foo = 'superLongLongLongLongLongLongLongLongString';\n    ```\n\n<a name=\"variables--no-unused-vars\"></a>\n  - [13.8](#variables--no-unused-vars) Disallow unused variables. eslint: [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars)\n\n    > Why? Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers.\n\n    ```javascript\n    // bad\n\n    var some_unused_var = 42;\n\n    // Write-only variables are not considered as used.\n    var y = 10;\n    y = 5;\n\n    // A read for a modification of itself is not considered as used.\n    var z = 0;\n    z = z + 1;\n\n    // Unused function arguments.\n    function getX(x, y) {\n        return x;\n    }\n\n    // good\n\n    function getXPlusY(x, y) {\n      return x + y;\n    }\n\n    var x = 1;\n    var y = a + 2;\n\n    alert(getXPlusY(x, y));\n\n    // 'type' is ignored even if unused because it has a rest property sibling.\n    // This is a form of extracting an object that omits the specified keys.\n    var { type, ...coords } = data;\n    // 'coords' is now the 'data' object without its 'type' property.\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Hoisting\n\n  <a name=\"hoisting--about\"></a><a name=\"14.1\"></a>\n  - [14.1](#hoisting--about) `var` declarations get hoisted to the top of their closest enclosing function scope, their assignment does not. `const` and `let` declarations are blessed with a new concept called [Temporal Dead Zones (TDZ)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz). It’s important to know why [typeof is no longer safe](https://web.archive.org/web/20200121061528/http://es-discourse.com/t/why-typeof-is-no-longer-safe/15).\n\n    ```javascript\n    // we know this wouldn’t work (assuming there\n    // is no notDefined global variable)\n    function example() {\n      console.log(notDefined); // => throws a ReferenceError\n    }\n\n    // creating a variable declaration after you\n    // reference the variable will work due to\n    // variable hoisting. Note: the assignment\n    // value of `true` is not hoisted.\n    function example() {\n      console.log(declaredButNotAssigned); // => undefined\n      var declaredButNotAssigned = true;\n    }\n\n    // the interpreter is hoisting the variable\n    // declaration to the top of the scope,\n    // which means our example could be rewritten as:\n    function example() {\n      let declaredButNotAssigned;\n      console.log(declaredButNotAssigned); // => undefined\n      declaredButNotAssigned = true;\n    }\n\n    // using const and let\n    function example() {\n      console.log(declaredButNotAssigned); // => throws a ReferenceError\n      console.log(typeof declaredButNotAssigned); // => throws a ReferenceError\n      const declaredButNotAssigned = true;\n    }\n    ```\n\n  <a name=\"hoisting--anon-expressions\"></a><a name=\"14.2\"></a>\n  - [14.2](#hoisting--anon-expressions) Anonymous function expressions hoist their variable name, but not the function assignment.\n\n    ```javascript\n    function example() {\n      console.log(anonymous); // => undefined\n\n      anonymous(); // => TypeError anonymous is not a function\n\n      var anonymous = function () {\n        console.log('anonymous function expression');\n      };\n    }\n    ```\n\n  <a name=\"hoisting--named-expresions\"></a><a name=\"hoisting--named-expressions\"></a><a name=\"14.3\"></a>\n  - [14.3](#hoisting--named-expressions) Named function expressions hoist the variable name, not the function name or the function body.\n\n    ```javascript\n    function example() {\n      console.log(named); // => undefined\n\n      named(); // => TypeError named is not a function\n\n      superPower(); // => ReferenceError superPower is not defined\n\n      var named = function superPower() {\n        console.log('Flying');\n      };\n    }\n\n    // the same is true when the function name\n    // is the same as the variable name.\n    function example() {\n      console.log(named); // => undefined\n\n      named(); // => TypeError named is not a function\n\n      var named = function named() {\n        console.log('named');\n      };\n    }\n    ```\n\n  <a name=\"hoisting--declarations\"></a><a name=\"14.4\"></a>\n  - [14.4](#hoisting--declarations) Function declarations hoist their name and the function body.\n\n    ```javascript\n    function example() {\n      superPower(); // => Flying\n\n      function superPower() {\n        console.log('Flying');\n      }\n    }\n    ```\n\n  - For more information refer to [JavaScript Scoping & Hoisting](https://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting/) by [Ben Cherry](https://www.adequatelygood.com/).\n\n**[⬆ back to top](#table-of-contents)**\n\n## Comparison Operators & Equality\n\n  <a name=\"comparison--eqeqeq\"></a><a name=\"15.1\"></a>\n  - [15.1](#comparison--eqeqeq) Use `===` and `!==` over `==` and `!=` unless comparing null, two literals, or the result of typeof (per eslint's eqeqeq \"smart\" mode). eslint: [`eqeqeq`](https://eslint.org/docs/rules/eqeqeq.html)\n\n      > This was modified from the original code style guide\n\n  <a name=\"comparison--if\"></a><a name=\"15.2\"></a>\n  - [15.2](#comparison--if) Conditional statements such as the `if` statement evaluate their expression using coercion with the `ToBoolean` abstract method and always follow these simple rules:\n\n    - **Objects** evaluate to **true**\n    - **Undefined** evaluates to **false**\n    - **Null** evaluates to **false**\n    - **Booleans** evaluate to **the value of the boolean**\n    - **Numbers** evaluate to **false** if **+0, -0, or NaN**, otherwise **true**\n    - **Strings** evaluate to **false** if an empty string `''`, otherwise **true**\n\n    ```javascript\n    if ([0] && []) {\n      // true\n      // an array (even an empty one) is an object, objects will evaluate to true\n    }\n    ```\n\n  <a name=\"comparison--shortcuts\"></a><a name=\"15.3\"></a>\n  - [15.3](#comparison--shortcuts) Use shortcuts for booleans, but explicit comparisons for strings and numbers.\n\n    ```javascript\n    // bad\n    if (isValid === true) {\n      // ...\n    }\n\n    // good\n    if (isValid) {\n      // ...\n    }\n\n    // bad\n    if (name) {\n      // ...\n    }\n\n    // good\n    if (name !== '') {\n      // ...\n    }\n\n    // bad\n    if (collection.length) {\n      // ...\n    }\n\n    // good\n    if (collection.length > 0) {\n      // ...\n    }\n    ```\n\n  <a name=\"comparison--moreinfo\"></a><a name=\"15.4\"></a>\n  - [15.4](#comparison--moreinfo) For more information see [Truth Equality and JavaScript](https://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll.\n\n  <a name=\"comparison--switch-blocks\"></a><a name=\"15.5\"></a>\n  - [15.5](#comparison--switch-blocks) Use braces to create blocks in `case` and `default` clauses that contain lexical declarations (e.g. `let`, `const`, `function`, and `class`). eslint: [`no-case-declarations`](https://eslint.org/docs/rules/no-case-declarations.html)\n\n    > Why? Lexical declarations are visible in the entire `switch` block but only get initialized when assigned, which only happens when its `case` is reached. This causes problems when multiple `case` clauses attempt to define the same thing.\n\n    ```javascript\n    // bad\n    switch (foo) {\n      case 1:\n        let x = 1;\n        break;\n      case 2:\n        const y = 2;\n        break;\n      case 3:\n        function f() {\n          // ...\n        }\n        break;\n      default:\n        class C {}\n    }\n\n    // good\n    switch (foo) {\n      case 1: {\n        let x = 1;\n        break;\n      }\n      case 2: {\n        const y = 2;\n        break;\n      }\n      case 3: {\n        function f() {\n          // ...\n        }\n        break;\n      }\n      case 4:\n        bar();\n        break;\n      default: {\n        class C {}\n      }\n    }\n    ```\n\n  <a name=\"comparison--nested-ternaries\"></a><a name=\"15.6\"></a>\n  - [15.6](#comparison--nested-ternaries) Ternaries should not be nested and generally be single line expressions. eslint: [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary.html)\n\n    ```javascript\n    // bad\n    const foo = maybe1 > maybe2\n      ? \"bar\"\n      : value1 > value2 ? \"baz\" : null;\n\n    // split into 2 separated ternary expressions\n    const maybeNull = value1 > value2 ? 'baz' : null;\n\n    // better\n    const foo = maybe1 > maybe2\n      ? 'bar'\n      : maybeNull;\n\n    // best\n    const foo = maybe1 > maybe2 ? 'bar' : maybeNull;\n    ```\n\n  <a name=\"comparison--unneeded-ternary\"></a><a name=\"15.7\"></a>\n  - [15.7](#comparison--unneeded-ternary) Avoid unneeded ternary statements. eslint: [`no-unneeded-ternary`](https://eslint.org/docs/rules/no-unneeded-ternary.html)\n\n    ```javascript\n    // bad\n    const foo = a ? a : b;\n    const bar = c ? true : false;\n    const baz = c ? false : true;\n\n    // good\n    const foo = a || b;\n    const bar = !!c;\n    const baz = !c;\n    ```\n\n  <a name=\"comparison--no-mixed-operators\"></a>\n  - [15.8](#comparison--no-mixed-operators) When mixing operators, enclose them in parentheses. The only exception is the standard arithmetic operators: `+`, `-`, and `**` since their precedence is broadly understood. We recommend enclosing `/` and `*` in parentheses because their precedence can be ambiguous when they are mixed.\n  eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html)\n\n    > Why? This improves readability and clarifies the developer’s intention.\n\n    ```javascript\n    // bad\n    const foo = a && b < 0 || c > 0 || d + 1 === 0;\n\n    // bad\n    const bar = a ** b - 5 % d;\n\n    // bad\n    // one may be confused into thinking (a || b) && c\n    if (a || b && c) {\n      return d;\n    }\n\n    // bad\n    const bar = a + b / c * d;\n\n    // good\n    const foo = (a && b < 0) || c > 0 || (d + 1 === 0);\n\n    // good\n    const bar = a ** b - (5 % d);\n\n    // good\n    if (a || (b && c)) {\n      return d;\n    }\n\n    // good\n    const bar = a + (b / c) * d;\n    ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Blocks\n\n  <a name=\"blocks--braces\"></a><a name=\"16.1\"></a>\n  - [16.1](#blocks--braces) Use braces with all multiline blocks. eslint: [`nonblock-statement-body-position`](https://eslint.org/docs/rules/nonblock-statement-body-position)\n\n    ```javascript\n    // bad\n    if (test)\n      return false;\n\n    // good\n    if (test) return false;\n\n    // good\n    if (test) {\n      return false;\n    }\n\n    // bad\n    function foo() { return false; }\n\n    // good\n    function bar() {\n      return false;\n    }\n    ```\n\n  <a name=\"blocks--cuddled-elses\"></a><a name=\"16.2\"></a>\n  - [16.2](#blocks--cuddled-elses) If you’re using multiline blocks with `if` and `else`, put `else` on the same line as your `if` block’s closing brace. eslint: [`brace-style`](https://eslint.org/docs/rules/brace-style.html)\n\n    ```javascript\n    // bad\n    if (test) {\n      thing1();\n      thing2();\n    }\n    else {\n      thing3();\n    }\n\n    // good\n    if (test) {\n      thing1();\n      thing2();\n    } else {\n      thing3();\n    }\n    ```\n\n  <a name=\"blocks--no-else-return\"></a><a name=\"16.3\"></a>\n  - [16.3](#blocks--no-else-return) If an `if` block always executes a `return` statement, the subsequent `else` block is unnecessary. A `return` in an `else if` block following an `if` block that contains a `return` can b","readmeFilename":"README.md"}