Giter VIP home page Giter VIP logo

Comments (2)

bvraghav avatar bvraghav commented on May 24, 2024

I was able to cirvumvent the problem by customising the checker to use source instead of source-original

:command ("eslint" ;; ... 
          "--stdin" "--stdin-filename" source)

My complete customisation looks as follows. For some reason I ended up hard-coding the find-working-directory routine, which may not be necessary.

(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)

from flycheck.

bvraghav avatar bvraghav commented on May 24, 2024

For posterity, I have created this simple workaround el.

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.

from flycheck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.