Skip to content

🐛 Biome GritQL plugin can't match interfaces #7363

@r4ai

Description

@r4ai

Environment information

CLI:
  Version:                      2.2.2
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         xterm-256color
  JS_RUNTIME_VERSION:           v24.6.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         bun/1.2.21

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true

Workspace:
  Open Documents:               0

What happened?

The following GritQL query successfully finds interfaces when executed with grit cli, but fails to find when run with biome.

`interface $name { $body }` where {
  register_diagnostic(span=$name, severity="warn", message="found interface")
}

Steps to reproduce the issue.

  1. Clone https://github.com/r4ai/biome-plugin-interface-issue.

  2. Install dependencies.

    $ bun install --frozen-lockfile
  3. Check that it matches the interface when you run with grit cli.

    $ bun grit apply interface
    Log in ./src/interface.ts: found interface
    
    - Range: 1:11 - 1:15
    - Source:
    Zero
    - Syntax tree:
    (identifier)
    ./src/interface.ts
        1  interface Zero {}
        3  interface Single {
        4    f1: string
        5  }
        7  interface Multi {
        8    id: number
        9    name: string
        10    email: string
        11  }
    
    Processed 1 files and found 3 matches
  4. Check that it doesn't match the interface when you run it with biome.

    $ bun biome check ./src
    src/interface.ts:1:6 lint/correctness/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
    ⚠ This type alias Zero is unused.
    
    > 1 │ type Zero = {};
        │      ^^^^
        2 │
        3 │ interface Single {
    
    ℹ Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.
    
    
    src/interface.ts:1:13 lint/complexity/noBannedTypes ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
    ⚠ Don't use '{}' as a type.
    
    > 1 │ type Zero = {};
        │             ^^
        2 │
        3 │ interface Single {
    
    ℹ Prefer explicitly define the object shape. '{}' means "any non-nullable value".
    
    
    src/interface.ts:3:11 lint/correctness/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
    ⚠ This interface Single is unused.
    
        1 │ type Zero = {};
        2 │
    > 3 │ interface Single {
        │           ^^^^^^
        4 │         f1: string;
        5 │ }
    
    ℹ Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.
    
    
    src/interface.ts:7:11 lint/correctness/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
    ⚠ This interface Multi is unused.
    
        5 │ }
        6 │
    > 7 │ interface Multi {
        │           ^^^^^
        8 │         id: number;
        9 │         name: string;
    
    ℹ Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.
    
    
    Checked 1 file in 2ms. No fixes applied.
    Found 4 warnings.
    

Expected result

I think it should match interfaces.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-Needs triageStatus: this issue needs to be triaged

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions