# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from mozterm import Terminal
from ..result import Issue from ..util.string import pluralize
class StylishFormatter: """Formatter based on the eslint default."""
_indent_ = " "
# Colors later on in the list are fallbacks in case the terminal # doesn't support colors earlier in the list. # See http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
_colors = { "blue": [4], "brightred": [9, 1], "brightyellow": [11, 3], "darkgrey": [247, 8], "green": [2], "grey": [7], "red": [1], "yellow": [3],
}
num_errors = 0
num_warnings = 0
num_fixed = result.fixed for path, errors in sorted(result.issues.items()):
self._reset_max()
message.append(self.term.underline(path)) # Do a first pass to calculate required padding for err in errors: assert isinstance(err, Issue)
self._update_max(err) if err.level == "error":
num_errors += 1 else:
num_warnings += 1
for err in sorted(
errors, key=lambda e: (int(e.lineno), int(e.column or0))
): if err.column:
col = ":" + str(err.column).ljust(self.max_column) else:
col = "".ljust(self.max_column + 1)
# If there were failures, make it clear which linters failed for fail in failed:
message.append( "{c}A failure occurred in the {name} linter.".format(
c=self.color("brightred"), name=fail
)
)
# Print a summary
message.append(
self.fmt_summary.format(
t=self.term,
c=(
self.color("brightred") if num_errors or failed else self.color("brightyellow")
),
problem=pluralize("problem", num_errors + num_warnings + len(failed)),
error=pluralize("error", num_errors),
warning=pluralize( "warning", num_warnings or result.total_suppressed_warnings
),
failure=( ", {}".format(pluralize("failure", len(failed))) if failed else""
),
fixed=f"{num_fixed} fixed",
)
)
if result.total_suppressed_warnings > 0and num_errors == 0:
message.append( "(pass {c1}-W/--warnings{c2} to see warnings.)".format(
c1=self.color("darkgrey"), c2=self.term.normal
)
)
return"\n".join(message)
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-08-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.