Browse Source

chore(linting): removed temporary fixes

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 4 years ago
parent
commit
2023fcc0c1

+ 0 - 2
frontend/.eslintrc

@@ -29,8 +29,6 @@
 		"no-control-regex": 0,
 		"no-control-regex": 0,
 		"no-var": 2,
 		"no-var": 2,
 		"no-underscore-dangle": 0,
 		"no-underscore-dangle": 0,
-		"prefer-promise-reject-errors": 0, // temp
-		"no-nested-ternary": 0, // temp
 		"radix": 0,
 		"radix": 0,
 		"no-multi-assign": 0,
 		"no-multi-assign": 0,
 		"no-shadow": 0
 		"no-shadow": 0

+ 5 - 12
frontend/api/auth.js

@@ -35,15 +35,10 @@ export default {
 									return resolve({ status: "success" });
 									return resolve({ status: "success" });
 								});
 								});
 							}
 							}
-							return reject({
-								status: "error",
-								message: "You must login"
-							});
+							return reject(new Error("You must login"));
 						}
 						}
-						return reject({
-							status: "error",
-							message: res.message
-						});
+
+						return reject(new Error(res.message));
 					}
 					}
 				);
 				);
 			});
 			});
@@ -72,10 +67,8 @@ export default {
 							return resolve({ status: "success" });
 							return resolve({ status: "success" });
 						});
 						});
 					}
 					}
-					return reject({
-						status: "error",
-						message: res.message
-					});
+
+					return reject(new Error(res.message));
 				});
 				});
 			});
 			});
 		});
 		});

+ 40 - 25
frontend/components/Modals/Playlists/Edit.vue

