Giter Club home page Giter Club logo

Comments (10)

wordijp avatar wordijp commented on September 4, 2024

typescript-language-server supported ESLint/TSLint by plugins:
typescript-language-server/typescript-language-server#58
typescript-language-server/typescript-language-server#73

and, found ESLint plugin:
https://github.com/Quramy/typescript-eslint-language-service

Example usage in semicolon test case.

files

.
├── main.js
├── tsconfig.json
└── .eslintrc.yml

Intall node_modules

$ # `typescript` need install, hmm.
$ npm init -y
$ npm install \
  eslint \
  typescript \
  typescript-eslint-language-service \
  @typescript-eslint/parser \
  @typescript-eslint/typescript-estree

main.js

const message = 'hello';
console.log(message) // error

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "plugins": [
      {
        "name": "typescript-eslint-language-service"
      }
    ]
  }
}

.eslintrc.yml

parser: "@typescript-eslint/parser"
rules:
  semi: error

from vim-lsp-settings.

mattn avatar mattn commented on September 4, 2024

If you want to enable eslint always on typescript-language-server, you can specify plugin for initialization_options like @wordijp's comment.

from vim-lsp-settings.

Vanuan avatar Vanuan commented on September 4, 2024

What if my eslint config is named .eslintrc.json?

Edit: works too.

from vim-lsp-settings.

wordijp avatar wordijp commented on September 4, 2024

Just replace yaml to json.

.eslintrc.json

{
  "parser": "@typescript-eslint/parser",
  "rules" : {
    "semi": "error"
  }
}

from vim-lsp-settings.

Vanuan avatar Vanuan commented on September 4, 2024

Apparently, it needs the dependencies to be installed locally. I had typescript-language-server installed globally, so I thought global install would work.

from vim-lsp-settings.

Vanuan avatar Vanuan commented on September 4, 2024

Ok, the issue was that I already had [email protected] installed. yarn add eslint added version ^6.7 which is resolved to 6.8.0 and is incompatible with eslint plugins I had installed.

from vim-lsp-settings.

Vanuan avatar Vanuan commented on September 4, 2024

Thanks. Lessons learned:

  1. Make sure eslint command works and produces lint errors
  2. Make sure to install typescript-eslint-language-service locally instead of globally
  3. Add typescript-eslint-language-service to tsconfig.json plugins
  4. Make sure @typescript-eslint/parser parser is used for *.ts files

Small question: is there any noticeable difference between typescript-eslint-language-service and vscode-eslint? That is, would VSCode user notice the difference?

from vim-lsp-settings.

wordijp avatar wordijp commented on September 4, 2024

I checked each language server system.
I think the user experience depends on each editor, It seems that there is no difference in Linter result.
Because both are plugins that bridge the language server and eslint.
vscode-eslint bridges vscode-languageserver and eslint.
typescript-eslint-language-service bridges typescript-language-server plugin and eslint.

Supplementary information: please see typescript-eslint-language-service author's slide, slide=17 is system image page.
https://quramy.github.io/ts-eslint-talk/#slide=17

from vim-lsp-settings.

Vanuan avatar Vanuan commented on September 4, 2024

So typescript-eslint-language-service requires typescript-language-server? It seemed to work without it.

from vim-lsp-settings.

Vanuan avatar Vanuan commented on September 4, 2024

Anyway, I got it running, thank you for your help!

from vim-lsp-settings.

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.