Skip to content

Commit d7d82e8

Browse files
committed
chore(options): min_intervalのバリデーションを追加
1 parent 93005fe commit d7d82e8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ textlint --rule no-doubled-joshi README.md
6363
{
6464
"rules": {
6565
"no-doubled-joshi": {
66-
// 助詞のtoken同士の距離が2以下ならエラーにする
67-
"min_interval" : 2,
66+
// 助詞のtoken同士の間隔値が1以下ならエラーにする
67+
// 間隔値は1から開始されます
68+
"min_interval" : 1,
6869
// 例外を許可するかどうか
6970
"strict": false,
7071
// 助詞のうち「も」「や」は複数回の出現を許す

src/no-doubled-joshi.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export interface Options {
111111
const report: TextlintRuleModule<Options> = function (context, options = {}) {
112112
const helper = new RuleHelper(context);
113113
// 最低間隔値
114-
const minInterval = options.min_interval || defaultOptions.min_interval;
114+
const minInterval = options.min_interval !== undefined ? options.min_interval : defaultOptions.min_interval;
115+
if (minInterval <= 0) {
116+
throw new Error("options.min_intervalは1以上の数値を指定してください");
117+
}
115118
const isStrict = options.strict || defaultOptions.strict;
116119
const allow = options.allow || defaultOptions.allow;
117120
const separatorCharacters = options.separatorCharacters || defaultOptions.separatorCharacters;

0 commit comments

Comments
 (0)