Skip to content

Fix dart_hooks.yaml example keys so hooks are actually enabled (#150)#151

Merged
reidbaker merged 3 commits into
flutter:mainfrom
reidbaker:fix-dart-hooks-yaml-keys-150
May 25, 2026
Merged

Fix dart_hooks.yaml example keys so hooks are actually enabled (#150)#151
reidbaker merged 3 commits into
flutter:mainfrom
reidbaker:fix-dart-hooks-yaml-keys-150

Conversation

@reidbaker
Copy link
Copy Markdown
Contributor

Summary

Fixes #150.

The example dart_hooks.yaml files committed in #148 used the script filenames as keys (agent_dart_format.dart / agent_dart_analyze.dart). BaseHook.run() gates each hook on its configKey, which is the class name (DartFormatHook / DartAnalyzeHook). Because those keys never matched, copying any committed example left both hooks silently disabled — contradicting the README, which documents the correct keys.

Changes

  • Update all four committed dart_hooks.yaml files to the class-name keys the code reads and the README documents:

    • dart_hooks.yaml
    • tool/dart_hooks.yaml
    • tool/dart_hooks/dart_hooks.yaml
    • tool/dart_skills_lint/dart_hooks.yaml (a fourth file with the same bug, not listed in the issue)
    DartFormatHook: true
    DartAnalyzeHook: true
  • Improve the diagnostic (the issue's optional suggestion). When the expected key is missing, the log now lists the keys that were found and suggests the correct one, so a typo'd or legacy key no longer disables a hook with an opaque message:

    Hook dart format is disabled (key "DartFormatHook" is missing in configuration). Found keys: [agent_dart_format.dart, agent_dart_analyze.dart]. Did you mean to enable it with "DartFormatHook: true"?

    This is scoped to each hook's own key (no shared-registry refactor) since the message points straight at the fix. The README troubleshooting section quotes only the unchanged message prefix, so it stays accurate.

Verification

  • dart test — all pass (extended the existing "missing config key" test to assert the found-keys diagnostic)
  • dart format --set-exit-if-changed — clean
  • dart analyze — no issues

…er#150)

The example dart_hooks.yaml files committed in flutter#148 used the script
filenames (agent_dart_format.dart / agent_dart_analyze.dart) as keys.
BaseHook.run() gates on each hook's configKey, which is the class name
(DartFormatHook / DartAnalyzeHook), so copying these files left both
hooks silently disabled, contradicting the README.

Update all four committed dart_hooks.yaml files to the class-name keys
the code reads and the README documents.

Also improve the diagnostic: when the expected key is missing, the log
now lists the keys that were found and suggests the correct one, so a
typo'd or legacy key no longer disables a hook with an opaque message.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the configuration keys in several dart_hooks.yaml files from script filenames to class-based hook names (DartFormatHook and DartAnalyzeHook). It also improves the logging in base_hook.dart when a hook is disabled due to a missing configuration key by listing the keys that were found. A review comment points out that since yaml is declared as dynamic, accessing yaml.keys results in a dynamic invocation. It is recommended to cast yaml to Map to avoid potential linter warnings.

Comment thread tool/dart_hooks/lib/src/base_hook.dart
reidbaker and others added 2 commits May 25, 2026 17:39
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
yaml is already promoted to Map by the enclosing `if (yaml is Map)`, so
`(yaml as Map)` is an unnecessary_cast that `dart analyze --fatal-infos`
treats as fatal. Drop the cast.
@reidbaker reidbaker merged commit ef41e12 into flutter:main May 25, 2026
17 checks passed
@reidbaker reidbaker deleted the fix-dart-hooks-yaml-keys-150 branch May 25, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint] dart_hooks.yaml example files added in #148 use keys that the hook code never reads (hooks stay disabled)

1 participant