Skip to content

Commit 78d71f2

Browse files
committed
fix: RuleErrorを使用して報告メッセージの構造を改善
1 parent 62f68f6 commit 78d71f2

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/rules/ai-tech-writing-guideline.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface Options {
2424
}
2525

2626
const rule: TextlintRuleModule<Options> = (context, options = {}) => {
27-
const { Syntax, report, locator } = context;
27+
const { Syntax, report, locator, RuleError } = context;
2828
const allows = options.allows ?? [];
2929
const disableRedundancyGuidance = options.disableRedundancyGuidance ?? false;
3030
const disableVoiceGuidance = options.disableVoiceGuidance ?? false;
@@ -233,10 +233,12 @@ const rule: TextlintRuleModule<Options> = (context, options = {}) => {
233233
documentQualityMetrics[category as keyof typeof documentQualityMetrics]++;
234234
hasDocumentIssues = true;
235235

236-
report(node, {
237-
message: message,
238-
padding: locator.range(originalRange)
239-
});
236+
report(
237+
node,
238+
new RuleError(message, {
239+
padding: locator.range(originalRange)
240+
})
241+
);
240242
}
241243
}
242244
}
@@ -266,9 +268,12 @@ const rule: TextlintRuleModule<Options> = (context, options = {}) => {
266268

267269
const detailsText = categoryDetails.length > 0 ? ` [内訳: ${categoryDetails.join(", ")}]` : "";
268270

269-
report(node, {
270-
message: `【テクニカルライティング品質分析】この文書で${totalIssues}件の改善提案が見つかりました${detailsText}。効果的なテクニカルライティングの7つのC(Clear, Concise, Correct, Coherent, Concrete, Complete, Courteous)の原則に基づいて見直しを検討してください。詳細なガイドライン: https://github.com/textlint-ja/textlint-rule-preset-ai-writing/blob/main/docs/tech-writing-guidelines.md`
271-
});
271+
report(
272+
node,
273+
new RuleError(
274+
`【テクニカルライティング品質分析】この文書で${totalIssues}件の改善提案が見つかりました${detailsText}。効果的なテクニカルライティングの7つのC(Clear, Concise, Correct, Coherent, Concrete, Complete, Courteous)の原則に基づいて見直しを検討してください。詳細なガイドライン: https://github.com/textlint-ja/textlint-rule-preset-ai-writing/blob/main/docs/tech-writing-guidelines.md`
275+
)
276+
);
272277
}
273278
}
274279
};

0 commit comments

Comments
 (0)