I would like to know the name of the syntax used for the Cloud Firestore security rules as described at https://firebase.google.com/docs/firestore/security/get-started?authuser=0. I would like to find syntax highlighter for that syntax and maybe parsers for it.
Firebase Security Rules is a custom DSL.
Condition expressions are JS like, and should work with one of those. The path matching framework is less common, but we're working on providing the grammar + additional tooling (syntax highlighting, parsing, type checking, evaluators) in the future.
For those interested in the history, the semantics are closely related to XACML, we just wanted to provide better (non-XML) syntax.
You can find a syntax highlighting plugin for Visual Studio here: https://github.com/toba/vsfire
I adapted the plugin for Atom: https://github.com/jaysquared/atom-firestore-grammar
For IntelliJ IDEs, I found the Set File Type Associations immensely useful for adding syntax highlighting to the .rules
file.
You don't need to create an IDE plugin. Just check some boxes, mention some keywords. I chose this:
Tab 2: true
, false
Tab 3: !==
,==
,&&
,||
Tab 4: !
,(
,)
The result is a rather pleasant, imho:
What it does not provide is collapsing of rules, scoping of functions (autocomplete), or anything else that needs syntax awareness. But it seems way better than no syntax highlight, at all.
Edit: Unfortunately, in order to provide a tab/spaces policy for .rules
files, "you have to develop your own language plugin." (source) It seems there's still need for a proper language plugin.
:(
© 2022 - 2024 — McMap. All rights reserved.