I ran into an issue trying to set up jsxhint checker (following these instructions). The following code runs fine when pasted into a buffer and executed with eval-region:
(flycheck-define-checker jsxhint-checker
"A JSX syntax and style checker based on JSXHint."
:command ("jsxhint" "--harmony" source)
:error-patterns
((error line-start (1+ nonl) ": line " line ", col " column ", " (message) line-end))
:modes (web-mode))
and syntax checking works as expected. However, when I add this code to init.el and restart emacs I am getting an error:
Warning (initialization): An error occurred while loading `/home/itkach/.emacs.d/init.el':
Symbol's function definition is void: flycheck-define-checker
and with --debug-init:
Debugger entered--Lisp error: (void-function flycheck-define-checker)
(flycheck-define-checker jsxhint-checker "A JSX syntax and style checker based on JSXHint." :command ("jsxhint" "--harmony" source) :error-patterns ((error line-start (1+ nonl) ": line " line ", col " column ", " (message) line-end)) :modes (web-mode))
eval-buffer(#<buffer *load*> nil "/home/itkach/.emacs.d/init.el" nil t) ; Reading at buffer position 3081
load-with-code-conversion("/home/itkach/.emacs.d/init.el" "/home/itkach/.emacs.d/init.el" t t)
load("/home/itkach/.emacs.d/init" t t)
#[0 "\205\262 \306=\203 \307\310Q\202; \311=\204 \307\312Q\202; \313\307\314\315#\203* \316\202; \313\307\314\317#\203: \320\nB\321\202; \316\322\323\322\211#\210\322=\203a \324\325\326\307\327Q!\"\323\322\211#\210\322=\203` \210\203\243 \330!\331\232\203\243 \332!\211\333P\334!\203} \211\202\210 \334!\203\207 \202\210 \314\262\203\241 \335\"\203\237 \336\337#\210\340\341!\210\266\f?\205\260 \314\323\342\322\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" (initialization "`_emacs' init file is deprecated, please use `.emacs'") "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7 "\n\n(fn)"]()
command-line()
normal-top-level()
Flycheck version: 0.23alpha (package: 20150112.1039)
I had the same error with an earlier version and upgraded to latest from MELPA which did not fix it.
I also tried setting up the checker in after-init-hook hook - same issue.
Here's my init.el: https://bitbucket.org/itkach/emacsd/src/90ae3c36178080aa77a8ec3ef72d1c280a825fc0/init.el?at=default
Flycheck version: 0.23alpha (package: 20150112.1039)
GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
of 2014-03-07 on lamiak, modified by Debian
You need to load Flycheck before defining checkers, i.e. M-x load-library RET flycheck or insert (require 'flycheck) before the syntax checker definition.
M-x load-library RET flycheck or insert (require 'flycheck)
Indeed, that was it. Thanks a lot!
:+1: I ran into the same thing, thanks for the answer @itkach
Most helpful comment
You need to load Flycheck before defining checkers, i.e.
M-x load-library RET flycheckor insert(require 'flycheck)before the syntax checker definition.