Skip to content

vp lint does not detect lint field in vite.config.ts #1084

Closed as duplicate
Closed as duplicate

Description

@Ionaru

Describe the bug

When I run vp lint in my newly setup Qwik/Vite+ project, I get this error:

VITE+ - The Unified Toolchain for the Web

Failed to parse oxlint configuration file.

  × Expected a `lint` field in the default export of C:/Users/USER/Projects/qwikplus/vite.config.ts

But vite.config.ts does contain the lint field. (see repro: https://github.com/Ionaru/qwikplus-vplint-error/blob/b58b3bb44e8ab79c7d8fed66e75df14bf7287993/vite.config.ts#L25)

Running pnpx oxlint works correctly.

Reproduction

https://github.com/Ionaru/qwikplus-vplint-error

Steps to reproduce

  1. git clone https://github.com/Ionaru/qwikplus-vplint-error.git
  2. cd qwikplus-vplint-error
  3. pnpm install --frozen-lockfile
  4. vp lint

OR

  1. vp create qwik@beta -- playground qwikplus -i false
  2. cd qwikplus
  3. Edit tsconfig.json -> set "module" to "esnext"
  4. Edit vite.config.ts -> add with { type: "json" } to import pkg from "./package.json"
  5. vp lint

System Info

VITE+ - The Unified Toolchain for the Web

Environment:
  Version       24.14.0
  Source        engines.node
  Source Path   C:\Users\USER\Projects\qwikplus\package.json
  Project Root  C:\Users\USER\Projects\qwikplus

Tool Paths:
  node  C:\Users\USER\.vite-plus\js_runtime\node\24.14.0\node.exe
  npm   C:\Users\USER\.vite-plus\js_runtime\node\24.14.0\npm.cmd
  npx   C:\Users\USER\.vite-plus\js_runtime\node\24.14.0\npx.cmd

VITE+ - The Unified Toolchain for the Web

vp v0.1.13

Local vite-plus:
  vite-plus  v0.1.13

Tools:
  vite             v8.0.1
  rolldown         v1.0.0-rc.10
  vitest           v4.1.0
  oxfmt            v0.41.0
  oxlint           v1.56.0
  oxlint-tsgolint  v0.17.1
  tsdown           v0.21.4

Environment:
  Package manager  pnpm v10.32.1
  Node.js          v24.14.0 (engines.node)

Used Package Manager

pnpm

Logs

No Vite+ commands support `--debug` it seems...

- vp lint --debug -> Error: no such flag: --debug, did you mean --deny?
- vp --debug lint -> error: Unexpected argument '--debug'

Validations

Activity

  1. added theissue type on Mar 21, 2026
  2. claude commented on Mar 21, 2026

    @claude

    Analysis

    Root Cause

    The bug occurs in the following flow when vp lint is called:

    1. vp lint calls resolveUniversalViteConfig(), which uses Vite's runtime config resolver to load vite.config.ts — this succeeds and correctly extracts the lint field.
    2. Since lint is set, cli.rs (lines 253–258) appends -c vite.config.ts to oxlint's arguments.
    3. Oxlint's own config parser then tries to re-parse vite.config.ts to find the lint field.
    4. Oxlint's parser fails when the file contains import attributes (with { type: "json" }), producing the "Expected a lint field in the default export" error.

    The second reproduction step confirms this: adding with { type: "json" } to an import is the exact trigger.

    Relevant Code

    packages/cli/binding/src/cli.rs lines 253–258: Where vite.config.ts path is passed to oxlint

    if let (Some(_), Some(config_file)) =
        (&resolved_vite_config.lint, &resolved_vite_config.config_file)
    {
        args.insert(0, "-c".to_string());
        args.insert(1, config_file.clone());
    }

    packages/cli/src/resolve-vite-config.ts: Returns both configFile (path to vite.config.ts) and lint (the already-extracted config object as JSON).

    Is This Fixable?

    Yes. This is fixable on the vite-plus side without waiting for an oxlint fix.

    Implementation Plan

    The fix is to stop passing vite.config.ts directly to oxlint and instead write a temporary JSON file containing just the extracted lint config:

    1. In cli.rs SynthesizableSubcommand::Lint handler: When resolved_vite_config.lint is Some(json_value), instead of passing -c vite.config.ts, serialize the JSON value to a temp file (e.g., a file in the system temp dir) and pass -c <temp_file_path>.

    2. Temp file lifecycle: Write the file before spawning oxlint and delete it after oxlint exits. The temp file can be written in a blocking fashion before the child process is spawned and cleaned up via a drop guard.

    3. Fallback: If resolved_vite_config.lint is None, don't pass any -c flag (current behavior for the no-lint case).

    An alternative would be to write the lint config to a deterministically named file (e.g., oxlint.json) in the project root — but a temp file avoids polluting the project directory.

    Potential Concerns

    • Temp file cleanup on process crash: The temp file should be cleaned up via a drop guard to avoid leftover files if the process is killed.
    • Import attributes are valid ECMAScript: This is a spec-compliant feature (ES2025), so this is ultimately an oxlint bug — consider also filing an issue with oxlint upstream. The vite-plus fix is a pragmatic workaround.
    • Complexity of lint config: The extracted lint value from resolveUniversalViteConfig is already the full JSON-serialized lint config, so no further transformation is needed before writing to a temp file.
  3. leaysgur commented on Mar 23, 2026

    @leaysgur
    Contributor

    The root cause: #930.

    • Both oxlint and oxfmt currently do not support function configuration.
      • defineConfig(() =>; {})
    • It is ignored for the auto-discovery of config
    • It is reported as an error when the -c flag is specified

    And:

    • vite-lint is equivalent to oxlint -c vite.config.ts
      • It tries to load vite.config.ts as a config with no lint field error
    • pnpx oxlint = oxlint
      • It also finds vite.config.ts but ignores it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions