99本文が「常体」である場合、箇条書きには「常体」または「体言止め」を使います。「敬体」は使いません。
1010いずれの場合も、ひとまとまりの箇条書きでは、敬体と常体を混在させません。文末に句点(。)を付けるかどうかも統一します。
1111 */
12- import { analyzeDesumasu , analyzeDearu } from "analyze-desumasu-dearu" ;
13- export default function ( context ) {
14- let { Syntax, RuleError, report, getSource} = context ;
12+ import { analyzeDesumasu , analyzeDearu } from "analyze-desumasu-dearu" ;
13+ module . exports = function ( context ) {
14+ let { Syntax, RuleError, report, getSource } = context ;
1515 let desumasuList = [ ] ;
1616 let dearuList = [ ] ;
1717 // 。付きのListItem
1818 let withPointList = [ ] ;
1919 // 。なしのListItem
2020 let withoutPointList = [ ] ;
21-
21+
2222 function resetList ( ) {
2323 dearuList = [ ] ;
2424 desumasuList = [ ] ;
2525 withPointList = [ ] ;
2626 withoutPointList = [ ] ;
2727 }
28-
29- function reportPointResult ( nodeList , { shouldUsePoint} ) {
28+
29+ function reportPointResult ( nodeList , { shouldUsePoint } ) {
3030 nodeList . forEach ( node => {
3131 let message ;
3232 if ( shouldUsePoint ) {
33- message = `箇条書きの文末に句点(。)を付けて下さい。\n箇条書きの文末に句点(。)を付けるかを統一します。`
33+ message = `箇条書きの文末に句点(。)を付けて下さい。\n箇条書きの文末に句点(。)を付けるかを統一します。` ;
3434 } else {
35- message = `箇条書きの文末から句点(。)を外して下さい。\n箇条書きの文末に句点(。)を付けるかを統一します。`
35+ message = `箇条書きの文末から句点(。)を外して下さい。\n箇条書きの文末に句点(。)を付けるかを統一します。` ;
3636 }
3737 report ( node , new RuleError ( message ) ) ;
3838 } ) ;
3939 }
40-
41- function reportDesumaruDearuResult ( list , { desumasu, dearu} ) {
42- list . forEach ( ( { node, matches} ) => {
40+
41+ function reportDesumaruDearuResult ( list , { desumasu, dearu } ) {
42+ list . forEach ( ( { node, matches } ) => {
4343 matches . forEach ( match => {
4444 let message ;
4545 if ( desumasu ) {
46- message = `箇条書きを敬体(ですます調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${ match . value } "が常体(である調)です。`
46+ message = `箇条書きを敬体(ですます調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${ match . value } "が常体(である調)です。` ;
4747 } else if ( dearu ) {
48- message = `箇条書きを常体(である調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${ match . value } "が敬体(ですます調)です。`
48+ message = `箇条書きを常体(である調)に統一して下さい。\nひとまとまりの箇条書きでは、敬体と常体を混在させません。\n"${ match . value } "が敬体(ですます調)です。` ;
4949 }
50- report ( node , new RuleError ( message , {
51- line : match . lineNumber - 1 ,
52- column : match . columnIndex
53- } ) ) ;
50+ report (
51+ node ,
52+ new RuleError ( message , {
53+ line : match . lineNumber - 1 ,
54+ column : match . columnIndex
55+ } )
56+ ) ;
5457 } ) ;
5558 } ) ;
5659 }
@@ -80,8 +83,8 @@ export default function (context) {
8083
8184 // 敬体(ですます調)あるいは常体(である調)なのかのチェック
8285 function countingDesumasuDearu ( desumasuList , dearuList ) {
83- let desumasuCount = desumasuList . reduce ( ( count , { matches} ) => count + matches . length , 0 ) ;
84- let dearuCount = dearuList . reduce ( ( count , { matches} ) => count + matches . length , 0 ) ;
86+ let desumasuCount = desumasuList . reduce ( ( count , { matches } ) => count + matches . length , 0 ) ;
87+ let dearuCount = dearuList . reduce ( ( count , { matches } ) => count + matches . length , 0 ) ;
8588 if ( desumasuCount === 0 || dearuCount === 0 ) {
8689 return ;
8790 }
@@ -102,12 +105,12 @@ export default function (context) {
102105 } ) ;
103106 }
104107 }
105-
108+
106109 return {
107- [ Syntax . List ] ( node ) {
108- resetList ( )
110+ [ Syntax . List ] ( node ) {
111+ resetList ( ) ;
109112 } ,
110- [ Syntax . ListItem ] ( node ) {
113+ [ Syntax . ListItem ] ( node ) {
111114 let text = getSource ( node ) ;
112115 // 末尾に。があるかが統一されているのチェック
113116 let matchPointReg = / 。 ( \s * ?) $ / ;
@@ -134,10 +137,10 @@ export default function (context) {
134137 } ) ;
135138 }
136139 } ,
137- [ `${ Syntax . List } :exit` ] ( node ) {
140+ [ `${ Syntax . List } :exit` ] ( node ) {
138141 countingPoint ( withPointList , withoutPointList ) ;
139-
142+
140143 countingDesumasuDearu ( desumasuList , dearuList ) ;
141144 }
142- }
143- }
145+ } ;
146+ } ;
0 commit comments