Skip to content

Commit 8d032fb

Browse files
authoredMar 10, 2021
fix(2.2.2): 〜つの慣用句に対応 (#85)
1 parent ed2fd87 commit 8d032fb

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed
 

‎src/2.2.2.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ function reporter(context) {
156156
};
157157

158158
// ignorePatternにマッチしたらmatchFnを呼ばないようにする(エラーを無視する)
159-
const ignoreWhenMatched = (ignorePattern, matchFn) => {
159+
const ignoreWhenMatched = (ignorePatterns, matchFn) => {
160160
return (text, pattern, match) => {
161-
if (ignorePattern.test(text)) {
161+
if (ignorePatterns.some(p => p.test(text))) {
162162
return null;
163163
} else {
164164
return matchFn(text, pattern, match);
@@ -172,9 +172,19 @@ function reporter(context) {
172172
matchToReplace(
173173
text,
174174
/([]+)[]/g,
175-
ignoreWhenMatched(/(|)([]+)[]/g, toNumber)
175+
ignoreWhenMatched([/(|)([]+)[]/g], toNumber)
176+
);
177+
matchToReplace(
178+
text,
179+
/([]+)/g,
180+
ignoreWhenMatched(
181+
[
182+
/[](|||||||[]|)/g,
183+
/(||[]|||鹿)[]/g
184+
],
185+
toNumber
186+
)
176187
);
177-
matchToReplace(text, /([]+)/g, toNumber);
178188
matchToReplace(text, /([]+)/g, toNumber);
179189
matchToReplace(text, /([]+)/g, toNumber);
180190
matchToReplace(text, /([]+)/g, toNumber);

‎test/2.2.2-test.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,24 @@ tester.run("2.2.2.算用数字と漢数字の使い分け", rule, {
9797
"五大陸",
9898
"数十億",
9999
"何十万",
100-
"しばしば数十万行以上に"
100+
"しばしば数十万行以上に",
101+
"二つ返事でOKした",
102+
"三つ子の魂百まで",
103+
"一つひとつ確かめる",
104+
"ミシュラン二つ星",
105+
"三つ編にする",
106+
"四つ葉のクローバー",
107+
"四つ橋線",
108+
"二つと無い宝石",
109+
"二つとない宝石",
110+
"二つに一つしかない",
111+
"ただ一つの弱点",
112+
"唯一つの欠点",
113+
"女手一つで育てた",
114+
"男手一つで育てた",
115+
"人を呪わば穴二つ",
116+
"瓜二つの姉妹",
117+
"馬鹿の一つ覚えだ"
101118
],
102119
invalid: [
103120
{

0 commit comments

Comments
 (0)