From 52eb8f3bc7c77336d3fec79b6258f27672fda84d Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sun, 19 May 2019 23:48:14 +0300 Subject: [PATCH] Finally fix eslint configuration --- .eslintrc.js | 418 +++++++++++++---------- package.json | 2 +- src/components/layout/content/styles.ts | 4 +- src/components/layout/footer/Footer.tsx | 3 +- src/components/table/Table.tsx | 2 +- src/components/table/styles.ts | 2 +- src/components/ui/index.ts | 9 +- src/emails/register/Register.tsx | 6 +- webpack-utils/image-size-loader/index.js | 6 +- 9 files changed, 250 insertions(+), 202 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7bcc9f4..3f67e56 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,9 +16,9 @@ module.exports = { }, env: { - "browser": true, - "commonjs": true, - "es6": true + browser: true, + commonjs: true, + es6: true, }, plugins: [ @@ -28,7 +28,6 @@ module.exports = { extends: [ 'eslint:recommended', 'plugin:react/recommended', - 'plugin:@typescript-eslint/recommended', ], globals: { @@ -38,204 +37,257 @@ module.exports = { // @see: http://eslint.org/docs/rules/ rules: { // possible errors (including eslint:recommended) - "valid-jsdoc": ["warn", { - "requireParamDescription": false, - "requireReturn": false, - "requireReturnDescription": false, - "prefer": { - "returns": "return" + 'valid-jsdoc': ['warn', { + requireParamDescription: false, + requireReturn: false, + requireReturnDescription: false, + prefer: { + returns: 'return', + }, + preferType: { + String: 'string', + Object: 'object', + Number: 'number', + Function: 'function', }, - "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", + '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"], // babel все сделает за нас + '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"], + '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", + '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", "only-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", "never"], - "space-in-parens": "warn", - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": "warn", + '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", + '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", - 'react/jsx-closing-bracket-location': ['warn', { - selfClosing: 'after-props', - // 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. - nonEmpty: false, + '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-curly-spacing": "warn", - "react/jsx-handler-names": ["warn", {"eventHandlerPrefix": "on", "eventHandlerPropPrefix": "on"}], - "react/jsx-indent-props": "warn", - "react/jsx-key": "warn", + 'react/jsx-indent-props': 'warn', + 'react/jsx-key': 'warn', 'react/jsx-max-props-per-line': 'off', - "react/jsx-no-bind": ['error', { + '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/prop-types": "off", // disable in favor of typescript - "react/react-in-jsx-scope": "off", - "react/self-closing-comp": "warn", - "react/sort-comp": ["warn", {"order": ["lifecycle", "render", "everything-else"]}], - - // TypeScript - '@typescript-eslint/array-type': ['error', 'generic'], - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', + '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 efd35c6..1e158e2 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "homepage": "https://gitlab.com/elyby/email-renderer#README", "scripts": { "start": "webpack-dev-server --mode=development --progress --colors", - "lint": "eslint", + "lint": "eslint \"{scripts,src,webpack-utils}/**/*.{js,jsx,ts,tsx}\"", "i18n:collect": "./scripts/i18n-collect/index.js", "i18n:pull": "node scripts/i18n-crowdin/index.js pull", "i18n:push": "node scripts/i18n-crowdin/index.js push", diff --git a/src/components/layout/content/styles.ts b/src/components/layout/content/styles.ts index 6b83ec6..74addb7 100644 --- a/src/components/layout/content/styles.ts +++ b/src/components/layout/content/styles.ts @@ -1,6 +1,6 @@ export default { content: { background: '#fff', - padding: '50px' - } + padding: '50px', + }, }; diff --git a/src/components/layout/footer/Footer.tsx b/src/components/layout/footer/Footer.tsx index 6040ba7..ce1eb86 100644 --- a/src/components/layout/footer/Footer.tsx +++ b/src/components/layout/footer/Footer.tsx @@ -13,10 +13,11 @@ export default function Footer() { + ), }} /> diff --git a/src/components/table/Table.tsx b/src/components/table/Table.tsx index 955c7c5..d6a2302 100644 --- a/src/components/table/Table.tsx +++ b/src/components/table/Table.tsx @@ -9,7 +9,7 @@ interface Props { const Table: FunctionComponent = ({ children, style }) => ( {children} diff --git a/src/components/table/styles.ts b/src/components/table/styles.ts index fd275e3..3785634 100644 --- a/src/components/table/styles.ts +++ b/src/components/table/styles.ts @@ -6,7 +6,7 @@ const styles: { [key: string]: CSSProperties } = { // @ts-ignore msoTableLspace: '0pt', msoTableRspace: '0pt', - width: '100%' + width: '100%', }, }; diff --git a/src/components/ui/index.ts b/src/components/ui/index.ts index 79056bf..eccbf9f 100644 --- a/src/components/ui/index.ts +++ b/src/components/ui/index.ts @@ -1,7 +1,2 @@ -import Button from './button/Button'; -import Input from './input/Input'; - -export { - Button, - Input -}; +export { default as Button } from './button/Button'; +export { default as Input } from './input/Input'; diff --git a/src/emails/register/Register.tsx b/src/emails/register/Register.tsx index 9d77a12..8fa90f9 100644 --- a/src/emails/register/Register.tsx +++ b/src/emails/register/Register.tsx @@ -61,7 +61,7 @@ const Register: FunctionComponent = ({ username, link, code }) => (
@@ -81,7 +81,7 @@ const Register: FunctionComponent = ({ username, link, code }) => (
@@ -101,7 +101,7 @@ const Register: FunctionComponent = ({ username, link, code }) => (
diff --git a/webpack-utils/image-size-loader/index.js b/webpack-utils/image-size-loader/index.js index da94934..9606ba7 100644 --- a/webpack-utils/image-size-loader/index.js +++ b/webpack-utils/image-size-loader/index.js @@ -68,9 +68,9 @@ module.exports = function(content) { const issuer = options.context ? context : this._module && this._module.issuer && this._module.issuer.context; const relativeUrl = issuer && path - .relative(issuer, filePath) - .split(path.sep) - .join('/'); + .relative(issuer, filePath) + .split(path.sep) + .join('/'); const relativePath = relativeUrl && `${path.dirname(relativeUrl)}/`; // eslint-disable-next-line no-bitwise