Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 21e7294

Browse files
author
Marlow Payne
committed
Merge pull request #105 from mobify/release-v2.4.3
Release v2.4.3: Trailing Commas
2 parents 2ee4826 + fb2dbc5 commit 21e7294

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2.4.3
2+
- Add eslint rule + doc entry regarding trailing commas
13
2.4.2
24
- Add/update documentation for Sass-Lint
35
2.4.1

javascript/.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@
110110
"semi": 2,
111111

112112
// Disallow function definitions of the form 'function myFunc() {'
113-
"func-style": [2, "expression"]
113+
"func-style": [2, "expression"],
114+
115+
// Enforce trailing comma style
116+
"comma-style": [2, "last"]
114117
}
115118
}

javascript/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ a = b;
105105
(f());
106106
```
107107

108+
##Use trailing commas
109+
110+
For multi-line lists or object properties place the commas separating items at the end of the line of the previous item.
111+
112+
```javascript
113+
// bad
114+
var foo = ["apples"
115+
, "oranges"
116+
, "bananas"];
117+
118+
var foo = {
119+
"fruit": "apple"
120+
, "vegetable": "arugula"
121+
};
122+
123+
// good
124+
var foo = ["apples",
125+
"oranges",
126+
"bananas"];
127+
128+
var foo = {
129+
"fruit": "apple",
130+
"vegetable": "arugula"
131+
};
132+
```
133+
108134
##Use function expressions over function declarations
109135

110136
The function expression is clearly recognisable as what it really is (a variable with a function value). Additionally, it helps organize code so that all variable declarations appear at the top of a file, and invocations follow. This gives some predictablity when others are reading your code, allowing for a more consistent structure.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobify-code-style",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "Code style guide and linting tools for Mobify",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)