Create React 17 TypeScript With ESLint , WebPack & SCSS

1. Initialize our project

Nacef Otay
eDonec
4 min readApr 12, 2021

--

Let’s start by creating a new directory then initialize our project:

2. Install React & TypeScript

To install React, TypeScript, run the following commands in a Terminal:

Create anindex.tsx file in the src folder

  • Create the App.ts component

3. Create Tsconfig.json in your project’s root directory

4. Adding Eslint

5. Installing and Configuring WebPack

WebPack Dependencies:

Let’s Install some Scss dependencies to work with our Webpack config file

  • ts-loader : TypeScript loader for Webpack
  • style-loader & CSS-loader : for loading CSS & SCSS files

Dependencies:

lets create webpack.config.ts in the root of our project folder and add the following to it:

  • ts-loader : TypeScript loader for Webpack
  • style-loader & CSS-loader : for loading CSS & SCSS files

6. Adding SCSS to our App

  • Create our SCSS file under src/ styles.scss
  • Import your .scss files in your React components like App.js
  • Testing Eslint :
ESLINT Warning

To start our React project, we will need to update our package.json

  • run yarn lint for fixing automatically Any ESLint errors
  • To start the project simply run :
Terminal

Final Touches :

We will add Prettier to standardize our code

we will create two files .prettierrcand .prettierignore

  • .prettierrc
  • .prettierignore

Add a few more settings to the .eslintrc file to integrate it with prettier.

Enable auto format in save for VSCODE

go to preferences -> Settings search for formatOnSave and check the checkbox

Or add this line to settings.json

This code can be found on GitHub

Thanks for reading, I hope you found this piece useful!

This has been developed by myself at eDonec

--

--