Skip to content

Commit 4eed026

Browse files
committed
feat(rule): textlint-rule-no-invalid-control-characterを追加
改行やタブ以外の不自然な制御文字が入るのを防止します。 Mac Chromeでのバグでバックスペース時に入ってしまった制御文字が文章に残るのを防止します。 close #30
1 parent e6a7f52 commit 4eed026

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ textlint --preset ja-technical-writing README.md
186186

187187
"no-nfd": true,
188188

189+
### 不必要な制御文字を使用しない
190+
> https://github.com/textlint-rule/textlint-rule-no-invalid-control-character
191+
192+
改行(`\n`)やタブ(`\t`)以外の一般的な文章にはでてこない不自然な制御文字が入るのを防止します。
193+
194+
"no-invalid-control-character": true,
195+
189196
### 感嘆符!!、感嘆符??を使用しない
190197
> https://github.com/azu/textlint-rule-no-exclamation-question-mark
191198

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
"no-nfd": require("textlint-rule-no-nfd"),
1919
"no-exclamation-question-mark": require("textlint-rule-no-exclamation-question-mark"),
2020
"no-hankaku-kana": require("textlint-rule-no-hankaku-kana"),
21+
"no-invalid-control-character": require("@textlint-rule/textlint-rule-no-invalid-control-character"),
2122
"ja-no-weak-phrase": require("textlint-rule-ja-no-weak-phrase"),
2223
"ja-no-successive-word": require("textlint-rule-ja-no-successive-word"),
2324
"ja-no-abusage": require("textlint-rule-ja-no-abusage"),
@@ -91,6 +92,10 @@ module.exports = {
9192
// 文章中にUTF8-MAC 濁点は不要です。
9293
// https://github.com/azu/textlint-rule-no-nfd
9394
"no-nfd": true,
95+
// # 不必要な制御文字を使用しない
96+
// 改行やタブ以外の一般的な文章にはでてこない不自然な制御文字が入るのを防止します。
97+
// https://github.com/textlint-rule/textlint-rule-no-invalid-control-character
98+
"no-invalid-control-character": true,
9499
// # 感嘆符!!、疑問符??を使用しない
95100
// https://github.com/azu/textlint-rule-no-exclamation-question-mark
96101
"no-exclamation-question-mark": true,
@@ -111,4 +116,4 @@ module.exports = {
111116
// https://github.com/textlint-ja/textlint-rule-ja-no-redundant-expression
112117
"ja-no-redundant-expression": true
113118
}
114-
};
119+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"mocha": "^5.0.0"
3535
},
3636
"dependencies": {
37+
"@textlint-rule/textlint-rule-no-invalid-control-character": "^1.0.1",
3738
"textlint-rule-ja-no-abusage": "^1.1.1",
3839
"textlint-rule-ja-no-mixed-period": "^2.0.0",
3940
"textlint-rule-ja-no-redundant-expression": "^2.0.0",

yarn.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# yarn lockfile v1
33

44

5+
"@textlint-rule/textlint-rule-no-invalid-control-character@^1.0.1":
6+
version "1.0.1"
7+
resolved "https://registry.yarnpkg.com/@textlint-rule/textlint-rule-no-invalid-control-character/-/textlint-rule-no-invalid-control-character-1.0.1.tgz#6ba7dd0555e1b41af2d002a62aa0ae7795111e09"
8+
dependencies:
9+
execall "^1.0.0"
10+
511
"@textlint/ast-node-types@^3.0.0":
612
version "3.0.1"
713
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-3.0.1.tgz#cf35e913aef798f0efac797144e167744a7857e8"
@@ -126,6 +132,13 @@ check-ends-with-period@^1.0.1:
126132
emoji-regex "^6.4.1"
127133
end-with "^1.0.2"
128134

135+
clone-regexp@^1.0.0:
136+
version "1.0.1"
137+
resolved "https://registry.yarnpkg.com/clone-regexp/-/clone-regexp-1.0.1.tgz#051805cd33173375d82118fc0918606da39fd60f"
138+
dependencies:
139+
is-regexp "^1.0.0"
140+
is-supported-regexp-flag "^1.0.0"
141+
129142
code-point@^1.0.1:
130143
version "1.1.0"
131144
resolved "https://registry.yarnpkg.com/code-point/-/code-point-1.1.0.tgz#999841f51f54ccae4a0dabbc869063234603fecd"
@@ -221,6 +234,12 @@ esprima@^4.0.0:
221234
version "4.0.0"
222235
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
223236

237+
execall@^1.0.0:
238+
version "1.0.0"
239+
resolved "https://registry.yarnpkg.com/execall/-/execall-1.0.0.tgz#73d0904e395b3cab0658b08d09ec25307f29bb73"
240+
dependencies:
241+
clone-regexp "^1.0.0"
242+
224243
expand-range@^1.8.1:
225244
version "1.8.2"
226245
resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337"
@@ -347,6 +366,14 @@ is-regex@^1.0.4:
347366
dependencies:
348367
has "^1.0.1"
349368

369+
is-regexp@^1.0.0:
370+
version "1.0.0"
371+
resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069"
372+
373+
is-supported-regexp-flag@^1.0.0:
374+
version "1.0.1"
375+
resolved "https://registry.yarnpkg.com/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.1.tgz#21ee16518d2c1dd3edd3e9a0d57e50207ac364ca"
376+
350377
is-symbol@^1.0.1:
351378
version "1.0.1"
352379
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"

0 commit comments

Comments
 (0)