[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/drupal-mode bd83268c5d 131/308: Add custom checker for che
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/drupal-mode bd83268c5d 131/308: Add custom checker for checking CSS/JS files with phpcs. |
Date: |
Tue, 25 Jan 2022 10:59:38 -0500 (EST) |
branch: elpa/drupal-mode
commit bd83268c5de11d47fffcc1e70a270ba868e00188
Author: Thomas Fini Hansen <xen@xen.dk>
Commit: Thomas Fini Hansen <xen@xen.dk>
Add custom checker for checking CSS/JS files with phpcs.
---
drupal/flycheck.el | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drupal/flycheck.el b/drupal/flycheck.el
index d3075bd801..58aeab0272 100644
--- a/drupal/flycheck.el
+++ b/drupal/flycheck.el
@@ -31,7 +31,14 @@
"Non-nil means don't highlight trailing whitespace when flycheck-phpcs is in
use.
Flycheck-phpcs will also highlight trailing whitespace as an error
so no need to highlight it twice."
- :type `(choice
+ :type `(choice
+ (const :tag "Yes" t)
+ (const :tag "No" nil))
+ :group 'drupal)
+
+(defcustom drupal/flycheck-phpcs-js-and-css t
+ "When Non-nil, override Flycheck to use PHPCS for checking CSS and
JavaScript files instead of the checkers configured for css-mode and js-mode."
+ :type `(choice
(const :tag "Yes" t)
(const :tag "No" nil))
:group 'drupal)
@@ -45,6 +52,12 @@ so no need to highlight it twice."
;; supported above.
(set (make-local-variable 'flycheck-phpcs-standard) drupal/phpcs-standard)
+ (when drupal/flycheck-phpcs-js-and-css
+ (if (apply 'derived-mode-p (append drupal-css-modes drupal-js-modes))
+ (set (make-local-variable 'flycheck-checker) 'css-js-phpcs)
+ )
+ )
+
;; Flycheck will also highlight trailing whitespace as an
;; error so no need to highlight it twice.
(when drupal/flycheck-phpcs-dont-show-trailing-whitespace
@@ -54,6 +67,28 @@ so no need to highlight it twice."
(add-hook 'drupal-mode-hook #'drupal/flycheck-hook)
+(flycheck-declare-checker css-js-phpcs
+ "Check CSS and JavaScript using PHP_CodeSniffer.
+
+PHP_CodeSniffer can be used to check non-PHP files, as exemplified by the
+Drupal code sniffer.
+
+See URL `http://pear.php.net/package/PHP_CodeSniffer/'."
+ :command '("phpcs" "--report=emacs"
+ (option "--standard=" flycheck-phpcs-standard)
+ source)
+ ;; Though phpcs supports Checkstyle output which we could feed to
+ ;; `flycheck-parse-checkstyle', we are still using error patterns here,
+ ;; because PHP has notoriously unstable output habits. See URL
+ ;; `https://github.com/lunaryorn/flycheck/issues/78' and URL
+ ;; `https://github.com/lunaryorn/flycheck/issues/118'
+ :error-patterns
+ '(("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)" error)
+ ("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)"
warning))
+ :modes '(css-mode js-mode)
+ :predicate #'(lambda ()
+ (apply 'derived-mode-p (append drupal-php-modes
drupal-css-modes drupal-js-modes))))
+
(provide 'drupal/flycheck)
- [nongnu] elpa/drupal-mode 89783165ad 225/308: Fixed wrong type argument in drupal-convert-line-ending., (continued)
- [nongnu] elpa/drupal-mode 89783165ad 225/308: Fixed wrong type argument in drupal-convert-line-ending., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 91cd3f9e2d 228/308: Added MELPA URLs to README., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 2f8ce00821 074/308: A functions args is shown in tooltip after 5 sec of idle time., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 7682fe81f5 079/308: Fixed argument tip when no window-system., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode cb918eb5f1 076/308: Defined defvars earlier in file to avoid using free variables., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 194db27ee9 091/308: Added skeleton position at end of skeleton., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 929af1cefc 097/308: Autoload `drupal-search-url' as safe-local-variable., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 9ea0f27c0e 098/308: Made `drupal-module-name' insert module name when called interactively., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 6c76c15e7c 100/308: Added auto-insert skeleton for .install files., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode fe8717b47c 106/308: Added `css-indent-offset'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode bd83268c5d 131/308: Add custom checker for checking CSS/JS files with phpcs.,
ELPA Syncer <=
- [nongnu] elpa/drupal-mode 889fc24427 145/308: Use setq., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 2517b39f42 154/308: Added a simple `drupal-tail-drupal-debug-txt` function., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 7d29d72a62 155/308: Added function to wrap string in t()., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode a08207b0c9 161/308: Merge branch 'release/0.3.1', ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 8f5a7568b0 159/308: Fixed `drupal-search-documentation` for PHP keywords., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 72ceba6089 174/308: Merge pull request #39 from xendk/develop, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 46ad71de46 170/308: Used `default-directory` as fallback if `buffer-file-name` us not set., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode f1985b5ca5 181/308: Merge branch 'release/0.4.0', ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 230e579786 185/308: Removed flymake-phpcs from `drush-make-mode' files., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 03b7e28b8d 192/308: Fixed bad indentation., ELPA Syncer, 2022/01/25