Coder Social home page Coder Social logo

Comments (8)

borkdude avatar borkdude commented on June 10, 2024 1

Related: clj-kondo/clj-kondo#543

from clj-kondo.lsp.

alidcast avatar alidcast commented on June 10, 2024

Ran into this issue trying to create custom React components with hx macros (https://github.com/Lokeh/hx/tree/master/src/hx)

the linter is complaining about the function name and arguments, since it's not catching them as being used or passed in, respectively.

in the snippet below, for example, both App and initial-name param cause lint errors:

(defnc App [{:keys [initial-name]}]
  (let [[name] (hooks/useState initial-name)]
    [rn/View [rn/Text {:style {:font-weight "bold"}} name]]))

(defn start
  {:dev/after-load true}
  []
  (expo/render-root (hx/f [App {:initial-name "Hello World!"}])))

is there a way to mitigate this?

currently using this library via vscode-clojure-lint
^scratch that, looks like this also comes bundled in @PEZ calva, so uninstalling clojure-lint got the clj-kondo config overrides working

from clj-kondo.lsp.

borkdude avatar borkdude commented on June 10, 2024

@alidcastano

got the clj-kondo config overrides working

Do I understand correctly that your problem was already fixed and there is no action needed from my side?

from clj-kondo.lsp.

alidcast avatar alidcast commented on June 10, 2024

well right now i just disabled the unresolved-symbol rule which isn't ideal. I'd be preferable to have better support for declaring how macros are initialized/used (or at least disabling warnings per line via comments)

which perhaps there is, and i just need to do more digging into docs - just started using clojure! 😅

from clj-kondo.lsp.

borkdude avatar borkdude commented on June 10, 2024

@alidcastano Check out the config docs of clj-kondo:

https://github.com/borkdude/clj-kondo/blob/master/doc/config.md

Example:

foo.cljs:

;; I have to guess your namespace form since you didn't provide it:
(ns foo (:require [bar :refer [defnc]]))

(defnc App [{:keys [initial-name]}]
  (let [[name] (hooks/useState initial-name)]
    [rn/View [rn/Text {:style {:font-weight "bold"}} name]]))

(defn start
  {:dev/after-load true}
  []
  (expo/render-root (hx/f [App {:initial-name "Hello World!"}])))

No more warnings when linting bar/defnc as clojure.core/defn:

$ clj-kondo --lint /tmp/foo.cljs --config '{:lint-as {bar/defnc clojure.core/defn}}'
linting took 16ms, errors: 0, warnings: 0

You can put these rules in .clj-kondo/config.edn in your workspace.

from clj-kondo.lsp.

alidcast avatar alidcast commented on June 10, 2024

oh yeah, I read the config section just wasn't sure what clojure.core declaration to alias it to. using defn makes sense since they basically have the same API.

thanks for the clarification!

from clj-kondo.lsp.

borkdude avatar borkdude commented on June 10, 2024

Related: clj-kondo/clj-kondo#253

from clj-kondo.lsp.

borkdude avatar borkdude commented on June 10, 2024

I have no plans of implementing this.

from clj-kondo.lsp.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.