Metadata-Version: 2.4
Name: sudsy
Version: 0.0.2
Summary: Formatter and linter for C#, JSON, YAML and more
License-Expression: MIT
License-File: LICENSE
Project-URL: Homepage, https://github.com/bingsubandit/sudsy
Requires-Python: >=3.8
Description-Content-Type: text/markdown

<p align="center"><img src="assets/logo/soap_3d.png" alt="Sudsy" width="96"></p>

# Sudsy

A formatter and linter for <!-- generated:languages -->C#, C/C++, CSS, Dockerfile, EditorConfig, Gitignore, GraphQL, HCL, HTML, INI, JSON, Java, JavaScript/TypeScript, Kotlin, Makefile, Markdown, PHP, PowerShell, Protobuf, Python, Ruby, SQL, Shell, TOML, XML and YAML<!-- /generated --> (JSON includes JSONC; XML covers `.csproj`, `.props`, `.targets`, `.config`, ...), configured from one `sudsy.yaml`.

- **Formatting**: every layout decision is a named option; presets reproduce the styles of Microsoft, the .NET runtime, Google, CSharpier and Prettier. Debug builds, the tests and the `corpus` profile check that each result has the same syntax tree (and for YAML the same data) as the input; release builds trust the formatter and do not run that check.
- **Linting**: built-in rules for every language, semantic C# rules (types, control and data flow), safe and unsafe fixes, suppression comments, [pattern rules](docs/rules/patterns.md) in YAML and [Wasm plugins](docs/rules/plugins.md) (unstable API).
- **Implementation**: a Rust core. JSON and YAML are parsed natively and TOML, XML and Markdown by embedded tree-sitter grammars; C# is parsed and analysed by a Roslyn-backed .NET worker that the CLI starts when it needs it.

Measured speed against CSharpier, Prettier, Biome and dprint, with the method and machine: [docs/performance/numbers.md](docs/performance/numbers.md).

## Install

- **CLI**: download the archive for your platform (Linux, Windows or macOS; x64 or arm64) from the GitHub releases page and put the `sudsy` executable on your `PATH`. Keep the `csharp-worker/` directory beside it.
- **Package managers** (same binary, `csharp-worker/` included except with cargo-binstall): `npm i -D @sudsylint/sudsy`, `pip install sudsy` / `uvx sudsy`, `brew install bingsubandit/sudsy/sudsy`, `scoop bucket add sudsy https://github.com/bingsubandit/scoop-sudsy && scoop install sudsy`, `winget install Coox.Sudsy`, `cargo binstall --git https://github.com/bingsubandit/sudsy sudsy`. Setup and publishing: [docs/development/ci-release.md](docs/development/ci-release.md).
- **VS Code**: install the extension `Coox.sudsy`. It bundles the CLI and the worker.
- **C#** needs the [.NET 10 runtime](https://dotnet.microsoft.com/download/dotnet/10.0). Every other language works without it.

## Quick start

```sh
sudsy init --preset csharp/google   # writes a starter sudsy.yaml
sudsy format                           # format the current directory in place
sudsy lint                             # report rule violations
sudsy fix                              # apply fixes, then format
sudsy rules                            # list the rules; `sudsy rules <id>` explains one
```

In CI, `sudsy check` runs `format --check` and `lint` together and exits 1 when a file is unformatted or a rule reports an error:

```sh
sudsy check --format github   # ::error file=...:: annotations in the GitHub Actions log
sudsy check --format sarif > sudsy.sarif   # for code scanning upload
```

Output formats are `human`, `json`, `sarif` and `github`. Exit codes and all commands: [docs/config/cli.md](docs/config/cli.md).

## Presets

Presets are ordinary config files; writing their options by hand in `sudsy.yaml` gives the same output.

| Preset | Style |
|---|---|
| `csharp/dotnet-runtime` | The defaults plus inline accessor bodies |
| `csharp/google` | 2 spaces, 100 columns, K&R braces |
| `csharp/csharpier-compat` | CSharpier 1.x layout |
| `csharp/stylecop` | StyleCop.Analyzers layout (blank lines, `)` placement, empty bodies) and its matching rules |
| `json/prettier-compat`, `yaml/prettier-compat` | Prettier-like (width 80) |
| `toml/taplo-compat` | taplo's defaults |
| `xml/csharpier-compat` | CSharpier 1.x's XML defaults |

Without `extends` every language uses Sudsy's defaults (C#: Microsoft's layout) and existing `.editorconfig` keys apply; presets exist only where they set something. Details: [docs/formatting/presets.md](docs/formatting/presets.md).

## Configuration

```yaml
extends: [preset:csharp/google, preset:json/prettier-compat]
exclude: ["**/Generated/**"]
analysis: standard            # fast | standard | deep
csharp:
  format: { line_width: 120 }
  lint:
    rules:
      no-empty-catch: error
overrides:
  - files: ["tests/**"]
    csharp: { lint: { rules: { async-suffix: "off" } } }
```

`sudsy config print` shows the resolved config and where each value came from. A JSON Schema is in [schemas/sudsy.schema.json](schemas/sudsy.schema.json). Reference: [docs/config/sudsy-yaml.md](docs/config/sudsy-yaml.md), [.editorconfig mapping](docs/config/editorconfig.md).

## Editor setup

The VS Code extension runs `sudsy lsp` and gives diagnostics, quick fixes, fix all and formatting. Format on save is your choice, per language:

```json
{
  "[csharp]": { "editor.defaultFormatter": "Coox.sudsy", "editor.formatOnSave": true },
  "[json]": { "editor.defaultFormatter": "Coox.sudsy", "editor.formatOnSave": true },
  "[yaml]": { "editor.defaultFormatter": "Coox.sudsy", "editor.formatOnSave": true },
  "editor.codeActionsOnSave": { "source.fixAll.sudsy": "explicit" }
}
```

Any editor with an LSP client can start `sudsy lsp` (stdio). See [docs/editor/vscode.md](docs/editor/vscode.md) and [docs/editor/lsp.md](docs/editor/lsp.md).

## Documentation

[docs/README.md](docs/README.md) indexes everything: architecture, per-language formatting options, the rule engine and built-in rules, pattern rules, plugins, performance, CI and release. The rule reference is also built as a searchable site ([docs/development/site.md](docs/development/site.md)). Planned and deliberately skipped work: [docs/roadmap.md](docs/roadmap.md). Changes: [CHANGELOG.md](CHANGELOG.md).

## License and contributing

MIT, copyright Maia Coox ([LICENSE](LICENSE)); test and benchmark inputs from other projects are listed in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). Contributions need a DCO sign-off; see [CONTRIBUTING.md](CONTRIBUTING.md).
