Skip to content

Commit d81b138

Browse files
committed
refactor(rule): move all rule to index-based reporter
1 parent 238df08 commit d81b138

27 files changed

+48
-64
lines changed

src/1.1.2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function mixer(context) {
3131
if (index !== -1) {
3232
report(node, {
3333
message: "見出しの文末には、句点(。)を付けません。",
34-
column: index,
34+
index: index,
3535
fix: fixer.removeRange([index, index + 1])
3636
});
3737
}

src/1.2.1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const reporter = (context) => {
4444
const indexOfSymbol = match.index;
4545
report(node, {
4646
message: "句読点には全角の「、」と「。」を使います。和文の句読点としてピリオド(.)とカンマ(,)を使用しません。",
47-
column: indexOfSymbol,
47+
index: indexOfSymbol,
4848
fix: fixer.replaceTextRange([indexOfSymbol, indexOfSymbol + 1], symbol)
4949
});
5050
})

src/1.2.2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function report(context) {
2626
const symbol = replaceSymbol[text[index]];
2727
report(node, {
2828
message: "全角のピリオドとカンマは使用しません。",
29-
column: index,
29+
index: index,
3030
fix: fixer.replaceTextRange([index, index + 1], symbol)
3131
});
3232
}

src/2.1.10.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function reporter(context) {
2727
matchCaptureGroupAll(matchedString, strictMatchReg).forEach(subMatch => {
2828
const {index} = subMatch;
2929
report(node, new RuleError("小数点には「ピリオド」を使います。", {
30-
column: match.index + index,
30+
index: match.index + index,
3131
fix: fixer.replaceTextRange([match.index + index, match.index + index + 1], ".")
3232
}));
3333
});

src/2.1.2.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export default function (context) {
2525
for (let index = 0; index < strArray.length; index++) {
2626
const item = strArray[index];
2727
if (kanjiRegExp.test(item) && !isJoyo(item)) {
28-
report(node, new RuleError("「" + item + "」は「常用漢字表」外の漢字です。", index));
28+
report(node, new RuleError("「" + item + "」は「常用漢字表」外の漢字です。", {
29+
index
30+
}));
2931
}
3032
}
3133
}

src/2.1.5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function reporter(context) {
4444
const {index, text} = match;
4545
report(node, {
4646
message: "カタカナは「全角」で表記します。",
47-
column: index,
47+
index: index,
4848
fix: fixer.replaceTextRange([index, index + text.length], toZenkaku(text))
4949
});
5050

src/2.1.8.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function reporter(context) {
2525
const {index, text} = match;
2626
report(node, {
2727
message: "算用数字は「半角」で表記します。",
28-
column: index,
28+
index: index,
2929
fix: fixer.replaceTextRange([index, index + text.length], toHankaku(text))
3030
})
3131
});

src/2.1.9.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function reporter(context) {
2525
const {index, text} = match;
2626
report(node, {
2727
message: "アルファベットは「半角」で表記します。",
28-
column: index,
28+
index: index,
2929
fix: fixer.replaceTextRange([index, index + text.length], toHankaku(text))
3030
})
3131
});

src/2.2.2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function reporter(context) {
125125
});
126126
const ruleError = new RuleError(`${matchedString} => ${expected}
127127
数量を表現し、数を数えられるものは算用数字を使用します。任意の数に置き換えても通用する語句がこれに該当します。`, {
128-
column: index,
128+
index: index,
129129
fix: fixer.replaceTextRange([index, index + matchedString.length], expected)
130130
});
131131
report(node, ruleError);
@@ -142,7 +142,7 @@ function reporter(context) {
142142
const index = match.index;
143143
report(node, new RuleError(`${matchedString} => ${expected}
144144
慣用的表現、熟語、概数、固有名詞、副詞など、漢数字を使用することが一般的な語句では漢数字を使います。`, {
145-
column: index,
145+
index: index,
146146
fix: fixer.replaceTextRange([index, index + matchedString.length], expected)
147147
}));
148148
};

src/3.1.1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function reporter(context) {
2222
const reportMatch = (match) => {
2323
const {index} = match;
2424
report(node, new RuleError("原則として、全角文字と半角文字の間にスペースを入れません。", {
25-
column: match.index,
25+
index: match.index,
2626
fix: fixer.replaceTextRange([index, index + 1], "")
2727
}));
2828
};

0 commit comments

Comments
 (0)