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
71 changes: 71 additions & 0 deletions .github/workflows/LINT_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# コード品質チェックツール

## 概要

このプロジェクトではESLintとPrettierを使用してコード品質を保っています。

## 使い方

### チェックのみ(CI で実行される)

```bash
# すべてのチェックを実行
npm run check

# または個別に
npm run lint # ESLint チェック
npm run format # Prettier チェック
```

### 自動修正

```bash
# すべて自動修正
npm run fix

# または個別に
npm run lint:fix # ESLint 自動修正
npm run format:fix # Prettier 自動修正
```

## GitHub Actions

### CI(自動チェック)

PR作成時とmainへのpush時に自動でチェックが実行されます:
- ESLintによるコード品質チェック
- Prettierによるフォーマットチェック
- TypeScriptのコンパイルチェック

チェックが失敗した場合は、ローカルで`npm run fix`を実行してから再度pushしてください。

### Deploy(自動デプロイ)

mainブランチにマージされると自動でGASにデプロイされます。

## 推奨ワークフロー

1. コードを編集
2. `npm run fix` で自動修正
3. `npm run check` で確認
4. コミット&プッシュ
5. CIが自動でチェック
6. mainにマージで自動デプロイ

## エディタ設定(VSCode)

推奨拡張機能:
- ESLint
- Prettier - Code formatter

保存時に自動フォーマットを有効にするには、`.vscode/settings.json`に以下を追加:

```json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
```
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI - Lint and Format Check

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

jobs:
lint-and-format:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Run Prettier
run: npm run format

- name: Check TypeScript compilation
run: npx tsc --noEmit
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
node_modules/
.clasp.json
.clasprc.json
*.log
esbuild.js
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100,
"arrowParens": "avoid"
}
38 changes: 38 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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: ['src/**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
},
globals: {
console: 'readonly',
Logger: 'readonly',
SpreadsheetApp: 'readonly',
},
},
plugins: {
'@typescript-eslint': tsPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'no-undef': 'off', // TypeScriptが処理するため
},
},
prettierConfig,
{
ignores: ['dist/', 'node_modules/', 'esbuild.js'],
},
];
Loading