Skip to content

Instantly share code, notes, and snippets.

@mfdorst
Last active July 25, 2019 01:29
Show Gist options
  • Save mfdorst/868720062419cfda2742c7882a9180d8 to your computer and use it in GitHub Desktop.
Save mfdorst/868720062419cfda2742c7882a9180d8 to your computer and use it in GitHub Desktop.
Node.js Notes

React

Installing create-react-app

$ npm i -g create-react-app

Creating a new react app

$ npm init react-app <app-name>

ESLint and Prettier

A specific version of eslint comes preinstalled, do not install your own - things will break.

$ npm i prettier eslint-config-prettier eslint-plugin-prettier husky lint-staged pretty-quick -D

Configuring ESLint and Prettier

Create a file named .eslintrc in the root directory of the app. It should contain:

{
  "extends": ["react-app", "plugin:prettier/recommended"]
}

Automatic linting on git commit

In package.json, add:

"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
}

Prettier rules

Prettier rules go in .prettierrc.json, in the root directory of the app.

My preferred prettier rules are as follows:

{
  "semi": false,
  "singleQuote": true,
  "trailingComma": "es5"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment