From fe5d0001ab3d351e1202aa602a38bffd60b01618 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Wed, 29 Jul 2026 23:29:59 +0800 Subject: [PATCH] test: pin Oxlint compatibility rules --- scripts/oxlint-contract.spec.ts | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/scripts/oxlint-contract.spec.ts b/scripts/oxlint-contract.spec.ts index 482b573492..0d3d1ca425 100644 --- a/scripts/oxlint-contract.spec.ts +++ b/scripts/oxlint-contract.spec.ts @@ -94,6 +94,53 @@ probePromise() } }, 20_000) + it('runs JavaScript compatibility and nursery rules', async () => { + const suffix = randomUUID() + const configPath = await writeContractConfig(suffix) + const path = join(repositoryRoot, 'scripts', `oxlint-contract-${suffix}.ts`) + const source = `export function firstProbe(): number { + const first = 1 + const second = 2 + return first + second +} + +export function secondProbe(): number { + const first = 1 + const second = 2 + return first + second +} + +export function hasValue(value: string): boolean { + return value !== undefined +} + +export const longProbe = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 +` + + try { + await writeFile(path, source) + const result = runOxlint([ + '--config', + relative(repositoryRoot, configPath), + '--format', + 'unix', + relative(repositoryRoot, path), + ]) + const output = normalizedOutput(result) + + expect(result.error).toBeUndefined() + expect(result.status, output).toBe(1) + expect(output).toContain('@stylistic(max-len)') + expect(output).toContain('sonarjs(no-identical-functions)') + expect(output).toContain('typescript(no-unnecessary-condition)') + } finally { + await Promise.all([ + rm(path, { force: true }), + rm(configPath, { force: true }), + ]) + } + }, 20_000) + it('applies staged stylistic fixes before Oxlint validation', async () => { const suffix = randomUUID() const configPath = await writeContractConfig(suffix)