textlint-rule / textlint-rule-prh

textlint rule for prh.
MIT License
82 stars 6 forks source link

Report error correctly when pattern starts with expected value #8

Closed orangain closed 8 years ago

orangain commented 8 years ago

Problem

textlint-rule-prh does not report an error with a text "(図1) " and the following rule:

  # 全角括弧前後の空白を除去
  - expected: )
    pattern: /) | )/

Note: prh does fix the error with this rule.

Cause

This is because the following condition incorrectly ignore the error.

               // Avoid accidental match(ignore case, expected contain actual pattern)
               if (slicedText.indexOf(expected) === 0) {
                   return;
               }

In this case, variables have the following values.

I understand that the condition is introduced by https://github.com/azu/textlint-rule-prh/commit/f528e780567b4cf1584182d773f3b2d499c5ac6f and https://github.com/azu/textlint-rule-prh/commit/cd739dc232e4108430bc2009a9fbb690e3dcbd88 to fix s/Web/Web/i problem and s/ベンダ/ベンダー/ problem. But prh itself does not handle s/ベンダ/ベンダー/ problem, i.e. prh corrects ベンダー to ベンダーー. So, I think s/ベンダ/ベンダー/ problem should be handled by rule (or changing prh's behavior). I believe incompatibility between prh and textlint-rule-prh is confusing.

Implementation

This fix the s/) /)/ problem.

I'll send another PR to web+db_press.yml to fix some patterns if this one is merged.

azu commented 8 years ago

Thanks.

Handle s/ベンダ/ベンダー/ problem by rule.

I agree with this.

azu commented 8 years ago

Release 3.0.0

orangain commented 8 years ago

Thanks for the merge. After upgrading to 3.0.1, I realized that there were several rules affected by this issue such as s/ユーザー/ユーザ/ :stuck_out_tongue: