diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..8ee7638 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,29 @@ +name: Backend + +on: [push, pull_request] + +permissions: read-all + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "18" + + - name: Install dependencies + run: yarn install + working-directory: backend + + - name: Check formatting + run: yarn format:check + working-directory: backend + + - name: Lint + run: yarn lint + working-directory: backend diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index 28c1f76..929c9be 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -1,63 +1,60 @@ -module.exports = { - root: true, - - env: { - es6: true, - node: true, - }, - plugins: ["import", "simple-import-sort", "unused-imports"], - extends: ["eslint:recommended"], - parserOptions: { - ecmaVersion: 2020, - sourceType: "module", - }, - rules: { - "prettier/prettier": [ - "error", - { - semi: false, - singleQuote: true, - printWidth: 120, - }, - ], - "import/no-unused-modules": ["error", { unusedExports: true }], - "object-shorthand": ["error", "always"], - "unused-imports/no-unused-imports": "error", - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", - }, - overrides: [ - { - files: ["*.ts"], - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint/eslint-plugin"], - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/typescript", - ], - settings: { - "import/parsers": { - "@typescript-eslint/parser": [".ts"], - }, - "import/resolver": { - typescript: { - alwaysTryTypes: true, - }, - }, - }, - rules: { - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/ban-ts-ignore": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-restricted-imports": ["error"], - }, - }, - { - files: ["*"], - plugins: ["prettier"], - extends: ["plugin:prettier/recommended"], - }, - ], -}; +module.exports = { + root: true, + + env: { + es6: true, + node: true, + }, + plugins: ['import', 'simple-import-sort', 'unused-imports'], + extends: ['eslint:recommended'], + parserOptions: { + ecmaVersion: 2020, + sourceType: 'module', + }, + rules: { + 'prettier/prettier': [ + 'error', + { + semi: false, + singleQuote: true, + printWidth: 120, + }, + ], + 'import/no-unused-modules': ['error', { unusedExports: true }], + 'object-shorthand': ['error', 'always'], + 'unused-imports/no-unused-imports': 'error', + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + }, + overrides: [ + { + files: ['*.ts'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint/eslint-plugin'], + extends: ['plugin:@typescript-eslint/recommended', 'plugin:import/typescript'], + settings: { + 'import/parsers': { + '@typescript-eslint/parser': ['.ts'], + }, + 'import/resolver': { + typescript: { + alwaysTryTypes: true, + }, + }, + }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-restricted-imports': ['error'], + }, + }, + { + files: ['*'], + plugins: ['prettier'], + extends: ['plugin:prettier/recommended'], + }, + ], +} diff --git a/backend/.prettierignore b/backend/.prettierignore new file mode 100644 index 0000000..8ef4bf2 --- /dev/null +++ b/backend/.prettierignore @@ -0,0 +1,6 @@ +dist/** +build/** +node_modules/** +types/** +drizzle/** +.eslintrc.js diff --git a/backend/.prettierrc b/backend/.prettierrc index a327b1e..31ba22d 100644 --- a/backend/.prettierrc +++ b/backend/.prettierrc @@ -1,5 +1,5 @@ -{ - "semi": false, - "singleQuote": true, - "printWidth": 120 -} +{ + "semi": false, + "singleQuote": true, + "printWidth": 120 +} diff --git a/backend/package.json b/backend/package.json index d047369..3d4b57e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,34 +1,36 @@ -{ - "name": "backend", - "scripts": { - "start": "tsx src/index.ts", - "typecheck": "tsc --noEmit", - "drizzle:generate": "drizzle-kit generate", - "prepare": "yarn drizzle:generate", - "lint": "eslint . --max-warnings=0", - "fix": "eslint . --fix" - }, - "dependencies": { - "dotenv": "^16.4.5", - "drizzle-orm": "^0.33.0", - "fastify": "^4.28.1", - "fastify-plugin": "^4.5.1", - "postgres": "^3.4.4" - }, - "devDependencies": { - "@types/node": "^22.5.3", - "@typescript-eslint/eslint-plugin": "^7.9.0", - "@typescript-eslint/parser": "^8.4.0", - "drizzle-kit": "^0.24.2", - "eslint": "^8.0.0", - "eslint-config-prettier": "^9.1.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-simple-import-sort": "^12.1.0", - "eslint-plugin-unused-imports": "^3.2.0", - "prettier": "^3.2.5", - "tsx": "^4.19.0", - "typescript": "^5.5.4" - } -} +{ + "name": "backend", + "scripts": { + "start": "tsx src/index.ts", + "typecheck": "tsc --noEmit", + "drizzle:generate": "drizzle-kit generate", + "prepare": "yarn drizzle:generate", + "format": "prettier --write .", + "format:check": "prettier --check .", + "lint": "eslint . --max-warnings=0", + "fix": "eslint . --fix" + }, + "dependencies": { + "dotenv": "^16.4.5", + "drizzle-orm": "^0.33.0", + "fastify": "^4.28.1", + "fastify-plugin": "^4.5.1", + "postgres": "^3.4.4" + }, + "devDependencies": { + "@types/node": "^22.5.3", + "@typescript-eslint/eslint-plugin": "^7.9.0", + "@typescript-eslint/parser": "^8.4.0", + "drizzle-kit": "^0.24.2", + "eslint": "^8.0.0", + "eslint-config-prettier": "^9.1.0", + "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-simple-import-sort": "^12.1.0", + "eslint-plugin-unused-imports": "^3.2.0", + "prettier": "^3.2.5", + "tsx": "^4.19.0", + "typescript": "^5.5.4" + } +} diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 8ae7f71..5f1468d 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -1,23 +1,23 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "esnext", - "target": "esnext", - "moduleResolution": "bundler", - "moduleDetection": "force", - "allowImportingTsExtensions": true, - "noEmit": true, - "composite": true, - "strict": true, - "downlevelIteration": true, - "skipLibCheck": true, - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "allowJs": true, - "baseUrl": ".", - "paths": { - "@/*": ["./src/*"] - }, - "types": [] - } -} +{ + "compilerOptions": { + "lib": ["ESNext"], + "module": "esnext", + "target": "esnext", + "moduleResolution": "bundler", + "moduleDetection": "force", + "allowImportingTsExtensions": true, + "noEmit": true, + "composite": true, + "strict": true, + "downlevelIteration": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "allowJs": true, + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + }, + "types": [] + } +}