Class: Vivlio::Starter::CLI::TextlintFormatter
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::TextlintFormatter
- Defined in:
- lib/vivlio/starter/cli/textlint_formatter.rb
Overview
textlint stylish 出力の再整形フォーマッター
Defined Under Namespace
Classes: LintEntry, Reformatter
Constant Summary collapse
- MESSAGE_TRANSLATIONS =
エラーメッセージの日本語マッピング(既存の translate_output 用)
{ 'Disallow to use "!"' => '感嘆符「!」は使用しないでください', 'Disallow to use "!"' => '感嘆符「!」は使用しないでください', 'Disallow to use "?"' => '疑問符「?」は使用しないでください', 'Disallow to use "?"' => '疑問符「?」は使用しないでください' }.freeze
- ERROR_LINE_PATTERN =
エラー開始行のパターン: “ 行:列 [✓] error メッセージ ルール名”
/\A\s+(\d+):(\d+)\s+(✓\s+)?error\s+(.+)\z/- FILE_HEADER_PATTERN =
ファイルパスヘッダー行のパターン
%r{\A(/\S+\.md)\s*\z}- NOISE_PATTERNS =
除去対象の冗長行パターン
[ /\A次の助詞が連続しているため/, /\A\s*-\s+"[^"]+"\s*\z/, /\AOver\s+\d+\s+characters/, /\ATotal:\s*\z/, /\A(である|ですます)\s*:\s*\d+\s*\z/, %r{\A解説:\s*https?://}, /\A\s*Try to run:/i, /\A\s*=>\s*/, /\AThis pair of marks is called/, /\A✖\s+\d+\s+problem/, /\A✓\s+\d+\s+fixable/ ].freeze
- SENTENCE_LENGTH_PATTERN =
sentence-length 英語→日本語翻訳パターン
/Line\s+\d+\s+sentence\s+length\((\d+)\)\s+exceeds\s+the\s+maximum\s+sentence\s+length\s+of\s+(\d+)\./
Class Method Summary collapse
-
.reformat_output(output) ⇒ String?
textlint stylish 出力を再整形する.
-
.translate_output(output) ⇒ Object
個別メッセージの日本語翻訳(既存互換).
Class Method Details
.reformat_output(output) ⇒ String?
textlint stylish 出力を再整形する
68 69 70 71 72 |
# File 'lib/vivlio/starter/cli/textlint_formatter.rb', line 68 def self.reformat_output(output) return output if output.nil? || output.empty? Reformatter.new(output).call end |
.translate_output(output) ⇒ Object
個別メッセージの日本語翻訳(既存互換)
75 76 77 78 79 80 81 |
# File 'lib/vivlio/starter/cli/textlint_formatter.rb', line 75 def self.translate_output(output) return output if output.nil? || output.empty? translated = output.dup MESSAGE_TRANSLATIONS.each { translated.gsub!(it.first, it.last) } translated end |