This article was originally published on bmf-tech.com.
Overview
I wanted to automate text proofreading when writing long documents, so I gave it a try.
Structure
The text is managed on GitHub, and the directory structure is as follows:
├── .circleci
│ └── config.yml
├── README.md
├── documents
│ ├── はじめに.md
│ └── おわりに.md
├── images
├── .textlintrc
├── package-lock.json
└── package.json
Installing npm Packages
Initial setup.
npm init -y
Install textlint and the rules used by textlint.
npm install --save-dev textlint textlint-rule-preset-ja-spacing textlint-rule-preset-ja-technical-writing textlint-rule-spellcheck-tech-word textlint-rule-preset-jtf-style textlint-rule-preset-japanese
Setting textlint Rules
.textlintrc
{
"filters": {},
"rules": {
"preset-ja-spacing": true,
"preset-ja-technical-writing": true,
"preset-japanese": true,
"preset-jtf-style": true,
"spellcheck-tech-word": true
}
}
CircleCI Configuration
Generate a token that only allows repo on GitHub and set it as an environment variable named REVIEWDOG_GITHUB_API_TOKEN.
The config.yml settings are as follows:
version: 2
jobs:
build:
docker:
- image: vvakame/review:latest
environment:
REVIEWDOG_VERSION: latest
steps:
- checkout
- restore_cache:
keys:
- npm-cache-{{ checksum "package-lock.json" }}
- run:
name: Setup
command: npm install
- save_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: install reviewdog
command: "curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s $REVIEWDOG_VERSION"
- run:
name: lint for ja
command: "$(npm bin)/textlint -f checkstyle documents/*.md | tee check_result"
- run:
name: reviewdog
command: >
if [ -n "$REVIEWDOG_GITHUB_API_TOKEN" ]; then
cat check_result | ./bin/reviewdog -f=checkstyle -name=textlint -reporter=github-pr-review
fi
when: on_fail
Running the CI
If textlint catches any issues, reviewdog will comment on them.

Top comments (0)