{"_id":"@alloc/formatly","_rev":"2-16e6c6e566aea950b4bc83410abd5f13","name":"@alloc/formatly","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@alloc/formatly","version":"0.1.0","author":{"name":"Alec Larson"},"license":"MIT","_id":"@alloc/formatly@0.1.0","maintainers":[{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"}],"contributors":[{"name":"Joshua Goldberg"}],"homepage":"https://github.com/aleclarson/formatly#readme","bugs":{"url":"https://github.com/aleclarson/formatly/issues"},"bin":{"formatly":"bin/index.mjs"},"dist":{"shasum":"f2112ea9cf1dc47f9f5db73b17b7c51b56d9da95","tarball":"https://registry.npmjs.org/@alloc/formatly/-/formatly-0.1.0.tgz","fileCount":19,"integrity":"sha512-2d4Ghup/m9uRlHtSY8KVSy4pYA7eQ8rF7DD7WprumQIqVvSrPIbR90/zqh+H8jW+zwyx2eJAEheQRehCaWcIWw==","signatures":[{"sig":"MEUCIQDGpAOX9ucttVpxH/fu3Yn8jUKfbLpa9NGd8D8056VwSgIgc52nlxxLyciOA4aUiCMPZ446J1RSFl+bLM6H3tApGtM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25509},"main":"./lib/index.js","type":"module","_from":"file:alloc-formatly-0.1.0.tgz","types":"./lib/index.d.ts","engines":{"node":">=18.3.0"},"scripts":{"tsc":"tsc","lint":"eslint . --max-warnings 0","test":"vitest","build":"tsup","format":"prettier .","lint:md":"markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line","lint:knip":"knip","lint:packages":"pnpm dedupe --check","lint:spelling":"cspell \"**\" \".github/**/*\""},"_npmUser":{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"},"_resolved":"/private/var/folders/4l/lb2f5pj1221bm7d89gh08fx80000gn/T/0486377d912c9359c18ed83da6a184f1/alloc-formatly-0.1.0.tgz","_integrity":"sha512-2d4Ghup/m9uRlHtSY8KVSy4pYA7eQ8rF7DD7WprumQIqVvSrPIbR90/zqh+H8jW+zwyx2eJAEheQRehCaWcIWw==","repository":{"url":"git+https://github.com/aleclarson/formatly.git","type":"git"},"_npmVersion":"10.9.2","description":"Formats your code with whatever formatter your project is already using. 🧼","directories":{},"lint-staged":{"*":"prettier --ignore-unknown --write"},"_nodeVersion":"23.7.0","_hasShrinkwrap":false,"devDependencies":{"knip":"5.43.1","tsup":"8.3.5","husky":"9.1.7","cspell":"8.17.1","eslint":"9.19.0","vitest":"3.0.0","prettier":"3.4.2","@eslint/js":"9.19.0","release-it":"18.1.1","typescript":"5.7.2","@types/node":"22.13.0","lint-staged":"15.4.0","markdownlint":"0.37.2","eslint-plugin-n":"17.15.1","markdownlint-cli":"0.44.0","console-fail-test":"0.5.0","eslint-plugin-yml":"1.16.0","typescript-eslint":"8.23.0","prettier-plugin-sh":"0.14.0","sentences-per-line":"0.3.0","@vitest/coverage-v8":"3.0.0","eslint-plugin-jsdoc":"50.6.1","eslint-plugin-jsonc":"2.19.1","eslint-plugin-regexp":"2.7.0","@vitest/eslint-plugin":"1.1.20","prettier-plugin-curly":"0.3.1","eslint-plugin-markdown":"5.1.0","eslint-plugin-package-json":"0.23.0","eslint-plugin-perfectionist":"4.8.0","prettier-plugin-packagejson":"2.5.6","@types/eslint-plugin-markdown":"2.0.2","@release-it/conventional-changelog":"10.0.0","@eslint-community/eslint-plugin-eslint-comments":"4.4.1"},"_npmOperationalInternal":{"tmp":"tmp/formatly_0.1.0_1739553836307_0.7367551552158647","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@alloc/formatly","version":"0.1.1","author":{"name":"Alec Larson"},"license":"MIT","_id":"@alloc/formatly@0.1.1","maintainers":[{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"}],"contributors":[{"name":"Joshua Goldberg"}],"homepage":"https://github.com/aleclarson/formatly#readme","bugs":{"url":"https://github.com/aleclarson/formatly/issues"},"bin":{"formatly":"bin/index.mjs"},"dist":{"shasum":"587e8510c724abf06fd75bf17fd41083b40f1645","tarball":"https://registry.npmjs.org/@alloc/formatly/-/formatly-0.1.1.tgz","fileCount":19,"integrity":"sha512-7iU71l8YpAICWk3weXqZvKIi+bL+D/FdTvhlhNoVzBTuVpbA/KqnbcyfZWQGxiGfZf1dnC3Z8vdCHntOB/kSyQ==","signatures":[{"sig":"MEYCIQDzyU1k7N9imR1JT6vzP1yRYi/UTi2Fbodyg5GrW7vANQIhANlOXA+pKH/K5uHGSzhsDweQpz4rVksJ7oMoZmoCsN6L","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27205},"main":"./lib/index.js","type":"module","_from":"file:alloc-formatly-0.1.1.tgz","types":"./lib/index.d.ts","engines":{"node":">=18.3.0"},"scripts":{"tsc":"tsc","lint":"eslint . --max-warnings 0","test":"vitest","build":"tsup","format":"prettier .","lint:md":"markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line","lint:knip":"knip","lint:packages":"pnpm dedupe --check","lint:spelling":"cspell \"**\" \".github/**/*\""},"_npmUser":{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"},"_resolved":"/private/var/folders/4l/lb2f5pj1221bm7d89gh08fx80000gn/T/fef24420be524f47fad9a92cb846cf49/alloc-formatly-0.1.1.tgz","_integrity":"sha512-7iU71l8YpAICWk3weXqZvKIi+bL+D/FdTvhlhNoVzBTuVpbA/KqnbcyfZWQGxiGfZf1dnC3Z8vdCHntOB/kSyQ==","repository":{"url":"git+https://github.com/aleclarson/formatly.git","type":"git"},"_npmVersion":"10.9.2","description":"Formats your code with whatever formatter your project is already using. 🧼","directories":{},"lint-staged":{"*":"prettier --ignore-unknown --write"},"_nodeVersion":"23.7.0","_hasShrinkwrap":false,"devDependencies":{"knip":"5.43.1","tsup":"8.3.5","husky":"9.1.7","cspell":"8.17.1","eslint":"9.19.0","vitest":"3.0.0","prettier":"3.4.2","@eslint/js":"9.19.0","release-it":"18.1.1","typescript":"5.7.2","@types/node":"22.13.0","lint-staged":"15.4.0","markdownlint":"0.37.2","eslint-plugin-n":"17.15.1","markdownlint-cli":"0.44.0","console-fail-test":"0.5.0","eslint-plugin-yml":"1.16.0","typescript-eslint":"8.23.0","prettier-plugin-sh":"0.14.0","sentences-per-line":"0.3.0","@vitest/coverage-v8":"3.0.0","eslint-plugin-jsdoc":"50.6.1","eslint-plugin-jsonc":"2.19.1","eslint-plugin-regexp":"2.7.0","@vitest/eslint-plugin":"1.1.20","prettier-plugin-curly":"0.3.1","eslint-plugin-markdown":"5.1.0","eslint-plugin-package-json":"0.23.0","eslint-plugin-perfectionist":"4.8.0","prettier-plugin-packagejson":"2.5.6","@types/eslint-plugin-markdown":"2.0.2","@release-it/conventional-changelog":"10.0.0","@eslint-community/eslint-plugin-eslint-comments":"4.4.1"},"_npmOperationalInternal":{"tmp":"tmp/formatly_0.1.1_1739555634611_0.08733517272978752","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@alloc/formatly","version":"0.1.2","description":"Formats your code with whatever formatter your project is already using. 🧼","repository":{"type":"git","url":"git+https://github.com/aleclarson/formatly.git"},"license":"MIT","author":{"name":"Alec Larson"},"contributors":[{"name":"Joshua Goldberg"}],"type":"module","main":"./lib/index.js","bin":{"formatly":"bin/index.mjs"},"lint-staged":{"*":"prettier --ignore-unknown --write"},"devDependencies":{"@eslint-community/eslint-plugin-eslint-comments":"4.4.1","@eslint/js":"9.19.0","@release-it/conventional-changelog":"10.0.0","@types/eslint-plugin-markdown":"2.0.2","@types/node":"22.13.0","@vitest/coverage-v8":"3.0.0","@vitest/eslint-plugin":"1.1.20","console-fail-test":"0.5.0","cspell":"8.17.1","eslint":"9.19.0","eslint-plugin-jsdoc":"50.6.1","eslint-plugin-jsonc":"2.19.1","eslint-plugin-markdown":"5.1.0","eslint-plugin-n":"17.15.1","eslint-plugin-package-json":"0.23.0","eslint-plugin-perfectionist":"4.8.0","eslint-plugin-regexp":"2.7.0","eslint-plugin-yml":"1.16.0","husky":"9.1.7","knip":"5.43.1","lint-staged":"15.4.0","markdownlint":"0.37.2","markdownlint-cli":"0.44.0","prettier":"3.4.2","prettier-plugin-curly":"0.3.1","prettier-plugin-packagejson":"2.5.6","prettier-plugin-sh":"0.14.0","release-it":"18.1.1","sentences-per-line":"0.3.0","tsup":"8.3.5","typescript":"5.7.2","typescript-eslint":"8.23.0","vitest":"3.0.0"},"engines":{"node":">=18.3.0"},"scripts":{"build":"tsup","format":"prettier .","lint":"eslint . --max-warnings 0","lint:knip":"knip","lint:md":"markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line","lint:packages":"pnpm dedupe --check","lint:spelling":"cspell \"**\" \".github/**/*\"","test":"vitest","tsc":"tsc"},"_id":"@alloc/formatly@0.1.2","types":"./lib/index.d.ts","bugs":{"url":"https://github.com/aleclarson/formatly/issues"},"homepage":"https://github.com/aleclarson/formatly#readme","_integrity":"sha512-ogUPOdSpdRLoog2wL60hLVK0ukfTICqbLk96DapIQxtXCkz5LyvoN8dfOC1FrtSiGcRuEj6HRnN3NbTfAhCa+Q==","_resolved":"/private/var/folders/4l/lb2f5pj1221bm7d89gh08fx80000gn/T/1d346266ad2b572e8cd7265e1d8e7a57/alloc-formatly-0.1.2.tgz","_from":"file:alloc-formatly-0.1.2.tgz","_nodeVersion":"23.7.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-ogUPOdSpdRLoog2wL60hLVK0ukfTICqbLk96DapIQxtXCkz5LyvoN8dfOC1FrtSiGcRuEj6HRnN3NbTfAhCa+Q==","shasum":"c7b87e5734a5cb3cc8b5479b50f2cd518c723d3b","tarball":"https://registry.npmjs.org/@alloc/formatly/-/formatly-0.1.2.tgz","fileCount":19,"unpackedSize":27274,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIETQlokCl66Nr+YoIDUBo1w/nC4KsgWqllMFopDfhdWTAiEAx1ey/Qn+kR/s6wPVzy2/IlSdmg/Y1Gy2e1TCOeml8eM="}]},"_npmUser":{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"},"directories":{},"maintainers":[{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/formatly_0.1.2_1739562646353_0.6329179021567328"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-14T17:23:56.180Z","modified":"2025-02-14T19:50:46.822Z","0.1.0":"2025-02-14T17:23:56.532Z","0.1.1":"2025-02-14T17:53:54.796Z","0.1.2":"2025-02-14T19:50:46.615Z"},"bugs":{"url":"https://github.com/aleclarson/formatly/issues"},"author":{"name":"Alec Larson"},"license":"MIT","homepage":"https://github.com/aleclarson/formatly#readme","repository":{"type":"git","url":"git+https://github.com/aleclarson/formatly.git"},"description":"Formats your code with whatever formatter your project is already using. 🧼","contributors":[{"name":"Joshua Goldberg"}],"maintainers":[{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"}],"readme":"<h1 align=\"center\">Formatly</h1>\n\n<p align=\"center\">\n\tFormats your code with whatever formatter your project is already using. \n\t🧼\n</p>\n\n<p align=\"center\">\n\t<!-- prettier-ignore-start -->\n\t<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\t<a href=\"#contributors\" target=\"_blank\"><img alt=\"👪 All Contributors: 1\" src=\"https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-1-21bb42.svg\" /></a>\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\t<!-- prettier-ignore-end -->\n\t<a href=\"https://github.com/JoshuaKGoldberg/formatly/blob/main/.github/CODE_OF_CONDUCT.md\" target=\"_blank\"><img alt=\"🤝 Code of Conduct: Kept\" src=\"https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42\" /></a>\n\t<a href=\"https://codecov.io/gh/JoshuaKGoldberg/formatly\" target=\"_blank\"><img alt=\"🧪 Coverage\" src=\"https://img.shields.io/codecov/c/github/JoshuaKGoldberg/formatly?label=%F0%9F%A7%AA%20coverage\" /></a>\n\t<a href=\"https://github.com/JoshuaKGoldberg/formatly/blob/main/LICENSE.md\" target=\"_blank\"><img alt=\"📝 License: MIT\" src=\"https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg\"></a>\n\t<a href=\"http://npmjs.com/package/formatly\"><img alt=\"📦 npm version\" src=\"https://img.shields.io/npm/v/formatly?color=21bb42&label=%F0%9F%93%A6%20npm\" /></a>\n\t<img alt=\"💪 TypeScript: Strict\" src=\"https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg\" />\n</p>\n\n> [!NOTE]\n> This is a fork of `formatly` with no dependencies. It also searches parent directories for formatter-specific config files, rather than only the current directory.\n\n## Usage\n\n`formatly` can automatically detect and format with:\n\n- [Biome](https://biomejs.dev/formatter)\n- [deno fmt](https://docs.deno.com/runtime/reference/cli/fmt)\n- [dprint](https://dprint.dev)\n- [Prettier](https://prettier.io)\n\nSee [Formatter Detection](#formatter-detection) for details on how they are detected.\n\n### CLI\n\n```shell\nnpx formatly <files>\n```\n\n`formatly` takes in any number of glob patterns.\nIt will then:\n\n1. Detect which [supported formatter](#supported-formatters) is configured in the repository\n2. Pass those glob patterns directly to the formatter\n\nFor example, to match all directories and folders in the current directory:\n\n```shell\nnpx formatly *\n```\n\nTo match only `.ts` files in `src/`:\n\n```shell\nnpx formatly \"src/**/*.ts\"\n```\n\n### Node.js API\n\n```shell\nnpm i formatly\n```\n\nThe `formatly` package exports the functions used by the `formatly` CLI.\n\n#### `formatly`\n\nRuns formatting on any number of glob pattern `string`s.\n\n```ts\nimport { formatly } from \"@alloc/formatly\";\n\nawait formatly([\"*\"]);\n```\n\nParameters:\n\n1. `patterns: string[]` _(required)_: any number of glob patterns\n2. `options: FormatlyOptions` _(optional)_:\n   - `cwd: string` _(optional)_: working directory, if not `\".\"`\n\nResolves with a `FormatlyReport`, which is either:\n\n- `FormatlyReportError` if a formatter could not be determined, which an object containing:\n  - `ran: false`\n- `FormatlyReportResult` if a formatter could be determined, which is an object containing:\n  - `formatter: Formatter`: as resolved by [`resolveFormatter`](#resolveformatter)\n  - `ran: true`\n  - `result: Result`, the [`Result`](https://github.com/sindresorhus/execa/blob/main/docs/api.md#result) from running the formatter with [`execa`](https://github.com/sindresorhus/execa)\n\nFor example, to run formatting on TypeScript source files in a child directory and check the result:\n\n```ts\nimport { formatly } from \"@alloc/formatly\";\n\nconst report = await formatly([\"src/**/*.ts\"], { cwd: \"path/to/project\" });\n\nif (!report.ran) {\n\tconsole.error(\"Could not determine formatter.\");\n\treturn;\n}\n\nconst { formatter, result } = report;\n\nif (result.code) {\n\tconsole.error(`Error running ${formatter.runner}:`, result.stderr);\n} else {\n\tconsole.log(`Formatted with ${formatter.name}! 🧼`);\n}\n```\n\n#### `resolveFormatter`\n\nDetects which of the [supported formatters](#supported-formatters) to use for a directory. Parent directories are searched if necessary. The search ends when a directory with `.git` folder is encountered.\n\n```ts\nimport { resolveFormatter } from \"@alloc/formatly\";\n\nconst formatter = await resolveFormatter();\n\n// {\n//   name: \"Prettier\",\n//   runner: \"npx prettier --write\",\n//   testers: { ... }\n// }\nconsole.log(formatter);\n```\n\nParameters:\n\n1. `cwd: string` _(optional)_: working directory, if not `\".\"`\n\nResolves with either:\n\n- `undefined` if a formatter could not be detected\n- `Formatter` if one can be found, which is an object containing:\n  - `name: string`: English name of the formatter\n  - `runner: string`: the shell command used to run the formatter\n  - `testers: object`: strings and regular expressions used to test for the formatter\n\n## Formatter Detection\n\nFormatters are detected based on the first match from, in order:\n\n1. Existence of the formatter's default supported config file name\n2. The formatter's name in a `package.json` `fmt` or `format` script\n3. Well-known root-level `package.json` key\n\n### Supported Formatters\n\n| Formatter                                                   | Config File                                                                                             | Package Key  | Script     |\n| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------ | ---------- |\n| [Biome](https://biomejs.dev/formatter)                      | [Configure Biome](https://biomejs.dev/guides/configure-biome)                                           |              | `biome`    |\n| [deno fmt](https://docs.deno.com/runtime/reference/cli/fmt) | [Deno Configuration > Formatting](https://docs.deno.com/runtime/fundamentals/configuration/#formatting) |              | `deno`     |\n| [dprint](https://dprint.dev)                                | [dprint setup](https://dprint.dev/setup)                                                                |              | `dprint`   |\n| [Prettier](https://prettier.io)                             | [Prettier Configuration File](https://prettier.io/docs/en/configuration)                                | `\"prettier\"` | `prettier` |\n\n> Want support for a formatter not mentioned here?\n> Great!\n> Please [file a feature request GitHub issue](https://github.com/JoshuaKGoldberg/formatly/issues/new?assignees=&labels=type%3A+feature&projects=&template=03-feature.yml&title=%F0%9F%9A%80+Feature%3A+%3Cshort+description+of+the+feature%3E).\n> 🙏\n\n## Why?\n\nFormatly is a tool for any developer tool that creates files for users.\nIf your tool creates, say, a config file that users are meant to check into their repository, you probably want that file to be formatted per the user's preference.\nBut there are several popular formatters in use today: it's not enough to just call to `prettier.format`.\n\nFormatly takes away the burden of\n\n- Detecting which formatter -if any- a userland project is using\n- Calling to that formatter's API(s) to format the file\n\n### Does Formatly replace Prettier, etc.?\n\nNo.\nFormatly is a detection + wrapping layer around formatters such as Prettier.\nUserland projects still need to configure a formatter themselves.\n\n## Development\n\nSee [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).\nThanks! 💖\n\n## Contributors\n\n<!-- spellchecker: disable -->\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"http://www.joshuakgoldberg.com/\"><img src=\"https://avatars.githubusercontent.com/u/3335181?v=4?s=100\" width=\"100px;\" alt=\"Josh Goldberg ✨\"/><br /><sub><b>Josh Goldberg ✨</b></sub></a><br /><a href=\"https://github.com/JoshuaKGoldberg/formatly/commits?author=JoshuaKGoldberg\" title=\"Code\">💻</a> <a href=\"#content-JoshuaKGoldberg\" title=\"Content\">🖋</a> <a href=\"#ideas-JoshuaKGoldberg\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"#infra-JoshuaKGoldberg\" title=\"Infrastructure (Hosting, Build-Tools, etc)\">🚇</a> <a href=\"#maintenance-JoshuaKGoldberg\" title=\"Maintenance\">🚧</a> <a href=\"#projectManagement-JoshuaKGoldberg\" title=\"Project Management\">📆</a> <a href=\"#tool-JoshuaKGoldberg\" title=\"Tools\">🔧</a> <a href=\"https://github.com/JoshuaKGoldberg/formatly/commits?author=JoshuaKGoldberg\" title=\"Documentation\">📖</a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n<!-- spellchecker: enable -->\n\n<!-- You can remove this notice if you don't want it 🙂 no worries! -->\n\n> 💝 This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [`create` engine](https://create.bingo).\n","readmeFilename":"README.md"}