Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Run lint-staged for backend
cd backend && npx lint-staged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a big question about using Husky. I don’t think it’s necessary, and I’m worried it will actually make our work more complicated. It’s much more convenient to make intermediate commits without thinking about the linter every time, and then run one general check before pushing. So I suggest we remove .husky/pre-commit.

7 changes: 7 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Run type checking before push
# TODO: Re-enable tests after Vitest setup is complete
cd backend && npm run type-check
# cd backend && npm run type-check && npm test
10 changes: 10 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"default": true,
"MD013": {
"line_length": 100,
"code_blocks": false,
"tables": false
},
"MD033": false,
"MD041": false
}
22 changes: 22 additions & 0 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# EditorConfig helps maintain consistent coding styles across different editors and IDEs
# https://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,ts,tsx,json,yml,yaml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
max_line_length = 100

[*.{sh,bash}]
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions backend/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{json,md}": ["prettier --write"],
"*.md": ["markdownlint-cli2 --fix"]
}
10 changes: 10 additions & 0 deletions backend/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"default": true,
"MD013": {
"line_length": 100,
"code_blocks": false,
"tables": false
},
"MD033": false,
"MD041": false
}
7 changes: 7 additions & 0 deletions backend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
dist
coverage
*.log
.env
.env.local
package-lock.json
20 changes: 20 additions & 0 deletions backend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf",
"bracketSpacing": true,
"overrides": [
{
"files": "*.md",
"options": {
"printWidth": 100,
"proseWrap": "always"
}
}
]
}
3 changes: 2 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# KeyCV Backend

This repository contains the backend service for the KeyCV application, built with Node.js, Express, and TypeScript.
This repository contains the backend service for the KeyCV application, built with Node.js, Express,
and TypeScript.

## Tech Stack

Expand Down
82 changes: 82 additions & 0 deletions backend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import js from "@eslint/js";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import prettierConfig from "eslint-config-prettier";

export default [
js.configs.recommended,
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
},
globals: {
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
NodeJS: "readonly",
},
},
plugins: {
"@typescript-eslint": tsPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,

// TypeScript specific rules
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],

// General rules
"no-console": "off", // Allow console in Node.js backend
"no-unused-vars": "off", // Use TS version instead

// Code quality
"prefer-const": "error",
"no-var": "error",
eqeqeq: ["error", "always"],
curly: ["error", "all"],
},
},
{
files: ["**/*.test.ts", "**/*.spec.ts"],
languageOptions: {
globals: {
describe: "readonly",
it: "readonly",
expect: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
vi: "readonly",
},
},
rules: {
"@typescript-eslint/no-explicit-any": "off", // Allow any in tests
},
},
prettierConfig, // Must be last to override other configs
{
ignores: [
"node_modules/**",
"dist/**",
"coverage/**",
"*.js", // Ignore JS files in root (like this config)
],
},
];
Loading