oakmac / standard-clojure-style-js

Standard Clojure Style in JavaScript
ISC License
33 stars 1 forks source link

namespaces - comments for individual symbols #143

Open oakmac opened 1 day ago

oakmac commented 1 day ago

In some cases, comments for individual symbols inside the ns form are not supported. Example:

(ns com.example.my-app
  ;; comment 1
  (:refer-clojure
    :exclude [some-> ;; comment 2
              get    ;; comment 3
              ])     ;; comment 4
  )

This is a perfectly valid namespace, but it is not clear how Standard Clojure Style should handle the comments here. After pretty-printing the ns with Standard Clojure Style, it will look like the following:

(ns com.example.my-app
  ;; comment 1
  (:refer-clojure :exclude [get some->])) ;; what to put here?

This is probably a "not possible to fix completely" scenario, and I think the best user experience might be to warn or error if we detect this case.

Presumably, if the user desires to format their codebase using Standard Clojure Style then they are ok with "losing" these comments after the formatting process, but I do not love the fact that we are "throwing away" some of their code here. There is also the #_ :standard-clj/ignore escape hatch for special cases.

Related to Issue #140