@@ -36,7 +36,7 @@ const replaceTokenWith = (matcherToken: any, actualToken: KuromojiToken, special
3636 * @returns {string }
3737 */
3838const tokensToString = ( tokens : KuromojiToken [ ] ) => {
39- return tokens . map ( token => token . surface_form ) . join ( "" ) ;
39+ return tokens . map ( ( token ) => token . surface_form ) . join ( "" ) ;
4040} ;
4141
4242/**
@@ -62,8 +62,16 @@ const isTokensAllowed = (tokens: KuromojiToken[], allows: string[]) => {
6262 * @param {*[] } actualTokens
6363 * @returns {null|string }
6464 */
65- const createExpected = ( { expected, matcherTokens, skipped, actualTokens } : {
66- expected ?: string , matcherTokens : any [ ] , skipped : boolean [ ] , actualTokens : KuromojiToken [ ]
65+ const createExpected = ( {
66+ expected,
67+ matcherTokens,
68+ skipped,
69+ actualTokens
70+ } : {
71+ expected ?: string ;
72+ matcherTokens : any [ ] ;
73+ skipped : boolean [ ] ;
74+ actualTokens : KuromojiToken [ ] ;
6775} ) : null | string => {
6876 if ( ! expected ) {
6977 return null ;
@@ -89,7 +97,19 @@ const createExpected = ({ expected, matcherTokens, skipped, actualTokens }: {
8997 return resultText ;
9098} ;
9199
92- const createMessage = ( { id, text, matcherTokens, skipped, actualTokens } : { id : string , text : string , matcherTokens : any [ ] , skipped : boolean [ ] , actualTokens : KuromojiToken [ ] } ) => {
100+ const createMessage = ( {
101+ id,
102+ text,
103+ matcherTokens,
104+ skipped,
105+ actualTokens
106+ } : {
107+ id : string ;
108+ text : string ;
109+ matcherTokens : any [ ] ;
110+ skipped : boolean [ ] ;
111+ actualTokens : KuromojiToken [ ] ;
112+ } ) => {
93113 let resultText = text ;
94114 let actualTokenIndex = 0 ;
95115 matcherTokens . forEach ( ( token , index ) => {
@@ -115,8 +135,8 @@ export interface Options {
115135 dictOptions ?: {
116136 [ index : string ] : {
117137 disabled ?: boolean ;
118- allows ?: string [ ]
119- }
138+ allows ?: string [ ] ;
139+ } ;
120140 } ;
121141 // - 無視したいNode typeを配列で指定
122142 // - Node typeは <https://textlint.github.io/docs/txtnode.html#type> を参照
@@ -132,7 +152,7 @@ const reporter: TextlintRuleModule<Options> = (context, options = {}) => {
132152 } ;
133153 const dictOptions = options . dictOptions || DefaultOptions . dictOptions ;
134154 // "disabled": trueな辞書は取り除く
135- const enabledDictionaryList = Dictionary . filter ( dict => {
155+ const enabledDictionaryList = Dictionary . filter ( ( dict ) => {
136156 const dictOption = dictOptions [ dict . id ] || { } ;
137157 const disabled = typeof dictOption . disabled === "boolean" ? dictOption . disabled : dict . disabled ;
138158 return ! disabled ;
@@ -144,14 +164,14 @@ const reporter: TextlintRuleModule<Options> = (context, options = {}) => {
144164 {
145165 ignoreNodeTypes : skipNodeTypes
146166 } ,
147- report => {
167+ ( report ) => {
148168 return {
149169 [ Syntax . Paragraph ] ( node ) {
150170 const source = new StringSource ( node ) ;
151171 const text = source . toString ( ) ;
152- return tokenize ( text ) . then ( currentTokens => {
172+ return tokenize ( text ) . then ( ( currentTokens ) => {
153173 const matchResults = matchAll ( currentTokens ) ;
154- matchResults . forEach ( matchResult => {
174+ matchResults . forEach ( ( matchResult ) => {
155175 const dictOption = dictOptions [ matchResult . dict . id ] || { } ;
156176 // "allows" オプションにマッチした場合はエラーを報告しない
157177 const allows = dictOption . allows || matchResult . dict . allows ;
@@ -162,21 +182,18 @@ const reporter: TextlintRuleModule<Options> = (context, options = {}) => {
162182 // エラー報告
163183 const firstToken = matchResult . tokens [ 0 ] ;
164184 const lastToken = matchResult . tokens [ matchResult . tokens . length - 1 ] ;
165- const firstWordIndex = source . originalIndexFromIndex (
166- Math . max ( firstToken . word_position - 1 , 0 )
167- ) || 0 ;
168- const lastWordIndex = source . originalIndexFromIndex (
169- Math . max ( lastToken . word_position - 1 , 0 )
170- ) || 0 ;
185+ const firstWordIndex =
186+ source . originalIndexFromIndex ( Math . max ( firstToken . word_position - 1 , 0 ) ) || 0 ;
187+ const lastWordIndex =
188+ source . originalIndexFromIndex ( Math . max ( lastToken . word_position - 1 , 0 ) ) || 0 ;
171189 // エラーメッセージ
172- const message =
173- createMessage ( {
174- id : matchResult . dict . id ,
175- text : matchResult . dict . message ,
176- matcherTokens : matchResult . dict . tokens ,
177- skipped : matchResult . skipped ,
178- actualTokens : matchResult . tokens
179- } ) ;
190+ const message = createMessage ( {
191+ id : matchResult . dict . id ,
192+ text : matchResult . dict . message ,
193+ matcherTokens : matchResult . dict . tokens ,
194+ skipped : matchResult . skipped ,
195+ actualTokens : matchResult . tokens
196+ } ) ;
180197 // 置換結果
181198 const expected = createExpected ( {
182199 expected : matchResult . dict . expected ,
0 commit comments