@yoshinani/style-guide 0.14.1 → 0.14.3
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 +79 -30
- package/cspell/words.txt +3 -0
- package/eslint/base.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- [ESLint](#eslint)
|
|
13
13
|
- [TypeScript](#typescript)
|
|
14
14
|
- [commitlint](#commitlint)
|
|
15
|
-
- [
|
|
15
|
+
- [CSpell](#CSpell)
|
|
16
16
|
|
|
17
17
|
## コントリビュートについて
|
|
18
18
|
|
|
@@ -69,7 +69,7 @@ VSCodeでフォーマッターとしてBiomeを利用する場合は、まず[Bi
|
|
|
69
69
|
|
|
70
70
|
次に、`.vscode/settings.json` に以下の設定を追加します。
|
|
71
71
|
|
|
72
|
-
```
|
|
72
|
+
```jsonc
|
|
73
73
|
{
|
|
74
74
|
"biome.enabled": true,
|
|
75
75
|
"editor.defaultFormatter": "biomejs.biome",
|
|
@@ -79,7 +79,7 @@ VSCodeでフォーマッターとしてBiomeを利用する場合は、まず[Bi
|
|
|
79
79
|
|
|
80
80
|
プロジェクトの推奨拡張機能として設定するために、`.vscode/extensions.json`を作成し、以下の内容を追加することをお勧めします。
|
|
81
81
|
|
|
82
|
-
```
|
|
82
|
+
```jsonc
|
|
83
83
|
{
|
|
84
84
|
"recommendations": [
|
|
85
85
|
"biomejs.biome"
|
|
@@ -106,6 +106,16 @@ const eslintConfig = [...next]
|
|
|
106
106
|
export default eslintConfig
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
+
プロジェクトの推奨拡張機能として設定するために、`.vscode/extensions.json`を作成し、以下の内容を追加することをお勧めします。
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"recommendations": [
|
|
114
|
+
"dbaeumer.vscode-eslint"
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
109
119
|
## TypeScript
|
|
110
120
|
|
|
111
121
|
このスタイルガイドは複数の TypeScript 設定を提供しています。利用可能な設定は以下の通りです。
|
|
@@ -128,7 +138,7 @@ export default eslintConfig
|
|
|
128
138
|
|
|
129
139
|
1. commitlintのインストール
|
|
130
140
|
|
|
131
|
-
```
|
|
141
|
+
```sh
|
|
132
142
|
pnpm add -D @commitlint/cli
|
|
133
143
|
```
|
|
134
144
|
|
|
@@ -140,13 +150,13 @@ export { default } from "@yoshinani/style-guide/commitlint"
|
|
|
140
150
|
|
|
141
151
|
3. コミット時のリントをする場合、huskyの設定をしてください。
|
|
142
152
|
|
|
143
|
-
```
|
|
153
|
+
```sh
|
|
144
154
|
pnpm add -D husky
|
|
145
155
|
```
|
|
146
156
|
|
|
147
157
|
`package.json`へスクリプトの追加。
|
|
148
158
|
|
|
149
|
-
```json
|
|
159
|
+
```json
|
|
150
160
|
"scripts": {
|
|
151
161
|
"prepare": "husky",
|
|
152
162
|
}
|
|
@@ -154,43 +164,82 @@ pnpm add -D husky
|
|
|
154
164
|
|
|
155
165
|
`.husky/commit-msg`を作成。
|
|
156
166
|
|
|
157
|
-
```bash
|
|
167
|
+
```bash
|
|
158
168
|
#!/usr/bin/env sh
|
|
159
169
|
. "$(dirname -- "$0")/_/husky.sh"
|
|
160
170
|
|
|
161
171
|
pnpm commitlint --edit "$1"
|
|
162
172
|
```
|
|
163
173
|
|
|
164
|
-
##
|
|
165
|
-
|
|
166
|
-
1. `cspell.config.mjs`を作成し以下のように記載します。
|
|
174
|
+
## CSpell
|
|
167
175
|
|
|
168
|
-
|
|
169
|
-
const dictPath =
|
|
170
|
-
import.meta.dirname + "/node_modules/@yoshinani/style-guide/cspell/words.txt"
|
|
176
|
+
`.vscode/cspell.json`を作成し以下のように記載します。こうすることでVSCodeからCSpellの設定が読み込まれます。
|
|
171
177
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
|
|
181
|
+
"dictionaries": ["yoshinani"],
|
|
182
|
+
"dictionaryDefinitions": [
|
|
175
183
|
{
|
|
176
|
-
name: "yoshinani
|
|
177
|
-
path:
|
|
178
|
-
addWords:
|
|
179
|
-
}
|
|
180
|
-
]
|
|
184
|
+
"name": "yoshinani",
|
|
185
|
+
"path": "../node_modules/@yoshinani/style-guide/cspell/words.txt",
|
|
186
|
+
"addWords": false
|
|
187
|
+
}
|
|
188
|
+
]
|
|
181
189
|
}
|
|
182
190
|
```
|
|
183
191
|
|
|
184
|
-
|
|
192
|
+
プロジェクトの推奨拡張機能として設定するために、`.vscode/extensions.json`を作成し、以下の内容を追加することをお勧めします。
|
|
185
193
|
|
|
186
|
-
```
|
|
194
|
+
```jsonc
|
|
187
195
|
{
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"addWords": false
|
|
193
|
-
}
|
|
194
|
-
}
|
|
196
|
+
"recommendations": [
|
|
197
|
+
"biomejs.biome",
|
|
198
|
+
"streetsidesoftware.code-spell-checker"
|
|
199
|
+
]
|
|
195
200
|
}
|
|
196
201
|
```
|
|
202
|
+
|
|
203
|
+
## 例外的なスペルチェックの無効化方法
|
|
204
|
+
|
|
205
|
+
固有名詞やランダムな文字列を書き込む際に、例外的にスペルチェックを無効化できます。
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
// 指定した行のチェックを無効化
|
|
209
|
+
const EXAMPLE_ID = "klfhasdflhadfasfa" // cspell: disable-line
|
|
210
|
+
|
|
211
|
+
// 直下の行のチェックを無効化
|
|
212
|
+
// cspell: disable-next-line
|
|
213
|
+
const LONG_ID = "klajdsjffadsfafkdafjajlmmxrklermanwafwncocmoc4ezdxcasf"
|
|
214
|
+
|
|
215
|
+
// 指定範囲のチェックを無効化
|
|
216
|
+
// cspell: disable
|
|
217
|
+
const MULTI_LINE_TXT = `
|
|
218
|
+
a;kfjas;dklfjads
|
|
219
|
+
aklfdj;adsjf;lka
|
|
220
|
+
;kajkls;dfjal;f
|
|
221
|
+
`
|
|
222
|
+
// cspell: enable
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
[詳細なドキュメント](https://cspell.org/docs/Configuration/document-settings)
|
|
226
|
+
|
|
227
|
+
## CI上の設定
|
|
228
|
+
|
|
229
|
+
CSpellをCI上で実行する際は、GitHub Actionsに以下のような設定を追加します。
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
name: 'Check spelling'
|
|
233
|
+
on:
|
|
234
|
+
pull_request:
|
|
235
|
+
push:
|
|
236
|
+
|
|
237
|
+
jobs:
|
|
238
|
+
spellcheck:
|
|
239
|
+
runs-on: ubuntu-latest
|
|
240
|
+
steps:
|
|
241
|
+
- uses: actions/checkout@v4
|
|
242
|
+
- uses: streetsidesoftware/cspell-action@v7
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
このときの設定は`.vscode/cspell.json`から暗黙的に読み込まれます。
|
package/cspell/words.txt
CHANGED
package/eslint/base.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoshinani/style-guide",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "YOSHINANI's Style Guide",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "22",
|
|
8
|
+
"node": ">=22",
|
|
9
9
|
"pnpm": "10"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|