{"id":23942964,"url":"https://github.com/ertugrulcetin/lein-nsort","last_synced_at":"2025-04-12T14:52:48.697Z","repository":{"id":62433341,"uuid":"311159139","full_name":"ertugrulcetin/lein-nsort","owner":"ertugrulcetin","description":"Leiningen plugin that checks that order of namespace declarations for Clojure and ClojureScript","archived":false,"fork":false,"pushed_at":"2021-05-13T16:34:09.000Z","size":28,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T11:57:53.933Z","etag":null,"topics":["clojure","clojurescript","leiningen","linter","namespace"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ertugrulcetin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-08T21:33:11.000Z","updated_at":"2024-05-25T14:13:45.000Z","dependencies_parsed_at":"2022-11-01T20:45:49.580Z","dependency_job_id":null,"html_url":"https://github.com/ertugrulcetin/lein-nsort","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertugrulcetin%2Flein-nsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertugrulcetin%2Flein-nsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertugrulcetin%2Flein-nsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertugrulcetin%2Flein-nsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ertugrulcetin","download_url":"https://codeload.github.com/ertugrulcetin/lein-nsort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586230,"owners_count":21128995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","clojurescript","leiningen","linter","namespace"],"created_at":"2025-01-06T05:17:21.459Z","updated_at":"2025-04-12T14:52:48.680Z","avatar_url":"https://github.com/ertugrulcetin.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lein-nsort\n\nLeiningen plugin that checks that order of namespace declarations for Clojure and ClojureScript\n\n## Usage\n\n[![Clojars Project](https://clojars.org/lein-nsort/latest-version.svg)](https://clojars.org/lein-nsort)\n\n### Adding the dependency to `:plugins`\n\nAdd `[lein-nsort \"0.1.14\"]` into the `:plugins` vector of your\n`project.clj` or `~/.lein/profiles.clj`.\n\n```clj\n(defproject my-project\n  :plugins [[lein-nsort \"0.1.14\"]])\n```\n\n### Running the checker\n\nRun the nsort like this:\n\n```\nlein nsort\n```\n\nThis will check `ns` declaration forms for all Clojure and ClojureScript source files in\nthe `{:nsort {:source-paths [\"src\"]}}` of your project (default `./src/`).\n\n### Output\n```clj\n(ns bloom.report.utils.citeproc\n  (:require [clojure.data.json :as json]\n            [bloom.server.config :refer [config]]\n            [clj-http.client :as http]))\n\n;; After running check\n--- bloom.report.utils.citeproc :require form should be sorted like this:\n\n(:require\n [bloom.server.config :refer [config]]\n [clj-http.client :as http]\n [clojure.data.json :as json])\n\n```\n\n## Automatically replacing namespace declarations in source files\n```\nlein nsort --replace\n```\nOR\n```\nlein nsort -r\n```\n\n## Configuration (Optional)\n\nAdd a `:nsort` key to your `project.clj` to customize the checker.\n\n```clj\n(defproject my-project\n  :nsort {:require :asc ;;(default)\n          :import  :desc\n          :source-paths [\"src\"] ;;(default)\n          :ignored-nses [my.app.core]\n          })\n```\n\nThere are 4 pre-defined sorting checks for `:require` and 2 for `:import`.\n\n**require**: `:asc`, `:desc`, `:alias-bottom-asc` and `:alias-bottom-desc`\n\n**import**: `:asc` and `:desc`\n\n`:alias-bottom-asc` and `:alias-bottom-desc` keep namespaces without aliases at the bottom and sort rest of the namespace declarations:\n\n```clj\n;; :alias-bottom-asc\n(:require\n [clojure.java.io :as io]\n [clojure.pprint :as pp]\n [clojure.tools.namespace.find :as ns-find]\n [clojure.string])\n```\n\nAlso you can **define** your own sorting functions like:\n```clj\n{...\n:nsort {:require {:sort-fn (juxt #(.indexOf % :as) first)}\n        :import  {:sort-fn first\n                  :comp    #(compare %2 %1)}} ;; converting to (sort-by first #(compare %2 %1) namespace-decls)\n...}\n```\n\n## License\n\nMIT License\n\nCopyright (c) 2020 Ertuğrul Çetin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fertugrulcetin%2Flein-nsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fertugrulcetin%2Flein-nsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fertugrulcetin%2Flein-nsort/lists"}