Skip to content

Commit

Permalink
Lint state-flow.labs.state/with-redefs (#175)
Browse files Browse the repository at this point in the history
* Initial implemention

* 💅

* Refer flow from state-flow.api

* Streamline the code

* 💅

* Bump project version to 5.16.0

* Update the Changelog
  • Loading branch information
acamargo authored Apr 23, 2024
1 parent 3840f4e commit e1fff3d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Changelog

## [5.16.0]
- Add linter for `state-flow.labs.state/with-redefs` [#175](https://github.com/nubank/state-flow/pull/175)

## [5.15.0]
- Store init function in state metadata

## [5.14.5]
- switch the declare/import-var function to def in state.api [#171](https://github.com/nubank/state-flow/pull/171)
- switch the declare/import-var function to def in state.api [#171](https://github.com/nubank/state-flow/pull/171)

## [5.14.4]
- Bump midje to 1.10.9
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject nubank/state-flow "5.15.0"
(defproject nubank/state-flow "5.16.0"
:description "Integration testing with composable flows"
:url "https://github.com/nubank/state-flow"
:license {:name "MIT"}
Expand Down
3 changes: 2 additions & 1 deletion resources/clj-kondo.exports/nubank/state-flow/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
:hooks {:analyze-call {state-flow.cljtest/defflow nubank.state-flow/defflow
state-flow.api/defflow nubank.state-flow/defflow
state-flow.core/flow nubank.state-flow/flow
state-flow.api/flow nubank.state-flow/flow}}}
state-flow.api/flow nubank.state-flow/flow
state-flow.labs.state/with-redefs nubank.state-flow/with-redefs}}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns nubank.state-flow
(:refer-clojure :exclude [with-redefs])
(:require [clj-kondo.hooks-api :as hooks]))

(defn- normalize-mlet-binds
Expand Down Expand Up @@ -33,3 +34,25 @@
(do-let body)])]
{:node (with-meta new-node (meta node))
:defined-by 'state-flow.cljtest/defflow}))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn with-redefs
"This transformation hook converts
(state-flow.labs.state/with-redefs [bindings & flows])
into
(clojure.core/with-redefs bindings
(state-flow.core/flow \"state-flow.labs.state/with-redefs\" flows))"
[{:keys [node]}]
(let [[bindings & flows] (rest (:children node))
new-node (hooks/list-node
[(hooks/token-node 'clojure.core/with-redefs)
bindings
(hooks/list-node
(concat [(hooks/token-node 'state-flow.api/flow)
(hooks/string-node "state-flow.labs.state/with-redefs")]
flows))])]
{:node (with-meta new-node (meta node))
:defined-by 'state-flow.labs.state/with-redefs}))

0 comments on commit e1fff3d

Please sign in to comment.