From 0940375b512d581c445929cec5dc2242513aeb17 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 28 May 2019 23:42:13 +0300 Subject: [PATCH] Integrate @elyby/eslint-plugin and apply its fixes --- .eslintrc.js | 286 +------------------ package.json | 4 +- src/devTools/DevApp.tsx | 8 +- src/devTools/List.tsx | 3 +- src/emails/forgotPassword/ForgotPassword.tsx | 2 +- yarn.lock | 49 +++- 6 files changed, 50 insertions(+), 302 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3f67e56..351b835 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,19 +1,9 @@ module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - sourceType: 'module', - ecmaVersion: 2018, - ecmaFeatures: { - jsx: true, - }, - project: './tsconfig.json', - }, - - settings: { - react: { - version: 'detect', - }, - }, + extends: [ + 'plugin:@elyby/base', + 'plugin:@elyby/react', + 'plugin:@elyby/typescript', + ], env: { browser: true, @@ -21,273 +11,7 @@ module.exports = { es6: true, }, - plugins: [ - '@typescript-eslint', - ], - - extends: [ - 'eslint:recommended', - 'plugin:react/recommended', - ], - globals: { __webpack_public_path__: true, }, - - // @see: http://eslint.org/docs/rules/ - rules: { - // possible errors (including eslint:recommended) - 'valid-jsdoc': ['warn', { - requireParamDescription: false, - requireReturn: false, - requireReturnDescription: false, - prefer: { - returns: 'return', - }, - preferType: { - String: 'string', - Object: 'object', - Number: 'number', - Function: 'function', - }, - }], - - // best practice - 'block-scoped-var': 'error', - 'curly': 'error', - 'default-case': 'error', - 'dot-location': ['error', 'property'], - 'dot-notation': 'error', - 'eqeqeq': ['error', 'smart'], - 'no-alert': 'error', - 'no-caller': 'error', - 'no-case-declarations': 'error', - 'no-div-regex': 'error', - 'no-else-return': 'error', - 'no-empty-pattern': 'error', - 'no-eq-null': 'error', - 'no-eval': 'error', - 'no-extend-native': 'error', - 'no-extra-bind': 'warn', - 'no-fallthrough': 'error', - 'no-floating-decimal': 'warn', - 'no-implied-eval': 'error', - 'no-invalid-this': 'off', - 'no-labels': 'error', - 'no-lone-blocks': 'warn', - 'no-loop-func': 'error', - 'no-multi-spaces': 'error', - 'no-multi-str': 'error', - 'no-native-reassign': 'error', - 'no-new-wrappers': 'warn', - 'no-new': 'warn', - 'no-octal-escape': 'warn', - 'no-octal': 'error', - 'no-proto': 'error', - 'no-redeclare': 'warn', - 'no-script-url': 'error', - 'no-self-compare': 'error', - 'no-sequences': 'error', - 'no-throw-literal': 'error', - 'no-unused-expressions': ['warn', { - allowShortCircuit: true, - allowTernary: true, - }], - 'no-useless-call': 'warn', - 'no-useless-concat': 'warn', - 'no-void': 'error', - 'no-with': 'error', - 'radix': 'error', - 'wrap-iife': 'error', - 'yoda': 'warn', - 'no-constant-condition': 'error', - - // strict mode - 'strict': ['warn', 'never'], // allow babel to do it for us - - // variables - 'no-catch-shadow': 'off', - 'no-delete-var': 'error', - 'no-label-var': 'error', - 'no-shadow-restricted-names': 'error', - 'no-shadow': 'off', - 'no-undef-init': 'error', - 'no-undef': 'error', - 'no-use-before-define': ['warn', 'nofunc'], - - // CommonJS - 'no-mixed-requires': 'warn', - 'no-path-concat': 'warn', - - // stylistic - 'array-bracket-spacing': 'off', // disable because we want spaces on destructured arrays - 'block-spacing': ['error', 'never'], - 'brace-style': ['error', '1tbs', { - allowSingleLine: true, - }], - 'comma-spacing': 'error', - 'comma-style': 'error', - 'comma-dangle': ['warn', 'always-multiline'], - 'computed-property-spacing': 'error', - 'consistent-this': ['error', 'that'], - 'camelcase': 'warn', - 'eol-last': 'warn', - 'id-length': ['error', { - min: 2, - exceptions: ['x', 'y', 'i', '$'], - }], - 'indent': ['error', 4, { - SwitchCase: 1, - }], - 'jsx-quotes': 'error', - 'key-spacing': ['error', { - mode: 'minimum', - }], - 'linebreak-style': 'error', - 'max-depth': 'error', - 'new-cap': 'error', - 'new-parens': 'error', - 'no-array-constructor': 'warn', - 'no-bitwise': 'warn', - 'no-lonely-if': 'error', - 'no-negated-condition': 'warn', - 'no-nested-ternary': 'error', - 'no-new-object': 'error', - 'no-spaced-func': 'error', - 'no-trailing-spaces': 'warn', - 'no-unneeded-ternary': 'warn', - 'one-var': ['error', 'never'], - 'operator-assignment': ['warn', 'always'], - 'operator-linebreak': ['error', 'before'], - 'padded-blocks': ['warn', 'never'], - 'quote-props': ['warn', 'as-needed'], - 'quotes': ['warn', 'single'], - 'semi': 'error', - 'semi-spacing': 'error', - 'keyword-spacing': 'warn', - 'space-before-blocks': 'error', - 'space-before-function-paren': ['error', { - anonymous: 'never', - named: 'never', - asyncArrow: 'always', - }], - 'space-in-parens': 'warn', - 'space-infix-ops': 'error', - 'space-unary-ops': 'error', - 'spaced-comment': 'warn', - - // es6 - 'arrow-body-style': 'warn', - 'arrow-parens': 'error', - 'arrow-spacing': 'error', - 'constructor-super': 'error', - 'generator-star-spacing': 'warn', - 'no-class-assign': 'error', - 'no-const-assign': 'error', - 'no-dupe-class-members': 'error', - 'no-this-before-super': 'error', - 'no-var': 'warn', - 'object-shorthand': 'warn', - 'prefer-arrow-callback': 'warn', - 'prefer-const': 'warn', - 'prefer-reflect': 'warn', - 'prefer-spread': 'warn', - 'prefer-template': 'warn', - 'require-yield': 'error', - - // react - 'react/display-name': 'warn', - 'react/forbid-prop-types': 'warn', - 'react/jsx-boolean-value': 'warn', - // We want to keep bracket in the next case: - // - // - // But put it on the next line if props are chopped down: - // - // - // So until we'll find the solution, let's disable this rule. - 'react/jsx-closing-bracket-location': 'off', - 'react/jsx-curly-spacing': 'warn', - 'react/jsx-handler-names': ['warn', { - eventHandlerPrefix: 'on', - eventHandlerPropPrefix: 'on', - }], - 'react/jsx-indent-props': 'warn', - 'react/jsx-key': 'warn', - 'react/jsx-max-props-per-line': 'off', - 'react/jsx-no-bind': ['error', { - allowArrowFunctions: true, - }], - 'react/jsx-no-duplicate-props': 'warn', - 'react/jsx-no-literals': 'off', - 'react/jsx-no-undef': 'warn', - 'react/jsx-pascal-case': 'warn', - 'react/jsx-uses-react': 'warn', - 'react/jsx-uses-vars': 'warn', - 'react/jsx-no-comment-textnodes': 'warn', - 'react/jsx-wrap-multilines': 'warn', - 'react/no-deprecated': 'warn', - 'react/no-did-mount-set-state': 'warn', - 'react/no-did-update-set-state': 'warn', - 'react/no-direct-mutation-state': 'warn', - 'react/require-render-return': 'warn', - 'react/no-is-mounted': 'warn', - 'react/no-multi-comp': 'warn', - 'react/no-string-refs': 'warn', - 'react/no-unknown-property': 'warn', - 'react/prefer-es6-class': 'warn', - 'react/react-in-jsx-scope': 'off', - 'react/self-closing-comp': 'warn', - 'react/sort-comp': ['warn', { - order: ['lifecycle', 'render', 'everything-else'], - }], - }, - - overrides: [ - { - files: ['*.ts', '*.tsx'], - rules: { - 'camelcase': 'off', - 'indent': 'off', - 'no-array-constructor': 'off', - 'no-unused-vars': 'off', - - 'react/prop-types': 'off', - - '@typescript-eslint/adjacent-overload-signatures': 'error', - '@typescript-eslint/array-type': ['error', 'generic'], - '@typescript-eslint/ban-types': 'error', - '@typescript-eslint/camelcase': 'error', - '@typescript-eslint/class-name-casing': 'error', - '@typescript-eslint/explicit-member-accessibility': 'error', - '@typescript-eslint/indent': 'error', - '@typescript-eslint/interface-name-prefix': 'error', - '@typescript-eslint/member-delimiter-style': 'error', - '@typescript-eslint/no-angle-bracket-type-assertion': 'error', - '@typescript-eslint/no-array-constructor': 'error', - '@typescript-eslint/no-empty-interface': 'error', - '@typescript-eslint/no-inferrable-types': 'error', - '@typescript-eslint/no-misused-new': 'error', - '@typescript-eslint/no-namespace': 'error', - '@typescript-eslint/no-non-null-assertion': 'error', - '@typescript-eslint/no-object-literal-type-assertion': 'error', - '@typescript-eslint/no-parameter-properties': 'error', - '@typescript-eslint/no-triple-slash-reference': 'error', - '@typescript-eslint/no-unused-vars': 'warn', - '@typescript-eslint/no-use-before-define': 'error', - '@typescript-eslint/no-var-requires': 'error', - '@typescript-eslint/prefer-for-of': 'warn', - '@typescript-eslint/prefer-interface': 'error', - '@typescript-eslint/prefer-namespace-keyword': 'error', - '@typescript-eslint/type-annotation-spacing': 'error', - }, - }, - ], }; diff --git a/package.json b/package.json index 1e158e2..5279042 100644 --- a/package.json +++ b/package.json @@ -35,16 +35,18 @@ "@babel/preset-env": "^7.3.4", "@babel/preset-react": "^7.0.0", "@babel/preset-typescript": "^7.3.3", + "@elyby/eslint-plugin": "^0.2.0", "@types/react": "^16.8.17", "@types/react-dom": "^16.8.4", "@types/react-intl": "^2.3.17", "@types/webpack-env": "^1.13.9", - "@typescript-eslint/eslint-plugin": "^1.9.0", + "@typescript-eslint/eslint-plugin": "^1.9.1-alpha.12", "@typescript-eslint/parser": "^1.9.0", "babel-loader": "^8.0.5", "babel-preset-react-hot": "^1.0.5", "eslint": "^5.16.0", "eslint-plugin-react": "^7.13.0", + "eslint-plugin-react-hooks": "^1.6.0", "extended-translations-loader": "file:webpack-utils/extended-translations-loader", "file-loader": "^3.0.1", "html-webpack-plugin": "^3.2.0", diff --git a/src/devTools/DevApp.tsx b/src/devTools/DevApp.tsx index ad0a7c0..9482d69 100644 --- a/src/devTools/DevApp.tsx +++ b/src/devTools/DevApp.tsx @@ -55,7 +55,7 @@ const DevApp: FunctionComponent = () => { const payload = useMemo(() => ({ locale, - ...(availableFixtures[fixture] || availableFixtures.default || {}), + ...availableFixtures[fixture] || availableFixtures.default || {}, }), [locale, availableFixtures, fixture]); const onMinimizeClick = useCallback((event: BaseSyntheticEvent) => { @@ -69,7 +69,8 @@ const DevApp: FunctionComponent = () => { opacity: 0.4, position: 'fixed', } : {}}> - [ { onClick={onMinimizeClick} > {isMinimized ? '+' : '-'} - ] + + ]
= ({ label, items, active, onChange = () => {} }) => (
- {label}: + {label} + : {items.map((item) => ( = ({ username, link, code }) => (
+ } /> diff --git a/yarn.lock b/yarn.lock index 432c059..96a1c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -741,6 +741,11 @@ lodash "^4.17.11" to-fast-properties "^2.0.0" +"@elyby/eslint-plugin@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@elyby/eslint-plugin/-/eslint-plugin-0.2.0.tgz#cb8fd2b45af8ba6ff758b3b844ad0e7bd75ca142" + integrity sha512-Mqs7enaYOo6dTa27v5Dxi1yyM9RLJfD4dEJWT8T+6TzBB++TGwCweG+S+1Z8f0+T4XGTtuPjohDtU9JfUclBVA== + "@lesechos/image-size-loader@file:./webpack-utils/image-size-loader": version "1.0.0" dependencies: @@ -802,17 +807,15 @@ resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.13.9.tgz#a67287861c928ebf4159a908d1fb1a2a34d4097a" integrity sha512-p8zp5xqkly3g4cCmo2mKOHI9+Z/kObmDj0BmjbDDJQlgDTiEGTbm17MEwTAusV6XceCy+bNw9q/ZHXHyKo3zkg== -"@typescript-eslint/eslint-plugin@^1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.9.0.tgz#29d73006811bf2563b88891ceeff1c5ea9c8d9c6" - integrity sha512-FOgfBorxjlBGpDIw+0LaZIXRX6GEEUfzj8LXwaQIUCp+gDOvkI+1WgugJ7SmWiISqK9Vj5r8S7NDKO/LB+6X9A== +"@typescript-eslint/eslint-plugin@^1.9.1-alpha.12": + version "1.9.1-alpha.14" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.9.1-alpha.14.tgz#3d71b4379011b8196742738f2ae0b8f2cdf53719" + integrity sha512-SwfV1336UP1QayeBlx8Yrc803lzBVdFYZArAkm36OlgyG1TUh1+sVlI3fymjDaDTyYS/eUhUekejPFV1BlhIAA== dependencies: - "@typescript-eslint/experimental-utils" "1.9.0" - "@typescript-eslint/parser" "1.9.0" + "@typescript-eslint/experimental-utils" "1.9.1-alpha.14+e6b2eff" eslint-utils "^1.3.1" functional-red-black-tree "^1.0.1" regexpp "^2.0.1" - requireindex "^1.2.0" tsutils "^3.7.0" "@typescript-eslint/experimental-utils@1.9.0": @@ -822,7 +825,15 @@ dependencies: "@typescript-eslint/typescript-estree" "1.9.0" -"@typescript-eslint/parser@1.9.0", "@typescript-eslint/parser@^1.9.0": +"@typescript-eslint/experimental-utils@1.9.1-alpha.14+e6b2eff": + version "1.9.1-alpha.14" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.9.1-alpha.14.tgz#c32162174da6695682c8d21048a2ba4aa67ef561" + integrity sha512-Y4OJ7qUxO3si+IJjHBAlAdG2YXcGwkQcogASfE9Q0CgTCXDRH2UShClQAOpuYd+ZRwpAxH4IrruEkszuw39SIg== + dependencies: + "@typescript-eslint/typescript-estree" "1.9.1-alpha.14+e6b2eff" + eslint-scope "^4.0.0" + +"@typescript-eslint/parser@^1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.9.0.tgz#5796cbfcb9a3a5757aeb671c1ac88d7a94a95962" integrity sha512-CWgC1XrQ34H/+LwAU7vY5xteZDkNqeAkeidEpJnJgkKu0yqQ3ZhQ7S+dI6MX4vmmM1TKRbOrKuXc6W0fIHhdbA== @@ -840,6 +851,14 @@ lodash.unescape "4.0.1" semver "5.5.0" +"@typescript-eslint/typescript-estree@1.9.1-alpha.14+e6b2eff": + version "1.9.1-alpha.14" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.9.1-alpha.14.tgz#3a78d99a5a9abb5cf735d167c9600b75258ca4da" + integrity sha512-j6vZF2c1lwB6PZuZDwR0A3TdIOMd94kb5QNfAi3CcYRq9kUxTrR+vymKvYkytmSGwTS3OvJkNNPJBiCyUUDVbQ== + dependencies: + lodash.unescape "4.0.1" + semver "5.5.0" + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" @@ -2434,6 +2453,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +eslint-plugin-react-hooks@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.6.0.tgz#348efcda8fb426399ac7b8609607c7b4025a6f5f" + integrity sha512-lHBVRIaz5ibnIgNG07JNiAuBUeKhEf8l4etNx5vfAEwqQ5tcuK3jV9yjmopPgQDagQb7HwIuQVsE3IVcGrRnag== + eslint-plugin-react@^7.13.0: version "7.13.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.13.0.tgz#bc13fd7101de67996ea51b33873cd9dc2b7e5758" @@ -2703,11 +2727,11 @@ extend@~3.0.2: "extended-translations-loader@file:webpack-utils/extended-translations-loader": version "1.0.0" dependencies: - "@lesechos/image-size-loader" "file:../../.cache/yarn/v4/npm-extended-translations-loader-1.0.0-219747a4-8d0f-47d7-83a4-9af91f809866-1558286521355/node_modules/image-size-loader" + "@lesechos/image-size-loader" "file:../../.cache/yarn/v4/npm-extended-translations-loader-1.0.0-9ec4ca4a-8ad3-461e-a5ec-b4790e8ab027-1559075964387/node_modules/image-size-loader" glob "^7.1.4" loader-utils "^1.2.3" qs "^6.0.0" - text2png-loader "file:../../.cache/yarn/v4/npm-extended-translations-loader-1.0.0-219747a4-8d0f-47d7-83a4-9af91f809866-1558286521355/node_modules/text2png-loader" + text2png-loader "file:../../.cache/yarn/v4/npm-extended-translations-loader-1.0.0-9ec4ca4a-8ad3-461e-a5ec-b4790e8ab027-1559075964387/node_modules/text2png-loader" tmp "^0.0.33" external-editor@^3.0.3: @@ -5301,11 +5325,6 @@ require-main-filename@^1.0.1: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= -requireindex@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef" - integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww== - requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"