diff --git a/biome.jsonc b/biome.jsonc index 63e8523..c4a1faf 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.3.0/schema.json", + "$schema": "https://biomejs.dev/schemas/2.4.11/schema.json", "files": { "includes": [ "src/**", diff --git a/scripts/extractVsix.mts b/scripts/extractVsix.mts index cc529c0..88269f7 100644 --- a/scripts/extractVsix.mts +++ b/scripts/extractVsix.mts @@ -15,20 +15,20 @@ const dirname = fileURLToPath(new URL('.', import.meta.url)); const vsix = fs .readdirSync(path.join(dirname, '..'), { - withFileTypes: true, + withFileTypes: true }) - .filter((f) => f.name.startsWith('mocha-vscode') && f.name.endsWith('.vsix')); + .filter(f => f.name.startsWith('mocha-vscode') && f.name.endsWith('.vsix')); if (vsix.length > 1) { console.error('Multiple VSIX files found, cannot decide which is the one for testing'); process.exit(1); } -const tempDir = process.env.TEST_TEMP ?? path.join(dirname, '..', 'tmp') +const tempDir = process.env.TEST_TEMP ?? path.join(dirname, '..', 'tmp'); const extensionDir = path.join(tempDir, 'vsix'); await fs.promises.rm(extensionDir, { recursive: true, force: true }); await fs.promises.mkdir(extensionDir, { recursive: true }); await extract(path.join(vsix[0].parentPath, vsix[0].name), { - dir: extensionDir, + dir: extensionDir }); diff --git a/scripts/prerelease.mts b/scripts/prerelease.mts index 99e27bd..99676db 100644 --- a/scripts/prerelease.mts +++ b/scripts/prerelease.mts @@ -14,9 +14,7 @@ import { fileURLToPath } from 'node:url'; console.log('Preparing for extension publish'); -const gitHubContext = process.env.GITHUB_CONTEXT - ? JSON.parse(process.env.GITHUB_CONTEXT) - : undefined; +const gitHubContext = process.env.GITHUB_CONTEXT ? JSON.parse(process.env.GITHUB_CONTEXT) : undefined; const dirname = fileURLToPath(new URL('.', import.meta.url)); @@ -39,7 +37,7 @@ if (gitHubContext) { if (packageJson.version !== tag.slice(1).split('-')[0]) { console.error( - `Git Tag '${tag}' does not match version in package.json '${packageJson.version}', please correct it!`, + `Git Tag '${tag}' does not match version in package.json '${packageJson.version}', please correct it!` ); process.exit(1); } @@ -50,7 +48,7 @@ if (gitHubContext) { packageJson['mocha-vscode'] = { version: semVer, - date: new Date().toISOString(), + date: new Date().toISOString() }; fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2).replaceAll('\r\n', '\n')); diff --git a/scripts/tsnocheck.mts b/scripts/tsnocheck.mts index fb5f335..57cd1b1 100644 --- a/scripts/tsnocheck.mts +++ b/scripts/tsnocheck.mts @@ -5,10 +5,6 @@ import { fileURLToPath } from 'node:url'; const dirname = fileURLToPath(new URL('.', import.meta.url)); const reporter = path.join(dirname, '../out/reporter'); const files = (await fs.promises.readdir(reporter)).filter(f => f.endsWith('.js')).map(f => `${reporter}/${f}`); -for(const f of files) { - await fs.promises.writeFile( - f, - '// @ts-nocheck\n' + - (await fs.promises.readFile(f, 'utf-8')) - ) -} \ No newline at end of file +for (const f of files) { + await fs.promises.writeFile(f, '// @ts-nocheck\n' + (await fs.promises.readFile(f, 'utf-8'))); +} diff --git a/src/reporter/fullJsonStreamReporter.ts b/src/reporter/fullJsonStreamReporter.ts index 519c5a7..b790cc5 100644 --- a/src/reporter/fullJsonStreamReporter.ts +++ b/src/reporter/fullJsonStreamReporter.ts @@ -28,9 +28,7 @@ module.exports = class FullJsonStreamReporter { runner.on(constants.EVENT_SUITE_BEGIN, (suite: Mocha.Suite) => writeEvent([MochaEvent.SuiteStart, { path: suite.titlePath(), file: suite.file }]) ); - runner.on(constants.EVENT_TEST_BEGIN, (test: Mocha.Test) => - writeEvent([MochaEvent.TestStart, clean(test)]) - ); + runner.on(constants.EVENT_TEST_BEGIN, (test: Mocha.Test) => writeEvent([MochaEvent.TestStart, clean(test)])); runner.on(constants.EVENT_TEST_PASS, test => writeEvent([MochaEvent.Pass, clean(test)])); runner.on(constants.EVENT_TEST_FAIL, (test, err) => { writeEvent([ diff --git a/src/runtime/settings.ts b/src/runtime/settings.ts index 049b08a..adff539 100644 --- a/src/runtime/settings.ts +++ b/src/runtime/settings.ts @@ -64,7 +64,9 @@ export class SettingsBasedTestRuntime implements ITestRuntime, Disposable { const pathToYarnEntry = path.resolve(path.dirname(pathToYarn), 'node_modules/corepack/dist/yarn.js'); nodeLaunchArgs = [ // equal to "yarn node" - 'node', pathToYarnEntry, 'node' + 'node', + pathToYarnEntry, + 'node' ]; } } @@ -81,9 +83,9 @@ export class SettingsBasedTestRuntime implements ITestRuntime, Disposable { 'node' ]; break; - case 'custom': - nodeLaunchArgs = this.settings.customRuntime.value; - break; + case 'custom': + nodeLaunchArgs = this.settings.customRuntime.value; + break; } this._runtime = new NodeLikeTestRuntime(this.logChannel, this.configFileUri, this.settings, nodeLaunchArgs); diff --git a/src/test/integration/yarn.test.ts b/src/test/integration/yarn.test.ts index 66f583d..35009e4 100644 --- a/src/test/integration/yarn.test.ts +++ b/src/test/integration/yarn.test.ts @@ -9,12 +9,7 @@ import { expect } from 'chai'; import * as vscode from 'vscode'; -import { - captureTestRun, - expectTestTree, - getController, - integrationTestPrepare -} from '../util'; +import { captureTestRun, expectTestTree, getController, integrationTestPrepare } from '../util'; describe('yarn', () => { integrationTestPrepare('yarn'); @@ -22,9 +17,7 @@ describe('yarn', () => { it('discovers tests', async () => { const c = await getController(); - expectTestTree(c, [ - ['hello.test.js', [['math', [['addition'], ['failing'], ['subtraction']]]]] - ]); + expectTestTree(c, [['hello.test.js', [['math', [['addition'], ['failing'], ['subtraction']]]]]]); }); it('runs tests', async () => { @@ -44,12 +37,11 @@ describe('yarn', () => { run.expectStates({ 'hello.test.js/math/addition': ['enqueued', 'started', 'passed'], 'hello.test.js/math/subtraction': ['enqueued', 'started', 'passed'], - 'hello.test.js/math/failing': ['enqueued', 'started', 'failed'], + 'hello.test.js/math/failing': ['enqueued', 'started', 'failed'] }); }); - - it('debugs tests', async () => { + it('debugs tests', async () => { const c = await getController(); const profiles = c.profiles; expect(profiles).to.have.lengthOf(2); @@ -66,7 +58,7 @@ describe('yarn', () => { run.expectStates({ 'hello.test.js/math/addition': ['enqueued', 'started', 'passed'], 'hello.test.js/math/subtraction': ['enqueued', 'started', 'passed'], - 'hello.test.js/math/failing': ['enqueued', 'started', 'failed'], + 'hello.test.js/math/failing': ['enqueued', 'started', 'failed'] }); }); }); diff --git a/src/test/util.ts b/src/test/util.ts index 7871fe8..25f9d16 100644 --- a/src/test/util.ts +++ b/src/test/util.ts @@ -71,17 +71,19 @@ export function integrationTestPrepare(name: string) { async function restoreWorkspace(workspaceFolder: string, workspaceBackup: string) { const restoredFiles = new Set(); // restore changed files - for(const dirOrFile of await fs.promises.readdir(workspaceBackup, {withFileTypes: true})) { + for (const dirOrFile of await fs.promises.readdir(workspaceBackup, { withFileTypes: true })) { restoredFiles.add(dirOrFile.name); - if(dirOrFile.isDirectory() && dirOrFile.name === 'node_modules') { + if (dirOrFile.isDirectory() && dirOrFile.name === 'node_modules') { continue; } - await fs.promises.cp(path.join(workspaceBackup, dirOrFile.name), path.join(workspaceFolder, dirOrFile.name), { recursive: true }); + await fs.promises.cp(path.join(workspaceBackup, dirOrFile.name), path.join(workspaceFolder, dirOrFile.name), { + recursive: true + }); } // delete new files - for(const dirOrFile of await fs.promises.readdir(workspaceFolder, {withFileTypes: true})) { - if(!restoredFiles.has(dirOrFile.name)) { + for (const dirOrFile of await fs.promises.readdir(workspaceFolder, { withFileTypes: true })) { + if (!restoredFiles.has(dirOrFile.name)) { await rmrf(path.join(workspaceFolder, dirOrFile.name)); } } @@ -196,7 +198,7 @@ function buildTreeExpectation(entry: TestTreeExpectation, c: vscode.TestItemColl export function onceChanged(controller: Controller, timeout = 10000) { return new Promise((resolve, reject) => { - setTimeout(timeout).then(() => reject("Timed out")); + setTimeout(timeout).then(() => reject('Timed out')); const l = controller.onDidChange(() => { l.dispose(); resolve(); diff --git a/src/workspaceWatcher.ts b/src/workspaceWatcher.ts index 7f9733e..6dc3346 100644 --- a/src/workspaceWatcher.ts +++ b/src/workspaceWatcher.ts @@ -35,9 +35,9 @@ export class WorkspaceFolderWatcher { watcher.onDidCreate(uri => { const isMatch = configFilePatterns.some(pattern => minimatch(uri.fsPath.replace(/\\/g, '/'), pattern)); - if(isMatch) { - const isIgnore = minimatch(uri.fsPath.replace(/\\/g, '/'), ignoreConfigFilePattern); - if(!isIgnore) { + if (isMatch) { + const isIgnore = minimatch(uri.fsPath.replace(/\\/g, '/'), ignoreConfigFilePattern); + if (!isIgnore) { this.addConfigFile(uri); return; }