spire-plugin-prettier

raw JSON →
5.0.8 verified Sat Apr 25 auth: no javascript

Prettier plugin for the Spire monorepo toolchain. Current stable version is 5.0.8, released November 2022. Cadence is tied to Spire major releases, with patch releases roughly monthly. Key differentiators: integrates Prettier into Spire's hook system (setup, precommit, run) and provides opinionated defaults for config and ignore files, while allowing customization via options like `prettierConfig`, `autosetPrettierConfig`, and `glob`. Alternative to manual Prettier setup in Spire-based monorepos. Requires peer dependency `spire` ^4.0.0 || ^5.0.0 and Node >=12.20.

error Error: Cannot find module 'spire-plugin-prettier'
cause spire-plugin-prettier not installed or not in node_modules.
fix
Run npm install --save-dev spire-plugin-prettier
error Invalid plugin configuration. Expected array or string.
cause Wrong format in spire.config.js; plugin must be a string or tuple.
fix
Use plugins: ['spire-plugin-prettier'] or plugins: [['spire-plugin-prettier', {}]]
error Spire: plugin 'spire-plugin-prettier' requires a peer dependency 'spire' but none was installed.
cause Missing peer dependency spire.
fix
Install spire: npm install --save-dev spire
breaking Node engine >=12.20 required. Older Node versions will fail.
fix Upgrade Node to v12.20 or later.
breaking Peer dependency spire must be ^4.0.0 || ^5.0.0. Mismatch causes install failures.
fix Install compatible spire version: npm install spire@^5.0.0
gotcha If allowCustomConfig is false but user has a .prettierrc file, the plugin throws an error.
fix Set allowCustomConfig: true or remove .prettierrc.
gotcha autosetPrettierConfig true modifies package.json on install; may cause unintended changes in CI.
fix Set autosetPrettierConfig: false and manually manage prettier config.
deprecated Prettier 2.x is used; Prettier 3.x may break plugin compatibility (untested).
fix Check if plugin supports prettier v3; if not, pin prettier to v2.
npm install spire-plugin-prettier
yarn add spire-plugin-prettier
pnpm add spire-plugin-prettier

Installs and configures spire-plugin-prettier, adds format command, and shows usage with npm script and npx.

// Install dependencies
npm install --save-dev spire spire-plugin-prettier

// Create spire.config.js
module.exports = {
  plugins: [
    ['spire-plugin-prettier', {
      command: 'format',
      prettierConfig: './config.js',
      autosetPrettierConfig: true,
    }]
  ]
};

// Add script to package.json
"scripts": {
  "format": "spire format"
}

// Run formatting
npm run format

// Or use npx
npx spire format --write 'src/**/*.js'