JoshuaKGoldberg / package.json-validator

Tools to validate package.json files
MIT License
107 stars 26 forks source link

🚀 Feature: Expose granular API for consumers like eslint-plugin-package-json #80

Open JoshuaKGoldberg opened 5 months ago

JoshuaKGoldberg commented 5 months ago

Context

I maintain eslint-plugin-package-json, which is an ESLint plugin that lints for package.json file correctness. It includes package.json-validator by way of a package-json/valid-package-def rule that directly runs package.json-validator's Node.js API and reports back any complaints.

Problem Statement

That strategy technically works for eslint-plugin-package-json, but:

Taking a step back, package.json-validator does more than just check for a "valid" package file. It also gives warnings and recommendations that are more akin to linter warnings.

Proposal

What if package.json-validator were to additionally expose individual API functions for each of its checks? Then consumers could use the individual API piece they want as needed.

In this case, eslint-plugin-package-json could make a single configurable rule for each of those checks. It'd still have a dependency on the package-json-validator package. We could then deduplicate code so that users can get the same recommendations and warnings either via ESLint plugin or this package.