Skip to content

Commit

Permalink
Merge pull request #1 from hatsu38/feature/add-linter
Browse files Browse the repository at this point in the history
LinterとCIを導入
  • Loading branch information
hatsu38 committed Apr 25, 2023
2 parents 74bcbe0 + 0c84a65 commit 50dffce
Show file tree
Hide file tree
Showing 18 changed files with 519 additions and 38 deletions.
118 changes: 117 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
{
"extends": "next/core-web-vitals"
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["import"],
"settings": {
"react": {
"version": "detect"
},
"import/extensions": [".ts", ".tsx", ".js", ".jsx"]
},
"rules": {
"react/react-in-jsx-scope": "off", // Reactのimportを不要にする
"eqeqeq": [2, "smart"], // ===にする
"quotes": ["error", "double"], // ダブルオーテーションで文字列を囲う
"semi": ["error", "always"], // セミコロンを必須にする
"prefer-const": "error", // 再代入を行わない変数はconstを利用
"no-var": "error", // var禁止
"no-debugger": "error", // デバッガーは残さない
"react/button-has-type": "error", // buttonにtypeを必須にする
// 未使用の値はエラーにする
"@typescript-eslint/no-unused-vars": [
"error",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" } // ただし _hoge などはok
],
"jsx-a11y/no-static-element-interactions": "off", // divにonClickをつけることを許可
"jsx-a11y/click-events-have-key-events": "off", // divにonClickをつけることを許可
// import禁止のルール
"no-restricted-imports": [
"error",
{
"name": "aws-amplify",
"message": "Use `@contracter/libs/aws` instead."
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
["parent", "sibling"],
"index",
"object",
"type"
],
"newlines-between": "always",
"pathGroupsExcludedImportTypes": ["builtin", "object"],
"alphabetize": { "order": "asc", "caseInsensitive": true },
"pathGroups": [
{
"pattern": "{react}",
"group": "builtin",
"position": "before"
},
{
"pattern": "{next,next/**}",
"group": "external",
"position": "after"
},
{
"pattern": "{@contracter/src/libs/**,@contracter/src/libs}",
"group": "external",
"position": "after"
},
{
"pattern": "{@contracter/src/utils/**,@contracter/src/utils}",
"group": "external",
"position": "after"
},
{
"pattern": "{@contracter/src/apis/**,@contracter/src/apis}",
"group": "external",
"position": "after"
},
{
"pattern": "{@contracter/src/models/**,@contracter/src/models}",
"group": "external",
"position": "after"
},
{
"pattern": "{@contracter/src/hooks/**,@contracter/src/hooks}",
"group": "internal",
"position": "before"
},
{
"pattern": "@contracter/components/**",
"group": "internal",
"position": "before"
},
{
"pattern": "{@contracter/src/config/**,@contracter/src/config}",
"group": "index",
"position": "after"
},
{
"pattern": "{@contracter/src/domains/**,@contracter/src/domains}",
"group": "type",
"position": "before"
},
{
"pattern": "{@contracter/src/constants/**,@contracter/src/constants}",
"group": "type",
"position": "after"
}
]
}
]
}
}
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 📋 概要

## 👓 関連PR

## 📮 レビュワーに伝えたいこと
<!-- 観点、ポイント、不明点、疑問点など -->
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
time: "09:00"
timezone: Asia/Tokyo
reviewers:
- hatsu38
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
time: "09:00"
timezone: Asia/Tokyo
reviewers:
- hatsu38
open-pull-requests-limit: 10
60 changes: 60 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🔧 Refactoring'
label: 'refactor'
branch:
- '/refactor\/.+/'
- title: '📖 Documentation'
label: 'docs'
branch:
- '/docs\/.+/'
- title: '⛓️ Dependency update'
label: 'dependencies'
- title: '🧰 Maintenance'
label: 'chore'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
autolabeler:
- label: feature
branch:
- '/^feat(ure)?[/-].+/'
- label: bug
branch:
- '/^fix[/-].+/'
- label: chore
branch:
- '/^chore[/-].+/'
- label: refactor
branch:
- '/(refactor|refactoring)[/-].+/'
- label: documentation
branch:
- '/docs[/-].+/'
files:
- '*.md'
19 changes: 19 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Assign Auto

on:
pull_request:
types: [opened]

jobs:
assign:
runs-on: ubuntu-latest

steps:
- name: Set assignees
run: gh pr edit $NUMBER --add-assignee $ASSIGNEE
if: github.actor != 'dependabot[bot]'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
ASSIGNEE: ${{ github.actor }}
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

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

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3.6.0
with:
node-version: 18.x
cache: npm

- name: Create dot env file
run: |
touch .env
- name: Install
run: npm ci --prefer-offline --no-audit --no-optional
env:
CI: true

- name: Build
run: npm run build

- name: Lint
run: npm run lint .

- name: Format Check
run: npm run format:check .

- name: Type Check
run: npm run type:check
21 changes: 21 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release Drafter

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore artifacts:
build
dist
coverage
.github
.codeclimate.yml
*.md
.env
.next
.vscode
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"trailingComma": "es5",
"semi": true,
"singleQuote": false
}
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
};

module.exports = nextConfig
module.exports = nextConfig;
Loading

0 comments on commit 50dffce

Please sign in to comment.