|
| 1 | +import vitest from "@vitest/eslint-plugin"; |
| 2 | +import withNuxt from "./.nuxt/eslint.config.mjs"; |
| 3 | +export default withNuxt( |
| 4 | + { |
| 5 | + ignores: [ |
| 6 | + "**/generated/**", // ignore linting autogenerated files |
| 7 | + ], |
| 8 | + }, |
| 9 | + { |
| 10 | + // Disallow <script lang="js"> in Vue files |
| 11 | + files: ["**/*.vue"], |
| 12 | + rules: { |
| 13 | + "vue/block-lang": [ |
| 14 | + "error", |
| 15 | + { |
| 16 | + script: { |
| 17 | + lang: "ts", |
| 18 | + }, |
| 19 | + }, |
| 20 | + ], |
| 21 | + }, |
| 22 | + }, |
| 23 | + { |
| 24 | + // Disallow .js files in favor of typescript |
| 25 | + files: ["**/*.js"], |
| 26 | + rules: { |
| 27 | + "no-restricted-syntax": [ |
| 28 | + "error", |
| 29 | + { |
| 30 | + selector: "Program", |
| 31 | + message: "Use .ts instead of .js.", |
| 32 | + }, |
| 33 | + ], |
| 34 | + }, |
| 35 | + }, |
| 36 | + { |
| 37 | + files: ["**/*.{test,spec}.ts"], |
| 38 | + plugins: { |
| 39 | + vitest, |
| 40 | + }, |
| 41 | + rules: { |
| 42 | + ...vitest.configs.all.rules, |
| 43 | + "vitest/unbound-method": "off", // requires typed linting (parserOptions.project), not configured in this project |
| 44 | + "vitest/require-mock-type-parameters": "off", // stylistic; vi.fn() inferred type is sufficient and explicit generics add noise on trivial mocks |
| 45 | + "vitest/prefer-describe-function-title": "off", // autofix rewrites string titles to identifier references, which then conflicts with vitest/valid-title for default-imported functions |
| 46 | + "vitest/padding-around-all": "off", // project test style keeps blank lines minimal (see AGENTS.md); these rules pad every block boundary |
| 47 | + "vitest/padding-around-after-all-blocks": "off", |
| 48 | + "vitest/padding-around-after-each-blocks": "off", |
| 49 | + "vitest/padding-around-before-all-blocks": "off", |
| 50 | + "vitest/padding-around-before-each-blocks": "off", |
| 51 | + "vitest/padding-around-describe-blocks": "off", |
| 52 | + "vitest/padding-around-expect-groups": "off", |
| 53 | + "vitest/padding-around-test-blocks": "off", |
| 54 | + "vitest/no-focused-tests": ["error", { fixable: false }], // automatically fixing this could confuse the user |
| 55 | + "vitest/consistent-test-filename": ["error", { pattern: ".*\\.spec\\.ts$" }], |
| 56 | + "vitest/prefer-lowercase-title": "off", // no reason to force lowercase titles |
| 57 | + "vitest/consistent-test-it": "off", // consistency for this is overrated, let the dev choose what's most readable based on the test title |
| 58 | + "vitest/prefer-to-be-falsy": "off", // sometimes you want to check explicitly for false and not just falsy |
| 59 | + "vitest/prefer-to-be-truthy": "off", // sometimes you want to check explicitly for true and not just truthy |
| 60 | + }, |
| 61 | + }, |
| 62 | + { |
| 63 | + files: ["tests/e2e/**/*.spec.ts"], |
| 64 | + rules: { |
| 65 | + "vitest/prefer-expect-assertions": "off", // E2E tests use Playwright's expect (for web-first auto-retrying matchers like toBeVisible), which vitest's `expect.assertions()` counter cannot track. |
| 66 | + "vitest/prefer-importing-vitest-globals": "off", // E2E tests import `expect` from Playwright, not vitest; autofix would shadow the Playwright import |
| 67 | + }, |
| 68 | + }, |
| 69 | +); |
0 commit comments