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
90 changes: 90 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: PR Check

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

Update GitHub Actions to latest versions.

The workflow uses older versions of GitHub Actions. Update to the latest versions for improved features and security:

  • actions/checkout@v3 โ†’ actions/checkout@v4
  • actions/setup-node@v3 โ†’ actions/setup-node@v4
  • actions/github-script@v6 โ†’ actions/github-script@v7

Also applies to: 15-15, 40-40

๐Ÿงฐ Tools
๐Ÿช› actionlint (1.7.4)

12-12: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
id: install
run: npm ci

- name: Lint check
id: lint
continue-on-error: true
run: npm run lint:fix

- name: Format check
id: format
continue-on-error: true
run: npm run format

- name: Type check
id: typecheck
continue-on-error: true
run: npx tsc --noEmit

- name: Run tests
id: test
continue-on-error: true
run: npm run test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build check
id: build
continue-on-error: true
run: npm run build

- name: Report Status
if: always()
uses: actions/github-script@v6
with:
script: |
const steps = {
lint: '${{ steps.lint.outcome }}',
format: '${{ steps.format.outcome }}',
typecheck: '${{ steps.typecheck.outcome }}',
test: '${{ steps.test.outcome }}',
build: '${{ steps.build.outcome }}'
};

const emoji = (status) => status === 'success' ? 'โœ…' : 'โŒ';

const body = `## CI Status Report\n\n` +
`### ๊ฒ€์‚ฌ ๊ฒฐ๊ณผ\n` +
`- Lint: ${emoji(steps.lint)} ${steps.lint}\n` +
`- Format: ${emoji(steps.format)} ${steps.format}\n` +
`- Type Check: ${emoji(steps.typecheck)} ${steps.typecheck}\n` +
`- Tests: ${emoji(steps.test)} ${steps.test}\n` +
`- Build: ${emoji(steps.build)} ${steps.build}\n\n` +
`${Object.values(steps).every(s => s === 'success') ? 'โœ… ๋ชจ๋“  ๊ฒ€์‚ฌ๊ฐ€ ํ†ต๊ณผ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.' : 'โŒ ์ผ๋ถ€ ๊ฒ€์‚ฌ๊ฐ€ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.'}`;

await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: body
});

if (Object.values(steps).some(s => s === 'failure')) {
core.setFailed('Some checks failed');
}
73 changes: 73 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: PR Labeler

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, edited]

jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

Update GitHub Actions to latest versions.

Similar to pr-check.yml, update to the latest versions:

  • actions/checkout@v3 โ†’ actions/checkout@v4
  • actions/github-script@v6 โ†’ actions/github-script@v7

Also applies to: 13-13

๐Ÿงฐ Tools
๐Ÿช› actionlint (1.7.4)

10-10: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


- name: Label PR based on commit messages
uses: actions/github-script@v6
with:
script: |
try {
const { data: commits } = await github.rest.pulls.listCommits({
...context.repo,
pull_number: context.issue.number
});

const labels = new Set();
commits.forEach(commit => {
const msg = commit.commit.message;
// Using regex to match your commit convention: type(issue) message
const typeMatch = msg.match(/^(feat|fix|style|refactor|test|docs|chore|setting)\(/i);

if (typeMatch) {
const type = typeMatch[1].toLowerCase();
switch (type) {
case 'feat':
labels.add('โœจ feat');
break;
case 'fix':
labels.add('๐Ÿ› fix');
break;
case 'style':
labels.add('๐Ÿ’„ style');
break;
case 'refactor':
labels.add('โ™ป๏ธ refactor');
break;
case 'test':
labels.add('โœ… test');
break;
case 'docs':
labels.add('๐Ÿ“ docs');
break;
case 'chore':
labels.add('๐Ÿ”ง chore');
break;
case 'setting':
labels.add('โš™๏ธ setting');
break;
}
}
});

if (labels.size > 0) {
await github.rest.issues.addLabels({
...context.repo,
issue_number: context.issue.number,
labels: Array.from(labels)
});
}
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
}
5 changes: 4 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf",
"plugins": ["prettier-plugin-tailwindcss"],
"plugins": [
"prettier-plugin-tailwindcss",
"@trivago/prettier-plugin-sort-imports"
],
"importOrder": [
"^@utils/(.*)$",
"^@apis/(.*)$",
Expand Down
13 changes: 0 additions & 13 deletions __tests__/page.test.tsx

This file was deleted.

33 changes: 14 additions & 19 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ const compat = new FlatCompat({
recommendedConfig: {},
});

/** @type {import('eslint').Linter.Config[]} */
const eslintConfig = [
{
ignores: ['node_modules/', 'dist/', 'public/'],
ignores: [
'node_modules/',
'dist/',
'public/',
'.next/',
'**/*.js',
'next-env.d.ts',
],
},
...compat.extends(
'eslint:recommended',
Expand All @@ -36,9 +44,7 @@ const eslintConfig = [
parserOptions: {
ecmaVersion: 2023,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
ecmaFeatures: { jsx: true },
project: './tsconfig.json',
},
},
Expand All @@ -57,33 +63,22 @@ const eslintConfig = [
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'after-used',
varsIgnorePattern: '^_',
},
{ args: 'after-used', varsIgnorePattern: '^_' },
],
'jsx-a11y/label-has-associated-control': [
'error',
{
required: { some: ['nesting', 'id'] },
},
{ required: { some: ['nesting', 'id'] } },
],
'no-console': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/jsx-no-useless-fragment': 'warn',
},
settings: {
react: {
version: 'detect',
},
},
settings: { react: { version: 'detect' } },
},
{
files: ['*.tsx', '*.jsx'],
rules: {
'@typescript-eslint/no-use-before-define': 'off',
},
rules: { '@typescript-eslint/no-use-before-define': 'off' },
},
];

Expand Down
1 change: 0 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// jest.config.ts

import type { Config } from 'jest';
import nextJest from 'next/jest.js';

Expand Down
49 changes: 45 additions & 4 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
"lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\"",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx}\"",
"prepare": "husky install",
"test": "jest"
Expand All @@ -23,6 +23,7 @@
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/jest": "^29.5.14",
"@types/node": "^20",
"@types/react": "^18",
Expand All @@ -45,7 +46,7 @@
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1",
"ts-node": "^10.9.2",
"typescript": "^5"
"typescript": "~5.5.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
Expand Down
7 changes: 1 addition & 6 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
module.exports = { plugins: { tailwindcss: {}, autoprefixer: {} } };
1 change: 1 addition & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Metadata } from 'next';

import './globals.css';

export const metadata: Metadata = {
Expand Down
Loading