UNPKG

@osskit/eslint-config

Version:
595 lines (593 loc) 23.6 kB
// @ts-check import unicornPlugin from 'eslint-plugin-unicorn'; import importXPlugin from 'eslint-plugin-import-x'; import typescriptEslint from 'typescript-eslint'; import globals from 'globals'; /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} */ export const baseConfig = { name: '@osskit/eslint-config', files: ['**/*.ts', '**/*.cts', '**.*.mts', '**/*.js', '**/*.jsx', '**/*.tsx'], languageOptions: { globals: { ...globals.browser, ...globals.node, }, parserOptions: { projectService: { allowDefaultProject: ['*.js', '*.ts'], defaultProject: './tsconfig.json', }, }, parser: typescriptEslint.parser, }, plugins: { unicorn: unicornPlugin, 'import-x': importXPlugin, '@typescript-eslint': typescriptEslint.plugin, }, rules: { '@typescript-eslint/no-deprecated': 'error', '@typescript-eslint/no-unnecessary-type-parameters': 'error', '@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error', '@typescript-eslint/no-empty-object-type': 'error', '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/array-type': 'error', '@typescript-eslint/await-thenable': 'error', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/ban-tslint-comment': 'error', '@typescript-eslint/class-literal-property-style': ['error', 'getters'], '@typescript-eslint/class-methods-use-this': 'error', '@typescript-eslint/consistent-generic-constructors': 'error', '@typescript-eslint/consistent-indexed-object-style': 'error', '@typescript-eslint/consistent-return': 'off', '@typescript-eslint/consistent-type-assertions': 'error', '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/default-param-last': 'error', '@typescript-eslint/dot-notation': 'error', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-member-accessibility': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/init-declarations': 'off', '@typescript-eslint/max-params': 'off', '@typescript-eslint/member-ordering': 'off', '@typescript-eslint/method-signature-style': 'error', '@typescript-eslint/naming-convention': [ 'error', { format: ['camelCase'], leadingUnderscore: 'allow', selector: 'default', trailingUnderscore: 'allow', }, { format: ['camelCase', 'UPPER_CASE'], leadingUnderscore: 'allow', selector: 'variable', trailingUnderscore: 'allow', }, { format: ['PascalCase'], selector: 'typeLike', }, { format: ['camelCase', 'UPPER_CASE', 'PascalCase'], selector: 'enumMember', }, { format: ['camelCase', 'PascalCase'], selector: 'import', }, { filter: { match: true, regex: '^x-|^Content-Type$', }, format: null, selector: 'objectLiteralProperty', }, ], '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-array-delete': 'error', '@typescript-eslint/no-base-to-string': 'error', '@typescript-eslint/no-confusing-non-null-assertion': 'error', '@typescript-eslint/no-confusing-void-expression': 'error', '@typescript-eslint/no-dupe-class-members': 'error', '@typescript-eslint/no-duplicate-enum-values': 'error', '@typescript-eslint/no-duplicate-type-constituents': 'error', '@typescript-eslint/no-dynamic-delete': 'off', '@typescript-eslint/no-empty-function': 'error', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-extra-non-null-assertion': 'error', '@typescript-eslint/no-extraneous-class': 'error', '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-for-in-array': 'error', '@typescript-eslint/no-implied-eval': 'off', '@typescript-eslint/no-import-type-side-effects': 'error', '@typescript-eslint/no-inferrable-types': 'error', '@typescript-eslint/no-invalid-this': 'error', '@typescript-eslint/no-invalid-void-type': 'error', '@typescript-eslint/no-loop-func': 'error', '@typescript-eslint/no-magic-numbers': 'off', '@typescript-eslint/no-meaningless-void-operator': 'error', '@typescript-eslint/no-misused-new': 'error', '@typescript-eslint/no-misused-promises': [ 'error', { checksVoidReturn: false, }, ], '@typescript-eslint/no-mixed-enums': 'error', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-redeclare': [ 'error', { builtinGlobals: true, }, ], '@typescript-eslint/no-redundant-type-constituents': 'error', '@typescript-eslint/no-require-imports': 'error', '@typescript-eslint/no-restricted-imports': 'off', '@typescript-eslint/no-restricted-types': 'off', '@typescript-eslint/no-unsafe-function-type': 'error', '@typescript-eslint/no-wrapper-object-types': 'error', '@typescript-eslint/no-shadow': 'off', '@typescript-eslint/no-this-alias': 'off', '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', '@typescript-eslint/no-unnecessary-condition': 'off', '@typescript-eslint/no-unnecessary-qualifier': 'error', '@typescript-eslint/no-unnecessary-template-expression': 'error', '@typescript-eslint/no-unnecessary-type-arguments': 'error', '@typescript-eslint/no-unnecessary-type-assertion': 'error', '@typescript-eslint/no-unnecessary-type-constraint': 'error', '@typescript-eslint/no-unsafe-argument': 'error', '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-declaration-merging': 'error', '@typescript-eslint/no-unsafe-enum-comparison': 'error', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', '@typescript-eslint/no-unsafe-unary-minus': 'error', '@typescript-eslint/no-unused-expressions': 'error', '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', }, ], '@typescript-eslint/no-use-before-define': 'error', '@typescript-eslint/no-useless-constructor': 'error', '@typescript-eslint/no-useless-empty-export': 'error', '@typescript-eslint/non-nullable-type-assertion-style': 'error', '@typescript-eslint/only-throw-error': 'error', '@typescript-eslint/parameter-properties': 'error', '@typescript-eslint/prefer-as-const': 'error', '@typescript-eslint/prefer-destructuring': 'error', '@typescript-eslint/prefer-enum-initializers': 'error', '@typescript-eslint/prefer-find': 'error', '@typescript-eslint/prefer-for-of': 'error', '@typescript-eslint/prefer-function-type': 'error', '@typescript-eslint/prefer-includes': 'error', '@typescript-eslint/prefer-literal-enum-member': 'error', '@typescript-eslint/prefer-namespace-keyword': 'off', '@typescript-eslint/prefer-nullish-coalescing': 'error', '@typescript-eslint/prefer-optional-chain': 'error', '@typescript-eslint/prefer-promise-reject-errors': 'error', '@typescript-eslint/prefer-readonly': 'error', '@typescript-eslint/prefer-readonly-parameter-types': 'off', '@typescript-eslint/prefer-reduce-type-parameter': 'error', '@typescript-eslint/prefer-regexp-exec': 'error', '@typescript-eslint/prefer-return-this-type': 'error', '@typescript-eslint/prefer-string-starts-ends-with': 'error', '@typescript-eslint/promise-function-async': 'off', '@typescript-eslint/require-array-sort-compare': 'error', '@typescript-eslint/require-await': 'off', '@typescript-eslint/restrict-plus-operands': 'off', '@typescript-eslint/restrict-template-expressions': 'off', '@typescript-eslint/return-await': 'error', '@typescript-eslint/strict-boolean-expressions': 'off', '@typescript-eslint/switch-exhaustiveness-check': ['error', { allowDefaultCaseForExhaustiveSwitch: false }], '@typescript-eslint/triple-slash-reference': 'error', '@typescript-eslint/unbound-method': 'off', '@typescript-eslint/unified-signatures': 'error', '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off', 'accessor-pairs': 'error', 'array-callback-return': 'error', 'arrow-body-style': ['error', 'as-needed'], 'block-scoped-var': 'error', camelcase: 'off', 'capitalized-comments': 'off', 'class-methods-use-this': 'off', complexity: 'off', 'consistent-return': 'off', 'consistent-this': ['error', 'self'], 'constructor-super': 'error', curly: 'error', 'default-case': 'off', 'default-case-last': 'error', 'default-param-last': 'error', 'dot-notation': 'off', eqeqeq: 'error', 'for-direction': 'error', 'func-name-matching': 'off', 'func-names': ['error', 'never'], 'func-style': 'off', 'getter-return': 'error', 'grouped-accessor-pairs': ['error', 'getBeforeSet'], 'guard-for-in': 'error', 'id-denylist': 'off', 'id-length': 'off', 'id-match': 'off', 'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'], 'import-x/default': 'error', 'import-x/dynamic-import-chunkname': 'off', 'import-x/export': 'error', 'import-x/exports-last': 'off', 'import-x/extensions': ['error', 'always'], 'import-x/first': 'error', 'import-x/group-exports': 'off', 'import-x/max-dependencies': 'off', 'import-x/named': 'error', 'import-x/namespace': 'error', 'import-x/newline-after-import': 'error', 'import-x/no-absolute-path': 'error', 'import-x/no-amd': 'error', 'import-x/no-anonymous-default-export': 'off', 'import-x/no-commonjs': 'error', 'import-x/no-cycle': 'error', 'import-x/no-default-export': 'off', 'import-x/no-deprecated': 'off', 'import-x/no-duplicates': 'error', 'import-x/no-dynamic-require': 'off', 'import-x/no-empty-named-blocks': 'error', 'import-x/no-extraneous-dependencies': 'error', 'import-x/no-import-module-exports': 'off', 'import-x/no-internal-modules': 'off', 'import-x/no-mutable-exports': 'off', 'import-x/no-named-as-default': 'off', 'import-x/no-named-as-default-member': 'off', 'import-x/no-named-default': 'error', 'import-x/no-named-export': 'off', 'import-x/no-namespace': 'off', 'import-x/no-nodejs-modules': 'off', 'import-x/no-relative-packages': 'off', 'import-x/no-relative-parent-imports': 'off', 'import-x/no-restricted-paths': 'off', 'import-x/no-self-import': 'error', 'import-x/no-unassigned-import': 'off', 'import-x/no-unresolved': 'off', 'import-x/no-unused-modules': 'error', 'import-x/no-useless-path-segments': 'error', 'import-x/no-webpack-loader-syntax': 'off', 'import-x/order': 'error', 'import-x/prefer-default-export': 'off', 'import-x/unambiguous': 'off', 'import-x/no-rename-default': 'off', 'init-declarations': 'off', 'logical-assignment-operators': 'error', 'max-classes-per-file': 'off', 'max-depth': 'off', 'max-lines': 'off', 'max-lines-per-function': 'off', 'max-nested-callbacks': 'off', 'max-params': 'off', 'max-statements': 'off', 'new-cap': [ 'error', { capIsNew: false, }, ], 'no-alert': 'error', 'no-array-constructor': 'error', 'no-async-promise-executor': 'error', 'no-await-in-loop': 'off', 'no-bitwise': 'error', 'no-caller': 'error', 'no-case-declarations': 'error', 'no-class-assign': 'error', 'no-compare-neg-zero': 'error', 'no-cond-assign': ['error', 'always'], 'no-console': 'off', 'no-const-assign': 'error', 'no-constant-binary-expression': 'error', 'no-constant-condition': 'error', 'no-constructor-return': 'error', 'no-continue': 'off', 'no-control-regex': 'error', 'no-debugger': 'error', 'no-delete-var': 'error', 'no-div-regex': 'error', 'no-dupe-args': 'error', 'no-dupe-class-members': 'off', 'no-dupe-else-if': 'error', 'no-dupe-keys': 'error', 'no-duplicate-case': 'error', 'no-duplicate-imports': 'off', 'no-else-return': 'error', 'no-empty': 'error', 'no-empty-character-class': 'error', 'no-empty-function': 'off', 'no-empty-pattern': 'error', 'no-empty-static-block': 'error', 'no-eq-null': 'off', 'no-eval': 'error', 'no-ex-assign': 'error', 'no-extend-native': 'error', 'no-extra-bind': 'error', 'no-extra-boolean-cast': 'error', 'no-extra-label': 'off', 'no-fallthrough': 'off', 'no-func-assign': 'error', 'no-global-assign': 'error', 'no-implicit-coercion': 'off', 'no-implicit-globals': 'error', 'no-implied-eval': 'error', 'no-import-assign': 'error', 'no-inline-comments': 'off', 'no-inner-declarations': 'error', 'no-invalid-regexp': 'error', 'no-invalid-this': 'off', 'no-irregular-whitespace': 'error', 'no-iterator': 'error', 'no-label-var': 'off', 'no-labels': 'error', 'no-lone-blocks': 'error', 'no-lonely-if': 'error', 'no-loop-func': 'off', 'no-loss-of-precision': 'error', 'no-magic-numbers': 'off', 'no-misleading-character-class': 'error', 'no-multi-assign': 'off', 'no-multi-str': 'error', 'no-negated-condition': 'off', 'no-nested-ternary': 'off', 'no-new': 'error', 'no-new-func': 'error', 'no-new-native-nonconstructor': 'error', 'no-new-wrappers': 'error', 'no-nonoctal-decimal-escape': 'error', 'no-obj-calls': 'error', 'no-object-constructor': 'error', 'no-octal': 'error', 'no-octal-escape': 'error', 'no-param-reassign': 'off', 'no-plusplus': 'off', 'no-promise-executor-return': 'off', 'no-proto': 'error', 'no-prototype-builtins': 'off', 'no-redeclare': 'off', 'no-regex-spaces': 'error', 'no-restricted-exports': 'off', 'no-restricted-globals': 'off', 'no-restricted-imports': 'off', 'no-restricted-properties': 'off', 'no-restricted-syntax': 'off', 'no-return-assign': 'error', 'no-script-url': 'error', 'no-self-assign': 'error', 'no-self-compare': 'error', 'no-sequences': 'error', 'no-setter-return': 'error', 'no-shadow': 'off', 'no-shadow-restricted-names': 'error', 'no-sparse-arrays': 'error', 'no-template-curly-in-string': 'error', 'no-ternary': 'off', 'no-this-before-super': 'error', 'no-throw-literal': 'error', 'no-undef': 'error', 'no-undef-init': 'error', 'no-undefined': 'off', 'no-underscore-dangle': 'off', 'no-unexpected-multiline': 'off', 'no-unmodified-loop-condition': 'error', 'no-unneeded-ternary': 'error', 'no-unreachable': 'error', 'no-unreachable-loop': 'error', 'no-unsafe-finally': 'off', 'no-unsafe-negation': 'error', 'no-unsafe-optional-chaining': 'error', 'no-unused-expressions': 'off', 'no-unused-labels': 'off', 'no-unused-private-class-members': 'error', 'no-unused-vars': 'off', 'no-use-before-define': 'off', 'no-useless-backreference': 'error', 'no-useless-assignment': 'error', 'no-useless-call': 'error', 'no-useless-catch': 'off', 'no-useless-computed-key': 'error', 'no-useless-concat': 'error', 'no-useless-constructor': 'error', 'no-useless-escape': 'error', 'no-useless-rename': 'error', 'no-useless-return': 'off', 'no-var': 'error', 'no-void': [ 'error', { allowAsStatement: true, }, ], 'no-warning-comments': 'off', 'no-with': 'error', 'object-shorthand': 'error', 'one-var': ['error', 'never'], 'operator-assignment': ['error', 'always'], 'prefer-arrow-callback': 'error', 'prefer-const': 'error', 'prefer-destructuring': 'off', 'prefer-exponentiation-operator': 'error', 'prefer-named-capture-group': 'off', 'prefer-numeric-literals': 'error', 'prefer-object-has-own': 'error', 'prefer-object-spread': 'error', 'prefer-promise-reject-errors': 'off', 'prefer-regex-literals': 'error', 'prefer-rest-params': 'error', 'prefer-spread': 'error', 'prefer-template': 'error', radix: ['error', 'as-needed'], 'require-atomic-updates': 'error', 'require-await': 'off', 'require-unicode-regexp': 'off', 'require-yield': 'error', 'sort-imports': 'off', 'sort-keys': 'off', 'sort-vars': 'off', strict: ['error', 'global'], 'symbol-description': 'error', 'unicode-bom': 'off', 'unicorn/better-regex': 'error', 'unicorn/catch-error-name': 'error', 'unicorn/consistent-destructuring': 'error', 'unicorn/consistent-empty-array-spread': 'error', 'unicorn/consistent-function-scoping': 'error', 'unicorn/custom-error-definition': 'error', 'unicorn/empty-brace-spaces': 'off', 'unicorn/error-message': 'error', 'unicorn/escape-case': 'error', 'unicorn/expiring-todo-comments': 'off', 'unicorn/explicit-length-check': 'off', 'unicorn/filename-case': 'off', 'unicorn/import-style': 'off', 'unicorn/new-for-builtins': 'error', 'unicorn/no-abusive-eslint-disable': 'error', 'unicorn/no-anonymous-default-export': 'error', 'unicorn/no-array-callback-reference': 'off', 'unicorn/no-array-for-each': 'off', 'unicorn/no-array-method-this-argument': 'error', 'unicorn/prefer-single-call': 'error', 'unicorn/no-array-reduce': 'off', 'unicorn/no-await-expression-member': 'error', 'unicorn/no-await-in-promise-methods': 'error', 'unicorn/no-console-spaces': 'error', 'unicorn/no-document-cookie': 'error', 'unicorn/no-empty-file': 'error', 'unicorn/no-for-loop': 'error', 'unicorn/no-hex-escape': 'off', 'unicorn/no-instanceof-builtins': 'error', 'unicorn/no-invalid-fetch-options': 'error', 'unicorn/no-invalid-remove-event-listener': 'error', 'unicorn/no-keyword-prefix': 'error', 'unicorn/no-lonely-if': 'error', 'unicorn/no-magic-array-flat-depth': 'error', 'unicorn/no-negated-condition': 'off', 'unicorn/no-negation-in-equality-check': 'error', 'unicorn/no-nested-ternary': 'off', 'unicorn/no-new-array': 'error', 'unicorn/no-new-buffer': 'error', 'unicorn/no-null': 'off', 'unicorn/no-object-as-default-parameter': 'error', 'unicorn/no-process-exit': 'off', 'unicorn/no-single-promise-in-promise-methods': 'error', 'unicorn/no-static-only-class': 'error', 'unicorn/no-thenable': 'error', 'unicorn/no-this-assignment': 'error', 'unicorn/no-typeof-undefined': 'error', 'unicorn/no-unnecessary-await': 'error', 'unicorn/no-unnecessary-polyfills': 'error', 'unicorn/no-unreadable-array-destructuring': 'off', 'unicorn/no-unreadable-iife': 'error', 'unicorn/no-unused-properties': 'off', 'unicorn/no-useless-fallback-in-spread': 'error', 'unicorn/no-useless-length-check': 'error', 'unicorn/no-useless-promise-resolve-reject': 'error', 'unicorn/no-useless-spread': 'error', 'unicorn/no-useless-switch-case': 'error', 'unicorn/no-useless-undefined': 'error', 'unicorn/no-zero-fractions': 'error', 'unicorn/number-literal-case': 'off', 'unicorn/numeric-separators-style': 'error', 'unicorn/prefer-add-event-listener': 'error', 'unicorn/prefer-array-find': 'error', 'unicorn/prefer-array-flat': 'error', 'unicorn/prefer-array-flat-map': 'error', 'unicorn/prefer-array-index-of': 'error', 'unicorn/prefer-array-some': 'error', 'unicorn/prefer-at': 'error', 'unicorn/prefer-blob-reading-methods': 'error', 'unicorn/prefer-code-point': 'error', 'unicorn/prefer-date-now': 'error', 'unicorn/prefer-default-parameters': 'error', 'unicorn/prefer-dom-node-append': 'error', 'unicorn/prefer-dom-node-dataset': 'error', 'unicorn/prefer-dom-node-remove': 'error', 'unicorn/prefer-dom-node-text-content': 'error', 'unicorn/prefer-event-target': 'error', 'unicorn/prefer-export-from': 'error', 'unicorn/prefer-includes': 'error', 'unicorn/prefer-json-parse-buffer': 'error', 'unicorn/prefer-keyboard-event-key': 'error', 'unicorn/prefer-logical-operator-over-ternary': 'error', 'unicorn/prefer-math-trunc': 'error', 'unicorn/prefer-modern-dom-apis': 'error', 'unicorn/prefer-modern-math-apis': 'error', 'unicorn/prefer-module': 'error', 'unicorn/prefer-native-coercion-functions': 'error', 'unicorn/prefer-negative-index': 'error', 'unicorn/prefer-node-protocol': 'error', 'unicorn/prefer-number-properties': 'error', 'unicorn/prefer-object-from-entries': 'error', 'unicorn/prefer-optional-catch-binding': 'error', 'unicorn/prefer-prototype-methods': 'error', 'unicorn/prefer-query-selector': 'error', 'unicorn/prefer-reflect-apply': 'error', 'unicorn/prefer-regexp-test': 'error', 'unicorn/prefer-set-has': 'error', 'unicorn/prefer-set-size': 'error', 'unicorn/prefer-spread': 'error', 'unicorn/prefer-string-raw': 'error', 'unicorn/prefer-string-replace-all': 'error', 'unicorn/prefer-string-slice': 'error', 'unicorn/prefer-string-starts-ends-with': 'error', 'unicorn/prefer-string-trim-start-end': 'error', 'unicorn/prefer-structured-clone': 'error', 'unicorn/prefer-switch': [ 'error', { emptyDefaultCase: 'no-default-case', }, ], 'unicorn/prefer-ternary': 'error', 'unicorn/prefer-top-level-await': 'error', 'unicorn/prefer-type-error': 'error', 'unicorn/prevent-abbreviations': 'off', 'unicorn/relative-url-style': 'error', 'unicorn/require-array-join-separator': 'error', 'unicorn/require-number-to-fixed-digits-argument': 'error', 'unicorn/require-post-message-target-origin': 'error', 'unicorn/string-content': 'off', 'unicorn/switch-case-braces': 'error', 'unicorn/template-indent': 'off', 'unicorn/text-encoding-identifier-case': 'error', 'unicorn/throw-new-error': 'error', 'unicorn/no-unnecessary-slice-end': 'error', 'use-isnan': 'error', 'valid-typeof': 'error', 'vars-on-top': 'off', yoda: 'error', '@typescript-eslint/no-misused-spread': 'error', '@typescript-eslint/no-unnecessary-type-conversion': 'error', '@typescript-eslint/no-unsafe-type-assertion': 'off', '@typescript-eslint/related-getter-setter-pairs': 'error', 'unicorn/consistent-assert': 'error', 'unicorn/consistent-date-clone': 'error', 'unicorn/consistent-existence-index-check': 'error', 'unicorn/no-accessor-recursion': 'error', 'unicorn/no-named-default': 'error', 'unicorn/no-unnecessary-array-flat-depth': 'error', 'unicorn/no-unnecessary-array-splice-count': 'error', 'unicorn/prefer-global-this': 'error', 'unicorn/prefer-import-meta-properties': 'error', 'unicorn/prefer-math-min-max': 'error', 'import-x/prefer-namespace-import': 'off', 'no-unassigned-vars': 'error', }, };