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

Create proper clj-kondo hooks for various macros #29

Closed
seancorfield opened this issue Nov 24, 2022 · 4 comments
Closed

Create proper clj-kondo hooks for various macros #29

seancorfield opened this issue Nov 24, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@seancorfield
Copy link
Contributor

seancorfield commented Nov 24, 2022

more-of, more->, maybe others.

The following works for more->:

(ns hooks.expectations.clojure.test.more-thread
  (:require [clj-kondo.hooks-api :as api]))

(defn more-> [{:keys [node]}]
  (let [tail (rest (:children node))
        rewritten
        (api/list-node
         (list*
          (api/token-node 'cond->)
          (api/token-node 'nil)
          tail))]
    {:node rewritten}))
@seancorfield seancorfield self-assigned this Nov 24, 2022
@seancorfield seancorfield added the enhancement New feature or request label Nov 24, 2022
seancorfield added a commit that referenced this issue Feb 1, 2023
more work is needed here
@NoahTheDuke
Copy link
Contributor

The single test version of defexpect with an expected string can throw spurious errors, tho I think this is a clj-kondo issue and not an expectations issue.

(defexpect missing-body-in-when-test
  "Missing body in when"
  (:message (check-str "(when true)")))

"Missing body in when" is labeled as a "missing docstring" currently, due to the :lint-as rule tying defexpect to deftest.

@seancorfield
Copy link
Contributor Author

I'll add a hook for defexpect that does something like the transformation that shorthand form does in the actual macro -- that will fix this. And, yes, maybe clj-kondo also has a bug in its deftest handling but that's no excuse for Expectations to provide a lazy clj-kondo config :)

seancorfield added a commit that referenced this issue Oct 23, 2023
@seancorfield
Copy link
Contributor Author

more-of has been added as a hook.

@seancorfield
Copy link
Contributor Author

Closing his out (as a general issue) with the specific single test defexpect case moved to #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants