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

Does rslint already support TypeScript? #87

Closed
zero734kr opened this issue Feb 21, 2021 · 16 comments
Closed

Does rslint already support TypeScript? #87

zero734kr opened this issue Feb 21, 2021 · 16 comments

Comments

@zero734kr
Copy link

zero734kr commented Feb 21, 2021

Hi,

I was testing rslint to see the difference with my eyes, but when I run rslint ***.ts it is throwing error: No matching files found.

This confused me because the description of this repo was saying:

A (WIP) Extremely fast JavaScript and TypeScript linter and Rust crate

After that error, I tried to lint some javascript files and it seems that there is no error.

Is this a bug or I need to do some other steps to lint typescript files?

Thanks!

@RDambrosio016
Copy link
Collaborator

Did you build from source? It supports TypeScript in the next version but i havent published 0.3 yet because i am lazy i have a couple more things to do

@zero734kr
Copy link
Author

I installed initially from cargo, but after that error, I tried to install from releases pages too, but apparently there is no difference between installing from cargo or prebuilt binaries from releases page

@zero734kr
Copy link
Author

My system is Linux Mint 20.1 Ulyssa (or just derivative of Ubuntu)

@RDambrosio016
Copy link
Collaborator

Yeah we publish all crates first to crates.io then add a release commit which builds binaries

@zero734kr
Copy link
Author

I converted my typescript file to javascript and now is working properly

@RDambrosio016
Copy link
Collaborator

I apologize for not having published a version which could actually lint TS before putting it in the readme. If you'd like to still try it you can git clone then either cargo build a binary or cargo run and feed it a path.

@zero734kr
Copy link
Author

zero734kr commented Feb 21, 2021

Ok, no problems. I'll wait for next publish to taste how rslint is good and close this issue after that

@zero734kr
Copy link
Author

I built rslint from source after running the git clone and it's working fine!

@suptejas
Copy link

Still waiting for a release 😅 , sometime soon would be great @RDambrosio016

@Stupremee
Copy link
Member

Oh yeah. Totally forgot about a new release. I will try to do a release ASAP.

@suptejas
Copy link

suptejas commented Jun 29, 2021

Also, if you don't mind me asking - I'm trying to basically use rslint to validate some code, though I want to call it directly through Rust.

So initially, I used:

let result = rslint_parser::parse_text_lossy(read_to_string(&f).unwrap().as_str().trim(), 0);

The above code worked just fine for Javascript files, though it didn't work for TS files.

I then moved the crates locally and imported the raw code, instead of downloading the crate from crates.io because the latest release didn't support TS yet.

The above code still doesn't look like it supports TS. What can I use to only validate syntax and stuff in TS and JS files? Which function should I use (I also want to display errors, and result.errors() gave me just that)?

@RDambrosio016
Copy link
Collaborator

You can make a typescript Syntax then give it to parse_with_syntax. Other functions assume default syntax which is just js

@suptejas
Copy link

@RDambrosio016 also was wondering, what does the file_id mean? Until now, I've just filled in 0 as the value, but wanted to understand its purpose

@RDambrosio016
Copy link
Collaborator

its used for rendering errors, at the start of linting, we build a map of IDs to file data in parallel, each file stores its line indices, line starts, etc. This info is then used for rendering errors, recomputing line info for each file for each error gets slow real quick, especially when you have big files

@suptejas
Copy link

Right, makes sense

@Stupremee
Copy link
Member

TS support is now in 0.3.0

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

No branches or pull requests

4 participants