Skip to content

Commit 40c9381

Browse files
committed
feat(4.2.4): fixer support
1 parent 8b28131 commit 40c9381

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/4.2.4.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,28 @@
99
「・」と「・」
1010
*/
1111
import {isUserWrittenNode} from "./util/node-util";
12-
export default function (context) {
13-
let {Syntax, RuleError, report, getSource} = context;
12+
import {matchCaptureGroupAll} from "./util/match-index";
13+
function reporter(context) {
14+
let {Syntax, RuleError, report, fixer, getSource} = context;
1415
return {
1516
[Syntax.Str](node){
1617
if (!isUserWrittenNode(node, context)) {
1718
return;
1819
}
19-
let text = getSource(node);
20+
const text = getSource(node);
2021
// 和文で半角の・は利用しない
21-
var matchHanNakaguro = //;
22-
var index = text.search(matchHanNakaguro);
23-
if (index !== -1) {
24-
return report(node, new RuleError("カタカナ複合語を区切る場合または同格の語句を並列する場合には全角の中黒(・)を使用します。", index));
25-
}
22+
const matchHanNakaguro = /()/g;
23+
matchCaptureGroupAll(text, matchHanNakaguro).forEach(match => {
24+
const {index} = match;
25+
report(node, new RuleError("カタカナ複合語を区切る場合または同格の語句を並列する場合には全角の中黒(・)を使用します。", {
26+
column: index,
27+
fix: fixer.replaceTextRange([index, index + 1], "・")
28+
}));
29+
})
2630
}
2731
};
32+
}
33+
export default {
34+
linter: reporter,
35+
fixer: reporter
2836
}

0 commit comments

Comments
 (0)