Skip to content

Commit 81048dc

Browse files
committed
Change eslint rule arrow-parens to always
1 parent 4d0632e commit 81048dc

15 files changed

+60
-60
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
],
209209
"arrow-parens": [
210210
"error",
211-
"as-needed"
211+
"always"
212212
],
213213
"arrow-body-style": [
214214
"error",

JavaScript/2-emulate-async-calls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const callbackCounter = (count, callback) => {
1313

1414
// Emulate asynchronous calls
1515

16-
const wrapAsync = fn => (...args) => setTimeout(
16+
const wrapAsync = (fn) => (...args) => setTimeout(
1717
() => fn(...args), Math.floor(Math.random() * 1000)
1818
);
1919

JavaScript/3-back-to-order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Emulate asynchronous calls
66

7-
const wrapAsync = fn => (...args) => setTimeout(
7+
const wrapAsync = (fn) => (...args) => setTimeout(
88
() => fn(...args), Math.floor(Math.random() * 1000)
99
);
1010

JavaScript/4-step-by-step.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const data = {};
77

88
// Emulate asynchronous calls
99

10-
const wrapAsync = fn => (...args) => setTimeout(
10+
const wrapAsync = (fn) => (...args) => setTimeout(
1111
() => fn(...args), Math.floor(Math.random() * 1000)
1212
);
1313

JavaScript/5-chain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const chain = (prev = null) => {
3535

3636
// Emulate asynchronous calls
3737

38-
const wrapAsync = fn => (...args) => setTimeout(
38+
const wrapAsync = (fn) => (...args) => setTimeout(
3939
() => fn(...args), Math.floor(Math.random() * 1000)
4040
);
4141

JavaScript/6-promise-sequential.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22

33
// Emulate asynchronous calls
44

5-
const wrapAsync = callback => setTimeout(
5+
const wrapAsync = (callback) => setTimeout(
66
callback, Math.floor(Math.random() * 1000)
77
);
88

99
const isWeekend = () => !(new Date().getDay() % 6);
1010

1111
// Asynchronous functions
1212

13-
const readConfig = name => new Promise((resolve, reject) => {
13+
const readConfig = (name) => new Promise((resolve, reject) => {
1414
wrapAsync(() => {
1515
console.log('(1) config loaded');
1616
if (!isWeekend()) resolve({ name });
1717
else reject(new Error('Promises will resolve next working day'));
1818
});
1919
});
2020

21-
const doQuery = statement => new Promise((resolve, reject) => {
21+
const doQuery = (statement) => new Promise((resolve, reject) => {
2222
wrapAsync(() => {
2323
console.log('(2) SQL query executed: ' + statement);
2424
if (!isWeekend()) resolve([{ name: 'Kiev' }, { name: 'Roma' }]);
2525
else reject(new Error('Promises will resolve next working day'));
2626
});
2727
});
2828

29-
const httpGet = url => new Promise((resolve, reject) => {
29+
const httpGet = (url) => new Promise((resolve, reject) => {
3030
wrapAsync(() => {
3131
console.log('(3) Page retrieved: ' + url);
3232
if (!isWeekend()) resolve('<html>Some archaic web here</html>');
3333
else reject(new Error('Promises will resolve next working day'));
3434
});
3535
});
3636

37-
const readFile = path => new Promise((resolve, reject) => {
37+
const readFile = (path) => new Promise((resolve, reject) => {
3838
wrapAsync(() => {
3939
console.log('(4) Readme file loaded: ' + path);
4040
if (!isWeekend()) resolve('file content');
@@ -48,10 +48,10 @@ Promise.resolve()
4848
.then(readConfig.bind(null, 'myConfig'))
4949
.then(doQuery.bind(null, 'select * from cities'))
5050
.then(httpGet.bind(null, 'http://kpi.ua'))
51-
.catch(err => console.log('Reject reason (1): ' + err.message))
51+
.catch((err) => console.log('Reject reason (1): ' + err.message))
5252
.then(readFile.bind(null, 'README.md'))
53-
.catch(err => console.log('Reject reason (2): ' + err.message))
54-
.then(data => {
53+
.catch((err) => console.log('Reject reason (2): ' + err.message))
54+
.then((data) => {
5555
console.log('Done');
5656
console.dir({ data });
5757
});

JavaScript/7-promise-all.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22

33
// Emulate asynchronous calls
44

5-
const wrapAsync = callback => setTimeout(
5+
const wrapAsync = (callback) => setTimeout(
66
callback, Math.floor(Math.random() * 1000)
77
);
88

99
// Asynchronous functions
1010

11-
const readConfig = name => new Promise(resolve => {
11+
const readConfig = (name) => new Promise((resolve) => {
1212
wrapAsync(() => {
1313
console.log('(1) config loaded: ' + name);
1414
resolve({ name });
1515
});
1616
});
1717

18-
const doQuery = statement => new Promise(resolve => {
18+
const doQuery = (statement) => new Promise((resolve) => {
1919
wrapAsync(() => {
2020
console.log('(2) SQL query executed: ' + statement);
2121
resolve([ { name: 'Kiev' }, { name: 'Roma' } ]);
2222
});
2323
});
2424

25-
const httpGet = url => new Promise(resolve => {
25+
const httpGet = (url) => new Promise((resolve) => {
2626
wrapAsync(() => {
2727
console.log('(3) Page retrieved: ' + url);
2828
resolve('<html>Some archaic web here</html>');
2929
});
3030
});
3131

32-
const readFile = path => new Promise(resolve => {
32+
const readFile = (path) => new Promise((resolve) => {
3333
wrapAsync(() => {
3434
console.log('(4) Readme file loaded: ' + path);
3535
resolve('file content');
@@ -43,7 +43,7 @@ Promise.all([
4343
doQuery('select * from cities'),
4444
httpGet('http://kpi.ua'),
4545
readFile('README.md')
46-
]).then(data => {
46+
]).then((data) => {
4747
console.log('Done');
4848
console.dir({ data });
4949
});

JavaScript/8-promise-mixed.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22

33
// Emulate asynchronous calls
44

5-
const wrapAsync = callback => setTimeout(
5+
const wrapAsync = (callback) => setTimeout(
66
callback, Math.floor(Math.random() * 1000)
77
);
88

99
// Asynchronous functions
1010

11-
const readConfig = name => new Promise(resolve => {
11+
const readConfig = (name) => new Promise((resolve) => {
1212
wrapAsync(() => {
1313
console.log('(1) config loaded: ' + name);
1414
resolve({ name });
1515
});
1616
});
1717

18-
const doQuery = statement => new Promise(resolve => {
18+
const doQuery = (statement) => new Promise((resolve) => {
1919
wrapAsync(() => {
2020
console.log('(2) SQL query executed: ' + statement);
2121
resolve([ { name: 'Kiev' }, { name: 'Roma' } ]);
2222
});
2323
});
2424

25-
const httpGet = url => new Promise(resolve => {
25+
const httpGet = (url) => new Promise((resolve) => {
2626
wrapAsync(() => {
2727
console.log('(3) Page retrieved: ' + url);
2828
resolve('<html>Some archaic web here</html>');
2929
});
3030
});
3131

32-
const readFile = path => new Promise(resolve => {
32+
const readFile = (path) => new Promise((resolve) => {
3333
wrapAsync(() => {
3434
console.log('(4) Readme file loaded: ' + path);
3535
resolve('file content');
@@ -45,7 +45,7 @@ Promise.resolve()
4545
httpGet('http://kpi.ua')
4646
]))
4747
.then(readFile.bind(null, 'README.md'))
48-
.then(data => {
48+
.then((data) => {
4949
console.log('Done');
5050
console.dir({ data });
5151
});

JavaScript/9-events.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ const ee = new EventEmitter();
55

66
// Emulate asynchronous calls
77

8-
const wrapAsync = fn => (...args) => setTimeout(
8+
const wrapAsync = (fn) => (...args) => setTimeout(
99
() => fn(...args), Math.floor(Math.random() * 1000)
1010
);
1111

1212
// Asynchronous functions
1313

14-
const readConfig = wrapAsync(name => {
14+
const readConfig = wrapAsync((name) => {
1515
console.log('(1) config loaded');
1616
ee.emit('config', { name });
1717
});
1818

19-
const doQuery = wrapAsync(statement => {
19+
const doQuery = wrapAsync((statement) => {
2020
console.log('(2) SQL query executed: ' + statement);
2121
ee.emit('query', [ { name: 'Kiev' }, { name: 'Roma' } ]);
2222
});
2323

24-
const httpGet = wrapAsync(url => {
24+
const httpGet = wrapAsync((url) => {
2525
console.log('(3) Page retrieved: ' + url);
2626
ee.emit('page', '<html>Some archaic web here</html>');
2727
});
2828

29-
const readFile = wrapAsync(path => {
29+
const readFile = wrapAsync((path) => {
3030
console.log('(4) Readme file loaded: ' + path);
3131
ee.emit('done', 'file content');
3232
});

JavaScript/a-to-async.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// Sync function to async
44

5-
const last = arr => arr[arr.length - 1];
5+
const last = (arr) => arr[arr.length - 1];
66

7-
const asyncify = fn => (...args) => {
7+
const asyncify = (fn) => (...args) => {
88
const callback = last(args);
99
args.pop();
1010
process.nextTick(() => {
@@ -14,10 +14,10 @@ const asyncify = fn => (...args) => {
1414

1515
// Functions
1616

17-
const f1 = par => par;
18-
const f2 = par => par;
19-
const f3 = par => par;
20-
const f4 = par => par;
17+
const f1 = (par) => par;
18+
const f2 = (par) => par;
19+
const f3 = (par) => par;
20+
const f4 = (par) => par;
2121

2222
// Usage
2323

0 commit comments

Comments
 (0)