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-groqVerified import paths — ran on the pinned version, not inferred.
Installs the plugin, configures Prettier, formats a .groq file with inline shorthand enabled.
Avoid inline comments; use block comments /* ... */ if needed, but they are also unsupported. Consider reformulating the query without comments.
Rewrite map components using filter syntax or ensure the GROQ parser supports them. They are currently unsupported.
Review formatted output to ensure expansion semantics are correct. The plugin groups and reorganizes properties.
Use the exact option name with correct capitalization.
Run 'npm install --save-dev prettier-plugin-groq' and add '"plugins": ["prettier-plugin-groq"]' to .prettierrc.
Remove inline comments from .groq files before formatting.
Use correct option name: 'groqInlineShorthandProperties' in .prettierrc.