-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make clj-kondo hook's name match the fully qualified name of the symb…
…ol it's linting (#17817)
- Loading branch information
Showing
3 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{:hooks {:analyze-call {utils.i18n/label hooks.core/i18n-label}} | ||
{:hooks {:analyze-call {utils.i18n/label utils.i18n/label}} | ||
:linters {:status-im.linter/invalid-translation-keyword {:level :error}}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(ns utils.i18n | ||
(:require [clj-kondo.hooks-api :as hooks])) | ||
|
||
(defn label | ||
"Verify call to `utils.i18n/label` pass the translation keyword qualified with `t`." | ||
[{:keys [node]}] | ||
(let [[_ translation-key-node & _] (:children node)] | ||
(when (and (hooks/keyword-node? translation-key-node) | ||
(not= "t" (-> translation-key-node hooks/sexpr namespace))) | ||
(hooks/reg-finding! (assoc (meta translation-key-node) | ||
:message "Translation keyword should be qualified with \"t\"" | ||
:type :status-im.linter/invalid-translation-keyword))))) | ||
|
||
(comment | ||
;; Valid | ||
(label {:node (hooks/parse-string "(i18n/label :t/foo {:var \"hello\"})") | ||
:cljc false | ||
:lang :cljs | ||
:filename "" | ||
:config {} | ||
:ns "" | ||
:context nil}) | ||
|
||
;; Invalid | ||
(label {:node (hooks/parse-string "(i18n/label :foo)")}) | ||
) |