Skip to content

Feat/add option/no colon list formatting #15

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

Closed
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
7 changes: 6 additions & 1 deletion src/rules/ai-tech-writing-guideline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface Options {
disableConsistencyGuidance?: boolean;
disableClarityGuidance?: boolean;
disableStructureGuidance?: boolean;
// Disable colon + list formatting checks (allows colon followed by bullet points)
"no-ai-colon-list-formatting"?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to align the name with other options and name it disableColonListFormatting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question. This rule's name uses camelCase.
It's diffrent from other textlint rules name using kebab-case.

Is this new standard of new textlint rule set?

BTW, I change the name of options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is option name, it is not rule name.

// Enable document-level analysis
enableDocumentAnalysis?: boolean;
}
Expand All @@ -31,6 +33,7 @@ const rule: TextlintRuleModule<Options> = (context, options = {}) => {
const disableConsistencyGuidance = options.disableConsistencyGuidance ?? false;
const disableClarityGuidance = options.disableClarityGuidance ?? false;
const disableStructureGuidance = options.disableStructureGuidance ?? false;
const noAiColonListFormatting = options["no-ai-colon-list-formatting"] ?? false;
const enableDocumentAnalysis = options.enableDocumentAnalysis ?? true;

// テクニカルライティングガイダンスパターン
Expand Down Expand Up @@ -255,7 +258,9 @@ const rule: TextlintRuleModule<Options> = (context, options = {}) => {
}

// コロン + 箇条書きパターンの検出
detectMechanicalListIntroPattern(node);
if (!noAiColonListFormatting) {
detectMechanicalListIntroPattern(node);
}
// 将来的にここに他の文書レベルの構造化パターンを追加できます
// 例:
// detectExcessiveNestedLists(node);
Expand Down
40 changes: 40 additions & 0 deletions test/rules/ai-tech-writing-guideline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ tester.run("ai-tech-writing-guideline", rule, {
{
text: "パフォーマンス改善の手法を紹介します。以下にその手法を示します。\n\n- コード最適化\n- キャッシュ活用",
options: { enableDocumentAnalysis: false }
},
// no-ai-colon-list-formatting オプション true の場合(コロン+箇条書きを許可)
{
text: "フレームワークの特徴は以下の通りです:\n\n- 便利な機能\n- 簡単な設定",
options: { "no-ai-colon-list-formatting": true, enableDocumentAnalysis: false }
},
{
text: "設定項目について説明します。例えば。\n\n- 基本設定\n- 詳細設定",
options: { "no-ai-colon-list-formatting": true, enableDocumentAnalysis: false }
}
],
invalid: [
Expand Down Expand Up @@ -200,6 +209,37 @@ tester.run("ai-tech-writing-guideline", rule, {
"【簡潔性】冗長な助動詞表現が検出されました。「できます」または「します」への簡潔化を検討してください。"
}
]
},
// no-ai-colon-list-formatting オプション false の場合(デフォルト動作:エラーを検出)
{
text: "フレームワークの特徴は以下の通りです:\n\n- 便利な機能\n- 簡単な設定",
options: { "no-ai-colon-list-formatting": false, enableDocumentAnalysis: false },
errors: [
{
message:
"【構造化】コロン(:)で終わる文の直後の箇条書きは機械的な印象を与える可能性があります。「たとえば、次のような点があります。」のような導入文を使った自然な表現を検討してください。"
}
]
},
{
text: "APIの使用方法について:\n\n- GET リクエスト\n- POST リクエスト",
options: { "no-ai-colon-list-formatting": false, enableDocumentAnalysis: false },
errors: [
{
message:
"【構造化】コロン(:)で終わる文の直後の箇条書きは機械的な印象を与える可能性があります。「たとえば、次のような点があります。」のような導入文を使った自然な表現を検討してください。"
}
]
},
{
text: "設定項目について説明します。例えば。\n\n- 基本設定\n- 詳細設定",
options: { "no-ai-colon-list-formatting": false, enableDocumentAnalysis: false },
errors: [
{
message:
"【構造化】接続表現と句点で終わる文の直後の箇条書きは機械的な印象を与える可能性があります。「たとえば、次のような点があります。」のような自然な導入文を検討してください。"
}
]
}
]
});