Skip to content
Yoann Cribier edited this page May 30, 2018 · 4 revisions

React setup (client)

https://www.youtube.com/watch?v=NhTiSfu2LK4&

Clone

git clone git@github.com:akabab/todos-client-react.git
cd todos-client-react

Branch

git checkout -b react-setup

React-Create-App

# uninstall yarn (si yarn fais chier)
brew uninstall --force yarn

# Generate app in current directory
npx create-react-app .

commit

git add . && git commit -m "Init create-react-app"

Storybook

npx storybook

commit

git add . && git commit -m "add storybook"

Lint

npm install --save-dev eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard stylelint stylelint-config-standard

add lint scripts in package.json

scripts: {
  // ...
  "lint": "npm run lint:js && npm run lint:css",
  "lint:js": "eslint .",
  "lint:css": "stylelint 'src/**/*.css'",
  "lint:fix": "eslint --fix . && stylelint --fix 'src/**/*.css'"
}

create .stylelintrc config file

{
  "extends": "stylelint-config-standard"
}

create .eslintrc config file

{
  "extends": [
    "react-app",
    "standard"
  ]
}

Fix lint errors

npm run lint:fix

commit

git add . && git commit -m "add lint"

EditorConfig

.editorconfig

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Indentation override for all JS under lib directory
[*.{js,json}]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
max_line_length = 80

commit

git add .editorconfig && git commit -m "add editorconfig"

Si ce n'est pas deja fait, installer le plugin EditorConfig pour votre editeur http://editorconfig.org/#download

Travis

.travis.yml

language: node_js
node_js:
  - "node"
branches:
  only:
    - dev
    - master
jobs:
  include:
    - stage: style
      script: npm run lint
    - stage: test
      script: npm run test

commit

git add .travis.yml && git commit -m "add travis"


Faite votre pull request sur github pour merge votre branche init-setup vers master.

πŸ‘ πŸŽ‰ πŸ‘ πŸŽ‰ πŸ‘ πŸŽ‰ πŸ‘ πŸŽ‰

Clone this wiki locally