Skip to content

Instantly share code, notes, and snippets.

@iaurg
Last active September 25, 2019 23:41
Show Gist options
  • Save iaurg/d73490ef52d267c74907966ac12f1386 to your computer and use it in GitHub Desktop.
Save iaurg/d73490ef52d267c74907966ac12f1386 to your computer and use it in GitHub Desktop.
Commands for initial react app with eslint, editorconfig, transpiler, prettier...
root = true
[*]
end_of_line = lf
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'airbnb',
'prettier',
'prettier/react'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser:'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
'prettier'
],
rules: {
'prettier/prettier': 'error',
'react/jsx-filename-extension': [
'warn',
{ extensions: ['.jsx', '.js'] }
],
'import/prefer-default-export': 'off'
},
};
{
"singleQuote": true,
"trailingComma": "es5"
}

Config for .editorconfig

root = true

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

Install Modules

yarn add eslint -D
yarn eslint --init

  • check syntax, find problems, and enforce code style
  • Javascript modules (import/export)
  • React
  • Browser
  • Use a popular style guide
  • Airbnb
  • Javascript
  • Y for all

After installation is done delete package-lock.json

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

Edit .eslintrc.js

module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'airbnb',
'prettier',
'prettier/react'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser:'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
'prettier'
],
rules: {
'prettier/prettier': 'error',
'react/jsx-filename-extension': [
'warn',
{ extensions: ['.jsx', '.js'] }
],
'import/prefer-default-export': 'off'
},
};

Create new file on root path with name .prettierrc, add:

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

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