Skip to content
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

ESlint for Typescript #1081

Closed
0x4d6165 opened this issue Sep 11, 2016 · 9 comments
Closed

ESlint for Typescript #1081

0x4d6165 opened this issue Sep 11, 2016 · 9 comments

Comments

@0x4d6165
Copy link

I attempted to enable ESlint in Typescript (which is now possible thanks to typescript-eslint-parser) by adding the line (flycheck-add-mode 'javascript-eslint 'typescript-mode) to my configuration and by selecting "javascript-eslint" from flycheck-select-checker in a Typescript file, that latter of which yields:

Syntax checker in buffer  *Flycheck checkers* in help-mode:

  javascript-eslint
    - major mode:         `help-mode' not supported
    - predicate:          t
    - executable:         Found at /home/gigavinyl/apps/.npm-packages/bin/eslint
    - configuration file: Not found

Flycheck cannot use this syntax checker for this buffer.

Flycheck Mode is disabled. Use SPC u M-x flycheck-disable-checker to enable
disabled checkers.

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

Flycheck version: 29snapshot (package: 20160826.941)
Emacs version:    24.5.2
System:           x86_64-unknown-linux-gnu
Window system:    x

. Is there anyway to quickly hack something together a way to enable ESlint in Typescript (I'm still quite a newbie to Emacs and Elisp so I may be missing an obvious solution)?

@fmdkdd
Copy link
Member

fmdkdd commented Sep 11, 2016

I don't have eslint or typescript-mode at hand, but it seems that you called flycheck-select-checker while in a help-mode buffer, hence the error.

Try to select the Typescript buffer first, then call flycheck-select-checker either via C-c ! s (the default binding, assuming you didn't remap it), or via the menu Tools -> Syntax Checking (assuming you didn't toggle it off), or via M-x flycheck-select-checker.

@Simplify
Copy link
Member

Hi @gigavinyl ,

Did you install typescript-mode first?
When editing typescript file type C-c ! v to display current checkers for typescript.
Make sure that you call flycheck-add-mode after flycheck is loaded:

(with-eval-after-load 'flycheck
    (flycheck-add-mode 'javascript-eslint 'typescript-mode)

Don't forget to install npm package that will add support for typescript in ESlint. There are two options if I remember correctly. You may need to configure ESlint to use that addon.

However, from my personal experience, I strongly suggest that you install tide that will provide code checking in flycheck and code completion in company using tsserver. Together with tslint checker provided by flycheck you'll get great dev environment for typescript.

@swsnr
Copy link
Contributor

swsnr commented Sep 23, 2016

@gigavinyl Were you able to fix the issue?

@Simplify
Copy link
Member

Simplify commented Mar 9, 2017

Hi @gigavinyl did you manage to solve this problem with suggestions above? I'll like to close this issue, but prefer to get your reply before doing that.

@ybiquitous
Copy link
Contributor

Hi. Recently the roadmap from TSLint to ESLint was announced:

Isn't Flycheck's default support meaningful yet?

@fmdkdd
Copy link
Member

fmdkdd commented Feb 26, 2019

Isn't Flycheck's default support meaningful yet?

Do you mean tha we should add typescript-mode as a default mode for the eslint checker?

@ybiquitous
Copy link
Contributor

Yes.

I am sorry for the confusing explanation. 🙇

DamienCassou pushed a commit to DamienCassou/flycheck that referenced this issue Apr 14, 2019
@aguynamedben
Copy link

aguynamedben commented Apr 29, 2019

I'm trying to use ESLint with typescript-mode this and can't get the recent code change working.

When I open a .ts file...

I get "No checker" in the bottom of my buffer...

image

M-x flycheck-select-checker in the typescript-mode buffer, then select javascript-eslint I get...

image

`M-x flycheck-version shows the up-to-date Melpa version which contains this change...
image

My Emacs config

;; https://emacs.stackexchange.com/questions/14898/flycheck-with-eslint-doesnt-use-eslintrc
(use-package flycheck
  :ensure t
  :custom
  (flycheck-display-errors-delay 0)
  :config
  (global-flycheck-mode)
  ;; disable jshint since we prefer eslint checking
  (setq-default flycheck-disabled-checkers (append flycheck-disabled-checkers '(javascript-jshint)))
  ;; Workaround for eslint loading slow
  ;; https://github.com/flycheck/flycheck/issues/1129#issuecomment-319600923
  (advice-add 'flycheck-eslint-config-exists-p :override (lambda() t)))

C-h v major-mode from the buffer shows typescript-mode, so I know the buffer is correctly being opened with typescript-mode. It just doesn't seem that flycheck wants to allow the javascript-eslint checker to be run from within typescript-mode.

UPDATE: In the same codebase I'm using flycheck + javascript-eslint checker from js2-mode... no problem... the executable is found. It seems maybe the path to the executable isn't being found, but only when in typescript-mode?

Any ideas?

@fmdkdd
Copy link
Member

fmdkdd commented Apr 30, 2019

It seems maybe the path to the executable isn't being found, but only when in typescript-mode?

Can you check the value of flycheck-javascript-eslint-executable in both cases?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants