Fork me on GitHub
#clj-kondo
<
2020-05-08
>
wilkerlucio02:05:01

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 $as_relative_path.invokeStatic(io.clj:414)
        at $file.invokeStatic(io.clj:426)
        at $file.invoke(io.clj:418)
Ideas on what may be going on?

seancorfield02:05:40

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)

wilkerlucio02:05:59

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])

wilkerlucio02:05:08

when I replaced with ../something it works

seancorfield02:05:45

Oh wow... I didn't know paths were a thing in cljs requires!

orestis06:05:12

They’re not, that’s a shadow-CLJS thing.

orestis06:05:30

(I think!)

wilkerlucio03:05:37

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?

wilkerlucio04:05:13

and funny enough, when I run in the CI it triggers the errors for unsorted namespaces :man-shrugging:

wilkerlucio05:05:56

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

wilkerlucio05:05:06

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?

wilkerlucio05:05:50

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]))

borkdude06:05:43

@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

wilkerlucio06:05:48

oh, cool! @borkdude I did the install yesterday from homebrew, maybe the recipe there is not on latest?

borkdude06:05:42

Can you repeat the version you have?

wilkerlucio06:05:15

clj-kondo v2020.01.13

borkdude06:05:49

@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

wilkerlucio06:05:43

I think I followed the instructions, but maybe I just did brew install clj-kondo

borkdude06:05:18

hmm, does brew have clj-kondo in the official repo now maybe...

borkdude06:05:28

I don't think so. Maybe your issue was the issue that Github had yesterday. Can you uninstall it and do it over?

borkdude06:05:56

brew install borkdude/brew/clj-kondo

wilkerlucio06:05:23

@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 facepalm

borkdude06:05:05

makes sense 🙂

wilkerlucio06:05:50

but about the local path thing, clj-kondo still complains about bad ordering when string requires are on top

wilkerlucio06:05:15

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]))

wilkerlucio06:05:26

I need to change some config?

borkdude06:05:33

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.

borkdude06:05:59

E.g. you can do (:require ["clojure.set" :as set]), it's valid in CLJS

borkdude06:05:31

Maybe putting them in separate (:require ...) clauses helps

wilkerlucio06:05:32

yeah, but would be nice if clj-kondo could respect the pure string checking there, I because tools like nsorg will put those first

wilkerlucio06:05:07

also, I like that the separation gets clear about what is JS and what is CLJ (altough is purely a convention)

wilkerlucio06:05:56

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 :))

borkdude06:05:25

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.

wilkerlucio06:05:42

I'm thinking of adding this as a configurable thing

borkdude06:05:58

@wilkerlucio Have you tried a separate require?

borkdude06:05:20

(:require ["foo.js"])
(:require [clojure.set :as set])

wilkerlucio06:05:21

oh man, I would rather not if possible, thats hundreds of files to change 😛

borkdude06:05:51

well, you can make an issue and then I'll for one check what emacs does

borkdude06:05:14

what editor are you using?

wilkerlucio06:05:25

would you be willing to take it if was a configurable feature? like :unsorted-required-namespaces {:level :warning :strings-first? true}

wilkerlucio06:05:30

I'm on IntelliJ

wilkerlucio06:05:02

nsorg is a separated tool I run from lein, that sorts all namespaces

borkdude06:05:30

The right order is: issue, hammock time/discussion, then PR. Maybe @helios also has an opinion on this, he created that linter.

borkdude06:05:55

Mention nsorg in the issue

wilkerlucio06:05:01

sure, just checking if it something you thing its interesting to consider

wilkerlucio06:05:38

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?

borkdude06:05:52

yes, we save that information

wilkerlucio06:05:12

cool 🙂 gonna open the issue for discussion

thumbnail07:05:55

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

wilkerlucio07:05:32

I didn't tried that, but the setup with FileWatchers worked very well here on IntelliJ

thumbnail07:05:44

The filewatcher setup is working correctly indeed, but i was intrigued for the lsp impl for a personal project 😬

borkdude07:05:26

It's funny because recently there was the exact opposite conversation: nobody could make the filewatchers work, so LSP was preferred 😉

😅 4
borkdude07:05:15

@UHJH8MG6S You can enable logging in the LSP plugin

borkdude07:05:21

so inspect the log file

thumbnail07:05:28

🎉 It needs an absolute path

thumbnail07:05:45

It works now, thanks. the log showed it couldn’t find the relative path

borkdude07:05:46

ah the tilde is probably not expanded

jeroenvandijk09:05:06

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)😎

borkdude18:05:37

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

jeroenvandijk18:05:24

Thanks Michiel :)

jeroenvandijk12:05:56

echt heel tof die pods. En met jvm helemaal precies wat ik nodig heb straks voor bijvoorbeeld die filewatcher

jeroenvandijk12:05:21

zag dat je emailadres publiek staat op je github (ook als je niet ingelogd bent). Weet niet of dat je bedoeling was

borkdude18:05:57

kan op zich geen kwaad denk ik toch?

👍 4
borkdude18:05:06

spamfilter van gmail is goed 😉

😂 4
borkdude18:05:34

@wilkerlucio Now I remember: for reader conditionals we just ignored the clauses with respect to sorting. Would that also be good for string requires?

wilkerlucio18:05:38

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

borkdude18:05:42

No, I mean: ignore string requires with regards to sorting like we do with reader conditionals, not the combination of those two

wilkerlucio18:05:43

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)'

borkdude18:05:54

clj-kondo ignores reader conditionals for sorting because the order in which tooling sorts your ns requires is quite undefined

borkdude18:05:03

we can do the same with strings

wilkerlucio18:05:33

oh, ignore could be an option, feels like group, but if possible I would like better to have the option to enforce it

wilkerlucio18:05:45

its so awesome to have kondo on the pipeline getting those 🙂

wilkerlucio18:05:41

do you have concerns about adding this complexity to the lint?

borkdude18:05:02

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

borkdude18:05:21

I just tested this in emacs and clojure-mode also sorts string requires on top

borkdude18:05:37

so it might make sense just to make this the default sorting

borkdude18:05:43

without another option

borkdude18:05:55

I'll add that to the issue

wilkerlucio18:05:13

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

borkdude18:05:40

the sorting linter is optional, so there might not be a lot of people using it?

borkdude18:05:56

I mean, it's turned off by default

wilkerlucio18:05:22

yeah, defaults make a difference for sure

wilkerlucio18:05:19

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

wilkerlucio18:05:54

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

borkdude19:05:07

didn't try it

wilkerlucio19:05:32

nice, I didn't knew about this one, thanks for the hint

borkdude19:05:05

it's also built on rewrite-clj like clj-kondo

wilkerlucio21:05:57

I'm enjoying cljstyle, but one thing though, they sort the namespaces in the way clj-kondo expects -.-

borkdude21:05:54

so it might be better to just ignore them with regards to sorting, so there won't be any tooling conflicts

borkdude21:05:01

or make a PR to cljstyle 😉

borkdude21:05:41

maybe he just was inspired by clj-kondo currently handles it.

borkdude21:05:49

since he has a .clj-kondo directory

borkdude21:05:55

it might be good to reach out to him

borkdude21:05:05

and also keep me up to date about what he says

wilkerlucio21:05:07

yeah, I'm down to send a PR there

wilkerlucio21:05:28

not nescessary for this case, but is it possible to have custom linters on my own source path and make kondo use them?

borkdude22:05:55

not at the moment. note that a typical use of clj-kondo is via the binary and that's pretty much a closed world

borkdude22:05:07

unless we involve sci into the equation