Skip to content

Commit 6c1d348

Browse files
authored
feat: add textlint-rule-no-zero-width-spaces (#88)
* feat: add textlint-rule-no-zero-width-spaces * Create stale-rocks-grab.md * dos: Update TOC
1 parent 7d4ccd9 commit 6c1d348

File tree

5 files changed

+82
-19
lines changed

5 files changed

+82
-19
lines changed

.changeset/stale-rocks-grab.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"textlint-rule-preset-ja-technical-writing": major
3+
---
4+
5+
:new: [textlint-rule-no-zero-width-spaces](https://github.com/textlint-rule/textlint-rule-no-zero-width-spaces)を追加
6+
7+
ゼロ幅スペース(`\u200b`)が文章に入るのを防止するルールです。

README.md

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
技術文書向けの[textlint](https://textlint.github.io/)ルールプリセットです。
44
全体的に少し厳しめの設定がデフォルト値となっているため、文章に合わせて設定値を変更する必要があります。
55

6-
また、[連続できる最大の漢字長は6文字まで](#%E9%80%A3%E7%B6%9A%E3%81%A7%E3%81%8D%E3%82%8B%E6%9C%80%E5%A4%A7%E3%81%AE%E6%BC%A2%E5%AD%97%E9%95%B7%E3%81%AF6%E6%96%87%E5%AD%97%E3%81%BE%E3%81%A7)のように文章全体として例外が必ず出てくるルールもデフォルトで入っています。
7-
ルールによっては`allow`オプションで例外を規定できるようになっているため、例外を明示しつつ利用することを想定しています。
6+
また、[連続できる最大の漢字長は6文字まで](#%E9%80%A3%E7%B6%9A%E3%81%A7%E3%81%8D%E3%82%8B%E6%9C%80%E5%A4%A7%E3%81%AE%E6%BC%A2%E5%AD%97%E9%95%B7%E3%81%AF6%E6%96%87%E5%AD%97%E3%81%BE%E3%81%A7)
7+
のように文章全体として例外が必ず出てくるルールもデフォルトで入っています。 ルールによっては`allow`オプションで例外を規定できるようになっているため、例外を明示しつつ利用することを想定しています。
88

99
合わせて利用することを想定しているfilterルール(例外を明示できる)も参照してください。
1010

@@ -26,9 +26,9 @@ Via `.textlintrc`(Recommended)
2626

2727
```json
2828
{
29-
"rules": {
30-
"preset-ja-technical-writing": true
31-
}
29+
"rules": {
30+
"preset-ja-technical-writing": true
31+
}
3232
}
3333
```
3434

@@ -38,6 +38,24 @@ Via CLI
3838
textlint --preset ja-technical-writing README.md
3939
```
4040

41+
## ルールの設定方法
42+
43+
次のように `"preset-ja-technical-writing"` 以下にそれぞれのオプション値を指定することで、設定を変更できます。
44+
各ルールの設定できるオプションは、各ルールのREADMEを参照してください。
45+
46+
```json
47+
{
48+
"rules": {
49+
"preset-ja-technical-writing": {
50+
"max": 120,
51+
"no-mix-dearu-desumasu": false
52+
}
53+
}
54+
}
55+
```
56+
57+
また、ルールの設定方法については[textlintのドキュメント](https://textlint.github.io/docs/configuring.html#rule-preset)も参照してください。
58+
4159
## ルール一覧
4260

4361
<!-- toc -->
@@ -56,6 +74,7 @@ textlint --preset ja-technical-writing README.md
5674
* [同じ助詞を連続して使用しない](#%E5%90%8C%E3%81%98%E5%8A%A9%E8%A9%9E%E3%82%92%E9%80%A3%E7%B6%9A%E3%81%97%E3%81%A6%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
5775
* [UTF8-MAC 濁点を使用しない](#utf8-mac-%E6%BF%81%E7%82%B9%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
5876
* [不必要な制御文字を使用しない](#%E4%B8%8D%E5%BF%85%E8%A6%81%E3%81%AA%E5%88%B6%E5%BE%A1%E6%96%87%E5%AD%97%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
77+
* [不必要なゼロ幅スペースを使用しない](#%E4%B8%8D%E5%BF%85%E8%A6%81%E3%81%AA%E3%82%BC%E3%83%AD%E5%B9%85%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
5978
* [感嘆符!!、感嘆符??を使用しない](#%E6%84%9F%E5%98%86%E7%AC%A6%E6%84%9F%E5%98%86%E7%AC%A6%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
6079
* [半角カナを使用しない](#%E5%8D%8A%E8%A7%92%E3%82%AB%E3%83%8A%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
6180
* [弱い日本語表現の利用を使用しない](#%E5%BC%B1%E3%81%84%E6%97%A5%E6%9C%AC%E8%AA%9E%E8%A1%A8%E7%8F%BE%E3%81%AE%E5%88%A9%E7%94%A8%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
@@ -66,8 +85,10 @@ textlint --preset ja-technical-writing README.md
6685
* [対になっていない括弧をチェックする](#%E5%AF%BE%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%81%AA%E3%81%84%E6%8B%AC%E5%BC%A7%E3%82%92%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%81%99%E3%82%8B)
6786
- [Changelog](#changelog)
6887
- [Semantic Versioning Policy](#semantic-versioning-policy)
88+
* [Release Flow](#release-flow)
6989
- [ルールの利用者](#%E3%83%AB%E3%83%BC%E3%83%AB%E3%81%AE%E5%88%A9%E7%94%A8%E8%80%85)
7090
- [Community](#community)
91+
- [その他のルール](#%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%AE%E3%83%AB%E3%83%BC%E3%83%AB)
7192
- [Running tests](#running-tests)
7293
- [Contributing](#contributing)
7394
- [Author](#author)
@@ -76,10 +97,10 @@ textlint --preset ja-technical-writing README.md
7697
<!-- tocstop -->
7798

7899
### 1文の長さは100文字以下とする
100+
79101
> https://github.com/azu/textlint-rule-sentence-length
80102
81-
長過ぎる文は読みにくさに繋がるため、適切な単位で文を区切ってください。
82-
厳しめの設定にしたい場合は`90`文字を推奨しています。
103+
長過ぎる文は読みにくさに繋がるため、適切な単位で文を区切ってください。 厳しめの設定にしたい場合は`90`文字を推奨しています。
83104

84105
"sentence-length": {
85106
max: 100
@@ -91,6 +112,7 @@ textlint --preset ja-technical-writing README.md
91112
- バージョン2.0.0以下: 90文字以下
92113

93114
### カンマは1文中に3つまで
115+
94116
> https://github.com/azu/textlint-rule-max-comma
95117
96118
カンマ(,)の多用は、文が長くなっている可能性があります。
@@ -100,6 +122,7 @@ textlint --preset ja-technical-writing README.md
100122
},
101123

102124
### 読点は1文中に3つまで
125+
103126
> https://github.com/azu/textlint-rule-max-ten
104127
105128
読点(、)の多用は、文が長くなっている可能性があります。
@@ -109,16 +132,17 @@ textlint --preset ja-technical-writing README.md
109132
},
110133

111134
### 連続できる最大の漢字長は6文字まで
135+
112136
> https://github.com/azu/textlint-rule-max-kanji-continuous-len
113137
114-
漢字同士が連続していると読みにくさにつながります。
115-
固有名詞は `allow` オプションに記述して回避します。
138+
漢字同士が連続していると読みにくさにつながります。 固有名詞は `allow` オプションに記述して回避します。
116139

117140
"max-kanji-continuous-len": {
118141
max: 6
119142
},
120143

121144
### 漢数字と算用数字を使い分けます
145+
122146
> https://github.com/azu/textlint-rule-preset-JTF-style
123147
124148
数量を表現し、数を数えられるものは算用数字を使用します。任意の数に置き換えても通用する語句がこれに該当します。
@@ -128,6 +152,7 @@ textlint --preset ja-technical-writing README.md
128152
"arabic-kanji-numbers": true,
129153

130154
### 「ですます調」、「である調」を統一します
155+
131156
> https://github.com/azu/textlint-rule-no-mix-dearu-desumasu
132157
133158
- 見出しは自動
@@ -143,8 +168,8 @@ textlint --preset ja-technical-writing README.md
143168
"strict": true
144169
},
145170

146-
147171
### 文末の句点記号として「。」を使います
172+
148173
> https://github.com/textlint-ja/textlint-rule-ja-no-mixed-period
149174
150175
文末には「。」を使い文を区切ります。
@@ -156,17 +181,19 @@ textlint --preset ja-technical-writing README.md
156181
},
157182

158183
### 二重否定は使用しない
184+
159185
> https://github.com/azu/textlint-rule-no-double-negative-ja
160186
161187
"no-double-negative-ja": true,
162188

163189
### ら抜き言葉を使用しない
190+
164191
> https://github.com/azu/textlint-rule-no-dropping-the-ra
165192
166193
"no-dropping-the-ra": true,
167194

168-
169195
### 逆接の接続助詞「が」を連続して使用しない
196+
170197
> https://github.com/takahashim/textlint-rule-no-doubled-conjunctive-particle-ga
171198
172199
逆接の接続助詞「が」は、特に否定の意味ではなくても安易に使われてしまいがちです。
@@ -176,54 +203,69 @@ textlint --preset ja-technical-writing README.md
176203
"no-doubled-conjunctive-particle-ga": true,
177204

178205
### 同じ接続詞を連続して使用しない
206+
179207
> https://github.com/takahashim/textlint-rule-no-doubled-conjunction
180208
181209
"no-doubled-conjunction": true,
182210

183211
### 同じ助詞を連続して使用しない
212+
184213
> https://github.com/azu/textlint-rule-no-doubled-joshi
185214
186215
"no-doubled-joshi": {
187216
"min_interval": 1
188217
},
189218

190219
### UTF8-MAC 濁点を使用しない
220+
191221
> https://github.com/azu/textlint-rule-no-nfd
192222
193-
文章中にUTF8-MAC 濁点は不要です。
194-
ファイルからコピー&ペーストした文字である場合があります。
223+
文章中にUTF8-MAC 濁点は不要です。 ファイルからコピー&ペーストした文字である場合があります。
195224

196225
"no-nfd": true,
197226

198-
### 不必要な制御文字を使用しない
227+
### 不必要な制御文字を使用しない
228+
199229
> https://github.com/textlint-rule/textlint-rule-no-invalid-control-character
200230
201-
改行(`\n`)やタブ(`\t`)以外の一般的な文章にはでてこない不自然な制御文字が入るのを防止します
231+
改行(`\n`)やタブ(`\t`)以外の制御文字が文章に入るのを防止します
202232

203233
"no-invalid-control-character": true,
204234

235+
### 不必要なゼロ幅スペースを使用しない
236+
237+
> https://github.com/textlint-rule/textlint-rule-no-zero-width-spaces
238+
239+
ゼロ幅スペース(`\u200b`)が文章に入るのを防止します。
240+
241+
"no-zero-width-spaces": true,
242+
205243
### 感嘆符!!、感嘆符??を使用しない
244+
206245
> https://github.com/azu/textlint-rule-no-exclamation-question-mark
207246
208247
特定の感嘆符または感嘆符を使用する場合は、オプションで許可して利用してください。
209248

210249
"no-exclamation-question-mark": true,
211250

212251
### 半角カナを使用しない
252+
213253
> https://github.com/azu/textlint-rule-no-hankaku-kana
214254
215255
全角カタカナを使用してください。
216256

217257
"no-hankaku-kana": true,
218258

219259
### 弱い日本語表現の利用を使用しない
260+
220261
> https://github.com/textlint-ja/textlint-rule-ja-no-weak-phrase
221262
222263
`〜かもしれない` 等の弱い表現を使用しない。
223264

224265
"ja-no-weak-phrase": true,
225266

226267
### 同一の単語を間違えて連続しているのをチェックする
268+
227269
> https://github.com/textlint-ja/textlint-rule-ja-no-successive-word
228270
229271
同一の単語(形態素解析したtoken)が連続している場合は誤字の可能性があります。
@@ -233,13 +275,15 @@ textlint --preset ja-technical-writing README.md
233275
"ja-no-successive-word": true,
234276

235277
### よくある日本語の誤用をチェックする
278+
236279
> https://github.com/textlint-ja/textlint-rule-ja-no-abusage
237280
238281
日本語や技術表現における漢字の誤用などをチェックするルールです。
239282

240283
"ja-no-abusage": true
241284

242285
### 冗長な表現をチェックする
286+
243287
> https://github.com/textlint-ja/textlint-rule-ja-no-redundant-expression
244288
245289
冗長な表現とは、その文から省いても意味が通じるような表現を示しています。
@@ -248,20 +292,21 @@ textlint --preset ja-technical-writing README.md
248292
"ja-no-redundant-expression": true
249293

250294
### 入力ミスで発生する不自然なアルファベットをチェックする
295+
251296
> https://github.com/textlint-ja/textlint-rule-ja-unnatural-alphabet
252297
253298
`リイr−ス` などIMEの入力ミスが日本語中に混じった不自然なアルファベットをチェックします。
254299

255300
"ja-unnatural-alphabet": true
256301

257302
### 対になっていない括弧をチェックする
303+
258304
> https://github.com/textlint-rule/textlint-rule-no-unmatched-pair
259305
260306
1文中で`(`に対応する`)`がない場合などの括弧の対応関係をチェックします。
261307

262308
"no-unmatched-pair": true
263309

264-
265310
## Changelog
266311

267312
See [Releases page](https://github.com/textlint-ja/textlint-rule-preset-ja-technical-writing/releases).
@@ -322,7 +367,8 @@ Install devDependencies and Run `npm test`:
322367

323368
Pull requests and stars are always welcome.
324369

325-
For bugs and feature requests, [please create an issue](https://github.com/textlint-ja/textlint-rule-preset-ja-technical-writing/issues).
370+
For bugs and feature
371+
requests, [please create an issue](https://github.com/textlint-ja/textlint-rule-preset-ja-technical-writing/issues).
326372

327373
1. Fork it
328374
2. Create your feature branch: `git checkout -b my-new-feature`

lib/textlint-rule-preset-ja-technical-writing.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
const {moduleInterop} = require("@textlint/module-interop");
2+
const { moduleInterop } = require("@textlint/module-interop");
33
const jtfRules = moduleInterop(require("textlint-rule-preset-jtf-style")).rules;
44
module.exports = {
55
rules: {
@@ -24,7 +24,8 @@ module.exports = {
2424
"ja-no-abusage": moduleInterop(require("textlint-rule-ja-no-abusage")),
2525
"ja-no-redundant-expression": moduleInterop(require("textlint-rule-ja-no-redundant-expression")),
2626
"ja-unnatural-alphabet": moduleInterop(require("textlint-rule-ja-unnatural-alphabet")),
27-
"no-unmatched-pair": moduleInterop(require("@textlint-rule/textlint-rule-no-unmatched-pair"))
27+
"no-unmatched-pair": moduleInterop(require("@textlint-rule/textlint-rule-no-unmatched-pair")),
28+
"no-zero-width-spaces": moduleInterop(require("textlint-rule-no-zero-width-spaces"))
2829
},
2930
rulesConfig: {
3031
// # 1文の長さは100文字以下とする
@@ -98,6 +99,9 @@ module.exports = {
9899
// 改行やタブ以外の一般的な文章にはでてこない不自然な制御文字が入るのを防止します。
99100
// https://github.com/textlint-rule/textlint-rule-no-invalid-control-character
100101
"no-invalid-control-character": true,
102+
// # ゼロ幅スペースの検出
103+
// https://github.com/textlint-rule/textlint-rule-no-zero-width-spaces
104+
"no-zero-width-spaces": true,
101105
// # 感嘆符!!、疑問符??を使用しない
102106
// https://github.com/azu/textlint-rule-no-exclamation-question-mark
103107
"no-exclamation-question-mark": true,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"textlint-rule-no-hankaku-kana": "^1.0.2",
5353
"textlint-rule-no-mix-dearu-desumasu": "^5.0.0",
5454
"textlint-rule-no-nfd": "^1.0.2",
55+
"textlint-rule-no-zero-width-spaces": "^1.0.1",
5556
"textlint-rule-preset-jtf-style": "^2.3.12",
5657
"textlint-rule-sentence-length": "^3.0.0"
5758
},

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,11 @@ textlint-rule-no-nfd@^1.0.2:
28292829
textlint-rule-helper "^2.1.1"
28302830
unorm "^1.4.1"
28312831

2832+
textlint-rule-no-zero-width-spaces@^1.0.1:
2833+
version "1.0.1"
2834+
resolved "https://registry.yarnpkg.com/textlint-rule-no-zero-width-spaces/-/textlint-rule-no-zero-width-spaces-1.0.1.tgz#15a6abda05f08e483d5bb33a7034d904259d77a3"
2835+
integrity sha512-AkxpzBILGB4YsXddzHx2xqpXmqMv5Yd+PQm4anUV+ADSJuwLP1Jd6yHf/LOtu9j3ps8K3XM9vQrXRK73z0bU3A==
2836+
28322837
textlint-rule-preset-jtf-style@^2.3.12:
28332838
version "2.3.12"
28342839
resolved "https://registry.yarnpkg.com/textlint-rule-preset-jtf-style/-/textlint-rule-preset-jtf-style-2.3.12.tgz#17a114c24eb83c093ecb7c352eb4447441581e40"

0 commit comments

Comments
 (0)