diff --git a/README.md b/README.md index 32c966ce98..eca714314a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Airbnb JavaScript Style Guide() { +# Crowdtap JavaScript Style Guide() { *A mostly reasonable approach to JavaScript* @@ -1334,14 +1334,14 @@ Other Style Guides ## Blocks - - [16.1](#16.1) Use braces with all multi-line blocks. + - [16.1](#16.1) Use braces with all blocks. ```javascript // bad if (test) return false; - // good + // bad if (test) return false; // good @@ -1483,6 +1483,13 @@ Other Style Guides } } ``` + + - [17.6](#17.6) Use `// XXX:` to annotate quirks, gotchas, and hacks, especially if it's not immediately obvious what the code is doing. + + ```javascript + // XXX: Trims the ", 20XX" from the date string if in current year + if (expiresAt.isSame(moment(), 'year')) time = time.slice(0, -6); + ``` **[⬆ back to top](#table-of-contents)** @@ -2112,6 +2119,24 @@ Other Style Guides export default AirbnbStyleGuide; ``` + + - [22.9](#22.9) Using snake_case is only acceptable for attributes returned from an API. + + ```javascript + // bad + Users + .get() + .then( (data) => { + vm.user_name = data.user_name; + }); + + // good + Users + .get() + .then( (data) => { + vm.userName = data.user_name; + }); + ``` **[⬆ back to top](#table-of-contents)** diff --git a/linters/.jshintrc b/linters/.jshintrc index 4d3468cb21..24db7b7725 100644 --- a/linters/.jshintrc +++ b/linters/.jshintrc @@ -13,6 +13,12 @@ // Define globals exposed by Node.js. "node": true, + // Define globals exposed by Mocha test framework. + "mocha": true, + + // Define globals from assets.shared and other libraries + "predef": ["Q", "EventBus", "ActionFetcher", "B64", "angular"], + // Allow ES6. "esnext": true, @@ -28,6 +34,9 @@ // Prohibit use of == and != in favor of === and !==. "eqeqeq": true, + // Prohibit overwriting prototypes of native objects. + "freeze": true, + // Enforce tab width of 2 spaces. "indent": 2, @@ -40,11 +49,8 @@ // Require capitalized names for constructor functions. "newcap": true, - // Enforce use of single quotation marks for strings. - "quotmark": "single", - - // Enforce placing 'use strict' at the top function scope - "strict": true, + // Prohibit trailing whitespace. + "trailing": true, // Prohibit use of explicitly undeclared variables. "undef": true, @@ -52,6 +58,9 @@ // Warn when variables are defined but never used. "unused": true, + // Enforce placing 'use strict' at the top function scope + "strict": true, + /* * RELAXING OPTIONS * ================= diff --git a/linters/SublimeLinter/SublimeLinter.sublime-settings b/linters/SublimeLinter/SublimeLinter.sublime-settings index 12360f3f1c..8029716c28 100644 --- a/linters/SublimeLinter/SublimeLinter.sublime-settings +++ b/linters/SublimeLinter/SublimeLinter.sublime-settings @@ -28,6 +28,12 @@ // Define globals exposed by Node.js. "node": true, + // Define globals exposed by Mocha test framework. + "mocha": true, + + // Define globals from assets.shared and other libraries + "predef": ["Q", "EventBus", "ActionFetcher", "B64", "angular"], + /* * ENFORCING OPTIONS * ================= @@ -43,6 +49,9 @@ // Suppress warnings about == null comparisons. "eqnull": true, + // Prohibit overwriting prototypes of native objects. + "freeze": true, + // Enforce tab width of 2 spaces. "indent": 2, @@ -52,9 +61,6 @@ // Require capitalized names for constructor functions. "newcap": true, - // Enforce use of single quotation marks for strings. - "quotmark": "single", - // Prohibit trailing whitespace. "trailing": true, @@ -63,9 +69,6 @@ // Warn when variables are defined but never used. "unused": true, - - // Enforce line length to 80 characters - "maxlen": 80, // Enforce placing 'use strict' at the top function scope "strict": true