0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

textlint ドキュメントのルールにどうぞ!

Last updated at Posted at 2025-03-24
1 / 10

image.png

はじめに

今回はプロジェクトで利用する事になった textlint-ja のメモです。
"LT会" 用に「スライドモード」で記載します。
※lint 系はいろいろとありますね


textlint-ja とは?

  • textlint は JavaScript で動作するテキスト校正ツール
  • textlint-ja は、日本語の文章をチェックするためのプラグインやルールセットを含む
  • lint ツールのように、文章の品質を自動チェック&修正可能

なぜ textlint-ja を使うのか?

  • 文章の統一性 を保つ(例:「下さい」or「ください」)
  • 誤字脱字のチェック を自動化
  • レビューコストを削減
  • CI/CD に組み込める ので、自動チェックが可能

textlint-ja のセットアップ

# Node.js が必要
npm init --yes
npm install textlint

基本的な使い方

  1. ルール設定(.textlintrc
    {
      "rules": {
        "preset-ja-technical-writing": true
      }
    }
    
  2. Lint を実行
    textlint sample.md
    

導入したルール

  • npm install textlint-rule-preset-ja-spacing
    • スペース周りのスタイル
  • npm install textlint-rule-preset-ja-technical-writing
    • 技術文書向け。「漢字のみが続く最大の長さ」とかも変更
  • npm install textlint-rule-spellcheck-tech-word
    • 技術用語

CI/CD に組み込む

GitHub Actions を使う場合の設定例(.github/workflows/textlint.yml

name: textlint

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install
      - run: npx textlint "**/*.md"

サンプルエラー出力

  3:16  error  文末が"。"で終わっていません。                   ja-technical-writing/ja-no-mixed-period
  5:1   error  漢字が6つ以上連続しています: 環境構築手順書作成  ja-technical-writing/max-kanji-continuous-len
  5:9   error  文末が"。"で終わっていません。                   ja-technical-writing/ja-no-mixed-period

おわりに

プロジェクトではREADMEをはじめ、いろいろなドキュメントを作ります。
みんな日本人でも"ですます調"だったり、"である調"だったりとバラけます。
ダイバーシティーなプロジェクトであれば尚更。
コードと同じようにドキュメントの記載を統一するためにも、ぜひ導入してください!


参考(感謝)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?