Skip to content

Commit deb0635

Browse files
committed
Fix all eslint errors
1 parent 8e37afb commit deb0635

36 files changed

+661
-428
lines changed

.eslintrc.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ module.exports = {
55
sourceType: 'module',
66
},
77
plugins: ['ember', 'prettier'],
8-
extends: ['eslint:recommended', 'plugin:ember/recommended', 'prettier'],
8+
extends: ['airbnb-base', 'plugin:ember/recommended', 'prettier'],
99
env: {
1010
browser: true,
1111
node: true,
1212
},
1313
rules: {
14+
'func-names': 'off',
1415
'no-console': 'off',
16+
'no-underscore-dangle': 'off',
17+
18+
strict: 'off',
19+
20+
'import/no-extraneous-dependencies': 'off',
21+
'import/no-unresolved': 'off',
22+
1523
'prettier/prettier': 'error',
1624
},
1725
overrides: [

app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Application from '@ember/application';
2-
import Resolver from './resolver';
32
import loadInitializers from 'ember-load-initializers';
3+
import Resolver from './resolver';
44
import config from './config/environment';
55

66
const App = Application.extend({

app/components/file-field.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ export default TextField.extend({
44
type: 'file',
55
classNames: ['invisible'],
66

7-
click: function(event) {
7+
click(event) {
88
event.stopPropagation();
99
},
1010

11-
change: function(event) {
11+
change(event) {
1212
const input = event.target;
13-
const files = input.files;
13+
const { files } = input;
1414
const file = files[0];
1515

16-
this.onChange({ file: file });
16+
this.onChange({ file });
1717
this.reset();
1818
},
1919

2020
// Hackish way to reset file input when sender cancels file transfer,
2121
// so if sender wants later to send the same file again,
2222
// the 'change' event is triggered correctly.
23-
reset: function() {
23+
reset() {
2424
const field = this.$();
2525
field
2626
.wrap('<form>')

app/components/ip-select.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export default Component.extend({
44
content: null,
55
selectedValue: null,
66

7-
didInitAttrs: function() {
8-
this._super(...arguments);
7+
didInitAttrs(...args) {
8+
this._super(args);
99
const content = this.get('content');
1010

1111
if (!content) {
@@ -14,10 +14,10 @@ export default Component.extend({
1414
},
1515

1616
actions: {
17-
change: function() {
17+
change() {
1818
const changeAction = this.get('action');
1919
const selectedEl = this.$('select')[0];
20-
const selectedIndex = selectedEl.selectedIndex;
20+
const { selectedIndex } = selectedEl;
2121
const content = this.get('content');
2222
const selectedValue = content[selectedIndex];
2323

app/components/modal-dialog.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Component from '@ember/component';
22

33
export default Component.extend({
44
actions: {
5-
close: function() {
5+
close() {
66
// This sends an action to application route.
77
// eslint-disable-next-line ember/closure-actions
88
return this.onClose();

app/components/peer-avatar.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ export default Component.extend({
2020
'data-sending-progress': alias('peer.transfer.sendingProgress'),
2121
'data-receiving-progress': alias('peer.transfer.receivingProgress'),
2222

23-
didInsertElement: function() {
24-
this._super(...arguments);
23+
didInsertElement(...args) {
24+
this._super(args);
2525
const peer = this.get('peer');
2626
const toggleTransferCompletedClass = () => {
2727
const klass = 'transfer-completed';
2828

2929
later(
3030
this,
31-
function() {
31+
function toggleClass() {
3232
this.$()
3333
.parent('.avatar')
3434
.addClass(klass)
3535
.delay(2000)
36-
.queue(function() {
36+
.queue(function removeClass() {
3737
$(this)
3838
.removeClass(klass)
3939
.dequeue();
@@ -47,16 +47,16 @@ export default Component.extend({
4747
peer.on('didSendFile', toggleTransferCompletedClass);
4848
},
4949

50-
willDestroyElement: function() {
51-
this._super(...arguments);
50+
willDestroyElement(...args) {
51+
this._super(args);
5252
const peer = this.get('peer');
5353

5454
peer.off('didReceiveFile');
5555
peer.off('didSendFile');
5656
},
5757

5858
// Delegate click to hidden file field in peer template
59-
click: function() {
59+
click() {
6060
if (this.canSendFile()) {
6161
this.$()
6262
.closest('.peer')
@@ -66,33 +66,33 @@ export default Component.extend({
6666
},
6767

6868
// Handle drop events
69-
dragEnter: function(event) {
69+
dragEnter(event) {
7070
this.cancelEvent(event);
7171

7272
this.$()
7373
.parent('.avatar')
7474
.addClass('hover');
7575
},
7676

77-
dragOver: function(event) {
77+
dragOver(event) {
7878
this.cancelEvent(event);
7979
},
8080

81-
dragLeave: function() {
81+
dragLeave() {
8282
this.$()
8383
.parent('.avatar')
8484
.removeClass('hover');
8585
},
8686

87-
drop: function(event) {
87+
drop(event) {
8888
this.cancelEvent(event);
8989
this.$()
9090
.parent('.avatar')
9191
.removeClass('hover');
9292

9393
const peer = this.get('peer');
9494
const dt = event.originalEvent.dataTransfer;
95-
const files = dt.files;
95+
const { files } = dt;
9696
const file = files[0];
9797

9898
if (this.canSendFile()) {
@@ -103,26 +103,26 @@ export default Component.extend({
103103
});
104104
} else {
105105
this.isFile(file).then(() => {
106-
this.onFileDrop({ file: file });
106+
this.onFileDrop({ file });
107107
});
108108
}
109109
}
110110
},
111111

112-
cancelEvent: function(event) {
112+
cancelEvent(event) {
113113
event.stopPropagation();
114114
event.preventDefault();
115115
},
116116

117-
canSendFile: function() {
117+
canSendFile() {
118118
const peer = this.get('peer');
119119

120120
// Can't send files if another file transfer is already in progress
121121
return !(peer.get('transfer.file') || peer.get('transfer.info'));
122122
},
123123

124-
isFile: function(file) {
125-
return new Promise(function(resolve, reject) {
124+
isFile(file) {
125+
return new Promise((resolve, reject) => {
126126
if (file instanceof window.File) {
127127
if (file.size > 1048576) {
128128
// It's bigger than 1MB, so we assume it's a file

app/components/peer-widget.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,29 @@ export default Component.extend({
3535

3636
actions: {
3737
// TODO: rename to something more meaningful (e.g. askIfWantToSendFile)
38-
uploadFile: function(data) {
38+
uploadFile(data) {
3939
const peer = this.get('peer');
40-
const file = data.file;
40+
const { file } = data;
4141

4242
// Cache the file, so that it's available
4343
// when the response from the recipient comes in
4444
peer.set('transfer.file', file);
4545
peer.set('state', 'has_selected_file');
4646
},
4747

48-
sendFileTransferInquiry: function() {
48+
sendFileTransferInquiry() {
4949
const webrtc = this.get('webrtc');
5050
const peer = this.get('peer');
5151

5252
webrtc.connect(peer.get('peer.id'));
5353
peer.set('state', 'establishing_connection');
5454
},
5555

56-
cancelFileTransfer: function() {
56+
cancelFileTransfer() {
5757
this._cancelFileTransfer();
5858
},
5959

60-
abortFileTransfer: function() {
60+
abortFileTransfer() {
6161
this._cancelFileTransfer();
6262

6363
const webrtc = this.get('webrtc');
@@ -66,18 +66,18 @@ export default Component.extend({
6666
webrtc.sendCancelRequest(connection);
6767
},
6868

69-
acceptFileTransfer: function() {
69+
acceptFileTransfer() {
7070
const peer = this.get('peer');
7171

7272
this._sendFileTransferResponse(true);
7373

74-
peer.get('peer.connection').on('receiving_progress', function(progress) {
74+
peer.get('peer.connection').on('receiving_progress', (progress) => {
7575
peer.set('transfer.receivingProgress', progress);
7676
});
7777
peer.set('state', 'sending_file_data');
7878
},
7979

80-
rejectFileTransfer: function() {
80+
rejectFileTransfer() {
8181
const peer = this.get('peer');
8282

8383
this._sendFileTransferResponse(false);
@@ -86,7 +86,7 @@ export default Component.extend({
8686
},
8787
},
8888

89-
_cancelFileTransfer: function() {
89+
_cancelFileTransfer() {
9090
const peer = this.get('peer');
9191

9292
peer.setProperties({
@@ -95,7 +95,7 @@ export default Component.extend({
9595
});
9696
},
9797

98-
_sendFileTransferResponse: function(response) {
98+
_sendFileTransferResponse(response) {
9999
const webrtc = this.get('webrtc');
100100
const peer = this.get('peer');
101101
const connection = peer.get('peer.connection');
@@ -106,7 +106,7 @@ export default Component.extend({
106106
errorTemplateName: computed('peer.errorCode', function() {
107107
const errorCode = this.get('peer.errorCode');
108108

109-
return errorCode ? 'errors/popovers/' + errorCode : null;
109+
return errorCode ? `errors/popovers/${errorCode}` : null;
110110
}),
111111

112112
label: computed(
@@ -115,9 +115,8 @@ export default Component.extend({
115115
function() {
116116
if (this.get('hasCustomRoomName')) {
117117
return this.get('peer.labelWithPublicIp');
118-
} else {
119-
return this.get('peer.label');
120118
}
119+
return this.get('peer.label');
121120
}
122121
),
123122
});

app/components/popover-confirm.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ export default Component.extend({
1414
const extension = match && match[1];
1515

1616
if (extension) {
17-
return 'glyphicon-' + extension.toLowerCase();
17+
return `glyphicon-${extension.toLowerCase()}`;
1818
}
1919
}
20+
21+
return undefined;
2022
}),
2123

2224
actions: {
23-
confirm: function() {
25+
confirm() {
2426
this.onConfirm();
2527
},
2628

27-
cancel: function() {
29+
cancel() {
2830
this.onCancel();
2931
},
3032
},

app/components/progress-bar.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default Component.extend({
1111

1212
transfer: null,
1313

14-
didInsertElement: function() {
14+
didInsertElement() {
1515
this.set('path', this.$().find('path'));
1616
},
1717

@@ -34,7 +34,7 @@ export default Component.extend({
3434
}
3535
),
3636

37-
_calculateSVGAnim: function(progress) {
37+
_calculateSVGAnim(progress) {
3838
const path = this.get('path');
3939
if (!path) {
4040
return;
@@ -46,7 +46,7 @@ export default Component.extend({
4646
const mid = α > 180 ? 1 : 0;
4747
const x = Math.sin(r) * 38;
4848
const y = Math.cos(r) * -38;
49-
const anim = 'M 0 0 v -38 A 38 38 1 ' + mid + ' 1 ' + x + ' ' + y + ' z';
49+
const anim = `M 0 0 v -38 A 38 38 1 ${mid} 1 ${x} ${y} z`;
5050

5151
path.attr('d', anim);
5252
},

app/components/room-url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default TextField.extend({
99
.select();
1010
},
1111

12-
copyValueToClipboard: function() {
12+
copyValueToClipboard() {
1313
if (window.ClipboardEvent) {
1414
const pasteEvent = new window.ClipboardEvent('paste', {
1515
dataType: 'text/plain',

app/controllers/application.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import $ from 'jquery';
44
import User from '../models/user';
55

66
export default Controller.extend({
7-
init: function() {
7+
init() {
88
this._super();
99

1010
const id = window.ShareDrop.userId;
@@ -20,9 +20,9 @@ export default Controller.extend({
2020
},
2121

2222
actions: {
23-
redirect: function() {
23+
redirect() {
2424
const uuid = $.uuid();
25-
const key = 'show-instructions-for-room-' + uuid;
25+
const key = `show-instructions-for-room-${uuid}`;
2626

2727
sessionStorage.setItem(key, 'yup');
2828
this.transitionToRoute('room', uuid);

0 commit comments

Comments
 (0)