Skip to content

no-all-caps-body-text: false positive on CJK text (caseless scripts read as "all caps") #1429

Description

@lightsound

React Doctor Version

0.9.0 (also reproduces with the rule's introduction in 0.8.2)

Context

Rule intent: no-all-caps-body-text flags long body copy set in all caps (hard to scan; uppercase should be reserved for short labels).

Reality: the "is all caps" detection appears to treat the absence of lowercase letters as "all caps". CJK scripts (Japanese, Chinese, Korean) have no letter case, so every long Japanese paragraph is flagged as all-caps body copy — with no uppercase styling anywhere (no text-transform, no tracking-*, plain <p className="text-sm">), and nothing actionable behind the finding: there is no "sentence case" to convert Japanese text to.

In a fully Japanese-language app this makes the rule fire on essentially every paragraph of UI copy, so the only practical option today is turning the rule off project-wide, which also loses the legitimate checks on Latin text.

Minimal repro

src/App.tsx in a bare React project:

export function App() {
  return (
    <div>
      <p className="text-sm">
        一部のフォルダにアクセスできないため、移動対象を検出できていない可能性があります。フォルダのアクセス権を確認してから更新してください。
      </p>
      <p className="text-sm">
        This is a normal English paragraph of comparable length that should not be flagged by the rule.
      </p>
    </div>
  );
}

react-doctor design . -y --verbose reports:

⚠ Accessibility: Long body copy is set in all caps
    src/App.tsx:4

The Japanese paragraph (line 4) is flagged; the English paragraph of comparable length is not.

Expected

Caseless scripts should never count as "all caps". A conservative fix: only treat text as all-caps when it actually contains a meaningful number of uppercase cased letters (e.g. require text !== text.toLowerCase(), or a minimum count of \p{Lu} code points), instead of inferring it from the absence of lowercase ones. That keeps the rule intact for Latin/Cyrillic/Greek copy while skipping CJK text entirely.

References

Related in spirit: #671 (no-wide-letter-spacing false positive around the uppercase heuristic).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions