Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ The oxlint configuration containing hapi style guide rules and config. To use in
[`@hapi/oxc-plugin`](https://github.com/hapijs/oxc-plugin) to your `package.json`, then in your `oxlint.config.ts` add:

```ts
import { defineConfig } from 'oxlint';
import DefaultOxlintConfig from '@hapi/oxc-plugin/oxlint';
import { defineConfig } from 'oxlint';

export default defineConfig({
extends: [DefaultOxlintConfig],
Expand All @@ -23,8 +23,8 @@ The [oxfmt](https://oxc.rs/docs/guide/usage/formatter/oxfmt.html) configuration
[`@hapi/oxc-plugin`](https://github.com/hapijs/oxc-plugin) to your `package.json`, then in your `oxfmt.config.ts` add:

```ts
import { defineConfig } from 'oxfmt';
import DefaultOxfmtConfig from '@hapi/oxc-plugin/oxfmt';
import { defineConfig } from 'oxfmt';

export default defineConfig({
...DefaultOxfmtConfig,
Expand Down Expand Up @@ -94,8 +94,8 @@ To use it, add [`@hapi/oxc-plugin`](https://github.com/hapijs/oxc-plugin) to you
in your `vitest.config.js` add:

```js
import { defineConfig } from 'vitest/config';
import oxc from '@hapi/oxc-plugin/vitest';
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [oxc()],
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@
"lint:fix": "oxlint --fix && oxfmt --write"
},
"dependencies": {
"@oxlint/plugins": "^1.76.0"
"@oxlint/plugins": "^1.90.0"
},
"devDependencies": {
"@hapi/oxc-plugin": "file:.",
"@vitest/coverage-v8": "^4.1.10",
"oxfmt": "^0.61.0",
"oxlint": "^1.76.0",
"vitest": "^4.1.10"
"@vitest/coverage-v8": "^5.0.5",
"oxfmt": "^0.75.0",
"oxlint": "^1.90.0",
"vitest": "^5.0.5"
},
"peerDependencies": {
"oxfmt": ">=0.61.0",
Expand Down
5 changes: 4 additions & 1 deletion src/vitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function (options = {}) {

return {
name: '@hapi/oxc-plugin:vitest',
async configureVitest({ injectTestProjects }) {
async configureVitest({ project, injectTestProjects }) {
await injectTestProjects({
// Vitest 5 makes inline projects extend the declaring config by default, which
// would run the host's own tests a 2nd time under this project.
Expand All @@ -19,6 +19,9 @@ export default function (options = {}) {
name: '@hapi/oxc-plugin',
include: [Path.join(import.meta.dirname, 'vitest.test.js')],
exclude: [],
// Without extending, our maxWorkers default ignores `vitest run` and follows the TTY,
// vitest 5 then refuses to group it with the host project.
maxWorkers: project.config.maxWorkers,
},
});
},
Expand Down
2 changes: 2 additions & 0 deletions test/vitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const internals = {};
internals.inject = async function (plugin) {
const injected = [];
const context = {
project: { config: { maxWorkers: 3 } },
injectTestProjects(config) {
injected.push(config);
return Promise.resolve([]);
Expand All @@ -34,6 +35,7 @@ describe('vitest plugin', () => {
expect(injected).toHaveLength(1);
expect(injected[0].extends).toBe(false);
expect(injected[0].test.name).toBe('@hapi/oxc-plugin');
expect(injected[0].test.maxWorkers).toBe(3);
expect(injected[0].test.include).toHaveLength(1);
expect(injected[0].test.include[0]).toMatch(/vitest\.test\.js$/);
expect(injected[0].define.__HAPI_OXC_OXLINT__).toBe(true);
Expand Down
9 changes: 8 additions & 1 deletion vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ export default defineConfig({
},
reportsDirectory: './coverage',
reporter: ['text', 'lcov'],
exclude: ['test/**', 'dist/**', '**/*.d.ts'],

exclude: [
'test/**',
'dist/**',
'**/*.d.ts',
// Vitest 5 no longer drops the test file injected by our own plugin from coverage.
'src/vitest.test.js',
],
},
},
});
Loading