hello, I'm getting this error on a project:
Unexpected error. Please report an issue.
java.lang.IllegalArgumentException: /scrollparent.transit.json is not a relative path
at <http://clojure.java.io|clojure.java.io>$as_relative_path.invokeStatic(io.clj:414)
at <http://clojure.java.io|clojure.java.io>$file.invokeStatic(io.clj:426)
at <http://clojure.java.io|clojure.java.io>$file.invoke(io.clj:418)
Ideas on what may be going on?Is that perhaps part of a top-level def
that has side-effect-y stuff in it? (hard to tell without more of the stacktrace)
after some debugging I found the issue is when you have a :require
on cljs that uses a root link, eg: (:require ["/something" :as js-local-thing])
when I replaced with ../something
it works
Oh wow... I didn't know paths were a thing in cljs requires!
another thing that I'm having, when I run clj-kondo --lint src
on my project, its not reporting unsorted namespaces, but when I save the file from my editor and it triggers from that, the error is reported, both using same config, is there something I'm missing here?
and funny enough, when I run in the CI it triggers the errors for unsorted namespaces :man-shrugging:
and still about unsorted imports, currently clj-kondo is sorting based on the real ns name, not in what is written, so when we have string requires from cljs, its working as if they were symbols (and expecting them to be in the middle), but I like that JS imports (from strings) appear at the top, also sorting libs like ns-org will also put the strings first, @borkdude do you think we can make this setting configurable, so I can choose to have the string requires at top?
example:
; this is what I consider organized
(ns devcards.render
(:require
["react" :as react]
[devcards.util :as d-u]
[reagent.core :as r]
[relemma.util :as u]))
; this is what clj-kondo considers organized
(ns devcards.render
(:require
[devcards.util :as d-u]
["react" :as react]
[reagent.core :as r]
[relemma.util :as u]))
on this, its not just the unsorted imports, some redundant do also did show up on CI, but not on my machine via clj-kondo --lint src
, but those also show in my editor when I save a file
Theyβre not, thatβs a shadow-CLJS thing.
(I think!)
@wilkerlucio please upgrade, you are using and old version. The local path require issue has been fixed. Also the issue about str/replace you posted on Github
oh, cool! @borkdude I did the install yesterday from homebrew, maybe the recipe there is not on latest?
Can you repeat the version you have?
clj-kondo v2020.01.13
@wilkerlucio How did you install. From which brew thing? https://github.com/borkdude/homebrew-brew/blob/master/clj-kondo.rb borkdude/brew/clj-kondo 2020.02.15 -> 2020.05.02 ==> Upgrading borkdude/brew/clj-kondo 2020.02.15 -> 2020.05.02
I think I followed the instructions, but maybe I just did brew install clj-kondo
hmm, does brew have clj-kondo in the official repo now maybe...
I don't think so. Maybe your issue was the issue that Github had yesterday. Can you uninstall it and do it over?
brew install borkdude/brew/clj-kondo
@borkdude just figured out my problem, in the project that Im working there was already a clj-kondo install from NPM, and when I was running from that folder was picking that instead of the system installation π€¦
makes sense π
but about the local path thing, clj-kondo still complains about bad ordering when string requires are on top
this is getting me a lint error:
(ns devcards.render
(:require-macros
[devcards.core :refer [defcard]])
(:require
["react" :as react]
[devcards.util :as d-u]
[reagent.core :as r]
[relemma.util :as u]))
I need to change some config?
about the sorting: don't know - David Nolen told me that strings are allowed in require only to support things that you can't express using symbols. In that sense they are no different. But clj-kondo does treats string requires as JS library requires, so you can use the namespace objects. I don't think it should affect the sorting.
E.g. you can do (:require ["clojure.set" :as set])
, it's valid in CLJS
Maybe putting them in separate (:require ...)
clauses helps
yeah, but would be nice if clj-kondo could respect the pure string checking there, I because tools like nsorg will put those first
also, I like that the separation gets clear about what is JS and what is CLJ (altough is purely a convention)
do you think its hard to support that? I wonder if clj-kondo currenty can tell the difference, I would be willing to work on that if you think its a feasable (and you want the feature :))
one problem is that different editors might have different opinions on sorting. if you can verify that e.g. Emacs / clojure-mode does the same thing for string requires, Atom, VSCode, etc, then it might start to make sense. But right now I'm not so certain of that.
I'm thinking of adding this as a configurable thing
@wilkerlucio Have you tried a separate require?
(:require ["foo.js"])
(:require [clojure.set :as set])
oh man, I would rather not if possible, thats hundreds of files to change π
well, you can make an issue and then I'll for one check what emacs does
what editor are you using?
would you be willing to take it if was a configurable feature? like :unsorted-required-namespaces {:level :warning :strings-first? true}
I'm on IntelliJ
nsorg is a separated tool I run from lein, that sorts all namespaces
The right order is: issue, hammock time/discussion, then PR. Maybe @helios also has an opinion on this, he created that linter.
Mention nsorg in the issue
sure, just checking if it something you thing its interesting to consider
do you know if the information about the original definition (if its a string or a symbol) is available at the linter call for this?
yes, we save that information
cool π gonna open the issue for discussion
Hey π:skin-tone-2: , Iβm trying to setup the LSP server in InteliJ, but i get timeouts (see screenshot).
Also manually running java -jar ~/bin/clj-kondo-lsp-server-2020.05.02-standalone.jar
yields nothing on openjdk 1.8.0_232
. How would i go about debugging this π¬
I also tried 2020.04.05
I didn't tried that, but the setup with FileWatchers worked very well here on IntelliJ
The filewatcher setup is working correctly indeed, but i was intrigued for the lsp impl for a personal project π¬
It's funny because recently there was the exact opposite conversation: nobody could make the filewatchers work, so LSP was preferred π
@jeroen.dejong You can enable logging in the LSP plugin
so inspect the log file
π It needs an absolute path
It works now, thanks. the log showed it couldnβt find the relative path
ah the tilde is probably not expanded
exactly
Hi Iβm pretty new to clj-kondo and specifically using it for a Clojurescript project. For now Iβve copied the setup of clj-kondo itself. If anyone wants to give feedback on this pull request that would be very much appreciated https://github.com/athensresearch/athens/pull/38 Itβs also for a good cause (an opensource tool for open knowledge)π
echt heel tof die pods. En met jvm helemaal precies wat ik nodig heb straks voor bijvoorbeeld die filewatcher
zag dat je emailadres publiek staat op je github (ook als je niet ingelogd bent). Weet niet of dat je bedoeling was
kan op zich geen kwaad denk ik toch?
spamfilter van gmail is goed π
CLJS does not support multiple requires π https://clojurians.slack.com/archives/CHY97NXE2/p1588920691162900
Hi Jeroen. Using the config from clj-kondo itself doesn't make much sense to me as that is used for linting clj-kondo itself. I would just start with a clean slate and add config when needed
@wilkerlucio Now I remember: for reader conditionals we just ignored the clauses with respect to sorting. Would that also be good for string requires?
that's a interesting question, I can't remember a time that I used string requires on .cljc, but I see this example in Fulcro: https://github.com/fulcrologic/fulcro/blob/bdb34022d0d51e150b3a3ee1e45a7cdc5ebdea2b/src/main/com/fulcrologic/fulcro/routing/legacy_ui_routers.cljc#L1-L17
No, I mean: ignore string requires with regards to sorting like we do with reader conditionals, not the combination of those two
so, IMO, I like the #? itself to be ignored, but if possible, check the sorting inside, having sam the string consideration (please note this example of fulcro is not actually sorted, but the strings are on top)'
Thanks Michiel :)
clj-kondo ignores reader conditionals for sorting because the order in which tooling sorts your ns requires is quite undefined
we can do the same with strings
oh, ignore could be an option, feels like group, but if possible I would like better to have the option to enforce it
All options are documented here: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md
its so awesome to have kondo on the pipeline getting those π
do you have concerns about adding this complexity to the lint?
I'm more concerned with adding config that's only useful to one person while the second person needs something slightly different and there will be another option
I just tested this in emacs and clojure-mode also sorts string requires on top
so it might make sense just to make this the default sorting
without another option
I'll add that to the issue
oh, sgtm, I wonder if I'm the first trying to use it with cljs like this (or first talking about it with you :P), or if other people are sorting into the current kondo way
the sorting linter is optional, so there might not be a lot of people using it?
I mean, it's turned off by default
yeah, defaults make a difference for sure
and thanks again for the tool, I had a nice surprise when I see that the notifications got highlighted inline on the editor in intellij, every file watcher extension that I used in the past just did a external read-only console, kudos on that
one idea in my mind, do you think makes sense to use clj-kondo as a base for writing a code formatter? I played with SCI and read a bit on edamame, but I'm not sure for a code formatter which would be make more sense, if any
I recently found this one: https://github.com/greglook/cljstyle
didn't try it
nice, I didn't knew about this one, thanks for the hint
it's also built on rewrite-clj like clj-kondo
I'm enjoying cljstyle, but one thing though, they sort the namespaces in the way clj-kondo expects -.-
aaargh
so it might be better to just ignore them with regards to sorting, so there won't be any tooling conflicts
or make a PR to cljstyle π
maybe he just was inspired by clj-kondo currently handles it.
since he has a .clj-kondo directory
it might be good to reach out to him
and also keep me up to date about what he says
yeah, I'm down to send a PR there
not nescessary for this case, but is it possible to have custom linters on my own source path and make kondo use them?
not at the moment. note that a typical use of clj-kondo is via the binary and that's pretty much a closed world
unless we involve sci into the equation