Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIの導入 #19

Merged
merged 7 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
27 changes: 27 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint Code Base
on:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
Copy link
Contributor

@Meiryo7743 Meiryo7743 Jan 4, 2025

Choose a reason for hiding this comment

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

8 行目について,PR の base branch に対しても実行されることを考えると「Checkout main branch」の「main」を「target」のような表現に変えてみるのはどうでしょうか? それなら意図が一層明瞭になって良さそうです

次行のような各 Actions についても,セキュリティーの観点からバージョンは commit hash による指定が望ましいです。pinact のようなツールを使って機械的に置換すればサクッと対応できます。願わくば Renovate を使ってこの更新管理も自動化できるとなお良しではあるものの,流石にそこは本件の範囲外といったところでしょうかね……。

Suggested change
- name: Checkout main branch
uses: actions/checkout@v4
- name: Checkout target branch
uses: actions/checkout@ # commit hash に置き換える

Copy link
Member Author

Choose a reason for hiding this comment

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

どちらも納得です、対応します!

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install dependencies
run: pnpm install
- name: TypeScript Compile Check
run: pnpm tsc --noEmit
- name: Run ESLint
run: pnpm lint
- name: Run Prettier
run: pnpm format --check
- name: Run Stylelint
run: pnpm stylelint
32 changes: 11 additions & 21 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { FlatCompat } from "@eslint/eslintrc";
import { dirname } from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
import { FlatCompat } from '@eslint/eslintrc';
import eslintConfigPrettier from 'eslint-config-prettier';

const compat = new FlatCompat({
baseDirectory: __dirname,
});
// import.meta.dirname is available after Node.js v20.11.0
baseDirectory: import.meta.dirname,
})

const eslintConfig = [
{
ignores: ["node_modules/", ".next/"],
},
...compat.extends("next/core-web-vitals", "next/typescript"),
importPlugin.flatConfigs.recommended,
eslintConfigPrettier,
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
"import/order": [
"error",
Expand All @@ -34,14 +29,9 @@ const eslintConfig = [
"pathGroups": [
{
"pattern": "{react,react-dom/**,react-router-dom,next,next/**}",
"group": "bulitin",
"group": "builtin",
"position": "before"
},
{
"pattern": "@mantine/**",
"group": "builtin",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["builtin"],
"alphabetize": {
Expand All @@ -54,4 +44,4 @@ const eslintConfig = [
},
];

export default eslintConfig;
export default eslintConfig;
6 changes: 4 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",
"format": "prettier --write \"./src/**/*.{ts,tsx}\"",
"lint": "next lint",
"lint": "eslint",
"stylelint": "stylelint \"./src/**/*.css\" --fix"
},
"dependencies": {
Expand All @@ -21,14 +21,16 @@
"react-dom": "^19.0.0"
},
"devDependencies": {
"eslint": "^9.16.0",
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-prettier": "^9.1.0",
"eslint-config-next": "15.1.0",
"eslint-plugin-import": "^2.31.0",
"prettier": "^3.4.2",
"typescript-eslint": "^8.19.0",
"stylelint": "^16.11.0",
"stylelint-config-recess-order": "^5.1.1",
"stylelint-config-standard": "^36.0.1",
Expand Down
Loading
Loading