Skip to content

Instantly share code, notes, and snippets.

@fnoquiq
Last active October 14, 2022 10:13
Show Gist options
  • Save fnoquiq/61b2b1ba02482a49e97b48d64cf40f37 to your computer and use it in GitHub Desktop.
Save fnoquiq/61b2b1ba02482a49e97b48d64cf40f37 to your computer and use it in GitHub Desktop.
React start and config project

Criando projeto do zero com REACT

Rode os seguintes comandos para iniciar o projeto:

ReactJS

yarn create react-app (nome-da-pasta/projeto)

React Native

npx react-native init (nome-da-pasta/projeto)

Aguarde a instalação e criação do projeto


Configurando ambiente de desenvolvimento

Rode os seguintes comandos para configurar o ambiente de desenvolvimento:

(OBS: Não se esqueça de entrar na nova pasta criada pelo create react-app)

yarn add eslint -D

yarn eslint --init

? How would you like to use ESLint? To check syntax, find problems, and enforce code style

? What type of modules does your project use? JavaScript modules (import/export)

? Which framework does your project use? React

? Does your project use TypeScript? No

? Where does your code run? (Press to select, to toggle all, to invert selection) Browser (for ReactJs) and None (for React Native)

? How would you like to define a style for your project? Use a popular style guide

? Which style guide do you want to follow? Airbnb (https://github.com/airbnb/javascript)

? What format do you want your config file to be in? JavaScript

? Would you like to install them now with npm? Yes

Aguarde a instalação e configuração do eslint, e execute o comando abaixo:

yarn add prettier eslint-config-prettier eslint-plugin-prettier babel-eslint eslint-plugin-react-hooks -D

Crie os arquivos .prettierrc, .eslintrc.js e .editorconfig para o diretório root deste projeto e então cole a seguinte configuração

.eslintrc.js

module.exports = {
  env: {
    es6: true,
    jest: true,
    browser: true,
  },
  extends: ['airbnb', 'prettier', 'prettier/react'],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
    __DEV__: true,
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  plugins: ['react', 'jsx-a11y', 'import', 'react-hooks', 'prettier'],
  rules: {
    'prettier/prettier': 'error',
    'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx'] }],
    'import/prefer-default-export': 'off',
    'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
    'react/jsx-one-expression-per-line': 'off',
    'global-require': 'off',
    'react-native/no-raw-text': 'off',
    'no-param-reassign': 'off',
    'no-underscore-dangle': 'off',
    camelcase: 'off',
    'no-console': ['error', { allow: ['tron'] }],
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'warn',
  },
};

.prettierrc

{
  "singleQuote": true,
  "trailingComma": "es5"
}

.editorconfig

root = true

[*]
end_of_line = lf
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment