Registry / devops / prettier-plugin-space-before-function-paren

prettier-plugin-space-before-function-paren

JSON →
library0.1.0jsnpmunverified

A Prettier plugin that adds a space before function parentheses for function definitions (not function calls) in JavaScript and TypeScript. Current stable version 0.1.0, released as a proof of concept. Release cadence: irregular, early stage. Differentiator: unlike Prettier's deprecated space-before-function-paren option, this plugin works with Prettier 3.0.0+ and only targets definitions, not calls. Requires Prettier >=3.0.0 as a peer dependency.

npm install prettier-plugin-space-before-function-paren
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-SP
P
prettier-plugin-space-before-function-paren
devopsjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

space-before-function-paren (plugin)
// In prettier config "plugins": ["prettier-plugin-space-before-function-paren"]
"plugins": ["prettier-plugin-space-before-function-paren"] // Omitting from plugins array: plugin won't apply
Plugin is added via Prettier config's plugins array, not imported in code.
Plugin as ES module (for programmatic use)
import plugin from 'prettier-plugin-space-before-function-paren'; await prettier.format(code, { plugins: [plugin], parser: 'babel' });
const plugin = require('prettier-plugin-space-before-function-paren');
Plugin is ESM-only as of v0.1.0 due to Prettier 3's ESM support. require() may fail in CommonJS contexts.
Type import (TypeScript)
import type { Plugin } from 'prettier'; const plugin: Plugin = require('prettier-plugin-space-before-function-paren');
import plugin from 'prettier-plugin-space-before-function-paren'; // TypeScript may not resolve types
Plugin does not ship TypeScript types; use Prettier's Plugin type if needed.

Shows installation, config, and formatting: adds space before function paren in definitions only.

// 1. Install // npm install -D prettier prettier-plugin-space-before-function-paren // 2. Configure .prettierrc { "plugins": ["prettier-plugin-space-before-function-paren"] } // 3. Input file (input.js) function foo() {} // 4. Format with Prettier // npx prettier --write input.js // 5. Output (input.js) function foo () {}
Debug
Known issues
breakingPlugin requires Prettier 3.0.0 or later. Older versions will fail to load the plugin.
fix
Upgrade Prettier to >=3.0.0
affects: <0.1.0
gotchaPlugin is a proof of concept; may not cover all edge cases (e.g., async functions, generators, TypeScript).
fix
Test thoroughly with your codebase. Report issues on GitHub.
affects: 0.1.0
gotchaPlugin does not affect function calls, only function definitions. Misconfiguration may lead to inconsistent formatting if expectations differ.
fix
Use Prettier's space-before-function-paren option (deprecated) for function calls if needed, but note incompatibility.
affects: 0.1.0
gotchaWhen used alongside other JS/TS Prettier plugins, they may conflict. Use prettier-plugin-merge to preserve changes.
fix
Install prettier-plugin-merge and add it to the end of your plugins array.
affects: 0.1.0
deprecatedPrettier's built-in space-before-function-paren option is deprecated in Prettier 3. This plugin is a replacement specifically for function definitions.
fix
Use this plugin or remove the deprecated option entirely.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-space-before-function-paren'
Plugin not installed or not in node_modules.
fix
Run 'npm install -D prettier prettier-plugin-space-before-function-paren'
error: Couldn't resolve plugin "prettier-plugin-space-before-function-paren". The plugin is probably not installed or is incompatible with Prettier version.
Prettier version <3.0.0 or plugin not in config correctly.
fix
Update Prettier to >=3.0.0 and ensure plugin is in plugins array.
TypeError: prettier.resolveConfig is not a function or its return value is not iterable
CommonJS require of plugin in Prettier 3 ESM context.
fix
Use ES module syntax (import) or ensure Prettier is running in ESM mode.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: requires Prettier 3.0.0 or later to function as a plugin.
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-space-before-function-paren — npm install prettier-plugin-space-before-function-paren · libregistry