{"id":20267,"library":"plop-prettier","title":"plop-prettier","description":"Plop action type that runs Prettier on files added via plop's add action. Version 3.0.0 requires plop 3.x and Prettier 1.17+. Released intermittently. Differentiator: integrates Prettier formatting directly into plop generators via 'pretty-add' action, reducing boilerplate.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/alsiola/plop-prettier","tags":["javascript","plop","prettier","typescript"],"install":[{"cmd":"npm install plop-prettier","lang":"bash","label":"npm"},{"cmd":"yarn add plop-prettier","lang":"bash","label":"yarn"},{"cmd":"pnpm add plop-prettier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for formatting","package":"prettier","optional":false}],"imports":[{"note":"Loaded via plop.load, not direct require; used in plopfile.js.","wrong":"require('plop-prettier')","symbol":"plop-prettier","correct":"plop.load('plop-prettier')"},{"note":"The action type string is 'pretty-add', not the package name.","wrong":"type: 'prettier' or type: 'plop-prettier'","symbol":"pretty-add action type","correct":"type: 'pretty-add'"},{"note":"Options are passed as a single object directly to plop.load, not nested under a 'prettier' key.","wrong":"plop.load('plop-prettier', { prettier: { tabWidth: 4 } })","symbol":"options object","correct":"plop.load('plop-prettier', { tabWidth: 4 })"}],"quickstart":{"code":"// plopfile.js\nmodule.exports = function (plop) {\n  plop.load('plop-prettier', { tabWidth: 4 });\n\n  plop.setGenerator('component', {\n    description: 'Create a new component',\n    prompts: [\n      {\n        type: 'input',\n        name: 'name',\n        message: 'Component name'\n      }\n    ],\n    actions: [\n      {\n        type: 'pretty-add',\n        path: 'src/{{pascalCase name}}/{{pascalCase name}}.js',\n        template: `import React from 'react';\n\nconst {{pascalCase name}} = () => {\n  return <div>{{pascalCase name}}</div>;\n};\n\nexport default {{pascalCase name}};`\n      }\n    ]\n  });\n};","lang":"javascript","description":"Example plopfile loading plop-prettier and using 'pretty-add' action type to create a component file."},"warnings":[{"fix":"Upgrade plop to version 3 or higher.","message":"plop-prettier 3.x requires plop 3.x; not compatible with plop 2.x.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Pass options directly: plop.load('plop-prettier', { tabWidth: 4 }) instead of plop.load('plop-prettier', { prettier: { tabWidth: 4 } })","message":"Style of pass options changed from nested to flat object in v3.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use exactly 'pretty-add' as the action type.","message":"Action type 'pretty-add' is not 'prettier-add' or 'prettyadd'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a separate prettier script or hook to format existing files.","message":"The 'pretty-add' action only runs Prettier on the content; it does not auto-format existing files.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install prettier","cause":"Missing peer dependency 'prettier'","error":"Error: Cannot find module 'prettier'"},{"fix":"Ensure plop.load is called inside the plopfile export function: module.exports = function(plop) { plop.load('plop-prettier'); }","cause":"Trying to run plop.load in a context where plop is not the plop API object","error":"TypeError: plop.load is not a function"},{"fix":"Use 'pretty-add' (with underscore, not hyphen).","cause":"Using wrong action type string","error":"Unrecognized action type: prettier-add"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}