FG
💻 Software🛠️ Developer Tools

Parentheses around single parameter arrow functions / Add support for arrow-parens property

Fresh3 days ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

Hey ! It will be great to add an option to disable auto remove of parenthesis when there is only one argument in an arrow function. Most of professional projects configure their way since it's the default eslint behaviour. Here is a Eslint Link : http://eslint.org/docs/rules/arrow-parens [code block]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Enable Arrow Function Parentheses Support in Prettier

Medium Risk

Prettier currently removes parentheses around single-parameter arrow functions by default, which can conflict with team coding standards that prefer explicit parentheses for clarity and consistency. This behavior is not configurable within Prettier, leading to discrepancies with ESLint configurations that allow for such options.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update Prettier Configuration

    Add a configuration option to Prettier to support keeping parentheses around single parameter arrow functions. This will align Prettier's behavior with common ESLint configurations.

    javascript
    module.exports = { arrowParens: 'always' };
  2. 2

    Modify ESLint Configuration

    Ensure that the ESLint configuration is set to enforce the same rule for consistency across the project. Update the ESLint configuration file to include the arrow-parens rule.

    javascript
    module.exports = { rules: { 'arrow-parens': ['error', 'always'] } };
  3. 3

    Run Prettier and ESLint

    After updating the configurations, run Prettier and ESLint on the codebase to ensure that the changes are applied correctly and that there are no formatting errors.

    bash
    npx prettier --write . && npx eslint .
  4. 4

    Review Code Changes

    Review the changes made by Prettier to ensure that all single-parameter arrow functions now have parentheses. Confirm that the code adheres to the new formatting rules.

    bash
    git diff

Validation

To confirm the fix worked, check that all single-parameter arrow functions in the codebase retain their parentheses after running Prettier. Additionally, ensure that ESLint does not report any errors related to the arrow-parens rule.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prettierformattingjavascripttype:option-requeststatus:has-prlang:javascript