{"id":27250,"library":"prettier-plugin-embed","title":"Prettier Plugin Embed","description":"A configurable Prettier plugin for formatting embedded languages (SQL, XML, PHP, markdown, CSS, etc.) in JavaScript/TypeScript template literals. Version 0.5.1, active development with frequent releases. Unlike Prettier's built-in 'auto' mode, it allows per-language control, custom block comments/tags for language detection, and opt-out per tag. Ships TypeScript types. Supports additional languages beyond Prettier defaults, with options for indentation and formatting behavior.","status":"active","version":"0.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/Sec-ant/prettier-plugin-embed","tags":["javascript","prettier","plugin","prettier-plugin","embed","embedded","embedded-language","format","typescript"],"install":[{"cmd":"npm install prettier-plugin-embed","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-embed","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-embed","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin runs as a Prettier plugin","package":"prettier","optional":false}],"imports":[{"note":"Default import is the plugin itself. Use with Prettier's 'plugins' array.","wrong":"const prettierPluginEmbed = require('prettier-plugin-embed')","symbol":"prettier-plugin-embed","correct":"import prettierPluginEmbed from 'prettier-plugin-embed'"},{"note":"EmbedOptions is a TypeScript type; use 'import type' in TS projects.","wrong":"import { EmbedOptions } from 'prettier-plugin-embed'","symbol":"EmbedOptions","correct":"import type { EmbedOptions } from 'prettier-plugin-embed'"},{"note":"Use the imported module, not a string, when using Prettier API programmatically.","wrong":"plugins: ['prettier-plugin-embed']","symbol":"options","correct":"plugins: [prettierPluginEmbed]"}],"quickstart":{"code":"// .prettierrc.js\nmodule.exports = {\n  plugins: [require('prettier-plugin-embed')],\n  // Optional: configure embedded languages\n  embeddedLanguageFormatting: 'off', // disable built-in to avoid conflicts\n  embed: {\n    // Enable SQL formatting in template literals tagged with sql\n    tags: ['sql'],\n    // Or use comments: /** sql */ `SELECT * FROM users`\n    comments: ['sql'],\n  },\n};\n\n// Example file: example.js\nconst sql = 'SELECT * FROM users WHERE id = 1';\n// After formatting, SQL in template literals tagged with sql is formatted\nconst query = sql`SELECT * FROM users WHERE id = 1`;\n","lang":"javascript","description":"Shows basic setup: install plugin, add to Prettier config, enable formatting for SQL template literals tagged with 'sql'."},"warnings":[{"fix":"Remove any usage of throwIfPluginIsNotFound from your Prettier config.","message":"In v0.4.14, throwIfPluginIsNotFound option was removed; language plugin checks now silently skip missing plugins.","severity":"breaking","affected_versions":">=0.4.14"},{"fix":"Set embeddedLanguageFormatting: 'off' in Prettier config to avoid conflicts.","message":"If using Prettier's built-in embedded language formatting ('auto'), this plugin may interfere. Disable built-in with 'embeddedLanguageFormatting: off'.","severity":"gotcha","affected_versions":""},{"fix":"Ensure your template literals have a tag (e.g., sql`...`) or a block comment (/* sql */ `...`).","message":"The plugin only formats template literals that are tagged with a recognized tag or preceded by a block comment. Untagged template literals are not formatted.","severity":"gotcha","affected_versions":""},{"fix":"Remove the option from your Prettier config.","message":"In v0.4.14, the 'throwIfPluginIsNotFound' option was removed; using it will cause an error.","severity":"deprecated","affected_versions":">=0.4.14"},{"fix":"Review tag configuration; if using tags in options, they are now matched by identifier name as well as call expressions.","message":"In v0.5.0, support for CallExpression as shorthand tag was added; existing configs for non-shorthand tags might need adjustment.","severity":"breaking","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install the required parser, e.g., npm i -D prettier-plugin-sql","cause":"Missing underlying Prettier parser for an embedded language (e.g., SQL).","error":"Error: Plugin parse error: Cannot find module 'prettier-plugin-sql'"},{"fix":"Ensure Prettier version >= 2.3.0. Use 'embeddedLanguageFormatting' (not 'embeddedLanguageFormat').","cause":"Using a Prettier version that doesn't support the option, or option is misspelled.","error":"[WARNING] Ignored unknown option: embeddedLanguageFormatting"},{"fix":"Use 'import prettierPluginEmbed from 'prettier-plugin-embed'' and add to 'plugins' array as a member.","cause":"Importing the plugin as a function instead of an object.","error":"TypeError: prettierPluginEmbed is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}