Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into Feature/#080_panda_css_라이브러리_설정

# Conflicts:
#	client/eslint.config.js
  • Loading branch information
pipisebastian committed Nov 11, 2024
2 parents 7ac9bba + 318e649 commit 967cb61
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 107 deletions.
6 changes: 1 addition & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
## 📋 개요

- 이번 PR에서 해결하려는 문제 또는 구현한 기능에 대한 간단한 설명을 작성합니다.

## 📝 변경 사항 요약
## 📝 변경 사항

- 변경된 주요 사항을 bullet point로 정리하여 작성합니다.

Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/auto_merge_approved_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Auto Merge Approved PRs"

on:
pull_request_review:
types: [submitted]

jobs:
auto_merge:
runs-on: ubuntu-latest
steps:
- name: "Get Pull Request"
id: pr
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
return JSON.stringify(pr);
- name: "Check Approvals"
id: check
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = JSON.parse(steps.pr.outputs.result);
const reviews = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
});
const approvals = reviews.data.filter(review => review.state === 'APPROVED');
core.setOutput('result', approvals.length >= 2);
- name: "Merge PR"
if: steps.check.outputs.result
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
steps:
# 1. 레포지토리 클론
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# 2. Docker Compose로 서비스 빌드 및 재시작
- name: Set up Docker
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build and Deploy Docker Images
run: |
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint and Test

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
lint_and_test:
name: Lint and Test
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

# Install pnpm
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: true

# Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"

# Run lint
- name: Run lint
run: pnpm eslint .

