DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.21k stars 774 forks source link

Clippy-style linting system #1460

Open tigerros opened 1 year ago

tigerros commented 1 year ago

Specific Demand

Create a Clippy-style linting system that would enforce best practices. We could integrate dx check into this, and add further lints. See #1448 for a further discussion on this.

Implement Suggestion

We could base it on Clippy, but I found an interesting crate, Dylint, that I think is worth taking a look at. It's similar to Clippy, but it's specifically designed to provide user-specific lints. Or in Dioxus's case, organization/crate specific lints. There's also this blog post by the author that introduces Dylint and it's advantages over Clippy.

ealmloff commented 1 year ago

Dylint looks great! This would let us do much more complex analysis for linting

tigerros commented 11 months ago

Dylint looks great!

Not so much. I've looked into this recently and it appears Dylint is not made for making linting binaries like a CLI tool, but rather libraries for a workspace. Basically, we could have custom lints in the Dioxus repo, but distributing it would be a pain.

However, I had a look at the Clippy source code and I've got a working demo of a CLI tool similar to Clippy. It's not a fork though, because that would include a lot of stuff we don't need. Right now I'm just doing some refactoring, and then I'll make the repo public so someone else can perhaps help with adding lints from dx check.

ealmloff commented 1 month ago

It looks like interfacing with rustc directly for lints isn't too difficult either: https://blog.guillaume-gomez.fr/articles/2024-01-18+Writing+your+own+Rust+linter