Skip to content

Syntax error compiling with figwheel #58

@2food

Description

@2food

When using camel-snake-kebab in clojurescript, running fighweel and tests at the same time i get this error:

Error refreshing environment: Syntax error compiling at (camel_snake_kebab/core.cljc:16:1).

The line specified is the first line where a conversion is defined with the defconversion macro from camel-snake-kebab.macros:

(defconversion "PascalCase"           clojure.string/capitalize clojure.string/capitalize "")

I don't know the exact reason for why this fails, but it has something to do with the conversion functions being defined with a macro. Redefining the conversion functions with defn and not requiring camel-snake-kebab-core solves the issue for me:

(ns my-conversions
  (:require [camel-snake-kebab.internals.misc :as csk-misc]
            [camel-snake-kebab.extras :as cks-extras]
            [camel-snake-kebab.internals.alter-name :refer [alter-name]]
            [clojure.string :as string]))


(defn convert-case
  [first-fn rest-fn sep s]
  (alter-name s (partial csk-misc/convert-case first-fn rest-fn sep)))

(defn ->PascalCase [x] (convert-case string/capitalize string/capitalize "" x))
(defn ->Camel_Snake_Case [x] (convert-case string/capitalize string/capitalize "_" x))
(defn ->camelCase [x] (convert-case string/lower-case string/capitalize "" x))
(defn ->SCREAMING_SNAKE_CASE [x] (convert-case string/upper-case string/upper-case "_" x))
(defn ->snake_case [x] (convert-case string/lower-case string/lower-case "_" x))
(defn ->kebab-case [x] (convert-case string/lower-case string/lower-case "-" x))
(defn ->HTTP-Header-Case [x] (convert-case csk-misc/capitalize-http-header csk-misc/capitalize-http-header "_" x))

All of these are type preserving, but I don't see the need for defining explicit type converting functions like ->kebab-case-keyword when you can just do (comp keyword ->kebab-case)?

As far as I can tell this works the same as when using defconversion, I might be missing something here though so please correct me if I'm wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions