@abelspithost/vitest-config 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
 
2
2
  # @abelspithost/vitest-config
3
3
 
4
- [![Quality gate status](https://sonarcloud.io/api/project_badges/measure?project=aspithost_vitest-config&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aspithost_vitest-config)
5
4
  ![NPM Version](https://img.shields.io/npm/v/@abelspithost/vitest-config)
5
+ ![Build](https://img.shields.io/github/actions/workflow/status/aspithost/vitest-config/cicd.yml)
6
+ [![Quality gate status](https://sonarcloud.io/api/project_badges/measure?project=aspithost_vitest-config&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aspithost_vitest-config)
7
+ [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=aspithost_vitest-config&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=aspithost_vitest-config)
8
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=aspithost_vitest-config&metric=coverage)](https://sonarcloud.io/summary/new_code?id=aspithost_vitest-config)
6
9
 
7
10
  This package provides a shared Vitest configuration for TypeScript projects.
8
11
  The `createVitestConfig` function returns a Node-oriented Vitest configuration
@@ -11,7 +14,7 @@ aliases.
11
14
 
12
15
  ## Requirements
13
16
 
14
- - Node.js 24 or newer
17
+ - Node.js 26 or newer
15
18
  - Vitest 5.0.0 or newer
16
19
 
17
20
  ## Installation
@@ -35,6 +38,22 @@ export default createVitestConfig();
35
38
  The configuration resolves the `@` alias to your project's `src` directory.
36
39
  For example, `@/utils/format` resolves to `src/utils/format`.
37
40
 
41
+ Pass a Vitest configuration object to customize the defaults:
42
+
43
+ ```ts
44
+ export default createVitestConfig({
45
+ test: {
46
+ pool: 'forks',
47
+ globals: false,
48
+ },
49
+ });
50
+ ```
51
+
52
+ The function merges your options with the preset using Vite's `mergeConfig`.
53
+ Nested objects merge, consumer values override scalar defaults, and arrays
54
+ concatenate. For example, a custom `test.include` pattern adds to the default
55
+ `**/*.spec.ts` pattern rather than replacing it.
56
+
38
57
  ## Defaults
39
58
 
40
59
  `createVitestConfig` applies these settings:
@@ -47,7 +66,7 @@ For example, `@/utils/format` resolves to `src/utils/format`.
47
66
  | Globals | Enabled |
48
67
  | Pool | `threads` |
49
68
  | Mock clearing | Enabled |
50
- | Coverage reporters | `json-summary`, `json` |
69
+ | Coverage reporters | `json-summary`, `json`, `lcov` |
51
70
  | Coverage on failure | Enabled |
52
71
  | Coverage exclusion | `**/constants/**` |
53
72
  | Branch threshold | 90% |
package/dist/index.d.ts CHANGED
@@ -1,2 +1,11 @@
1
- export declare function createVitestConfig(): import("vite").UserConfig;
1
+ import { type ViteUserConfig } from 'vitest/config';
2
+ /**
3
+ * Creates a Vitest configuration with shared test and coverage defaults.
4
+ *
5
+ * @param overrides - Vitest options to merge with the preset defaults
6
+ * @returns A configuration that resolves `@` to the project's `src` directory
7
+ * and sets the test environment, discovery patterns, mock handling, and
8
+ * coverage thresholds.
9
+ */
10
+ export declare function createVitestConfig(overrides?: ViteUserConfig): ViteUserConfig;
2
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,8BAmCjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,GAAE,cAAmB,GAAG,cAAc,CAqCjF"}
package/dist/index.js CHANGED
@@ -1,7 +1,15 @@
1
1
  import { join } from 'node:path';
2
- import { defineConfig } from 'vitest/config';
3
- export function createVitestConfig() {
4
- return defineConfig({
2
+ import { defineConfig, mergeConfig, } from 'vitest/config';
3
+ /**
4
+ * Creates a Vitest configuration with shared test and coverage defaults.
5
+ *
6
+ * @param overrides - Vitest options to merge with the preset defaults
7
+ * @returns A configuration that resolves `@` to the project's `src` directory
8
+ * and sets the test environment, discovery patterns, mock handling, and
9
+ * coverage thresholds.
10
+ */
11
+ export function createVitestConfig(overrides = {}) {
12
+ const defaultConfig = defineConfig({
5
13
  resolve: {
6
14
  alias: {
7
15
  '@': join(process.cwd(), './src'),
@@ -30,5 +38,6 @@ export function createVitestConfig() {
30
38
  pool: 'threads',
31
39
  },
32
40
  });
41
+ return mergeConfig(defaultConfig, overrides);
33
42
  }
34
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,UAAU,kBAAkB;IAChC,OAAO,YAAY,CAAC;QAClB,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;aAClC;SACF;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,IAAI;YAEhB,QAAQ,EAAE;gBACR,QAAQ,EAAE;oBACR,cAAc;oBACd,MAAM;oBACN,MAAM;iBACP;gBACD,eAAe,EAAE,IAAI;gBACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC;gBAC5B,UAAU,EAAE;oBACV,QAAQ,EAAE,EAAE;oBACZ,SAAS,EAAE,EAAE;oBACb,KAAK,EAAE,EAAE;iBACV;aACF;YAED,WAAW,EAAE,MAAM;YAEnB,OAAO,EAAE,CAAC,cAAc,CAAC;YACzB,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC;YAEjC,OAAO,EAAE,IAAI;YAEb,IAAI,EAAE,SAAS;SAChB;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACgB,YAAY,EAAE,WAAW,GAC/C,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAA4B,EAAE;IAC/D,MAAM,aAAa,GAAG,YAAY,CAAC;QACjC,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;aAClC;SACF;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,IAAI;YAEhB,QAAQ,EAAE;gBACR,QAAQ,EAAE;oBACR,cAAc;oBACd,MAAM;oBACN,MAAM;iBACP;gBACD,eAAe,EAAE,IAAI;gBACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC;gBAC5B,UAAU,EAAE;oBACV,QAAQ,EAAE,EAAE;oBACZ,SAAS,EAAE,EAAE;oBACb,KAAK,EAAE,EAAE;iBACV;aACF;YAED,WAAW,EAAE,MAAM;YAEnB,OAAO,EAAE,CAAC,cAAc,CAAC;YACzB,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC;YAEjC,OAAO,EAAE,IAAI;YAEb,IAAI,EAAE,SAAS;SAChB;KACF,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelspithost/vitest-config",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Shared Vitest configuration preset for TypeScript projects",
5
5
  "keywords": [
6
6
  "vitest",
@@ -29,34 +29,41 @@
29
29
  "dist"
30
30
  ],
31
31
  "engines": {
32
- "node": ">=24"
32
+ "node": ">=26"
33
33
  },
34
34
  "scripts": {
35
- "build": "npm run clean && tsc -p tsconfig.build.json && npm run deps:check",
35
+ "build": "npm run clean && tsc -p tsconfig.spec.json && tsc -p tsconfig.build.json && npm run deps:check",
36
36
  "clean": "rimraf dist",
37
37
  "deps:check": "npx -y npm-check-updates --cooldown 2",
38
38
  "deps:update": "npx -y npm-check-updates -u --target minor --cooldown 2 && npm install",
39
39
  "deps:update:major": "npx -y npm-check-updates -u --cooldown 2 && npm install",
40
40
  "lint": "eslint . && npm run publint",
41
+ "prepare": "husky || true",
41
42
  "publint": "npx -y publint",
42
- "typecheck": "tsc -p tsconfig.build.json --noEmit",
43
- "prepare": "husky || true"
43
+ "release": "npx tsx release.config.ts",
44
+ "release:dry-run": "npx -p @abelspithost/conventional-commits-changelog release --dry-run",
45
+ "test:unit": "vitest",
46
+ "test:cov": "vitest run --coverage --coverage.reporter=text",
47
+ "test:cov:ci": "vitest run --coverage",
48
+ "typecheck": "tsc -p tsconfig.build.json --noEmit && tsc -p tsconfig.spec.json"
44
49
  },
45
50
  "peerDependencies": {
46
51
  "vitest": ">=5.0.0"
47
52
  },
48
53
  "devDependencies": {
49
- "@abelspithost/commitlint": "^0.1.9",
50
- "@abelspithost/eslint-config-ts": "^3.0.0",
51
- "@abelspithost/tsconfig-node": "^0.1.1",
52
- "@commitlint/cli": "^21.2.3",
53
- "@types/node": "^24.19.1",
54
- "commitlint": "^21.2.3",
55
- "eslint": "^10.12.0",
54
+ "@abelspithost/commitlint": "^0.2.3",
55
+ "@abelspithost/conventional-commits-changelog": "^0.0.3",
56
+ "@abelspithost/eslint-config-ts": "^3.2.2",
57
+ "@abelspithost/tsconfig-node": "^0.1.2",
58
+ "@commitlint/cli": "^21.2.4",
59
+ "@types/node": "^26.6.6",
60
+ "@vitest/coverage-v8": "^5.1.0",
61
+ "commitlint": "^21.2.4",
62
+ "eslint": "^10.14.0",
56
63
  "husky": "^9.1.7",
57
64
  "jiti": "^2.7.0",
58
- "rimraf": "^6.1.3",
65
+ "rimraf": "^6.1.4",
59
66
  "typescript": "^6.0.3",
60
- "vitest": "^5.0.3"
67
+ "vitest": "^5.1.0"
61
68
  }
62
69
  }