├── README.md └── flycheck-credo.el /README.md: -------------------------------------------------------------------------------- 1 | # flycheck-credo [![MELPA](https://melpa.org/packages/flycheck-credo-badge.svg)](https://melpa.org/#/flycheck-credo) 2 | 3 | [flycheck][] checker for [credo][]. 4 | 5 | ## Installation 6 | 7 | You can install this package from [Melpa][] 8 | 9 | ``` 10 | M-x package-install RET flycheck-credo RET 11 | ``` 12 | 13 | ## Usage 14 | 15 | Ensure that `credo` is installed in your project. 16 | 17 | Then, in your `init.el`: 18 | 19 | ```elisp 20 | (eval-after-load 'flycheck 21 | '(flycheck-credo-setup)) 22 | (add-hook 'elixir-mode-hook 'flycheck-mode) 23 | ``` 24 | 25 | This package works with both [elixir-ts-mode](https://github.com/wkirschbaum/elixir-ts-mode) and [elixir-mode](https://github.com/elixir-editors/emacs-elixir). 26 | 27 | ## Options 28 | 29 | You can tell flycheck-credo to call credo with the '--strict' argument. 30 | 31 | ```elisp 32 | (setq flycheck-elixir-credo-strict t) 33 | ``` 34 | 35 | ## Thanks 36 | 37 | * [@rrrene][] for [credo][]. 38 | * [@lunaryorn][] for [flycheck][]. 39 | 40 | [flycheck]: http://www.flycheck.org/ 41 | [credo]: https://github.com/rrrene/credo 42 | [@rrrene]: https://github.com/rrrene 43 | [@lunaryorn]: https://github.com/lunaryorn 44 | [Melpa]: http://melpa.milkbox.net/ 45 | -------------------------------------------------------------------------------- /flycheck-credo.el: -------------------------------------------------------------------------------- 1 | ;;; flycheck-credo.el --- flycheck checker for elixir credo 2 | 3 | ;; Copyright (C) 2016 by Aaron Jensen 4 | 5 | ;; Author: Aaron Jensen 6 | ;; URL: https://github.com/aaronjensen/flycheck-credo 7 | ;; Version: 0.1.0 8 | ;; Package-Requires: ((flycheck "29")) 9 | 10 | ;;; Commentary: 11 | 12 | ;; This package adds support for credo to flycheck. 13 | 14 | ;; To use it, require it and ensure you have elixir-mode set up for flycheck: 15 | 16 | ;; (eval-after-load 'flycheck 17 | ;; '(flycheck-credo-setup)) 18 | ;; (add-hook 'elixir-mode-hook 'flycheck-mode) 19 | 20 | ;;; License: 21 | 22 | ;; This file is not part of GNU Emacs. 23 | ;; However, it is distributed under the same license. 24 | 25 | ;; GNU Emacs is free software; you can redistribute it and/or modify 26 | ;; it under the terms of the GNU General Public License as published by 27 | ;; the Free Software Foundation; either version 3, or (at your option) 28 | ;; any later version. 29 | 30 | ;; GNU Emacs is distributed in the hope that it will be useful, 31 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | ;; GNU General Public License for more details. 34 | 35 | ;; You should have received a copy of the GNU General Public License 36 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 37 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 38 | ;; Boston, MA 02110-1301, USA. 39 | 40 | ;;; Code: 41 | (require 'flycheck) 42 | 43 | (defun flycheck-credo--working-directory (&rest _ignored) 44 | "Find directory with from which we can run credo." 45 | (and buffer-file-name 46 | (locate-dominating-file buffer-file-name "deps/credo"))) 47 | 48 | (flycheck-def-option-var flycheck-elixir-credo-strict nil elixir-credo 49 | "Enable strict mode in credo. 50 | 51 | When non-nil, pass the `--strict' flag to credo." 52 | :type 'boolean 53 | :safe #'booleanp) 54 | 55 | (flycheck-define-checker elixir-credo 56 | "Elixir credo checker." 57 | :command ("mix" 58 | "credo" 59 | (option-flag "--strict" flycheck-elixir-credo-strict) 60 | "--format" 61 | "flycheck" 62 | "--read-from-stdin" 63 | source-original) 64 | :standard-input t 65 | :predicate 66 | (lambda () (and buffer-file-name 67 | (locate-dominating-file buffer-file-name "deps/credo"))) 68 | :working-directory flycheck-credo--working-directory 69 | :error-patterns 70 | ((info line-start (file-name) ":" line ":" column ": " (or "F" "R" "C") ": " (message) line-end) 71 | (info line-start (file-name) ":" line ": " (or "F" "R" "C") ": " (message) line-end) 72 | (warning line-start (file-name) ":" line ":" column ": " (or "D" "W") ": " (message) line-end) 73 | (warning line-start (file-name) ":" line ": " (or "D" "W") ": " (message) line-end)) 74 | :modes (elixir-ts-mode elixir-mode)) 75 | 76 | ;;;###autoload 77 | (defun flycheck-credo-setup () 78 | "Setup flycheck-credo. 79 | Add `elixir-credo' to `flycheck-checkers'." 80 | (interactive) 81 | (add-to-list 'flycheck-checkers 'elixir-credo t)) 82 | 83 | (provide 'flycheck-credo) 84 | ;;; flycheck-credo.el ends here 85 | --------------------------------------------------------------------------------