File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed
packages/textlint-rule-ja-no-space-between-full-width Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 3232 "textlint-scripts" : " ^13.3.3"
3333 },
3434 "dependencies" : {
35- "match-index" : " ^1.0.3" ,
3635 "regx" : " ^1.0.4" ,
3736 "textlint-rule-helper" : " ^2.2.4"
3837 }
Original file line number Diff line number Diff line change 66 ただしカタカナ複合語の場合を除きます。
77 */
88import { RuleHelper } from "textlint-rule-helper" ;
9- import { matchAll } from "match-index" ;
109import regx from "regx" ;
1110const rx = regx ( "g" ) ;
1211const japaneseRegExp =
@@ -24,23 +23,21 @@ function reporter(context) {
2423 // 全角同士の間は半角スペースを入れない
2524 const matchReg = rx `${ japaneseRegExp } ( )${ japaneseRegExp } ` ;
2625 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 ] ;
2928 // ただしカタカナ複合語の場合を除きます。
3029 if ( katakakana . test ( input ) ) {
3130 return ;
3231 }
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+ }
4441 }
4542 } ;
4643}
You can’t perform that action at this time.
0 commit comments