Files
ThreadNet-Web/vitest.config.ts
T
Michael TelatynskiandGitHub bbec915fb0 Enable more oxlint rules (#34189)
* Fix type imports

* Fix jsdoc

* Fixup types

* Fix stray awaits on non-thenables

* Fixup imports

* Fix splats

* Fix this-context on callbacks

* Memoise react contexts

* Prefer find/flatMap

* Make oxlint happier about our React keys

* Avoid unsafe default function params

* Fixup jsdoc

* Fixup contexts

* Switch from eslint to oxlint

* Some oxlint-related tweaks

* Iterate

* Partial revert to defer some changes and shrink diff

* Iterate

* Add eslint-plugin-element-call and enable the copyright rule

* Set strictStorePkgContentCheck

* Iterate

* Enable forwardRef oxlint rule

* Enable no-unused-vars oxlint rule

* Enable no-implied-eval oxlint rule

* Enable no-duplicate-type-constituents oxlint rule

* Enable explicit-length-check oxlint rule

* Enable prefer-number-properties oxlint rule

* Enable no-callback-in-promise oxlint rule

* Enable no-require-imports oxlint rule

* Remove disablement of most unicorn oxlint rules

* Enable no-conditional-tests oxlint rule

* Enable promise-valid-params oxlint rule

* Enable require-unicode-regexp oxlint rule

* Remove max-len comments as we use oxfmt for formatting

* Enable majority of oxlint `suspicious` rules

* Iterate

* Fix oxlint type-aware lint running without dependencies built
2026-07-29 08:26:07 +00:00

73 lines
2.5 KiB
TypeScript

/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { defineConfig, type ViteUserConfig } from "vitest/config";
import { type Reporter } from "vitest/node";
import { env } from "node:process";
const reporters: NonNullable<ViteUserConfig["test"]>["reporters"] = [["default"]];
const slowTestReporter: Reporter = {
onTestRunEnd(testModules, unhandledErrors, reason) {
const tests = testModules
.flatMap((m) => Array.from(m.children.allTests()))
.filter((test) => test.diagnostic()?.slow);
tests.sort((x, y) => x.diagnostic()!.duration - y.diagnostic()!.duration);
tests.reverse();
if (tests.length > 0) {
console.warn("Slowest 10 tests:");
}
for (const t of tests.slice(0, 10)) {
console.warn(`${t.module.moduleId} > ${t.fullName}: ${t.diagnostic()?.duration.toFixed(0)}ms`);
}
},
};
// if we're running under GHA, enable the GHA & Sonar reporters
if (env["GITHUB_ACTIONS"] !== undefined) {
reporters.push(["github-actions", { silent: false }]);
// if we're running against the develop branch, also enable the slow test reporter
if (env["GITHUB_REF"] == "refs/heads/develop") {
reporters.push(slowTestReporter);
}
}
export default defineConfig({
oxc: {
// Configure the ts loader to handle all the files we may throw at it
include: /\.[cm]?tsx?$/,
},
test: {
projects: [
"{apps,modules,packages}/*/vitest.config.ts",
// We run shared-components separately for now as vitest lacks support for nested projects
// https://github.com/vitest-dev/vitest/issues/8544
"!packages/shared-components",
],
coverage: {
provider: "v8",
include: ["{apps,modules,packages}/*/src/**/*.{cts,ts,tsx}"],
exclude: [
// Exclude test files
"**/*.{stories,test}.{ts,tsx}",
// Exclude test utilities
"**/src/test/**",
// Exclude mocks
"**/src/**/*-{mock,mocks}.{ts,tsx}",
// Exclude type definition files
"**/*.d.ts",
// Exclude playwright-common as it is just test utilities
"packages/playwright-common/**",
],
reporter: [["lcov"]],
},
reporters,
},
});