Add ESLint (#941)

* Add eslint, switch to lint-staged for precommit

* Fix all ESLint errors

* Update GH workflow to check prettier and eslint
This commit is contained in:
Madeline
2023-01-20 18:10:47 +11:00
committed by GitHub
parent 0c815fde91
commit 084dc0be08
157 changed files with 1905 additions and 668 deletions
+5 -5
View File
@@ -41,7 +41,7 @@ router.post(
throw new HTTPError("Invalid request signature");
if (!req.file) throw new HTTPError("file missing");
const { buffer, mimetype, size, originalname, fieldname } = req.file;
const { buffer, mimetype, size, originalname } = req.file;
const { channel_id } = req.params;
const filename = originalname
.replaceAll(" ", "_")
@@ -53,8 +53,8 @@ router.post(
Config.get()?.cdn.endpointPublic || "http://localhost:3003";
await storage.set(path, buffer);
var width;
var height;
let width;
let height;
if (mimetype.includes("image")) {
const dimensions = imageSize(buffer);
if (dimensions) {
@@ -81,10 +81,10 @@ router.get(
"/:channel_id/:id/:filename",
async (req: Request, res: Response) => {
const { channel_id, id, filename } = req.params;
const { format } = req.query;
// const { format } = req.query;
const path = `attachments/${channel_id}/${id}/${filename}`;
let file = await storage.get(path);
const file = await storage.get(path);
if (!file) throw new HTTPError("File not found");
const type = await FileType.fromBuffer(file);
let content_type = type?.mime || "application/octet-stream";
+5 -4
View File
@@ -48,10 +48,10 @@ router.post(
if (req.headers.signature !== Config.get().security.requestSignature)
throw new HTTPError("Invalid request signature");
if (!req.file) throw new HTTPError("Missing file");
const { buffer, mimetype, size, originalname, fieldname } = req.file;
const { buffer, size } = req.file;
const { user_id } = req.params;
var hash = crypto
let hash = crypto
.createHash("md5")
.update(Snowflake.generate())
.digest("hex");
@@ -77,7 +77,7 @@ router.post(
);
router.get("/:user_id", async (req: Request, res: Response) => {
var { user_id } = req.params;
let { user_id } = req.params;
user_id = user_id.split(".")[0]; // remove .file extension
const path = `avatars/${user_id}`;
@@ -92,7 +92,8 @@ router.get("/:user_id", async (req: Request, res: Response) => {
});
export const getAvatar = async (req: Request, res: Response) => {
var { user_id, hash } = req.params;
const { user_id } = req.params;
let { hash } = req.params;
hash = hash.split(".")[0]; // remove .file extension
const path = `avatars/${user_id}/${hash}`;
+5 -3
View File
@@ -45,7 +45,7 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => {
if (req.headers.signature !== Config.get().security.requestSignature)
throw new HTTPError("Invalid request signature");
if (!req.file) throw new HTTPError("Missing file");
const { buffer, mimetype, size, originalname, fieldname } = req.file;
const { buffer, size } = req.file;
const { guild_id, user_id } = req.params;
let hash = crypto
@@ -72,7 +72,8 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => {
});
router.get("/", async (req: Request, res: Response) => {
let { guild_id, user_id } = req.params;
const { guild_id } = req.params;
let { user_id } = req.params;
user_id = user_id.split(".")[0]; // remove .file extension
const path = `guilds/${guild_id}/users/${user_id}/avatars`;
@@ -87,7 +88,8 @@ router.get("/", async (req: Request, res: Response) => {
});
router.get("/:hash", async (req: Request, res: Response) => {
let { guild_id, user_id, hash } = req.params;
const { guild_id, user_id } = req.params;
let { hash } = req.params;
hash = hash.split(".")[0]; // remove .file extension
const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`;
+4 -4
View File
@@ -48,10 +48,10 @@ router.post(
if (req.headers.signature !== Config.get().security.requestSignature)
throw new HTTPError("Invalid request signature");
if (!req.file) throw new HTTPError("Missing file");
const { buffer, mimetype, size, originalname, fieldname } = req.file;
const { buffer, size } = req.file;
const { role_id } = req.params;
var hash = crypto
const hash = crypto
.createHash("md5")
.update(Snowflake.generate())
.digest("hex");
@@ -76,7 +76,7 @@ router.post(
);
router.get("/:role_id", async (req: Request, res: Response) => {
var { role_id } = req.params;
const { role_id } = req.params;
//role_id = role_id.split(".")[0]; // remove .file extension
const path = `role-icons/${role_id}`;
@@ -91,7 +91,7 @@ router.get("/:role_id", async (req: Request, res: Response) => {
});
router.get("/:role_id/:hash", async (req: Request, res: Response) => {
var { role_id, hash } = req.params;
const { role_id, hash } = req.params;
//hash = hash.split(".")[0]; // remove .file extension
const path = `role-icons/${role_id}/${hash}`;