Skip to content

Commit 648cb8e

Browse files
authored
fix(ja-nakaguro-or-halfwidth-space-between-katakana): replace match-index with String.prototype.matchAll (#70)
* fix(ja-nakaguro-or-halfwidth-space-between-katakana): replace match-index with String.prototype.matchAll * deps(ja-nakaguro-or-halfwidth-space-between-katakana) remove match-index
1 parent 9d642c1 commit 648cb8e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"textlint-scripts": "^13.3.3"
3333
},
3434
"dependencies": {
35-
"match-index": "^1.0.3",
3635
"textlint-rule-helper": "^2.2.4"
3736
}
3837
}

packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
中黒または半角スペースを用いてカタカナ語を区切ります。
66
*/
77
import { RuleHelper } from "textlint-rule-helper";
8-
import { matchCaptureGroupAll } from "match-index";
8+
99
module.exports = function (context) {
1010
const { Syntax, RuleError, report, getSource } = context;
1111
const helper = new RuleHelper();
@@ -16,18 +16,18 @@ module.exports = function (context) {
1616
}
1717
const text = getSource(node);
1818
// カタカナ(カタカナ以外)カタカナ のパターンを取り出す
19-
matchCaptureGroupAll(text, /[-]([^[-])[-]/).forEach((match) => {
19+
for (const match of text.matchAll(/[-]([^[-])[-]/g)) {
2020
// カタカナの間を全角スペースでは区切らない
21-
const { text } = match;
21+
const text = match[1];
2222
if (text === " ") {
2323
report(
2424
node,
2525
new RuleError("カタカナ語間は中黒(・)または半角スペースを用いてカタカナ語を区切ります", {
26-
index: match.index
26+
index: match.index + 1
2727
})
2828
);
2929
}
30-
});
30+
}
3131
}
3232
};
3333
};

0 commit comments

Comments
 (0)