Registry / data / prettier-plugin-firestore-rules

prettier-plugin-firestore-rules

JSON →
library0.1.5jsnpmunverified

A prettier plugin to format Firebase Firestore Security Rules files (.rules). Version 0.1.5 adds support for the 'in' operator. It is a lightweight, single-purpose plugin that integrates with Prettier, providing consistent formatting for Firestore rules alongside other code. Compared to manual formatting or IDE extensions, it offers automated, reproducible formatting within the Prettier ecosystem. The plugin is actively maintained with regular releases and supports Node.js ≥11. It is an ideal choice for Firebase projects using Prettier, ensuring rules keep the same code style as the rest of the codebase.

npm install prettier-plugin-firestore-rules
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-FI
P
prettier-plugin-firestore-rules
datajavascriptv0.1.5
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

prettier-plugin-firestore-rules
✓ No explicit import needed; use in .prettierrc or CLI as --plugin=prettier-plugin-firestore-rules
✗ import plugin from 'prettier-plugin-firestore-rules'; // Not needed and will not work
This is a prettier plugin, used via configuration or CLI, not directly imported in JavaScript/TypeScript.
firestore.rules
✓ Files with .rules extension are automatically detected and formatted when plugin is registered
✗ Relying on file detection without registering the plugin
Works out of the box for .rules files if the plugin is installed and listed in prettier config.
require('prettier-plugin-firestore-rules')
✓ Add to .prettierrc: { "plugins": ["prettier-plugin-firestore-rules"] }
✗ const rulesPlugin = require('prettier-plugin-firestore-rules'); // Not a standalone module
The plugin is not meant to be required directly; it is loaded by prettier.

Install the plugin, configure .prettierrc to include the plugin, then format .rules files using prettier CLI.

// 1. Install plugin and prettier npm install --save-dev prettier prettier-plugin-firestore-rules // 2. Create .prettierrc in project root // .prettierrc { "plugins": ["prettier-plugin-firestore-rules"], "singleQuote": true, "tabWidth": 2 } // 3. Format a .rules file (e.g., firestore.rules) // Run: npx prettier --write firestore.rules // Example firestore.rules before formatting: // rules_version = '2'; // service cloud.firestore { // match /databases/{database}/documents { // match /{document=**} { // allow read, write: if false; // } // } // } // After formatting: // rules_version = '2'; // service cloud.firestore { // match /databases/{database}/documents { // match /{document=**} { // allow read, write: if false; // } // } // }
Debug
Known issues
breakingv0.1.5 changed formatting for 'in' operator. Previous versions may have formatted 'in' differently, causing formatting diffs.
fix
Update to >=0.1.5 and re-format .rules files.
affects: <=0.1.4
deprecatedNode.js v10 and below are not supported. The plugin requires Node >=11.
fix
Upgrade Node.js to version 11 or later.
affects: all
gotchaPlugin must be listed in prettier config or passed via CLI argument; otherwise, .rules files will not be formatted.
fix
Ensure plugins array includes "prettier-plugin-firestore-rules" in .prettierrc or use --plugin=... on CLI.
affects: all
gotchaThe plugin only formats .rules files; other Firebase configuration files (e.g., firestore.indexes.json) are not affected.
fix
Use separate prettier plugins or formatters for other file types.
affects: all
gotchaNo TypeScript typings are provided in this version; the plugin is plain JavaScript.
fix
If using TypeScript in your project, ignore missing types or write a declaration file.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-firestore-rules'
Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev prettier-plugin-firestore-rules'.
TypeError: plugin is not a function
Incorrect usage: trying to require the plugin as a standalone module instead of via prettier configuration.
fix
Remove direct require/import and add the plugin name to prettier's plugins config.
Error: No parser could be inferred for file: firestore.rules
Plugin not registered in prettier config; prettier does not know how to parse .rules files.
fix
Add the plugin to .prettierrc plugins array.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies
prettierrequiredpeer dependency; required as the formatting engine
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-plugin-firestore-rules — npm install prettier-plugin-firestore-rules · libregistry