Registry / aws / prettier-plugin-firebase-database

prettier-plugin-firebase-database

JSON →
library2.0.0jsnpmunverified

The `prettier-plugin-firebase-database` package, currently at version 2.0.0, is a specialized Prettier plugin designed to format Firebase Realtime Database Rules. It enforces a consistent code style for `*.rules` files (e.g., `database.rules.json`), ensuring readability and maintainability within development teams working with Firebase. As a Prettier plugin, it integrates into existing Prettier setups via configuration, providing custom parsing and formatting logic tailored to the unique JSON-like syntax of Firebase security rules. The project follows Prettier's major release cadence, with updates typically occurring to maintain compatibility with new Prettier versions or to adapt to changes in Firebase rules syntax. Its key differentiator is providing specific, correct formatting for Firebase rules, which generic JSON formatters often handle incorrectly.

npm install prettier-plugin-firebase-database
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-FI
P
prettier-plugin-firebase-database
awsjavascriptv2.0.0
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.

"prettier-plugin-firebase-database"
// In prettier.config.js plugins: ["prettier-plugin-firebase-database"]
import * as FirebasePrettierPlugin from 'prettier-plugin-firebase-database';
This package is a Prettier plugin loaded by Prettier through its configuration file (e.g., `prettier.config.js`), not via a direct JavaScript `import` or `require` statement. The correct usage is to include its package name as a string within the `plugins` array.
parser: 'prettier-plugin-firebase-database'
// prettier.config.js, inside overrides.options parser: 'prettier-plugin-firebase-database'
parser: 'firebase' || parser: 'rules'
When using Prettier `overrides` to explicitly associate specific file patterns (like `*.rules`) with this plugin, the `parser` option must be set to the full plugin package name as a string.
import("prettier").Config
/** @type {import("prettier").Config} */ const config = { ... };
import { Config } from 'prettier-plugin-firebase-database';
For TypeScript-enabled Prettier configuration files (e.g., `prettier.config.js` or `prettier.config.mjs`), you typically import the `Config` type from the `prettier` package itself for type checking, not from the plugin.

This quickstart demonstrates how to configure Prettier to load the Firebase Database Rules plugin. After installing `prettier` and `prettier-plugin-firebase-database` as dev dependencies, create or update your `prettier.config.js` file with the plugin reference. You can then format `.rules` files using `prettier --write your-file.rules`.

// prettier.config.js /** * @see https://prettier.io/docs/en/configuration.html * @type {import("prettier").Config} */ const config = { plugins: ['prettier-plugin-firebase-database'], // Recommended: Explicitly associate .rules files with the plugin's parser. // This ensures consistent formatting for all files ending with .rules. overrides: [ { files: '*.rules', options: { parser: 'prettier-plugin-firebase-database' } } ] }; export default config;
Debug
Known issues
breakingVersion 2.0.0 and above of `prettier-plugin-firebase-database` requires Prettier version 3 or newer due to a peer dependency. Older versions of Prettier (e.g., v2.x) are not supported and will lead to installation or runtime errors.
fix
Upgrade Prettier to version 3 or greater by running `npm install prettier@latest` or `yarn add prettier@latest`.
affects: >=2.0.0
gotchaIf Prettier isn't formatting your `.rules` files, ensure the plugin is correctly listed in the `plugins` array of your Prettier configuration file (e.g., `prettier.config.js`). Typos or missing the entry will prevent the plugin from being loaded.
fix
Verify that `plugins: ['prettier-plugin-firebase-database']` is present and correctly spelled in your Prettier config.
affects: >=1.0.0
gotchaThe plugin by default attempts to parse `.rules` files. If you have Firebase rules files with different extensions or if auto-detection fails, explicitly configure `overrides` in your `prettier.config.js` to associate specific file patterns with the plugin's parser.
fix
Add an `overrides` entry to your Prettier config: `overrides: [{ files: '*.your_extension', options: { parser: 'prettier-plugin-firebase-database' } }]` where `your_extension` is the actual file extension.
affects: >=1.0.0
Errors
Common errors & fixes
[error] Unknown parser "prettier-plugin-firebase-database" for file "your-file.rules"
Prettier could not find or load the `prettier-plugin-firebase-database` plugin, or it's not correctly referenced in your configuration.
fix
Ensure `prettier-plugin-firebase-database` is installed as a dev dependency and correctly listed in the `plugins` array of your `prettier.config.js`. If using package managers like Yarn PnP, check plugin resolution.
Error: Cannot find module 'prettier' (or similar during npm install/yarn add)
The `prettier-plugin-firebase-database` package has a peer dependency on `prettier` version 3 or higher, but an incompatible or missing version of `prettier` is installed.
fix
Install `prettier` version 3 or greater: `npm install --save-dev prettier@latest` or `yarn add --dev prettier@latest`.
No files matching the pattern were found: "firebase-database.rules"
This is a Prettier CLI error, indicating that the command-line pattern provided to `prettier --write` did not find any files.
fix
Verify the file path and pattern provided to the `prettier --write` command. Ensure the file exists and the glob pattern is correct relative to where you run the command.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency for Prettier plugin functionality, requiring version 3 or newer.
Agent activity
10 hits · last 30 days
node
10
Resources
prettier-plugin-firebase-database — npm install prettier-plugin-firebase-database · libregistry