Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ja-nakaguro-or-halfwidth-space-between-katakana): replace match-index with String.prototype.matchAll #70

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"textlint-scripts": "^13.3.3"
},
"dependencies": {
"match-index": "^1.0.3",
"textlint-rule-helper": "^2.2.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
中黒または半角スペースを用いてカタカナ語を区切ります。
*/
import { RuleHelper } from "textlint-rule-helper";
import { matchCaptureGroupAll } from "match-index";

module.exports = function (context) {
const { Syntax, RuleError, report, getSource } = context;
const helper = new RuleHelper();
Expand All @@ -16,18 +16,18 @@ module.exports = function (context) {
}
const text = getSource(node);
// カタカナ(カタカナ以外)カタカナ のパターンを取り出す
matchCaptureGroupAll(text, /[ァ-ヶー]([^[ァ-ヶー])[ァ-ヶー]/).forEach((match) => {
for (const match of text.matchAll(/[ァ-ヶー]([^[ァ-ヶー])[ァ-ヶー]/g)) {
// カタカナの間を全角スペースでは区切らない
const { text } = match;
const text = match[1];
if (text === " ") {
report(
node,
new RuleError("カタカナ語間は中黒(・)または半角スペースを用いてカタカナ語を区切ります", {
index: match.index
index: match.index + 1
})
);
}
});
}
}
};
};
Loading