Skip to content

Add textlint to enforce style guide #11691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"lint:linkcheck:nobuild": "tsm --require=./scripts/lib/filter-warnings.cjs ./scripts/lint-linkcheck.ts",
"lint:slugcheck": "node ./scripts/lint-slugcheck.mjs",
"lint:eslint": "eslint .",
"lint:ja": "node ./scripts/lint-text.mjs ja",
"lint:zh": "node ./scripts/lint-text.mjs zh",
"netlify:build": "pnpm ${NETLIFY_BUILD_SCRIPT:-build}",
"lunaria:build": "tsm ./scripts/lunaria.mts"
},
Expand Down Expand Up @@ -55,6 +57,13 @@
"prettier": "^3.4.2",
"prettier-plugin-astro": "^0.14.1",
"rehype": "^13.0.2",
"textlint": "14.7.1",
"textlint-plugin-mdx": "^1.0.2",
"textlint-rule-ja-space-between-half-and-full-width": "^2.4.2",
"textlint-rule-no-doubled-joshi": "^5.1.0",
"textlint-rule-preset-jtf-style": "^3.0.2",
"textlint-rule-prh": "^6.1.0",
"textlint-rule-zh-half-and-full-width-bracket": "^1.1.0",
"tsm": "^2.3.0",
"typescript": "5.6.2",
"typescript-eslint": "^8.19.1",
Expand Down
1,820 changes: 1,816 additions & 4 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions scripts/lint-text.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { argv, exit } from "node:process";

const lang = argv[2] || "ja";
const config = `./textlint/${lang}/config.json`;
const glob = `src/content/**/${lang}/**/*.{md,mdx}`;

try {
execSync(`pnpm exec textlint -c ${config} "${glob}"`, {
stdio: "inherit"
});
} catch (e) {
// textlint already printed details; just propagate exit code
exit(e.status ?? 1);
}
11 changes: 11 additions & 0 deletions textlint/ja/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": ["textlint-plugin-mdx"],
"rules": {
"preset-jtf-style": true,
"ja-space-between-half-and-full-width": true,
"no-doubled-joshi": true,
"prh": {
"rulePaths": ["prh.yml"]
}
}
}
50 changes: 50 additions & 0 deletions textlint/ja/prh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 1
rules:
# 用語統一

- expected: アダプター
pattern: /アダプタ(?!ー)/

- expected: アーキテクチャ
pattern: /アーキテクチャー/

- expected: ビルドする
pattern: /ビルド(?!する)/

- expected: コンテンツコレクション
pattern: /コンテンツコレクションズ?/

- expected: コントリビューター
pattern: /コントリビュータ\b/

- expected: 依存関係
pattern: /依存\b(?!関係)/

- expected: フロントマター
pattern: /フロントマッター/

- expected: インテグレーション
pattern: /インテグレーションズ?/

- expected: アイランド
pattern: /アイランズ?|アイランドス/

- expected: ページ
pattern: /ページャ?/

- expected: パーシャルハイドレーション
pattern: /パーシャル・?ハイドレーション/

- expected: レンダリング
pattern: /レンダー(?!リング)/

- expected: ルーティング
pattern: /ルート(?!ィング)|ルート化/

# 冗長表現の簡潔化

- expected: できます
pattern: /することができます/

- expected: 使えます
pattern: /使うことができます/
9 changes: 9 additions & 0 deletions textlint/zh-cn/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"plugins": ["textlint-plugin-mdx"],
"rules": {
"zh-half-and-full-width-bracket": true,
"prh": {
"rulePaths": ["./prh.yml"]
}
}
}
2 changes: 2 additions & 0 deletions textlint/zh-cn/prh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version: 1
rules:
Loading