@jacobknightley/fabric-format
v0.0.9
Published
A fast, opinionated formatter for Microsoft Fabric notebooks with Spark SQL and Python support
Maintainers
Readme
fabric-format
A zero-config formatter for Microsoft Fabric notebooks.
Philosophy
Opinionated by design. This formatter has one style, enforced everywhere, with no configuration options—and no plans to add any.
Built this for teams who want consistent notebook formatting without endless debates over style guides. The decisions are made. Your code looks the same every time.
The focus is on clean, consistent output—not tailored experiences or nuanced edge cases.
Browser Extension
Format Fabric notebooks directly in your browser with a single click.
- Install the Edge extension Edge Add-ons
Until Chrome is supported, download the extension and unpack in chrome developer mode
- Open a notebook in Microsoft Fabric
- Click the
button in the notebook toolbar
CLI
Format Fabric notebook-content files synced from a workspace in a repository.
# install
npm install -g @jacobknightley/fabric-format
# format
fabfmt format notebook.py # Format a single file
fabfmt format ./src # Format all files in directory
fabfmt format query.sql --print # Print formatted output
fabfmt format --type sparksql -i "select * from t" # Format inline string
echo "select * from t" | fabfmt format --type sparksql # Format from stdin
# check (exit 1 if changes needed)
fabfmt check notebook.py # Check a single file
fabfmt check ./src # Check all files in directory
fabfmt check --type sparksql -i "select * from t" # Check inline string
echo "select * from t" | fabfmt check --type sparksql # Check from stdinSupported File Types
.py— Python notebooks.scala— Scala notebooks.r— R notebooks.sql— SQL notebooks
Language Support
Spark SQL
The SQL formatter uses an ANTLR grammar to parse and reformat Spark SQL. All keywords, functions, and syntax are derived directly from the official Spark SQL grammar.
See SQL_STYLE_GUIDE.md for formatting rules.
Python / PySpark
The Python formatter uses Ruff WASM for:
- Code formatting — Consistent styling (line length 140, double quotes, trailing commas)
- Safe lint auto-fixes — Automatically applies safe fixes from ~60 Ruff rules
Included lint auto-fixes:
- Import sorting (I001) — Organizes imports by standard library, third-party, local
- Modernization (UP008, UP018, UP032) — Updates deprecated patterns to modern Python
- Simplifications (SIM118, SIM201, SIM300) —
key in dictinstead ofkey in dict.keys(), etc. - Bug fixes (B009, B010) — Use
getattr()/setattr()properly - Style (E703, E711, F632) — Remove useless semicolons, use
is None, etc. - Ruff specific (RUF005) — List concatenation with unpacking
Explicitly excluded rules (unsafe for notebooks):
- F401, F841 — Unused imports/variables may be used in other cells
- Rules that add imports (RUF017, SIM105, etc.) — Can break cell execution order
- RET504 — Removing intermediate variables changes code structure
The lint fixes are applied automatically—no configuration needed.
Documentation
Find all documentation at fabric-format wiki
