Skip to content

Linter error on -> and ->> without forms. #36

@iafilatov

Description

@iafilatov

-> and ->> with one arg could have it's use cases. For ex. mapping "to a structure":

(map #(-> [%]) [1 2 3]) => ([1] [2] [3])
(map #(-> {:foo %}) [1 2 3]) => ({:foo 1} {:foo 2} {:foo 3})
(map #(-> `(~%)) [1 2 3]) => ((1) (2) (3))

which cause "No forms in ->". This has to be written like

(map #(vec [%]) [1 2 3])          ;; i put vec in your ver so you get vec...
(map #(assoc {} :foo %) [1 2 3])  ;; almost like m = {}; for i in ...
(map #(list %) [1 2 3])           ;; ok, this probably is a tie

I assume the linter wants to guard against mistakes like

(let [val ...]
  (-> val)
  (do-something-with-val))  ;; should be in ->

but I can't think of any examples where this could go unnoticed and not cause problems immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions