{"name":"@dprint/formatter","version":"0.4.0","keywords":["dprint","formatter","wasm"],"author":{"name":"David Sherret"},"license":"MIT","_id":"@dprint/formatter@0.4.0","homepage":"https://github.com/dprint/js-formatter#readme","bugs":{"url":"https://github.com/dprint/js-formatter/issues"},"dist":{"shasum":"6bcc62e2cd18739ae82e2767921461d52d6ccf1b","tarball":"http://registry-npm.ywwl.com/@dprint/formatter/download/@dprint/formatter-0.4.0.tgz","fileCount":109,"integrity":"sha512-PwzfZS0axDbECrgff7R3EMt0robHC+k8wF8wg7NhcxTLGiQ+ZyFUBF0TrRWaswCXilv+PFtw8S1lyUzFF2iPtA==","signatures":[{"sig":"MEYCIQDnH32rY0RXRTf7OVAY+Ihcah6WAxMzIMBLEKeUWQSQnQIhANt5qM6TJtBaLIHv7H40mVisEpHmT3mtsXfCe2tJOuIh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":95530,"size":13824,"noattachment":false,"key":"/@dprint/formatter/-/@dprint/formatter-0.4.0.tgz"},"main":"./script/mod.js","types":"./script/mod.d.ts","module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"}},"gitHead":"627d2d7620156d1f1a7556131ba9ff91ff43c11d","scripts":{"test":"node test_runner.js"},"_npmUser":{"name":"dsherret","email":"dsherret@gmail.com"},"repository":{"url":"git+https://github.com/dprint/js-formatter.git","type":"git"},"_npmVersion":"10.7.0","description":"Wasm formatter for dprint plugins.","directories":{},"_nodeVersion":"20.15.0","_hasShrinkwrap":false,"devDependencies":{"undici":"^4.12.1","picocolors":"^1.0.0","@types/node":"^20.9.0","@deno/shim-deno-test":"~0.5.0"},"_npmOperationalInternal":{"tmp":"tmp/formatter_0.4.0_1719785252728_0.8317046457183142","host":"s3://npm-registry-packages"},"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### 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":1719785252899,"maintainers":[{"name":"dsherret","email":"dsherret@gmail.com"}],"_cnpm_publish_time":1719785252899,"dist-tags":{"latest":"0.6.0"}}