# Run tests
- name: Run tests
run: pnpm test
22 changes: 7 additions & 15 deletions client/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ export default [
navigator: true,
},
},
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: "./tsconfig.json",
},
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/internal-regex": "^@/",
},
rules: {
// Airbnb React 규칙
"react/boolean-prop-naming": ["error", { rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+" }],
Expand Down Expand Up @@ -131,6 +116,13 @@ export default [
react: {
version: "detect",
},
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/internal-regex": "^@/",
},
];
103 changes: 51 additions & 52 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
import prettierPlugin from 'eslint-plugin-prettier';
import importPlugin from 'eslint-plugin-import';
import js from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
import prettierPlugin from "eslint-plugin-prettier";
import importPlugin from "eslint-plugin-import";

const airbnbRules = {
// Airbnb 스타일 가이드의 핵심 규칙들
'no-var': 'error',
'prefer-const': 'error',
'prefer-template': 'error',
'no-param-reassign': 'error',
'object-shorthand': 'error',
'prefer-destructuring': ['error', { array: true, object: true }],
'no-array-constructor': 'error',
'func-style': ['error', 'expression'],
'arrow-parens': ['error', 'always'],
'arrow-body-style': ['warn', 'as-needed'],
'no-duplicate-imports': 'error',
'one-var': ['error', 'never'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'spaced-comment': ['error', 'always'],
'no-underscore-dangle': 'off',
'max-len': ['warn', { code: 100, ignoreComments: true }],
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error",
"no-param-reassign": "error",
"object-shorthand": "error",
"prefer-destructuring": ["error", { array: true, object: true }],
"no-array-constructor": "error",
"func-style": ["error", "expression"],
"arrow-parens": ["error", "always"],
"arrow-body-style": ["warn", "as-needed"],
"no-duplicate-imports": "error",
"one-var": ["error", "never"],
"no-plusplus": ["error", { allowForLoopAfterthoughts: true }],
"spaced-comment": ["error", "always"],
"no-underscore-dangle": "off",
"max-len": ["warn", { code: 100, ignoreComments: true }],

// Import 규칙
'import/prefer-default-export': 'off',
'import/no-default-export': 'off',
'import/extensions': 'off',
'import/no-extraneous-dependencies': 'off',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
"import/prefer-default-export": "off",
"import/no-default-export": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
};

/** @type {import('eslint').Linter.FlatConfig[]} */
const config = [
js.configs.recommended,
// 공통 설정
{
files: ['**/*.{ts,tsx,js,jsx}'],
files: ["**/*.{ts,tsx,js,jsx}"],
plugins: {
'@typescript-eslint': tseslint,
"@typescript-eslint": tseslint,
prettier: prettierPlugin,
import: importPlugin,
},
languageOptions: {
parser: tsparser,
ecmaVersion: 2022,
sourceType: 'module',
sourceType: "module",
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand All @@ -60,46 +60,45 @@ const config = [

// TypeScript
...tseslint.configs.recommended.rules,
'@typescript-eslint/no-unused-vars': [
'warn',
"@typescript-eslint/no-unused-vars": [
"warn",
{
varsIgnorePattern:
'^(js|Injectable|Controller|Get|Post|Put|Delete|Patch|Options|Head|All)$',
argsIgnorePattern: '^_',
"^(js|Injectable|Controller|Get|Post|Put|Delete|Patch|Options|Head|All)$",
argsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "warn",

// Prettier
...prettierPlugin.configs.recommended.rules,

// 개발 초기 단계를 위한 규칙 완화
'no-console': 'off',
'no-unused-vars': 'off', // TypeScript rule을 대신 사용
'no-undef': 'off', // TypeScript에서 처리
"no-console": "off",
"no-unused-vars": "off", // TypeScript rule을 대신 사용
"no-undef": "off", // TypeScript에서 처리
},
},
{
ignores: [
'node_modules/',
'dist/',
'build/',
'coverage/',
'*.config.js',
'src/**/*.test.js',
'public/*',
'server/dist/'
"**/node_modules/",
"**/dist/",
"**/build/",
"**/coverage/",
"**/*.config.js",
"**/src/**/*.test.js",
"**/public/*",
],
},
// 설정 파일에 대한 특별 규칙
{
files: ['**/eslint.config.js', '**/prettier.config.js', '**/vite.config.ts'],
files: ["**/eslint.config.js", "**/prettier.config.js", "**/vite.config.ts"],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'import/no-unused-modules': 'off',
"@typescript-eslint/no-unused-vars": "off",
"import/no-unused-modules": "off",
},
},
];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "pnpm --filter server test",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"lint": "eslint . --fix",
"lint:client": "eslint \"client/src/**/*.{ts,tsx}\" --fix",
Expand Down
20 changes: 10 additions & 10 deletions server/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import rootConfig from '../eslint.config.js';
import { fileURLToPath } from "url";
import { dirname, resolve } from "path";
import rootConfig from "../eslint.config.js";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand All @@ -10,10 +10,10 @@ export default [
...rootConfig,

{
files: ['src/**/*.ts', 'test/**/*.ts'],
files: ["src/**/*.ts", "test/**/*.ts"],
languageOptions: {
parserOptions: {
project: resolve(__dirname, './tsconfig.json'),
project: resolve(__dirname, "./tsconfig.json"),
},
globals: {
// Test globals
Expand All @@ -34,11 +34,11 @@ export default [
},
},
rules: {
'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
"no-console": ["warn", { allow: ["warn", "error", "info"] }],
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "warn",
},
},
];
15 changes: 15 additions & 0 deletions server/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Config } from "jest";

const config: Config = {
moduleFileExtensions: ["js", "json", "ts"],
rootDir: ".",
testRegex: ".*\\.spec\\.ts$",
transform: {
"^.+\\.(t|j)s$": "ts-jest",
},
collectCoverageFrom: ["**/*.(t|j)s"],
coverageDirectory: "./coverage",
testEnvironment: "node",
};

export default config;
12 changes: 6 additions & 6 deletions server/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Test, TestingModule } from "@nestjs/testing";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";

describe('AppController', () => {
describe("AppController", () => {
let appController: AppController;

beforeEach(async () => {
Expand All @@ -14,9 +14,9 @@ describe('AppController', () => {
appController = app.get<AppController>(AppController);
});

describe('root', () => {
describe("root", () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
expect(appController.getHello()).toBe("Hello World!");
});
});
});
Loading

0 comments on commit 967cb61

Please sign in to comment.