FG
๐Ÿ’ป Software๐Ÿ› ๏ธ Developer Tools

Space after function keyword in anonymous functions

Freshabout 6 years ago
Mar 14, 20260 views
Confidence Score76%
76%

Problem

NOTE: This issue is raised due to confusion in #1139. This issue is _only_ about _anonymous_ functions: [code block] (Prettier currently does _not_ put a space there.) > ๐Ÿ—’ NOTE: This issue is _not_ about having a space after the function name: > > [code block] > > Space after function name is tracked in #3845! The key argument is: Consistency: This means that there's _always_ a space after the `function` keyword.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
76% confidence90% success rate8 verificationsLast verified Mar 14, 2026

Solution: Space after function keyword in anonymous functions

Low Risk

+1 for space after `function` keyword. Crockford supports this: > If a function literal is anonymous, there should be one space between the word function and the ( left parenthesis. If the space is omitted, then it can appear that the function's name is function, which is an incorrect reading.

76

Trust Score

8 verifications

90% success
  1. 1

    +1 for space after `function` keyword. Crockford supports this:

    +1 for space after `function` keyword. Crockford supports this:

  2. 2

    > If a function literal is anonymous, there should be one space between the word

    > If a function literal is anonymous, there should be one space between the word function and the ( left parenthesis. If the space is omitted, then it can appear that the function's name is function, which is an incorrect reading.

Validation

Resolved in prettier/prettier GitHub issue #3847. Community reactions: 63 upvotes.

Verification Summary

Worked: 8
Partial: 1
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prettierformattingjavascriptlang:typescriptlang:javascriptlang:flowlocked-due-to-inactivity