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 3232 "textlint-scripts" : " ^13.3.3"
3333 },
3434 "dependencies" : {
35- "match-index" : " ^1.0.3" ,
3635 "textlint-rule-helper" : " ^2.2.4"
3736 }
3837}
Original file line number Diff line number Diff line change 55 中黒または半角スペースを用いてカタカナ語を区切ります。
66 */
77import { RuleHelper } from "textlint-rule-helper" ;
8- import { matchCaptureGroupAll } from "match-index" ;
8+
99module . exports = function ( context ) {
1010 const { Syntax, RuleError, report, getSource } = context ;
1111 const helper = new RuleHelper ( ) ;
@@ -16,18 +16,18 @@ module.exports = function (context) {
1616 }
1717 const text = getSource ( node ) ;
1818 // カタカナ(カタカナ以外)カタカナ のパターンを取り出す
19- matchCaptureGroupAll ( text , / [ ァ - ヶ ー ] ( [ ^ [ ァ - ヶ ー ] ) [ ァ - ヶ ー ] / ) . forEach ( ( match ) => {
19+ for ( const match of text . matchAll ( / [ ァ - ヶ ー ] ( [ ^ [ ァ - ヶ ー ] ) [ ァ - ヶ ー ] / g ) ) {
2020 // カタカナの間を全角スペースでは区切らない
21- const { text } = match ;
21+ const text = match [ 1 ] ;
2222 if ( text === " " ) {
2323 report (
2424 node ,
2525 new RuleError ( "カタカナ語間は中黒(・)または半角スペースを用いてカタカナ語を区切ります" , {
26- index : match . index
26+ index : match . index + 1
2727 } )
2828 ) ;
2929 }
30- } ) ;
30+ }
3131 }
3232 } ;
3333} ;
You can’t perform that action at this time.
0 commit comments