openfga / openfga/language

Allow the ability to format a DSL file

Open
#485 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
35
Forks
17
Avg merge
48m
Merged PRs (30d)
10

Description

We would like to expose a new method: formatter.Format(dslFile, options).

Given a DSL file contents, it would return a formatted DSL file.

Options may not be much at the start, but can grow to include:

  • using spaces instead of tabs
  • tab width
  • having a space between types
  • grouping assignable relations at the top
  • grouping non-assignable relations prefixed with is_ or can_ at the bottom

For modular models, we should allow passing a map containing the fga.mod and the contents of each file, but that should be a separate ticket.

In later tickets:

  • this should be integrated into the VS Code ext, IntelliJ plugin and CLI
  • We should allow formatting the store file

Also potentially later combined with a linter used in a github action

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the requested formatter.Format(dslFile, options) API and the proposed formatting options. The issue scopes initial work to formatting a single DSL file; modular models, editor and CLI integrations, store-file formatting, and linting are explicitly later work. Done means the agreed initial API formats DSL input according to its supported options.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.