9 files changed

+83
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": "2017",
4+
"sourceType": "module"
5+
},
6+
"rules": {
7+
"eqeqeq": 2,
8+
"no-console": 0,
9+
"quotes": [2, "single"],
10+
"linebreak-style": [2, "unix"],
11+
"semi": [2, "always"],
12+
"no-unused-vars": 0,
13+
"react/prop-types": 0
14+
},
15+
"globals": {
16+
"define": true
17+
},
18+
"env": {
19+
"es6": true,
20+
"browser": true,
21+
"commonjs": true
22+
},
23+
"extends": ["eslint:recommended"]
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ function makeBankAccount() {
985985
return {
986986
// ...
987987
getBalance,
988-
setBalance
988+
setBalance,
989989
};
990990
}
991991

@@ -1156,15 +1156,15 @@ function makeNodeAdapter() {
11561156
}
11571157

11581158
function makeHttpRequester(adapter) {
1159-
fetch(url) {
1159+
function fetch(url) {
11601160
return adapter.request(url).then((response) => {
11611161
// transform response and return
11621162
});
11631163
}
11641164

11651165
return {
11661166
fetch,
1167-
}
1167+
};
11681168
}
11691169
```
11701170
[full example](examples/open-closed-principle-GOOD.js)
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
function makeAirplane(config) {
22
function getMaxAltitude() {
3-
return config.altitude;
4-
}
5-
6-
function getPassengerCount() {
7-
return config.passengers;
8-
}
3+
return config.altitude;
4+
}
95

10-
function getFuelExpenditure() {
11-
return config.fuelExpenditure;
12-
}
6+
function getPassengerCount() {
7+
return config.passengers;
8+
}
139

10+
function getFuelExpenditure() {
11+
return config.fuelExpenditure;
12+
}
1413

1514
function getCruisingAltitude() {
1615
switch (config.type) {
@@ -28,5 +27,5 @@ function getFuelExpenditure() {
2827
getPassengerCount,
2928
getFuelExpenditure,
3029
getCruisingAltitude
31-
}
30+
};
3231
}
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ const config = {
5353
passengers: 200,
5454
fuelExpenditure: 10,
5555
cruisingAltitude: 800
56-
}
56+
};
5757

5858
const cessna = makeCessna(config);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global makeAjaxCall, makeHttpCall */
12
class AjaxAdapter {
23
constructor() {
34
this.name = 'ajaxAdapter';
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global fetch */
12
function makeAjaxAdapter() {
23
// ..
34
function request(url) {
@@ -21,15 +22,15 @@ function makeNodeAdapter() {
2122
}
2223

2324
function makeHttpRequester(adapter) {
24-
fetch(url) {
25+
function fetch(url) {
2526
return adapter.request(url).then((response) => {
2627
// transform response and return
2728
});
2829
}
2930

3031
return {
3132
fetch,
32-
}
33+
};
3334
}
3435

3536
// example usage
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
function makeBankAccount() {
2-
// this one is private
3-
let balance = 0;
2+
// this one is private
3+
let balance = 0;
44

5-
// a "getter", made public via the returned object below
6-
function getBalance() {
7-
return balance;
8-
}
5+
// a "getter", made public via the returned object below
6+
function getBalance() {
7+
return balance;
8+
}
99

10-
// a "setter", made public via the returned object below
11-
function setBalance(amount) {
12-
// ... validate before updating the balance
13-
balance = amount;
14-
}
10+
// a "setter", made public via the returned object below
11+
function setBalance(amount) {
12+
// ... validate before updating the balance
13+
balance = amount;
14+
}
1515

16-
return {
17-
// ...
18-
getBalance,
19-
setBalance
20-
};
16+
return {
17+
// ...
18+
getBalance,
19+
setBalance,
20+
};
2121
}
2222

2323
const account = makeBankAccount();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "clean-code-javascript-func-remix",
3+
"version": "1.0.0",
4+
"description": "Clean Code JavaScript (Davids func remix)",
5+
"main": "index.js",
6+
"directories": {
7+
"example": "examples"
8+
},
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://.com/DavidVujic/clean-code-javascript.git"
15+
},
16+
"author": "David Vujic",
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://.com/DavidVujic/clean-code-javascript/issues"
20+
},
21+
"homepage": "https://.com/DavidVujic/clean-code-javascript#readme",
22+
"devDependencies": {
23+
"eslint": "^3.14.1"
24+
}
25+
}

0 commit comments

Comments
 (0)