NEXT.js setting with airbnb eslint & prettier application & styled components

Lewis Kim·2020년 1월 7일
0
  • What is Next.js
    Next.js is react framework for server rendered applications.

  • Installation
    First, create an app in the project directory
    like me~

image.png

Screen Shot 2020-01-07 at 4.58.03 pm.png

This command creates you a project folder with basic next.js project folders.

Now open package.json in the next-project file and change package.json scripts.

Screen Shot 2020-01-07 at 5.02.14 pm.png

You have to add the below code into the package.json just right above one.
Screen Shot 2020-01-07 at 5.02.39 pm.png

Then you can run with your npm client dev script

Screen Shot 2020-01-07 at 5.03.47 pm.png

Now you can open http://localhost:3000 from your favourite browser.
Since we didnt create our index.jsx in pages there will be nothing to show. Now lets create our pages/index.jsx file.

Screen Shot 2020-01-07 at 5.06.00 pm.png

Success for this page!!!!
Now you stepped into the world of Next.js

  • eslint application apply into NEXT.js

  • Installation
    Go into the directory and open the terminal. write the below code for installing 'airbnb eslint' - airbnb is norm of the world now
    Screen Shot 2020-01-07 at 5.08.00 pm.png

  • Configuration
    Let’s create .eslintrc.json file to specify settings in our application as below.
    You can edit your configuration as your requirements. Here is my configuration.

Screen Shot 2020-01-07 at 5.09.49 pm.png

Screen Shot 2020-01-07 at 5.10.43 pm.png
copy and paste for this code in the .eslintrc file.

After add configuration, also change some code in package.json file

Screen Shot 2020-01-07 at 5.12.40 pm.png
like this. Originally it only has "react-app" extends, but add "airbnb" to use.

Having that, you will face this red underlines for your code!!!

Screen Shot 2020-01-07 at 5.14.14 pm.png

Don't be packiced of this one.

You can refer this blog for solving one.
https://velog.io/@velopert/eslint-and-prettier-in-react
https://medium.com/@melih193/next-js-start-web-development-with-next-js-create-next-app-4042ca071dcb

Since I didn't use the library for Create Next App, I have to make file "gitignore". If I don't make this file and push on the GitHub, my node_modules which have more than 5,000 files will be sync to git repository. So I have to make like this.

Screen Shot 2020-01-07 at 5.30.53 pm.png

This one is for the Styled components
https://frontendmantra.com/using-next-js-with-styled-components-easy-way/

Sincerely

0개의 댓글