-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Documentation: Getting Started Guide and User Journeys #36
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
Comments
I think for your second point, it would be great to have an example of ESLint rules for typescript, written in typescript. Happy to help out with this however is most helpful. To me it seems like the most important things for this are:
I realise all these projects are still in their infancy - but certainly interested in learning more and helping out. |
The |
@johnwiseheart Regarding the |
Ahh sweet, will give it a try now that #37 has been merged. How do you folks feel about the typeguard note - would that be something you think should live in this monorepo too, or better off just being an external thing? Understand if you're more concerned about writing rules for typescript rather than in typescript. Can also make a separate issue to track this if you think that makes sense. |
I think providing guidance in the repo for writing custom rules is definitely desired 👍 |
So how does one configure .eslintrc in order to lint *.ts files using this project? |
@qwelias simplest use case will be: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#usage // .eslintrc
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"]
} and from cli you have to run: eslint --ext .ts src |
Things I'd probably like to see in our documentation: I.e. if I'm a user looking to lint the non-null operator, which rules can I look to? This sort of documentation would make it easier for us to organise our rules, as we can look to rolling settings into rules based on related lint behaviour instead of based on language features. As an example: #202 relates to the non-null operator. If we had documentation saying "non-null operator linting is touched on in these rules X, Y Z", then we could go either way without worrying too much about it. |
Hi, fascinating project. I'm mostly in (2)... Is the idea to replace .eslint.json:
tslint.json:
|
yes, the idea is to replace tslint completely. have a look at our ROADMAP for alternates to tslint rules that you can use. There's also our Make sure you configure prettier if you want it to set a specific quote style. |
Thanks @bradzacher , I'm much smarter now. For anyone reading, my new .eslint.json:
tslint.json is empty, and .prettierrc sets |
I try to setup eslint for Typescript for one project. This project uses webpack with a
Running
AFIK I can not change this in the file a import. Is there an way to set a eslint config to work with Typescript and JavaScript or do I need two config files and lint them separately? |
@StefanSchoof you can either disable the rule for that file with a disable comment, or you can use eslint overrides to control the rules for the different types of files in your project. |
Do you plan sharing some info about using Webpack and eslint-loader? I've setup my eslintrc file according to the docs and have this error
I assume this is not the place to get help with this issue but in general it'd be helpful to have some note for Webpack users, quite a large crowd. Also not sure where to open a separate issue, wether in this repo or in eslint-loader. Any guidance will be much appreciated. UPDATE: looks like an issue with my version of eslint (e.g. |
it's not an issue with webpack, scoped plugins in eslint are supported since version 5 and if you are using >=5.0.0 you can simply setup this like this: (tested and its working) {
test: /\.(js|ts)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [path.resolve('./src')]
}, |
Thanks. I ended up with: module.exports = {
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
},
"overrides": [
{
"files": "*.js",
"rules": {
"@typescript-eslint/no-var-requires": "off"}
}
]
}; I other thing, that take me some time, where the missing lightbulbs in vs code, see microsoft/vscode-eslint#609 |
If anyone is wondering why the ESLint VSCode plugin auto-fix doesn't work, you're missing this setting:
It basically tells the plugin that ESLint also works for typescript files. |
Hi. I am looking into getting started with Typescript, and currently use the ESLint pluign in vscode and airbnb rules modified to work with Prettier (I manually removed rules that the supplied CLI util said were conflicting) Right now I would say that the state of documentation for how to get going with linting typescript using ESLint with Prettier and a supplied set of rules is awful. All the applications are fragmented and in a total state of flux. I would say that most developers wanting to switch to typescript would be VERY likely to: a. being using vscode I know this is not everyone, but if it were me I would have no idea where to start. Having to plough through endless out of date blog articles is a waste of time and effort. As a normal user I would first go to the eslint home page: no mention of typescript there, so I use the search and this is the only thing that turns up: https://eslint.org/blog/2019/01/future-typescript-eslint#the-future-of-typescript-on-eslint OK, so I learn that typescript support is new and is going to get better. I click the link to the main home of TypeScript linting: https://github.com/typescript-eslint/typescript-eslint What do I do? How do I make it work with VS Code? How do I add my ESlint rules? How do I make it work with Prettier? May I propose you guys contact the ESLint people and first get their web page changed from:
to
and make the word TypeScript be a link to this Github. Now write some docs explaining in easy to understand language how to achive the a, b, c and d points listed above in the .README docs. All the info hidden in this thread needs to be on the front page. Cheers! |
You shouldn’t need to modify the Airbnb config. |
@David-Else - we work very closely with the eslint team. That being said, we aren't affiliated with them as an "org". At the time of writing, googling for typescript eslint returns our repo as the second link, and googling for eslint typescript returns us as the fifth. As more people click the links, SEO will improve. Documentation is on our todo list. But we are but a few devs doing this in what free time we can find around our work and life. A large portion of the open source time I specifically allocate myself is just triaging issues + reviewing prs (so much so my other projects have fallen into disrepair). Be the change you want to see - if you think the documentation on here is awful, we are 100% open to PRs improving it. If that's not something you're interested in, that's perfectly acceptable - we'll get around to it when we have time. |
@bradzacher I hope I didn't come off as negative, I was just trying to give the point of view of a total new comer to TypeScript and show the issues I am finding in the user journey. I did not know that this project was all volunteer, I assumed that as TypeScript is created and actively promoted by MicroSoft they would be volunteering some manpower into such an important project. Maybe they can be persuaded? They spend a lot of resources promoting TypeScript, they have a huge vested interest in this working well. Unfortunately I am a total beginner at TypeScript and was only just Googling about seeing how to set it up! When I get up and running I will be in a much better position to contribute, and would love to help. I think linting is very important for code quality, and that is very important for everyone. I am sure the SEO will continue to go well. If I can help in the future I will, and thanks for all the time you and the other devs have put into this! |
Sorry, I wasn't trying to have a go. Probably came off a bit strong, sorry. Was just highlighting that we're happy to have as many contributors as we can, for code and for documentation. There are a number of Microsoft folks pitching in; you'll see them submitting PRs to add missing tslint rules and helping with the parser layer, but AFAIK there's no "concentrated" effort. We're still a new repo, it was only about 2 months ago that we merged the 4 projects together. We'll get there eventually :) |
I found some mentions about |
Kind of frustrating getting Prettier running with an airbnb config at the moment. You will have to read through eslint-config-prettier to come to the conclusion that a lot of autofixes and most of formatting is not supported. Single Quotes, Multi spaces, Max-Lines all sort of "most beneficial" auto formatting rules will not work. Maybe this lib is ready for daily usage, but defenitly not for an easy kickstart.. EDIT Got somewhere acceptable with this:
Last thing I would like to adjust ist the "new-line-on-chaining-methods" to allow 3 method calls to be inline. |
@NikoMontana Using eslint-config-prettier will disable every single rule that is covered by prettier's formatting. Of you want to instead use the style imposed by eslint, you can either:
I would hazard against the second one for now, as their library is broken and won't work with this plugin out of the box; it requires some manual patching (see the PRs on their repo for more info). On many of my projects I've had it working perfectly by doing the first option. It also works fine in vscode if you use the prettier extension for formatting and then turn on the eslint extension's autlfix on save. Could you please expand upon what was frustrating about the setup experience? I'm not quite sure I understand your frustrations with this plugin or its interaction with other config. |
@bradzacher Thank you for the explaination, this was a step further for understanding all things combined. My codebase looks like this now: .eslintrc.js
.vscode/settings.json
package.json
And this works for me like expected! Besides the formatting of the method chaining - but for now I can live with that. This config seems to trigger the whole formating process twice though, because by saving the changes, the code will jump into false formating and jump right back. Sure, I will give my best to explain what I didnt understand - still dont understand.
At this point the linting worked very well and like expected. Last but not least I wanted to format on save by the given linting rules with prettier. So I read the Note, installed eslint-config-prettier and did this:
This config formated the code but in a unsatisfying way (ofc opinionated) because there was no "universal" style. For example I could line-break method chains like I wanted without triggering the formatter. One line could have 3 line breaks and the next one could be single lined. So I created an issue. Because I was so dumb that I didnt understood that "prettier" in the extends section will overwrite ALL rules - my fault! So finally I got here and tried this configuration where I realized that Hope that helps you! |
Yeah I know it sucks, not much you can do about it for now. The vscode prettier extension has Turning on eslint's autofixer in the extension is a hacky compromise for now. There are configuration options for prettier btw The only downside to prettier is that it's entirely opinionated. For me I've found it took a bit of getting used to (I used to work at a startup where I had complete control over the code style, now I work at facebook where prettier is on by default, and enforced). Once I let go and accepted I couldn't control it, I found that it wasn't that bad, and the time and effort it saves you in formatting is actually amazing. In addition that is the fact that it is pretty strict, so everyone's code looks the same, meaning you spend less (or usually zero) time nitpicking formatting choices. Awesome, so it looks like in the end, it wasn't a problem with the config of this project, but the config of the eslint ecosystem as a whole. Do you think there's anything we could have documented better within this project? |
@JamesHenry @bradzacher I want to contribute to the project so where should I start? |
@moulikcipherX - this is a decent filter for the list of issues that need working on I've generally been pretty quick with handling bugs, so the vast majority are enhancements. It would probably be better to start with an issue tagged with |
@JamesHenry @bradzacher I am currently working as a GSoC Intern in Salesforce and I am creating an eslint-plugin for them. Should I proceed with the existing Creating ESlInt Plugin method? |
@moulikcipherX It depends. If the answer is no to both of those questions, then sure, follow the article you linked. You don't need the tooling we've created. If the answer is yes to either (or both) of those questions, then you can create a new plugin as easy as this (I should probably write some docs for this).
|
@bradzacher our users use both typescript and javascript. |
@bradzacher I think typescript is good to use instead of javascript. |
Hello @bradzacher, I have created my plugin as per the instructions so, should I run I am having a problem after I build using |
Have a play with the typescript config so that you get the desired result. |
I think the option you’re looking for is |
Hello @bradzacher |
For now, just |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@moulikcipherX @j-f1 Is there a more appropriate place to discuss this? Either in a new issue, or in some other support channel? I don't think this should be the place to discuss general rule creation issues. |
I think that this issue has gone off the rails all over the place. |
@moulikcipherX Feel free to open a new issue if you’re still having trouble. |
I'm going to close and unpin this. We are so much further along than we were when I opened this, with 1000s of developers successfully using the documentation we have to use the project effectively. If there are specific weaknesses/areas for improvement they can be addresses in a more focused way |
We should document the potential journeys to guide users through setting up our various packages. I see three main paths:
I want to start linting my TypeScript project with ESLint
I am already linting my TypeScript project with TSLint and I want to switch to ESLint
I am converting my project from JavaScript to TypeScript and I want to keep using ESLint
I think breaking down the docs like this will make everything much more approachable.
The text was updated successfully, but these errors were encountered: