Giter Site home page Giter Site logo

cljfmt-runner's Introduction

cljfmt-runner

CircleCI No Maintenance Intended

Cljfmt runner for native Clojure projects.

This project is unmantained and archived. If you still need this functionality, please refer to one of the many fabulious forks.

Operation

The runner detects any Clojure or Clojurescript files located in the src and test directories when run.

It can be run in two modes:

  • check will check all source files and will return a diff of any proposed changes. It also returns a nonzero exit code on any incorrectly formatted files and so is suitable for use in a continuous integration build to enforce code style correctness.
  • fix will fix any problems it sees in source files and write the updated changes to disk.

Installation

Recommended approach is to use an alias in your deps.edn file, bring in this project as a dependency, and set the main class to the operation you want to perform.

Example

Within an :alias block:

  :lint {:extra-deps {com.jameslaverack/cljfmt-runner
                      {:git/url "https://github.com/JamesLaverack/cljfmt-runner"
                       :sha "97960e9a6464935534b5a6bab529e063d0027128"}}
         :main-opts ["-m" "cljfmt-runner.check"]}
  :lint/fix {:main-opts ["-m" "cljfmt-runner.fix"]}

You can then run check with clojure -A:lint and lint/fix with clojure -A:lint:lint/fix.

You can, of course, name these aliases whatever you want.

The following one liner also works:

clojure -Sdeps "{:deps 
                   {com.jameslaverack/cljfmt-runner
                      {:git/url \"https://github.com/JamesLaverack/cljfmt-runner\"
                       :sha \"97960e9a6464935534b5a6bab529e063d0027128\"}}}" -m cljfmt-runner.check

It's advisable to find the most recent sha from this repo for latest features.

Configuration

If you want to automatically scan directories in addition to src and test, then you can specify them in a cljfmt.edn file at the top level of your project directory.

{:dirs ["extra-dir"]}

Alternatively, you can specify extra directories on the command line with the -d flag.

For example, using the alias setup from the example above, if you wanted to scan a dev directory for Clojure sources too then you could do this with clj -A:lint -d dev.

License

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

Copyright © 2018 James Laverack.

Portions of this code (in particular src/cljfmt_runner/diff.clj) are © 2016 James Reeves and taken from https://github.com/weavejester/cljfmt

cljfmt-runner's People

Contributors

biserkov avatar iku000888 avatar jameslaverack avatar mpenet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cljfmt-runner's Issues

How to check deps.edn format?

Seems like currently the filename pattern config option is not supported, which by default does not scan for edn files.

Add support for reading from deps.edn paths

Instead of a new cljfmt config file, or specifying extra dirs at the CLI, is it possible to reuse the existing path info in deps.edn?

E.g.: if aliases called dev and test added certain directories to the paths, then clojure -R:dev:test -A:lint should check the added path dirs.

.cljc support

Could this be extended to support cljc files as well?

Currently its ignoring cljfmt.edn for `:indents` configuration

I have a file cljfmt.edn on my root folder with

{:indents {flow               [[:block 1]]
           facts              [[:block 1]]
           fact               [[:block 1]]
           as-customer        [[:block 1]]
           as-of              [[:block 1]]
           assoc-if           [[:block 1]]
           let-entities       [[:block 2]]
           defspec            [[:block 1]]
           constraint-fn      [[:block 2]]
           quick-check        [[:block 1]]
           for-all            [[:block 1]]
           provided           [[:inner 0]]
           tabular            [[:inner 0]]
           consume!           [[:block 0]]
           try-type           [[:block 0]]
           with-fn-validation [[:block 0]]
           system-map         [[:block 0]]}}

but that's being ignored by the runner

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.