Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Help from tslint-eslint rules? #74

Closed
gaurav21r opened this issue Aug 29, 2016 · 5 comments
Closed

Help from tslint-eslint rules? #74

gaurav21r opened this issue Aug 29, 2016 · 5 comments
Labels

Comments

@gaurav21r
Copy link

Hi there! I don't know a lot about the TS Language Services API but I am cheering for ESLint to support TS very soon! ESLint is pretty fantastic and I think we would all win if there are fewer tools covering a larger area! Besides, eslint configs are far superior to TSLint's.

This project -> https://github.com/buzinas/tslint-eslint-rules uses the reverse methodology. I was just wondering if the core team could have a look at it and get any help from it?

Sorry if this is the wrong place to post this!

@nzakas
Copy link
Member

nzakas commented Aug 29, 2016

@gaurav21r unfortunately, there's not a lot of value to ESLint TypeScript support from looking at that project. Basically, that project will be irrelevant if we do our job correctly because the core ESLint rules will just work. :)

I'm also privately working on a plugin with TypeScript-specific rules: https://github.com/nzakas/eslint-plugin-typescript. That's an area where we could definitely use help (the core ESLint team is not involved in that).

@nzakas nzakas closed this as completed Aug 29, 2016
@gaurav21r
Copy link
Author

@nzakas Thanks for your response! What is the difference between eslint-plugin-typescript and typescript-eslint-parser?

If I understood the goals of this project correctly (#13), typescript-eslint-parser will enable us to :

  1. Use standard ESLint rules (say the airbnb shareable config) with TS Code.
  2. Add TS specific rules for TS Code. (Eg: Type annotations should have a space)

@platinumazure
Copy link
Member

platinumazure commented Aug 29, 2016

Disclaimer: I don't actually work on these projects and don't know TypeScript, so I might be misusing some terminology here 😄

@gaurav21r typescript-eslint-parser is a parser that wraps the TypeScript compiler, and it basically transforms TypeScript code into a format that ESLint can use to walk through the code and allow the rules to run on the code. Using just typescript-eslint-parser will allow core ESLint rules to be run on TypeScript code, but any rules specific to TypeScript (e.g., anything that has to do with type inference) will not be run, because ESLint won't allow those rules into the core rule set (due to not being widely applicable to all JavaScript).

eslint-plugin-typescript is an ESLint plugin that contains TypeScript-specific rules. In theory, it could be run on JavaScript code using a parser that isn't typescript-eslint-parser, but in reality the rules would probably crash because they would inspect decorator or type information that the parser simply wouldn't provide.

So basically, the two projects work to add TypeScript to two different steps of the ESLint process-- parsing/code input, and linting rules. Basically, typescript-eslint-parser helps with your first point, and eslint-plugin-typescript will help with your second point.

Make sense?

@gaurav21r
Copy link
Author

@platinumazure Thanks a lot! Thats a great explanation! I was almost there except I thought this repo would handle both 1 & 2 points. Just to re-iterate, if I set .eslintrc to

{
  "extends": "airbnb",
  "parser": "typescript-eslint-parser"
}

My typescript code would get linted with the AirBnb rules config?

@platinumazure
Copy link
Member

Yes- when this project is ready, of course. :-)

On Aug 30, 2016 4:22 PM, "Gaurav Ramanan" [email protected] wrote:

@platinumazure https://github.com/platinumazure Thanks a lot! Thats a
great explanation! I was almost there except I thought this repo would
handle both 1 & 2 points. Just to re-iterate, if I set .eslintrc to

{
"extends": "airbnb",
"parser": "typescript-eslint-parser"
}

My typescript code would get linted with the AirBnb rules config?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#74 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AARWeg3oa7zJVPn5sM_tbQKN9-5aEtj8ks5qlItKgaJpZM4JvzrT
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants