# 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/.
import os import signal import subprocess
from mozlint import result
PRETTIER_ERROR_MESSAGE = """
An error occurred running prettier. Please check the following error messages:
def run_prettier(cmd_args, config, fix):
shell = False if is_windows(): # The eslint binary needs to be run from a shell with msys
shell = True
encoding = "utf-8"
if errors:
errors = errors.decode(encoding, "replace").strip().split("\n")
errors = [
error for error in errors # Unknown options are not an issue for Prettier, this avoids # errors during tests. ifnot ("Ignored unknown option"in error)
] if errors:
results.append(
result.from_config(
config,
**{ "name": "eslint", "path": os.path.abspath("."), "message": PRETTIER_ERROR_MESSAGE.format("\n".join(errors)), "level": "error", "rule": "prettier", "lineno": 0, "column": 0,
},
)
)
ifnot output: # If we have errors, but no output, we assume something really bad happened. if errors and errors: return {"results": results, "fixed": 0}
return {"results": [], "fixed": 0} # no output means success
if fix: # When Prettier is running in fix mode, it outputs the list of files # that have been fixed, so sum them up here. # If it can't fix files, it will throw an error, which will be handled # above.
fixed = len(output) else: # When in "check" mode, Prettier will output the list of files that # need changing, so we'll wrap them in our result structure here. for f in output: ifnot f: continue
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.