-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider suggesting spelling fixes for unrecognized pubspec keys #4529
Comments
We are actually doing this when publishing. Doing it on @jonasfj suggests hardcoding a list of likely misspellings of the hardest-to-spell properties, and have We could also do the spell-check in a lint. That would enable |
Is the thought that there would be lots of false positives? That seems somewhat unlikely to me, certainly it could happen, but if you only warn on an edit distance of say 2, it will catch a lot of cases still while reducing false positives. |
No, more that a single false positive will be bothering on every invocation - and if you indeed rely on the new property name (pubspec.yaml is open-ended) then there should be a way to turn off the warning. |
Yaml does support comments so we could allow some form of ignore comment, but I don't know how easy they are to get at. A lint could be reasonable but I would worry that keeping it in sync with the known keys would be a bit weird. |
I implemented
We could do the lint in a similar way to our current typo-validator. It only complains if the edit distance to a known key is short: https://github.com/dart-lang/pub/blob/master/lib/src/validator/pubspec_typo.dart . That way unknown keys are ignored (unless they happen to be very similar to known keys.) |
Yes, and I agree it should only warn on very short edit distances (2?), but it also means that the lint won't fire on any examples when new pubspec keys are added. Since the lint would have to be totally separate from pub itself, it seems very unlikely to me that it would get updated to provide help for any of these new keys, because we just won't think about doing so. If it is built into pub itself, it would automatically work for any known keys. |
I recently helped somebody diagnose an issue where their dependency overrides weren't working, and they had just left off the
s
.I realize that pub cannot more generally error on keys it doesn't recognize, but it could potentially check if unrecognized keys are within a close edit distance of a known key, and in that case give a warning about the likely misspelling.
See package:args as an example https://github.com/dart-lang/core/blob/0b2bd3fcd7f3e082f4cc9b14c19ffa93894b85ae/pkgs/args/lib/command_runner.dart#L526C5-L526C18
The text was updated successfully, but these errors were encountered: