Closed2
zennの執筆環境の整備
いい環境で執筆したいと思い、上記の記事を見つけたので設定してみます。
npmでtextlint一式をインストールします。
$ npm install --save-dev textlint textlint-rule-preset-ja-technical-writing textlint-rule-preset-ja-spacing
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'textlint@12.0.2',
npm WARN EBADENGINE required: { node: '^12.20.0 || ^14.13.1 || >=16.0.0' },
npm WARN EBADENGINE current: { node: 'v14.11.0', npm: '7.20.5' }
npm WARN EBADENGINE }
added 580 packages, and audited 581 packages in 42s
103 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
.textlintrc
に設定を記載します。
$ cat << EOF > .textlintrc
{
"plugins": {
"@textlint/markdown": {
"extensions": [".md"]
}
},
"rules": {
"preset-ja-technical-writing": {
"no-exclamation-question-mark": {
"allowFullWidthExclamation": true,
"allowFullWidthQuestion": true,
},
"no-doubled-joshi": {
"strict": false,
"allow": ["か"],
}
},
"preset-ja-spacing": {
"ja-space-between-half-and-full-width": {
space: "always",
exceptPunctuation: true,
},
"ja-space-around-code": {
"before": true,
"after": true
}
},
"ja-technical-writing/ja-no-mixed-period": {
"allowPeriodMarks": [":"],
},
"ja-technical-writing/sentence-length": false
}
}
EOF
reviewdogのGitHub Actionsを作成します。
$ mkdir -p .github/workflows
$ cat << EOF > .github/workflows/reviewdog.yml
name: reviewdog
on: [pull_request]
jobs:
textlint:
name: runner / textlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: textlint-github-pr-review(articles)
uses: tsuyoshicho/action-textlint@v3
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: warning
textlint_flags: "articles/**"
- name: textlint-github-pr-review(book)
uses: tsuyoshicho/action-textlint@v3
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: warning
textlint_flags: "books/**"
EOF
参考記事ではarticles
ディレクトリのみが対象になってますが、book
も追加しました。
textlint_flags
に1stepで複数ディレクトリの指定は出来なそうです。
以上で設定は完了です。作業後の変更点は以下のようになりました。
$ git status
On branch feature/reviewdog
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
.github/
.textlintrc
no changes added to commit (use "git add" and/or "git commit -a")
このスクラップは2021/08/10にクローズされました