UNPKG

@jimmy.codes/eslint-config

Version:

A simple, modern ESLint config that covers most use cases.

87 lines (86 loc) 3.48 kB
import { GLOB_E2E, GLOB_TESTS, GLOB_TYPE_TESTS } from "./globs.mjs"; import { l as hasTypescript } from "./has-dependency-Bzazc-3p.mjs"; import { n as extractOptions, t as unwrapDefault } from "./interop-default-CAdBatTA.mjs"; //#region src/rules/vitest.ts const vitestRules = async (options) => { const vitestPlugin = await unwrapDefault(import("@vitest/eslint-plugin")); const isUsingTypescript = hasTypescript(); return { ...vitestPlugin.configs.recommended.rules, "vitest/consistent-each-for": ["error", { describe: "each", it: "each", suite: "each", test: "each" }], "vitest/consistent-test-it": ["error", { fn: "test", withinDescribe: "it" }], "vitest/consistent-vitest-vi": "error", "vitest/hoisted-apis-on-top": "error", "vitest/no-alias-methods": "error", "vitest/no-conditional-in-test": "error", "vitest/no-duplicate-hooks": "error", "vitest/no-hooks": "off", "vitest/no-importing-vitest-globals": options?.globals === "implicit" ? "error" : "off", "vitest/no-large-snapshots": "off", "vitest/no-restricted-matchers": "off", "vitest/no-restricted-vi-methods": "off", "vitest/no-test-prefixes": "error", "vitest/no-test-return-statement": "error", "vitest/no-unneeded-async-expect-function": "error", "vitest/padding-around-all": "error", "vitest/prefer-called-once": "error", "vitest/prefer-called-times": "off", "vitest/prefer-called-with": "error", "vitest/prefer-comparison-matcher": "error", "vitest/prefer-describe-function-title": "off", "vitest/prefer-each": "error", "vitest/prefer-equality-matcher": "error", "vitest/prefer-expect-assertions": "off", "vitest/prefer-expect-resolves": "error", "vitest/prefer-expect-type-of": "error", "vitest/prefer-hooks-in-order": "error", "vitest/prefer-hooks-on-top": "error", "vitest/prefer-importing-vitest-globals": options?.globals === "explicit" ? "error" : "off", "vitest/prefer-lowercase-title": "off", "vitest/prefer-mock-promise-shorthand": "error", "vitest/prefer-mock-return-shorthand": "error", "vitest/prefer-snapshot-hint": "error", "vitest/prefer-spy-on": "off", "vitest/prefer-strict-boolean-matchers": "error", "vitest/prefer-strict-equal": "error", "vitest/prefer-to-be": "error", "vitest/prefer-to-contain": "error", "vitest/prefer-to-have-been-called-times": "error", "vitest/prefer-to-have-length": "error", "vitest/prefer-todo": "warn", "vitest/prefer-vi-mocked": "error", "vitest/require-awaited-expect-poll": "error", "vitest/require-hook": "error", "vitest/require-to-throw-message": "error", "vitest/require-top-level-describe": "off", "vitest/unbound-method": isUsingTypescript ? "error" : "off", "vitest/valid-title": ["error", { mustMatch: { it: "^should" } }], "vitest/warn-todo": "warn", ...isUsingTypescript ? { "@typescript-eslint/unbound-method": "off" } : {}, ...options?.overrides }; }; //#endregion //#region src/configs/vitest.ts async function vitestConfig(options) { const vitestPlugin = await unwrapDefault(import("@vitest/eslint-plugin")); const extractedOptions = extractOptions(options); return [{ files: [...GLOB_TESTS, ...extractedOptions?.typecheck ? GLOB_TYPE_TESTS : []], ignores: GLOB_E2E, ...vitestPlugin.configs.recommended, name: "jimmy.codes/vitest", rules: await vitestRules(extractedOptions), settings: { vitest: { typecheck: extractedOptions?.typecheck ?? false } } }]; } //#endregion export { vitestConfig as default };