0

Suppose I have the following Flycheck checker:

(flycheck-def-config-file-var flycheck-jscs
                              javascript-jscs
                              ".jscs"
                              :safe #'stringp)

(flycheck-define-checker javascript-jscs
                         "A jscs code style checker."
                         :command ("jscs" "--reporter" "checkstyle"
                                   (config-file "--config" flycheck-jscs) source)
                         :error-parser flycheck-parse-checkstyle
                         :modes (js-mode js2-mode js3-mode)
                         :next-checkers (javascript-jshint))

(provide 'flycheck-jscs)

How do I add a :predicate that tells flycheck to disable the checker if flycheck-jscs is nil?

I only manage to get this message regardless what code I try with:

Error while checking syntax automatically:

(invalid-function (quote (not (not (quote flycheck-jscs)))))

  • A little extra bit of info: jscs is a style checker for JavaScript. You define your style in a .jscs file. If that file doesn't exist, running the checker doesn't make much sense so the goal is to disable the checking them altogether. – Mattias Bengtsson Jan 29 '15 at 16:30
  • What about the :predicate property ? – politza Jan 30 '15 at 8:53
  • That's what I'm trying to do :) – Mattias Bengtsson Jan 30 '15 at 8:54
  • I overlooked the colon... It would be easier, if you'd posted what value you've tried. But judging from the output, you used a sexp rather than a function. – politza Jan 30 '15 at 8:58
1

It looks like you tried to pass a sexp rather than a function. The argument to :predicate needs to be a proper function, that is, a lambda in your case:

:predicate (lambda () flycheck-jscs)

I'm pretty sure that I documented this, so I wonder why you tried it in a different way. Did you find the documentation lacking or unclear? I'd love to fix it, if possible.

There's little use in the double negation, by the way. Flycheck only tests for truthy-ness, but never for t.

  • Hm, you are correct, my ELisp is really not that great, I was passing a sexp just like you say. That specific line still didn't work though, jscs is still being called even if there's no .jscs file. – Mattias Bengtsson Feb 5 '15 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.