textlint-ja/textlint-rule-preset-JTF-style

backquoteを含む文字列の二重引用符チェック

ksato9700 opened this issue · 3 comments

backquote (`) を含む文字列の二重引用符(")チェックがうまく動かない場合があるようです。

再現手順

設定(textlintrc)

{
  "rules": {
    "preset-jtf-style": true
  }
}

試した文章(test.md)

"a" "`a`"

実行結果

$ npx textlint -c ./textlintrc test.md
/tmp/bugreport/test.md
  1:9  error  "の対となる"が見つかりません。""  jtf-style/4.3.5.二重引用符

✖ 1 problem (1 error, 0 warnings)

期待する結果

正常終了する

実際の結果

対となる二重引用符が見つからないというエラーになる

azu commented

ご報告ありがとうございます。

"`a`"

https://textlint.github.io/astexplorer/

AST的にNodeが次のように3つのNodeとして分解されます。

<Str><Code><Str>

個別の <Str> の中で " の対を探してるので見つけられてないみたいですね。
<Str><Str> を結合した中で探索するのが正しそうですね。

currentStrInParagraph.forEach((node) => {

azu commented

📝 同じことをする別のルールは、Paragraphの中身で ペアを探索して、Codeの中は無視する実装だった
https://github.com/textlint-rule/textlint-rule-no-unmatched-pair/blob/1a030f2eae0941dea534b77fe0ecb8a9dde9e098/src/textlint-rule-no-unmatched-pair.js これはこれでコード内にペアがあるとおかしくなりそうな気がする…

azu commented

https://github.com/textlint-ja/textlint-rule-preset-JTF-style/releases/tag/v2.3.10 としてリリースしました。
対応ありがとうございます!