A plugin for prettier to enable autoformatting for Cloud Firestore Security Rules.
A custom built parser for the rules is included.
With npm
npm i --save-dev prettier prettier-plugin-firestore-rules
With yarn
yarn add -D prettier prettier-plugin-firestore-rules
Generally
prettier -w <path/to/file>
Using yarn berry
yarn prettier -w <path/to/file>
Create a .prettierrc
file and add your preferred configuration options.
Configurations are optional.
emptyLinesBetweenBlocks
- Default:
0
- Adds empty lines between matcher blocks
- Default:
{
"emptyLinesBetweenBlocks" : 1
}
For more information see Prettier documentation.
- Fix some indentation issues
- Array not correctly indented as function parameter
request.resource.data.keys().hasOnly( ['rank', 'name', 'description', 'imageUrl', 'timeSlot'] )
- Function parameter in general
get( /databases/$(database)/documents/configurations/someData ).data.values.hasAll(request.resource.data.someData)
- if-alignments, sometimes off
if hasValue('writeSLots', request.auth.uid, carId) && zxcv && xcvb
- semicolon may be off
&& request.resource.data.timeSlot.to > request.resource.data.timeSlot.from ;
- Add formatter options:
- && at start or end of the line