Skip to content

Commit

Permalink
added backend linting
Browse files Browse the repository at this point in the history
  • Loading branch information
parkrafael committed Nov 26, 2024
1 parent b23c57b commit ada1ac3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 39 deletions.
45 changes: 13 additions & 32 deletions backend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
import js from '@eslint/js'
import jest from 'eslint-plugin-jest'
import globals from 'globals'
import globals from "globals";
import pluginJs from "@eslint/js";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,ts}'],
languageOptions: {
ecmaVersion: 'latest',
globals: globals.node,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
...js.configs.recommended.rules,
},
},
{
files: ['**/__tests__/**/*.test.{js,ts}'],
plugins: {
jest,
},
languageOptions: {
globals: jest.environments.globals.globals
},
rules: {
...jest.configs.recommended.rules,
}
}
]
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
{
rules: {
camelcase: ["warn", { properties: "never", ignoreDestructuring: false }],
"max-len": ["warn", { code: 140 }],
"no-console": "warn",
},
},
];
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "babel index.js -d dist",
"dev": "nodemon server",
"lint": "eslint .",
"lint": "eslint",
"start": "node index.js",
"test": "jest"
},
Expand Down
2 changes: 0 additions & 2 deletions backend/src/middlewares/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ const auth = async (req, res, next) => {
})
req.supabase = supabase;
} else {
console.error("No token: Authentication Denied");
return res.status(401).json({ message: "No token: Authentication Denied" });
}
next();
} catch (err) {
console.error("Invalid token, authentication denied:", err.message);
return res.status(400).json({ message: `Invalid token, authentication denied: ${err.message}`});
}
};
Expand Down
8 changes: 4 additions & 4 deletions backend/src/routes/logbooks-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ router.post("/:logbookID/logs", auth, async (req, res) => {
});

router.get("/:logbookID/logs/", auth, async (req, res) => {
const logbookLogs = await getLogbookLogs(req)
const logbookLogs = await getLogbookLogs(req);
res.status(200).json({ data: logbookLogs });
})
});

router.get("/:logbookID/logs/:logID", auth, async (req, res) => {
const log = await getLog(req)
const log = await getLog(req);
res.status(200).json({ data: log });
})
});

export default router;

0 comments on commit ada1ac3

Please sign in to comment.