Created
May 4, 2021 10:37
-
-
Save wisniewski94/6977dc67366194a446a9d39aecfc37ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable no-undef */ | |
| /* eslint-disable no-magic-numbers */ | |
| const confusingBrowserGlobals = require('confusing-browser-globals'); | |
| module.exports = { | |
| env: { | |
| browser: true, | |
| es2021: true, | |
| }, | |
| parser: '@babel/eslint-parser', | |
| parserOptions: { | |
| ecmaFeatures: { | |
| jsx: true, | |
| }, | |
| sourceType: 'module', | |
| }, | |
| plugins: ['import', 'react'], | |
| settings: { | |
| 'import/resolver': { | |
| node: { | |
| extensions: ['.mjs', '.js', '.json'], | |
| }, | |
| }, | |
| 'import/extensions': [ | |
| '.js', | |
| '.mjs', | |
| '.jsx', | |
| ], | |
| 'import/core-modules': [ | |
| ], | |
| 'import/ignore': [ | |
| 'node_modules', | |
| '\\.(coffee|scss|css|less|hbs|svg|json)$', | |
| ], | |
| }, | |
| rules: { | |
| 'accessor-pairs': ['warn'], | |
| 'array-callback-return': 'error', | |
| 'block-scoped-var': 'error', | |
| complexity: ['error', 3], | |
| 'consistent-return': 'error', | |
| curly: 'error', | |
| 'default-case': 'warn', | |
| 'dot-notation': 'error', | |
| 'dot-location': ['error', 'property'], | |
| eqeqeq: ['error', 'always', { null: 'ignore' }], | |
| 'grouped-accessor-pairs': 'error', | |
| 'guard-for-in': 'warn', | |
| 'max-classes-per-file': ['error', 1], | |
| 'no-case-declarations': 'error', | |
| 'no-constructor-return': 'warn', | |
| 'no-else-return': ['error', { allowElseIf: false }], | |
| 'no-empty-function': 'warn', | |
| 'no-empty-pattern': 'warn', | |
| 'no-eq-null': 'warn', | |
| 'no-eval': 'error', | |
| 'no-extend-native': 'error', | |
| 'no-extra-label': 'warn', | |
| 'no-fallthrough': 'error', | |
| 'no-floating-decimal': 'error', | |
| 'no-global-assign': 'error', | |
| 'no-implicit-coercion': 'warn', | |
| 'no-implicit-globals': 'error', | |
| 'no-implied-eval': 'error', | |
| 'no-invalid-this': 'error', | |
| 'no-lone-blocks': 'warn', | |
| 'no-loop-func': 'error', | |
| 'no-magic-numbers': ['warn', { | |
| ignore: [], | |
| ignoreArrayIndexes: true, | |
| enforceConst: true, | |
| detectObjects: false, | |
| }], | |
| 'no-multi-spaces': 'error', | |
| 'no-new': 'error', | |
| 'no-new-func': 'error', | |
| 'no-new-wrappers': 'error', | |
| 'no-octal': 'error', | |
| 'no-octal-escape': 'error', | |
| 'no-param-reassign': ['error', { | |
| props: true, | |
| ignorePropertyModificationsFor: [ | |
| 'acc', // for reduce accumulators | |
| 'accumulator', // for reduce accumulators | |
| 'e', // for e.returnvalue | |
| ], | |
| }], | |
| 'no-proto': 'error', | |
| 'no-redeclare': 'error', | |
| 'no-restricted-properties': ['error', { | |
| object: 'arguments', | |
| property: 'callee', | |
| message: 'arguments.callee is deprecated', | |
| }, { | |
| object: 'global', | |
| property: 'isFinite', | |
| message: 'Please use Number.isFinite instead', | |
| }, { | |
| object: 'self', | |
| property: 'isFinite', | |
| message: 'Please use Number.isFinite instead', | |
| }, { | |
| object: 'window', | |
| property: 'isFinite', | |
| message: 'Please use Number.isFinite instead', | |
| }, { | |
| object: 'global', | |
| property: 'isNaN', | |
| message: 'Please use Number.isNaN instead', | |
| }, { | |
| object: 'self', | |
| property: 'isNaN', | |
| message: 'Please use Number.isNaN instead', | |
| }, { | |
| object: 'window', | |
| property: 'isNaN', | |
| message: 'Please use Number.isNaN instead', | |
| }, { | |
| property: '__defineGetter__', | |
| message: 'Please use Object.defineProperty instead.', | |
| }, { | |
| property: '__defineSetter__', | |
| message: 'Please use Object.defineProperty instead.', | |
| }, { | |
| object: 'Math', | |
| property: 'pow', | |
| message: 'Use the exponentiation operator (**) instead.', | |
| }], | |
| 'no-return-assign': ['error', 'always'], | |
| 'no-return-await': 'error', | |
| 'no-self-assign': ['error', { | |
| props: true, | |
| }], | |
| 'no-self-compare': 'error', | |
| 'no-sequences': ['error', { allowInParentheses: false }], | |
| 'no-throw-literal': 'error', | |
| 'no-unused-labels': 'error', | |
| 'no-useless-call': 'error', | |
| 'no-useless-catch': 'error', | |
| 'no-useless-concat': 'error', | |
| 'no-useless-escape': 'warn', | |
| 'no-useless-return': 'warn', | |
| 'no-with': 'error', | |
| 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], | |
| radix: 'warn', | |
| 'vars-on-top': 'error', | |
| 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }], | |
| yoda: 'error', | |
| 'for-direction': 'error', | |
| 'getter-return': ['error', { allowImplicit: true }], | |
| 'no-async-promise-executor': 'error', | |
| 'no-await-in-loop': 'error', | |
| 'no-compare-neg-zero': 'error', | |
| 'no-cond-assign': ['error', 'always'], | |
| 'no-console': 'warn', | |
| 'no-constant-condition': 'warn', | |
| 'no-control-regex': 'error', | |
| 'no-debugger': 'warn', // todo | |
| 'no-dupe-args': 'error', | |
| 'no-dupe-else-if': 'error', | |
| 'no-dupe-keys': 'error', | |
| 'no-duplicate-case': 'error', | |
| 'no-empty': 'error', | |
| 'no-empty-character-class': 'warn', | |
| 'no-ex-assign': 'error', | |
| 'no-extra-boolean-cast': 'warn', | |
| 'no-extra-semi': 'error', | |
| 'no-func-assign': 'error', | |
| 'no-import-assign': 'error', | |
| 'no-inner-declarations': 'error', | |
| 'no-invalid-regexp': 'error', | |
| 'no-irregular-whitespace': 'error', | |
| 'no-loss-of-precision': 'warn', | |
| 'no-misleading-character-class': 'warn', | |
| 'no-obj-calls': 'warn', | |
| 'no-prototype-builtins': 'error', | |
| 'no-regex-spaces': 'error', | |
| 'no-setter-return': 'warn', | |
| 'no-sparse-arrays': 'error', | |
| 'no-template-curly-in-string': 'warn', | |
| 'no-unexpected-multiline': 'error', | |
| 'no-unreachable': 'error', | |
| 'no-unsafe-finally': 'error', | |
| 'no-unsafe-negation': 'error', | |
| 'no-negated-in-lhs': 'off', | |
| 'use-isnan': 'error', | |
| 'valid-typeof': ['error', { requireStringLiterals: true }], | |
| 'arrow-body-style': ['error', 'as-needed', { | |
| requireReturnForObjectLiteral: true, | |
| }], | |
| 'arrow-parens': ['error', 'always'], | |
| 'arrow-spacing': ['error', { before: true, after: true }], | |
| 'constructor-super': 'error', | |
| 'generator-star-spacing': ['error', { before: false, after: true }], | |
| 'no-class-assign': 'error', | |
| 'no-confusing-arrow': ['error', { | |
| allowParens: true, | |
| }], | |
| 'no-const-assign': 'error', | |
| 'no-dupe-class-members': 'error', | |
| 'no-new-symbol': 'error', | |
| 'no-this-before-super': 'error', | |
| 'no-useless-computed-key': 'error', | |
| 'no-useless-rename': ['error', { | |
| ignoreDestructuring: false, | |
| ignoreImport: false, | |
| ignoreExport: false, | |
| }], | |
| 'no-var': 'error', | |
| 'object-shorthand': ['error', 'always', { | |
| ignoreConstructors: false, | |
| avoidQuotes: true, | |
| }], | |
| 'prefer-arrow-callback': ['warn', { | |
| allowNamedFunctions: false, | |
| allowUnboundThis: true, | |
| }], | |
| 'prefer-const': ['error', { | |
| destructuring: 'any', | |
| ignoreReadBeforeAssign: true, | |
| }], | |
| 'prefer-destructuring': ['error', { | |
| VariableDeclarator: { | |
| array: false, | |
| object: true, | |
| }, | |
| AssignmentExpression: { | |
| array: true, | |
| object: false, | |
| }, | |
| }, { | |
| enforceForRenamedProperties: false, | |
| }], | |
| 'prefer-numeric-literals': 'warn', | |
| 'prefer-rest-params': 'error', | |
| 'prefer-spread': 'error', | |
| 'prefer-template': 'error', | |
| 'require-yield': 'error', | |
| 'rest-spread-spacing': ['error', 'never'], | |
| 'sort-imports': ['error', { | |
| ignoreCase: false, | |
| ignoreDeclarationSort: false, | |
| ignoreMemberSort: false, | |
| memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], | |
| }], | |
| 'symbol-description': 'error', | |
| 'template-curly-spacing': 'error', | |
| 'yield-star-spacing': ['error', 'after'], | |
| 'import/named': 'error', | |
| 'import/default': 'error', | |
| 'import/namespace': 'warn', | |
| 'import/export': 'error', | |
| 'import/no-named-as-default': 'error', | |
| 'import/no-named-as-default-member': 'error', | |
| 'import/no-extraneous-dependencies': ['error', { | |
| devDependencies: true, | |
| optionalDependencies: false, | |
| }], | |
| 'import/no-mutable-exports': 'error', | |
| 'import/no-amd': 'error', | |
| 'import/first': 'error', | |
| 'import/no-duplicates': 'error', | |
| 'import/extensions': ['error', 'ignorePackages', { | |
| js: 'never', | |
| mjs: 'never', | |
| jsx: 'never', | |
| }], | |
| 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }], | |
| 'import/newline-after-import': 'error', | |
| 'import/prefer-default-export': 'error', | |
| 'import/no-absolute-path': 'error', | |
| 'import/no-named-default': 'error', | |
| 'import/exports-last': 'warn', | |
| 'import/no-self-import': 'error', | |
| 'import/no-useless-path-segments': ['error', { commonjs: true }], | |
| 'array-bracket-spacing': ['error', 'never'], | |
| 'block-spacing': ['error', 'always'], | |
| 'brace-style': ['error', '1tbs', { allowSingleLine: true }], | |
| 'comma-dangle': ['error', { | |
| arrays: 'always-multiline', | |
| objects: 'always-multiline', | |
| imports: 'always-multiline', | |
| exports: 'always-multiline', | |
| functions: 'always-multiline', | |
| }], | |
| 'comma-spacing': ['error', { before: false, after: true }], | |
| 'comma-style': ['error', 'last', { | |
| exceptions: { | |
| ArrayExpression: false, | |
| ArrayPattern: false, | |
| ArrowFunctionExpression: false, | |
| CallExpression: false, | |
| FunctionDeclaration: false, | |
| FunctionExpression: false, | |
| ImportDeclaration: false, | |
| ObjectExpression: false, | |
| ObjectPattern: false, | |
| VariableDeclaration: false, | |
| NewExpression: false, | |
| }, | |
| }], | |
| 'computed-property-spacing': ['error', 'never'], | |
| 'eol-last': ['error', 'always'], | |
| 'func-call-spacing': ['error', 'never'], | |
| 'func-names': 'warn', | |
| 'function-paren-newline': ['error', 'consistent'], | |
| 'implicit-arrow-linebreak': ['error', 'beside'], | |
| indent: ['error', 2, { | |
| SwitchCase: 1, | |
| VariableDeclarator: 1, | |
| outerIIFEBody: 1, | |
| // MemberExpression: null, | |
| FunctionDeclaration: { | |
| parameters: 1, | |
| body: 1, | |
| }, | |
| FunctionExpression: { | |
| parameters: 1, | |
| body: 1, | |
| }, | |
| CallExpression: { | |
| arguments: 1, | |
| }, | |
| ArrayExpression: 1, | |
| ObjectExpression: 1, | |
| ImportDeclaration: 1, | |
| flatTernaryExpressions: false, | |
| // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js | |
| ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], | |
| ignoreComments: false, | |
| }], | |
| 'key-spacing': ['error', { beforeColon: false, afterColon: true }], | |
| 'keyword-spacing': ['error', { | |
| before: true, | |
| after: true, | |
| overrides: { | |
| return: { after: true }, | |
| throw: { after: true }, | |
| case: { after: true }, | |
| }, | |
| }], | |
| 'linebreak-style': ['error', 'unix'], | |
| 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }], | |
| 'lines-around-directive': ['error', { | |
| before: 'always', | |
| after: 'always', | |
| }], | |
| 'max-len': ['error', 100, 2, { | |
| ignoreUrls: true, | |
| ignoreComments: false, | |
| ignoreRegExpLiterals: true, | |
| ignoreStrings: true, | |
| ignoreTemplateLiterals: true, | |
| }], | |
| 'new-cap': ['error', { | |
| newIsCap: true, | |
| newIsCapExceptions: [], | |
| capIsNew: false, | |
| capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'], | |
| }], | |
| 'new-parens': 'error', | |
| 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], | |
| 'no-array-constructor': 'error', | |
| 'no-bitwise': 'error', | |
| 'no-continue': 'error', | |
| 'no-lonely-if': 'error', | |
| 'no-mixed-operators': ['error', { | |
| groups: [ | |
| ['%', '**'], | |
| ['%', '+'], | |
| ['%', '-'], | |
| ['%', '*'], | |
| ['%', '/'], | |
| ['/', '*'], | |
| ['&', '|', '<<', '>>', '>>>'], | |
| ['==', '!=', '===', '!=='], | |
| ['&&', '||'], | |
| ], | |
| allowSamePrecedence: false, | |
| }], | |
| 'no-mixed-spaces-and-tabs': 'error', | |
| 'no-multi-assign': ['error'], | |
| 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }], | |
| 'no-nested-ternary': 'error', | |
| 'no-new-object': 'error', | |
| 'no-plusplus': 'error', | |
| 'no-restricted-syntax': [ | |
| 'error', | |
| { | |
| selector: 'ForInStatement', | |
| message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', | |
| }, | |
| { | |
| selector: 'ForOfStatement', | |
| message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.', | |
| }, | |
| { | |
| selector: 'LabeledStatement', | |
| message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', | |
| }, | |
| { | |
| selector: 'WithStatement', | |
| message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', | |
| }, | |
| ], | |
| 'no-spaced-func': 'error', | |
| 'no-tabs': 'error', | |
| 'no-trailing-spaces': ['error', { | |
| skipBlankLines: false, | |
| ignoreComments: false, | |
| }], | |
| 'no-underscore-dangle': ['error', { | |
| allow: [], | |
| allowAfterThis: false, | |
| allowAfterSuper: false, | |
| enforceInMethodNames: true, | |
| }], | |
| 'no-unneeded-ternary': ['error', { defaultAssignment: false }], | |
| 'no-whitespace-before-property': 'error', | |
| 'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }], | |
| 'object-curly-spacing': ['error', 'always'], | |
| 'object-curly-newline': ['error', { | |
| ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, | |
| ObjectPattern: { minProperties: 4, multiline: true, consistent: true }, | |
| ImportDeclaration: { minProperties: 4, multiline: true, consistent: true }, | |
| ExportDeclaration: { minProperties: 4, multiline: true, consistent: true }, | |
| }], | |
| 'object-property-newline': ['error', { | |
| allowAllPropertiesOnSameLine: true, | |
| }], | |
| 'one-var-declaration-per-line': ['error', 'always'], | |
| 'operator-assignment': ['error', 'always'], | |
| 'padded-blocks': ['error', { | |
| blocks: 'never', | |
| classes: 'never', | |
| switches: 'never', | |
| }, { | |
| allowSingleLineBlocks: true, | |
| }], | |
| 'prefer-object-spread': 'error', | |
| 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], | |
| quotes: ['error', 'single', { avoidEscape: true }], | |
| 'space-before-function-paren': ['error', 'never'], | |
| 'space-in-parens': ['error', 'never'], | |
| 'space-infix-ops': 'error', | |
| 'space-unary-ops': ['error', { | |
| words: true, | |
| nonwords: false, | |
| overrides: { | |
| }, | |
| }], | |
| 'spaced-comment': ['error', 'always', { | |
| line: { | |
| exceptions: ['-', '+'], | |
| markers: ['=', '!', '/'], // space here to support sprockets directives, slash for TS /// comments | |
| }, | |
| block: { | |
| exceptions: ['-', '+'], | |
| markers: ['=', '!', ':', '::'], // space here to support sprockets directives and flow comment types | |
| balanced: true, | |
| }, | |
| }], | |
| 'switch-colon-spacing': ['error', { after: true, before: false }], | |
| 'template-tag-spacing': ['error', 'never'], | |
| 'unicode-bom': ['error', 'never'], | |
| 'no-catch-shadow': 'warn', | |
| 'no-delete-var': 'error', | |
| 'no-label-var': 'error', | |
| 'no-restricted-globals': [ | |
| 'error', | |
| { | |
| name: 'isFinite', | |
| message: | |
| 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite', | |
| }, | |
| { | |
| name: 'isNaN', | |
| message: | |
| 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan', | |
| }, | |
| ].concat(confusingBrowserGlobals), | |
| 'no-shadow': 'error', | |
| 'no-shadow-restricted-names': 'error', | |
| 'no-undef': 'error', | |
| 'no-undef-init': 'error', | |
| 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }], | |
| 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }], | |
| 'react/jsx-uses-react': 'error', | |
| 'react/jsx-uses-vars': 'error', | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment