File tree 2 files changed +11
-15
lines changed
packages/textlint-rule-ja-no-space-between-full-width
2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 32
32
"textlint-scripts" : " ^13.3.3"
33
33
},
34
34
"dependencies" : {
35
- "match-index" : " ^1.0.3" ,
36
35
"regx" : " ^1.0.4" ,
37
36
"textlint-rule-helper" : " ^2.2.4"
38
37
}
Original file line number Diff line number Diff line change 6
6
ただしカタカナ複合語の場合を除きます。
7
7
*/
8
8
import { RuleHelper } from "textlint-rule-helper" ;
9
- import { matchAll } from "match-index" ;
10
9
import regx from "regx" ;
11
10
const rx = regx ( "g" ) ;
12
11
const japaneseRegExp =
@@ -24,23 +23,21 @@ function reporter(context) {
24
23
// 全角同士の間は半角スペースを入れない
25
24
const matchReg = rx `${ japaneseRegExp } ( )${ japaneseRegExp } ` ;
26
25
const katakakana = / [ ァ - ヶ ] ( ) [ ァ - ヶ ] / ;
27
- matchAll ( text , matchReg ) . forEach ( ( match ) => {
28
- const { input, captureGroups } = match ;
26
+ for ( const match of text . matchAll ( matchReg ) ) {
27
+ const input = match [ 1 ] ;
29
28
// ただしカタカナ複合語の場合を除きます。
30
29
if ( katakakana . test ( input ) ) {
31
30
return ;
32
31
}
33
- captureGroups . forEach ( ( captureGroup ) => {
34
- const index = captureGroup . index ;
35
- report (
36
- node ,
37
- new RuleError ( "原則として、全角文字どうしの間にスペースを入れません。" , {
38
- index : index ,
39
- fix : fixer . replaceTextRange ( [ index , index + 1 ] , "" )
40
- } )
41
- ) ;
42
- } ) ;
43
- } ) ;
32
+ const indexOneBased = match . index + 1 ;
33
+ report (
34
+ node ,
35
+ new RuleError ( "原則として、全角文字どうしの間にスペースを入れません。" , {
36
+ index : indexOneBased ,
37
+ fix : fixer . replaceTextRange ( [ indexOneBased , indexOneBased + 1 ] , "" )
38
+ } )
39
+ ) ;
40
+ }
44
41
}
45
42
} ;
46
43
}
You can’t perform that action at this time.
0 commit comments