@@ -6,6 +6,24 @@ This repo contains an `eslintrc.js` file that should be included (as
66` .eslintrc.js ` ) in each project. Periodically, a repo's ` .eslintrc.js ` file
77should be synced with the one here.
88
9+ ### Variable and Function Names
10+
11+ Names of variables and functions should be CamelCased. This may not be
12+ practical to enforce automatically with ESLint on all projects, since code
13+ interacting with APIs will frequently need to snake\_ case object properties for
14+ API queries and such. In those cases, only use snake\_ case when interacting
15+ directly with the API, either querying or handling a response. If an API
16+ response is being transformed into a model-like object, key names should change
17+ to CamelCase at that boundary. E.g.:
18+
19+ ```
20+ api.getModel("id").then(function(data) {
21+ var model = new Model();
22+ model.keyName = data.key_name;
23+ return model;
24+ });
25+ ```
26+
927### JQuery
1028
1129- Prefer ` return false ` over ` event.preventDefault() ` when you don't need the
@@ -24,3 +42,18 @@ should be synced with the one here.
2442 return false ;
2543 });
2644 ```
45+
46+ ### ECMAScript 6
47+
48+ There is an additional set of ESLint rules we use for ES6 code: these are in
49+ ` eslintrc-es6.js ` , and can be included into the main ` .eslintrc.js ` file in ES6
50+ projects with an ` "extends" ` directive.
51+
52+ The rules there are mostly self explanatory, with one perhaps requiring an
53+ explanatory note: ` => ` functions are preferred over the ` var self = this; `
54+ pattern, but not ` => ` in all cases, as there are good reasons * not* to use ` => `
55+ in other cases. The ` consistent-this ` rule makes it feasible to flag these
56+ non-preferred usages without causing false positives on other cases, though
57+ this isn't the strictly intended purpose of the rule. This does not mean that
58+ ` => ` should not be used in any other cases, only that whether to use it or not
59+ in other cases is a judgment call.
0 commit comments