From f272eb17d19f92ae4fbfd060fce8229e6ce57c02 Mon Sep 17 00:00:00 2001 From: piyo Date: Fri, 26 Apr 2024 18:23:51 +0900 Subject: [PATCH 1/2] fix(ja-nakaguro-or-halfwidth-space-between-katakana): replace match-index with String.prototype.matchAll --- .../src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/src/index.js b/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/src/index.js index a10fa52..9080f31 100644 --- a/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/src/index.js +++ b/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/src/index.js @@ -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(); @@ -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 }) ); } - }); + } } }; }; From 22568f9d98f2ba8a9a83443514a94d278639ae46 Mon Sep 17 00:00:00 2001 From: piyo Date: Fri, 26 Apr 2024 18:59:57 +0900 Subject: [PATCH 2/2] deps(ja-nakaguro-or-halfwidth-space-between-katakana) remove match-index --- .../package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/package.json b/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/package.json index 9ddc8bb..655f23b 100644 --- a/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/package.json +++ b/packages/textlint-rule-ja-nakaguro-or-halfwidth-space-between-katakana/package.json @@ -32,7 +32,6 @@ "textlint-scripts": "^13.3.3" }, "dependencies": { - "match-index": "^1.0.3", "textlint-rule-helper": "^2.2.4" } }