ReactJS
yarn create react-app (nome-da-pasta/projeto)
React Native
npx react-native init (nome-da-pasta/projeto)
(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
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
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',
},
};
{
"singleQuote": true,
"trailingComma": "es5"
}
root = true
[*]
end_of_line = lf
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true