Skip to content

Commit c51bccd

Browse files
azuclaude
andauthored
feat: textlintのMCP設定 (#1826)
## 概要 iterator-helpersブランチから必要な設定ファイルを移植しました。 ## 変更内容 - `.mcp.json`と`.vscode/mcp.json`にtextlint MCPサーバー設定を追加 - VSCodeでMCP(Model Context Protocol)を使用してtextlintを実行できるようになります - `TEXTLINT_MCP=true`環境変数が設定されます - `.textlintrc.js`にAI向けルール(`@textlint-ja/preset-ai-writing`)を追加 - `TEXTLINT_MCP=true`環境変数が設定されている場合のみ有効になります ## 動作確認 - [ ] `TEXTLINT_MCP=true npm run textlint` でAI向けルールが有効になることを確認 - [ ] VSCodeでMCP拡張機能が正しく動作することを確認 ## 関連 - iterator-helpersブランチで開発されていた設定を移植 Co-authored-by: Claude <noreply@anthropic.com>
1 parent fa6389a commit c51bccd

File tree

3 files changed

+82
-53
lines changed

3 files changed

+82
-53
lines changed

.mcp.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"mcpServers": {
3+
"textlint": {
4+
"type": "stdio",
5+
"command": "npx",
6+
"args": [
7+
"textlint",
8+
"--mcp"
9+
],
10+
"env": {
11+
"TEXTLINT_MCP": "true"
12+
}
13+
}
14+
}
15+
}

.textlintrc.js

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,85 @@
11
const IS_LINK_CHECK = !!process.env.LINK_CHECK;
2+
// TEXTLINT_MCP=true なら、AI向けのルールを有効にする
3+
const IS_AI_RULE_ENABLED = process.env.TEXTLINT_MCP === "true";
24
module.exports = {
3-
"filters": {
4-
"comments": true,
5-
"allowlist": {
6-
"allow": [
5+
filters: {
6+
comments: true,
7+
allowlist: {
8+
allow: [
79
"/{#[a-z.-]*?}/g",
810
"/{{[a-zA-Z.]*?}}/g",
911
"と考えるかもしれません",
10-
"ブラウザーの開発者ツールとは?"
11-
]
12-
}
12+
"ブラウザーの開発者ツールとは?",
13+
],
14+
},
1315
},
14-
"rules": {
16+
rules: {
17+
"@textlint-ja/preset-ai-writing": IS_AI_RULE_ENABLED,
1518
"@textlint-ja/no-synonyms": {
16-
"allows": ["アプリ", "ウェブアプリ", "極め", "決め"]
19+
allows: ["アプリ", "ウェブアプリ", "極め", "決め"],
1720
},
1821
// 使っては行けない変数、関数名
1922
// 詳細: https://github.com/asciidwango/js-primer/issues/804
2023
"inline-code-denylist": {
21-
"denylist": ["string", "number", "object", "boolean", "symbol"]
24+
denylist: ["string", "number", "object", "boolean", "symbol"],
2225
},
2326
// 静的メソッドの書き方
2427
"static-method-syntax": true,
2528
"no-use-column": true,
2629
"footnote-order": true,
2730
"no-use-prototype-hash": {
28-
"allow": [
31+
allow: [
2932
// CSSセレクタの表現であるため許可
30-
"div#result"
31-
]
33+
"div#result",
34+
],
3235
},
3336
"@textlint-rule/require-header-id": true,
3437
// 箇条書きには。を付けない
3538
"period-in-list-item": {
36-
"periodMark": ""
39+
periodMark: "",
3740
},
3841
"no-js-function-paren": {
39-
"allow": [
40-
"Symbol"
41-
]
42+
allow: ["Symbol"],
4243
},
4344
"preset-ja-technical-writing": {
4445
"no-mix-dearu-desumasu": {
45-
"preferInHeader": "",
46-
"preferInBody": "ですます",
47-
"preferInList": "ですます",
48-
"strict": false
46+
preferInHeader: "",
47+
preferInBody: "ですます",
48+
preferInList: "ですます",
49+
strict: false,
4950
},
5051
"ja-no-redundant-expression": {
51-
"dictOptions": {
52+
dictOptions: {
5253
// "すること[助詞]できる"
5354
// https://github.com/textlint-ja/textlint-rule-ja-no-redundant-expression#dict2
54-
"dict2": {
55-
"disabled": true
55+
dict2: {
56+
disabled: true,
5657
},
57-
"dict5": {
58-
"allows": [
58+
dict5: {
59+
allows: [
5960
"/読み書き/",
6061
"/通信/",
6162
// デフォルトの許可リストは上書きされるので、維持したい場合は追加する
6263
"/^処理を行[ぁ-ん]/",
6364
"/^[ァ-ヶ]+を.?行[ぁ-ん]/",
64-
"/^[a-zA-Z]+を.?行[ぁ-ん]/"
65-
]
66-
}
67-
}
65+
"/^[a-zA-Z]+を.?行[ぁ-ん]/",
66+
],
67+
},
68+
},
6869
},
6970
"sentence-length": {
70-
"max": 95,
71-
"skipPatterns": [
71+
max: 95,
72+
skipPatterns: [
7273
// 文末の(...)。はカウントしない
73-
"/(.*?)。$/"
74-
]
74+
"/(.*?)。$/",
75+
],
7576
},
7677
"no-exclamation-question-mark": {
77-
"allowFullWidthQuestion": true
78+
allowFullWidthQuestion: true,
7879
},
7980
"max-kanji-continuous-len": {
80-
"max": 6,
81-
"allow": [
81+
max: 6,
82+
allow: [
8283
"倍精度浮動小数",
8384
"浮動小数点数",
8485
"排他的論理和",
@@ -91,34 +92,32 @@ module.exports = {
9192
"論理和演算子",
9293
"排他的論理和演算子",
9394
"文字列結合演算子",
94-
"符号化文字集合"
95-
]
95+
"符号化文字集合",
96+
],
9697
},
9798
"no-invalid-control-character": {
98-
"checkCode": true
99-
}
99+
checkCode: true,
100+
},
100101
},
101-
"eslint": {
102-
"configFile": "./eslint.config.mjs"
102+
eslint: {
103+
configFile: "./eslint.config.mjs",
103104
},
104-
"prh": {
105-
"rulePaths": [
106-
"prh.yml"
107-
]
105+
prh: {
106+
rulePaths: ["prh.yml"],
108107
},
109108
// npm run textlint-linkでのみ外部URLをチェックする
110109
"no-dead-link": IS_LINK_CHECK
111110
? {
112-
"concurrency": 4,
113-
"ignore": [
111+
concurrency: 4,
112+
ignore: [
114113
"https://github.com/asciidwango/js-primer/issues/new?*",
115114
"ttps://help.github.com/articles/about-pull-requests/", // 言語にリダイレクトがある
116115
"https://goo.gl/**",
117116
"https://forms.gle/**",
118-
"http://localhost:3000/**"
117+
"http://localhost:3000/**",
119118
],
120-
maxRetryAfterTime: 60
119+
maxRetryAfterTime: 60,
121120
}
122-
: false
123-
}
121+
: false,
122+
},
124123
};

.vscode/mcp.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"mcpServers": {
3+
"textlint": {
4+
"type": "stdio",
5+
"command": "npx",
6+
"args": [
7+
"textlint",
8+
"--mcp"
9+
],
10+
"env": {
11+
"TEXTLINT_MCP": "true"
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)