All Projects β†’ greglook β†’ Cljstyle

greglook / Cljstyle

Licence: epl-1.0
A tool for formatting Clojure code

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Cljstyle

Format.cmake
πŸ’… Stylize your code! Automatic clang-format and cmake-format targets for CMake.
Stars: ✭ 94 (-36.49%)
Mutual labels:  linter, style
EditorConfig-Action
πŸ”ŽA GitHub Action to check, enforce & fix EditorConfig style violations
Stars: ✭ 40 (-72.97%)
Mutual labels:  linter, style
standard-packages
List of packages that use `standard`
Stars: ✭ 32 (-78.38%)
Mutual labels:  linter, style
standard-www
πŸ‘† Website for JavaScript Standard Style (@standard)
Stars: ✭ 28 (-81.08%)
Mutual labels:  linter, style
Proselint
A linter for prose.
Stars: ✭ 3,836 (+2491.89%)
Mutual labels:  linter, style
Kcc
k crash course
Stars: ✭ 127 (-14.19%)
Mutual labels:  style
Pt Three Ways
Path tracing, done three ways
Stars: ✭ 135 (-8.78%)
Mutual labels:  style
Mypy
Optional static typing for Python
Stars: ✭ 11,995 (+8004.73%)
Mutual labels:  linter
Php Cs Fixer Configurator
Inspect PHP-CS-Fixer fixers and easily configure them
Stars: ✭ 124 (-16.22%)
Mutual labels:  style
Rubocop
A Ruby static code analyzer and formatter, based on the community Ruby style guide.
Stars: ✭ 11,593 (+7733.11%)
Mutual labels:  linter
Expo Dark Mode Switch
A beautiful React dark mode switch component for iOS, Android, and Web
Stars: ✭ 137 (-7.43%)
Mutual labels:  style
Drstring
DrString finds issues in your Swift docstrings and fixes them for you.
Stars: ✭ 133 (-10.14%)
Mutual labels:  linter
Njsscan
njsscan is a semantic aware SAST tool that can find insecure code patterns in your Node.js applications.
Stars: ✭ 128 (-13.51%)
Mutual labels:  linter
Nitpick
Enforce the same settings across multiple language-independent projects
Stars: ✭ 134 (-9.46%)
Mutual labels:  linter
Stylablenavigationbar
🧸 StylableNavigationBar provide a lightweight replacement for a standard UINavigationController, so you can easily manage your navigation and status bar styles throughout your iOS app
Stars: ✭ 127 (-14.19%)
Mutual labels:  style
Pep8 Git Hook
Git pre-commit hook that checks for Python PEP8 style compliance.
Stars: ✭ 143 (-3.38%)
Mutual labels:  style
Style Dictionary
A build system for creating cross-platform styles.
Stars: ✭ 2,097 (+1316.89%)
Mutual labels:  style
Css Animation 101 Cn
ε­¦δΉ ε¦‚δ½•δΈΊδ½ ηš„ Web η¨‹εΊζ·»εŠ εŠ¨ζ•ˆ
Stars: ✭ 132 (-10.81%)
Mutual labels:  style
Ale
Check syntax in Vim asynchronously and fix files, with Language Server Protocol (LSP) support
Stars: ✭ 11,380 (+7589.19%)
Mutual labels:  linter
Rstcheck
Checks syntax of reStructuredText and code blocks nested within it
Stars: ✭ 130 (-12.16%)
Mutual labels:  linter

cljstyle

CircleCI codecov

cljstyle is a tool for formatting Clojure code. It can take something messy like this:

(  ns
 foo.bar.baz  "some doc"
    (:require (foo.bar [abc :as abc]
        def))
    (:use foo.bar.qux)
    (:import foo.bar.qux.Foo
      ;; Need this for the thing
      foo.bar.qux.Bar)
    )

(defn hello "says hi" (
      [] (hello "world")
  ) ([name]
  ( println "Hello," name  )
  ))

...and restyle it into nicely-formatted code like this:

(ns foo.bar.baz
  "some doc"
  (:require
    [foo.bar.abc :as abc]
    [foo.bar.def]
    [foo.bar.qux :refer :all])
  (:import
    (foo.bar.qux
      ;; Need this for the thing
      Bar
      Foo)))


(defn hello
  "says hi"
  ([] (hello "world"))
  ([name]
   (println "Hello," name)))

Note that this is a rewrite of the original weavejester/cljfmt tool to provide more capabilities and configurability as well as a native-compiled binary.

Installation

Binary releases are available on the GitHub project. The native binaries are self-contained, so to install them simply place them on your path.

Releases are also published to Clojars. To use the latest version, add the following dependency to your project:

Clojars Project

macOS via Homebrew

cljstyle can be installed on macOS via a Homebrew Cask:

brew cask install cljstyle

Usage

The cljstyle tool supports several different commands for checking source files.

Check and Fix

To check the formatting of your source files, use:

cljstyle check

If the formatting of any source file is incorrect, a diff will be supplied showing the problem, and what cljstyle thinks it should be.

If you want to check only a specific file, or several specific files, you can do that, too:

cljstyle check src/foo/core.clj

Once you've identified formatting issues, you can choose to ignore them, fix them manually, or let cljstyle fix them with:

cljstyle fix

As with the check task, you can choose to fix a specific file:

cljstyle fix src/foo/core.clj

The pipe command offers a generic way to correct style by reading Clojure code from stdin and writing the reformatted code to stdout:

cljstyle pipe < in.clj > out.clj

This command resolves configuration from the directory it is executed in, since there is no explicit file path to use.

Debugging

For inspecting what cljstyle is doing, one tool is to specify the --verbose flag, which will cause additional debugging output to be printed. There are also a few extra commands which can help understand what's happening.

The find command will print what files would be checked by cljstyle. It will print each file path to standard output on a new line:

cljstyle find [path...]

The config command will show what configuration settings cljstyle would use to process the specified files or files in the current directory:

cljstyle config [path]

Finally, version will show what version of the tool you're using:

cljstyle version

Integrations

cljstyle can be integrated into many different tools, including shells, editors, and tests. See the integration docs for more details.

Configuration

The cljstyle tool comes with a sensible set of default configuration built-in and may additionally be configured by using a hierarchy of .cljstyle files in the source tree. The configuration settings include toggles for format rules, width constraints, and the indentation rules.

Ignoring Forms

By default, cljstyle will ignore forms which are wrapped in a (comment ...) form or preceeded by the discard macro #_. You can also optionally disable formatting rules from matching a form by tagging it with ^:cljstyle/ignore metadata - this is often useful for macros.

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].