From ccd284ab9fe424060ebba16d84ef8da9418f06af Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 24 Oct 2025 10:17:00 +0800 Subject: [PATCH 1/2] test: add test for type-aware linting --- .../snap-tests/oxlint-typeaware/package.json | 1 + .../cli/snap-tests/oxlint-typeaware/snap.txt | 23 +++++++++++++++++++ .../snap-tests/oxlint-typeaware/src/index.ts | 3 +++ .../snap-tests/oxlint-typeaware/steps.json | 14 +++++++++++ .../cli/snap-tests/oxlint-typeaware/types.ts | 1 + 5 files changed, 42 insertions(+) create mode 100644 packages/cli/snap-tests/oxlint-typeaware/package.json create mode 100644 packages/cli/snap-tests/oxlint-typeaware/snap.txt create mode 100644 packages/cli/snap-tests/oxlint-typeaware/src/index.ts create mode 100644 packages/cli/snap-tests/oxlint-typeaware/steps.json create mode 100644 packages/cli/snap-tests/oxlint-typeaware/types.ts diff --git a/packages/cli/snap-tests/oxlint-typeaware/package.json b/packages/cli/snap-tests/oxlint-typeaware/package.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/cli/snap-tests/oxlint-typeaware/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/cli/snap-tests/oxlint-typeaware/snap.txt b/packages/cli/snap-tests/oxlint-typeaware/snap.txt new file mode 100644 index 0000000000..dfc03f0dd1 --- /dev/null +++ b/packages/cli/snap-tests/oxlint-typeaware/snap.txt @@ -0,0 +1,23 @@ +> vite lint ./src +Found 0 warnings and 0 errors. +Finished in ms on 1 file with rules using threads. + + +> echo //comment >> types.ts +> vite lint ./src # non-type-aware linting doesn't read types.ts +✓ cache hit, replaying +Found 0 warnings and 0 errors. +Finished in ms on 1 file with rules using threads. + + +> vite lint --type-aware ./src +Found 0 warnings and 0 errors. +Finished in ms on 1 file with rules using threads. + + +> echo //comment >> types.ts +> vite lint --type-aware ./src # type-aware linting reads types.ts +✗ cache miss: content of input 'types.ts' changed, executing +Found 0 warnings and 0 errors. +Finished in ms on 1 file with rules using threads. + diff --git a/packages/cli/snap-tests/oxlint-typeaware/src/index.ts b/packages/cli/snap-tests/oxlint-typeaware/src/index.ts new file mode 100644 index 0000000000..10c5e7e0aa --- /dev/null +++ b/packages/cli/snap-tests/oxlint-typeaware/src/index.ts @@ -0,0 +1,3 @@ +import type { Foo } from '../types'; + +declare const _foo: Foo; diff --git a/packages/cli/snap-tests/oxlint-typeaware/steps.json b/packages/cli/snap-tests/oxlint-typeaware/steps.json new file mode 100644 index 0000000000..916bff384d --- /dev/null +++ b/packages/cli/snap-tests/oxlint-typeaware/steps.json @@ -0,0 +1,14 @@ +{ + "env": { + "VITE_DISABLE_AUTO_INSTALL": "1" + }, + "commands": [ + "vite lint ./src", + "echo //comment >> types.ts", + "vite lint ./src # non-type-aware linting doesn't read types.ts", + + "vite lint --type-aware ./src", + "echo //comment >> types.ts", + "vite lint --type-aware ./src # type-aware linting reads types.ts" + ] +} diff --git a/packages/cli/snap-tests/oxlint-typeaware/types.ts b/packages/cli/snap-tests/oxlint-typeaware/types.ts new file mode 100644 index 0000000000..191a99ee30 --- /dev/null +++ b/packages/cli/snap-tests/oxlint-typeaware/types.ts @@ -0,0 +1 @@ +export type Foo = number; From 94ae95e83934c68bb7e415243a8e11a8ad68dbf0 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 24 Oct 2025 10:23:24 +0800 Subject: [PATCH 2/2] ignore on Linux --- packages/cli/snap-tests/oxlint-typeaware/steps.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/snap-tests/oxlint-typeaware/steps.json b/packages/cli/snap-tests/oxlint-typeaware/steps.json index 916bff384d..2955df5ff9 100644 --- a/packages/cli/snap-tests/oxlint-typeaware/steps.json +++ b/packages/cli/snap-tests/oxlint-typeaware/steps.json @@ -1,4 +1,5 @@ { + "ignoredPlatforms": ["linux"], "env": { "VITE_DISABLE_AUTO_INSTALL": "1" },