UNPKG

@dangee1705/eslint-config

Version:
488 lines (481 loc) 22.3 kB
import stylistic from '@stylistic/eslint-plugin'; import typescriptEslint from '@typescript-eslint/eslint-plugin'; import parser from '@typescript-eslint/parser'; import reactHooks from 'eslint-plugin-react-hooks'; import simpleImportSort from 'eslint-plugin-simple-import-sort'; import globals from 'globals'; /** @type {import('eslint').Linter.Config[]} */ export default [ { rules: { 'no-console': ['warn', {allow: ['info', 'warn', 'error']}] } }, { files: ['**/*.{js,jsx,ts,tsx}'], languageOptions: { globals: { ...globals.browser, ...globals.node }, parser, parserOptions: { allowJS: true, projectService: { allowDefaultProject: ['*.js'] }, tsconfigRootDir: import.meta.dirname } }, rules: { 'array-callback-return': ['warn'], 'constructor-super': ['warn'], 'for-direction': ['warn'], 'getter-return': ['warn'], 'no-async-promise-executor': ['warn'], 'no-await-in-loop': ['warn'], 'no-class-assign': ['warn'], 'no-compare-neg-zero': ['warn'], 'no-cond-assign': ['warn'], 'no-const-assign': ['warn'], 'no-constant-binary-expression': ['warn'], 'no-constant-condition': ['warn'], 'no-constructor-return': ['warn'], 'no-control-regex': ['warn'], 'no-debugger': ['warn'], 'no-dupe-args': ['warn'], 'no-dupe-class-members': ['warn'], 'no-dupe-else-if': ['warn'], 'no-dupe-keys': ['warn'], 'no-duplicate-case': ['warn'], 'no-duplicate-imports': ['warn'], 'no-empty-character-class': ['warn'], 'no-empty-pattern': ['warn'], 'no-ex-assign': ['warn'], 'no-fallthrough': ['warn'], 'no-func-assign': ['warn'], 'no-import-assign': ['warn'], 'no-inner-declarations': ['warn'], 'no-invalid-regexp': ['warn'], 'no-irregular-whitespace': ['warn'], 'no-loss-of-precision': ['warn'], 'no-misleading-character-class': ['warn'], 'no-new-native-nonconstructor': ['warn'], 'no-obj-calls': ['warn'], 'no-promise-executor-return': ['warn'], 'no-prototype-builtins': ['warn'], 'no-self-assign': ['warn'], 'no-self-compare': ['warn'], 'no-setter-return': ['warn'], 'no-sparse-arrays': ['warn'], 'no-template-curly-in-string': ['warn'], 'no-this-before-super': ['warn'], 'no-undef': ['warn'], 'no-unexpected-multiline': ['warn'], 'no-unmodified-loop-condition': ['warn'], 'no-unreachable': ['warn'], 'no-unreachable-loop': ['warn'], 'no-unsafe-finally': ['warn'], 'no-unsafe-negation': ['warn'], 'no-unsafe-optional-chaining': ['warn'], 'no-unused-private-class-members': ['warn'], 'no-unused-vars': ['off'], 'no-use-before-define': ['warn'], 'no-useless-assignment': ['warn'], 'no-useless-backreference': ['warn'], 'require-atomic-updates': ['warn'], 'use-isnan': ['warn'], 'valid-typeof': ['warn'], 'accessor-pairs': ['off'], 'arrow-body-style': ['warn', 'as-needed'], 'block-scoped-var': ['warn'], 'camelcase': ['warn'], // TODO: check this for objects 'capitalized-comments': ['off'], 'class-methods-use-this': ['warn'], 'complexity': ['off'], 'consistent-return': ['off'], 'consistent-this': ['warn'], 'curly': ['warn', 'multi', 'consistent'], 'default-case': ['off'], 'default-case-last': ['off'], 'default-param-last': ['off'], 'dot-notation': ['off'], 'eqeqeq': ['warn'], 'func-name-matching': ['warn'], 'func-names': ['warn', 'as-needed'], 'func-style': ['off'], 'grouped-accessor-pairs': ['off'], 'guard-for-in': ['warn'], 'id-denylist': ['off'], 'id-length': ['off'], 'id-match': ['off'], 'init-declarations': ['off'], 'logical-assignment-operators': ['warn'], 'max-classes-per-file': ['off'], 'max-depth': ['warn', {'max': 4}], 'max-lines': ['off'], 'max-lines-per-function': ['off'], 'max-nested-callbacks': ['warn', {'max': 3}], 'max-params': ['warn', {'max': 5}], 'max-statements': ['off'], 'new-cap': ['warn'], 'no-alert': ['off'], 'no-array-constructor': ['warn'], 'no-bitwise': ['off'], 'no-caller': ['warn'], 'no-case-declarations': ['warn'], 'no-console': ['warn', {'allow': ['info']}], 'no-continue': ['off'], 'no-delete-var': ['warn'], 'no-div-regex': ['warn'], 'no-else-return': ['warn'], 'no-empty': ['warn'], 'no-empty-function': ['warn'], 'no-empty-static-block': ['warn'], 'no-eq-null': ['warn'], 'no-eval': ['warn'], 'no-extend-native': ['warn'], 'no-extra-bind': ['warn'], 'no-extra-boolean-cast': ['warn'], 'no-extra-label': ['warn'], 'no-global-assign': ['warn'], 'no-implicit-coercion': ['off'], 'no-implicit-globals': ['warn'], 'no-implied-eval': ['warn'], 'no-inline-comments': ['off'], 'no-invalid-this': ['warn'], 'no-iterator': ['warn'], 'no-label-var': ['warn'], 'no-labels': ['off'], 'no-lone-blocks': ['off'], 'no-lonely-if': ['warn'], 'no-loop-func': ['warn'], 'no-magic-numbers': ['off'], // TODO: probably a good idea to enable 'no-multi-assign': ['warn', {'ignoreNonDeclaration': true}], 'no-multi-str': ['warn'], 'no-negated-condition': ['warn'], 'no-nested-ternary': ['off'], 'no-new': ['warn'], 'no-new-func': ['warn'], 'no-new-wrappers': ['warn'], 'no-nonoctal-decimal-escape': ['warn'], 'no-object-constructor': ['warn'], 'no-octal': ['warn'], 'no-octal-escape': ['warn'], 'no-param-reassign': ['warn'], 'no-plusplus': ['off'], 'no-proto': ['warn'], 'no-redeclare': ['warn'], 'no-regex-spaces': ['warn'], 'no-restricted-exports': ['off'], 'no-restricted-globals': ['off'], 'no-restricted-imports': ['off'], 'no-restricted-properties': ['off'], 'no-restricted-syntax': ['off'], 'no-return-assign': ['warn'], 'no-script-url': ['warn'], 'no-sequences': ['off'], 'no-shadow': ['off'], 'no-shadow-restricted-names': ['warn'], 'no-ternary': ['off'], 'no-throw-literal': ['warn'], 'no-undef-init': ['warn'], 'no-undefined': ['off'], 'no-underscore-dangle': ['warn'], 'no-unneeded-ternary': ['warn'], 'no-unused-expressions': ['warn'], 'no-unused-labels': ['warn'], 'no-useless-call': ['warn'], 'no-useless-catch': ['warn'], 'no-useless-computed-key': ['warn'], 'no-useless-concat': ['warn'], 'no-useless-constructor': ['warn'], 'no-useless-escape': ['warn'], 'no-useless-rename': ['warn'], 'no-useless-return': ['warn'], 'no-var': ['warn'], 'no-void': ['off'], 'no-warning-comments': ['off'], 'no-with': ['warn'], 'object-shorthand': ['warn', 'always'], 'one-var': ['off'], 'operator-assignment': ['warn'], 'prefer-arrow-callback': ['warn'], 'prefer-const': ['off'], 'prefer-destructuring': ['off'], 'prefer-exponentiation-operator': ['warn'], 'prefer-named-capture-group': ['off'], 'prefer-numeric-literals': ['warn'], 'prefer-object-has-own': ['warn'], 'prefer-object-spread': ['warn'], 'prefer-promise-reject-errors': ['warn'], 'prefer-regex-literals': ['warn'], 'prefer-rest-params': ['warn'], 'prefer-spread': ['warn'], 'prefer-template': ['warn'], 'radix': ['warn'], 'require-await': ['warn'], 'require-unicode-regexp': ['off'], 'require-yield': ['warn'], 'sort-imports': ['off'], 'sort-keys': ['off'], 'sort-vars': ['off'], 'strict': ['warn'], 'symbol-description': ['warn'], 'vars-on-top': ['warn'], 'yoda': ['warn'], 'unicode-bom': ['warn'], 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'error', '@stylistic/array-bracket-newline': ['warn', 'consistent'], '@stylistic/array-bracket-spacing': ['warn', 'never'], '@stylistic/array-element-newline': ['warn', {'consistent': true, 'multiline': true}], '@stylistic/arrow-parens': ['warn', 'as-needed'], '@stylistic/arrow-spacing': ['warn'], '@stylistic/block-spacing': ['warn', 'never'], '@stylistic/brace-style': ['warn', '1tbs'], '@stylistic/comma-dangle': ['warn', 'never'], '@stylistic/comma-spacing': ['warn'], '@stylistic/comma-style': ['warn'], '@stylistic/computed-property-spacing': ['warn'], '@stylistic/curly-newline': ['warn', 'always'], '@stylistic/dot-location': ['warn', 'property'], '@stylistic/eol-last': ['warn', 'always'], '@stylistic/function-call-argument-newline': ['warn', 'consistent'], '@stylistic/function-call-spacing': ['warn', 'never'], '@stylistic/function-paren-newline': ['warn', 'multiline-arguments'], '@stylistic/generator-star-spacing': ['warn', {'before': true, 'after': false}], '@stylistic/implicit-arrow-linebreak': ['warn', 'beside'], '@stylistic/indent': ['warn', 'tab', {'SwitchCase': 1}], '@stylistic/indent-binary-ops': ['warn', 'tab'], '@stylistic/jsx-child-element-spacing': ['warn'], '@stylistic/jsx-closing-bracket-location': ['warn', 'line-aligned'], '@stylistic/jsx-closing-tag-location': ['warn', 'line-aligned'], '@stylistic/jsx-curly-brace-presence': ['warn', {'props': 'never', 'children': 'never', 'propElementValues': 'always'}], '@stylistic/jsx-curly-newline': ['warn', {'multiline': 'consistent', 'singleline': 'consistent'}], '@stylistic/jsx-curly-spacing': ['warn', {'when': 'never', 'children': true}], '@stylistic/jsx-equals-spacing': ['warn', 'never'], '@stylistic/jsx-first-prop-new-line': ['warn', 'multiline'], '@stylistic/jsx-function-call-newline': ['warn', 'multiline'], '@stylistic/jsx-indent': ['warn', 'tab'], '@stylistic/jsx-indent-props': ['warn', 'tab'], '@stylistic/jsx-max-props-per-line': ['off'], '@stylistic/jsx-newline': ['off'], '@stylistic/jsx-one-expression-per-line': ['off'], '@stylistic/jsx-pascal-case': ['warn'], '@stylistic/jsx-props-no-multi-spaces': ['warn'], '@stylistic/jsx-quotes': ['warn', 'prefer-single'], '@stylistic/jsx-self-closing-comp': ['warn', {'component': true, 'html': true}], '@stylistic/jsx-sort-props': ['off'], '@stylistic/jsx-tag-spacing': ['warn', {'closingSlash': 'never', 'beforeSelfClosing': 'never', 'afterOpening': 'never', 'beforeClosing': 'never'}], '@stylistic/jsx-wrap-multilines': ['warn', {'declaration': 'parens-new-line', 'assignment': 'parens-new-line', 'return': 'parens-new-line', 'arrow': 'parens-new-line', 'condition': 'parens-new-line', 'logical': 'parens-new-line', 'prop': 'parens-new-line'}], '@stylistic/key-spacing': ['warn', {'beforeColon': false, 'afterColon': true}], '@stylistic/keyword-spacing': [ 'warn', { 'before': true, 'after': true, 'overrides': { 'if': {'after': false}, 'for': {'after': false}, 'while': {'after': false} } } ], '@stylistic/line-comment-position': ['off'], '@stylistic/linebreak-style': ['warn', 'unix'], '@stylistic/lines-around-comment': ['warn', {'beforeBlockComment': true, 'beforeLineComment': true, 'allowBlockStart': true, 'allowBlockEnd': true, 'allowObjectStart': true, 'allowObjectEnd': true, 'allowArrayStart': true, 'allowArrayEnd': true}], '@stylistic/lines-between-class-members': ['warn', 'always'], '@stylistic/max-len': ['warn', {'code': 120, 'tabWidth': 4, 'ignoreUrls': true, 'ignoreStrings': true, 'ignoreTemplateLiterals': true, 'ignoreRegExpLiterals': true}], '@stylistic/max-statements-per-line': ['warn', {'max': 1}], '@stylistic/member-delimiter-style': ['warn', {'multiline': {'delimiter': 'semi', 'requireLast': true}, 'singleline': {'delimiter': 'semi', 'requireLast': false}}], '@stylistic/multiline-comment-style': ['off'], '@stylistic/multiline-ternary': ['warn', 'always-multiline'], '@stylistic/new-parens': ['warn', 'always'], '@stylistic/newline-per-chained-call': ['warn', {'ignoreChainWithDepth': 3}], '@stylistic/no-confusing-arrow': ['warn', {'allowParens': true}], '@stylistic/no-extra-parens': ['warn', 'all', {'nestedBinaryExpressions': false, 'ignoreJSX': 'multi-line', 'enforceForArrowConditionals': false}], '@stylistic/no-extra-semi': ['warn'], '@stylistic/no-floating-decimal': ['warn'], '@stylistic/no-mixed-operators': ['warn', {'allowSamePrecedence': true}], '@stylistic/no-mixed-spaces-and-tabs': ['warn'], '@stylistic/no-multi-spaces': ['warn'], '@stylistic/no-multiple-empty-lines': ['warn', {'max': 2, 'maxEOF': 0}], '@stylistic/no-tabs': ['warn', {allowIndentationTabs: true}], '@stylistic/no-trailing-spaces': ['warn'], '@stylistic/no-whitespace-before-property': ['warn'], '@stylistic/nonblock-statement-body-position': ['warn', 'any'], '@stylistic/object-curly-newline': [ 'warn', { 'multiline': true, 'consistent': true } ], '@stylistic/object-curly-spacing': ['warn', 'never'], '@stylistic/object-property-newline': ['off'], '@stylistic/one-var-declaration-per-line': ['warn', 'initializations'], '@stylistic/operator-linebreak': ['warn', 'after'], '@stylistic/padded-blocks': ['warn', 'never'], '@stylistic/padding-line-between-statements': ['off'], '@stylistic/quote-props': ['warn', 'consistent'], '@stylistic/quotes': ['warn', 'single'], '@stylistic/rest-spread-spacing': ['warn', 'never'], '@stylistic/semi': ['warn'], '@stylistic/semi-spacing': ['warn', {'before': false, 'after': true}], '@stylistic/semi-style': ['warn', 'last'], '@stylistic/space-before-blocks': ['warn', 'always'], '@stylistic/space-before-function-paren': ['warn', {'anonymous': 'always', 'named': 'never', 'asyncArrow': 'always'}], '@stylistic/space-in-parens': ['warn', 'never'], '@stylistic/space-infix-ops': ['warn'], '@stylistic/space-unary-ops': ['warn', {'words': true, 'nonwords': false}], '@stylistic/spaced-comment': ['warn', 'always'], '@stylistic/switch-colon-spacing': ['warn'], '@stylistic/template-curly-spacing': ['warn', 'never'], '@stylistic/template-tag-spacing': ['warn', 'never'], '@stylistic/type-annotation-spacing': ['warn'], '@stylistic/type-generic-spacing': ['warn'], '@stylistic/type-named-tuple-spacing': ['warn'], '@stylistic/wrap-iife': ['warn', 'inside'], '@stylistic/wrap-regex': ['off'], '@stylistic/yield-star-spacing': ['warn', 'before'], '@typescript-eslint/adjacent-overload-signatures': ['warn'], '@typescript-eslint/array-type': ['warn', {'default': 'array'}], '@typescript-eslint/await-thenable': ['warn'], '@typescript-eslint/ban-ts-comment': ['off'], '@typescript-eslint/ban-tslint-comment': ['error'], '@typescript-eslint/class-literal-property-style': ['off'], // no preference afaik '@typescript-eslint/class-methods-use-this': ['off'], '@typescript-eslint/consistent-generic-constructors': ['warn', 'constructor'], '@typescript-eslint/consistent-indexed-object-style': ['warn', 'index-signature'], '@typescript-eslint/consistent-return': ['warn'], '@typescript-eslint/consistent-type-assertions': ['warn', {'assertionStyle': 'as', 'objectLiteralTypeAssertions': 'allow'}], '@typescript-eslint/consistent-type-definitions': ['warn', 'type'], '@typescript-eslint/consistent-type-exports': ['off'], '@typescript-eslint/consistent-type-imports': ['off'], '@typescript-eslint/default-param-last': ['error'], '@typescript-eslint/dot-notation': ['off'], '@typescript-eslint/explicit-function-return-type': ['off'], '@typescript-eslint/explicit-member-accessibility': ['off'], // '@typescript-eslint/explicit-module-boundary-types': ['warn'], // '@typescript-eslint/init-declarations': ['warn'], // '@typescript-eslint/max-params': ['warn'], // '@typescript-eslint/member-ordering': ['warn'], // '@typescript-eslint/method-signature-style': ['warn'], // '@typescript-eslint/naming-convention': ['off'], // '@typescript-eslint/no-array-constructor': ['warn'], // '@typescript-eslint/no-array-delete': ['warn'], // '@typescript-eslint/no-base-to-string': ['warn'], // '@typescript-eslint/no-confusing-non-null-assertion': ['warn'], // '@typescript-eslint/no-confusing-void-expression': ['warn'], // '@typescript-eslint/no-deprecated': ['warn'], // '@typescript-eslint/no-dupe-class-members': ['warn'], // '@typescript-eslint/no-duplicate-enum-values': ['warn'], // '@typescript-eslint/no-duplicate-type-constituents': ['warn'], // '@typescript-eslint/no-dynamic-delete': ['warn'], // '@typescript-eslint/no-empty-function': ['warn'], // '@typescript-eslint/no-empty-interface': ['warn'], // '@typescript-eslint/no-empty-object-type': ['warn'], // '@typescript-eslint/no-explicit-any': ['warn'], // '@typescript-eslint/no-extra-non-null-assertion': ['warn'], // '@typescript-eslint/no-extraneous-class': ['warn'], // '@typescript-eslint/no-floating-promises': ['warn'], // '@typescript-eslint/no-for-in-array': ['warn'], // '@typescript-eslint/no-implied-eval': ['warn'], // '@typescript-eslint/no-import-type-side-effects': ['warn'], // '@typescript-eslint/no-inferrable-types': ['warn'], // '@typescript-eslint/no-invalid-this': ['warn'], // '@typescript-eslint/no-invalid-void-type': ['warn'], // '@typescript-eslint/no-loop-func': ['warn'], // '@typescript-eslint/no-loss-of-precision': ['warn'], // '@typescript-eslint/no-magic-numbers': ['warn'], // '@typescript-eslint/no-meaningless-void-operator': ['warn'], // '@typescript-eslint/no-misused-new': ['warn'], // '@typescript-eslint/no-misused-promises': ['warn'], // '@typescript-eslint/no-misused-spread': ['warn'], // '@typescript-eslint/no-mixed-enums': ['warn'], // '@typescript-eslint/no-namespace': ['warn'], // '@typescript-eslint/no-non-null-asserted-nullish-coalescing': ['warn'], // '@typescript-eslint/no-non-null-asserted-optional-chain': ['warn'], // '@typescript-eslint/no-non-null-assertion': ['warn'], // '@typescript-eslint/no-redeclare': ['warn'], // '@typescript-eslint/no-redundant-type-constituents': ['warn'], // '@typescript-eslint/no-require-imports': ['warn'], // '@typescript-eslint/no-restricted-imports': ['warn'], // '@typescript-eslint/no-restricted-types': ['warn'], // '@typescript-eslint/no-shadow': ['warn'], // '@typescript-eslint/no-this-alias': ['warn'], // '@typescript-eslint/no-type-alias': ['warn'], // '@typescript-eslint/no-unnecessary-boolean-literal-compare': ['warn'], // '@typescript-eslint/no-unnecessary-condition': ['warn'], // '@typescript-eslint/no-unnecessary-parameter-property-assignment': ['warn'], // '@typescript-eslint/no-unnecessary-qualifier': ['warn'], // '@typescript-eslint/no-unnecessary-template-expression': ['warn'], // '@typescript-eslint/no-unnecessary-type-arguments': ['warn'], // '@typescript-eslint/no-unnecessary-type-assertion': ['warn'], // '@typescript-eslint/no-unnecessary-type-constraint': ['warn'], // '@typescript-eslint/no-unnecessary-type-parameters': ['warn'], // '@typescript-eslint/no-unsafe-argument': ['warn'], // '@typescript-eslint/no-unsafe-assignment': ['warn'], // '@typescript-eslint/no-unsafe-call': ['warn'], // '@typescript-eslint/no-unsafe-declaration-merging': ['warn'], // '@typescript-eslint/no-unsafe-enum-comparison': ['warn'], // '@typescript-eslint/no-unsafe-function-type': ['warn'], // '@typescript-eslint/no-unsafe-member-access': ['warn'], // '@typescript-eslint/no-unsafe-return': ['warn'], // '@typescript-eslint/no-unsafe-type-assertion': ['warn'], // '@typescript-eslint/no-unsafe-unary-minus': ['warn'], // '@typescript-eslint/no-unused-expressions': ['warn'], '@typescript-eslint/no-unused-vars': ['warn'], // '@typescript-eslint/no-use-before-define': ['warn'], // '@typescript-eslint/no-useless-constructor': ['warn'], // '@typescript-eslint/no-useless-empty-export': ['warn'], // '@typescript-eslint/no-var-requires': ['warn'], // '@typescript-eslint/no-wrapper-object-types': ['warn'], // '@typescript-eslint/non-nullable-type-assertion-style': ['warn'], // '@typescript-eslint/only-throw-error': ['warn'], // '@typescript-eslint/parameter-properties': ['warn'], // '@typescript-eslint/prefer-as-const': ['warn'], // '@typescript-eslint/prefer-destructuring': ['warn'], // '@typescript-eslint/prefer-enum-initializers': ['warn'], // '@typescript-eslint/prefer-find': ['warn'], // '@typescript-eslint/prefer-for-of': ['warn'], // '@typescript-eslint/prefer-function-type': ['warn'], // '@typescript-eslint/prefer-includes': ['warn'], // '@typescript-eslint/prefer-literal-enum-member': ['warn'], // '@typescript-eslint/prefer-namespace-keyword': ['warn'], // '@typescript-eslint/prefer-nullish-coalescing': ['warn'], // '@typescript-eslint/prefer-optional-chain': ['warn'], // '@typescript-eslint/prefer-promise-reject-errors': ['warn'], // '@typescript-eslint/prefer-readonly': ['warn'], // '@typescript-eslint/prefer-readonly-parameter-types': ['warn'], // '@typescript-eslint/prefer-reduce-type-parameter': ['warn'], // '@typescript-eslint/prefer-regexp-exec': ['warn'], // '@typescript-eslint/prefer-return-this-type': ['warn'], // '@typescript-eslint/prefer-string-starts-ends-with': ['warn'], // '@typescript-eslint/prefer-ts-expect-error': ['warn'], // '@typescript-eslint/promise-function-async': ['warn'], // '@typescript-eslint/related-getter-setter-pairs': ['warn'], // '@typescript-eslint/require-array-sort-compare': ['warn'], // '@typescript-eslint/require-await': ['warn'], // '@typescript-eslint/restrict-plus-operands': ['warn'], // '@typescript-eslint/restrict-template-expressions': ['warn'], // '@typescript-eslint/return-await': ['warn'], // '@typescript-eslint/sort-type-constituents': ['warn'], // '@typescript-eslint/strict-boolean-expressions': ['warn'], // '@typescript-eslint/switch-exhaustiveness-check': ['warn'], // '@typescript-eslint/triple-slash-reference': ['warn'], // '@typescript-eslint/typedef': ['warn'], // '@typescript-eslint/unbound-method': ['warn'], // '@typescript-eslint/unified-signatures': ['warn'], // '@typescript-eslint/use-unknown-in-catch-callback-variable': ['warn'] 'simple-import-sort/imports': ['warn'] }, plugins: { 'react-hooks': reactHooks, '@stylistic': stylistic, '@typescript-eslint': typescriptEslint, 'simple-import-sort': simpleImportSort } } ];