File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana Expand file tree Collapse file tree 2 files changed +5
-6
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
"textlint-rule-helper" : " ^2.2.4"
37
36
}
38
37
}
Original file line number Diff line number Diff line change 5
5
中黒または半角スペースを用いてカタカナ語を区切ります。
6
6
*/
7
7
import { RuleHelper } from "textlint-rule-helper" ;
8
- import { matchCaptureGroupAll } from "match-index" ;
8
+
9
9
module . exports = function ( context ) {
10
10
const { Syntax, RuleError, report, getSource } = context ;
11
11
const helper = new RuleHelper ( ) ;
@@ -16,18 +16,18 @@ module.exports = function (context) {
16
16
}
17
17
const text = getSource ( node ) ;
18
18
// カタカナ(カタカナ以外)カタカナ のパターンを取り出す
19
- matchCaptureGroupAll ( text , / [ ァ - ヶ ー ] ( [ ^ [ ァ - ヶ ー ] ) [ ァ - ヶ ー ] / ) . forEach ( ( match ) => {
19
+ for ( const match of text . matchAll ( / [ ァ - ヶ ー ] ( [ ^ [ ァ - ヶ ー ] ) [ ァ - ヶ ー ] / g ) ) {
20
20
// カタカナの間を全角スペースでは区切らない
21
- const { text } = match ;
21
+ const text = match [ 1 ] ;
22
22
if ( text === " " ) {
23
23
report (
24
24
node ,
25
25
new RuleError ( "カタカナ語間は中黒(・)または半角スペースを用いてカタカナ語を区切ります" , {
26
- index : match . index
26
+ index : match . index + 1
27
27
} )
28
28
) ;
29
29
}
30
- } ) ;
30
+ }
31
31
}
32
32
} ;
33
33
} ;
You can’t perform that action at this time.
0 commit comments