Skip to content

Commit c141fe2

Browse files
authored
Improve error (#18)
* feat: add no-ai-colon-continuation rule with kuromojin morphological analysis - Implement new rule to detect English syntax patterns translated to Japanese - Use kuromojin for accurate part-of-speech analysis to distinguish nouns from predicates - Allow natural Japanese expressions like '使い方:' (noun + colon) - Detect unnatural patterns like '実行します:' (predicate + colon) - Support AST-based detection for Paragraph + block element combinations - Remove duplicate colon detection from ai-tech-writing-guideline rule - Add comprehensive test coverage for various patterns Fixes #16 * fix: support full-width colon and add original test cases - Add support for both half-width (:) and full-width (:) colons - Include conjunction detection (例えば: should be flagged) - Port original test cases from ai-tech-writing-guideline - Ensure proper colon character display in error messages - All tests now passing with comprehensive pattern coverage * refactor: improve colon detection implementation - Remove redundant colon index calculation - Determine colon type once and reuse - Remove unused colonIndex variable - Keep clean and efficient implementation * feat: no-ai-colon-continuationルールを追加し、自然な日本語表現を促進 * fix: コロンで終わる述語パターンのエラーメッセージを改善し、自然な日本語表現を提案 * fix: エラーメッセージの表現を改善し、述語とコロンで終わるパターンを明確にしました * fix: エラーメッセージから冗長な表現を削除し、自然な日本語表現を強調しました
1 parent 2522ce8 commit c141fe2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/rules/no-ai-colon-continuation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const rule = (context: any, options: any = {}) => {
136136
const matchRange = [paragraphColonIndex, paragraphColonIndex + 1] as const;
137137

138138
const ruleError = new RuleError(
139-
`「${beforeColonText}${colonChar}のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。`,
139+
`「${beforeColonText}${colonChar}のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。`,
140140
{
141141
padding: locator.range(matchRange)
142142
}

test/rules/no-ai-colon-continuation.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ tester.run("no-ai-colon-continuation", noAiColonContinuation, {
8686
errors: [
8787
{
8888
message:
89-
"「実行します:」のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。"
89+
"「実行します:」のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。"
9090
}
9191
]
9292
},
@@ -95,7 +95,7 @@ tester.run("no-ai-colon-continuation", noAiColonContinuation, {
9595
errors: [
9696
{
9797
message:
98-
"「説明します:」のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。"
98+
"「説明します:」のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。"
9999
}
100100
]
101101
},
@@ -104,7 +104,7 @@ tester.run("no-ai-colon-continuation", noAiColonContinuation, {
104104
errors: [
105105
{
106106
message:
107-
"「使用します:」のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。"
107+
"「使用します:」のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。"
108108
}
109109
]
110110
},
@@ -113,7 +113,7 @@ tester.run("no-ai-colon-continuation", noAiColonContinuation, {
113113
errors: [
114114
{
115115
message:
116-
"「表示します:」のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。"
116+
"「表示します:」のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。"
117117
}
118118
]
119119
},
@@ -124,7 +124,7 @@ tester.run("no-ai-colon-continuation", noAiColonContinuation, {
124124
errors: [
125125
{
126126
message:
127-
"「例えば:」のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。"
127+
"「例えば:」のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。"
128128
}
129129
]
130130
},
@@ -133,7 +133,7 @@ tester.run("no-ai-colon-continuation", noAiColonContinuation, {
133133
errors: [
134134
{
135135
message:
136-
"「JSXはJavaScriptの中でUIを記述するため、プログラマーにとって理解しやすいです:」のようなパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。より自然な日本語表現を検討してください。"
136+
"「JSXはJavaScriptの中でUIを記述するため、プログラマーにとって理解しやすいです:」のような述語とコロンで終わるパターンは、読み手によっては英語の構文を直訳したような印象を与える場合があります。「次のように〜します。」のような自然な日本語表現を検討してください。"
137137
}
138138
]
139139
}

0 commit comments

Comments
 (0)