1

I have the following flycheck setup in my init.el

(use-package flycheck
      :after web-mode
      :config
      (global-flycheck-mode)
      (flycheck-add-mode 'javascript-eslint 'web-mode)
      :diminish flycheck-mode)

Now, I expect the line (flycheck-add-mode 'javascript-eslint 'web-mode) to add javascript-eslint as a linter whenever I have a buffer running web-mode. However, when inside a buffer using web-mode I get the following setup:

Syntax checkers for buffer .eslintrc.js in web-mode:

No checker to run in this buffer.

Checkers that are compatible with this mode, but will not run until properly configured:

  handlebars (disabled)
    - may enable: Automatically disabled!
    - predicate:  nil
    - executable: Not found

Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 32snapshot (package: 20191108.2129)
Emacs version:    25.2.2
System:           x86_64-pc-linux-gnu
Window system:    x

And if I try to manually select the syntax checker, I get:

Syntax checker in buffer .eslintrc.js in web-mode:

  javascript-eslint
    - major mode:  `web-mode' not supported
    - may enable:  yes
    - executable:  Found at /home/mfb/src/MyFantasyBasketball/frontend/mfb-spa/node_modules/eslint/bin/eslint.js
    - config file: found

Flycheck cannot use this syntax checker for this buffer.

Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 32snapshot (package: 20191108.2129)
Emacs version:    25.2.2
System:           x86_64-pc-linux-gnu
Window system:    x

Anyone have an idea what I'm missing?

P.S. For some reason my :diminish flycheck-mode line also doesn't work...

Edit: expanded use-package command

(progn
  (use-package-ensure-elpa 'flycheck
                           '(t)
                           'nil)
  (defvar use-package--warning313
    #'(lambda
        (keyword err)
        (let
            ((msg
              (format "%s/%s: %s" 'flycheck keyword
                      (error-message-string err))))
          (display-warning 'use-package msg :error))))
  (condition-case-unless-debug err
      (eval-after-load 'web-mode
        '(if
             (not
              (require 'flycheck nil t))
             (display-warning 'use-package
                              (format "Cannot load %s" 'flycheck)
                              :error)
           (condition-case-unless-debug err
               (progn
                 (global-flycheck-mode)
                 (flycheck-add-mode 'javascript-eslint 'web-mode)
                 (if
                     (fboundp 'diminish)
                     (diminish 'flycheck-mode))
                 t)
             (error
              (funcall use-package--warning313 :config err)))))
    (error
     (funcall use-package--warning313 :catch err))))

Also, I noticed it will work if I add the single line (flycheck-add-mode 'javascript-eslint 'web-mode) to my init.el. I just can't get it to work with use-package for some reason

Edit 2: flychecker-describe-checker output

javascript-eslint is a Flycheck syntax checker in `flycheck.el'.

  This syntax checker checks syntax in the major mode(s) `web-mode', `js-mode',
  `js-jsx-mode', `js2-mode', `js2-jsx-mode', `js3-mode', `rjsx-mode',
  `typescript-mode'.

  This syntax checker executes "eslint". The executable can be overridden with
  `flycheck-javascript-eslint-executable'.

  This syntax checker can be configured with these options:

     * `flycheck-eslint-args'
     * `flycheck-eslint-rules-directories'

Documentation:
A Javascript syntax and style checker using eslint.

See URL `https://eslint.org/'.

[back]
  • Something is going wrong because I manually did the add to mode and can see it supported for web-mode. What does flycheck-describe-checker say for javascript-eslint? – stsquad Dec 4 '19 at 16:40
  • actually I suspect the :config line might need to be wrapped in a (progn depending on how old your use-package is. Viewing the expanded macro (I use macrostep-expand) would verify the whole form is being correctly interpreted. – stsquad Dec 4 '19 at 16:44
  • @stsquad I added the full macro expansion. I don't see anything wrong and it's already wrapped in progn – Jacob Pavlock Dec 6 '19 at 1:35
  • What about the flycheck-describe-checker output? Have you tried applying the change manually? – stsquad Dec 6 '19 at 10:55
  • @stsquad added to my edits. I already tried applying the change manually and that's also in my op. – Jacob Pavlock Dec 10 '19 at 4:39

Your Answer

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

Browse other questions tagged or ask your own question.