dependency_validator icon indicating copy to clipboard operation
dependency_validator copied to clipboard

Dependencies used inside `hook/` must be regular dependencies, not dev_dependencies

Open goderbauer opened this issue 3 months ago • 1 comments

The validator complains that dependencies only used inside a build hook (which is placed inside the top-level hook directory) should be dev_dependnecies (because they are only used outside of lib/). That is not correct as also stated in the documentation for hooks:

You need to add the dependencies under dependencies, not dev_dependencies. The hooks will be run by packages and applications depending on your package, so the Dart code needs to be part of the resolution in those packages.

goderbauer avatar Oct 15 '25 11:10 goderbauer

Thanks for reporting. It appears hooks is relatively new and still in preview. We'll look to add support for hooks properly but in the meantime as a workaround, you can configure an ignore https://pub.dev/packages/dependency_validator#configuration

robbecker-wf avatar Oct 15 '25 17:10 robbecker-wf