Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

chore: add pre-commit, migrate to biomejs (#1389)

Myles Scolnick40266cc84059
diff --git a/.github/renovate.json b/.github/renovate.json
index 99858becb8..18f95deac0 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -9,6 +9,9 @@
"enabled": true,
"packagePatterns": [".*sphinx.*"]
},
+ "pre-commit": {
+ "enabled": true
+ },
"pep621": {
"enabled": false
},
@@ -17,6 +20,11 @@
"depTypeList": ["peerDependencies"],
"enabled": false
},
+ {
+ "groupName": "pre-commit dependencies",
+ "matchManagers": ["pre-commit"],
+ "description": "Weekly update of pre-commit dependencies"
+ },
{
"packageNames": ["node"],
"enabled": false
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
index ba46365103..8ccb43cab1 100644
--- a/.github/workflows/cla.yml
+++ b/.github/workflows/cla.yml
@@ -3,7 +3,7 @@ on:
issue_comment:
types: [created]
pull_request_target:
- types: [opened,closed,synchronize]
+ types: [opened, closed, synchronize]
# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
permissions:
@@ -25,13 +25,13 @@ jobs:
# This token is required only if you have configured to store the signatures in a remote repository/organization
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
- path-to-signatures: 'signatures/version1/cla.json'
- path-to-document: 'https://marimo.io/cla' # e.g. a CLA or a DCO document
+ path-to-signatures: "signatures/version1/cla.json"
+ path-to-document: "https://marimo.io/cla" # e.g. a CLA or a DCO document
# branch should not be protected
- branch: 'main'
+ branch: "main"
allowlist: user1,bot*
- # the followings are the optional inputs - If the optional inputs are not given, then default values will be taken
+ # the followings are the optional inputs - If the optional inputs are not given, then default values will be taken
remote-organization-name: marimo-team
remote-repository-name: cla-signers
lock-pullrequest-aftermerge: false #- if you don't want this bot to automatically lock the pull request after merging (default - true)
diff --git a/.gitpod.yml b/.gitpod.yml
index bae926eeb7..555725160b 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -1,14 +1,14 @@
# Commands that will run on workspace start
tasks:
- - name: build from source
- before: pnpm install vite # vite needs to be installed in gitpod
- init: |
- make fe && make py
- gp sync-done bundle
-
- - name: marimo app in dev mode
- openMode: "split-left"
- init: gp sync-await bundle # wait for the above 'init' to finish
- command: |
- marimo -d edit
- gp ports expose 2718
+ - name: build from source
+ before: pnpm install vite # vite needs to be installed in gitpod
+ init: |
+ make fe && make py
+ gp sync-done bundle
+
+ - name: marimo app in dev mode
+ openMode: "split-left"
+ init: gp sync-await bundle # wait for the above 'init' to finish
+ command: |
+ marimo -d edit
+ gp ports expose 2718
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000000..4f8321cc19
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,38 @@
+fail_fast: true
+
+repos:
+ - repo: https://github.com/abravalheri/validate-pyproject
+ rev: v0.17
+ hooks:
+ - id: validate-pyproject
+
+ - repo: https://github.com/igorshubovych/markdownlint-cli
+ rev: v0.40.0
+ hooks:
+ - id: markdownlint-fix
+ args: [-c, configs/.markdownlint.yaml, --fix]
+
+ - repo: https://github.com/crate-ci/typos
+ rev: v1.21.0
+ hooks:
+ - id: typos
+
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.4.4
+ hooks:
+ # Run the linter
+ - id: ruff
+ args: [--fix]
+ # Run the formatter
+ - id: ruff-format
+
+ - repo: https://github.com/biomejs/pre-commit
+ rev: v0.1.0
+ hooks:
+ - id: biome-format
+ args: [--config-path, frontend/biome.json]
+ additional_dependencies: ["@biomejs/[email protected]"]
+ exclude: |
+ (?x)^(
+ docs/_static/.*|
+ )$
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 21a4287edd..01fed3c71a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -18,24 +18,37 @@ contribution._ Get in touch at
[GitHub issues](https://github.com/marimo-team/marimo/issues)
or [on Discord](https://discord.gg/JE7nhX6mD8).
-## Building from source
-
-You'll need to build marimo from source to edit and test code.
+## Prerequisites
-**Build dependencies.**
To build marimo from source, you'll need to have Node.js, pnpm, GNU make, and
Python (>=3.8) installed.
-- Install [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm)
+- Install [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm) >= 18
- We use Node.js version 20
-- Install [pnpm](https://github.com/pnpm/pnpm) with `npm install -g pnpm@8`
- - We use version 8 of pnpm. If you have a different version installed, you can
- install version 8 with `npm install -g pnpm@8`
+- Install [pnpm](https://github.com/pnpm/pnpm) == 8.x
+ - `npm install -g pnpm@8`
- Install [GNU Make](https://www.gnu.org/software/make/) (you may already have it installed)
-- Install [Python](https://www.python.org/). (You may already it installed. To see your version, use
- `python -v` at the command line.)
+- Install [Python](https://www.python.org/) >= 3.8. (You may already it installed. To see your version, use `python -v` at the command line.)
+
+And you'll need [pre-commit](https://pre-commit.com/) to run some validation checks:
+
+```bash
+pipx install pre-commit # or `pip install pre-commit` if you have a virtualenv
+```
+
+You can optionally install pre-commit hooks to automatically run the validation checks
+when making a commit:
+
+```bash
+pre-commit install
+```
+
+## Building from source
+
+Be sure to install the dependencies above before building from source.
+
+### Build from source
-**Build from source.**
After installing the dependencies, run the following in a fresh Python virtual
environment (such as [venv](https://docs.python.org/3/library/venv.html) or
[virtualenv](https://virtualenv.pypa.io/en/latest/)):
@@ -48,7 +61,7 @@ make fe && make py
(All `make` commands should be run in the project's root directory.)
-**Building from source, unminified.**
+### Building from source, unminified
To build the frontend unminified, run:
@@ -56,6 +69,31 @@ To build the frontend unminified, run:
NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=development make fe -B
```
+## `make` commands
+
+| Command | Category | Description |
+| -------------- | --------- | -------------------------------------------------------------- |
+| `help` | General | Show this help |
+| `py` | Setup | Editable python install; only need to run once |
+| `install-all` | Setup | Install everything; takes a long time due to editable install |
+| `fe` | Build | Package frontend into `marimo/` |
+| `wheel` | Build | Build wheel |
+| `check` | Test | Run all checks |
+| `check-test` | Test | Run all checks and tests |
+| `test` | Test | Run all tests |
+| `fe-check` | Lint/Test | Check frontend |
+| `fe-test` | Test | Test frontend |
+| `e2e` | Test | Test end-to-end |
+| `fe-lint` | Lint | Lint frontend |
+| `fe-typecheck` | Lint | Typecheck frontend |
+| `py-check` | Lint | Check python |
+| `py-test` | Test | Test python |
+| `py-snapshots` | Test | Update HTML snapshots |
+| `storybook` | Docs | Run Storybook |
+| `docs` | Docs | Build docs. Use `make ARGS="-a" docs` to force docs to rebuild |
+| `docs-auto` | Docs | Autobuild docs |
+| `docs-clean` | Docs | Remove built docs |
+
## Lint, Typecheck, Format
**All checks.**
@@ -175,7 +213,7 @@ For the frontend, you can run either
pnpm dev
```
-_OR_
+### OR
```bash
# OR, in order to test closer to production, you can build the frontend and watch for changes
@@ -199,19 +237,16 @@ marimo -d edit --no-token
frontend changes, or when you want to test the frontend in a way that is
closer to production.
- **When to run marimo CLI with development mode?**: When you are making
- changes to the backend and you want your changes to be auto-reloaded so you
- don't have to restart the server every time you make a change. If you are
- running the frontend in watch mode, you will want to run the marimo server in
- debug mode so that it will reload on changes.
+ changes to the backend and want to see debug logs.
+ When developing on marimo plugins, you can run with "On module change" as "autorun" to see changes immediately.
**Caveats for running `pnpm dev`**
Running `pnpm dev` will serve the frontend from a Vite dev server, not from the
marimo server. This means that:
-1. You will want to run your marimo server with `--headless` so it does not open a new browser tab, as it will
- interfere with the frontend dev server.
-2. The tradeoff of using the frontend dev server is that it is faster to
+1. You will want to run your marimo server with `--headless` and `--no-token` so it does not open a new browser tab, as it will interfere with the frontend dev server.
+1. The tradeoff of using the frontend dev server is that it is faster to
develop on the frontend, but you will not be able to test the frontend in
the same way that it will be used in production.
@@ -224,11 +259,10 @@ If use use vscode, you might find the following `settings.json` useful:
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"[typescript]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode"
+ "editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode"
+ "editor.defaultFormatter": "biomejs.biome"
},
- "prettier.configPath": "./frontend/.prettierrc.json"
}
```
diff --git a/Makefile b/Makefile
index 0ccd6fb00c..ec26e8c76a 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ e2e:
.PHONY: fe-lint
fe-lint:
- cd frontend/src && typos && cd - && cd frontend && pnpm lint:fix
+ cd frontend/src && typos && cd - && cd frontend && pnpm lint
.PHONY: fe-typecheck
fe-typecheck:
diff --git a/configs/.markdownlint.yaml b/configs/.markdownlint.yaml
new file mode 100644
index 0000000000..f0ff114568
--- /dev/null
+++ b/configs/.markdownlint.yaml
@@ -0,0 +1,20 @@
+# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md for all rules.
+default: true
+# line-length
+MD013: false
+# first-line-heading/first-line-h1
+MD041: false
+# no-inline-html
+MD033: false
+# no-alt-text
+MD045: false
+# link-fragments
+MD051: false
+# no-emphasis-as-heading
+MD036: false
+# heading-increment
+MD001: false
+# fenced-code-language
+MD040: false
+# ol-prefix
+MD029: false
diff --git a/docs/_static/js/analytics.js b/docs/_static/js/analytics.js
index db34727284..5d027568eb 100644
--- a/docs/_static/js/analytics.js
+++ b/docs/_static/js/analytics.js
@@ -1,5 +1,5 @@
// @ts-ignore
-// prettier-ignore
+// biome-ignore
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
// @ts-ignore
posthog.init("phc_U2xS6waxdmM6YDt9l6jwDdluVinawgkSn69qPAohz59", {
diff --git a/docs/api/miscellaneous.md b/docs/api/miscellaneous.md
index 752cf278a2..02ea6a1134 100644
--- a/docs/api/miscellaneous.md
+++ b/docs/api/miscellaneous.md
@@ -1,6 +1,5 @@
# Miscellaneous
-
```{eval-rst}
.. autofunction:: marimo.running_in_notebook
```
diff --git a/docs/api/outputs.md b/docs/api/outputs.md
index 3f206df8c1..34cf78f6df 100644
--- a/docs/api/outputs.md
+++ b/docs/api/outputs.md
@@ -34,9 +34,6 @@ already written. Wrap the last expression in `mo.output.append` if you want
to add to an existing output instead of replacing it.
```
-
-
-
## Console outputs
```{admonition} Console outputs
diff --git a/docs/faq.md b/docs/faq.md
index 5819b2ca9f..20dab75104 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -365,7 +365,6 @@ See the
[recipes for grouping UI elements together](/recipes.md#grouping-ui-elements-together)
for example code.
-
<a name="faq-on-change-last"></a>
### Why are my `on_change` handlers in an array all referencing the last element?
@@ -378,7 +377,6 @@ array = mo.ui.array(
])
```
-
**Instead, do this**: Explicitly bind `i` to the current loop value:
```python
@@ -416,7 +414,6 @@ x: "A" = ...
For Python 3.12+, marimo additionally implements annotation scoping.
-
<a name="faq-dotenv"></a>
### How do I use dotenv?
diff --git a/docs/guides/dataframes.md b/docs/guides/dataframes.md
index 0ca3e72fdc..569793c4c2 100644
--- a/docs/guides/dataframes.md
+++ b/docs/guides/dataframes.md
@@ -24,7 +24,6 @@ them in the last expression of the cell:
</figure>
</div>
-
```python
import pandas as pd
@@ -46,7 +45,6 @@ elements.
</figure>
</div>
-
```python
import marimo as mo
import altair as alt
@@ -81,7 +79,6 @@ and your selection is _automatically sent to Python as a Pandas dataframe_.
</figure>
</div>
-
```python
# Cell 1 - display a dataframe
import marimo as mo
@@ -99,7 +96,6 @@ table.value
## Transforming dataframes
-
### No-code transformations
Use [`mo.ui.dataframe`](/api/inputs/dataframe/) to interactively
@@ -107,7 +103,6 @@ transform a dataframe with a GUI, no coding required!. When you're done, you
can copy the code that the GUI generated for you and paste it into your
notebook.
-
<div align="center">
<figure>
<img src="/_static/docs-dataframe-transform.gif"/>
@@ -115,7 +110,6 @@ notebook.
</figure>
</div>
-
```python
# Cell 1
import marimo as mo
@@ -160,7 +154,6 @@ filtered_df = df[df["age"] < age_filter.value]
mo.ui.table(filtered_df)
```
-
## Polars support
marimo also supports [Polars](https://pola.rs/), a
diff --git a/docs/guides/integrating_with_marimo/displaying_objects.md b/docs/guides/integrating_with_marimo/displaying_objects.md
index dde7c821a4..2d3b06cf4c 100644
--- a/docs/guides/integrating_with_marimo/displaying_objects.md
+++ b/docs/guides/integrating_with_marimo/displaying_objects.md
@@ -83,5 +83,4 @@ codebase for
examples](https://github.com/marimo-team/marimo/tree/main/marimo/_output/formatters),
then open a pull request.
-
[AnyWidget](/api/inputs/anywidget.md)
diff --git a/docs/guides/integrating_with_marimo/index.md b/docs/guides/integrating_with_marimo/index.md
index 42e6d35a8e..40af24dbd7 100644
--- a/docs/guides/integrating_with_marimo/index.md
+++ b/docs/guides/integrating_with_marimo/index.md
@@ -23,8 +23,6 @@ You can check if Python is running in a marimo notebook with
when developing library code that integrates with marimo.
```
-
-
| | |
| :------------------------ | :------------------------------------------------------------------------ |
| {doc}`displaying_objects` | Richly display objects by hooking into marimo's media viewer |
diff --git a/docs/guides/interactivity.md b/docs/guides/interactivity.md
index d7d21f6334..9c837eddf9 100644
--- a/docs/guides/interactivity.md
+++ b/docs/guides/interactivity.md
@@ -83,5 +83,3 @@ value on form submission.
<figcaption>Use an array to group together elements or create a collection of elements that is determined at runtime</figcaption>
</figure>
</div>
-
-
diff --git a/docs/guides/plotting.md b/docs/guides/plotting.md
index d97f0ed270..e5b63b04f1 100644
--- a/docs/guides/plotting.md
+++ b/docs/guides/plotting.md
@@ -223,7 +223,6 @@ selectable Plotly plots whose values are sent back to Python on selection.
.. autofunction:: marimo.ui.plotly
```
-
## matplotlib
To output a matplotlib plot in a cell's output area, include its `Axes` or
diff --git a/docs/guides/reactivity.md b/docs/guides/reactivity.md
index cef5475cda..e144f59bc5 100644
--- a/docs/guides/reactivity.md
+++ b/docs/guides/reactivity.md
@@ -26,6 +26,7 @@ running them. Learn more in the
```
## References and definitions
+
A marimo notebook is a DAG where nodes are cells and edges are data
dependencies. marimo creates this graph by statically analyzing each cell
(i.e., without running it) to determine its
@@ -95,6 +96,7 @@ If you must mutate a variable in a downstream cell, try creating a new variable
instead.
_Don't_ do this:
+
```python
l = [1]
```
diff --git a/docs/guides/runtime_configuration.md b/docs/guides/runtime_configuration.md
index 7721a81805..b4d00db3df 100644
--- a/docs/guides/runtime_configuration.md
+++ b/docs/guides/runtime_configuration.md
@@ -12,6 +12,7 @@ _When sharing a notebook as an app with `marimo run`, this setting has
no effect._
## On cell change
+
By default, when a cell is run or a UI element is interacted with, marimo
automatically runs cells that reference any of its variables. **You can disable
automatic execution of cell's descendants in the notebook settings menu by
diff --git a/docs/guides/scripts.md b/docs/guides/scripts.md
index 4f5b633ee4..c78aa306f8 100644
--- a/docs/guides/scripts.md
+++ b/docs/guides/scripts.md
@@ -7,7 +7,6 @@ any other Python script. For example,
python my_marimo_notebook.py
```
-
Running a notebook as a script is useful when your notebook has side-effects,
like writing to disk. Print statements and other console outputs will show
up in your terminal.
@@ -18,4 +17,3 @@ up in your terminal.
In the future, we may make UI element values configurable as command-line
arguments, and optionally generate a PDF or HTML of the cell outputs.
```
-
diff --git a/docs/guides/state.md b/docs/guides/state.md
index 4c92f7e4f6..ce33085ff8 100644
--- a/docs/guides/state.md
+++ b/docs/guides/state.md
@@ -50,7 +50,6 @@ But sometimes, you might want interactions to mutate state:
<figcaption>A proof-of-concept TODO list made using state.</figcaption>
</div>
-
- You want to tie two different UI elements so that updating one updates
the other.
@@ -61,14 +60,12 @@ But sometimes, you might want interactions to mutate state:
</figure>
</div>
-
For cases like these, marimo provides the function [`mo.state()`](/api/state),
which creates a state object and returns a getter and setter function. When you
call the setter function in one cell, all other cells that reference the getter
function **via a global variable** are automatically run (similar to UI
elements).
-
```{admonition} State and UI elements are similar
:class: note
@@ -163,10 +160,10 @@ also enables new use cases. The next few examples showcase good uses of state.
```
### Example: counter
+
The next few cells implement a counter controlled by two buttons. This
particular example could be implemented without state (try it!), but the
-implementation using state is simpler.
-
+implementation using state is simpler.
<div align="center">
<figure>
@@ -174,7 +171,6 @@ implementation using state is simpler.
</figure>
</div>
-
```python
import marimo as mo
```
@@ -217,7 +213,6 @@ value depends on the other. This is impossible to do without `mo.state`.
</figure>
</div>
-
```python
import marimo as mo
```
@@ -277,7 +272,6 @@ The next few cells use state to create a todo list.
</figure>
</div>
-
```python
import marimo as mo
from dataclasses import dataclass
diff --git a/docs/index.md b/docs/index.md
index 99bc72ed17..ba17e1cbd4 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -36,7 +36,6 @@ conda install -c conda-forge marimo && marimo tutorial intro
Developer experience is core to marimo, with an emphasis on
reproducibility, maintainability, composability, and shareability.
-
**Highlights.**
- **reactive**: run a cell and marimo automatically runs affected cells and updates their outputs
@@ -45,8 +44,6 @@ reproducibility, maintainability, composability, and shareability.
- **deployable**: executable as a script, deployable as an app
- **developer-friendly**: git-friendly `.py` file format, GitHub Copilot, fast autocomplete, code formatting, and more
-
-
> ⚡ marimo notebooks run automatically with interactions and code changes
<div align="center">
diff --git a/docs/recipes.md b/docs/recipes.md
index 9af8bf54dc..5e12a3ee5d 100644
--- a/docs/recipes.md
+++ b/docs/recipes.md
@@ -119,8 +119,8 @@ mo.stop(form.value is None, mo.md("Submit the form to continue"))
mo.md(f"Hello, {form.value}!")
```
-
## Grouping UI elements together
+
### Create an array of UI elements
**Use cases.** In order to synchronize UI elements between the frontend and
@@ -207,8 +207,6 @@ in other outputs (like tables or markdown).
**Recipe.**
-
-
1. Import packages
```python
@@ -353,8 +351,6 @@ table
get_state()
```
-
-
### Create a form with multiple UI elements
**Use cases.** Combine multiple UI elements into a form so that submission
@@ -390,7 +386,6 @@ form
form.value
```
-
## Working with buttons
### Create a counter button
@@ -456,7 +451,6 @@ mo.md("True!") if button.value else mo.md("False!")
**Use cases.** For example, you have a cell showing a random sample of data,
and you want to resample on button press.
-
**Recipe.**
1. Import packages
@@ -488,7 +482,6 @@ random.randint(0, 100)
**Use cases.** Wait for confirmation before executing downstream cells
(similar to a form).
-
**Recipe.**
1. Import packages
@@ -514,7 +507,6 @@ mo.stop(button.value == 0)
mo.md(f"The button was clicked {button.value} times")
```
-
### Reveal an output when a button is pressed
**Use cases.** Incrementally reveal a user interface.
@@ -560,7 +552,7 @@ import functools
@functools.cache
def compute_predictions(problem_parameters):
# replace with your own function/parameters
- ...
+ ...
```
Whenever `compute_predictions` is called with a value of `problem_parameters`
diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs
index 04cfe395f1..a773a99954 100644
--- a/frontend/.eslintrc.cjs
+++ b/frontend/.eslintrc.cjs
@@ -26,7 +26,7 @@ module.exports = {
"plugin:unicorn/all",
// Testing
"plugin:vitest/recommended",
- // This removes rules that conflict with prettier.
+ // This removes rules that conflict with prettier/biomejs.
"prettier",
],
settings: {
diff --git a/frontend/.prettierignore b/frontend/.prettierignore
deleted file mode 100644
index 836b5779ea..0000000000
--- a/frontend/.prettierignore
+++ /dev/null
@@ -1,3 +0,0 @@
-dist
-lib
-pnpm-lock.yaml
diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json
deleted file mode 100644
index 0d0bbc9456..0000000000
--- a/frontend/.prettierrc.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "$schema": "http://json.schemastore.org/prettierrc",
- "singleQuote": false
-}
diff --git a/frontend/biome.json b/frontend/biome.json
new file mode 100644
index 0000000000..41c7e70cc7
--- /dev/null
+++ b/frontend/biome.json
@@ -0,0 +1,34 @@
+{
+ "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
+ "formatter": {
+ "enabled": true,
+ "formatWithErrors": false,
+ "indentStyle": "space",
+ "indentWidth": 2,
+ "lineEnding": "lf",
+ "lineWidth": 80,
+ "attributePosition": "auto",
+ "ignore": [
+ "dist",
+ "lib",
+ "pnpm-lock.yaml",
+ "storybook-static",
+ "package.json"
+ ]
+ },
+ "organizeImports": { "enabled": true },
+ "linter": { "enabled": true, "rules": { "recommended": true } },
+ "javascript": {
+ "formatter": {
+ "jsxQuoteStyle": "double",
+ "quoteProperties": "asNeeded",
+ "trailingComma": "all",
+ "semicolons": "always",
+ "arrowParentheses": "always",
+ "bracketSpacing": true,
+ "bracketSameLine": false,
+ "quoteStyle": "double",
+ "attributePosition": "auto"
+ }
+ }
+}
diff --git a/frontend/package.json b/frontend/package.json
index 99968596a1..0e729a7f25 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -138,15 +138,10 @@
"build": "vite build",
"test": "vitest",
"typecheck": "tsc --noEmit",
- "lint": "run-s lint:eslint lint:stylelint lint:prettier",
- "lint:eslint": "TIMING=1 eslint src e2e-tests --max-warnings=0",
- "lint:prettier": "prettier --check src/ e2e-tests/ islands/",
- "lint:stylelint": "stylelint src/**/*.css",
- "lint:fix": "run-s lint:eslint:fix lint:stylelint:fix lint:prettier:fix",
- "lint:eslint:fix": "pnpm run lint:eslint --fix",
- "lint:stylelint:fix": "pnpm run lint:stylelint --fix",
- "lint:prettier:fix": "prettier --write src/ e2e-tests/ islands/",
- "format": "prettier --write src/ e2e-tests/ islands/",
+ "lint": "run-s lint:eslint lint:stylelint format",
+ "lint:eslint": "TIMING=1 eslint src e2e-tests --max-warnings=0 --fix",
+ "lint:stylelint": "stylelint src/**/*.css --fix",
+ "format": "biome format --write .",
"preview": "vite preview",
"dev:islands": "VITE_MARIMO_ISLANDS=true vite --config islands/vite.config.mts",
"build:islands": "VITE_MARIMO_ISLANDS=true vite --config islands/vite.config.mts build",
@@ -159,6 +154,7 @@
"react-dom": "^17 || ^18"
},
"devDependencies": {
+ "@biomejs/biome": "1.7.3",
"@playwright/test": "^1.44.0",
"@storybook/addon-docs": "^8.0.10",
"@storybook/addon-essentials": "^8.0.10",
@@ -195,7 +191,6 @@
"npm-run-all2": "^6.1.2",
"postcss": "^8.4.38",
"postcss-plugin-namespace": "^0.0.3",
- "prettier": "^3.2.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-test-renderer": "^18.3.1",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 38de22ed30..244a06ef0e 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -352,6 +352,9 @@ dependencies:
version: 3.23.6
devDependencies:
+ '@biomejs/biome':
+ specifier: 1.7.3
+ version: 1.7.3
'@playwright/test':
specifier: ^1.44.0
version: 1.44.0
@@ -460,9 +463,6 @@ devDependencies:
postcss-plugin-namespace:
specifier: ^0.0.3
version: 0.0.3
- prettier:
- specifier: ^3.2.5
- version: 3.2.5
react:
specifier: ^18.3.1
version: 18.3.1
@@ -1807,6 +1807,94 @@ packages:
resolution: {integrity: sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA==}
dev: true
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-ogFQI+fpXftr+tiahA6bIXwZ7CSikygASdqMtH07J2cUzrpjyTMVc9Y97v23c7/tL1xCZhM+W9k4hYIBm7Q6cQ==}
+ engines: {node: '>=14.21.3'}
+ hasBin: true
+ requiresBuild: true
+ optionalDependencies:
+ '@biomejs/cli-darwin-arm64': 1.7.3
+ '@biomejs/cli-darwin-x64': 1.7.3
+ '@biomejs/cli-linux-arm64': 1.7.3
+ '@biomejs/cli-linux-arm64-musl': 1.7.3
+ '@biomejs/cli-linux-x64': 1.7.3
+ '@biomejs/cli-linux-x64-musl': 1.7.3
+ '@biomejs/cli-win32-arm64': 1.7.3
+ '@biomejs/cli-win32-x64': 1.7.3
+ dev: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-eDvLQWmGRqrPIRY7AIrkPHkQ3visEItJKkPYSHCscSDdGvKzYjmBJwG1Gu8+QC5ed6R7eiU63LEC0APFBobmfQ==}
+ engines: {node: '>=14.21.3'}
+ cpu: [arm64]
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-JXCaIseKRER7dIURsVlAJacnm8SG5I0RpxZ4ya3dudASYUc68WGl4+FEN03ABY3KMIq7hcK1tzsJiWlmXyosZg==}
+ engines: {node: '>=14.21.3'}
+ cpu: [x64]
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-c8AlO45PNFZ1BYcwaKzdt46kYbuP6xPGuGQ6h4j3XiEDpyseRRUy/h+6gxj07XovmyxKnSX9GSZ6nVbZvcVUAw==}
+ engines: {node: '>=14.21.3'}
+ cpu: [arm64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-phNTBpo7joDFastnmZsFjYcDYobLTx4qR4oPvc9tJ486Bd1SfEVPHEvJdNJrMwUQK56T+TRClOQd/8X1nnjA9w==}
+ engines: {node: '>=14.21.3'}
+ cpu: [arm64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-UdEHKtYGWEX3eDmVWvQeT+z05T9/Sdt2+F/7zmMOFQ7boANeX8pcO6EkJPK3wxMudrApsNEKT26rzqK6sZRTRA==}
+ engines: {node: '>=14.21.3'}
+ cpu: [x64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-vnedYcd5p4keT3iD48oSKjOIRPYcjSNNbd8MO1bKo9ajg3GwQXZLAH+0Cvlr+eMsO67/HddWmscSQwTFrC/uPA==}
+ engines: {node: '>=14.21.3'}
+ cpu: [x64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-unNCDqUKjujYkkSxs7gFIfdasttbDC4+z0kYmcqzRk6yWVoQBL4dNLcCbdnJS+qvVDNdI9rHp2NwpQ0WAdla4Q==}
+ engines: {node: '>=14.21.3'}
+ cpu: [arm64]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@biomejs/[email protected]:
+ resolution: {integrity: sha512-ZmByhbrnmz/UUFYB622CECwhKIPjJLLPr5zr3edhu04LzbfcOrz16VYeNq5dpO1ADG70FORhAJkaIGdaVBG00w==}
+ engines: {node: '>=14.21.3'}
+ cpu: [x64]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
/@braintree/[email protected]:
resolution: {integrity: sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==}
dev: false
diff --git a/frontend/public/site.webmanifest b/frontend/public/site.webmanifest
index 45dc8a2065..09317d7cf8 100644
--- a/frontend/public/site.webmanifest
+++ b/frontend/public/site.webmanifest
@@ -1 +1,19 @@
-{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
\ No newline at end of file
+{
+ "background_color": "#ffffff",
+ "display": "standalone",
+ "icons": [
+ {
+ "sizes": "192x192",
+ "src": "/android-chrome-192x192.png",
+ "type": "image/png"
+ },
+ {
+ "sizes": "512x512",
+ "src": "/android-chrome-512x512.png",
+ "type": "image/png"
+ }
+ ],
+ "name": "marimo",
+ "short_name": "marimo",
+ "theme_color": "#ffffff"
+}
diff --git a/frontend/src/core/islands/components/web-components.tsx b/frontend/src/core/islands/components/web-components.tsx
index 4aa7bd6d08..cc10473368 100644
--- a/frontend/src/core/islands/components/web-components.tsx
+++ b/frontend/src/core/islands/components/web-components.tsx
@@ -56,7 +56,9 @@ export class MarimoIslandElement extends HTMLElement {
const code = this.code;
const codeCallback: () => string = optionalEditor
? () =>
- `${UI_ELEMENT_REGISTRY.lookupValue(optionalEditor.props["object-id"])}`
+ `${UI_ELEMENT_REGISTRY.lookupValue(
+ optionalEditor.props["object-id"],
+ )}`
: () => code;
this.root = ReactDOM.createRoot(this);
diff --git a/frontend/src/core/pyodide/worker/getMarimoWheel.ts b/frontend/src/core/pyodide/worker/getMarimoWheel.ts
index 214d3321c4..e031608cca 100644
--- a/frontend/src/core/pyodide/worker/getMarimoWheel.ts
+++ b/frontend/src/core/pyodide/worker/getMarimoWheel.ts
@@ -4,7 +4,9 @@ export function getMarimoWheel(version: string) {
return "marimo >= 0.3.0";
}
if (version === "local") {
- return `http://localhost:8000/dist/marimo-${import.meta.env.VITE_MARIMO_VERSION}-py3-none-any.whl`;
+ return `http://localhost:8000/dist/marimo-${
+ import.meta.env.VITE_MARIMO_VERSION
+ }-py3-none-any.whl`;
}
if (version === "latest") {
return "marimo";
diff --git a/frontend/src/plugins/impl/RangeSliderPlugin.tsx b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
index 9f3e0c9f01..4408cb10af 100644
--- a/frontend/src/plugins/impl/RangeSliderPlugin.tsx
+++ b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
@@ -130,7 +130,9 @@ const RangeSliderComponent = ({
/>
{showValue && (
<div className="text-xs text-muted-foreground min-w-[16px]">
- {`${prettyScientificNumber(valueMap(internalValue[0]))}, ${prettyScientificNumber(valueMap(internalValue[1]))}`}
+ {`${prettyScientificNumber(
+ valueMap(internalValue[0]),
+ )}, ${prettyScientificNumber(valueMap(internalValue[1]))}`}
</div>
)}
</div>
diff --git a/frontend/src/plugins/impl/data-frames/python/python-print.ts b/frontend/src/plugins/impl/data-frames/python/python-print.ts
index 6d9447ef14..2f47396fe7 100644
--- a/frontend/src/plugins/impl/data-frames/python/python-print.ts
+++ b/frontend/src/plugins/impl/data-frames/python/python-print.ts
@@ -20,11 +20,15 @@ export function pythonPrint(dfName: string, transform: TransformType): string {
switch (transform.type) {
case "column_conversion": {
const { column_id, data_type, errors } = transform;
- return `${dfName}[${asLiteral(column_id)}].astype("${data_type}", errors="${errors}")`;
+ return `${dfName}[${asLiteral(
+ column_id,
+ )}].astype("${data_type}", errors="${errors}")`;
}
case "rename_column": {
const { column_id, new_column_id } = transform;
- return `${dfName}.rename(columns={${asLiteral(column_id)}: ${asLiteral(new_column_id)}})`;
+ return `${dfName}.rename(columns={${asLiteral(column_id)}: ${asLiteral(
+ new_column_id,
+ )}})`;
}
case "sort_column": {
const { column_id, ascending, na_position } = transform;
@@ -116,15 +120,21 @@ function generateWhereClause(
case "does_not_equal":
return `${dfName}[${asLiteral(column_id)}].ne(${asLiteral(value)})`;
case "contains":
- return `${dfName}[${asLiteral(column_id)}].str.contains(${asLiteral(value)})`;
+ return `${dfName}[${asLiteral(column_id)}].str.contains(${asLiteral(
+ value,
+ )})`;
case "regex":
return `${dfName}[${asLiteral(column_id)}].str.contains(${asLiteral(
value,
)}, regex=True)`;
case "starts_with":
- return `${dfName}[${asLiteral(column_id)}].str.startswith(${asLiteral(value)})`;
+ return `${dfName}[${asLiteral(column_id)}].str.startswith(${asLiteral(
+ value,
+ )})`;
case "ends_with":
- return `${dfName}[${asLiteral(column_id)}].str.endswith(${asLiteral(value)})`;
+ return `${dfName}[${asLiteral(column_id)}].str.endswith(${asLiteral(
+ value,
+ )})`;
case "in":
return `${dfName}[${asLiteral(column_id)}].isin(${listOfStrings(value)})`;
case "!=":
diff --git a/frontend/technology-decisions.md b/frontend/technology-decisions.md
index ef7f57e73e..c8eaf59a5d 100644
--- a/frontend/technology-decisions.md
+++ b/frontend/technology-decisions.md
@@ -7,7 +7,7 @@ Quick-hit list of technologies used and why, for the frontend.
- [Radix UI](https://www.radix-ui.com/) - Unstyled Component Library that's accessible and has a good API.
- [Radix Colors](https://www.radix-ui.com/colors) - Color palette. It's a great color palette that's accessible and has a good range of colors, supporting light and dark modes.
- [ESLint](https://eslint.org/) - Linter for Typescript. Pretty much the standard for linting.
-- [Prettier](https://prettier.io/) - Code formatter. Pretty much the standard for formatting.
+- [Biome](https://biomejs.dev/) - Fast code formatter
- [MSW](https://mswjs.io/) - Mocking library for API calls. Great for testing and development.
- [Playwright](https://playwright.dev/) - E2E testing library. Great for testing and development. It's faster than Cypress and has a better API.
- [jotai](https://jotai.org/) - State management library to avoid re-renders. Great for simple state management. It's a lot simpler than Redux and has a better API.
diff --git a/lsp/index.ts b/lsp/index.ts
index a3bad7e38e..59414e0aa8 100644
--- a/lsp/index.ts
+++ b/lsp/index.ts
@@ -27,7 +27,7 @@ const wss = new WebSocketServer(
},
() => {
console.log(`Listening to http and ws requests on ${serverPort}`);
- }
+ },
);
function toSocket(webSocket: ws): rpc.IWebSocket {
@@ -64,7 +64,7 @@ wss.on("connection", (client: ws, request: http.IncomingMessage) => {
const localConnection = rpcServer.createServerProcess(
"local",
langServer[0],
- langServer.slice(1)
+ langServer.slice(1),
);
const socket = toSocket(client);
const connection = rpcServer.createWebSocketConnection(socket);
diff --git a/pyodide/build_and_serve.py b/pyodide/build_and_serve.py
index 9e77bac743..9c5607d408 100644
--- a/pyodide/build_and_serve.py
+++ b/pyodide/build_and_serve.py
@@ -10,7 +10,7 @@ from watchdog.observers import Observer
class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
- def end_headers(self):
+ def end_headers(self) -> None:
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
self.send_header(
@@ -18,7 +18,7 @@ class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
)
super().end_headers()
- def do_OPTIONS(self):
+ def do_OPTIONS(self) -> None:
self.send_response(200, "ok")
self.end_headers()
@@ -26,14 +26,14 @@ class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
class WheelBuilderHandler(PatternMatchingEventHandler):
patterns = ["*.py"] # Watch for changes in Python files
- def on_any_event(self, event):
+ def on_any_event(self, event) -> None:
print(f"Change detected: {event.src_path}")
print("Building wheel...")
subprocess.run(["python3", "-m", "build"])
print("Wheel built successfully.")
-def serve():
+def serve() -> None:
with socketserver.TCPServer(("", 8000), CORSHTTPRequestHandler) as httpd:
httpd.allow_reuse_address = True
print("Serving at http://localhost:8000")
diff --git a/pyproject.toml b/pyproject.toml
index f65ab556da..f667e2898d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -149,6 +149,8 @@ include = ["marimo*"]
[tool.ruff]
line-length=79
exclude = [
+ "examples",
+ "scripts/print_banned_cell_names.py",
"marimo/_tutorials",
"marimo/_snippets/data",
"marimo/_smoke_tests",