Skip to content

Instantly share code, notes, and snippets.

@ezy
Last active March 30, 2020 13:22
Show Gist options
  • Save ezy/107c74c014251f0c8f2c2b0bea460d58 to your computer and use it in GitHub Desktop.
Save ezy/107c74c014251f0c8f2c2b0bea460d58 to your computer and use it in GitHub Desktop.
[Create react app with typescipt and npm] #eslint #prettier #npm #bash
#!/bin/bash
npx create-react-app formatting-project --template typescript --use-npm
npm i -D --save-exact eslint eslint-config-airbnb eslint-config-airbnb-typescript eslint-config-prettier eslint-config-react-app eslint-import-resolver-typescript eslint-loader eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks babel-eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm i -D --save-exact prettier prettier-eslint prettier-eslint-cli eslint-plugin-prettier
> ".eslintrc"
echo '// .eslintrc
{
"plugins": ["prettier", "@typescript-eslint"],
"extends": ["airbnb-typescript", "react-app", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
},
"rules": {
"object-curly-spacing": ["warn", "always"],
"no-unused-vars": [
"warn",
{
"vars": "all",
"args": "none"
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"vars": "all",
"args": "none"
}
],
"@typescript-eslint/no-explicit-any": [
"error",
{
"ignoreRestArgs": true
}
],
"max-len": [
"warn",
{
"code": 80,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreComments": true
}
],
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"react/jsx-key": "error",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"**/*.test.js",
"**/*.test.jsx",
"**/*.test.ts",
"**/*.test.tsx",
"src/tests/**/*"
]
}
],
"react/jsx-props-no-spreading": "off",
"import/prefer-default-export": "off",
"react/jsx-boolean-value": "off",
"react/prop-types": "off",
"react/no-unescaped-entities": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-wrap-multilines": "off",
"react/destructuring-assignment": "off"
}
}' >> .eslintrc
> ".eslintignore"
echo '// .eslintignore
build/*
public/*
src/react-app-env.d.ts
src/serviceWorker.ts' >> .eslintignore
> ".prettierrc"
echo '{
"printWidth": 80,
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2
}' >> .prettierrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment