{"id":18924000,"url":"https://github.com/sane-fmt/sane-fmt","last_synced_at":"2025-04-15T12:32:18.135Z","repository":{"id":38325058,"uuid":"259005613","full_name":"sane-fmt/sane-fmt","owner":"sane-fmt","description":"Opinionated code formatter for TypeScript and JavaScript","archived":false,"fork":false,"pushed_at":"2024-02-25T09:07:05.000Z","size":1262,"stargazers_count":27,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T05:19:38.145Z","etag":null,"topics":["aur","deno","dprint","formatter","javascript","linux","macos","nodejs","opinionated","rust","sane-fmt","typescript","wasi","wasm","webassembly","windows"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sane-fmt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"khai96_","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://paypal.me/khai96x"]}},"created_at":"2020-04-26T10:47:19.000Z","updated_at":"2024-06-19T09:54:00.760Z","dependencies_parsed_at":"2023-11-23T22:32:57.369Z","dependency_job_id":"3b2dd7d2-ba7f-4985-aa68-a05d53adbe9c","html_url":"https://github.com/sane-fmt/sane-fmt","commit_stats":{"total_commits":1174,"total_committers":4,"mean_commits":293.5,"dds":"0.16269165247018735","last_synced_commit":"5289ac56a68c980962f1ad919dde09dc4a3c58ef"},"previous_names":[],"tags_count":197,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sane-fmt%2Fsane-fmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sane-fmt%2Fsane-fmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sane-fmt%2Fsane-fmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sane-fmt%2Fsane-fmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sane-fmt","download_url":"https://codeload.github.com/sane-fmt/sane-fmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249072405,"owners_count":21208182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aur","deno","dprint","formatter","javascript","linux","macos","nodejs","opinionated","rust","sane-fmt","typescript","wasi","wasm","webassembly","windows"],"created_at":"2024-11-08T11:05:14.286Z","updated_at":"2025-04-15T12:32:17.843Z","avatar_url":"https://github.com/sane-fmt.png","language":"Rust","funding_links":["https://patreon.com/khai96_","https://paypal.me/khai96x"],"categories":[],"sub_categories":[],"readme":"# sane-fmt\n\n[![GitHub Actions Status](https://github.com/sane-fmt/sane-fmt/workflows/Test/badge.svg)](https://github.com/sane-fmt/sane-fmt/actions)\n[![Travis Build Status](https://travis-ci.org/sane-fmt/sane-fmt.svg?branch=master)](https://travis-ci.org/sane-fmt/sane-fmt)\n\nOpinionated code formatter for TypeScript and JavaScript.\n\n## Rules\n\n* Prefer single quotes.\n* No semicolons.\n* Trailing commas for multi-line.\n* No function parentheses for arrow function with single argument.\n* Multi-line union and intersection use consistent leading separator.\n\n[Preview](https://git.io/JflcU).\n\nRead [exports/sane-fmt.typescript.json](https://git.io/JmNWN), [src/rules.rs](https://git.io/JmNlv), and [tests/rules.rs](https://git.io/JflOp) for more information.\n\n## Installation\n\n### Download prebuilt binaries\n\nGo to [the release page](https://github.com/sane-fmt/sane-fmt/releases).\n\n### From [crates.io](https://crates.io)\n\n```sh\ncargo install sane-fmt\n```\n\n**Links:**\n  * https://crates.io/crates/sane-fmt/\n  * https://docs.rs/crate/sane-fmt/\n  * https://lib.rs/crates/sane-fmt/\n\n### From [NPM](https://www.npmjs.com)\n\n#### WASM (all platform)\n\n```sh\nnpm i -g @sane-fmt/wasm32-wasi\n```\n\n**Links:**\n  * https://www.npmjs.com/package/@sane-fmt/wasm32-wasi\n\n#### Native binaries\n\nThe WASM package while work on all platform, it is slow to start. For better speed, install one of the following packages instead:\n\n**For Linux:**\n  * [@sane-fmt/x86_64-unknown-linux-gnu](https://www.npmjs.com/package/@sane-fmt/x86_64-unknown-linux-gnu)\n  * [@sane-fmt/x86_64-unknown-linux-musl](https://www.npmjs.com/package/@sane-fmt/x86_64-unknown-linux-musl)\n\n**For macOS:**\n  * [@sane-fmt/x86_64-apple-darwin](https://www.npmjs.com/package/@sane-fmt/x86_64-apple-darwin)\n\n**For Windows:**\n  * [@sane-fmt/x86_64-pc-windows-gnu](https://www.npmjs.com/package/@sane-fmt/x86_64-pc-windows-gnu)\n  * [@sane-fmt/x86_64-pc-windows-msvc](https://www.npmjs.com/package/@sane-fmt/x86_64-pc-windows-msvc)\n\n### From [Deno Registry](https://deno.land/x)\n\n**Links:**\n  * https://deno.land/x/sane_fmt/\n  * https://github.com/sane-fmt/deno/\n  * https://sane-fmt.github.io/deno/\n\n### From [Arch User Repository](https://aur.archlinux.org)\n\n#### Download source and compile\n\n```sh\nparu -S sane-fmt\n```\n\n**Links:**\n  * https://aur.archlinux.org/packages/sane-fmt/\n\n#### Download prebuilt binary\n\n```sh\nparu -S sane-fmt-bin\n```\n\n**Links:**\n  * https://aur.archlinux.org/packages/sane-fmt-bin/\n\n### Use with [Dprint](https://dprint.dev/)\n\nIf you already have Dprint, you can skip installing `sane-fmt` binary. Create a `dprint.json` file with the following content:\n\n```json\n{\n  \"$schema\": \"https://dprint.dev/schemas/v0.json\",\n  \"projectType\": \"openSource\",\n  \"extends\": \"https://github.com/sane-fmt/sane-fmt/raw/master/exports/sane-fmt.dprint.json\",\n  \"includes\": [\n    \"**/*.js\",\n    \"**/*.ts\"\n  ],\n  \"excludes\": [\n    \".git\",\n    \"node_modules\"\n  ],\n  \"plugins\": [\n    \"https://plugins.dprint.dev/typescript-${DPRINT_TYPESCRIPT_VERSION}.wasm\"\n  ]\n}\n```\n\n**Notes:**\n  * Replace `master` in the `\"extends\"` line above with appropriate sane-fmt version.\n  * Replace `${DPRINT_TYPESCRIPT_VERSION}` above with appropriate [dprint-plugin-typescript](https://github.com/dprint/dprint-plugin-typescript) version.\n\n**See also:**\n  * [sane-fmt.dprint.json](https://github.com/sane-fmt/sane-fmt/blob/master/exports/sane-fmt.dprint.json): Dprint configuration with rules of sane-fmt.\n  * [sane-fmt.typescript.json](https://github.com/sane-fmt/sane-fmt/blob/master/exports/sane-fmt.typescript.json): Configuration of dprint-plugin-typescript with rules of sane-fmt.\n\n## Usage\n\n### Format all TypeScript and JavaScript files\n\n```sh\nsane-fmt --write\n```\n\nThis command would reformat all TypeScript and JavaScript files.\n\n### Check for all TypeScript and JavaScript files\n\n```sh\nsane-fmt\n```\n\nThis command would check all TypeScript and JavaScript files.\n\n### Format only some files\n\n```sh\nsane-fmt --write foo.ts bar.js\n```\n\nThis command would only reformat `foo.ts` and `bar.js`.\n\n### Format all TypeScript and JavaScript files in a directory\n\n```sh\nsane-fmt --write src/\n```\n\nThis command would reformat all TypeScript and JavaScript files within `src/` directory.\n\n### Check all TypeScript and JavaScript files in a list\n\nEach line of `list.txt` is a path to a TypeScript/JavaScript file.\n\n```sh\nsane-fmt --include=list.txt\n```\n\n### Check all TypeScript and JavaScript files from a Git repo\n\n```sh\ngit ls-files | grep -Ei '\\.(js|ts)$' | sane-fmt --include=-\n```\n\n### GitHub Actions\n\n`sane-fmt` also provides a convenient way to integrate with GitHub Actions. To use it, simply add `--log-format=github-actions`, like so:\n\n```sh\nsane-fmt --log-format=github-actions --details=diff\n```\n\nWhen this command is executed within a GitHub Actions runner, it will:\n* Annotates unformatted files.\n* Group diffs by file names (if `--details=diff`).\n* Export `total`, `changed`, and `unchanged` as outputs.\n\n_Recommendation:_ This [action](https://github.com/sane-fmt/action) will install `sane-fmt` and execute it for you.\n\n### Print help message\n\n```sh\nsane-fmt --help\n```\n\n## Shell Completions\n\nIf you installed sane-fmt [via the AUR](#from-arch-user-repository), completions for bash, fish, and zsh are already installed for you.\n\nShell completion files are located in [./exports directory of this repo](https://github.com/sane-fmt/sane-fmt/tree/master/exports) or [the Release Page](https://github.com/sane-fmt/sane-fmt/releases) with name in form of `completion.\u003cextension\u003e` where `\u003cextension\u003e` is corresponding file extension of target language. Install them to appropriate locations in your filesystem to use.\n\n## Become a Patron\n\n[My Patreon Page](https://patreon.com/khai96_).\n\n## Frequently Asked Questions\n\n### What is this program?\n\n`sane-fmt` is an opinionated code formatter for TypeScript and JavaScript powered by [dprint](https://dprint.dev/). You can think of it as a portable Dprint config file that is always up-to-date.\n\n### What is the point of this program?\n\nI want to apply a single, consistent formatting for all my codes regardless of environment without complex tooling.\n\nI have considered using Prettier or Dprint, but that would mean having to set up Node.js even in non-Node.js environments. I also don't like copying my config files back-and-forth to update them.\n\nOn the other hand, setting up `sane-fmt` is simple: just download the binary.\n\n### How to customize the rules?\n\nCustomization is antithetical to the purpose of this project, and as such, the `sane-fmt` command does not have customization capability.\n\nHowever, if you still want a copy of `sane-fmt` with your own customized rules, do one of the following:\n* Use [`sane-fmt`](https://docs.rs/sane-fmt) as a library crate.\n* Fork this project.\n* Just use [dprint](#use-with-dprint).\n\n## License\n\n[MIT](https://git.io/Jflmx) © [Hoàng Văn Khải](https://ksxgithub.github.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsane-fmt%2Fsane-fmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsane-fmt%2Fsane-fmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsane-fmt%2Fsane-fmt/lists"}