Skip to content

Instantly share code, notes, and snippets.

@whalemare
Last active August 29, 2019 06:20
Show Gist options
  • Save whalemare/38cb05d736b8cdc4ebccb629e727b27a to your computer and use it in GitHub Desktop.
Save whalemare/38cb05d736b8cdc4ebccb629e727b27a to your computer and use it in GitHub Desktop.
Fast install ESLint and Prettier
#!/bin/bash
file="package.json"
if [ -f "$file" ]
then
# all is ok
echo ""
else
cd ..
if [ -f "$file" ]
then
# all is ok
echo ""
else
echo "Can not find $file. Abort eslint installing"
fi
fi
npm install eslint prettier-eslint babel-eslint eslint-config-airbnb eslint-config-prettier eslint-config-react eslint-config-standard eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx eslint-plugin-node eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-react eslint-plugin-standard eslint-plugin-jsx-a11y --save-dev
echo '{
"plugins": ["prettier"],
"parser": "babel-eslint",
"extends": [
"airbnb",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:react/recommended",
"eslint:recommended",
"plugin:prettier/recommended",
"prettier"
],
"rules": {
"prettier/prettier": "warn",
"linebreak-style": ["error", "unix"],
"react/jsx-filename-extension": ["warn", { "extensions": [".js", ".jsx"] }],
"react/forbid-prop-types": "off",
"import/order": ["error", { "groups": ["builtin", "external", "parent", "sibling", "index"] }],
"quotes": "off",
"arrow-parens": ["error", "as-needed"],
"no-unused-vars": "off",
"semi": ["error", "never"],
"react/jsx-closing-bracket-location": [
"off",
{
"selfClosing": "props-aligned",
"nonEmpty": "after-props"
}
],
"no-trailing-spaces": ["warn", { "skipBlankLines": true }],
"object-shorthand": ["off", "never"],
"react/destructuring-assignment": ["warn", "always", { "ignoreClassFields": true }],
"react/jsx-wrap-multilines": "off",
"no-return-assign": "off",
"react/jsx-closing-tag-location": "warn",
"react/prefer-stateless-function": "off",
"react/prop-types": ["warn", { "ignore": ["children", "style"] }],
"react/jsx-uses-vars": "warn",
"react/jsx-uses-react": "warn",
"react/no-unused-prop-types": "warn",
"class-methods-use-this": "off",
"no-plusplus": ["off", { "allowForLoopAfterthoughts": true }],
"react/no-did-update-set-state": "off",
"operator-linebreak": "off",
"arrow-body-style": "off",
"prefer-destructuring": [
"warn",
{
"array": false,
"object": true
},
{
"enforceForRenamedProperties": false
}
],
"no-restricted-syntax": "off",
"guard-for-in": "off",
"no-console": "off",
"react/jsx-indent-props": "off",
"react/jsx-indent": "off",
"max-len": [
"warn",
{
"code": 100,
"ignoreUrls": true
}
],
"no-mixed-operators": "warn"
}
}
' > .eslintrc.json
echo '{
"useTabs": false,
"printWidth": 100,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "es5",
"jsxBracketSameLine": true,
"semi": false,
"bracketSpacing": true,
"arrowParens": "avoid"
}
' > .prettierrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment