clj-kondo

https://github.com/clj-kondo/clj-kondo
wilkerlucio 2020-05-08T02:17:01.144Z

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?

seancorfield 2020-05-08T02:18:40.144900Z

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)

wilkerlucio 2020-05-08T02:21:59.145800Z

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

wilkerlucio 2020-05-08T02:22:08.146100Z

when I replaced with ../something it works

seancorfield 2020-05-08T02:30:45.146600Z

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

wilkerlucio 2020-05-08T03:42:37.147500Z

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?

wilkerlucio 2020-05-08T04:39:13.147700Z

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

wilkerlucio 2020-05-08T05:08:06.149500Z

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?

wilkerlucio 2020-05-08T05:12:50.150400Z

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

wilkerlucio 2020-05-08T05:19:56.150700Z

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

orestis 2020-05-08T06:19:12.151200Z

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

orestis 2020-05-08T06:19:30.151600Z

(I think!)

borkdude 2020-05-08T06:38:43.153400Z

@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

wilkerlucio 2020-05-08T06:39:48.154400Z

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

borkdude 2020-05-08T06:40:42.155300Z

Can you repeat the version you have?

wilkerlucio 2020-05-08T06:41:15.155500Z

clj-kondo v2020.01.13

borkdude 2020-05-08T06:42:49.156Z

@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

wilkerlucio 2020-05-08T06:43:43.157Z

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

borkdude 2020-05-08T06:44:18.157400Z

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

borkdude 2020-05-08T06:45:28.157900Z

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

borkdude 2020-05-08T06:45:56.158100Z

brew install borkdude/brew/clj-kondo

wilkerlucio 2020-05-08T06:48:23.158900Z

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

borkdude 2020-05-08T06:49:05.159200Z

makes sense πŸ™‚

wilkerlucio 2020-05-08T06:49:50.160500Z

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

wilkerlucio 2020-05-08T06:50:15.161Z

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

wilkerlucio 2020-05-08T06:50:26.161400Z

I need to change some config?

borkdude 2020-05-08T06:50:33.161600Z

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.

borkdude 2020-05-08T06:50:59.162Z

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

borkdude 2020-05-08T06:51:31.162900Z

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

wilkerlucio 2020-05-08T06:51:32.163Z

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

wilkerlucio 2020-05-08T06:52:07.163500Z

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

wilkerlucio 2020-05-08T06:52:56.164800Z

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

borkdude 2020-05-08T06:53:25.165400Z

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.

wilkerlucio 2020-05-08T06:53:42.165700Z

I'm thinking of adding this as a configurable thing

borkdude 2020-05-08T06:53:58.166100Z

@wilkerlucio Have you tried a separate require?

borkdude 2020-05-08T06:54:20.166800Z

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

wilkerlucio 2020-05-08T06:54:21.166900Z

oh man, I would rather not if possible, thats hundreds of files to change πŸ˜›

borkdude 2020-05-08T06:54:51.167300Z

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

borkdude 2020-05-08T06:55:14.167800Z

what editor are you using?

wilkerlucio 2020-05-08T06:55:25.168100Z

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

wilkerlucio 2020-05-08T06:55:30.168300Z

I'm on IntelliJ

wilkerlucio 2020-05-08T06:56:02.169100Z

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

borkdude 2020-05-08T06:56:30.169600Z

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

borkdude 2020-05-08T06:56:55.170100Z

Mention nsorg in the issue

wilkerlucio 2020-05-08T06:57:01.170200Z

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

wilkerlucio 2020-05-08T06:57:38.171100Z

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?

borkdude 2020-05-08T06:57:52.171400Z

yes, we save that information

wilkerlucio 2020-05-08T06:58:12.171700Z

cool πŸ™‚ gonna open the issue for discussion

2020-05-08T07:07:55.174300Z

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

wilkerlucio 2020-05-08T07:08:32.174600Z

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

2020-05-08T07:09:44.174800Z

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

borkdude 2020-05-08T07:10:26.175200Z

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

πŸ˜… 1
borkdude 2020-05-08T07:11:15.175400Z

@jeroen.dejong You can enable logging in the LSP plugin

