File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 6
6
原文でセミコロンが使われている場合も、和文では使用しません。
7
7
*/
8
8
import { isUserWrittenNode } from "./util/node-util" ;
9
+ import { matchCaptureGroupAll } from "./util/match-index" ;
10
+ import regx from 'regx' ;
11
+ import { japaneseRegExp } from "./util/regexp" ;
12
+ const rx = regx ( "g" ) ;
9
13
export default function ( context ) {
10
14
let { Syntax, RuleError, report, getSource} = context ;
11
15
return {
12
16
[ Syntax . Str ] ( node ) {
13
17
if ( ! isUserWrittenNode ( node , context ) ) {
14
18
return ;
15
19
}
16
- let text = getSource ( node ) ;
20
+ const text = getSource ( node ) ;
17
21
// "和文;" というような半角;は使用しない
18
- var matchHanQuestion = / ( [ \u3400 - \u4DBF \u4E00 - \u9FFF \uF900 - \uFAFF ] | [ \uD840 - \uD87F ] [ \uDC00 - \uDFFF ] | [ ぁ - ん ァ - ヶ ] ) ; / ;
19
- var index = text . search ( matchHanQuestion ) ;
20
- if ( index !== - 1 ) {
21
- return report ( node , new RuleError ( "原則として和文ではセミコロン(;)を使用しません。" , index + 1 ) )
22
- }
22
+ const matchRegExp = rx `(?:${ japaneseRegExp } )(;)` ;
23
+ matchCaptureGroupAll ( text , matchRegExp ) . forEach ( match => {
24
+ const { index} = match ;
25
+ report ( node , new RuleError ( "原則として和文ではセミコロン(;)を使用しません。" , {
26
+ column : index
27
+ } ) )
28
+ } )
23
29
}
24
30
} ;
25
31
}
You can’t perform that action at this time.
0 commit comments