incalculable-yacht-75851
01/04/2022, 10:24 PM./pants -l=debug lint pants-plugins::
and it passes all the python files to prettier but not the markdown file. I want the prettier plugin to operate on all files in a project (BUILD context).hundreds-father-404
01/04/2022, 10:27 PMhappy-kitchen-89482
01/04/2022, 10:53 PMhundreds-father-404
01/04/2022, 11:31 PMprettier_sources
or prettier_files
and doing something like sources=['**/*'.md]
with it.
(The new target type is meant to make it easier for them to differentiate between conventional uses of `files`/`resources` targets vs. their plugin, so if they ever need to evolve this target it's clear what is what.)happy-kitchen-89482
01/05/2022, 6:11 AMhappy-kitchen-89482
01/05/2022, 6:11 AMprettier
is unusual in that it operates on many languages and file typeshappy-kitchen-89482
01/05/2022, 6:12 AMhappy-kitchen-89482
01/05/2022, 6:12 AMfiles/resources
targetshappy-kitchen-89482
01/05/2022, 6:14 AMprettier_files
seems wrong to me - "the user wants to feed me to prettier" is not a property of the files themselveshundreds-father-404
01/05/2022, 5:07 PMwhy not just use all target typesActually, that reminds me that currently @incalculable-yacht-75851 is using
SourceFiles
for the FieldSet
meaning that every target with sources will match
I realize now that can eventually cause issues specifically with fmt
. We run formatters within each language sequentially so they don't overwrite each other, i.e. Python vs Go vs Shell etc. But we run each language in parallel, i.e. Python at the same time as Go. This is why we have that LanguageFmtTargets
thing
For Prettier running on multiple different languages, it's important that it still properly respect this expectation. When you eventually add other JavaScript linters, you'll need to have Prettier use your JavaScriptLanguageFmtTargets
stuff, otherwise your Prettier implementation will have merge conflicts with the Javascript linters and Pants will error. (If you also wanted Prettier to run on things like markdown files, you could have in addition MarkdownLanguageFmtTargets
or FilesLanguageFmtTargets
, for example)
Concretely, this will only be a problem once you start having Prettier run on targets that are already being formatted in another "language" - so, you can get away with the current implementation until you add other JavaScript or Markdown linters etc
I think Benjy might be right to use `files`/`resources` for now and not add prettier_files
. Although both approaches seem fine.incalculable-yacht-75851
01/05/2022, 5:37 PMhundreds-father-404
01/05/2022, 11:04 PMprettier_sources
generates file
targets. It allows them to have the default sources
they want, while still using the core Pants target
We also discussed the difference between files vs resources: https://www.pantsbuild.org/docs/resources. For now, they're generating file
targets, but can change that to be resource
targets when necessary. And they could model it in a few ways, like adding a field to prettier_sources
to decide which target type to generate
FYI @incalculable-yacht-75851 and @icy-account-9671, when doing that you'll have to update Prettier to say it works with both FileSource
and ResourceSource
. Right now, that's not possible to do - we can possibly tweak Pants itself to allow that, or there's a workaround we can help you withhappy-kitchen-89482
01/06/2022, 2:48 PMprettier_sources
makes sense as a name of a target type.happy-kitchen-89482
01/06/2022, 2:48 PMhappy-kitchen-89482
01/06/2022, 2:49 PMhappy-kitchen-89482
01/06/2022, 2:49 PM