greglook / cljstyle

A tool for formatting Clojure code
Eclipse Public License 1.0
293 stars 39 forks source link

imports should allow `[` as well as `(` #31

Closed dharrigan closed 2 years ago

dharrigan commented 4 years ago

Currently, when checking a file with imports like so:

  (:import
   [org.flywaydb.core 
    Flyway]
   [org.flywaydb.core.api.configuration 
    FluentConfiguration])

cljstyle will complain like so:

-   [org.flywaydb.core
-    Flyway]
-   [org.flywaydb.core.api.configuration
-    FluentConfiguration]))
+   (org.flywaydb.core
+    Flyway)
+   (org.flywaydb.core.api.configuration
+    FluentConfiguration))

i.e., flagging the use of [ as incorrect. It's totally acceptable to perfer [ in keeping with the use of require.

Cljstyle should allow as a configuration option the option to perfer one or the other.

greglook commented 4 years ago

I don't really agree with the usage of [ for import grouping. It works with the (ns (:import ,,,)) form, but doesn't match how grouping works for namespaces in the :require form. I'm not opposed to adding an option for this eventually, but am unlikely to work on it any time soon.

hden commented 3 years ago

FYI

https://clojure.org/guides/learn/namespaces#_java_classes_and_imports

(ns com.some-example.my-app2
  (:import
    [java.util Date UUID]
    [java.io File]))