File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export default function (context) {
24
24
const { index} = match ;
25
25
report ( node , new RuleError ( "原則として和文ではセミコロン(;)を使用しません。" , {
26
26
column : index
27
- } ) )
27
+ } ) ) ;
28
28
} )
29
29
}
30
30
} ;
Original file line number Diff line number Diff line change @@ -10,20 +10,26 @@ Note: ここでのダッシュはU+2012-U+2015とする
10
10
https://ja.wikipedia.org/wiki/%E3%83%80%E3%83%83%E3%82%B7%E3%83%A5_%28%E8%A8%98%E5%8F%B7%29
11
11
*/
12
12
import { isUserWrittenNode } from "./util/node-util" ;
13
+ import { matchCaptureGroupAll } from "./util/match-index" ;
14
+ import regx from 'regx' ;
15
+ import { japaneseRegExp } from "./util/regexp" ;
16
+ const rx = regx ( "g" ) ;
13
17
export default function ( context ) {
14
18
let { Syntax, RuleError, report, getSource} = context ;
15
19
return {
16
20
[ Syntax . Str ] ( node ) {
17
21
if ( ! isUserWrittenNode ( node , context ) ) {
18
22
return ;
19
23
}
20
- let text = getSource ( node ) ;
24
+ const text = getSource ( node ) ;
21
25
// 和文でダッシュは使用しない
22
- var matchHanQuestion = / ( [ \u3400 - \u4DBF \u4E00 - \u9FFF \uF900 - \uFAFF ] | [ \uD840 - \uD87F ] [ \uDC00 - \uDFFF ] | [ ぁ - ん ァ - ヶ ] ) [ \u2012 - \u2015 ] / ;
23
- var index = text . search ( matchHanQuestion ) ;
24
- if ( index !== - 1 ) {
25
- return report ( node , new RuleError ( "原則として和文ではダッシュ(―)を使用しません。" , index + 1 ) )
26
- }
26
+ const matchRegExp = rx `(?:${ japaneseRegExp } )([\u2012-\u2015])` ;
27
+ matchCaptureGroupAll ( text , matchRegExp ) . forEach ( match => {
28
+ const { index} = match ;
29
+ report ( node , new RuleError ( "原則として和文ではダッシュ(―)を使用しません。" , {
30
+ column : index
31
+ } ) ) ;
32
+ } )
27
33
}
28
34
} ;
29
35
}
You can’t perform that action at this time.
0 commit comments