|
1 | 1 | ;;; drupal/flycheck.el --- Drupal-mode support for flycheck and phpcs |
2 | 2 |
|
3 | | -;; Copyright (C) 2012, 2013 Arne Jørgensen |
| 3 | +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen |
4 | 4 |
|
5 | 5 | ;; Author: Thomas Fini Hansen <[email protected]> |
6 | 6 |
|
|
25 | 25 |
|
26 | 26 | ;;; Code: |
27 | 27 |
|
| 28 | +(eval-when-compile |
| 29 | + (require 'flycheck)) |
| 30 | + |
28 | 31 | (require 'drupal/phpcs) |
29 | 32 |
|
30 | 33 | (defcustom drupal/flycheck-phpcs-js-and-css t |
|
48 | 51 |
|
49 | 52 | (add-hook 'drupal-mode-hook #'drupal/flycheck-hook) |
50 | 53 |
|
51 | | -(flycheck-declare-checker css-js-phpcs |
| 54 | +(flycheck-define-checker css-js-phpcs |
52 | 55 | "Check CSS and JavaScript using PHP_CodeSniffer. |
53 | 56 |
|
54 | 57 | PHP_CodeSniffer can be used to check non-PHP files, as exemplified by the |
55 | 58 | Drupal code sniffer. |
56 | 59 |
|
57 | 60 | See URL `http://pear.php.net/package/PHP_CodeSniffer/'." |
58 | | - :command '("phpcs" "--report=emacs" |
59 | | - (option "--standard=" flycheck-phpcs-standard) |
60 | | - source) |
| 61 | + :command ("phpcs" "--report=emacs" |
| 62 | + (option "--standard=" flycheck-phpcs-standard) |
| 63 | + source) |
61 | 64 | ;; Though phpcs supports Checkstyle output which we could feed to |
62 | 65 | ;; `flycheck-parse-checkstyle', we are still using error patterns here, |
63 | 66 | ;; because PHP has notoriously unstable output habits. See URL |
64 | 67 | ;; `https://github.com/lunaryorn/flycheck/issues/78' and URL |
65 | 68 | ;; `https://github.com/lunaryorn/flycheck/issues/118' |
66 | 69 | :error-patterns |
67 | | - '(("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)" error) |
68 | | - ("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)" warning)) |
69 | | - :modes '(css-mode js-mode) |
| 70 | + ((error "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)") |
| 71 | + (warning "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)")) |
| 72 | + :modes (css-mode js-mode) |
70 | 73 | :predicate (lambda () |
71 | 74 | (and drupal/flycheck-phpcs-js-and-css (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes))))) |
| 75 | + |
72 | 76 | (add-to-list 'flycheck-checkers 'css-js-phpcs) |
73 | 77 |
|
74 | 78 |
|
|
0 commit comments