/* eslint-disable @typescript-eslint/naming-convention */ const TypescriptOffRules = { '@typescript-eslint/adjacent-overload-signatures': 'off', '@typescript-eslint/array-type': 'off', '@typescript-eslint/await-thenable': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/ban-tslint-comment': 'off', '@typescript-eslint/ban-types': 'off', '@typescript-eslint/brace-style': 'off', '@typescript-eslint/class-literal-property-style': 'off', '@typescript-eslint/comma-dangle': 'off', '@typescript-eslint/comma-spacing': 'off', '@typescript-eslint/consistent-indexed-object-style': 'off', '@typescript-eslint/consistent-type-assertions': 'off', '@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/consistent-type-imports': 'off', '@typescript-eslint/default-param-last': 'off', '@typescript-eslint/dot-notation': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-member-accessibility': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/func-call-spacing': 'off', '@typescript-eslint/indent': 'off', '@typescript-eslint/index': 'off', '@typescript-eslint/init-declarations': 'off', '@typescript-eslint/keyword-spacing': 'off', '@typescript-eslint/lines-between-class-members': 'off', '@typescript-eslint/member-delimiter-style': 'off', '@typescript-eslint/member-ordering': 'off', '@typescript-eslint/method-signature-style': 'off', '@typescript-eslint/naming-convention': 'off', '@typescript-eslint/no-array-constructor': 'off', '@typescript-eslint/no-base-to-string': 'off', '@typescript-eslint/no-confusing-non-null-assertion': 'off', '@typescript-eslint/no-confusing-void-expression': 'off', '@typescript-eslint/no-dupe-class-members': 'off', '@typescript-eslint/no-duplicate-imports': 'off', '@typescript-eslint/no-dynamic-delete': 'off', '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-empty-interface': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-extra-non-null-assertion': 'off', '@typescript-eslint/no-extra-parens': 'off', '@typescript-eslint/no-extra-semi': 'off', '@typescript-eslint/no-extraneous-class': 'off', '@typescript-eslint/no-floating-promises': 'off', '@typescript-eslint/no-for-in-array': 'off', '@typescript-eslint/no-implicit-any-catch': 'off', '@typescript-eslint/no-implied-eval': 'off', '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/no-invalid-this': 'off', '@typescript-eslint/no-invalid-void-type': 'off', '@typescript-eslint/no-loop-func': 'off', '@typescript-eslint/no-loss-of-precision': 'off', '@typescript-eslint/no-magic-numbers': 'off', '@typescript-eslint/no-misused-new': 'off', '@typescript-eslint/no-misused-promises': 'off', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-non-null-asserted-optional-chain': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-parameter-properties': 'off', '@typescript-eslint/no-redeclare': 'off', '@typescript-eslint/no-require-imports': 'off', '@typescript-eslint/no-shadow': 'off', '@typescript-eslint/no-this-alias': 'off', '@typescript-eslint/no-throw-literal': 'off', '@typescript-eslint/no-type-alias': 'off', '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', '@typescript-eslint/no-unnecessary-condition': 'off', '@typescript-eslint/no-unnecessary-qualifier': 'off', '@typescript-eslint/no-unnecessary-type-arguments': 'off', '@typescript-eslint/no-unnecessary-type-assertion': 'off', '@typescript-eslint/no-unnecessary-type-constraint': 'off', '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', '@typescript-eslint/no-unused-expressions': 'off', '@typescript-eslint/no-unused-vars-experimental': 'off', '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/no-useless-constructor': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/non-nullable-type-assertion-style': 'off', '@typescript-eslint/object-curly-spacing': 'off', '@typescript-eslint/prefer-as-const': 'off', '@typescript-eslint/prefer-enum-initializers': 'off', '@typescript-eslint/prefer-for-of': 'off', '@typescript-eslint/prefer-function-type': 'off', '@typescript-eslint/prefer-includes': 'off', '@typescript-eslint/prefer-literal-enum-member': 'off', '@typescript-eslint/prefer-namespace-keyword': 'off', '@typescript-eslint/prefer-nullish-coalescing': 'off', '@typescript-eslint/prefer-optional-chain': 'off', '@typescript-eslint/prefer-readonly-parameter-types': 'off', '@typescript-eslint/prefer-readonly': 'off', '@typescript-eslint/prefer-reduce-type-parameter': 'off', '@typescript-eslint/prefer-regexp-exec': 'off', '@typescript-eslint/prefer-return-this-type': 'off', '@typescript-eslint/prefer-string-starts-ends-with': 'off', '@typescript-eslint/prefer-ts-expect-error': 'off', '@typescript-eslint/promise-function-async': 'off', '@typescript-eslint/quotes': 'off', '@typescript-eslint/require-array-sort-compare': 'off', '@typescript-eslint/require-await': 'off', '@typescript-eslint/restrict-plus-operands': 'off', '@typescript-eslint/restrict-template-expressions': 'off', '@typescript-eslint/return-await': 'off', '@typescript-eslint/semi': 'off', '@typescript-eslint/sort-type-union-intersection-members': 'off', '@typescript-eslint/space-before-function-paren': 'off', '@typescript-eslint/space-infix-ops': 'off', '@typescript-eslint/strict-boolean-expressions': 'off', '@typescript-eslint/switch-exhaustiveness-check': 'off', '@typescript-eslint/triple-slash-reference': 'off', '@typescript-eslint/type-annotation-spacing': 'off', '@typescript-eslint/typedef': 'off', '@typescript-eslint/unbound-method': 'off', '@typescript-eslint/unified-signatures': 'off', }; const CommonOverrideRules = { '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-extraneous-class': 'off', '@typescript-eslint/prefer-readonly': 'off', '@typescript-eslint/member-ordering': 'off', '@typescript-eslint/array-type': ['error', { default: 'array' }], '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/dot-notation': [ 'error', { allowPrivateClassPropertyAccess: true, allowProtectedClassPropertyAccess: true, allowIndexSignaturePropertyAccess: true, }, ], '@typescript-eslint/no-this-alias': 'off', 'capitalized-comments': 'off', 'accessor-pairs': 'off', 'no-eq-null': 'off', eqeqeq: ['error', 'always', { null: 'ignore' }], 'no-await-in-loop': 'off', 'no-return-assign': 'off', 'no-sequences': 'off', 'no-unused-vars': 'off', 'operator-linebreak': 'off', 'dot-notation': 'off', 'no-void': 'off', '@typescript-eslint/class-literal-property-style': ['error', 'fields'], '@typescript-eslint/no-throw-literal': 'off', '@typescript-eslint/no-useless-constructor': 'off', '@typescript-eslint/naming-convention': [ 'error', { selector: [ 'variable', 'classProperty', 'accessor', 'objectLiteralProperty', ], format: ['strictCamelCase', 'UPPER_CASE', 'StrictPascalCase'], leadingUnderscore: 'forbid', trailingUnderscore: 'forbid', filter: { regex: '[- ]', match: false, }, }, { selector: [ 'function', 'parameterProperty', 'classMethod', 'objectLiteralMethod', 'typeMethod', ], format: ['strictCamelCase'], leadingUnderscore: 'forbid', trailingUnderscore: 'forbid', filter: { regex: '[- ]', match: false, }, }, { selector: 'typeLike', format: ['StrictPascalCase'], }, { selector: 'variable', types: ['boolean'], format: ['StrictPascalCase'], prefix: ['is', 'has', 'can', 'should', 'will', 'did'], }, { // Interface name should not be prefixed with `I`. selector: 'interface', filter: /^(?!I)[A-Z]/.source, format: ['StrictPascalCase'], }, { // Type parameter name should either be `T` or a descriptive name. selector: 'typeParameter', filter: /^T$|^[A-Z][a-zA-Z]+$/.source, format: ['StrictPascalCase'], }, { // Type name should not be prefixed with `T`. selector: 'typeAlias', filter: /^(?!T)[A-Z]/.source, format: ['StrictPascalCase'], }, // Allow these in non-camel-case when quoted. { selector: ['classProperty', 'objectLiteralProperty'], format: null, modifiers: ['requiresQuotes'], }, ], '@typescript-eslint/ban-types': [ 'error', { extendDefaults: false, types: { Object: { message: 'The `Object` type is mostly the same as `unknown`. You probably want `Record` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848', fixWith: 'Record', }, '{}': { message: 'The `{}` type is mostly the same as `unknown`. You probably want `Record` instead.', fixWith: 'Record', }, object: { message: 'The `object` type is hard to use. Use `Record` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848', fixWith: 'Record', }, }, }, ], '@typescript-eslint/unified-signatures': 'off', 'no-new-wrappers': 'off', 'max-params': 'off', 'no-undef-init': 'off', 'no-labels': 'off', 'no-unused-labels': 'off', 'no-extra-label': 'off', '@typescript-eslint/indent': 'off', 'no-mixed-spaces-and-tabs': 'off', '@typescript-eslint/triple-slash-reference': [ 'error', { path: 'always', types: 'never', lib: 'always' }, ], '@typescript-eslint/no-duplicate-enum-values': 'off', 'new-cap': 'off', '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], 'no-bitwise': 'off', }; module.exports = { overrides: [ { files: ['**/*.svelte'], parser: 'svelte-eslint-parser', parserOptions: { parser: { // Specify a parser for each lang. ts: '@typescript-eslint/parser', js: 'espree', typescript: '@typescript-eslint/parser', }, }, extends: [ 'xo', 'xo-typescript', 'plugin:prettier/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking', 'plugin:svelte/recommended', ], rules: { // TS doesn't do too well in svelte files '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', // for $: lines '@typescript-eslint/no-unused-expressions': 'off', 'no-unused-expressions': 'off', 'no-sequences': 'off', // svelte files n stuff 'no-multiple-empty-lines': 'off', // enable importing from the same file for both module & instance scripts '@typescript-eslint/no-duplicate-imports': 'off', // bugs out when optional chaining is used to call functions '@typescript-eslint/no-confusing-void-expression': 'off', curly: 'off', // bugs out when assigning to stores using $ 'prefer-const': 'off', // no xo '@typescript-eslint/object-curly-spacing': 'off', '@typescript-eslint/quotes': [ 'error', 'single', { avoidEscape: true }, ], 'arrow-parens': ['error', 'always'], 'no-mixed-operators': 'off', ...CommonOverrideRules, }, }, { files: ['**/*.ts'], extends: [ 'xo', 'xo-typescript', 'prettier', 'plugin:prettier/recommended', ], rules: CommonOverrideRules, }, { files: ['**/*.js', '**/*.cjs'], extends: ['xo', 'prettier', 'plugin:prettier/recommended'], rules: { ...TypescriptOffRules, 'arrow-parens': ['error', 'always'], 'new-cap': 'off', ...CommonOverrideRules, }, }, ], parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 'latest', tsconfigRootDir: __dirname, project: ['./tsconfig.json'], extraFileExtensions: ['.svelte'], }, env: { node: false, browser: true, }, plugins: ['@typescript-eslint', 'only-warn'], settings: { svelte: { compileOptions: { postcss: { configFilePath: './postcss.config.js', }, }, }, }, rules: CommonOverrideRules, };