Scripts: Try using cosmiconf for locating tool configs #30842
Labels
Good First Issue
An issue that's suitable for someone looking to contribute for the first time
Needs Dev
Ready for, and needs developer efforts
[Tool] WP Scripts
/packages/scripts
[Type] Enhancement
A suggestion for improvement.
A number of our scripts in the
@wordpress/scripts
contain logic to find the relevant config and/orignore
file (orpackage.json
entry) for a given tool by replicating that tool's logic in doing so. E.g.lint-js
tries to locate the relevant config foreslint
here:gutenberg/packages/scripts/scripts/lint-js.js
Lines 23 to 33 in dd4cc1b
Similar strategies can be found across our other scripts. This has lead to creation of helper methods such as
hasProjectFile
orhasPackageProp
.Rather than replicating and hard-wiring those tools' strategies, we might consider using a tool like
cosmiconf
, which seeks to establish somewhat of a standard for config file retrieval across tools. (Here's a broader discussion in thenodejs/tooling
repo that had a similar goal but didn't really go anywhere.) AFAIK, some of the tools we use actually usecosmiconf
themselves (e.g.prettier
), while it has been proposed (but not yet adopted) by others (e.g.eslint
).We could consider multiple strategies:
cosmiconf
that use it themselves.Inspired by #30240 (comment)
The text was updated successfully, but these errors were encountered: