{"_id":"@dprint/formatter@0.6.0","bugs":{"url":"https://github.com/dprint/js-formatter/issues"},"dist":{"shasum":"d5a0c31937e88d26727ff683af45e418af9ed97e","tarball":"http://registry-npm.ywwl.com/@dprint/formatter/download/@dprint/formatter-0.6.0.tgz","fileCount":123,"integrity":"sha512-otnYh2jmGWbekYkAd4xiF416lpdZwNCbhkDrLQcAanvvutp0PhTNSJrwJ4DKBEu6xtP36NUX70t9YQw3oC/ONg==","signatures":[{"sig":"MEYCIQDyguGHj98x1Y2swequk4l8HBn5wJr276WjraBhXZwXjAIhAMBY8b+tXr4ByOWArcglIPE7DOg89fxbsGuK7ESJvmd8","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC1nBdBmala1fi4x+PE/dKk4ydasEKjz/Fd0Qs0ypBUiQIgIPUzwDq1I8lu/T/12pXqg8/zAt4wfGBXW6XBxBTydms="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dprint%2fformatter@0.6.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":156905,"size":23055,"noattachment":false,"key":"/@dprint/formatter/-/@dprint/formatter-0.6.0.tgz"},"main":"./script/mod.js","name":"@dprint/formatter","types":"./script/mod.d.ts","author":{"name":"David Sherret"},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"}},"gitHead":"d313bb045a75606fdf0b42384707e8299302ab3a","license":"MIT","scripts":{"test":"node test_runner.js"},"version":"0.6.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"439403a8-7dc1-4219-9632-6f91647d68d3"}},"homepage":"https://github.com/dprint/js-formatter#readme","keywords":["dprint","formatter","wasm"],"repository":{"url":"git+https://github.com/dprint/js-formatter.git","type":"git"},"_npmVersion":"11.19.0","description":"Wasm formatter for dprint plugins.","directories":{},"maintainers":[{"name":"dsherret","email":"dsherret@gmail.com"}],"_nodeVersion":"24.21.0","_hasShrinkwrap":false,"devDependencies":{"undici":"^4.12.1","picocolors":"^1.0.0","@types/node":"^25","@dprint/json":"^0.21.1","@dprint/markdown":"^0.20.0","@dprint/typescript":"^0.95.13","@deno/shim-deno-test":"~0.5.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/formatter_0.6.0_1791672623476_0.1534378122044251"},"readme":"# dprint - JS Formatter\n\n[![CI](https://github.com/dprint/js-formatter/workflows/CI/badge.svg)](https://github.com/dprint/js-formatter/actions?query=workflow%3ACI)\n[![npm version](https://badge.fury.io/js/%40dprint%2Fformatter.svg)](https://badge.fury.io/js/%40dprint%2Fformatter)\n[![JSR](https://jsr.io/badges/@dprint/formatter)](https://jsr.io/@dprint/formatter)\n\nJS formatter for dprint Wasm plugins.\n\n## Setup\n\nDeno:\n\n```sh\ndeno add npm:@dprint/formatter\n```\n\nNode.js:\n\n```sh\nnpm i @dprint/formatter\n```\n\n## Use\n\nThe context API allows you to manage multiple plugins with shared configuration and automatic plugin selection based on file type:\n\n```ts\nimport { createContext } from \"@dprint/formatter\";\nimport * as json from \"@dprint/json\";\nimport * as markdown from \"@dprint/markdown\";\nimport * as typescript from \"@dprint/typescript\";\nimport fs from \"node:fs\";\n\nconst context = createContext({\n  // global config\n  indentWidth: 2,\n  lineWidth: 80,\n});\n\n// note: some plugins might have a getBuffer() export instead\ncontext.addPlugin(fs.readFileSync(typescript.getPath()), {\n  semiColons: \"asi\",\n});\ncontext.addPlugin(fs.readFileSync(json.getPath()));\ncontext.addPlugin(fs.readFileSync(markdown.getPath()));\n\nconsole.log(context.formatText({\n  filePath: \"config.json\",\n  fileText: \"{\\\"a\\\":1}\",\n}));\n\nconsole.log(context.formatText({\n  filePath: \"app.ts\",\n  fileText: \"const x=1\",\n}));\n```\n\nThe context also handles host formatting automatically, so embedded code blocks (like JSON in Markdown) will be formatted by the appropriate plugin.\n\n### WASI plugins\n\nPlugins compiled with a toolchain that needs a WASI libc (ex. .NET, Go) are provided the same sandboxed subset of WASI preview 1 as the dprint CLI. That is the clocks, sleeping, random bytes, and writing text to stdout/stderr (which is written to stderr). There are no environment variables, arguments, or file system access.\n\n### Plugin output\n\nText a plugin writes to stdout or stderr is written to stderr by default. Provide an `onOutput` function to capture or ignore it instead:\n\n```ts\nconst context = createContext(globalConfig, {\n  onOutput: (text) => console.error(text),\n});\n```\n\nThe same option is accepted by `createFromBuffer`, `createFromWasmModule`, and `createStreaming`.\n\n### Plugin NPM Packages\n\nNote: In the future I will ensure plugins are published to JSR as well.\n\n- [@dprint/json](https://www.npmjs.com/package/@dprint/json)\n- [@dprint/typescript](https://www.npmjs.com/package/@dprint/typescript)\n- [@dprint/markdown](https://www.npmjs.com/package/@dprint/markdown)\n- [@dprint/toml](https://www.npmjs.com/package/@dprint/toml)\n- [@dprint/dockerfile](https://www.npmjs.com/package/@dprint/dockerfile)\n- [@dprint/biome](https://www.npmjs.com/package/@dprint/biome)\n- [@dprint/oxc](https://www.npmjs.com/package/@dprint/oxc)\n- [@dprint/mago](https://www.npmjs.com/package/@dprint/mago)\n- [@dprint/ruff](https://www.npmjs.com/package/@dprint/ruff)\n","publish_time":1791672623565,"_cnpm_publish_time":1791672623565,"dist-tags":{"latest":"0.6.0"}}