1
1
// LICENSE : MIT
2
2
"use strict" ;
3
- import { RuleHelper } from "textlint-rule-helper" ;
4
- import { splitAST as splitSentences , Syntax as SentenceSyntax , SentenceNode } from "sentence-splitter" ;
5
- import { getTokenizer , KuromojiToken } from "kuromojin" ;
3
+ import { RuleHelper } from "textlint-rule-helper" ;
4
+ import { splitAST as splitSentences , Syntax as SentenceSyntax , SentenceNode } from "sentence-splitter" ;
5
+ import { getTokenizer , KuromojiToken } from "kuromojin" ;
6
6
import {
7
7
is助詞Token , is読点Token ,
8
8
concatJoishiTokens ,
9
9
createKeyFromKey ,
10
10
restoreToSurfaceFromKey
11
11
} from "./token-utils" ;
12
- import { TextlintRuleModule } from "@textlint/types" ;
13
- import { TxtNode } from "@textlint/types/lib/ast-node-types/src" ;
12
+ import { TextlintRuleModule , TextlintRuleOptions } from "@textlint/types" ;
13
+ import { TxtNode } from "@textlint/types/lib/ast-node-types/src" ;
14
14
15
15
const StringSource = require ( "textlint-util-to-string" ) ;
16
16
@@ -62,6 +62,13 @@ const defaultOptions = {
62
62
separatorChars : [ "。" , "?" , "!" , "?" , "!" ]
63
63
} ;
64
64
65
+
66
+ export interface Options {
67
+ min_interval ?: number ;
68
+ strict ?: boolean ;
69
+ allow ?: string [ ] ;
70
+ separatorChars ?: string [ ]
71
+ }
65
72
/*
66
73
1. Paragraph Node -> text
67
74
2. text -> sentences
@@ -70,13 +77,13 @@ const defaultOptions = {
70
77
71
78
TODO: need abstraction
72
79
*/
73
- const report : TextlintRuleModule = function ( context , options = { } ) {
80
+ const report : TextlintRuleModule = function ( context , options : TextlintRuleOptions < Options > = { } ) {
74
81
const helper = new RuleHelper ( context ) ;
75
82
// 最低間隔値
76
83
const minInterval = options . min_interval || defaultOptions . min_interval ;
77
84
const isStrict = options . strict || defaultOptions . strict ;
78
85
const allow = options . allow || defaultOptions . allow ;
79
- const { Syntax, report, RuleError} = context ;
86
+ const { Syntax, report, RuleError } = context ;
80
87
return {
81
88
[ Syntax . Paragraph ] ( node ) {
82
89
if ( helper . isChildNode ( node , [ Syntax . Link , Syntax . Image , Syntax . BlockQuote , Syntax . Emphasis ] ) ) {
0 commit comments