Finally fix eslint configuration

This commit is contained in:
ErickSkrauch 2019-05-19 23:48:14 +03:00
parent 030cc70c2b
commit 52eb8f3bc7
9 changed files with 250 additions and 202 deletions

View File

@ -16,9 +16,9 @@ module.exports = {
}, },
env: { env: {
"browser": true, browser: true,
"commonjs": true, commonjs: true,
"es6": true es6: true,
}, },
plugins: [ plugins: [
@ -28,7 +28,6 @@ module.exports = {
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:react/recommended', 'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
], ],
globals: { globals: {
@ -38,154 +37,168 @@ module.exports = {
// @see: http://eslint.org/docs/rules/ // @see: http://eslint.org/docs/rules/
rules: { rules: {
// possible errors (including eslint:recommended) // possible errors (including eslint:recommended)
"valid-jsdoc": ["warn", { 'valid-jsdoc': ['warn', {
"requireParamDescription": false, requireParamDescription: false,
"requireReturn": false, requireReturn: false,
"requireReturnDescription": false, requireReturnDescription: false,
"prefer": { prefer: {
"returns": "return" returns: 'return',
},
preferType: {
String: 'string',
Object: 'object',
Number: 'number',
Function: 'function',
}, },
"preferType": {
"String": "string",
"Object": "object",
"Number": "number",
"Function": "function"
}
}], }],
// best practice // best practice
"block-scoped-var": "error", 'block-scoped-var': 'error',
"curly": "error", 'curly': 'error',
"default-case": "error", 'default-case': 'error',
"dot-location": ["error", "property"], 'dot-location': ['error', 'property'],
"dot-notation": "error", 'dot-notation': 'error',
"eqeqeq": ["error", "smart"], 'eqeqeq': ['error', 'smart'],
"no-alert": "error", 'no-alert': 'error',
"no-caller": "error", 'no-caller': 'error',
"no-case-declarations": "error", 'no-case-declarations': 'error',
"no-div-regex": "error", 'no-div-regex': 'error',
"no-else-return": "error", 'no-else-return': 'error',
"no-empty-pattern": "error", 'no-empty-pattern': 'error',
"no-eq-null": "error", 'no-eq-null': 'error',
"no-eval": "error", 'no-eval': 'error',
"no-extend-native": "error", 'no-extend-native': 'error',
"no-extra-bind": "warn", 'no-extra-bind': 'warn',
"no-fallthrough": "error", 'no-fallthrough': 'error',
"no-floating-decimal": "warn", 'no-floating-decimal': 'warn',
"no-implied-eval": "error", 'no-implied-eval': 'error',
"no-invalid-this": "off", 'no-invalid-this': 'off',
"no-labels": "error", 'no-labels': 'error',
"no-lone-blocks": "warn", 'no-lone-blocks': 'warn',
"no-loop-func": "error", 'no-loop-func': 'error',
"no-multi-spaces": "error", 'no-multi-spaces': 'error',
"no-multi-str": "error", 'no-multi-str': 'error',
"no-native-reassign": "error", 'no-native-reassign': 'error',
"no-new-wrappers": "warn", 'no-new-wrappers': 'warn',
"no-new": "warn", 'no-new': 'warn',
"no-octal-escape": "warn", 'no-octal-escape': 'warn',
"no-octal": "error", 'no-octal': 'error',
"no-proto": "error", 'no-proto': 'error',
"no-redeclare": "warn", 'no-redeclare': 'warn',
"no-script-url": "error", 'no-script-url': 'error',
"no-self-compare": "error", 'no-self-compare': 'error',
"no-sequences": "error", 'no-sequences': 'error',
"no-throw-literal": "error", 'no-throw-literal': 'error',
"no-unused-expressions": ["warn", {"allowShortCircuit": true, "allowTernary": true}], 'no-unused-expressions': ['warn', {
"no-useless-call": "warn", allowShortCircuit: true,
"no-useless-concat": "warn", allowTernary: true,
"no-void": "error", }],
"no-with": "error", 'no-useless-call': 'warn',
"radix": "error", 'no-useless-concat': 'warn',
"wrap-iife": "error", 'no-void': 'error',
"yoda": "warn", 'no-with': 'error',
"no-constant-condition": "error", 'radix': 'error',
'wrap-iife': 'error',
'yoda': 'warn',
'no-constant-condition': 'error',
// strict mode // strict mode
"strict": ["warn", "never"], // babel все сделает за нас 'strict': ['warn', 'never'], // allow babel to do it for us
// variables // variables
"no-catch-shadow": "off", 'no-catch-shadow': 'off',
"no-delete-var": "error", 'no-delete-var': 'error',
"no-label-var": "error", 'no-label-var': 'error',
"no-shadow-restricted-names": "error", 'no-shadow-restricted-names': 'error',
"no-shadow": "off", 'no-shadow': 'off',
"no-undef-init": "error", 'no-undef-init': 'error',
"no-undef": "error", 'no-undef': 'error',
"no-use-before-define": ["warn", "nofunc"], 'no-use-before-define': ['warn', 'nofunc'],
// CommonJS // CommonJS
"no-mixed-requires": "warn", 'no-mixed-requires': 'warn',
"no-path-concat": "warn", 'no-path-concat': 'warn',
// stylistic // stylistic
"array-bracket-spacing": "off", // disable because we want spaces on destructured arrays 'array-bracket-spacing': 'off', // disable because we want spaces on destructured arrays
"block-spacing": ["error", "never"], 'block-spacing': ['error', 'never'],
"brace-style": ["error", "1tbs", {"allowSingleLine": true}], 'brace-style': ['error', '1tbs', {
"comma-spacing": "error", allowSingleLine: true,
"comma-style": "error", }],
"comma-dangle": ["warn", "only-multiline"], 'comma-spacing': 'error',
"computed-property-spacing": "error", 'comma-style': 'error',
"consistent-this": ["error", "that"], 'comma-dangle': ['warn', 'always-multiline'],
"camelcase": "warn", 'computed-property-spacing': 'error',
"eol-last": "warn", 'consistent-this': ['error', 'that'],
"id-length": ["error", {"min": 2, "exceptions": ["x", "y", "i", "$"]}], 'camelcase': 'warn',
"indent": ["error", 4, {"SwitchCase": 1}], 'eol-last': 'warn',
"jsx-quotes": "error", 'id-length': ['error', {
"key-spacing": ["error", {"mode": "minimum"}], min: 2,
"linebreak-style": "error", exceptions: ['x', 'y', 'i', '$'],
"max-depth": "error", }],
"new-cap": "error", 'indent': ['error', 4, {
"new-parens": "error", SwitchCase: 1,
"no-array-constructor": "warn", }],
"no-bitwise": "warn", 'jsx-quotes': 'error',
"no-lonely-if": "error", 'key-spacing': ['error', {
"no-negated-condition": "warn", mode: 'minimum',
"no-nested-ternary": "error", }],
"no-new-object": "error", 'linebreak-style': 'error',
"no-spaced-func": "error", 'max-depth': 'error',
"no-trailing-spaces": "warn", 'new-cap': 'error',
"no-unneeded-ternary": "warn", 'new-parens': 'error',
"one-var": ["error", "never"], 'no-array-constructor': 'warn',
"operator-assignment": ["warn", "always"], 'no-bitwise': 'warn',
"operator-linebreak": ["error", "before"], 'no-lonely-if': 'error',
"padded-blocks": ["warn", "never"], 'no-negated-condition': 'warn',
"quote-props": ["warn", "as-needed"], 'no-nested-ternary': 'error',
"quotes": ["warn", "single"], 'no-new-object': 'error',
"semi": "error", 'no-spaced-func': 'error',
"semi-spacing": "error", 'no-trailing-spaces': 'warn',
"keyword-spacing": "warn", 'no-unneeded-ternary': 'warn',
"space-before-blocks": "error", 'one-var': ['error', 'never'],
"space-before-function-paren": ["error", "never"], 'operator-assignment': ['warn', 'always'],
"space-in-parens": "warn", 'operator-linebreak': ['error', 'before'],
"space-infix-ops": "error", 'padded-blocks': ['warn', 'never'],
"space-unary-ops": "error", 'quote-props': ['warn', 'as-needed'],
"spaced-comment": "warn", '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 // es6
"arrow-body-style": "warn", 'arrow-body-style': 'warn',
"arrow-parens": "error", 'arrow-parens': 'error',
"arrow-spacing": "error", 'arrow-spacing': 'error',
"constructor-super": "error", 'constructor-super': 'error',
"generator-star-spacing": "warn", 'generator-star-spacing': 'warn',
"no-class-assign": "error", 'no-class-assign': 'error',
"no-const-assign": "error", 'no-const-assign': 'error',
"no-dupe-class-members": "error", 'no-dupe-class-members': 'error',
"no-this-before-super": "error", 'no-this-before-super': 'error',
"no-var": "warn", 'no-var': 'warn',
"object-shorthand": "warn", 'object-shorthand': 'warn',
"prefer-arrow-callback": "warn", 'prefer-arrow-callback': 'warn',
"prefer-const": "warn", 'prefer-const': 'warn',
"prefer-reflect": "warn", 'prefer-reflect': 'warn',
"prefer-spread": "warn", 'prefer-spread': 'warn',
"prefer-template": "warn", 'prefer-template': 'warn',
"require-yield": "error", 'require-yield': 'error',
// react // react
"react/display-name": "warn", 'react/display-name': 'warn',
"react/forbid-prop-types": "warn", 'react/forbid-prop-types': 'warn',
"react/jsx-boolean-value": "warn", 'react/jsx-boolean-value': 'warn',
'react/jsx-closing-bracket-location': ['warn', {
selfClosing: 'after-props',
// We want to keep bracket in the next case: // We want to keep bracket in the next case:
// <Component simpleProp="123" objectProp={{ // <Component simpleProp="123" objectProp={{
// param: 'value', // param: 'value',
@ -200,42 +213,81 @@ module.exports = {
// > // >
// //
// So until we'll find the solution, let's disable this rule. // So until we'll find the solution, let's disable this rule.
nonEmpty: false, '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-indent-props': 'warn',
"react/jsx-handler-names": ["warn", {"eventHandlerPrefix": "on", "eventHandlerPropPrefix": "on"}], 'react/jsx-key': 'warn',
"react/jsx-indent-props": "warn",
"react/jsx-key": "warn",
'react/jsx-max-props-per-line': 'off', 'react/jsx-max-props-per-line': 'off',
"react/jsx-no-bind": ['error', { 'react/jsx-no-bind': ['error', {
allowArrowFunctions: true, allowArrowFunctions: true,
}], }],
"react/jsx-no-duplicate-props": "warn", 'react/jsx-no-duplicate-props': 'warn',
"react/jsx-no-literals": "off", 'react/jsx-no-literals': 'off',
"react/jsx-no-undef": "warn", 'react/jsx-no-undef': 'warn',
"react/jsx-pascal-case": "warn", 'react/jsx-pascal-case': 'warn',
"react/jsx-uses-react": "warn", 'react/jsx-uses-react': 'warn',
"react/jsx-uses-vars": "warn", 'react/jsx-uses-vars': 'warn',
"react/jsx-no-comment-textnodes": "warn", 'react/jsx-no-comment-textnodes': 'warn',
"react/jsx-wrap-multilines": "warn", 'react/jsx-wrap-multilines': 'warn',
"react/no-deprecated": "warn", 'react/no-deprecated': 'warn',
"react/no-did-mount-set-state": "warn", 'react/no-did-mount-set-state': 'warn',
"react/no-did-update-set-state": "warn", 'react/no-did-update-set-state': 'warn',
"react/no-direct-mutation-state": "warn", 'react/no-direct-mutation-state': 'warn',
"react/require-render-return": "warn", 'react/require-render-return': 'warn',
"react/no-is-mounted": "warn", 'react/no-is-mounted': 'warn',
"react/no-multi-comp": "warn", 'react/no-multi-comp': 'warn',
"react/no-string-refs": "warn", 'react/no-string-refs': 'warn',
"react/no-unknown-property": "warn", 'react/no-unknown-property': 'warn',
"react/prefer-es6-class": "warn", 'react/prefer-es6-class': 'warn',
"react/prop-types": "off", // disable in favor of typescript 'react/react-in-jsx-scope': 'off',
"react/react-in-jsx-scope": "off", 'react/self-closing-comp': 'warn',
"react/self-closing-comp": "warn", 'react/sort-comp': ['warn', {
"react/sort-comp": ["warn", {"order": ["lifecycle", "render", "everything-else"]}], 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',
}, },
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',
},
},
],
}; };

View File

@ -16,7 +16,7 @@
"homepage": "https://gitlab.com/elyby/email-renderer#README", "homepage": "https://gitlab.com/elyby/email-renderer#README",
"scripts": { "scripts": {
"start": "webpack-dev-server --mode=development --progress --colors", "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:collect": "./scripts/i18n-collect/index.js",
"i18n:pull": "node scripts/i18n-crowdin/index.js pull", "i18n:pull": "node scripts/i18n-crowdin/index.js pull",
"i18n:push": "node scripts/i18n-crowdin/index.js push", "i18n:push": "node scripts/i18n-crowdin/index.js push",

View File

@ -1,6 +1,6 @@
export default { export default {
content: { content: {
background: '#fff', background: '#fff',
padding: '50px' padding: '50px',
} },
}; };

View File

@ -13,10 +13,11 @@ export default function Footer() {
<tr> <tr>
<td style={styles.footerText}> <td style={styles.footerText}>
<Message {...messages.footer} values={{ <Message {...messages.footer} values={{
serviceLink: serviceLink: (
<a href="https://account.ely.by" style={styles.footerLink}> <a href="https://account.ely.by" style={styles.footerLink}>
<Message {...messages.service_name} /> <Message {...messages.service_name} />
</a> </a>
),
}} /> }} />
</td> </td>
<td style={styles.footerLogo}> <td style={styles.footerLogo}>

View File

@ -9,7 +9,7 @@ interface Props {
const Table: FunctionComponent<Props> = ({ children, style }) => ( const Table: FunctionComponent<Props> = ({ children, style }) => (
<table cellPadding="0" cellSpacing="0" style={{ <table cellPadding="0" cellSpacing="0" style={{
...styles.table, ...styles.table,
...style ...style,
}}> }}>
<tbody> <tbody>
{children} {children}

View File

@ -6,7 +6,7 @@ const styles: { [key: string]: CSSProperties } = {
// @ts-ignore // @ts-ignore
msoTableLspace: '0pt', msoTableLspace: '0pt',
msoTableRspace: '0pt', msoTableRspace: '0pt',
width: '100%' width: '100%',
}, },
}; };

View File

@ -1,7 +1,2 @@
import Button from './button/Button'; export { default as Button } from './button/Button';
import Input from './input/Input'; export { default as Input } from './input/Input';
export {
Button,
Input
};

View File

@ -61,7 +61,7 @@ const Register: FunctionComponent<Props> = ({ username, link, code }) => (
<HTMLMessage {...messages.choose_you_skin_image} /> <HTMLMessage {...messages.choose_you_skin_image} />
<div style={{ <div style={{
...styles.paragraph, ...styles.paragraph,
...styles.todoItemText ...styles.todoItemText,
}}> }}>
<Message {...messages.choose_you_skin_text} /> <Message {...messages.choose_you_skin_text} />
</div> </div>
@ -81,7 +81,7 @@ const Register: FunctionComponent<Props> = ({ username, link, code }) => (
<HTMLMessage {...messages.install_our_patch_image} /> <HTMLMessage {...messages.install_our_patch_image} />
<div style={{ <div style={{
...styles.paragraph, ...styles.paragraph,
...styles.todoItemText ...styles.todoItemText,
}}> }}>
<Message {...messages.install_our_patch_text} /> <Message {...messages.install_our_patch_text} />
</div> </div>
@ -101,7 +101,7 @@ const Register: FunctionComponent<Props> = ({ username, link, code }) => (
<HTMLMessage {...messages.useTLLauncher} /> <HTMLMessage {...messages.useTLLauncher} />
<div style={{ <div style={{
...styles.paragraph, ...styles.paragraph,
...styles.todoItemText ...styles.todoItemText,
}}> }}>
<Message {...messages.useTLLauncherText} /> <Message {...messages.useTLLauncherText} />
</div> </div>