-
-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flycheck fails in an indirect region buffer #2011
Comments
I was able to cirvumvent the problem by customising the checker to use :command ("eslint" ;; ...
"--stdin" "--stdin-filename" source) My complete customisation looks as follows. For some reason I ended up hard-coding the (defun bvr-flycheck-eslint--find-working-directory (_checker)
"Look for a working directory to run ESLint CHECKER in.
This will be the directory that contains the `node_modules'
directory. If no such directory is found in the directory
hierarchy, it looks first for `.eslintignore' and then for
`.eslintrc' files to detect the project root."
(let* ((file (or (buffer-file-name) default-directory)))
(when file
(or (locate-dominating-file file "node_modules")
(locate-dominating-file file ".eslintignore")
(locate-dominating-file file ".eslintrc")
(locate-dominating-file file ".eslintrc.js")
(locate-dominating-file file ".eslintrc.json")
(locate-dominating-file file ".eslintrc.yaml")
(locate-dominating-file file ".eslintrc.yml")))))
(flycheck-define-checker bvr-javascript-eslint
"A Javascript syntax and style checker using eslint.
See URL `https://eslint.org/'."
:command ("eslint" "--format=json"
(option-list "--rulesdir" flycheck-eslint-rules-directories)
(eval flycheck-eslint-args)
"--stdin" "--stdin-filename" source)
:standard-input t
:error-parser flycheck-parse-eslint
:enabled (lambda () (flycheck-eslint-config-exists-p))
:modes (js-mode js-jsx-mode js2-mode js2-jsx-mode js3-mode rjsx-mode
typescript-mode js-ts-mode typescript-ts-mode tsx-ts-mode)
:working-directory bvr-flycheck-eslint--find-working-directory
:verify
(lambda (_)
(let* ((default-directory
(flycheck-compute-working-directory 'bvr-javascript-eslint))
(have-config (flycheck-eslint-config-exists-p)))
(list
(flycheck-verification-result-new
:label "config file"
:message (if have-config "found" "missing or incorrect")
:face (if have-config 'success '(bold error))))))
:error-explainer
(lambda (err)
(let ((error-code (flycheck-error-id err))
(url "https://eslint.org/docs/rules/%s"))
(and error-code
;; skip non-builtin rules
(not ;; `seq-contains-p' is only in seq >= 2.21
(with-no-warnings (seq-contains error-code ?/)))
`(url . ,(format url error-code))))))
(add-to-list 'flycheck-checkers 'bvr-javascript-eslint) |
This code is merely an adaptation for flycheck eslint to use `source' instead of `source-original' as the argument for commandline. For more details, ref: flycheck/flycheck#2011
For posterity, I have created this simple workaround https://github.com/bvraghav/dotelisp/blob/master/bvr-flycheck-eslint.el And I leave it to the good judgement of maintainers to close this issue. |
Thank you for taking the time to report an issue and improve Flycheck. This template is for actual bugs you observed. If you have trouble setting up Flycheck, or if you have a question, please use the relevant issue template instead.
Checklist
Bug description
flycheck-eslint
fails in an edit-indirect setting, maybe since there's no filename associated.My guess is that because
flycheck-eslint
command is configured with, the part where
"--stdin-filename" source-original
is hard-coded,source-original
evaluates tonil
in case of an indirect buffer causing the eslint executable to fail.Steps to reproduce
In file
${PROJ}/tmp/foo.js
flycheck-verify-setup
givesIn file
${PROJ}/tmp/foo.org
,flycheck-verify-setup
givesBut, at cursor position
[I]
do
C-c '
to edit indirect-ly as js buffer, andflycheck fails with this this message
Expected behavior
I don't know for sure, but I guess that
flycheck
should send the buffer-contents as stdin, because there's no associated(buffer-file-name)
Screenshots
If applicable, add screenshots to help explain your problem.
System configuration
Emacs configuration:
Additional notes
The difference in invoked
flycheck-command
I had tried to get to the root cause using this step
The text was updated successfully, but these errors were encountered: