Skip to content

Commit a37f99c

Browse files
committed
Fix prettier errors
1 parent ed5e4ad commit a37f99c

File tree

9 files changed

+116
-104
lines changed

9 files changed

+116
-104
lines changed

.eslintrc.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,29 @@ module.exports = {
88
'plugin:react/recommended',
99
'plugin:react-hooks/recommended',
1010
'standard',
11-
'prettier'
11+
'prettier',
1212
],
1313
parserOptions: {
1414
ecmaFeatures: {
15-
jsx: true
15+
jsx: true,
1616
},
1717
ecmaVersion: 12,
18-
sourceType: 'module'
18+
sourceType: 'module',
1919
},
20-
plugins: [
21-
'react',
22-
'react-hooks'
23-
],
20+
plugins: ['react', 'react-hooks'],
2421
rules: {
2522
'react/prop-types': 'off',
2623
'no-unused-vars': 'off',
27-
'react/no-children-prop': 'off'
24+
'react/no-children-prop': 'off',
2825
},
2926
settings: {
3027
react: {
3128
version: 'detect',
32-
}
29+
},
3330
},
3431
overrides: [
3532
{
36-
files: [
37-
'**/*.test.js',
38-
'**/*.test.jsx'
39-
]
40-
}
41-
]
42-
}
33+
files: ['**/*.test.js', '**/*.test.jsx'],
34+
},
35+
],
36+
};

.github/workflows/node.js.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ name: Node.js CI
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [master]
99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
strategy:
@@ -20,13 +19,13 @@ jobs:
2019
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2120

2221
steps:
23-
- uses: actions/checkout@v2
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v2
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
- run: npm ci
29-
- run: npm run build --if-present
30-
- run: npm run lint
31-
- run: npm run prettier-check
32-
- run: npm test
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npm run build --if-present
29+
- run: npm run lint
30+
- run: npm run prettier-check
31+
- run: npm test

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"trailingComma": "es5",
44
"singleQuote": true,
55
"semi": true,
6-
"endOfLine": "lf",
6+
"endOfLine": "lf"
77
}

.vscode/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{
2-
}
1+
{}

jsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"compilerOptions": {
33
"baseUrl": "src"
44
}
5-
}
5+
}

src/components/RoomBox/index.js

