🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

prettier-plugin-space-before-function-paren

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-space-before-function-paren

A prettier plugin to add a space before function parentheses for function definitions (but not function calls) in JS. **Requires Prettier 3.0.0 or later.**

Source
npmnpm
Version
0.0.3
Version published
Weekly downloads
1.3K
48.41%
Maintainers
2
Weekly downloads
 
Created
Source

prettier-plugin-space-before-function-paren

A prettier plugin to add a space before function parentheses for function definitions (but not function calls) in JS. Requires Prettier 3.0.0 or later.

Installation

npm install -D prettier prettier-plugin-space-before-function-paren

Configuration

There are no config options for this plugin. All you need to do is actually include it in your Prettier config:

{
	"plugins": ["prettier-plugin-space-before-function-paren"]
}

What this plugin changes

Function declaration

function test(a, b) {
	return a + b;
}

becomes:

function test (a, b) {
	return a + b;
}

Async function declaration

async function test(a, b) {
	return a + b;
}

becomes:

async function test (a, b) {
	return a + b;
}

Class methods

class Foo {
	method(a, b) {
		return a + b;
	}
}

becomes:

class Foo {
	method (a, b) {
		return a + b;
	}
}

Async class methods

class Foo {
	async method(a, b) {
		return a + b;
	}
}

becomes:

class Foo {
	async method (a, b) {
		return a + b;
	}
}

Static class methods

class Foo {
	static method(a, b) {
		return a + b;
	}
}

becomes:

class Foo {
	static method (a, b) {
		return a + b;
	}
}

Class getters

class Foo {
	get foo() {
		return true;
	}
}

becomes:

class Foo {
	get foo () {
		return true;
	}
}

Class setters

class Foo {
	set foo(value) {
		this._foo = value;
	}
}

becomes:

class Foo {
	set foo (value) {
		this._foo = value;
	}
}

Generator functions

function* test() {
	yield 1;
}

becomes:

function* test () {
	yield 1;
}

What remains unchanged

Function calls

test(1, 2);

becomes:

test(1, 2);

Arrow function

const add = (a, b) => a + b;

becomes:

const add = (a, b) => a + b;

Anonymous functions

Prettier already handles this case.

const add = function(a, b) {
	return a + b;
};

becomes:

const add = function (a, b) {
	return a + b;
};

Status

Current version is a proof of concept, please try it out and give feedback!

FAQs

Package last updated on 16 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts