@@ -34,15 +34,11 @@ const reporter = (context, options = {}) => {
3434 const preferPeriodMark = options . periodMark || defaultOptions . periodMark ;
3535 // 優先する句点記号は常に句点として許可される
3636 const allowPeriodMarks = ( options . allowPeriodMarks || defaultOptions . allowPeriodMarks ) . concat ( preferPeriodMark ) ;
37- const allowEmojiAtEnd = options . allowEmojiAtEnd !== undefined
38- ? options . allowEmojiAtEnd
39- : defaultOptions . allowEmojiAtEnd ;
40- const forceAppendPeriod = options . forceAppendPeriod !== undefined
41- ? options . forceAppendPeriod
42- : defaultOptions . forceAppendPeriod ;
43- const checkFootnote = options . checkFootnote !== undefined
44- ? options . checkFootnote
45- : defaultOptions . checkFootnote ;
37+ const allowEmojiAtEnd =
38+ options . allowEmojiAtEnd !== undefined ? options . allowEmojiAtEnd : defaultOptions . allowEmojiAtEnd ;
39+ const forceAppendPeriod =
40+ options . forceAppendPeriod !== undefined ? options . forceAppendPeriod : defaultOptions . forceAppendPeriod ;
41+ const checkFootnote = options . checkFootnote !== undefined ? options . checkFootnote : defaultOptions . checkFootnote ;
4642 // 脚注のNode Typeを定義(TxtASTの定義外)
4743 const FootnoteNodes = [
4844 // https://github.com/orangain/textlint-plugin-review
@@ -52,7 +48,12 @@ const reporter = (context, options = {}) => {
5248 "Definition"
5349 ] ;
5450 const ignoredNodeTypes = [
55- Syntax . ListItem , Syntax . Link , Syntax . Code , Syntax . Image , Syntax . BlockQuote , Syntax . Emphasis
51+ Syntax . ListItem ,
52+ Syntax . Link ,
53+ Syntax . Code ,
54+ Syntax . Image ,
55+ Syntax . BlockQuote ,
56+ Syntax . Emphasis
5657 ] . concat ( checkFootnote ? FootnoteNodes : [ ] ) ;
5758 return {
5859 [ Syntax . Paragraph ] ( node ) {
@@ -81,35 +82,47 @@ const reporter = (context, options = {}) => {
8182 }
8283 // 文末がスペースである場合はスペースを削除する
8384 if ( / \s / . test ( periodMark ) ) {
84- report ( lastNode , new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。末尾に不要なスペースがあります。` , {
85- index,
86- fix : fixer . replaceTextRange ( [ index , index + periodMark . length ] , "" )
87- } ) ) ;
88- return
85+ report (
86+ lastNode ,
87+ new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。末尾に不要なスペースがあります。` , {
88+ index,
89+ fix : fixer . replaceTextRange ( [ index , index + periodMark . length ] , "" )
90+ } )
91+ ) ;
92+ return ;
8993 }
9094 // 典型的なパターンは自動的に`preferPeriodMark`に置き換える
9195 // 例) "." であるなら "。"に変換
9296 if ( classicPeriodMarkPattern . test ( periodMark ) ) {
93- report ( lastNode , new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。` , {
94- index : index ,
95- fix : fixer . replaceTextRange ( [ index , index + preferPeriodMark . length ] , preferPeriodMark )
96- } ) ) ;
97+ report (
98+ lastNode ,
99+ new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。` , {
100+ index : index ,
101+ fix : fixer . replaceTextRange ( [ index , index + preferPeriodMark . length ] , preferPeriodMark )
102+ } )
103+ ) ;
97104 } else {
98105 // 句点を忘れているパターン
99106 if ( forceAppendPeriod ) {
100107 // `forceAppendPeriod`のオプションがtrueならば、自動で句点を追加する。
101- report ( lastNode , new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。` , {
102- index : index ,
103- fix : fixer . replaceTextRange ( [ index + 1 , index + 1 ] , preferPeriodMark )
104- } ) ) ;
108+ report (
109+ lastNode ,
110+ new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。` , {
111+ index : index ,
112+ fix : fixer . replaceTextRange ( [ index + 1 , index + 1 ] , preferPeriodMark )
113+ } )
114+ ) ;
105115 } else {
106- report ( lastNode , new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。` , {
107- index : index
108- } ) ) ;
116+ report (
117+ lastNode ,
118+ new RuleError ( `文末が"${ preferPeriodMark } "で終わっていません。` , {
119+ index : index
120+ } )
121+ ) ;
109122 }
110123 }
111124 }
112- }
125+ } ;
113126} ;
114127
115128module . exports = {
0 commit comments