Skip to content

Commit

Permalink
chore: improve code quality setup
Browse files Browse the repository at this point in the history
- Configure Prettier and ESLint
- Add best practices rules
- Implement import organization
- Create .vscode/extension.json and settings.json
- Add checkfile plugin
  • Loading branch information
sanjaysah101 committed Sep 22, 2024
1 parent c64af28 commit 958f1cd
Show file tree
Hide file tree
Showing 100 changed files with 493 additions and 217 deletions.
6 changes: 5 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"printWidth": 120,
"semi": true,
"tabWidth": 2,
"trailingComma": "es5"
"trailingComma": "es5",
"importOrder": ["<THIRD_PARTY_MODULES>", "^@/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint",
"orta.vscode-jest",
"firsttris.vscode-jest-runner",
"esbenp.prettier-vscode",
"yoavbls.pretty-ts-errors"
]
}
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"cSpell.words": ["maxlength", "Parens", "pino"]
"cSpell.words": ["maxlength", "Parens", "pino"],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "always",
"source.organizeImports": "always"
},
"typescript.tsdk": "node_modules\\typescript\\lib"
}
27 changes: 24 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import checkFile from "eslint-plugin-check-file";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -22,6 +23,7 @@ export default [
{
plugins: {
"@typescript-eslint": typescriptEslint,
"check-file": checkFile,
},
languageOptions: {
globals: {
Expand All @@ -40,6 +42,25 @@ export default [
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/strict-boolean-expressions": "error",
"no-console": "error",
"prefer-template": ["error"],
"prefer-arrow-callback": ["error"],
"func-style": ["error", "expression"],
"prefer-destructuring": ["error", { object: true, array: true }],
"check-file/filename-naming-convention": [
"error",
{
"**/*.{ts,tsx}": "KEBAB_CASE",
},
{
ignoreMiddleExtensions: true,
},
],
"check-file/folder-naming-convention": [
"error",
{
"src/**/!^[.*": "KEBAB_CASE",
},
],
},
},
];
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
Expand All @@ -54,6 +55,7 @@
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"eslint": "^9.9.0",
"eslint-plugin-check-file": "^2.8.0",
"globals": "^15.9.0",
"husky": "^9.1.4",
"jest": "^29.7.0",
Expand Down
126 changes: 126 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/api/v1/auth/__test__/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { sign } from "jsonwebtoken";
import { envConstants, errorMap, ErrorTypeEnum, STATUS_CODES } from "@/constants";
import { ZodError, ZodIssue } from "zod";

import { Login, loginSchema } from "@/api/v1/auth/auth.validation";
import { ErrorTypeEnum, STATUS_CODES, envConstants, errorMap } from "@/constants";
import {
expectSignUpSuccess,
expectUnauthorizedResponseForInvalidToken,
login,
renewToken,
signUp,
} from "@/utils/test";
import { Login, loginSchema } from "@/api/v1/auth/auth.validation";
import { ZodError, ZodIssue } from "zod";

const VALID_CREDENTIALS = {
username: "validUser",
Expand Down
Loading

0 comments on commit 958f1cd

Please sign in to comment.