borkdude 2020-05-08T07:11:21.175600Z

so inspect the log file

2020-05-08T07:13:28.175900Z

πŸŽ‰ It needs an absolute path

2020-05-08T07:13:45.176100Z

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

borkdude 2020-05-08T07:13:46.176300Z

ah the tilde is probably not expanded

2020-05-08T07:13:52.176500Z

exactly

2020-05-08T09:05:06.178700Z

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

2020-05-09T12:49:56.190800Z

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

2020-05-09T12:50:21.191Z

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

borkdude 2020-05-09T18:05:57.191600Z

kan op zich geen kwaad denk ik toch?

πŸ‘ 1
borkdude 2020-05-09T18:06:06.191800Z

spamfilter van gmail is goed πŸ˜‰

πŸ˜‚ 1
serioga 2020-05-08T15:14:04.179500Z

CLJS does not support multiple requires 😞 https://clojurians.slack.com/archives/CHY97NXE2/p1588920691162900

borkdude 2020-05-08T18:23:37.179700Z

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

borkdude 2020-05-08T18:24:34.180400Z

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

wilkerlucio 2020-05-08T18:39:38.180600Z

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

borkdude 2020-05-08T18:40:42.180900Z

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

wilkerlucio 2020-05-08T18:40:43.181100Z

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

2020-05-08T18:41:24.181300Z

Thanks Michiel :)

borkdude 2020-05-08T18:41:54.181500Z

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

borkdude 2020-05-08T18:42:03.181700Z

we can do the same with strings

wilkerlucio 2020-05-08T18:42:33.181900Z

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

borkdude 2020-05-08T18:42:43.182100Z

All options are documented here: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md

πŸ‘ 1
wilkerlucio 2020-05-08T18:43:45.182700Z

its so awesome to have kondo on the pipeline getting those πŸ™‚

wilkerlucio 2020-05-08T18:45:41.182900Z

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

borkdude 2020-05-08T18:47:02.183100Z

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

borkdude 2020-05-08T18:47:21.183300Z

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

borkdude 2020-05-08T18:47:37.183500Z

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

borkdude 2020-05-08T18:47:43.183700Z

without another option

borkdude 2020-05-08T18:47:55.183900Z

I'll add that to the issue

wilkerlucio 2020-05-08T18:49:13.184100Z

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

borkdude 2020-05-08T18:49:40.184400Z

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

borkdude 2020-05-08T18:49:56.184600Z

I mean, it's turned off by default

wilkerlucio 2020-05-08T18:50:22.184800Z

yeah, defaults make a difference for sure

wilkerlucio 2020-05-08T18:52:19.185Z

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

wilkerlucio 2020-05-08T18:54:54.185200Z

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

borkdude 2020-05-08T19:00:47.185400Z

I recently found this one: https://github.com/greglook/cljstyle

borkdude 2020-05-08T19:01:07.185800Z

didn't try it

wilkerlucio 2020-05-08T19:22:32.186500Z

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

borkdude 2020-05-08T19:25:05.186700Z

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

wilkerlucio 2020-05-08T21:25:57.186900Z

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

borkdude 2020-05-08T21:26:11.187100Z

aaargh

borkdude 2020-05-08T21:26:54.187300Z

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

borkdude 2020-05-08T21:30:01.187500Z

or make a PR to cljstyle πŸ˜‰

borkdude 2020-05-08T21:30:41.187800Z

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

borkdude 2020-05-08T21:30:49.188Z

since he has a .clj-kondo directory

borkdude 2020-05-08T21:30:55.188200Z

it might be good to reach out to him

borkdude 2020-05-08T21:31:05.188400Z

and also keep me up to date about what he says

wilkerlucio 2020-05-08T21:59:07.188600Z

yeah, I'm down to send a PR there

wilkerlucio 2020-05-08T21:59:28.188800Z

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

borkdude 2020-05-08T22:00:55.189Z

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

borkdude 2020-05-08T22:01:07.189200Z

unless we involve sci into the equation

wilkerlucio 2020-05-08T22:40:13.189400Z

https://github.com/greglook/cljstyle/pull/45