+27-18
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ function RoomBox(props) {
4343
setShowViewOnly(true);
4444
}
4545
// Populate bubbles data, but don't add client's bubble
46-
setBubblesData(produce(data.members, draft => {
47-
delete draft[clientUsername];
48-
}));
46+
setBubblesData(
47+
produce(data.members, draft => {
48+
delete draft[clientUsername];
49+
})
50+
);
4951
// todo: set video position to current time - data.songStartTime
5052
} else if (status === 'failed') {
5153
toast({
@@ -63,9 +65,12 @@ function RoomBox(props) {
6365
if (clientUsername === username) return;
6466

6567
// TODO: find a better way to update this
66-
setBubblesData(data => produce(data, draft => {
67-
if (draft?.[username]?.position) draft[username].position = newPosition;
68-
}));
68+
setBubblesData(data =>
69+
produce(data, draft => {
70+
if (draft?.[username]?.position)
71+
draft[username].position = newPosition;
72+
})
73+
);
6974
};
7075

7176
const handleJoin = (user, position) => {
@@ -78,15 +83,17 @@ function RoomBox(props) {
7883
isClosable: true,
7984
duration: 3000,
8085
});
81-
setBubblesData(data => produce(data, draft => {
82-
draft[username] = {
83-
profilePicture: profilePicture,
84-
prefix: '',
85-
username: username,
86-
type: 'other',
87-
position: position,
88-
};
89-
}));
86+
setBubblesData(data =>
87+
produce(data, draft => {
88+
draft[username] = {
89+
profilePicture: profilePicture,
90+
prefix: '',
91+
username: username,
92+
type: 'other',
93+
position: position,
94+
};
95+
})
96+
);
9097
};
9198

9299
const handleLeave = username => {
@@ -98,9 +105,11 @@ function RoomBox(props) {
98105
isClosable: true,
99106
duration: 3000,
100107
});
101-
setBubblesData(data => produce(data, draft => {
102-
delete draft[username];
103-
}));
108+
setBubblesData(data =>
109+
produce(data, draft => {
110+
delete draft[username];
111+
})
112+
);
104113
};
105114

106115
const handleTransferHost = username => {

src/components/YoutubePlayer/index.js

+60-49
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
playSong,
99
endSong,
1010
stopSong,
11-
youtubeAPIReady
11+
youtubeAPIReady,
1212
} from 'slices/youtubeSlice';
1313
import { ClientPositionContext } from 'contexts/clientposition';
1414
import { Box } from '@chakra-ui/react';
@@ -88,53 +88,64 @@ function YoutubePlayer(props) {
8888
const player = useRef(null);
8989
const boundingBox = useRef(baseBoundingBox);
9090
const song = useSelector(state => state.currentRoom.data.currentSong);
91-
const isYouTubeAPIReady = useSelector(state => state.youtube.isYouTubeAPIReady)
92-
93-
const onError = useCallback(event => {
94-
const { data } = event;
95-
96-
dispatch(reportError(data));
97-
}, [dispatch])
98-
99-
const onPlayerStateChange = useCallback(event => {
100-
const { data } = event;
101-
102-
switch (data) {
103-
case -1:
104-
dispatch(clearError());
105-
break;
106-
case 0:
107-
dispatch(endSong());
108-
dispatch(clearError());
109-
break;
110-
case 1:
111-
dispatch(playSong());
112-
break;
113-
case 2:
114-
dispatch(clearError());
115-
break;
116-
case 3:
117-
dispatch(clearError());
118-
break;
119-
case 5:
120-
dispatch(clearError());
121-
break;
122-
default:
123-
break;
124-
}
125-
}, [dispatch])
91+
const isYouTubeAPIReady = useSelector(
92+
state => state.youtube.isYouTubeAPIReady
93+
);
12694

127-
const onPlayerReady = useCallback(event => {
128-
event.target.playVideo();
95+
const onError = useCallback(
96+
event => {
97+
const { data } = event;
12998

130-
if (!isAuth) {
131-
// Set player volume for non authed users,
132-
// because they can't control volume by moving bubble
133-
dispatch(changeVolume(50));
134-
}
99+
dispatch(reportError(data));
100+
},
101+
[dispatch]
102+
);
103+
104+
const onPlayerStateChange = useCallback(
105+
event => {
106+
const { data } = event;
107+
108+
switch (data) {
109+
case -1:
110+
dispatch(clearError());
111+
break;
112+
case 0:
113+
dispatch(endSong());
114+
dispatch(clearError());
115+
break;
116+
case 1:
117+
dispatch(playSong());
118+
break;
119+
case 2:
120+
dispatch(clearError());
121+
break;
122+
case 3:
123+
dispatch(clearError());
124+
break;
125+
case 5:
126+
dispatch(clearError());
127+
break;
128+
default:
129+
break;
130+
}
131+
},
132+
[dispatch]
133+
);
135134

136-
boundingBox.current = event.target.getIframe().getBoundingClientRect();
137-
}, [dispatch, isAuth])
135+
const onPlayerReady = useCallback(
136+
event => {
137+
event.target.playVideo();
138+
139+
if (!isAuth) {
140+
// Set player volume for non authed users,
141+
// because they can't control volume by moving bubble
142+
dispatch(changeVolume(50));
143+
}
144+
145+
boundingBox.current = event.target.getIframe().getBoundingClientRect();
146+
},
147+
[dispatch, isAuth]
148+
);
138149

139150
const createPlayer = useCallback(() => {
140151
player.current = new window.YT.Player('youtube-player', {
@@ -156,7 +167,7 @@ function YoutubePlayer(props) {
156167
onError: onError,
157168
},
158169
});
159-
}, [height, width, song, onPlayerReady, onPlayerStateChange, onError])
170+
}, [height, width, song, onPlayerReady, onPlayerStateChange, onError]);
160171

161172
function updateSong(song) {
162173
if (song?.videoId == null) {
@@ -176,13 +187,13 @@ function YoutubePlayer(props) {
176187
useEffect(() => {
177188
// callback for youtube iframe api
178189
window.onYouTubeIframeAPIReady = () => {
179-
dispatch(youtubeAPIReady())
180-
}
190+
dispatch(youtubeAPIReady());
191+
};
181192

182193
// if youtube iframe api was loaded before
183194
if (isYouTubeAPIReady) {
184195
if (!song) {
185-
return
196+
return;
186197
}
187198

188199
// create a youtube player if there isn't already one

src/slices/currentRoomSlice.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const currentRoomSlice = createSlice({
8181
state.data.host = host;
8282
state.data.numMembers = numMembers;
8383
// Convert members from object to array
84-
state.data.members = members;
84+
state.data.members = members;
8585
state.data.currentSong = currentSong;
8686
state.status = 'success';
8787
state.isGuest = payload.guest;

src/slices/youtubeSlice.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const initialState = {
55
videoId: null,
66
status: 'unstarted',
77
errorCode: null,
8-
isYouTubeAPIReady: false
8+
isYouTubeAPIReady: false,
99
};
1010

1111
// This is for storing youtube player data
@@ -50,7 +50,7 @@ export const youtubeSlice = createSlice({
5050
},
5151
youtubeAPIReady: state => {
5252
state.isYouTubeAPIReady = true;
53-
}
53+
},
5454
},
5555
});
5656

@@ -64,7 +64,7 @@ export const {
6464
reportError,
6565
clearError,
6666
reset,
67-
youtubeAPIReady
67+
youtubeAPIReady,
6868
} = youtubeSlice.actions;
6969

7070
export default youtubeSlice.reducer;

0 commit comments

Comments
 (0)