-
Notifications
You must be signed in to change notification settings - Fork 385
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
Linter for drift #3281
base: develop
Are you sure you want to change the base?
Linter for drift #3281
Conversation
See how I setup the tests. Lmk if you have a better way of setting them up. Also, Some of the async code is copied from the dart sdk, I don't know how this affects licensing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on the test infrastructure
Right now warnings in manager generation are not reported in the resolver, so the linter can't use them The warning I'm focusing on are duplicate reverse names e.g. class User extends Table {
late final group = integer().references(Group, #id)
late final supergroup = integer().references(Group, #id)
}
class Group extends Table {
// `userRefs` has 2 relations!!!
} How would I go about this? |
I add a warning level to |
Ideally, these warnings should be discovered in the analysis step instead of during code generation. I know that some of them are easier to report during codegen, is it a lot of work to port them over to something that could run in |
Yeah, could you please do that? |
@simolus3 Any update on this. |
In FileAnalyzer I don't have access to the base element to report the error |
Ping |
I had this commit laying around: b64d602#diff-d36a7b426417ff349d59d9768776e3b2d36ff88fcafe18d7f82c086db523c55d I tried doing a rebase, but I appear to have messed up. I'm not sure why there are so many conflicts in the docs though... |
b64d602
to
54e204c
Compare
drift_lint will only report IDE lints for However, the custom_lint cli will still report errors so I guess it could be helpful |
At this point there is only a single lint which I need passed through all these layers. |
77917ea
to
3a97943
Compare
🚀 Deployed on https://deploy-preview-3281--moor.netlify.app |
All done. I'll add docs once you give me the go ahead |
@simolus3 Yup, we def got a flaky test |
On the test, I blame the Dart update :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks! I hope we don't need too much documentation for this because this should just work for users already using custom_lint
.
I imagine a simple page in the CLI directory noting that the feature exists and what kind of errors are generally reported would be helpful. We should also link to that page from the analyze command docs.
import 'package:drift_dev/src/lints/custom_lint_plugin.dart'; | ||
|
||
/// This function is automaticly recognized by custom_lint to include this drift_dev package as a linter | ||
PluginBase createPlugin() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of this, is there a way to tell custom_lint
to use a different import for a package providing linters (my preferred library would be lib/integrations/custom_lint.dart
).
But if that's not possible so be it, I can file an issue on custom_lint
and we can leave this as-is until that gets resolved.
Co-authored-by: Simon Binder <[email protected]>
This reverts commit e3bc59b.
?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay (again...) I can take a final look later today and merge this if it's ready from your side.
I'll probably do a patch release before merging this (there are some bugfixes waiting to be released), that way we can ship this in a minor version and I'll have more time to test this.
@@ -34,12 +34,13 @@ adding a package to open database on the respective platform. | |||
dev_dependencies: | |||
drift_dev: ^{{ versions.drift_dev }} | |||
build_runner: ^{{ versions.build_runner }} | |||
custom_lint: ^{{ versions.custom_lint }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a small section somewhere mentioning this explicitly (it can also be linked at the bottom of this page).
I'm wary about mentioning the custom_lint
dependency here. We're already suggesting users install a lot of dependencies.
IMO, we should:
- Mention somewhere that if users already have
custom_lint
, drift will work seamlessly with that and provide its own lints. - Suggest (but less strongly than done here, essentially pretending
custom_lint
is a requirement) that users trycustom_lint
to get quicker feedback about potential issues related to drift.
I think the best way to do that would be to mention this on /Tools and then add a bullet point at the end of this page next to the others.
Ill work on the docs. |
Dunno what happened to the old PR. I think the VScode Github Plugin must've closed it. Anyway, here's it as a new PR
createReturning
with ignore mode- [ ] Manager report issues