Skip to content

Commit 55dd798

Browse files
committed
fix(rule): Make options types
1 parent f71c272 commit 55dd798

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/no-doubled-joshi.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// LICENSE : MIT
22
"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";
66
import {
77
is助詞Token, is読点Token,
88
concatJoishiTokens,
99
createKeyFromKey,
1010
restoreToSurfaceFromKey
1111
} 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";
1414

1515
const StringSource = require("textlint-util-to-string");
1616

@@ -62,6 +62,13 @@ const defaultOptions = {
6262
separatorChars: ["。", "?", "!", "?", "!"]
6363
};
6464

65+
66+
export interface Options {
67+
min_interval?: number;
68+
strict?: boolean;
69+
allow?: string[];
70+
separatorChars?: string[]
71+
}
6572
/*
6673
1. Paragraph Node -> text
6774
2. text -> sentences
@@ -70,13 +77,13 @@ const defaultOptions = {
7077
7178
TODO: need abstraction
7279
*/
73-
const report: TextlintRuleModule = function (context, options = {}) {
80+
const report: TextlintRuleModule = function (context, options: TextlintRuleOptions<Options> = {}) {
7481
const helper = new RuleHelper(context);
7582
// 最低間隔値
7683
const minInterval = options.min_interval || defaultOptions.min_interval;
7784
const isStrict = options.strict || defaultOptions.strict;
7885
const allow = options.allow || defaultOptions.allow;
79-
const {Syntax, report, RuleError} = context;
86+
const { Syntax, report, RuleError } = context;
8087
return {
8188
[Syntax.Paragraph](node) {
8289
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {

0 commit comments

Comments
 (0)