incalculable-yacht-75851
01/04/2022, 12:54 AM./pants help prettier
🧵incalculable-yacht-75851
01/04/2022, 12:55 AMimport os.path
from pants.core.util_rules.external_tool import ExternalTool
from pants.engine.platform import Platform
from pants.engine.rules import collect_rules
from pants.option.custom_types import file_option, shell_str
class Prettier(ExternalTool):
options_scope = "prettier"
help = "An opinionated code formatter."
@classmethod
def register_options(cls, register):
super().register_options(register)
register(
"--skip",
type=bool,
default=False,
help="Don't use prettier when running `./pants fmt` or `./pants lint`.",
)
default_version = "2.5.1"
default_known_versions = [
"2.5.1|macos_arm64|86c6af269a5d6e15924d8d718ceb534542549ab94d66deade740d1465fa89d79|3168093",
"2.5.1|macos_x86_64|86c6af269a5d6e15924d8d718ceb534542549ab94d66deade740d1465fa89d79|3168093",
"2.5.1|linux_arm64|86c6af269a5d6e15924d8d718ceb534542549ab94d66deade740d1465fa89d79|3168093",
"2.5.1|linux_x86_64|86c6af269a5d6e15924d8d718ceb534542549ab94d66deade740d1465fa89d79|3168093",
]
def generate_url(self, plat: Platform) -> str:
return "<https://github.com/prettier/prettier/archive/refs/tags/{version}.tar.gz>".format(
version=self.version
)
def generate_exe(self, plat: Platform) -> str:
prettier = "prettier-{version}".format(version=self.version)
return "." + os.path.join("", prettier, "bin", "prettier.js")
def rules():
return collect_rules()
incalculable-yacht-75851
01/04/2022, 12:55 AM"""Prettier - An opinionated code formatter
<https://prettier.io>
"""
from prettier import subsystem
def rules():
return [*subsystem.rules()]
def target_types():
return []
incalculable-yacht-75851
01/04/2022, 12:57 AM[GLOBAL]
pants_version = "2.8.0"
pythonpath = ["%(buildroot)s/pants-plugins"]
backend_packages.add = [
"pants.backend.python",
"prettier"
]
[source]
root_patterns = [
"pants-plugins"
]
[python]
interpreter_constraints = [">=3.9"]
witty-crayon-22786
01/04/2022, 1:02 AMcollect_rules()
is that it will not collect a Subsystem
unless it sees it in the argument list of a @rule
witty-crayon-22786
01/04/2022, 1:02 AMwitty-crayon-22786
01/04/2022, 1:03 AM@rule
witty-crayon-22786
01/04/2022, 1:03 AM@rule
that consumes the Subsystem
hundreds-father-404
01/04/2022, 1:06 AMincalculable-yacht-75851
01/04/2022, 1:07 AMincalculable-yacht-75851
01/04/2022, 1:07 AMhundreds-father-404
01/04/2022, 1:09 AMincalculable-yacht-75851
01/04/2022, 1:12 AM