Registry / web-framework / prettier-plugin-groq

prettier-plugin-groq

JSON →
library0.2.5jsnpmunverified

A Prettier plugin for formatting GROQ queries used with Sanity.io. Version 0.2.5 is the latest stable release. Release cadence is irregular, driven by community contributions. Key differentiators: opinionated formatting following Prettier philosophy, groups object properties by value type, respects printWidth and inlineShorthandProperties option. Supports filters, projections, order, select, and conditional expressions. Does not preserve whitespace or inline comments. Standard Prettier plugin installation; auto-detected by editors when installed locally.

npm install prettier-plugin-groq
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-GR
P
prettier-plugin-groq
web-frameworkjavascriptv0.2.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Plugin
import * as prettierPluginGroq from 'prettier-plugin-groq'
const prettierPluginGroq = require('prettier-plugin-groq')
Prettier plugins are typically specified in config files, not imported directly. The plugin auto-registers when installed.
Config
// .prettierrc { "plugins": ["prettier-plugin-groq"], "groqInlineShorthandProperties": false }
// incorrect: plugins: ['prettier-plugin-groq'] missing in config
Add the plugin name to the plugins array in .prettierrc or prettier.config.js to enable GROQ formatting.
groqInlineShorthandProperties
// .prettierrc { "groqInlineShorthandProperties": true }
// typo: "groqInlineShorthandProps": true
Option name is groqInlineShorthandProperties, not groqInlineShorthandProps.

Installs the plugin, configures Prettier, formats a .groq file with inline shorthand enabled.

npm install --save-dev prettier prettier-plugin-groq echo '{ "plugins": ["prettier-plugin-groq"], "groqInlineShorthandProperties": true }' > .prettierrc cat << 'EOF' > query.groq *[_type == "movie" && popularity > 10] | order(popularity desc){ _id, title, popularity } EOF npx prettier --write query.groq cat query.groq # Output: # *[_type == "movie" && popularity > 10] | order(popularity desc) { # _id, # title, # popularity # }
Debug
Known issues
gotchaInline comments in GROQ queries are ignored and will be removed during formatting.
fix
Avoid inline comments; use block comments /* ... */ if needed, but they are also unsupported. Consider reformulating the query without comments.
affects: >=0.0.0
gotchaMap components like `* | ([ like, this ])` are not supported by the parser and will cause errors.
fix
Rewrite map components using filter syntax or ensure the GROQ parser supports them. They are currently unsupported.
affects: >=0.0.0
gotchaExpansion operator `...` behavior may not be preserved exactly as input due to AST-based formatting.
fix
Review formatted output to ensure expansion semantics are correct. The plugin groups and reorganizes properties.
affects: >=0.0.0
gotchaOption name `groqInlineShorthandProperties` is case-sensitive and must be spelt correctly.
fix
Use the exact option name with correct capitalization.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-groq'
Prettier plugin not installed or not added to plugins array in config.
fix
Run 'npm install --save-dev prettier-plugin-groq' and add '"plugins": ["prettier-plugin-groq"]' to .prettierrc.
Unexpected token '//' (or similar comment error)
Inline comments are not supported by the GROQ parser used by this plugin.
fix
Remove inline comments from .groq files before formatting.
Unknown option: groqInlineShorthandProps (or typo)
Option name is misspelled.
fix
Use correct option name: 'groqInlineShorthandProperties' in .prettierrc.
Upgrade
Version history
0.2.5latest on npm
Audit
Dependencies
prettierrequiredpeer dependency required to use the plugin
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-groq — npm install prettier-plugin-groq · libregistry