From 57c12061928adf4729f7c9953bc1e2ae3dbfab1c Mon Sep 17 00:00:00 2001 From: Alex Gabites Date: Thu, 23 Apr 2020 14:33:42 +1200 Subject: [PATCH] add prettier and eslint --- .eslintignore | 4 ++++ .eslintrc.js | 44 ++++++++++++++++++++++++++++++++++++- .prettierignore | 4 ++++ .prettierrc.js | 7 ++++++ package.json | 11 ++++++++++ yarn.lock | 58 +++++++++++++++++++++++++++++++++++++++++++------ 6 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 .eslintignore create mode 100644 .prettierignore create mode 100644 .prettierrc.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..34752d1 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +node_modules +dist +coverage +storybook-static diff --git a/.eslintrc.js b/.eslintrc.js index 10e6d1e..6b80f6d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,8 +1,50 @@ module.exports = { - extends: ['react-app', 'prettier/@typescript-eslint', 'plugin:prettier/recommended'], + parser: '@typescript-eslint/parser', + extends: ['airbnb-typescript', 'plugin:prettier/recommended', 'plugin:jest/recommended'], + parserOptions: { + ecmaVersion: 2018, + project: './tsconfig.json', + sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, + }, rules: { + 'import/named': 'off', + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'parent', 'sibling', 'index'], + 'newlines-between': 'never', + }, + ], + 'import/prefer-default-export': 'off', 'jsx-a11y/accessible-emoji': 'off', + 'no-console': 'off', + 'no-underscore-dangle': 'off', + 'react/jsx-curly-newline': 'off', + 'react/jsx-one-expression-per-line': 'off', + 'react/jsx-props-no-spreading': 'off', + 'react/jsx-wrap-multilines': 'off', + '@typescript-eslint/ban-ts-ignore': 'warn', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/indent': 'off', + '@typescript-eslint/quotes': 'off', }, + overrides: [ + { + files: ['**/*.tsx'], + rules: { + 'react/prop-types': 'off', + }, + }, + { + files: ['**/*.stories.tsx'], + rules: { + 'import/no-extraneous-dependencies': 'off', + }, + }, + ], settings: { react: { version: 'detect', diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..34752d1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +node_modules +dist +coverage +storybook-static diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..12fd81d --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + parser: 'typescript', + endOfLine: 'lf', + printWidth: 120, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/package.json b/package.json index 2574a1b..1212b41 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,20 @@ "@types/styled-components": "^5.1.0", "@types/styled-system": "^5.1.9", "@types/styled-system__css": "^5.0.8", + "@typescript-eslint/eslint-plugin": "^2.29.0", + "@typescript-eslint/parser": "^2.29.0", "babel-loader": "^8.1.0", "color": "^3.1.2", + "eslint": "^6.8.0", + "eslint-config-airbnb-typescript": "^7.2.1", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-jest": "^23.8.2", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-prettier": "^3.1.3", + "eslint-plugin-react": "^7.19.0", + "eslint-plugin-react-hooks": "^3.0.0", "fork-ts-checker-webpack-plugin": "^4.1.3", + "prettier": "^2.0.5", "react": "^16.13.1", "react-docgen-typescript-loader": "^3.7.2", "react-dom": "^16.13.1", diff --git a/yarn.lock b/yarn.lock index d4d40a1..d8c4908 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2315,7 +2315,7 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^2.12.0": +"@typescript-eslint/eslint-plugin@^2.12.0", "@typescript-eslint/eslint-plugin@^2.29.0": version "2.29.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.29.0.tgz#c9efab7624e3dd6d144a0e4577a541d1bd42c2ac" integrity sha512-X/YAY7azKirENm4QRpT7OVmzok02cSkqeIcLmdz6gXUQG4Hk0Fi9oBAynSAyNXeGdMRuZvjBa0c1Lu0dn/u6VA== @@ -2325,7 +2325,7 @@ regexpp "^3.0.0" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@2.29.0": +"@typescript-eslint/experimental-utils@2.29.0", "@typescript-eslint/experimental-utils@^2.5.0": version "2.29.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.29.0.tgz#3cb8060de9265ba131625a96bbfec31ba6d4a0fe" integrity sha512-H/6VJr6eWYstyqjWXBP2Nn1hQJyvJoFdDtsHxGiD+lEP7piGnGpb/ZQd+z1ZSB1F7dN+WsxUDh8+S4LwI+f3jw== @@ -2335,7 +2335,7 @@ eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/parser@^2.12.0": +"@typescript-eslint/parser@^2.12.0", "@typescript-eslint/parser@^2.24.0", "@typescript-eslint/parser@^2.29.0": version "2.29.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.29.0.tgz#6e3c4e21ed6393dc05b9d8b47f0b7e731ef21c9c" integrity sha512-H78M+jcu5Tf6m/5N8iiFblUUv+HJDguMSdFfzwa6vSg9lKR8Mk9BsgeSjO8l2EshKnJKcbv0e8IDDOvSNjl0EA== @@ -5131,6 +5131,33 @@ escodegen@^1.12.0, escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" +eslint-config-airbnb-base@^14.1.0: + version "14.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.1.0.tgz#2ba4592dd6843258221d9bff2b6831bd77c874e4" + integrity sha512-+XCcfGyCnbzOnktDVhwsCAx+9DmrzEmuwxyHUJpw+kqBVT744OUBrB09khgFKlK1lshVww6qXGsYPZpavoNjJw== + dependencies: + confusing-browser-globals "^1.0.9" + object.assign "^4.1.0" + object.entries "^1.1.1" + +eslint-config-airbnb-typescript@^7.2.1: + version "7.2.1" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-7.2.1.tgz#bce3f02fa894d1ec2f31ac527992e03761a9b7d4" + integrity sha512-D3elVKUbdsCfkOVstSyWuiu+KGCVTrYxJPoenPIqZtL6Li/R4xBeVTXjZIui8B8D17bDN3Pz5dSr7jRLY5HqIg== + dependencies: + "@typescript-eslint/parser" "^2.24.0" + eslint-config-airbnb "^18.1.0" + eslint-config-airbnb-base "^14.1.0" + +eslint-config-airbnb@^18.1.0: + version "18.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-18.1.0.tgz#724d7e93dadd2169492ff5363c5aaa779e01257d" + integrity sha512-kZFuQC/MPnH7KJp6v95xsLBf63G/w7YqdPfQ0MUanxQ7zcKUNG8j+sSY860g3NwCBOa62apw16J6pRN+AOgXzw== + dependencies: + eslint-config-airbnb-base "^14.1.0" + object.assign "^4.1.0" + object.entries "^1.1.1" + eslint-config-prettier@^6.0.0: version "6.11.0" resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz#f6d2238c1290d01c859a8b5c1f7d352a0b0da8b1" @@ -5168,7 +5195,7 @@ eslint-plugin-flowtype@^3.13.0: dependencies: lodash "^4.17.15" -eslint-plugin-import@^2.18.2: +eslint-plugin-import@^2.18.2, eslint-plugin-import@^2.20.2: version "2.20.2" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz#91fc3807ce08be4837141272c8b99073906e588d" integrity sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg== @@ -5186,6 +5213,13 @@ eslint-plugin-import@^2.18.2: read-pkg-up "^2.0.0" resolve "^1.12.0" +eslint-plugin-jest@^23.8.2: + version "23.8.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-23.8.2.tgz#6f28b41c67ef635f803ebd9e168f6b73858eb8d4" + integrity sha512-xwbnvOsotSV27MtAe7s8uGWOori0nUsrXh2f1EnpmXua8sDfY6VZhHAhHg2sqK7HBNycRQExF074XSZ7DvfoFg== + dependencies: + "@typescript-eslint/experimental-utils" "^2.5.0" + eslint-plugin-jsx-a11y@^6.2.3: version "6.2.3" resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.2.3.tgz#b872a09d5de51af70a97db1eea7dc933043708aa" @@ -5201,7 +5235,7 @@ eslint-plugin-jsx-a11y@^6.2.3: has "^1.0.3" jsx-ast-utils "^2.2.1" -eslint-plugin-prettier@^3.1.0: +eslint-plugin-prettier@^3.1.0, eslint-plugin-prettier@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz#ae116a0fc0e598fdae48743a4430903de5b4e6ca" integrity sha512-+HG5jmu/dN3ZV3T6eCD7a4BlAySdN7mLIbJYo0z1cFQuI+r2DiTJEFeF68ots93PsnrMxbzIZ2S/ieX+mkrBeQ== @@ -5213,7 +5247,12 @@ eslint-plugin-react-hooks@^2.2.0: resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-2.5.1.tgz#4ef5930592588ce171abeb26f400c7fbcbc23cd0" integrity sha512-Y2c4b55R+6ZzwtTppKwSmK/Kar8AdLiC2f9NADCuxbcTgPPg41Gyqa6b9GppgXSvCtkRw43ZE86CT5sejKC6/g== -eslint-plugin-react@^7.14.3: +eslint-plugin-react-hooks@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-3.0.0.tgz#9e80c71846eb68dd29c3b21d832728aa66e5bd35" + integrity sha512-EjxTHxjLKIBWFgDJdhKKzLh5q+vjTFrqNZX36uIxWS4OfyXe5DawqPj3U5qeJ1ngLwatjzQnmR0Lz0J0YH3kxw== + +eslint-plugin-react@^7.14.3, eslint-plugin-react@^7.19.0: version "7.19.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.19.0.tgz#6d08f9673628aa69c5559d33489e855d83551666" integrity sha512-SPT8j72CGuAP+JFbT0sJHOB80TX/pu44gQ4vXH/cq+hQTiY2PuZ6IHkqXJV6x1b28GDdo1lbInjKUrrdUf0LOQ== @@ -5266,7 +5305,7 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== -eslint@^6.1.0: +eslint@^6.1.0, eslint@^6.8.0: version "6.8.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== @@ -9230,6 +9269,11 @@ prettier@^1.16.4, prettier@^1.19.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" + integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== + pretty-error@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"