TransWikia.com

Flycheck - Eslint: 'config file: missing or incorrect'

Emacs Asked by Ben.krck on September 2, 2021

After following the installation instructions I received this error:

javascript-eslint (disabled)
    - may enable:  Automatically disabled!
    - executable:  Found at /Users/ben/programming/eslint_test/node_modules/eslint/bin/eslint.js
    - config file: missing or incorrect

I have tried many things, yet nothing worked. Out of desperation I reinstalled my MacOS in the hope that a fresh install would fix things.

My steps:

  1. Fresh MacOS install. (Catalina, 10.15.6)
  2. Installed Emacs through Brew
  3. Installed the minimal amount of packages, like Flycheck and exec-path-from-shell (see config file below)
  4. Made a simple Eslint project. (main.js, with eslint init)
  5. C-c ! v in the main.js buffer
  6. Received the error
  7. From the terminal: eslint main.js -> success
  8. From the terminal: eslint --describe-config main.js -> success

Running M-x describe-variable RET exec-path returns:

Its value is
("/usr/local/bin/" "/usr/bin/" "/bin/" "/usr/sbin/" "/sbin/" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_14/" "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_14/" "/Applications/Emacs.app/Contents/MacOS/libexec/")
Original value was 
("/usr/local/bin" "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_14" "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_14" "/Applications/Emacs.app/Contents/MacOS/libexec")

My config file:

(require 'package)

(add-to-list 'package-archives
             '("MELPA Stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages (quote (exec-path-from-shell js2-mode web-mode flycheck))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(when (memq window-system '(mac ns))
  (exec-path-from-shell-initialize))

;; turn on flychecking globally
(add-hook 'after-init-hook #'global-flycheck-mode)

;; use local eslint from node_modules before global
;; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
(defun my/use-eslint-from-node-modules ()
  (let* ((root (locate-dominating-file
                (or (buffer-file-name) default-directory)
                "node_modules"))
         (eslint (and root
                      (expand-file-name "node_modules/eslint/bin/eslint.js"
                                        root))))
    (when (and eslint (file-executable-p eslint))
      (setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)

No google search led me in the right direction. I tried this with a global eslint, and with a local one. Both fail.

Eslint version: 7.4.0

One Answer

run command eslint --print-config ./xxx.js to see what cause the error

Answered by user3113626 on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP