@yoshinani/style-guide 0.1.3 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  - [Prettier](#prettier)
10
10
  - [ESLint](#eslint)
11
11
  - [TypeScript](#typescript)
12
+ - [commitlint](#commitlint)
12
13
 
13
14
  ## コントリビュートについて
14
15
 
@@ -29,14 +30,8 @@ pnpm i --save-dev @yoshinani/style-guide
29
30
  yarn add --dev @yoshinani/style-guide
30
31
  ```
31
32
 
32
- 一部の ESLint 設定にはピア依存関係が必要です。必要な場合は [ESLint](#eslint) セクションで記載しています。
33
-
34
33
  ## Prettier
35
34
 
36
- > 注意: Prettier はこのパッケージのピア依存関係であり、プロジェクトのルートにインストールする必要があります。
37
- >
38
- > 参考: https://prettier.io/docs/en/install.html
39
-
40
35
  共有 Prettier 設定を使うには、`package.json` に以下を追加してください。
41
36
 
42
37
  ```json
@@ -47,10 +42,6 @@ yarn add --dev @yoshinani/style-guide
47
42
 
48
43
  ## ESLint
49
44
 
50
- > 注意: ESLint はこのパッケージのピア依存関係であり、プロジェクトのルートにインストールする必要があります。
51
- >
52
- > 参考: https://eslint.org/docs/user-guide/getting-started#installation-and-usage
53
-
54
45
  利用できる設定は以下の通りです。
55
46
 
56
47
  - `@yoshinani/style-guide/eslint/base`
@@ -58,43 +49,19 @@ yarn add --dev @yoshinani/style-guide
58
49
  - `@yoshinani/style-guide/eslint/library`
59
50
  - `@yoshinani/style-guide/eslint/react-internal`
60
51
 
61
- > ESLint の設定解決の問題([eslint/eslint#9188](https://github.com/eslint/eslint/issues/9188))のため、`require.resolve` を使って絶対パスを指定してください。
62
-
63
- 例として、Next.js プロジェクトで共有 ESLint 設定を使う場合、`.eslintrc.js` に以下のように記載します。
52
+ 例として、Next.js プロジェクトで共有 ESLint 設定を使う場合、`eslint.config.mjs` に以下のように記載します。
64
53
 
65
54
  ```js
66
- /** @type {import("eslint").Linter.Config} */
67
- module.exports = {
68
- root: true,
69
- extends: [require.resolve("@yoshinani/style-guide/eslint/next")],
70
- parser: "@typescript-eslint/parser",
71
- parserOptions: {
72
- project: true,
73
- },
74
- }
75
- ```
76
-
77
- ### `overrides` を使ったスコープ設定
55
+ import next from "@yoshinani/style-guide/eslint/next"
78
56
 
79
- ESLint 設定は特定のパスにスコープできます。これにより、ルールが不要な場所に適用されるのを防げます。
57
+ const eslintConfig = [...next]
80
58
 
81
- 例として、Jest のルールをテストファイルのみに適用する場合は以下のようにします。
82
-
83
- ```js
84
- module.exports = {
85
- extends: [require.resolve('@yoshinani/style-guide/eslint/node')],
86
- overrides: [
87
- {
88
- files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
89
- extends: [require.resolve('@yoshinani/style-guide/eslint/jest')],
90
- },
91
- ],
92
- };
59
+ export default eslintConfig
93
60
  ```
94
61
 
95
62
  ## TypeScript
96
63
 
97
- このスタイルガイドは複数の TypeScript 設定を提供しています。これらの設定は LTS の Node.js バージョンに対応しており、それぞれに適した `lib`、`module`、`target`、`moduleResolution` 設定が含まれています。利用可能な設定は以下の通りです。
64
+ このスタイルガイドは複数の TypeScript 設定を提供しています。利用可能な設定は以下の通りです。
98
65
 
99
66
  | 種類 | 設定パッケージ名 |
100
67
  | -------------- | --------------------------------------------------- |
@@ -110,4 +77,39 @@ module.exports = {
110
77
  }
111
78
  ```
112
79
 
113
- ベースとなる TypeScript 設定は [`@yoshinani/style-guide/typescript`](./typescript/tsconfig.base.json) としても利用可能で、一般的なルールのみを指定しています。`lib`、`module`、`target`、`moduleResolution` 設定をカスタマイズする場合はこのファイルを継承してください。
80
+ ## commitlint
81
+
82
+ 1. commitlintのインストール
83
+
84
+ ```bash
85
+ pnpm add -D @commitlint/cli
86
+ ```
87
+
88
+ 2. `commitlint.config.mjs`を作成し以下のように記載します。
89
+
90
+ ```js
91
+ export { default } from "@yoshinani/style-guide/commitlint"
92
+ ```
93
+
94
+ 3. コミット時のリントをする場合、huskyの設定をしてください。
95
+
96
+ ```bash
97
+ pnpm add -D husky
98
+ ```
99
+
100
+ `package.json`へスクリプトの追加。
101
+
102
+ ```json:package.json
103
+ "scripts": {
104
+ "prepare": "husky",
105
+ }
106
+ ```
107
+
108
+ `.husky/commit-msg`を作成。
109
+
110
+ ```bash:.husky/commit-msg
111
+ #!/usr/bin/env sh
112
+ . "$(dirname -- "$0")/_/husky.sh"
113
+
114
+ pnpm commitlint --edit "$1"
115
+ ```
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@yoshinani/style-guide",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "Yoshinani's Style Guide",
5
+ "license": "MIT",
5
6
  "homepage": "https://github.com/yoshinani-dev/style-guide#readme",
6
7
  "bugs": {
7
8
  "url": "https://github.com/yoshinani-dev/style-guide/issues"
@@ -15,12 +16,14 @@
15
16
  "./typescript/nextjs": "./typescript/nextjs.json",
16
17
  "./typescript/react-library": "./typescript/react-library.json",
17
18
  "./eslint/*": "./eslint/*.mjs",
18
- "./commitlint": "./commitlint/commitlint.config.mjs"
19
+ "./commitlint": "./commitlint/commitlint.config.mjs",
20
+ "./prettier": "./prettier/prettier.config.cjs"
19
21
  },
20
22
  "files": [
21
23
  "typescript",
22
24
  "eslint",
23
- "commitlint"
25
+ "commitlint",
26
+ "prettier"
24
27
  ],
25
28
  "dependencies": {
26
29
  "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
@@ -34,15 +37,17 @@
34
37
  "eslint-plugin-tailwindcss": "^3.18.0",
35
38
  "globals": "^16.0.0",
36
39
  "typescript": "^5.8.3",
37
- "typescript-eslint": "^8.31.0",
38
- "@commitlint/config-conventional": "^19.8.0"
40
+ "typescript-eslint": "^8.31.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@commitlint/cli": "^19.8.0",
42
- "husky": "^9.1.7"
44
+ "husky": "^9.1.7",
45
+ "@commitlint/config-conventional": "19.8.0"
43
46
  },
44
47
  "peerDependencies": {
45
- "eslint": ">=9 <10"
48
+ "eslint": ">=9 <10",
49
+ "@commitlint/config-conventional": "^19",
50
+ "prettier": "^3"
46
51
  },
47
52
  "packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
48
53
  "scripts": {
@@ -0,0 +1,17 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @see https://prettier.io/docs/configuration
5
+ * @type {import("prettier").Config}
6
+ */
7
+ const config = {
8
+ endOfLine: "lf",
9
+ tabWidth: 2,
10
+ printWidth: 80,
11
+ useTabs: false,
12
+ singleQuote: false,
13
+ semi: false,
14
+ trailingComma: "all",
15
+ };
16
+
17
+ module.exports = config;