Skip to content
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

Add clj-kondo hook and config for linting defcomponent #52

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

PEZ
Copy link
Contributor

@PEZ PEZ commented Feb 18, 2024

Hej! Thanks for providing Dumdom! I am having a blast with it.

This PR adds configuration for linting the defcomponent macro with clj-kondo. clj-kondo will, upon request, import it and. For people using cljure-lsp, clj-kondo will be requested to do so, and basically thet will not need to do anything but commit the config to their repositories.

In my work project we're currently using an adapted defcomponent macro which lends itself to being linted as defn. The config submitted here improves on that solution by not requiring Dumdom users to include such a macro, offering some help with getting the life-cycle hook keywords right, and generally is less confusing.

It's my first clj-kondo hook and I'm a bit wary that I'm doing something stupid (I often do!), but things behaves nicely with every test I throw at it.

A thing I am not sure I got right is the choice to lint life-cycle hook keywords as warnings. It could be errors as well, but at least I am in the habit of renaming things temporarily to disable some behaviour and then it makes sense with warning. I think users can override this with project local config.

I'm planning to write some more hooks for event code navigation and checking, but I think those will be better served as examples, because they will depend on what particular framework people set up with the global event handle. At least I think it will depend on that, I guess I will know better once I've started working on the hooks.

@cjohansen
Copy link
Owner

Excellent work 👏 Extra star for the documentation 😊

For "reasons" dumdom uses a manually updated pom.xml, which will need to list resources now. The only issue with this is that dumdom currently has development files in resources. I'll move those to dev-resources.

The hook itself looks good -- I have never made one, so I'm trusting your testing here. Good learning opportunity for me 😊

@PEZ
Copy link
Contributor Author

PEZ commented Feb 18, 2024

I guess it makes sense to keep dev-resources separate.

I've added the auto-imported config to .gitignore now. Also made the project use the exported config, even though it doesn't seem that defcomponent is ever being used. But maybe someone writes an example or a test for it or something going forward...

@cjohansen cjohansen merged commit eebf107 into cjohansen:master Feb 19, 2024
@cjohansen
Copy link
Owner

Released as 2024.02.19, thanks 👍

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.

2 participants