// only add vitest rules
// see: https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#rules

export default {
  // Prevent focused tests (.only)
  // https://github.com/levibuzolic/eslint-plugin-no-only-tests#usage
  'no-only-tests/no-only-tests': 'error',

  // Require .test test file pattern
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
  'vitest/consistent-test-filename': 'error',

  // Enforce consistent usage of each with for...of
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-each-for.md
  'vitest/consistent-each-for': 'error',

  // Prefer test or it but not both
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
  'vitest/consistent-test-it': 'error',

  // Enforce consistent usage of vi vs vitest
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-vitest-vi.md
  'vitest/consistent-vitest-vi': 'error',

  // Enforce having expectation in test body
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
  'vitest/expect-expect': 'error',

  // Ensure hoisted APIs (vi.mock, vi.hoisted, etc.) are at the top
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/hoisted-apis-on-top.md
  'vitest/hoisted-apis-on-top': 'error',

  // Enforce a maximum number of expect per test
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
  'vitest/max-expects': [
    'error',
    {
      max: 15,
    },
  ],

  // Nested describe block should be less than set max value or default value
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
  'vitest/max-nested-describe': 'error',

  // Disallow alias methods
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
  'vitest/no-alias-methods': 'error',

  // Disallow commented out tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
  'vitest/no-commented-out-tests': 'error',

  // Disallow conditional expects
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
  'vitest/no-conditional-expect': 'error',

  // Disallow conditional tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
  'vitest/no-conditional-in-test': 'error',

  // Disallow conditional tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md
  'vitest/no-conditional-tests': 'error',

  // Disallow disabled tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
  // decision: it is often useful to be allowed to add a .skip
  'vitest/no-disabled-tests': 'off',

  // Disallow using a callback in asynchronous tests and hooks
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
  // decision: this rule is deprecated.
  // 'vitest/no-done-callback': 'error',

  // Disallow duplicate hooks and teardown hooks
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
  'vitest/no-duplicate-hooks': 'error',

  // Disallow focused tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
  'vitest/no-focused-tests': 'error',

  // Disallow setup and teardown hooks
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
  'vitest/no-hooks': 'off',

  // Disallow identical titles
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
  'vitest/no-identical-title': 'error',

  // Disallow importing node:test
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
  'vitest/no-import-node-test': 'error',

  // Disallow importing vitest globals when using globals: true
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-importing-vitest-globals.md
  // decision: we enable `vitest/prefer-importing-vitest-globals` and this is it's opposite rule
  'vitest/no-importing-vitest-globals': 'off',

  // Disallow string interpolation in snapshots
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
  'vitest/no-interpolation-in-snapshots': 'error',

  // Disallow large snapshots
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
  'vitest/no-large-snapshots': ['error', { maxSize: 500 }],

  // Disallow importing from mocks directory
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
  'vitest/no-mocks-import': 'error',

  // Disallow the use of certain matchers
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
  'vitest/no-restricted-matchers': 'error',

  // Disallow specific vi. methods
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md
  'vitest/no-restricted-vi-methods': 'error',

  // Disallow using expect outside of it or test blocks
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
  'vitest/no-standalone-expect': 'error',

  // Disallow using test as a prefix
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
  'vitest/no-test-prefixes': 'error',

  // Disallow return statements in tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
  'vitest/no-test-return-statement': 'error',

  // Disallow unnecessary async in expect functions
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md
  'vitest/no-unneeded-async-expect-function': 'error',

  // This rule enforces a line of padding before and after 1 or more `afterAll` statements.
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-all-blocks.md
  'vitest/padding-around-after-all-blocks': 'error',

  // This rule enforces a line of padding before and after 1 or more `afterEach` statements.
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-each-blocks.md
  'vitest/padding-around-after-each-blocks': 'error',

  // This rule enforces a line of padding before and after `beforeAll` statements.
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-before-all-blocks.md
  'vitest/padding-around-before-all-blocks': 'error',

  // This rule enforces a line of padding before and after 1 or more `beforeEach` statements
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-before-each-blocks.md
  'vitest/padding-around-before-each-blocks': 'error',

  // This rule enforces a line of padding before and after 1 or more `expect` statements
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-expect-groups.md
  'vitest/padding-around-expect-groups': 'error',

  // This rule enforces a line of padding before and after 1 or more `describe` statements
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-describe-blocks.md
  'vitest/padding-around-describe-blocks': 'error',

  // This rule enforces a line of padding before and after 1 or more `test`/`it` statements
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-test-blocks.md
  'vitest/padding-around-test-blocks': 'error',

  // This is a meta rule that simply enables all of the previous rules
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-all.md
  'vitest/padding-around-all': 'off',

  // Prefer toHaveBeenCalledExactlyOnceWith over separate assertions
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-exactly-once-with.md
  'vitest/prefer-called-exactly-once-with': 'error',

  // Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-once.md
  // decision: this conflicts with `prefer-called-times` rule, which is enabled
  'vitest/prefer-called-once': 'off',

  // Prefer toHaveBeenCalledTimes over multiple assertions
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-times.md
  'vitest/prefer-called-times': 'error',

  // Suggest using toBeCalledWith() or toHaveBeenCalledWith()
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
  'vitest/prefer-called-with': 'error',

  // Suggest using the built-in comparison matchers
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
  'vitest/prefer-comparison-matcher': 'error',

  // Enforce describe titles to match function names
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-describe-function-title.md
  'vitest/prefer-describe-function-title': 'error',

  // Prefer each rather than manual loops
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
  'vitest/prefer-each': 'error',

  // Suggest using the built-in quality matchers
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
  'vitest/prefer-equality-matcher': 'error',

  // Suggest using expect assertions instead of callbacks
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
  'vitest/prefer-expect-assertions': 'off',

  // Suggest using expect().resolves over expect(await ...) syntax
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
  'vitest/prefer-expect-resolves': 'error',

  // Prefer expect.typeOf() usage
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-type-of.md
  'vitest/prefer-expect-type-of': 'error',

  // Prefer having hooks in consistent order
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
  'vitest/prefer-hooks-in-order': 'error',

  // Suggest having hooks before any test cases
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
  'vitest/prefer-hooks-on-top': 'error',

  // Prefer vi.importActual/vi.importMock in vi.mock factories
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-import-in-mock.md
  // decision: potentially helpful but causes too many type errors
  'vitest/prefer-import-in-mock': 'off',

  // Prefer importing vitest globals instead of using them implicitly
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-importing-vitest-globals.md
  'vitest/prefer-importing-vitest-globals': 'error',

  // Enforce lowercase titles
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
  'vitest/prefer-lowercase-title': 'off',

  // Prefer mock resolved/rejected shorthands for promises
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
  'vitest/prefer-mock-promise-shorthand': 'error',

  // Prefer mock return shorthands
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-return-shorthand.md
  'vitest/prefer-mock-return-shorthand': 'error',

  // Prefer including a hint with external snapshots
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
  'vitest/prefer-snapshot-hint': 'error',

  // Suggest using vi.spyOn
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
  'vitest/prefer-spy-on': 'error',

  // Prefer strict boolean matchers (toBe(true) over toBeTruthy())
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-boolean-matchers.md
  'vitest/prefer-strict-boolean-matchers': 'error',

  // Prefer strict equal over equal
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
  'vitest/prefer-strict-equal': 'error',

  // Suggest using toBe()
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
  'vitest/prefer-to-be': 'error',

  // Suggest using toBeFalsy()
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md
  // decision: not necessary to br prescriptive here
  'vitest/prefer-to-be-falsy': 'off',

  // Prefer toBeObject()
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md
  'vitest/prefer-to-be-object': 'error',

  // Suggest using toBeTruthy
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md
  // decision: not necessary to br prescriptive here
  'vitest/prefer-to-be-truthy': 'off',

  // Prefer using toContain()
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
  'vitest/prefer-to-contain': 'error',

  // Suggest using toHaveLength()
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
  'vitest/prefer-to-have-length': 'error',

  // Suggest using test.todo
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
  'vitest/prefer-todo': 'error',

  // Require setup and teardown to be within a hook
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
  'vitest/require-hook': 'error',

  // Require local Test Context for concurrent snapshot tests
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
  'vitest/require-local-test-context-for-concurrent-snapshots': 'error',

  // Require toThrow() to be called with an error message
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
  'vitest/require-to-throw-message': 'error',

  // Enforce that all tests are in a top-level describe
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
  'vitest/require-top-level-describe': 'error',

  // Enforce valid describe callback
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
  'vitest/valid-describe-callback': 'error',

  // Enforce valid expect() usage
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
  'vitest/valid-expect': 'error',

  // Enforce valid titles
  // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
  // decision: `allowArguments` avoids conflict with `prefer-describe-function-title` rule, which is enabled
  'vitest/valid-title': ['error', { allowArguments: true }],
};