@@ -204,33 +204,48 @@ export default {
 	methods: {
 	methods: {
 		formatTime(length) {
 		formatTime(length) {
 			const duration = moment.duration(length, "seconds");
 			const duration = moment.duration(length, "seconds");
-			function getHours() {
+			const getHours = () => {
 				return Math.floor(duration.asHours());
 				return Math.floor(duration.asHours());
-			}
+			};
+
 			if (length <= 0) return "0 seconds";
 			if (length <= 0) return "0 seconds";
-			return (
-				(getHours() > 0
-					? getHours() > 1
-						? getHours() < 10
-							? `0${getHours()} hours `
-							: `${getHours()} hours `
-						: `0${getHours()} hour `
-					: "") +
-				(duration.minutes() > 0
-					? duration.minutes() > 1
-						? duration.minutes() < 10
-							? `0${duration.minutes()} minutes `
-							: `${duration.minutes()} minutes `
-						: `0${duration.minutes()} minute `
-					: "") +
-				(duration.seconds() > 0
-					? duration.seconds() > 1
-						? duration.seconds() < 10
-							? `0${duration.seconds()} seconds `
-							: `${duration.seconds()} seconds `
-						: `0${duration.seconds()} second `
-					: "")
-			);
+
+			const formatHours = () => {
+				if (getHours() > 0) {
+					if (getHours() > 1) {
+						if (getHours() < 10) return `0${getHours()} hours `;
+						return `${getHours()} hours `;
+					}
+					return `0${getHours()} hour `;
+				}
+				return "";
+			};
+
+			const formatMinutes = () => {
+				if (duration.minutes() > 0) {
+					if (duration.minutes() > 1) {
+						if (duration.minutes() < 10)
+							return `0${duration.minutes()} minutes `;
+						return `${duration.minutes()} minutes `;
+					}
+					return `0${duration.minutes()} minute `;
+				}
+				return "";
+			};
+
+			const formatSeconds = () => {
+				if (duration.seconds() > 0) {
+					if (duration.seconds() > 1) {
+						if (duration.seconds() < 10)
+							return `0${duration.seconds()} seconds `;
+						return `${duration.seconds()} seconds `;
+					}
+					return `0${duration.seconds()} second `;
+				}
+				return "";
+			};
+
+			return formatHours() + formatMinutes() + formatSeconds();
 		},
 		},
 		totalLength() {
 		totalLength() {
 			let length = 0;
 			let length = 0;

+ 12 - 9
frontend/components/Station/Station.vue

@@ -634,16 +634,19 @@ export default {
 			}
 			}
 		},
 		},
 		formatTime(duration) {
 		formatTime(duration) {
-			const d = moment.duration(duration, "seconds");
+			const dur = moment.duration(duration, "seconds");
 			if (duration < 0) return "0:00";
 			if (duration < 0) return "0:00";
-			return `${
-				d.hours() > 0
-					? d.hours() < 10
-						? `0${d.hours()}:`
-						: `${d.hours()}:`
-					: ""
-			}${d.minutes()}:${
-				d.seconds() < 10 ? `0${d.seconds()}` : d.seconds()
+
+			const getHours = () => {
+				if (dur.hours > 0) {
+					if (dur.hours() < 10) return `0${dur.hours()}:`;
+					return `${dur.hours()}:`;
+				}
+				return "";
+			};
+
+			return `${getHours()}${dur.minutes()}:${
+				dur.seconds() < 10 ? `0${dur.seconds()}` : dur.seconds()
 			}`;
 			}`;
 		},
 		},
 		calculateTimeElapsed() {
 		calculateTimeElapsed() {

+ 1 - 1
frontend/package.json

@@ -44,7 +44,7 @@
     "@babel/runtime": "^7.5.4",
     "@babel/runtime": "^7.5.4",
     "chart.js": "^2.5.0",
     "chart.js": "^2.5.0",
     "config": "^3.2.2",
     "config": "^3.2.2",
-    "eslint-config-airbnb-base": "13.2.0",
+    "eslint-config-airbnb-base": "^13.2.0",
     "html-webpack-plugin": "^3.2.0",
     "html-webpack-plugin": "^3.2.0",
     "vue": "^2.6.10",
     "vue": "^2.6.10",
     "vue-loader": "^15.7.0",
     "vue-loader": "^15.7.0",

+ 24 - 36
frontend/store/modules/user.js

@@ -25,54 +25,48 @@ const modules = {
 					const { username, email, password } = user;
 					const { username, email, password } = user;
 
 
 					if (!email || !username || !password)
 					if (!email || !username || !password)
-						return reject({
-							status: "error",
-							message: "Please fill in all fields"
-						});
+						return reject(new Error("Please fill in all fields"));
 
 
 					if (!validation.isLength(email, 3, 254))
 					if (!validation.isLength(email, 3, 254))
-						return reject({
-							status: "error",
-							message:
+						return reject(
+							new Error(
 								"Email must have between 3 and 254 characters."
 								"Email must have between 3 and 254 characters."
-						});
+							)
+						);
 
 
 					if (
 					if (
 						email.indexOf("@") !== email.lastIndexOf("@") ||
 						email.indexOf("@") !== email.lastIndexOf("@") ||
 						!validation.regex.emailSimple.test(email)
 						!validation.regex.emailSimple.test(email)
 					)
 					)
-						return reject({
-							status: "error",
-							message: "Invalid email format."
-						});
+						return reject(new Error("Invalid email format."));
 
 
 					if (!validation.isLength(username, 2, 32))
 					if (!validation.isLength(username, 2, 32))
-						return reject({
-							status: "error",
-							message:
+						return reject(
+							new Error(
 								"Username must have between 2 and 32 characters."
 								"Username must have between 2 and 32 characters."
-						});
+							)
+						);
 
 
 					if (!validation.regex.azAZ09_.test(username))
 					if (!validation.regex.azAZ09_.test(username))
-						return reject({
-							status: "error",
-							message:
+						return reject(
+							new Error(
 								"Invalid username format. Allowed characters: a-z, A-Z, 0-9 and _."
 								"Invalid username format. Allowed characters: a-z, A-Z, 0-9 and _."
-						});
+							)
+						);
 
 
 					if (!validation.isLength(password, 6, 200))
 					if (!validation.isLength(password, 6, 200))
-						return reject({
-							status: "error",
-							message:
+						return reject(
+							new Error(
 								"Password must have between 6 and 200 characters."
 								"Password must have between 6 and 200 characters."
-						});
+							)
+						);
 
 
 					if (!validation.regex.password.test(password))
 					if (!validation.regex.password.test(password))
-						return reject({
-							status: "error",
-							message:
+						return reject(
+							new Error(
 								"Invalid password format. Must have one lowercase letter, one uppercase letter, one number and one special character."
 								"Invalid password format. Must have one lowercase letter, one uppercase letter, one number and one special character."
-						});
+							)
+						);
 
 
 					return auth
 					return auth
 						.register(user)
 						.register(user)
@@ -83,10 +77,7 @@ const modules = {
 							});
 							});
 						})
 						})
 						.catch(err => {
 						.catch(err => {
-							return reject({
-								status: "error",
-								message: err.message
-							});
+							return reject(new Error(err.message));
 						});
 						});
 				});
 				});
 			},
 			},
@@ -101,10 +92,7 @@ const modules = {
 							});
 							});
 						})
 						})
 						.catch(err => {
 						.catch(err => {
-							return reject({
-								status: "error",
-								message: err.message
-							});
+							return reject(new Error(err.message));
 						});
 						});
 				});
 				});
 			},
 			},