npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sanity/groq-lint

v0.0.3

Published

GROQ linting engine, rules, and CLI for Sanity Lint

Readme

@sanity/groq-lint

GROQ query linter for catching performance issues and best practice violations.

Installation

npm install @sanity/groq-lint
# or
pnpm add @sanity/groq-lint

Usage

CLI

# Lint a query directly
npx @sanity/groq-lint -q '*[author->name == "Bob"]'

# Lint files
npx @sanity/groq-lint 'src/**/*.ts'

# With schema for schema-aware rules
npx @sanity/groq-lint 'src/**/*.ts' --schema schema.json

# JSON output for CI
npx @sanity/groq-lint --json 'src/**/*.ts'

Programmatic API

import { lint, initLinter } from '@sanity/groq-lint'

// Optional: Initialize WASM for better performance
await initLinter()

// Lint a query
const result = lint('*[author->name == "Bob"]')

if (result.findings.length > 0) {
  for (const finding of result.findings) {
    console.log(`${finding.ruleId}: ${finding.message}`)
  }
}

With Configuration

import { lint } from '@sanity/groq-lint'

const result = lint(query, {
  config: {
    rules: {
      'deep-pagination': false, // Disable specific rule
      'large-pages': { enabled: true }, // Configure rule
    },
  },
})

With Schema (Schema-Aware Rules)

import { lint } from '@sanity/groq-lint'
import type { SchemaType } from 'groq-js'

const schema: SchemaType = {
  // Your Sanity schema
}

const result = lint(query, { schema })

Rules

| Rule | Severity | Description | | ------------------------------ | -------- | ------------------------------------------------------ | | join-in-filter | error | Dereference (->) inside filter prevents optimization | | join-to-get-id | warning | Using -> to get _id (use ._ref instead) | | computed-value-in-filter | error | Computed values in filter prevent optimization | | match-on-id | info | Using match on _id with wildcard | | order-on-expr | error | Ordering on computed values | | deep-pagination | warning | Large offset in slice (>=1000) | | deep-pagination-param | warning | Pagination offset from parameter | | large-pages | warning | Fetching >100 results from index 0 | | non-literal-comparison | error | Comparing two non-literal expressions | | repeated-dereference | info | Multiple -> on same attribute in projection | | count-in-correlated-subquery | info | count() on correlated subqueries | | very-large-query | error | Query exceeds 10KB | | extremely-large-query | error | Query exceeds 100KB | | many-joins | warning | Query has >10 dereference operators |

WASM Acceleration

This package uses WASM-compiled Rust for maximum performance on pure GROQ rules. Call initLinter() once at startup to enable WASM:

import { initLinter, lint } from '@sanity/groq-lint'

// Initialize WASM (optional but recommended)
const wasmAvailable = await initLinter()
console.log(`WASM available: ${wasmAvailable}`)

// lint() automatically uses WASM for supported rules
const result = lint(query)

Hybrid Architecture

The linter uses a hybrid approach:

  • WASM rules: Pure GROQ rules run via high-performance Rust/WASM
  • TypeScript rules: Schema-aware rules run via TypeScript

This gives you the best of both worlds: raw performance for syntax-only checks and full schema integration for semantic checks.

Force TypeScript

To force TypeScript rules (useful for debugging):

const result = lint(query, { forceTs: true })

API Reference

initLinter(): Promise<boolean>

Initialize the WASM linter. Returns true if WASM is available.

lint(query: string, options?: LintOptions): LintResult

Lint a GROQ query.

interface LintOptions {
  config?: LinterConfig // Rule configuration
  schema?: SchemaType // Schema for schema-aware rules
  forceTs?: boolean // Force TypeScript rules
}

interface LintResult {
  query: string
  findings: Finding[]
  parseError?: string
}

lintMany(queries: string[], options?: LintOptions): LintResult[]

Lint multiple queries.

License

MIT