Setting up vite, React, TypeScript, eslint, prettier, vitest, testing-library and react-router

  Рет қаралды 102,584

Coding Garden

Coding Garden

Күн бұрын

Пікірлер: 154
@AlanRutter-h2m
@AlanRutter-h2m Жыл бұрын
I have been updating a react app that I 'inherited' and decided to use vite, vitest and eslint. I read through countless articles, all saying different things, all configuring their apps slightly differently. Then I found this video .... a presenter that speaks clearly, presents the content at a comfortable pace to follow along, doesn't rush or skip over important bits. One of the best coding tutorials I have come across. Thanks to this video, i was easily able to re-configure the app. Great job.
@maplestoryinchinese
@maplestoryinchinese 2 жыл бұрын
This is amazing! Quality content like this deserves so much more recognition.
@BJAnderson
@BJAnderson 2 жыл бұрын
Long time angular dev here. Was looking for a good tutorial on how to set up a real react project that I would actually use to build a professional (linted/formatted/tested) project from. This is that tutorial. A-ma-zing!!! Thank you so much!
@Cognitoman
@Cognitoman 10 ай бұрын
Yea not bad
@isurumaldeniya9536
@isurumaldeniya9536 Жыл бұрын
Thank you CJ for the super helpful video. If someone get error when accessing `toHaveTextContent` when writing tests add `import '@testing-library/jest-dom/vitest' ` in setupTest.ts file
@youngun550
@youngun550 2 жыл бұрын
8:32 to 8:37 is charming. I've seen this whole video 3 times now. It's really helped me get a firm sense of what eslint actually is and how to get a good ts environment. This is one of the best tutorials I've seen in a long time!
@rembautimes8808
@rembautimes8808 Жыл бұрын
An amazing video for productivity .
@michaela.178
@michaela.178 11 ай бұрын
Now that was a good tutorial! No point in excusing yourself for setting up tests the way you did. It's exactly what one would need to get started. I'd also add that one shouldn't get too obsessed with the designations of test types, you'll need those terms to keep some structure in your zoo of tests, eventually. Primarily, the set of all tests serves as cleverly laid out tripwires that keep us informed about unintentional changes, which helps our(future)selfes and anyone else getting on the project to make changes confidently.
@elenafromny9567
@elenafromny9567 Жыл бұрын
OMG! I tryied to set up jets for 2 days and now I found this video, thank you a lot!
@PraveenChaudhary-u7f
@PraveenChaudhary-u7f Жыл бұрын
Good work man, one of the best videos on setting up a Vite project with Vitest + RTL.
@wellingtonostemberg7585
@wellingtonostemberg7585 Жыл бұрын
Thank you too much! You helped me solving a problem, nobody says that we need to add the file information on tsconfig -> include, this helped me a lot
@shashikaharshana
@shashikaharshana 6 ай бұрын
What a video. Dude you are just amazing attention to the detail is awesome. Love the content keep it up my bro. Love from Sri Lanka.
@tukitukitsuki
@tukitukitsuki 2 жыл бұрын
Amazing! This is the first time I have seen such a detailed video.
@neddev2990
@neddev2990 2 жыл бұрын
You are so damn efficient at writing code! It's a pleasure to watch ;)
@papacktrue
@papacktrue 2 жыл бұрын
Thank you! so helpfull!
@CodingGarden
@CodingGarden 2 жыл бұрын
Thanks for your support! 💚
@ThomasPoth
@ThomasPoth 2 жыл бұрын
This video was very helpful for me. And there were no hiccups. I was able to code properly without any problems or weird bugs getting in my way. Thank you very much!
@abeljr88
@abeljr88 2 жыл бұрын
I have set up my own boilerplate in the past using also vite and some linting packages. But this video is complete that it includes test packages for testing. Love it.
@domoknows3275
@domoknows3275 Жыл бұрын
amazing tutorial. pretty much going to use this as my default starting vite project
@davidaviles5032
@davidaviles5032 Жыл бұрын
This was by far one of the most amazing videos I have ever seen. Setting up ESLint has been so foreign and walking through a good set up is much appreciated. I will say I had a lot of trouble configuring ESLint with Prettier This was because I had Prettier Extension installed as well as ESLint. I followed your steps but something was conflicting. I ended up turning off my Prettier Extension. Come to find out my formatting was not working and my prettier config file was not being recognized. I really do not know what. Everything worked when I added the prettier rules from my config file into my eslint config file, which according to docs, overrides prettier config file. So I ended up removing prettier config file, extended the prettier recommended as the video shown and any rules I did not like from the default linting rules for prettier formatting I added inside the prettier rules in the eslint file and everything worked as expected. For example JSX attributes would have double quotes fixed on save and js would allow single quotes. I know this was long but hope you read it and provide any insight you might have. Thnks again for the video
@Hattrick249
@Hattrick249 Жыл бұрын
thank you for this video, really appreciate you taking the time to walk through everything! I'm working through The Odin Project and am currently on the React testing lessons. They teach you how to use create-react-app to build applications (which has Jest and the react testing library configured out of the box), but I much prefer Vite. This video includes everything that I need to know to still follow the curriculum despite the differences in tech used.
@julianm786
@julianm786 Жыл бұрын
Thanks, I was struggling so much with the setup, you made it really easy
@theprimecoder4981
@theprimecoder4981 2 жыл бұрын
Thank you, I have been looking for this video for weeks.
@tiagonobrega8046
@tiagonobrega8046 2 жыл бұрын
This video was extremely helpful to me. Thank you for the great content man, you covered a lot of stuff and explained it all in a way that it was easy to understand!
@davidbrookoliver
@davidbrookoliver 2 жыл бұрын
Valeu!
@christiannikolov923
@christiannikolov923 2 жыл бұрын
So glad you uploaded it can't wait to get my hands on it.
@angelhdzdev
@angelhdzdev 2 жыл бұрын
Hey CJ, we don't need Auto Rename Tag extension anymore! The setting is Enable Linked Editing. Same with Bracket Pair Colorizer, the setting is Bracket Pair Colorization. Cheers!
@BenMakerProducer
@BenMakerProducer 2 жыл бұрын
Nice video !! It would have been great to see more examples with TypeScript and react-router (loaders, react-query, params, matches, ...) 😁
@dbmitrich
@dbmitrich Жыл бұрын
Thank you for this guide! I found answers to some questions I had before.
@Andrei-pq6qp
@Andrei-pq6qp 2 жыл бұрын
This is gold. Excellent explanations. I love it.
@zb2747
@zb2747 2 жыл бұрын
Thank you for this video - would love more on formatting and linting configuration, CI/CD automation tools, and more on testing.
@xxxMantou
@xxxMantou 6 ай бұрын
this is amazingly helpful setup tutorial, comfortable pace to follow alone!
@AI-su3ds
@AI-su3ds Жыл бұрын
I'm happy I found your channel. Thank you for helpful videos
@Fullflexno
@Fullflexno 2 жыл бұрын
Love it! Great job, CJ!
@paulraven8236
@paulraven8236 Жыл бұрын
nice! actually I came here to check my eslint config, but I'm vitesting now :D . I've never used testing libraries before, but man I'm hours just looking at dom checking accesibility and stuff. Thanks!! you improved my workflow :)
@riendlyf
@riendlyf Жыл бұрын
I was looking for that setup!! Thanks!!
@chuckydigitalworldwide
@chuckydigitalworldwide Жыл бұрын
That was amazing!! Thanks! Glad I found this channel
@belaldif6689
@belaldif6689 2 жыл бұрын
High quality content, we are looking for the next: React-testing-library 😁
@whoa_dood
@whoa_dood 2 жыл бұрын
Great Video CJ, thank you for all the hard work!
@fernandoferrari9937
@fernandoferrari9937 2 жыл бұрын
congrats for the video, so instructional. i was looking for something like this.
@rcchandan
@rcchandan 10 ай бұрын
Reloading VS Code is so normal, Its now part of the development process 😂😂. Great content though, Helped me migrate a codebase from webpage to vite.
@ievlevdmitriy
@ievlevdmitriy 2 жыл бұрын
Amazing! I've already shared this video to my friends. Thank you for your excellent job!
@christopheraulotte5277
@christopheraulotte5277 2 жыл бұрын
Really great tutorial. You know your subject, you are cool and fun when you talk. Amazing, I recommend.
@beakerbkr
@beakerbkr 2 жыл бұрын
Fantastic content with great instruction!
@endlessnameless3613
@endlessnameless3613 2 жыл бұрын
Big thanks for this! It would be nice do the same but with webpack. I mean React app from scratch, without CRA💫
@jonatankruszewski53
@jonatankruszewski53 2 ай бұрын
Amazing resource! Any chance that the setting can be uploaded to the new eslint flat config? airbnb doesn't support the new format :(
@kinglouis5190
@kinglouis5190 Жыл бұрын
sir i love your turorial am your follower from cameroon
@sanhvo6105
@sanhvo6105 Жыл бұрын
i am beginner. Thank you so much for sharing this useful knowledge. This is wonderfull
@sanjitselvan5348
@sanjitselvan5348 Жыл бұрын
Thanks for this setup video!
@stepo355
@stepo355 Жыл бұрын
Nice overview, thank you!
@agustinperez8700
@agustinperez8700 2 жыл бұрын
This video is weasome, It has all the configurations that you always look for
@djarma7980
@djarma7980 Жыл бұрын
Thank you a lot of for saving my time😅, this video help me a lot!
@sebastianchaca00
@sebastianchaca00 2 жыл бұрын
I have type error on my vite react app but still working, how can I make it throw an error like CRA ? I followed your steps but I don't know how s supposed to work. Thanks
@ArleiFerreiraFarnetaniJunior
@ArleiFerreiraFarnetaniJunior 2 жыл бұрын
Congratulations and thanks a lot! 👊👊👊
@jasonnares9634
@jasonnares9634 2 жыл бұрын
This is just amazing. Thank you so much.
@itamar-jr-tech
@itamar-jr-tech 2 жыл бұрын
I am use BrowserRouter to work at the browser because I put a specific path, for example path='/login'. And work my test too
@helloWorldPlus
@helloWorldPlus 2 жыл бұрын
Something I would add is the import order. It takes some time to be doing the imports order manually.
@flnnx
@flnnx Жыл бұрын
That was very informative. Thanks
@karlkrasnowsky3895
@karlkrasnowsky3895 Жыл бұрын
2:04 ... By naming it react-ts-app it automatically created tsconfig for you and you weren't prompted if you wanted typescript or not? what sort of magic is this?
@WaguanKing
@WaguanKing 11 ай бұрын
most video i watch abt that they are using mac os but im using windows sometimes while following up like when i want to use vite some files are missing and aloot of errors appears any advice
@KikeVanegas23
@KikeVanegas23 2 жыл бұрын
Great job!
@tesohi
@tesohi Жыл бұрын
jesus christ, it helped so much! I really thank you a lot!!
@abuzain859
@abuzain859 Жыл бұрын
Hey there! I watched your video and it is awesome . Now i am using the Vitest in my project but I am getting this error : ( Not implemented: window.computedStyle(elt, pseudoElt) at module.exports (C:\Users\Faizan\Desktop\full-stack ode_modules\jsdom\lib\jsdom\browser ot-implemented.js:9:17) )
@3ggr
@3ggr Жыл бұрын
awesome tutorial!🔥
@ontheruntonowhere
@ontheruntonowhere 2 жыл бұрын
I like almost everything about this but I feel like the WrappedApp thing is not efficient or necessary. Otherwise BIG PROPS to you for putting this all together. I'm integrating much of this into my own boilerplate setup. 👍👍
@adarshchhokar3818
@adarshchhokar3818 2 жыл бұрын
AYYY I LOVED THAT CATJAM
@alexandr8151
@alexandr8151 2 жыл бұрын
really useful video, thanks a lot!
@SidneiMV
@SidneiMV 2 жыл бұрын
Great job bro! video is liked.
@karlkrasnowsky3895
@karlkrasnowsky3895 Жыл бұрын
7:37 : Looks like the latest vite installer adds eslint by default.
@gargantooga
@gargantooga 2 жыл бұрын
this is gold!
@DmitriyLekomtsev
@DmitriyLekomtsev Жыл бұрын
Is there Vite template with all of this preconfigured?
@Pouetpouets
@Pouetpouets Жыл бұрын
Thanks, helped me a lot
@kabo123
@kabo123 2 жыл бұрын
is this compatible with the add storybook command?
@robmad0x
@robmad0x Жыл бұрын
I wholeheartly love this guy, just starting this type of project and this tutorial actually made it more managable and fun. Thanks a bunch my guy!🥲
@michelmbili
@michelmbili 2 жыл бұрын
Is there any reason for using function App () {} instead of the arrow function ?
@maplestoryinchinese
@maplestoryinchinese 2 жыл бұрын
Nope, only reason not to use an arrow function is when you're working with methods as using them would cause issues around the value of .this keyword
@temurkhan9601
@temurkhan9601 Жыл бұрын
very usefull video thank you for makin it. I have question I feel like I am following each steps one by one but somehow I still can manage to miss something or I dunno at some point I have a different result than the video. Can it be because now the codes changes a little or my previous setting are not allowing it or I am really missing something. Who else had a same issue ?
@CodingGarden
@CodingGarden Жыл бұрын
Sorry for the late reply. There were some breaking changes in version 6 of @testing-library/jest-dom I updated the template to include the fixes: github.com/CodingGarden/react-ts-starter/commit/a1b2aa106cacd5f2377a4b1800879e058e3bfe25
@temurkhan9601
@temurkhan9601 Жыл бұрын
@@CodingGarden u d man. Tyvm
@danielpreza4159
@danielpreza4159 2 жыл бұрын
do you have pettier installed either like a dependency or as an extension as well?
@CodingGarden
@CodingGarden 2 жыл бұрын
I have it as both a dependency and extension. The npm dependency is used in conjunction with eslint for "eslint fix all auto fixable problems". If I want to format files manually without eslint, I can run "Format Document With -> Prettier" in VS Code (this uses the prettier extension only).
@boyefrederic4716
@boyefrederic4716 2 жыл бұрын
Hi @Coding garden! This is an amazing content. I have a question though, can we do this kind of config with a nexjts project too
@CodingGarden
@CodingGarden 2 жыл бұрын
You can definitely use eslint and prettier with next.js, but not vite (next.js uses swc under the hood - swc.rs/). You should also be able to use vitest and test-library with next.js
@coderboysobuj
@coderboysobuj 2 жыл бұрын
Help -> React router dom with vite project doesn't work on server when i refresh the page, it's shows me server 404 page
@Cognitoman
@Cognitoman 10 ай бұрын
Ohh so the public is like a place for images, videos audio etc… so that when when you build your files they are safe. If you were to put images in the assets folder they would get deleted every time during build time… I deleted that public folder… wonder if there is way to just ignore folders or files… in your assets folder so it doesn’t get deleted..
@incacube
@incacube 2 жыл бұрын
great video for beginners like myself. i use prettier as extension in vscode, should i disable and use it as dependency?
@CodingGarden
@CodingGarden 2 жыл бұрын
I believe you need the extension installed for the eslint rules to work.
@hjrr6471
@hjrr6471 2 жыл бұрын
thank you for this kind vid
@bahramsarafzadeh8250
@bahramsarafzadeh8250 2 жыл бұрын
Nice! You're a life saver...
@morpheusmatrix1073
@morpheusmatrix1073 2 жыл бұрын
Hi great video ! But am getting some error. I choosed React at the first input, but the second just propose me javascript and typescript. So I choosed Javascript as variant. But am getting error in loading page "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/jsx". Strict MIME type checking is enforced for module scripts per HTML spec." Plz help
@kennethmatov1546
@kennethmatov1546 2 жыл бұрын
Very informative! Is there a way to automate all these initial setup steps?
@CodingGarden
@CodingGarden 2 жыл бұрын
You can click "use this template" on the github repo, or you can use a tool like degit. Repo is here: github.com/CodingGarden/react-ts-starter If you want to use degit, you can type "npx degit CodingGarden/react-ts-starter your-app-name", to create a folder with the base template.
@kennethmatov1546
@kennethmatov1546 2 жыл бұрын
@@CodingGarden Thank you so much.
@Lucas-av7
@Lucas-av7 2 жыл бұрын
Thanks, dude!
@jfeyers
@jfeyers Жыл бұрын
If anyone runs into an error (related to expect.extend(matchers);) in your jest setup upon running a test, change your matchers import to "import * as matchers from '@testing-library/jest-dom/matchers';"
@dheerajs5774
@dheerajs5774 Жыл бұрын
Tnx a lot man 🙏
@nikhilpandeydigital
@nikhilpandeydigital Жыл бұрын
Thank you so much
@zaphry
@zaphry Жыл бұрын
god is that you? came from the heavens to help us peasants???? love u
@asyncawaited
@asyncawaited 2 жыл бұрын
"This video is just starting, but you've probably been watching KZbin all day." Based.
@Okir09
@Okir09 6 ай бұрын
In the .eslintcr.cjs i get : 'module' is not defined. :( :( :( please help :(
@pkvpraveen
@pkvpraveen Жыл бұрын
When I converted all my jest based tests to vitest, It took a looong time to execute 😢
@DARSHAN1212
@DARSHAN1212 2 жыл бұрын
I 💌🍀Love Coding Garden!!
@som3ah0
@som3ah0 2 жыл бұрын
wow super wow really for such content ... wish this channel get bigger and bigger bist wishes for you really ... thank you so mush pro
@beshoosamy8452
@beshoosamy8452 2 жыл бұрын
Amazing Video! Can you make a video about deploying vite app with react-router-dom 6.6+ to GitHub pages?
@emil4483
@emil4483 2 жыл бұрын
Are you perhaps planning to release an edited version of 'Intro to React with TypeScript' on KZbin? I noticed that you jumped from "Intro to TypeScript + Express" directly to "Setting up vite..." Thanks!
@CodingGarden
@CodingGarden 2 жыл бұрын
I plan to re-do it sometime this week using this template as a starter. Last time I got a bit in the weeds. However, the VOD will be available on the archive channel soon.
@emil4483
@emil4483 2 жыл бұрын
@@CodingGarden Great news ✨
@emil4483
@emil4483 2 жыл бұрын
@@CodingGarden 😅 Hey CJ, is it safe to assume at this time that this episode is unlikely to appear? Greetings
@NewtonJR1987
@NewtonJR1987 2 жыл бұрын
Hey, thank you so much for the video, it's amazing. I'm having some trouble on this part 14:24 when we add the eslint parse option project: './tsconfig.json' In the same file (.eslintrc) the module declaration on top of the file says: Parsing error: Cannot read file 'tsconfig.json', and in the every other file on the first line. But the tsconfig file is in the root folder of the project, I don't know what to do now, can you help? EDIT: Oops, just found the answer from another user on the comments below: replace the project key from parserOptions with: project: ...... for tsconfigRootDir: __dirname
@quickguidesbynatanoob9867
@quickguidesbynatanoob9867 2 жыл бұрын
Can this also be used in JS react not TS? thanks
@CodingGarden
@CodingGarden 2 жыл бұрын
Yes that is possible. The airbnb setup would be slightly different but it is possible.
@GMEveryday
@GMEveryday 2 жыл бұрын
@@CodingGarden my biggest problem with vite react is it doesn't show errors on vscode terminal you have to constantly open browser console to see the problem. For beginners like me, it's time consuming. You know any work around with that?
@Krzysiekoy
@Krzysiekoy Жыл бұрын
10:01 - notice the squiggly line under module.exports on line 1. The error says: "module' is not defined. (eslint no-undef)". Holy shit, I was stuck on this for so long and it was so frustrating. What is so frustrating about this is that this file was created AUTOMATICALLY by using the official vite documentation (the command is yarn create vite your-app-name --template react-ts). I didn't touch shit, this is all created automatically, yet it still has an error... The app works even with this squiggly line but it is so frustrating because you think you have done something wrong. Another pain point is that there is no one obvious way to solve this. The error go away if you do one of the following: - remove eslint:recommended - replace eslint:recommended with something else (e.g. airbnb, like shown in this video) - change file extension from .cjs to .js - add node:true to the "env" object. Why does it have to be like that? How come that the official starter template comes with an error only for me to pull my hair out. /rant over
@CodingGarden
@CodingGarden Жыл бұрын
Yeah it is a bit frustrating when a freshly generated app gives errors like this. I just created an issue and opened a PR against vite to fix this in newly generated react apps. github.com/vitejs/vite/issues/13517 github.com/vitejs/vite/pull/13518
@Krzysiekoy
@Krzysiekoy Жыл бұрын
@@CodingGarden Wow, that is so cool, didn't think you'd take your time to respond since this is an old-ish video. Thanks, man, you rock!!!
@ОксанаКраснодемская-у7з
@ОксанаКраснодемская-у7з Жыл бұрын
Thank you!!!
@yolla_4
@yolla_4 2 жыл бұрын
what font are you using?
@CodingGarden
@CodingGarden 2 жыл бұрын
Anonymous Pro - more info here: github.com/CodingGarden/vscode-settings#font
@azamatcto
@azamatcto Жыл бұрын
where is placed expect() function
@thibao8726
@thibao8726 Жыл бұрын
thanks bro , you can help how can you show Emoji 8:05 same you
@Californ1a
@Californ1a 2 жыл бұрын
Personally not a huge fan of Prettier. Quite a few of the opinions in it don't match my preferred eslint configs, so format on save always ends up making eslint complain if I use Prettier, especially for stuff like arrow functions or ternaries (when to line break, place ? and : at start or end of line, use or don't use extra indent when nested, etc.). For that reason I've been using HookyQR's Beautify, but it hasn't been updated in over 3 years (so I've largely just been using the built-in formatter, since vscode 1.63.2 in Nov 2021 with the multi-language syntax) - I really wish there was a beautify/prettier-type of extension that just used your eslint config rather than their own opinions and much smaller list of options. There is Prettier ESLint, which just runs prettier and then eslint --fix, but that seems like a poor workaround for something that should just be built into the base formatting extension itself, using the actual eslint config for the formatting, rather than needing to format it twice. I'd essentially want the opposite of eslint-config-prettier, instead of disabling eslint rules to fit prettier, I'd want to override prettier rules to match eslint. The built-in formatter's been doing alright for me though.
@runningtractor
@runningtractor 2 жыл бұрын
eslint-plugin-prettier vs. prettier-eslint, which one is the best? another video about setting prettier-eslint?
@CodingGarden
@CodingGarden 2 жыл бұрын
eslint-plugin-prettier adds rules to your eslint config that correspond to prettier formatting rules, so when you run "eslint fix all auto fixable problems", it using prettier rules to auto fix things in a single command. prettier-eslint is separate from eslint and is a 2 part process. It first runs prettier to format your files and then "eslint fix all auto fixable problems". You can read more about this here: prettier.io/docs/en/integrating-with-linters.html
@alext5497
@alext5497 2 жыл бұрын
Just don't use prettier. Easy
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 506 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
Build a CRUD API with TypeScript, Express, MongoDB, Zod and Jest
1:38:56
This is the Only Right Way to Write React clean-code - SOLID
18:23
Vitest with React Testing Library, Jest-dom & MSW
18:44
Learn from Scratch
Рет қаралды 12 М.
ESLint with VSCode, Prettier, Husky and React For Beginners
35:03
Vite Crash Course | Faster Alternative To CRA
16:24
Traversy Media
Рет қаралды 224 М.
How To Debug React Apps Like A Senior Developer
21:07
Web Dev Simplified
Рет қаралды 196 М.
React Unit Testing Crash Course: Beginner to Advanced Guide
42:59
Monsterlessons Academy
Рет қаралды 4,3 М.
How to use Vitest with Jest-DOM and React Testing Library
12:19
EricWinkDev
Рет қаралды 41 М.
Everything I Learned Trying Laravel / PHP
19:37
Coding Garden
Рет қаралды 12 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН